/* 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 tbitset284012 tbitset284012;
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 tbitset284012 {
  TGenericSeq Sup;
  NI8 data[SEQ_DECL_SIZE];
};
N_NIMCALL(void, TMP2833)(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 NTI284012; /* TBitSet */
N_NIMCALL(void, TMP2833)(void* p, NI op) {
	tbitset284012* a;
	NI LOC1;
	a = (tbitset284012*)p;
	LOC1 = 0;
	for (LOC1 = 0; LOC1 < a->Sup.len; LOC1++) {
	}
}

N_NIMCALL(void, bitsetinit_284021)(tbitset284012** b, NI length) {
	unsureAsgnRef((void**) (&(*b)), (tbitset284012*) newSeq((&NTI284012), length));
}

N_NIMCALL(void, bitsetincl_284061)(tbitset284012** 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_284037)(tbitset284012** x, tbitset284012* y) {
	{
		NI i_284305;
		NI HEX3Atmp_284307;
		NI res_284310;
		i_284305 = 0;
		HEX3Atmp_284307 = 0;
		HEX3Atmp_284307 = ((*x)->Sup.len-1);
		res_284310 = 0;
		{
			while (1) {
				if (!(res_284310 <= HEX3Atmp_284307)) goto LA3;
				i_284305 = res_284310;
				(*x)->data[i_284305] = (NI8)((*x)->data[i_284305] & (NI8)((NU8) ~(y->data[i_284305])));
				res_284310 += 1;
			} LA3: ;
		}
	}
}

N_NIMCALL(NIM_BOOL, bitsetin_284077)(tbitset284012* 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_284091)(tbitset284012* x, tbitset284012* y) {
	NIM_BOOL result;
	result = 0;
	{
		NI i_284461;
		NI HEX3Atmp_284463;
		NI res_284466;
		i_284461 = 0;
		HEX3Atmp_284463 = 0;
		HEX3Atmp_284463 = (x->Sup.len-1);
		res_284466 = 0;
		{
			while (1) {
				if (!(res_284466 <= HEX3Atmp_284463)) goto LA3;
				i_284461 = res_284466;
				{
					if (!!(((NI8)(x->data[i_284461] & (NI8)((NU8) ~(y->data[i_284461]))) == ((NI8) 0)))) goto LA6;
					result = NIM_FALSE;
					goto BeforeRet;
				}
				LA6: ;
				res_284466 += 1;
			} LA3: ;
		}
	}
	result = NIM_TRUE;
	BeforeRet: ;
	return result;
}

N_NIMCALL(NIM_BOOL, bitsetequals_284084)(tbitset284012* x, tbitset284012* y) {
	NIM_BOOL result;
	result = 0;
	{
		NI i_284422;
		NI HEX3Atmp_284424;
		NI res_284427;
		i_284422 = 0;
		HEX3Atmp_284424 = 0;
		HEX3Atmp_284424 = (x->Sup.len-1);
		res_284427 = 0;
		{
			while (1) {
				if (!(res_284427 <= HEX3Atmp_284424)) goto LA3;
				i_284422 = res_284427;
				{
					if (!!((x->data[i_284422] == y->data[i_284422]))) goto LA6;
					result = NIM_FALSE;
					goto BeforeRet;
				}
				LA6: ;
				res_284427 += 1;
			} LA3: ;
		}
	}
	result = NIM_TRUE;
	BeforeRet: ;
	return result;
}

N_NIMCALL(void, bitsetintersect_284053)(tbitset284012** x, tbitset284012* y) {
	{
		NI i_284383;
		NI HEX3Atmp_284385;
		NI res_284388;
		i_284383 = 0;
		HEX3Atmp_284385 = 0;
		HEX3Atmp_284385 = ((*x)->Sup.len-1);
		res_284388 = 0;
		{
			while (1) {
				if (!(res_284388 <= HEX3Atmp_284385)) goto LA3;
				i_284383 = res_284388;
				(*x)->data[i_284383] = (NI8)((*x)->data[i_284383] & y->data[i_284383]);
				res_284388 += 1;
			} LA3: ;
		}
	}
}

N_NIMCALL(void, bitsetunion_284029)(tbitset284012** x, tbitset284012* y) {
	{
		NI i_284266;
		NI HEX3Atmp_284268;
		NI res_284271;
		i_284266 = 0;
		HEX3Atmp_284268 = 0;
		HEX3Atmp_284268 = ((*x)->Sup.len-1);
		res_284271 = 0;
		{
			while (1) {
				if (!(res_284271 <= HEX3Atmp_284268)) goto LA3;
				i_284266 = res_284271;
				(*x)->data[i_284266] = (NI8)((*x)->data[i_284266] | y->data[i_284266]);
				res_284271 += 1;
			} LA3: ;
		}
	}
}

N_NIMCALL(void, bitsetsymdiff_284045)(tbitset284012** x, tbitset284012* y) {
	{
		NI i_284344;
		NI HEX3Atmp_284346;
		NI res_284349;
		i_284344 = 0;
		HEX3Atmp_284346 = 0;
		HEX3Atmp_284346 = ((*x)->Sup.len-1);
		res_284349 = 0;
		{
			while (1) {
				if (!(res_284349 <= HEX3Atmp_284346)) goto LA3;
				i_284344 = res_284349;
				(*x)->data[i_284344] = (NI8)((*x)->data[i_284344] ^ y->data[i_284344]);
				res_284349 += 1;
			} LA3: ;
		}
	}
}
NIM_EXTERNC N_NOINLINE(void, HEX00_bitsetsInit)(void) {
}

NIM_EXTERNC N_NOINLINE(void, HEX00_bitsetsDatInit)(void) {
NTI284012.size = sizeof(tbitset284012*);
NTI284012.kind = 24;
NTI284012.base = (&NTI110);
NTI284012.flags = 2;
NTI284012.marker = TMP2833;
}

