/* Generated by Nim Compiler v0.11.2 */
/*   (c) 2015 Andreas Rumpf */
/* The generated code is subject to the original license. */
#define NIM_INTBITS 64
#include "nimbase.h"
typedef struct Tbitset239012 Tbitset239012;
typedef struct TGenericSeq TGenericSeq;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
struct  TGenericSeq  {
NI len;
NI reserved;
};
typedef N_NIMCALL_PTR(void, TY3289) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, TY3294) (void* p);
struct  TNimType  {
NI size;
NU8 kind;
NU8 flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY3289 marker;
TY3294 deepcopy;
};
struct  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct Tbitset239012 {
  TGenericSeq Sup;
  NI8 data[SEQ_DECL_SIZE];
};
N_NIMCALL(void, TMP2809)(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 NTI239012; /* TBitSet */
N_NIMCALL(void, TMP2809)(void* p, NI op) {
	Tbitset239012* a;
	NI LOC1;
	a = (Tbitset239012*)p;
	LOC1 = 0;
	for (LOC1 = 0; LOC1 < a->Sup.len; LOC1++) {
	}
}

N_NIMCALL(void, bitsetinit_239021)(Tbitset239012** b, NI length) {
	unsureAsgnRef((void**) (&(*b)), (Tbitset239012*) newSeq((&NTI239012), ((NI) (length))));
}

N_NIMCALL(void, bitsetincl_239061)(Tbitset239012** 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_239037)(Tbitset239012** x, Tbitset239012* y) {
	{
		NI i_239301;
		NI HEX3Atmp_239303;
		NI res_239306;
		i_239301 = 0;
		HEX3Atmp_239303 = 0;
		HEX3Atmp_239303 = ((*x) ? ((*x)->Sup.len-1) : -1);
		res_239306 = ((NI) 0);
		{
			while (1) {
				if (!(res_239306 <= HEX3Atmp_239303)) goto LA3;
				i_239301 = res_239306;
				(*x)->data[i_239301] = (NI8)((*x)->data[i_239301] & (NI8)((NU8) ~(y->data[i_239301])));
				res_239306 += ((NI) 1);
			} LA3: ;
		}
	}
}

N_NIMCALL(NIM_BOOL, bitsetin_239077)(Tbitset239012* 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_239091)(Tbitset239012* x, Tbitset239012* y) {
	NIM_BOOL result;
{	result = 0;
	{
		NI i_239465;
		NI HEX3Atmp_239467;
		NI res_239470;
		i_239465 = 0;
		HEX3Atmp_239467 = 0;
		HEX3Atmp_239467 = (x ? (x->Sup.len-1) : -1);
		res_239470 = ((NI) 0);
		{
			while (1) {
				if (!(res_239470 <= HEX3Atmp_239467)) goto LA3;
				i_239465 = res_239470;
				{
					if (!!(((NI8)(x->data[i_239465] & (NI8)((NU8) ~(y->data[i_239465]))) == ((NI8) 0)))) goto LA6;
					result = NIM_FALSE;
					goto BeforeRet;
				}
				LA6: ;
				res_239470 += ((NI) 1);
			} LA3: ;
		}
	}
	result = NIM_TRUE;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(NIM_BOOL, bitsetequals_239084)(Tbitset239012* x, Tbitset239012* y) {
	NIM_BOOL result;
{	result = 0;
	{
		NI i_239424;
		NI HEX3Atmp_239426;
		NI res_239429;
		i_239424 = 0;
		HEX3Atmp_239426 = 0;
		HEX3Atmp_239426 = (x ? (x->Sup.len-1) : -1);
		res_239429 = ((NI) 0);
		{
			while (1) {
				if (!(res_239429 <= HEX3Atmp_239426)) goto LA3;
				i_239424 = res_239429;
				{
					if (!!((x->data[i_239424] == y->data[i_239424]))) goto LA6;
					result = NIM_FALSE;
					goto BeforeRet;
				}
				LA6: ;
				res_239429 += ((NI) 1);
			} LA3: ;
		}
	}
	result = NIM_TRUE;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(void, bitsetintersect_239053)(Tbitset239012** x, Tbitset239012* y) {
	{
		NI i_239383;
		NI HEX3Atmp_239385;
		NI res_239388;
		i_239383 = 0;
		HEX3Atmp_239385 = 0;
		HEX3Atmp_239385 = ((*x) ? ((*x)->Sup.len-1) : -1);
		res_239388 = ((NI) 0);
		{
			while (1) {
				if (!(res_239388 <= HEX3Atmp_239385)) goto LA3;
				i_239383 = res_239388;
				(*x)->data[i_239383] = (NI8)((*x)->data[i_239383] & y->data[i_239383]);
				res_239388 += ((NI) 1);
			} LA3: ;
		}
	}
}

N_NIMCALL(void, bitsetunion_239029)(Tbitset239012** x, Tbitset239012* y) {
	{
		NI i_239260;
		NI HEX3Atmp_239262;
		NI res_239265;
		i_239260 = 0;
		HEX3Atmp_239262 = 0;
		HEX3Atmp_239262 = ((*x) ? ((*x)->Sup.len-1) : -1);
		res_239265 = ((NI) 0);
		{
			while (1) {
				if (!(res_239265 <= HEX3Atmp_239262)) goto LA3;
				i_239260 = res_239265;
				(*x)->data[i_239260] = (NI8)((*x)->data[i_239260] | y->data[i_239260]);
				res_239265 += ((NI) 1);
			} LA3: ;
		}
	}
}

N_NIMCALL(void, bitsetsymdiff_239045)(Tbitset239012** x, Tbitset239012* y) {
	{
		NI i_239342;
		NI HEX3Atmp_239344;
		NI res_239347;
		i_239342 = 0;
		HEX3Atmp_239344 = 0;
		HEX3Atmp_239344 = ((*x) ? ((*x)->Sup.len-1) : -1);
		res_239347 = ((NI) 0);
		{
			while (1) {
				if (!(res_239347 <= HEX3Atmp_239344)) goto LA3;
				i_239342 = res_239347;
				(*x)->data[i_239342] = (NI8)((*x)->data[i_239342] ^ y->data[i_239342]);
				res_239347 += ((NI) 1);
			} LA3: ;
		}
	}
}
NIM_EXTERNC N_NOINLINE(void, nimsrc_bitsetsInit)(void) {
}

NIM_EXTERNC N_NOINLINE(void, nimsrc_bitsetsDatInit)(void) {
NTI239012.size = sizeof(Tbitset239012*);
NTI239012.kind = 24;
NTI239012.base = (&NTI110);
NTI239012.flags = 2;
NTI239012.marker = TMP2809;
}

