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

N_NIMCALL(void, bitsetinit_273021)(Tbitset273012** b, NI length) {
	unsureAsgnRef((void**) (&(*b)), (Tbitset273012*) newSeq((&NTI273012), ((NI) (length))));
}

N_NIMCALL(void, bitsetincl_273061)(Tbitset273012** 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_273037)(Tbitset273012** x, Tbitset273012* y) {
	{
		NI i_273301;
		NI HEX3Atmp_273303;
		NI res_273306;
		i_273301 = 0;
		HEX3Atmp_273303 = 0;
		HEX3Atmp_273303 = ((*x) ? ((*x)->Sup.len-1) : -1);
		res_273306 = ((NI) 0);
		{
			while (1) {
				if (!(res_273306 <= HEX3Atmp_273303)) goto LA3;
				i_273301 = res_273306;
				(*x)->data[i_273301] = (NI8)((*x)->data[i_273301] & (NI8)((NU8) ~(y->data[i_273301])));
				res_273306 += ((NI) 1);
			} LA3: ;
		}
	}
}

N_NIMCALL(NIM_BOOL, bitsetin_273077)(Tbitset273012* 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_273091)(Tbitset273012* x, Tbitset273012* y) {
	NIM_BOOL result;
{	result = 0;
	{
		NI i_273465;
		NI HEX3Atmp_273467;
		NI res_273470;
		i_273465 = 0;
		HEX3Atmp_273467 = 0;
		HEX3Atmp_273467 = (x ? (x->Sup.len-1) : -1);
		res_273470 = ((NI) 0);
		{
			while (1) {
				if (!(res_273470 <= HEX3Atmp_273467)) goto LA3;
				i_273465 = res_273470;
				{
					if (!!(((NI8)(x->data[i_273465] & (NI8)((NU8) ~(y->data[i_273465]))) == ((NI8) 0)))) goto LA6;
					result = NIM_FALSE;
					goto BeforeRet;
				}
				LA6: ;
				res_273470 += ((NI) 1);
			} LA3: ;
		}
	}
	result = NIM_TRUE;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(NIM_BOOL, bitsetequals_273084)(Tbitset273012* x, Tbitset273012* y) {
	NIM_BOOL result;
{	result = 0;
	{
		NI i_273424;
		NI HEX3Atmp_273426;
		NI res_273429;
		i_273424 = 0;
		HEX3Atmp_273426 = 0;
		HEX3Atmp_273426 = (x ? (x->Sup.len-1) : -1);
		res_273429 = ((NI) 0);
		{
			while (1) {
				if (!(res_273429 <= HEX3Atmp_273426)) goto LA3;
				i_273424 = res_273429;
				{
					if (!!((x->data[i_273424] == y->data[i_273424]))) goto LA6;
					result = NIM_FALSE;
					goto BeforeRet;
				}
				LA6: ;
				res_273429 += ((NI) 1);
			} LA3: ;
		}
	}
	result = NIM_TRUE;
	}BeforeRet: ;
	return result;
}

N_NIMCALL(void, bitsetintersect_273053)(Tbitset273012** x, Tbitset273012* y) {
	{
		NI i_273383;
		NI HEX3Atmp_273385;
		NI res_273388;
		i_273383 = 0;
		HEX3Atmp_273385 = 0;
		HEX3Atmp_273385 = ((*x) ? ((*x)->Sup.len-1) : -1);
		res_273388 = ((NI) 0);
		{
			while (1) {
				if (!(res_273388 <= HEX3Atmp_273385)) goto LA3;
				i_273383 = res_273388;
				(*x)->data[i_273383] = (NI8)((*x)->data[i_273383] & y->data[i_273383]);
				res_273388 += ((NI) 1);
			} LA3: ;
		}
	}
}

N_NIMCALL(void, bitsetunion_273029)(Tbitset273012** x, Tbitset273012* y) {
	{
		NI i_273260;
		NI HEX3Atmp_273262;
		NI res_273265;
		i_273260 = 0;
		HEX3Atmp_273262 = 0;
		HEX3Atmp_273262 = ((*x) ? ((*x)->Sup.len-1) : -1);
		res_273265 = ((NI) 0);
		{
			while (1) {
				if (!(res_273265 <= HEX3Atmp_273262)) goto LA3;
				i_273260 = res_273265;
				(*x)->data[i_273260] = (NI8)((*x)->data[i_273260] | y->data[i_273260]);
				res_273265 += ((NI) 1);
			} LA3: ;
		}
	}
}

N_NIMCALL(void, bitsetsymdiff_273045)(Tbitset273012** x, Tbitset273012* y) {
	{
		NI i_273342;
		NI HEX3Atmp_273344;
		NI res_273347;
		i_273342 = 0;
		HEX3Atmp_273344 = 0;
		HEX3Atmp_273344 = ((*x) ? ((*x)->Sup.len-1) : -1);
		res_273347 = ((NI) 0);
		{
			while (1) {
				if (!(res_273347 <= HEX3Atmp_273344)) goto LA3;
				i_273342 = res_273347;
				(*x)->data[i_273342] = (NI8)((*x)->data[i_273342] ^ y->data[i_273342]);
				res_273347 += ((NI) 1);
			} LA3: ;
		}
	}
}
NIM_EXTERNC N_NOINLINE(void, compiler_bitsetsInit000)(void) {
}

NIM_EXTERNC N_NOINLINE(void, compiler_bitsetsDatInit000)(void) {
NTI273012.size = sizeof(Tbitset273012*);
NTI273012.kind = 24;
NTI273012.base = (&NTI110);
NTI273012.flags = 2;
NTI273012.marker = TMP2923;
}

