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

N_NIMCALL(void, bitsetinit_260009)(Tbitset260006** b, NI length) {
	unsureAsgnRef((void**) (&(*b)), (Tbitset260006*) newSeq((&NTI260006), ((NI) (length))));
}

N_NIMCALL(void, bitsetincl_260034)(Tbitset260006** 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_260019)(Tbitset260006** x, Tbitset260006* y) {
	{
		NI i_260266;
		NI HEX3Atmp_260268;
		NI res_260271;
		i_260266 = 0;
		HEX3Atmp_260268 = 0;
		HEX3Atmp_260268 = ((*x) ? ((*x)->Sup.len-1) : -1);
		res_260271 = ((NI) 0);
		{
			while (1) {
				if (!(res_260271 <= HEX3Atmp_260268)) goto LA3;
				i_260266 = res_260271;
				(*x)->data[i_260266] = (NI8)((*x)->data[i_260266] & (NI8)((NU8) ~(y->data[i_260266])));
				res_260271 += ((NI) 1);
			} LA3: ;
		}
	}
}

N_NIMCALL(NIM_BOOL, bitsetin_260044)(Tbitset260006* 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_260052)(Tbitset260006* x, Tbitset260006* y) {
	NIM_BOOL result;
{	result = 0;
	{
		NI i_260366;
		NI HEX3Atmp_260368;
		NI res_260371;
		i_260366 = 0;
		HEX3Atmp_260368 = 0;
		HEX3Atmp_260368 = (x ? (x->Sup.len-1) : -1);
		res_260371 = ((NI) 0);
		{
			while (1) {
				if (!(res_260371 <= HEX3Atmp_260368)) goto LA3;
				i_260366 = res_260371;
				{
					if (!!(((NI8)(x->data[i_260366] & (NI8)((NU8) ~(y->data[i_260366]))) == ((NI8) 0)))) goto LA6;
					result = NIM_FALSE;
					goto BeforeRet;
				}
				LA6: ;
				res_260371 += ((NI) 1);
			} LA3: ;
		}
	}
	result = NIM_TRUE;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(NIM_BOOL, bitsetequals_260048)(Tbitset260006* x, Tbitset260006* y) {
	NIM_BOOL result;
{	result = 0;
	{
		NI i_260341;
		NI HEX3Atmp_260343;
		NI res_260346;
		i_260341 = 0;
		HEX3Atmp_260343 = 0;
		HEX3Atmp_260343 = (x ? (x->Sup.len-1) : -1);
		res_260346 = ((NI) 0);
		{
			while (1) {
				if (!(res_260346 <= HEX3Atmp_260343)) goto LA3;
				i_260341 = res_260346;
				{
					if (!!((x->data[i_260341] == y->data[i_260341]))) goto LA6;
					result = NIM_FALSE;
					goto BeforeRet;
				}
				LA6: ;
				res_260346 += ((NI) 1);
			} LA3: ;
		}
	}
	result = NIM_TRUE;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(void, bitsetintersect_260029)(Tbitset260006** x, Tbitset260006* y) {
	{
		NI i_260316;
		NI HEX3Atmp_260318;
		NI res_260321;
		i_260316 = 0;
		HEX3Atmp_260318 = 0;
		HEX3Atmp_260318 = ((*x) ? ((*x)->Sup.len-1) : -1);
		res_260321 = ((NI) 0);
		{
			while (1) {
				if (!(res_260321 <= HEX3Atmp_260318)) goto LA3;
				i_260316 = res_260321;
				(*x)->data[i_260316] = (NI8)((*x)->data[i_260316] & y->data[i_260316]);
				res_260321 += ((NI) 1);
			} LA3: ;
		}
	}
}

N_NIMCALL(void, bitsetunion_260014)(Tbitset260006** x, Tbitset260006* y) {
	{
		NI i_260241;
		NI HEX3Atmp_260243;
		NI res_260246;
		i_260241 = 0;
		HEX3Atmp_260243 = 0;
		HEX3Atmp_260243 = ((*x) ? ((*x)->Sup.len-1) : -1);
		res_260246 = ((NI) 0);
		{
			while (1) {
				if (!(res_260246 <= HEX3Atmp_260243)) goto LA3;
				i_260241 = res_260246;
				(*x)->data[i_260241] = (NI8)((*x)->data[i_260241] | y->data[i_260241]);
				res_260246 += ((NI) 1);
			} LA3: ;
		}
	}
}

N_NIMCALL(void, bitsetsymdiff_260024)(Tbitset260006** x, Tbitset260006* y) {
	{
		NI i_260291;
		NI HEX3Atmp_260293;
		NI res_260296;
		i_260291 = 0;
		HEX3Atmp_260293 = 0;
		HEX3Atmp_260293 = ((*x) ? ((*x)->Sup.len-1) : -1);
		res_260296 = ((NI) 0);
		{
			while (1) {
				if (!(res_260296 <= HEX3Atmp_260293)) goto LA3;
				i_260291 = res_260296;
				(*x)->data[i_260291] = (NI8)((*x)->data[i_260291] ^ y->data[i_260291]);
				res_260296 += ((NI) 1);
			} LA3: ;
		}
	}
}
NIM_EXTERNC N_NOINLINE(void, compiler_bitsetsInit000)(void) {
}

NIM_EXTERNC N_NOINLINE(void, compiler_bitsetsDatInit000)(void) {
NTI260006.size = sizeof(Tbitset260006*);
NTI260006.kind = 24;
NTI260006.base = (&NTI106);
NTI260006.flags = 2;
NTI260006.marker = TMP2967;
}

