/* Generated by Nim Compiler v0.12.0 */
/*   (c) 2015 Andreas Rumpf */
/* The generated code is subject to the original license. */
#define NIM_INTBITS 32

#include "nimbase.h"
typedef struct Tbitset274012 Tbitset274012;
typedef struct TGenericSeq TGenericSeq;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
struct  TGenericSeq  {
NI len;
NI reserved;
};
typedef N_NIMCALL_PTR(void, TY3889) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, TY3894) (void* p);
struct  TNimType  {
NI size;
NU8 kind;
NU8 flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY3889 marker;
TY3894 deepcopy;
};
struct  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct Tbitset274012 {
  TGenericSeq Sup;
  NI8 data[SEQ_DECL_SIZE];
};
N_NIMCALL(void, TMP2924)(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 NTI274012; /* TBitSet */
N_NIMCALL(void, TMP2924)(void* p, NI op) {
	Tbitset274012* a;
	NI LOC1;
	a = (Tbitset274012*)p;
	LOC1 = 0;
	for (LOC1 = 0; LOC1 < a->Sup.len; LOC1++) {
	}
}

N_NIMCALL(void, bitsetinit_274021)(Tbitset274012** b, NI length) {
	unsureAsgnRef((void**) (&(*b)), (Tbitset274012*) newSeq((&NTI274012), ((NI) (length))));
}

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

N_NIMCALL(void, bitsetdiff_274037)(Tbitset274012** x, Tbitset274012* y) {
	{
		NI i_274301;
		NI HEX3Atmp_274303;
		NI res_274306;
		i_274301 = 0;
		HEX3Atmp_274303 = 0;
		HEX3Atmp_274303 = ((*x) ? ((*x)->Sup.len-1) : -1);
		res_274306 = ((NI) 0);
		{
			while (1) {
				if (!(res_274306 <= HEX3Atmp_274303)) goto LA3;
				i_274301 = res_274306;
				(*x)->data[i_274301] = (NI8)((*x)->data[i_274301] & (NI8)((NU8) ~(y->data[i_274301])));
				res_274306 += ((NI) 1);
			} LA3: ;
		}
	}
}

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

N_NIMCALL(NIM_BOOL, bitsetcontains_274091)(Tbitset274012* x, Tbitset274012* y) {
	NIM_BOOL result;
{	result = 0;
	{
		NI i_274465;
		NI HEX3Atmp_274467;
		NI res_274470;
		i_274465 = 0;
		HEX3Atmp_274467 = 0;
		HEX3Atmp_274467 = (x ? (x->Sup.len-1) : -1);
		res_274470 = ((NI) 0);
		{
			while (1) {
				if (!(res_274470 <= HEX3Atmp_274467)) goto LA3;
				i_274465 = res_274470;
				{
					if (!!(((NI8)(x->data[i_274465] & (NI8)((NU8) ~(y->data[i_274465]))) == ((NI8) 0)))) goto LA6;
					result = NIM_FALSE;
					goto BeforeRet;
				}
				LA6: ;
				res_274470 += ((NI) 1);
			} LA3: ;
		}
	}
	result = NIM_TRUE;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(NIM_BOOL, bitsetequals_274084)(Tbitset274012* x, Tbitset274012* y) {
	NIM_BOOL result;
{	result = 0;
	{
		NI i_274424;
		NI HEX3Atmp_274426;
		NI res_274429;
		i_274424 = 0;
		HEX3Atmp_274426 = 0;
		HEX3Atmp_274426 = (x ? (x->Sup.len-1) : -1);
		res_274429 = ((NI) 0);
		{
			while (1) {
				if (!(res_274429 <= HEX3Atmp_274426)) goto LA3;
				i_274424 = res_274429;
				{
					if (!!((x->data[i_274424] == y->data[i_274424]))) goto LA6;
					result = NIM_FALSE;
					goto BeforeRet;
				}
				LA6: ;
				res_274429 += ((NI) 1);
			} LA3: ;
		}
	}
	result = NIM_TRUE;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(void, bitsetintersect_274053)(Tbitset274012** x, Tbitset274012* y) {
	{
		NI i_274383;
		NI HEX3Atmp_274385;
		NI res_274388;
		i_274383 = 0;
		HEX3Atmp_274385 = 0;
		HEX3Atmp_274385 = ((*x) ? ((*x)->Sup.len-1) : -1);
		res_274388 = ((NI) 0);
		{
			while (1) {
				if (!(res_274388 <= HEX3Atmp_274385)) goto LA3;
				i_274383 = res_274388;
				(*x)->data[i_274383] = (NI8)((*x)->data[i_274383] & y->data[i_274383]);
				res_274388 += ((NI) 1);
			} LA3: ;
		}
	}
}

N_NIMCALL(void, bitsetunion_274029)(Tbitset274012** x, Tbitset274012* y) {
	{
		NI i_274260;
		NI HEX3Atmp_274262;
		NI res_274265;
		i_274260 = 0;
		HEX3Atmp_274262 = 0;
		HEX3Atmp_274262 = ((*x) ? ((*x)->Sup.len-1) : -1);
		res_274265 = ((NI) 0);
		{
			while (1) {
				if (!(res_274265 <= HEX3Atmp_274262)) goto LA3;
				i_274260 = res_274265;
				(*x)->data[i_274260] = (NI8)((*x)->data[i_274260] | y->data[i_274260]);
				res_274265 += ((NI) 1);
			} LA3: ;
		}
	}
}

N_NIMCALL(void, bitsetsymdiff_274045)(Tbitset274012** x, Tbitset274012* y) {
	{
		NI i_274342;
		NI HEX3Atmp_274344;
		NI res_274347;
		i_274342 = 0;
		HEX3Atmp_274344 = 0;
		HEX3Atmp_274344 = ((*x) ? ((*x)->Sup.len-1) : -1);
		res_274347 = ((NI) 0);
		{
			while (1) {
				if (!(res_274347 <= HEX3Atmp_274344)) goto LA3;
				i_274342 = res_274347;
				(*x)->data[i_274342] = (NI8)((*x)->data[i_274342] ^ y->data[i_274342]);
				res_274347 += ((NI) 1);
			} LA3: ;
		}
	}
}
NIM_EXTERNC N_NOINLINE(void, compiler_bitsetsInit000)(void) {
}

NIM_EXTERNC N_NOINLINE(void, compiler_bitsetsDatInit000)(void) {
NTI274012.size = sizeof(Tbitset274012*);
NTI274012.kind = 24;
NTI274012.base = (&NTI110);
NTI274012.flags = 2;
NTI274012.marker = TMP2924;
}

