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

#include "nimbase.h"
typedef struct Tbitset277012 Tbitset277012;
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 Tbitset277012 {
  TGenericSeq Sup;
  NI8 data[SEQ_DECL_SIZE];
};
N_NIMCALL(void, TMP2927)(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 NTI277012; /* TBitSet */
N_NIMCALL(void, TMP2927)(void* p, NI op) {
	Tbitset277012* a;
	NI LOC1;
	a = (Tbitset277012*)p;
	LOC1 = 0;
	for (LOC1 = 0; LOC1 < a->Sup.len; LOC1++) {
	}
}

N_NIMCALL(void, bitsetinit_277021)(Tbitset277012** b, NI length) {
	unsureAsgnRef((void**) (&(*b)), (Tbitset277012*) newSeq((&NTI277012), ((NI) (length))));
}

N_NIMCALL(void, bitsetincl_277061)(Tbitset277012** 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_277037)(Tbitset277012** x, Tbitset277012* y) {
	{
		NI i_277301;
		NI HEX3Atmp_277303;
		NI res_277306;
		i_277301 = 0;
		HEX3Atmp_277303 = 0;
		HEX3Atmp_277303 = ((*x) ? ((*x)->Sup.len-1) : -1);
		res_277306 = ((NI) 0);
		{
			while (1) {
				if (!(res_277306 <= HEX3Atmp_277303)) goto LA3;
				i_277301 = res_277306;
				(*x)->data[i_277301] = (NI8)((*x)->data[i_277301] & (NI8)((NU8) ~(y->data[i_277301])));
				res_277306 += ((NI) 1);
			} LA3: ;
		}
	}
}

N_NIMCALL(NIM_BOOL, bitsetin_277077)(Tbitset277012* 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_277091)(Tbitset277012* x, Tbitset277012* y) {
	NIM_BOOL result;
{	result = 0;
	{
		NI i_277465;
		NI HEX3Atmp_277467;
		NI res_277470;
		i_277465 = 0;
		HEX3Atmp_277467 = 0;
		HEX3Atmp_277467 = (x ? (x->Sup.len-1) : -1);
		res_277470 = ((NI) 0);
		{
			while (1) {
				if (!(res_277470 <= HEX3Atmp_277467)) goto LA3;
				i_277465 = res_277470;
				{
					if (!!(((NI8)(x->data[i_277465] & (NI8)((NU8) ~(y->data[i_277465]))) == ((NI8) 0)))) goto LA6;
					result = NIM_FALSE;
					goto BeforeRet;
				}
				LA6: ;
				res_277470 += ((NI) 1);
			} LA3: ;
		}
	}
	result = NIM_TRUE;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(NIM_BOOL, bitsetequals_277084)(Tbitset277012* x, Tbitset277012* y) {
	NIM_BOOL result;
{	result = 0;
	{
		NI i_277424;
		NI HEX3Atmp_277426;
		NI res_277429;
		i_277424 = 0;
		HEX3Atmp_277426 = 0;
		HEX3Atmp_277426 = (x ? (x->Sup.len-1) : -1);
		res_277429 = ((NI) 0);
		{
			while (1) {
				if (!(res_277429 <= HEX3Atmp_277426)) goto LA3;
				i_277424 = res_277429;
				{
					if (!!((x->data[i_277424] == y->data[i_277424]))) goto LA6;
					result = NIM_FALSE;
					goto BeforeRet;
				}
				LA6: ;
				res_277429 += ((NI) 1);
			} LA3: ;
		}
	}
	result = NIM_TRUE;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(void, bitsetintersect_277053)(Tbitset277012** x, Tbitset277012* y) {
	{
		NI i_277383;
		NI HEX3Atmp_277385;
		NI res_277388;
		i_277383 = 0;
		HEX3Atmp_277385 = 0;
		HEX3Atmp_277385 = ((*x) ? ((*x)->Sup.len-1) : -1);
		res_277388 = ((NI) 0);
		{
			while (1) {
				if (!(res_277388 <= HEX3Atmp_277385)) goto LA3;
				i_277383 = res_277388;
				(*x)->data[i_277383] = (NI8)((*x)->data[i_277383] & y->data[i_277383]);
				res_277388 += ((NI) 1);
			} LA3: ;
		}
	}
}

N_NIMCALL(void, bitsetunion_277029)(Tbitset277012** x, Tbitset277012* y) {
	{
		NI i_277260;
		NI HEX3Atmp_277262;
		NI res_277265;
		i_277260 = 0;
		HEX3Atmp_277262 = 0;
		HEX3Atmp_277262 = ((*x) ? ((*x)->Sup.len-1) : -1);
		res_277265 = ((NI) 0);
		{
			while (1) {
				if (!(res_277265 <= HEX3Atmp_277262)) goto LA3;
				i_277260 = res_277265;
				(*x)->data[i_277260] = (NI8)((*x)->data[i_277260] | y->data[i_277260]);
				res_277265 += ((NI) 1);
			} LA3: ;
		}
	}
}

N_NIMCALL(void, bitsetsymdiff_277045)(Tbitset277012** x, Tbitset277012* y) {
	{
		NI i_277342;
		NI HEX3Atmp_277344;
		NI res_277347;
		i_277342 = 0;
		HEX3Atmp_277344 = 0;
		HEX3Atmp_277344 = ((*x) ? ((*x)->Sup.len-1) : -1);
		res_277347 = ((NI) 0);
		{
			while (1) {
				if (!(res_277347 <= HEX3Atmp_277344)) goto LA3;
				i_277342 = res_277347;
				(*x)->data[i_277342] = (NI8)((*x)->data[i_277342] ^ y->data[i_277342]);
				res_277347 += ((NI) 1);
			} LA3: ;
		}
	}
}
NIM_EXTERNC N_NOINLINE(void, compiler_bitsetsInit000)(void) {
}

NIM_EXTERNC N_NOINLINE(void, compiler_bitsetsDatInit000)(void) {
NTI277012.size = sizeof(Tbitset277012*);
NTI277012.kind = 24;
NTI277012.base = (&NTI110);
NTI277012.flags = 2;
NTI277012.marker = TMP2927;
}

