/* Generated by Nimrod Compiler v0.9.5 */
/*   (c) 2014 Andreas Rumpf */
/* The generated code is subject to the original license. */
/* Compiled for: Linux, i386, gcc */
/* Command for C compiler:
   gcc -c  -w -O3 -fno-strict-aliasing  -I/build/nimrod/src/nimrod/lib -o compiler/nimcache/bitsets.o compiler/nimcache/bitsets.c */
#define NIM_INTBITS 32
#include "nimbase.h"
typedef struct tbitset243012 tbitset243012;
typedef struct TGenericSeq TGenericSeq;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
struct  TGenericSeq  {
NI len;
NI reserved;
};
typedef N_NIMCALL_PTR(void, TY2289) (void* p, NI op);
struct  TNimType  {
NI size;
NU8 kind;
NU8 flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY2289 marker;
};
struct  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct tbitset243012 {
  TGenericSeq Sup;
  NI8 data[SEQ_DECL_SIZE];
};
N_NIMCALL(void, TMP2612)(void* p, NI op);
N_NIMCALL(void*, newSeq)(TNimType* typ, NI len);
N_NIMCALL(void, unsureAsgnRef)(void** dest, void* src);
extern TNimType NTI108; /* int8 */
TNimType NTI243012; /* TBitSet */
N_NIMCALL(void, TMP2612)(void* p, NI op) {
	tbitset243012* a;
	NI LOC1;
	a = (tbitset243012*)p;
	LOC1 = 0;
	for (LOC1 = 0; LOC1 < a->Sup.len; LOC1++) {
	}
}

N_NIMCALL(void, bitsetinit_243017)(tbitset243012** b, NI length) {
	unsureAsgnRef((void**) &(*b), (tbitset243012*) newSeq((&NTI243012), length));
}

N_NIMCALL(void, bitsetincl_243047)(tbitset243012** x, NI64 elem) {
	(*x)->data[(NI64)(elem / 8)] = (NI8)((*x)->data[(NI64)(elem / 8)] | ((NI8)(NU8)(NU)((NI)((NU32)(1) << (NU32)(((NI) ((NI64)(elem % 8))))))));
}

N_NIMCALL(void, bitsetdiff_243029)(tbitset243012** x, tbitset243012* y) {
	NI i_243279;
	NI HEX3Atmp_243280;
	NI res_243282;
	i_243279 = 0;
	HEX3Atmp_243280 = 0;
	HEX3Atmp_243280 = ((*x)->Sup.len-1);
	res_243282 = 0;
	while (1) {
		if (!(res_243282 <= HEX3Atmp_243280)) goto LA1;
		i_243279 = res_243282;
		(*x)->data[i_243279] = (NI8)((*x)->data[i_243279] & (NI8)((NU8) ~(y->data[i_243279])));
		res_243282 += 1;
	} LA1: ;
}

N_NIMCALL(NIM_BOOL, bitsetin_243059)(tbitset243012* x, NI64 e) {
	NIM_BOOL result;
	result = 0;
	result = !(((NI8)(x->data[(NI64)(e / 8)] & ((NI8)(NU8)(NU)((NI)((NU32)(1) << (NU32)(((NI) ((NI64)(e % 8)))))))) == ((NI8) 0)));
	return result;
}

N_NIMCALL(NIM_BOOL, bitsetcontains_243069)(tbitset243012* x, tbitset243012* y) {
	NIM_BOOL result;
	NI i_243379;
	NI HEX3Atmp_243380;
	NI res_243382;
	result = 0;
	i_243379 = 0;
	HEX3Atmp_243380 = 0;
	HEX3Atmp_243380 = (x->Sup.len-1);
	res_243382 = 0;
	while (1) {
		if (!(res_243382 <= HEX3Atmp_243380)) goto LA1;
		i_243379 = res_243382;
		{
			if (!!(((NI8)(x->data[i_243379] & (NI8)((NU8) ~(y->data[i_243379]))) == ((NI8) 0)))) goto LA4;
			result = NIM_FALSE;
			goto BeforeRet;
		}
		LA4: ;
		res_243382 += 1;
	} LA1: ;
	result = NIM_TRUE;
	BeforeRet: ;
	return result;
}

N_NIMCALL(NIM_BOOL, bitsetequals_243064)(tbitset243012* x, tbitset243012* y) {
	NIM_BOOL result;
	NI i_243354;
	NI HEX3Atmp_243355;
	NI res_243357;
	result = 0;
	i_243354 = 0;
	HEX3Atmp_243355 = 0;
	HEX3Atmp_243355 = (x->Sup.len-1);
	res_243357 = 0;
	while (1) {
		if (!(res_243357 <= HEX3Atmp_243355)) goto LA1;
		i_243354 = res_243357;
		{
			if (!!((x->data[i_243354] == y->data[i_243354]))) goto LA4;
			result = NIM_FALSE;
			goto BeforeRet;
		}
		LA4: ;
		res_243357 += 1;
	} LA1: ;
	result = NIM_TRUE;
	BeforeRet: ;
	return result;
}

N_NIMCALL(void, bitsetintersect_243041)(tbitset243012** x, tbitset243012* y) {
	NI i_243329;
	NI HEX3Atmp_243330;
	NI res_243332;
	i_243329 = 0;
	HEX3Atmp_243330 = 0;
	HEX3Atmp_243330 = ((*x)->Sup.len-1);
	res_243332 = 0;
	while (1) {
		if (!(res_243332 <= HEX3Atmp_243330)) goto LA1;
		i_243329 = res_243332;
		(*x)->data[i_243329] = (NI8)((*x)->data[i_243329] & y->data[i_243329]);
		res_243332 += 1;
	} LA1: ;
}

N_NIMCALL(void, bitsetunion_243023)(tbitset243012** x, tbitset243012* y) {
	NI i_243254;
	NI HEX3Atmp_243255;
	NI res_243257;
	i_243254 = 0;
	HEX3Atmp_243255 = 0;
	HEX3Atmp_243255 = ((*x)->Sup.len-1);
	res_243257 = 0;
	while (1) {
		if (!(res_243257 <= HEX3Atmp_243255)) goto LA1;
		i_243254 = res_243257;
		(*x)->data[i_243254] = (NI8)((*x)->data[i_243254] | y->data[i_243254]);
		res_243257 += 1;
	} LA1: ;
}

N_NIMCALL(void, bitsetsymdiff_243035)(tbitset243012** x, tbitset243012* y) {
	NI i_243304;
	NI HEX3Atmp_243305;
	NI res_243307;
	i_243304 = 0;
	HEX3Atmp_243305 = 0;
	HEX3Atmp_243305 = ((*x)->Sup.len-1);
	res_243307 = 0;
	while (1) {
		if (!(res_243307 <= HEX3Atmp_243305)) goto LA1;
		i_243304 = res_243307;
		(*x)->data[i_243304] = (NI8)((*x)->data[i_243304] ^ y->data[i_243304]);
		res_243307 += 1;
	} LA1: ;
}
N_NOINLINE(void, bitsetsInit)(void) {
}

N_NOINLINE(void, bitsetsDatInit)(void) {
NTI243012.size = sizeof(tbitset243012*);
NTI243012.kind = 24;
NTI243012.base = (&NTI108);
NTI243012.flags = 2;
NTI243012.marker = TMP2612;
}

