/* Generated by Nim Compiler v0.10.2 */
/*   (c) 2014 Andreas Rumpf */
/* The generated code is subject to the original license. */
#define NIM_INTBITS 32
#include "nimbase.h"
typedef struct tbitset283012 tbitset283012;
typedef struct TGenericSeq TGenericSeq;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
struct  TGenericSeq  {
NI len;
NI reserved;
};
typedef N_NIMCALL_PTR(void, TY3089) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, TY3094) (void* p);
struct  TNimType  {
NI size;
NU8 kind;
NU8 flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY3089 marker;
TY3094 deepcopy;
};
struct  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct tbitset283012 {
  TGenericSeq Sup;
  NI8 data[SEQ_DECL_SIZE];
};
N_NIMCALL(void, TMP2831)(void* p, NI op);
N_NIMCALL(void*, newSeq)(TNimType* typ, NI len);
N_NIMCALL(void, unsureAsgnRef)(void** dest, void* src);
extern TNimType NTI110; /* int8 */
TNimType NTI283012; /* TBitSet */
N_NIMCALL(void, TMP2831)(void* p, NI op) {
	tbitset283012* a;
	NI LOC1;
	a = (tbitset283012*)p;
	LOC1 = 0;
	for (LOC1 = 0; LOC1 < a->Sup.len; LOC1++) {
	}
}

N_NIMCALL(void, bitsetinit_283021)(tbitset283012** b, NI length) {
	unsureAsgnRef((void**) (&(*b)), (tbitset283012*) newSeq((&NTI283012), length));
}

N_NIMCALL(void, bitsetincl_283061)(tbitset283012** x, NI64 elem) {
	(*x)->data[(NI64)(elem / IL64(8))] = (NI8)((*x)->data[(NI64)(elem / IL64(8))] | ((NI8)(NU8)(NU)((NI)((NU32)(1) << (NU32)(((NI) ((NI64)(elem % IL64(8)))))))));
}

N_NIMCALL(void, bitsetdiff_283037)(tbitset283012** x, tbitset283012* y) {
	{
		NI i_283305;
		NI HEX3Atmp_283307;
		NI res_283310;
		i_283305 = 0;
		HEX3Atmp_283307 = 0;
		HEX3Atmp_283307 = ((*x)->Sup.len-1);
		res_283310 = 0;
		{
			while (1) {
				if (!(res_283310 <= HEX3Atmp_283307)) goto LA3;
				i_283305 = res_283310;
				(*x)->data[i_283305] = (NI8)((*x)->data[i_283305] & (NI8)((NU8) ~(y->data[i_283305])));
				res_283310 += 1;
			} LA3: ;
		}
	}
}

N_NIMCALL(NIM_BOOL, bitsetin_283077)(tbitset283012* x, NI64 e) {
	NIM_BOOL result;
	result = 0;
	result = !(((NI8)(x->data[(NI64)(e / IL64(8))] & ((NI8)(NU8)(NU)((NI)((NU32)(1) << (NU32)(((NI) ((NI64)(e % IL64(8))))))))) == ((NI8) 0)));
	return result;
}

N_NIMCALL(NIM_BOOL, bitsetcontains_283091)(tbitset283012* x, tbitset283012* y) {
	NIM_BOOL result;
	result = 0;
	{
		NI i_283461;
		NI HEX3Atmp_283463;
		NI res_283466;
		i_283461 = 0;
		HEX3Atmp_283463 = 0;
		HEX3Atmp_283463 = (x->Sup.len-1);
		res_283466 = 0;
		{
			while (1) {
				if (!(res_283466 <= HEX3Atmp_283463)) goto LA3;
				i_283461 = res_283466;
				{
					if (!!(((NI8)(x->data[i_283461] & (NI8)((NU8) ~(y->data[i_283461]))) == ((NI8) 0)))) goto LA6;
					result = NIM_FALSE;
					goto BeforeRet;
				}
				LA6: ;
				res_283466 += 1;
			} LA3: ;
		}
	}
	result = NIM_TRUE;
	BeforeRet: ;
	return result;
}

N_NIMCALL(NIM_BOOL, bitsetequals_283084)(tbitset283012* x, tbitset283012* y) {
	NIM_BOOL result;
	result = 0;
	{
		NI i_283422;
		NI HEX3Atmp_283424;
		NI res_283427;
		i_283422 = 0;
		HEX3Atmp_283424 = 0;
		HEX3Atmp_283424 = (x->Sup.len-1);
		res_283427 = 0;
		{
			while (1) {
				if (!(res_283427 <= HEX3Atmp_283424)) goto LA3;
				i_283422 = res_283427;
				{
					if (!!((x->data[i_283422] == y->data[i_283422]))) goto LA6;
					result = NIM_FALSE;
					goto BeforeRet;
				}
				LA6: ;
				res_283427 += 1;
			} LA3: ;
		}
	}
	result = NIM_TRUE;
	BeforeRet: ;
	return result;
}

N_NIMCALL(void, bitsetintersect_283053)(tbitset283012** x, tbitset283012* y) {
	{
		NI i_283383;
		NI HEX3Atmp_283385;
		NI res_283388;
		i_283383 = 0;
		HEX3Atmp_283385 = 0;
		HEX3Atmp_283385 = ((*x)->Sup.len-1);
		res_283388 = 0;
		{
			while (1) {
				if (!(res_283388 <= HEX3Atmp_283385)) goto LA3;
				i_283383 = res_283388;
				(*x)->data[i_283383] = (NI8)((*x)->data[i_283383] & y->data[i_283383]);
				res_283388 += 1;
			} LA3: ;
		}
	}
}

N_NIMCALL(void, bitsetunion_283029)(tbitset283012** x, tbitset283012* y) {
	{
		NI i_283266;
		NI HEX3Atmp_283268;
		NI res_283271;
		i_283266 = 0;
		HEX3Atmp_283268 = 0;
		HEX3Atmp_283268 = ((*x)->Sup.len-1);
		res_283271 = 0;
		{
			while (1) {
				if (!(res_283271 <= HEX3Atmp_283268)) goto LA3;
				i_283266 = res_283271;
				(*x)->data[i_283266] = (NI8)((*x)->data[i_283266] | y->data[i_283266]);
				res_283271 += 1;
			} LA3: ;
		}
	}
}

N_NIMCALL(void, bitsetsymdiff_283045)(tbitset283012** x, tbitset283012* y) {
	{
		NI i_283344;
		NI HEX3Atmp_283346;
		NI res_283349;
		i_283344 = 0;
		HEX3Atmp_283346 = 0;
		HEX3Atmp_283346 = ((*x)->Sup.len-1);
		res_283349 = 0;
		{
			while (1) {
				if (!(res_283349 <= HEX3Atmp_283346)) goto LA3;
				i_283344 = res_283349;
				(*x)->data[i_283344] = (NI8)((*x)->data[i_283344] ^ y->data[i_283344]);
				res_283349 += 1;
			} LA3: ;
		}
	}
}
NIM_EXTERNC N_NOINLINE(void, HEX00_bitsetsInit)(void) {
}

NIM_EXTERNC N_NOINLINE(void, HEX00_bitsetsDatInit)(void) {
NTI283012.size = sizeof(tbitset283012*);
NTI283012.kind = 24;
NTI283012.base = (&NTI110);
NTI283012.flags = 2;
NTI283012.marker = TMP2831;
}

