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

#include "nimbase.h"
typedef struct Tbitset258006 Tbitset258006;
typedef struct TGenericSeq TGenericSeq;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
struct  TGenericSeq  {
NI len;
NI reserved;
};
typedef N_NIMCALL_PTR(void, TY3489) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, TY3494) (void* p);
struct  TNimType  {
NI size;
NU8 kind;
NU8 flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY3489 marker;
TY3494 deepcopy;
};
struct  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct Tbitset258006 {
  TGenericSeq Sup;
  NI8 data[SEQ_DECL_SIZE];
};
N_NIMCALL(void, TMP2964)(void* p, NI op);
N_NIMCALL(void*, newSeq)(TNimType* typ, NI len);
N_NIMCALL(void, unsureAsgnRef)(void** dest, void* src);
extern TNimType NTI106; /* int8 */
TNimType NTI258006; /* TBitSet */
N_NIMCALL(void, TMP2964)(void* p, NI op) {
	Tbitset258006* a;
	NI LOC1;
	a = (Tbitset258006*)p;
	LOC1 = 0;
	for (LOC1 = 0; LOC1 < a->Sup.len; LOC1++) {
	}
}

N_NIMCALL(void, bitsetinit_258009)(Tbitset258006** b, NI length) {
	unsureAsgnRef((void**) (&(*b)), (Tbitset258006*) newSeq((&NTI258006), ((NI) (length))));
}

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

N_NIMCALL(void, bitsetdiff_258019)(Tbitset258006** x, Tbitset258006* y) {
	{
		NI i_258266;
		NI HEX3Atmp_258268;
		NI res_258271;
		i_258266 = 0;
		HEX3Atmp_258268 = 0;
		HEX3Atmp_258268 = ((*x) ? ((*x)->Sup.len-1) : -1);
		res_258271 = ((NI) 0);
		{
			while (1) {
				if (!(res_258271 <= HEX3Atmp_258268)) goto LA3;
				i_258266 = res_258271;
				(*x)->data[i_258266] = (NI8)((*x)->data[i_258266] & (NI8)((NU8) ~(y->data[i_258266])));
				res_258271 += ((NI) 1);
			} LA3: ;
		}
	}
}

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

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

N_NIMCALL(NIM_BOOL, bitsetequals_258048)(Tbitset258006* x, Tbitset258006* y) {
	NIM_BOOL result;
{	result = 0;
	{
		NI i_258341;
		NI HEX3Atmp_258343;
		NI res_258346;
		i_258341 = 0;
		HEX3Atmp_258343 = 0;
		HEX3Atmp_258343 = (x ? (x->Sup.len-1) : -1);
		res_258346 = ((NI) 0);
		{
			while (1) {
				if (!(res_258346 <= HEX3Atmp_258343)) goto LA3;
				i_258341 = res_258346;
				{
					if (!!((x->data[i_258341] == y->data[i_258341]))) goto LA6;
					result = NIM_FALSE;
					goto BeforeRet;
				}
				LA6: ;
				res_258346 += ((NI) 1);
			} LA3: ;
		}
	}
	result = NIM_TRUE;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(void, bitsetintersect_258029)(Tbitset258006** x, Tbitset258006* y) {
	{
		NI i_258316;
		NI HEX3Atmp_258318;
		NI res_258321;
		i_258316 = 0;
		HEX3Atmp_258318 = 0;
		HEX3Atmp_258318 = ((*x) ? ((*x)->Sup.len-1) : -1);
		res_258321 = ((NI) 0);
		{
			while (1) {
				if (!(res_258321 <= HEX3Atmp_258318)) goto LA3;
				i_258316 = res_258321;
				(*x)->data[i_258316] = (NI8)((*x)->data[i_258316] & y->data[i_258316]);
				res_258321 += ((NI) 1);
			} LA3: ;
		}
	}
}

N_NIMCALL(void, bitsetunion_258014)(Tbitset258006** x, Tbitset258006* y) {
	{
		NI i_258241;
		NI HEX3Atmp_258243;
		NI res_258246;
		i_258241 = 0;
		HEX3Atmp_258243 = 0;
		HEX3Atmp_258243 = ((*x) ? ((*x)->Sup.len-1) : -1);
		res_258246 = ((NI) 0);
		{
			while (1) {
				if (!(res_258246 <= HEX3Atmp_258243)) goto LA3;
				i_258241 = res_258246;
				(*x)->data[i_258241] = (NI8)((*x)->data[i_258241] | y->data[i_258241]);
				res_258246 += ((NI) 1);
			} LA3: ;
		}
	}
}

N_NIMCALL(void, bitsetsymdiff_258024)(Tbitset258006** x, Tbitset258006* y) {
	{
		NI i_258291;
		NI HEX3Atmp_258293;
		NI res_258296;
		i_258291 = 0;
		HEX3Atmp_258293 = 0;
		HEX3Atmp_258293 = ((*x) ? ((*x)->Sup.len-1) : -1);
		res_258296 = ((NI) 0);
		{
			while (1) {
				if (!(res_258296 <= HEX3Atmp_258293)) goto LA3;
				i_258291 = res_258296;
				(*x)->data[i_258291] = (NI8)((*x)->data[i_258291] ^ y->data[i_258291]);
				res_258296 += ((NI) 1);
			} LA3: ;
		}
	}
}
NIM_EXTERNC N_NOINLINE(void, compiler_bitsetsInit000)(void) {
}

NIM_EXTERNC N_NOINLINE(void, compiler_bitsetsDatInit000)(void) {
NTI258006.size = sizeof(Tbitset258006*);
NTI258006.kind = 24;
NTI258006.base = (&NTI106);
NTI258006.flags = 2;
NTI258006.marker = TMP2964;
}

