/* Generated by Nim Compiler v1.4.2 */
/*   (c) 2020 Andreas Rumpf */
/* The generated code is subject to the original license. */
#define NIM_INTBITS 64
#define NIM_EmulateOverflowChecks

/* section: NIM_merge_HEADERS */

#include "nimbase.h"
#undef LANGUAGE_C
#undef MIPSEB
#undef MIPSEL
#undef PPC
#undef R3000
#undef R4000
#undef i386
#undef linux
#undef mips
#undef near
#undef far
#undef powerpc
#undef unix

/* section: NIM_merge_FRAME_DEFINES */
#define nimfr_(x, y)
#define nimln_(x, y)

/* section: NIM_merge_FORWARD_TYPES */
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;

/* section: NIM_merge_TYPES */
typedef NU8 tyEnum_PrefixMatch__Dkww2nY9cxJVLF9cfoQS5U6Q;
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef NU8 tyEnum_TNimKind__jIBKr1ejBgsfM33Kxw4j7A;
typedef NU8 tySet_tyEnum_TNimTypeFlag__v8QUszD1sWlSIWZz7mC4bQ;
typedef N_NIMCALL_PTR(void, tyProc__ojoeKfW4VYIm36I9cpDTQIg) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ) (void* p);
struct TNimType {
NI size;
NI align;
tyEnum_TNimKind__jIBKr1ejBgsfM33Kxw4j7A kind;
tySet_tyEnum_TNimTypeFlag__v8QUszD1sWlSIWZz7mC4bQ flags;
TNimType* base;
TNimNode* node;
void* finalizer;
tyProc__ojoeKfW4VYIm36I9cpDTQIg marker;
tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ deepcopy;
};
typedef NU8 tyEnum_TNimNodeKind__unfNsxrcATrufDZmpBq4HQ;
struct TNimNode {
tyEnum_TNimNodeKind__unfNsxrcATrufDZmpBq4HQ kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};

/* section: NIM_merge_PROC_HEADERS */
N_LIB_PRIVATE N_NIMCALL(NIM_CHAR, nsuToLowerAsciiChar)(NIM_CHAR c);

/* section: NIM_merge_DATA */
N_LIB_PRIVATE TNimType NTI__Dkww2nY9cxJVLF9cfoQS5U6Q_;

/* section: NIM_merge_PROCS */
N_LIB_PRIVATE N_NIMCALL(tyEnum_PrefixMatch__Dkww2nY9cxJVLF9cfoQS5U6Q, prefixMatch__pK9a9aTI3V8r6eOzZI8EfYlw)(NimStringDesc* p, NimStringDesc* s) {
	tyEnum_PrefixMatch__Dkww2nY9cxJVLF9cfoQS5U6Q result;
	NI i;
{	result = (tyEnum_PrefixMatch__Dkww2nY9cxJVLF9cfoQS5U6Q)0;
	{
		if (!((s ? s->Sup.len : 0) < (p ? p->Sup.len : 0))) goto LA3_;
		result = ((tyEnum_PrefixMatch__Dkww2nY9cxJVLF9cfoQS5U6Q) 0);
		goto BeforeRet_;
	}
	LA3_: ;
	i = ((NI) 0);
	{
		while (1) {
			if (!(i < (s ? s->Sup.len : 0))) goto LA6;
			{
				if (!((NU8)(s->data[i]) == (NU8)(95))) goto LA9_;
				i += ((NI) 1);
			}
			LA9_: ;
			{
				NIM_BOOL T13_;
				NIM_CHAR T15_;
				NIM_CHAR T16_;
				NI ii;
				NI jj;
				T13_ = (NIM_BOOL)0;
				T13_ = (i < (s ? s->Sup.len : 0));
				if (!(T13_)) goto LA14_;
				T15_ = (NIM_CHAR)0;
				T15_ = nsuToLowerAsciiChar(s->data[i]);
				T16_ = (NIM_CHAR)0;
				T16_ = nsuToLowerAsciiChar(p->data[((NI) 0)]);
				T13_ = ((NU8)(T15_) == (NU8)(T16_));
				LA14_: ;
				if (!T13_) goto LA17_;
				ii = (NI)(i + ((NI) 1));
				jj = ((NI) 1);
				{
					while (1) {
						NIM_BOOL T21_;
						T21_ = (NIM_BOOL)0;
						T21_ = (ii < (s ? s->Sup.len : 0));
						if (!(T21_)) goto LA22_;
						T21_ = (jj < (p ? p->Sup.len : 0));
						LA22_: ;
						if (!T21_) goto LA20;
						{
							if (!((NU8)(p->data[jj]) == (NU8)(95))) goto LA25_;
							jj += ((NI) 1);
						}
						LA25_: ;
						{
							if (!((NU8)(s->data[ii]) == (NU8)(95))) goto LA29_;
							ii += ((NI) 1);
						}
						LA29_: ;
						{
							NIM_CHAR T33_;
							NIM_CHAR T34_;
							T33_ = (NIM_CHAR)0;
							T33_ = nsuToLowerAsciiChar(s->data[ii]);
							T34_ = (NIM_CHAR)0;
							T34_ = nsuToLowerAsciiChar(p->data[jj]);
							if (!!(((NU8)(T33_) == (NU8)(T34_)))) goto LA35_;
							goto LA19;
						}
						LA35_: ;
						ii += ((NI) 1);
						jj += ((NI) 1);
					} LA20: ;
				} LA19: ;
				{
					if (!((p ? p->Sup.len : 0) <= jj)) goto LA39_;
					{
						if (!(i == ((NI) 0))) goto LA43_;
						result = ((tyEnum_PrefixMatch__Dkww2nY9cxJVLF9cfoQS5U6Q) 3);
						goto BeforeRet_;
					}
					goto LA41_;
					LA43_: ;
					{
						result = ((tyEnum_PrefixMatch__Dkww2nY9cxJVLF9cfoQS5U6Q) 2);
						goto BeforeRet_;
					}
					LA41_: ;
				}
				LA39_: ;
			}
			LA17_: ;
			i += ((NI) 1);
		} LA6: ;
	}
	{
		NIM_CHAR T48_;
		NIM_CHAR T49_;
		NI j;
		T48_ = (NIM_CHAR)0;
		T48_ = nsuToLowerAsciiChar(s->data[((NI) 0)]);
		T49_ = (NIM_CHAR)0;
		T49_ = nsuToLowerAsciiChar(p->data[((NI) 0)]);
		if (!((NU8)(T48_) == (NU8)(T49_))) goto LA50_;
		i = ((NI) 1);
		j = ((NI) 1);
		{
			while (1) {
				if (!(i < (s ? s->Sup.len : 0))) goto LA53;
				{
					NIM_BOOL T56_;
					T56_ = (NIM_BOOL)0;
					T56_ = (i < (NI)((s ? s->Sup.len : 0) - ((NI) 1)));
					if (!(T56_)) goto LA57_;
					T56_ = ((NU8)(s->data[i]) == (NU8)(95));
					LA57_: ;
					if (!T56_) goto LA58_;
					{
						NIM_BOOL T62_;
						NIM_CHAR T64_;
						NIM_CHAR T65_;
						T62_ = (NIM_BOOL)0;
						T62_ = (j < (p ? p->Sup.len : 0));
						if (!(T62_)) goto LA63_;
						T64_ = (NIM_CHAR)0;
						T64_ = nsuToLowerAsciiChar(p->data[j]);
						T65_ = (NIM_CHAR)0;
						T65_ = nsuToLowerAsciiChar(s->data[(NI)(i + ((NI) 1))]);
						T62_ = ((NU8)(T64_) == (NU8)(T65_));
						LA63_: ;
						if (!T62_) goto LA66_;
						j += ((NI) 1);
					}
					goto LA60_;
					LA66_: ;
					{
						result = ((tyEnum_PrefixMatch__Dkww2nY9cxJVLF9cfoQS5U6Q) 0);
						goto BeforeRet_;
					}
					LA60_: ;
				}
				LA58_: ;
				{
					NIM_BOOL T71_;
					NIM_BOOL T72_;
					T71_ = (NIM_BOOL)0;
					T72_ = (NIM_BOOL)0;
					T72_ = (i < (s ? s->Sup.len : 0));
					if (!(T72_)) goto LA73_;
					T72_ = (((NU8)(s->data[i])) >= ((NU8)(65)) && ((NU8)(s->data[i])) <= ((NU8)(90)));
					LA73_: ;
					T71_ = T72_;
					if (!(T71_)) goto LA74_;
					T71_ = !((((NU8)(s->data[(NI)(i - ((NI) 1))])) >= ((NU8)(65)) && ((NU8)(s->data[(NI)(i - ((NI) 1))])) <= ((NU8)(90))));
					LA74_: ;
					if (!T71_) goto LA75_;
					{
						NIM_BOOL T79_;
						NIM_CHAR T81_;
						NIM_CHAR T82_;
						T79_ = (NIM_BOOL)0;
						T79_ = (j < (p ? p->Sup.len : 0));
						if (!(T79_)) goto LA80_;
						T81_ = (NIM_CHAR)0;
						T81_ = nsuToLowerAsciiChar(p->data[j]);
						T82_ = (NIM_CHAR)0;
						T82_ = nsuToLowerAsciiChar(s->data[i]);
						T79_ = ((NU8)(T81_) == (NU8)(T82_));
						LA80_: ;
						if (!T79_) goto LA83_;
						j += ((NI) 1);
					}
					goto LA77_;
					LA83_: ;
					{
						result = ((tyEnum_PrefixMatch__Dkww2nY9cxJVLF9cfoQS5U6Q) 0);
						goto BeforeRet_;
					}
					LA77_: ;
				}
				LA75_: ;
				i += ((NI) 1);
			} LA53: ;
		}
		{
			if (!((p ? p->Sup.len : 0) <= j)) goto LA88_;
			result = ((tyEnum_PrefixMatch__Dkww2nY9cxJVLF9cfoQS5U6Q) 1);
			goto BeforeRet_;
		}
		goto LA86_;
		LA88_: ;
		{
			result = ((tyEnum_PrefixMatch__Dkww2nY9cxJVLF9cfoQS5U6Q) 0);
			goto BeforeRet_;
		}
		LA86_: ;
	}
	LA50_: ;
	result = ((tyEnum_PrefixMatch__Dkww2nY9cxJVLF9cfoQS5U6Q) 0);
	goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, compiler_prefixmatchesDatInit000)(void) {

/* section: NIM_merge_TYPE_INIT1 */
static TNimNode* TM__P9b9adRChs9cbzL6i5n3jD9b9ag_2_4[4];
NI TM__P9b9adRChs9cbzL6i5n3jD9b9ag_4;
static char* NIM_CONST TM__P9b9adRChs9cbzL6i5n3jD9b9ag_3[4] = {
"None", 
"Abbrev", 
"Substr", 
"Prefix"};
static TNimNode TM__P9b9adRChs9cbzL6i5n3jD9b9ag_0[5];

/* section: NIM_merge_TYPE_INIT3 */
NTI__Dkww2nY9cxJVLF9cfoQS5U6Q_.size = sizeof(tyEnum_PrefixMatch__Dkww2nY9cxJVLF9cfoQS5U6Q);
NTI__Dkww2nY9cxJVLF9cfoQS5U6Q_.align = NIM_ALIGNOF(tyEnum_PrefixMatch__Dkww2nY9cxJVLF9cfoQS5U6Q);
NTI__Dkww2nY9cxJVLF9cfoQS5U6Q_.kind = 14;
NTI__Dkww2nY9cxJVLF9cfoQS5U6Q_.base = 0;
NTI__Dkww2nY9cxJVLF9cfoQS5U6Q_.flags = 3;
for (TM__P9b9adRChs9cbzL6i5n3jD9b9ag_4 = 0; TM__P9b9adRChs9cbzL6i5n3jD9b9ag_4 < 4; TM__P9b9adRChs9cbzL6i5n3jD9b9ag_4++) {
TM__P9b9adRChs9cbzL6i5n3jD9b9ag_0[TM__P9b9adRChs9cbzL6i5n3jD9b9ag_4+0].kind = 1;
TM__P9b9adRChs9cbzL6i5n3jD9b9ag_0[TM__P9b9adRChs9cbzL6i5n3jD9b9ag_4+0].offset = TM__P9b9adRChs9cbzL6i5n3jD9b9ag_4;
TM__P9b9adRChs9cbzL6i5n3jD9b9ag_0[TM__P9b9adRChs9cbzL6i5n3jD9b9ag_4+0].name = TM__P9b9adRChs9cbzL6i5n3jD9b9ag_3[TM__P9b9adRChs9cbzL6i5n3jD9b9ag_4];
TM__P9b9adRChs9cbzL6i5n3jD9b9ag_2_4[TM__P9b9adRChs9cbzL6i5n3jD9b9ag_4] = &TM__P9b9adRChs9cbzL6i5n3jD9b9ag_0[TM__P9b9adRChs9cbzL6i5n3jD9b9ag_4+0];
}
TM__P9b9adRChs9cbzL6i5n3jD9b9ag_0[4].len = 4; TM__P9b9adRChs9cbzL6i5n3jD9b9ag_0[4].kind = 2; TM__P9b9adRChs9cbzL6i5n3jD9b9ag_0[4].sons = &TM__P9b9adRChs9cbzL6i5n3jD9b9ag_2_4[0];
NTI__Dkww2nY9cxJVLF9cfoQS5U6Q_.node = &TM__P9b9adRChs9cbzL6i5n3jD9b9ag_0[4];
}

