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

N_NIMCALL(void, bitsetinit_261009)(Tbitset261006** b, NI length) {
	unsureAsgnRef((void**) (&(*b)), (Tbitset261006*) newSeq((&NTI261006), ((NI) (length))));
}

N_NIMCALL(void, bitsetincl_261034)(Tbitset261006** 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_261019)(Tbitset261006** x, Tbitset261006* y) {
	{
		NI i_261266;
		NI HEX3Atmp_261268;
		NI res_261271;
		i_261266 = 0;
		HEX3Atmp_261268 = 0;
		HEX3Atmp_261268 = ((*x) ? ((*x)->Sup.len-1) : -1);
		res_261271 = ((NI) 0);
		{
			while (1) {
				if (!(res_261271 <= HEX3Atmp_261268)) goto LA3;
				i_261266 = res_261271;
				(*x)->data[i_261266] = (NI8)((*x)->data[i_261266] & (NI8)((NU8) ~(y->data[i_261266])));
				res_261271 += ((NI) 1);
			} LA3: ;
		}
	}
}

N_NIMCALL(NIM_BOOL, bitsetin_261044)(Tbitset261006* 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_261052)(Tbitset261006* x, Tbitset261006* y) {
	NIM_BOOL result;
{	result = 0;
	{
		NI i_261366;
		NI HEX3Atmp_261368;
		NI res_261371;
		i_261366 = 0;
		HEX3Atmp_261368 = 0;
		HEX3Atmp_261368 = (x ? (x->Sup.len-1) : -1);
		res_261371 = ((NI) 0);
		{
			while (1) {
				if (!(res_261371 <= HEX3Atmp_261368)) goto LA3;
				i_261366 = res_261371;
				{
					if (!!(((NI8)(x->data[i_261366] & (NI8)((NU8) ~(y->data[i_261366]))) == ((NI8) 0)))) goto LA6;
					result = NIM_FALSE;
					goto BeforeRet;
				}
				LA6: ;
				res_261371 += ((NI) 1);
			} LA3: ;
		}
	}
	result = NIM_TRUE;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(NIM_BOOL, bitsetequals_261048)(Tbitset261006* x, Tbitset261006* y) {
	NIM_BOOL result;
{	result = 0;
	{
		NI i_261341;
		NI HEX3Atmp_261343;
		NI res_261346;
		i_261341 = 0;
		HEX3Atmp_261343 = 0;
		HEX3Atmp_261343 = (x ? (x->Sup.len-1) : -1);
		res_261346 = ((NI) 0);
		{
			while (1) {
				if (!(res_261346 <= HEX3Atmp_261343)) goto LA3;
				i_261341 = res_261346;
				{
					if (!!((x->data[i_261341] == y->data[i_261341]))) goto LA6;
					result = NIM_FALSE;
					goto BeforeRet;
				}
				LA6: ;
				res_261346 += ((NI) 1);
			} LA3: ;
		}
	}
	result = NIM_TRUE;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(void, bitsetintersect_261029)(Tbitset261006** x, Tbitset261006* y) {
	{
		NI i_261316;
		NI HEX3Atmp_261318;
		NI res_261321;
		i_261316 = 0;
		HEX3Atmp_261318 = 0;
		HEX3Atmp_261318 = ((*x) ? ((*x)->Sup.len-1) : -1);
		res_261321 = ((NI) 0);
		{
			while (1) {
				if (!(res_261321 <= HEX3Atmp_261318)) goto LA3;
				i_261316 = res_261321;
				(*x)->data[i_261316] = (NI8)((*x)->data[i_261316] & y->data[i_261316]);
				res_261321 += ((NI) 1);
			} LA3: ;
		}
	}
}

N_NIMCALL(void, bitsetunion_261014)(Tbitset261006** x, Tbitset261006* y) {
	{
		NI i_261241;
		NI HEX3Atmp_261243;
		NI res_261246;
		i_261241 = 0;
		HEX3Atmp_261243 = 0;
		HEX3Atmp_261243 = ((*x) ? ((*x)->Sup.len-1) : -1);
		res_261246 = ((NI) 0);
		{
			while (1) {
				if (!(res_261246 <= HEX3Atmp_261243)) goto LA3;
				i_261241 = res_261246;
				(*x)->data[i_261241] = (NI8)((*x)->data[i_261241] | y->data[i_261241]);
				res_261246 += ((NI) 1);
			} LA3: ;
		}
	}
}

N_NIMCALL(void, bitsetsymdiff_261024)(Tbitset261006** x, Tbitset261006* y) {
	{
		NI i_261291;
		NI HEX3Atmp_261293;
		NI res_261296;
		i_261291 = 0;
		HEX3Atmp_261293 = 0;
		HEX3Atmp_261293 = ((*x) ? ((*x)->Sup.len-1) : -1);
		res_261296 = ((NI) 0);
		{
			while (1) {
				if (!(res_261296 <= HEX3Atmp_261293)) goto LA3;
				i_261291 = res_261296;
				(*x)->data[i_261291] = (NI8)((*x)->data[i_261291] ^ y->data[i_261291]);
				res_261296 += ((NI) 1);
			} LA3: ;
		}
	}
}
NIM_EXTERNC N_NOINLINE(void, compiler_bitsetsInit000)(void) {
}

NIM_EXTERNC N_NOINLINE(void, compiler_bitsetsDatInit000)(void) {
NTI261006.size = sizeof(Tbitset261006*);
NTI261006.kind = 24;
NTI261006.base = (&NTI106);
NTI261006.flags = 2;
NTI261006.marker = TMP2972;
}

