/* Generated by Nim Compiler v1.6.14 */
#define NIM_INTBITS 64

#include "nimbase.h"
#include <string.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
#define nimfr_(x, y)
#define nimln_(x, y)
typedef struct tyObject_HeapQueue__MBC6eEbMfekVnGqjI07yVg tyObject_HeapQueue__MBC6eEbMfekVnGqjI07yVg;
typedef struct tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA;
typedef struct tySequence__wDFGR0GrXEVcAPtPuTlVAA tySequence__wDFGR0GrXEVcAPtPuTlVAA;
typedef struct TGenericSeq TGenericSeq;
typedef struct NimStringDesc NimStringDesc;
typedef struct tyObject_TSym__3r34mwqcVmg5JFNmiaVncw tyObject_TSym__3r34mwqcVmg5JFNmiaVncw;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct tyObject_Cell__nhn83Yf9cX7rcmG5W9b4oa6g tyObject_Cell__nhn83Yf9cX7rcmG5W9b4oa6g;
typedef struct tyObject_CellSeq__nav876ELHgxScHhs30CKiA tyObject_CellSeq__nav876ELHgxScHhs30CKiA;
typedef struct tyObject_GcHeap__ZRn9bWCksoiGwT2drZZzyWQ tyObject_GcHeap__ZRn9bWCksoiGwT2drZZzyWQ;
typedef struct tyObject_GcStack__qFeGMKlnq6c9cTM2vPWycQQ tyObject_GcStack__qFeGMKlnq6c9cTM2vPWycQQ;
typedef struct tyObject_MemRegion__6QRscFDo4mEwbg9aL76vDGQ tyObject_MemRegion__6QRscFDo4mEwbg9aL76vDGQ;
typedef struct tyObject_SmallChunk__eUrTKmsk1Dqt5tm2WUT2Lw tyObject_SmallChunk__eUrTKmsk1Dqt5tm2WUT2Lw;
typedef struct tyObject_BigChunk__39bC3HTk2w4NGDjG74oNjmA tyObject_BigChunk__39bC3HTk2w4NGDjG74oNjmA;
typedef struct tyObject_LLChunk__Fjkr5Ya6Zl0UoUGxG047hA tyObject_LLChunk__Fjkr5Ya6Zl0UoUGxG047hA;
typedef struct tyObject_IntSet__WrQriiGmHk59cB1lNPtGo6A tyObject_IntSet__WrQriiGmHk59cB1lNPtGo6A;
typedef struct tyObject_Trunk__Ju1AURWHenTn3cJwAjbUhg tyObject_Trunk__Ju1AURWHenTn3cJwAjbUhg;
typedef struct tyObject_AvlNode__aGkK1t9a0WoXjpugXR6FWpw tyObject_AvlNode__aGkK1t9a0WoXjpugXR6FWpw;
typedef struct tyObject_HeapLinks__5IkCDh5QlsYpsfEMJf6zNw tyObject_HeapLinks__5IkCDh5QlsYpsfEMJf6zNw;
typedef struct tyTuple__p2vAp9cQ6YrpDq9cI3XzEDWA tyTuple__p2vAp9cQ6YrpDq9cI3XzEDWA;
typedef struct tyObject_GcStat__OG9ams3mtFJyICkjTOHbc9bg tyObject_GcStat__OG9ams3mtFJyICkjTOHbc9bg;
typedef struct tyObject_CellSet__A0mJvGLunfUxGkLUtesjdA tyObject_CellSet__A0mJvGLunfUxGkLUtesjdA;
typedef struct tyObject_PageDesc__N7tjEodqPVJaQ6oKQW8YfQ tyObject_PageDesc__N7tjEodqPVJaQ6oKQW8YfQ;
struct tyObject_HeapQueue__MBC6eEbMfekVnGqjI07yVg {
tySequence__wDFGR0GrXEVcAPtPuTlVAA* data;
};
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA {
NI dist;
NI depth;
NimStringDesc* msg;
tyObject_TSym__3r34mwqcVmg5JFNmiaVncw* sym;
};
typedef NU8 tyEnum_TNimKind__pspQAsqJLrw3jEKBD9bxmyQ;
typedef NU8 tySet_tyEnum_TNimTypeFlag__Yt5hq6z2IoHhKZrzIVrc1w;
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__pspQAsqJLrw3jEKBD9bxmyQ kind;
tySet_tyEnum_TNimTypeFlag__Yt5hq6z2IoHhKZrzIVrc1w flags;
TNimType* base;
TNimNode* node;
void* finalizer;
tyProc__ojoeKfW4VYIm36I9cpDTQIg marker;
tyProc__WSm2xU5ARYv9aAR4l0z9c9auQ deepcopy;
};
typedef NU8 tyEnum_TNimNodeKind__rrp49bl1h9aEkXfXp9bNg0yZw;
struct TNimNode {
tyEnum_TNimNodeKind__rrp49bl1h9aEkXfXp9bNg0yZw kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct tyObject_Cell__nhn83Yf9cX7rcmG5W9b4oa6g {
NI refcount;
TNimType* typ;
};
struct tyObject_GcStack__qFeGMKlnq6c9cTM2vPWycQQ {
void* bottom;
};
struct tyObject_CellSeq__nav876ELHgxScHhs30CKiA {
NI len;
NI cap;
tyObject_Cell__nhn83Yf9cX7rcmG5W9b4oa6g** d;
};
typedef tyObject_SmallChunk__eUrTKmsk1Dqt5tm2WUT2Lw* tyArray__1eFxjkcKGHnofywkmCV8oQ[256];
typedef NU32 tyArray__BHbOSqU1t9b3Gt7K2c6fQig[24];
typedef tyObject_BigChunk__39bC3HTk2w4NGDjG74oNjmA* tyArray__KxTmKT9a3kTkdwYfqXhEYSw[32];
typedef tyArray__KxTmKT9a3kTkdwYfqXhEYSw tyArray__ATT5LBefmjy9bg8ApRmg3rw[24];
typedef tyObject_Trunk__Ju1AURWHenTn3cJwAjbUhg* tyArray__RxhBwkGQwTHLKhoK685Xfg[256];
struct tyObject_IntSet__WrQriiGmHk59cB1lNPtGo6A {
tyArray__RxhBwkGQwTHLKhoK685Xfg data;
};
typedef tyObject_AvlNode__aGkK1t9a0WoXjpugXR6FWpw* tyArray__DrxDrI9bg9apB70ydOoNZrWw[2];
struct tyObject_AvlNode__aGkK1t9a0WoXjpugXR6FWpw {
tyArray__DrxDrI9bg9apB70ydOoNZrWw link;
NI key;
NI upperBound;
NI level;
};
struct tyTuple__p2vAp9cQ6YrpDq9cI3XzEDWA {
tyObject_BigChunk__39bC3HTk2w4NGDjG74oNjmA* Field0;
NI Field1;
};
typedef tyTuple__p2vAp9cQ6YrpDq9cI3XzEDWA tyArray__wsokuoa9bVBSU4gPLKbFaaw[30];
struct tyObject_HeapLinks__5IkCDh5QlsYpsfEMJf6zNw {
NI len;
tyArray__wsokuoa9bVBSU4gPLKbFaaw chunks;
tyObject_HeapLinks__5IkCDh5QlsYpsfEMJf6zNw* next;
};
struct tyObject_MemRegion__6QRscFDo4mEwbg9aL76vDGQ {
NI minLargeObj;
NI maxLargeObj;
tyArray__1eFxjkcKGHnofywkmCV8oQ freeSmallChunks;
NU32 flBitmap;
tyArray__BHbOSqU1t9b3Gt7K2c6fQig slBitmap;
tyArray__ATT5LBefmjy9bg8ApRmg3rw matrix;
tyObject_LLChunk__Fjkr5Ya6Zl0UoUGxG047hA* llmem;
NI currMem;
NI maxMem;
NI freeMem;
NI occ;
NI lastSize;
tyObject_IntSet__WrQriiGmHk59cB1lNPtGo6A chunkStarts;
tyObject_AvlNode__aGkK1t9a0WoXjpugXR6FWpw* root;
tyObject_AvlNode__aGkK1t9a0WoXjpugXR6FWpw* deleted;
tyObject_AvlNode__aGkK1t9a0WoXjpugXR6FWpw* last;
tyObject_AvlNode__aGkK1t9a0WoXjpugXR6FWpw* freeAvlNodes;
NIM_BOOL locked;
NIM_BOOL blockChunkSizeIncrease;
NI nextChunkSize;
tyObject_AvlNode__aGkK1t9a0WoXjpugXR6FWpw bottomData;
tyObject_HeapLinks__5IkCDh5QlsYpsfEMJf6zNw heapLinks;
};
struct tyObject_GcStat__OG9ams3mtFJyICkjTOHbc9bg {
NI stackScans;
NI cycleCollections;
NI maxThreshold;
NI maxStackSize;
NI maxStackCells;
NI cycleTableSize;
NI64 maxPause;
};
struct tyObject_CellSet__A0mJvGLunfUxGkLUtesjdA {
NI counter;
NI max;
tyObject_PageDesc__N7tjEodqPVJaQ6oKQW8YfQ* head;
tyObject_PageDesc__N7tjEodqPVJaQ6oKQW8YfQ** data;
};
struct tyObject_GcHeap__ZRn9bWCksoiGwT2drZZzyWQ {
tyObject_GcStack__qFeGMKlnq6c9cTM2vPWycQQ stack;
NI cycleThreshold;
NI zctThreshold;
tyObject_CellSeq__nav876ELHgxScHhs30CKiA zct;
tyObject_CellSeq__nav876ELHgxScHhs30CKiA decStack;
tyObject_CellSeq__nav876ELHgxScHhs30CKiA tempStack;
NI recGcLock;
tyObject_MemRegion__6QRscFDo4mEwbg9aL76vDGQ region;
tyObject_GcStat__OG9ams3mtFJyICkjTOHbc9bg stat;
tyObject_CellSet__A0mJvGLunfUxGkLUtesjdA marked;
tyObject_CellSeq__nav876ELHgxScHhs30CKiA additionalRoots;
NI gcThreadId;
};
struct tySequence__wDFGR0GrXEVcAPtPuTlVAA {
  TGenericSeq Sup;
  tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA data[SEQ_DECL_SIZE];
};
N_LIB_PRIVATE N_NIMCALL(void, unsureAsgnRef)(void** dest, void* src);
N_LIB_PRIVATE N_NIMCALL(TGenericSeq*, incrSeqV3)(TGenericSeq* s, TNimType* typ);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, copyStringRC1)(NimStringDesc* src);
static N_INLINE(void, nimGCunrefNoCycle)(void* p);
static N_INLINE(void, decRef__system_5326)(tyObject_Cell__nhn83Yf9cX7rcmG5W9b4oa6g* c);
static N_INLINE(NI, minuspercent___system_716)(NI x, NI y);
static N_INLINE(NIM_BOOL, ltpercent___system_1005)(NI x, NI y);
static N_INLINE(void, rtlAddZCT__system_5324)(tyObject_Cell__nhn83Yf9cX7rcmG5W9b4oa6g* c);
N_LIB_PRIVATE N_NOINLINE(void, addZCT__system_5275)(tyObject_CellSeq__nav876ELHgxScHhs30CKiA* s, tyObject_Cell__nhn83Yf9cX7rcmG5W9b4oa6g* c);
static N_INLINE(tyObject_Cell__nhn83Yf9cX7rcmG5W9b4oa6g*, usrToCell__system_5281)(void* usr);
static N_INLINE(void, asgnRef)(void** dest, void* src);
static N_INLINE(void, incRef__system_5319)(tyObject_Cell__nhn83Yf9cX7rcmG5W9b4oa6g* c);
static N_INLINE(NI, pluspercent___system_696)(NI x, NI y);
N_LIB_PRIVATE N_NIMCALL(void, siftup__lookups_1704)(tyObject_HeapQueue__MBC6eEbMfekVnGqjI07yVg* heap, NI startpos, NI p);
static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem__systemZmemory_7)(void* a, int v, NI size);
static N_INLINE(tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA*, X5BX5D___lookups_1764)(tyObject_HeapQueue__MBC6eEbMfekVnGqjI07yVg* heap, NI i);
static N_INLINE(NIM_BOOL, heapCmp__lookups_1843)(tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA* x, tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA* y);
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, lt___lookups_1596)(tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA* a, tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA* b);
static N_INLINE(NI, len__lookups_1696)(tyObject_HeapQueue__MBC6eEbMfekVnGqjI07yVg heap);
static N_INLINE(void, pop__lookups_2058)(tySequence__wDFGR0GrXEVcAPtPuTlVAA** s, tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA* Result);
N_LIB_PRIVATE N_NIMCALL(NimStringDesc*, copyString)(NimStringDesc* src);
N_LIB_PRIVATE N_NIMCALL(TGenericSeq*, setLengthSeqV2)(TGenericSeq* s, TNimType* typ, NI newLen);
N_LIB_PRIVATE N_NIMCALL(void, siftdownToBottom__lookups_2178)(tyObject_HeapQueue__MBC6eEbMfekVnGqjI07yVg* heap, NI p);
extern TNimType NTIseqLspellcandidateT__wDFGR0GrXEVcAPtPuTlVAA_;
extern tyObject_GcHeap__ZRn9bWCksoiGwT2drZZzyWQ gch__system_5228;
N_LIB_PRIVATE N_NIMCALL(void, initHeapQueue__lookups_1629)(tyObject_HeapQueue__MBC6eEbMfekVnGqjI07yVg* Result) {
	unsureAsgnRef((void**)&(*Result).data, NIM_NIL);
}
static N_INLINE(NI, minuspercent___system_716)(NI x, NI y) {
	NI result;
	result = (NI)0;
	result = ((NI) ((NU)((NU64)(((NU) (x))) - (NU64)(((NU) (y))))));
	return result;
}
static N_INLINE(NIM_BOOL, ltpercent___system_1005)(NI x, NI y) {
	NIM_BOOL result;
	result = (NIM_BOOL)0;
	result = ((NU64)(((NU) (x))) < (NU64)(((NU) (y))));
	return result;
}
static N_INLINE(void, rtlAddZCT__system_5324)(tyObject_Cell__nhn83Yf9cX7rcmG5W9b4oa6g* c) {
	addZCT__system_5275((&gch__system_5228.zct), c);
}
static N_INLINE(void, decRef__system_5326)(tyObject_Cell__nhn83Yf9cX7rcmG5W9b4oa6g* c) {
	(*c).refcount = minuspercent___system_716((*c).refcount, ((NI) 8));
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = ltpercent___system_1005((*c).refcount, ((NI) 8));
		if (!T3_) goto LA4_;
		rtlAddZCT__system_5324(c);
	}
	LA4_: ;
}
static N_INLINE(tyObject_Cell__nhn83Yf9cX7rcmG5W9b4oa6g*, usrToCell__system_5281)(void* usr) {
	tyObject_Cell__nhn83Yf9cX7rcmG5W9b4oa6g* result;
	NI T1_;
	result = (tyObject_Cell__nhn83Yf9cX7rcmG5W9b4oa6g*)0;
	T1_ = (NI)0;
	T1_ = minuspercent___system_716(((NI) (ptrdiff_t) (usr)), ((NI) 16));
	result = ((tyObject_Cell__nhn83Yf9cX7rcmG5W9b4oa6g*) (T1_));
	return result;
}
static N_INLINE(void, nimGCunrefNoCycle)(void* p) {
	tyObject_Cell__nhn83Yf9cX7rcmG5W9b4oa6g* T1_;
	T1_ = (tyObject_Cell__nhn83Yf9cX7rcmG5W9b4oa6g*)0;
	T1_ = usrToCell__system_5281(p);
	decRef__system_5326(T1_);
}
static N_INLINE(NI, pluspercent___system_696)(NI x, NI y) {
	NI result;
	result = (NI)0;
	result = ((NI) ((NU)((NU64)(((NU) (x))) + (NU64)(((NU) (y))))));
	return result;
}
static N_INLINE(void, incRef__system_5319)(tyObject_Cell__nhn83Yf9cX7rcmG5W9b4oa6g* c) {
	(*c).refcount = pluspercent___system_696((*c).refcount, ((NI) 8));
}
static N_INLINE(void, asgnRef)(void** dest, void* src) {
	{
		tyObject_Cell__nhn83Yf9cX7rcmG5W9b4oa6g* T5_;
		if (!!((src == NIM_NIL))) goto LA3_;
		T5_ = (tyObject_Cell__nhn83Yf9cX7rcmG5W9b4oa6g*)0;
		T5_ = usrToCell__system_5281(src);
		incRef__system_5319(T5_);
	}
	LA3_: ;
	{
		tyObject_Cell__nhn83Yf9cX7rcmG5W9b4oa6g* T10_;
		if (!!(((*dest) == NIM_NIL))) goto LA8_;
		T10_ = (tyObject_Cell__nhn83Yf9cX7rcmG5W9b4oa6g*)0;
		T10_ = usrToCell__system_5281((*dest));
		decRef__system_5326(T10_);
	}
	LA8_: ;
	(*dest) = src;
}
static N_INLINE(void, nimSetMem__systemZmemory_7)(void* a, int v, NI size) {
	void* T1_;
	T1_ = (void*)0;
	T1_ = memset(a, v, ((size_t) (size)));
}
static N_INLINE(void, nimZeroMem)(void* p, NI size) {
	nimSetMem__systemZmemory_7(p, ((int) 0), size);
}
static N_INLINE(tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA*, X5BX5D___lookups_1764)(tyObject_HeapQueue__MBC6eEbMfekVnGqjI07yVg* heap, NI i) {
	tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA* result;
	result = (tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA*)0;
	result = (&(*heap).data->data[i]);
	return result;
}
static N_INLINE(NIM_BOOL, heapCmp__lookups_1843)(tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA* x, tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA* y) {
	NIM_BOOL result;
	result = (NIM_BOOL)0;
	result = lt___lookups_1596(x, y);
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, siftup__lookups_1704)(tyObject_HeapQueue__MBC6eEbMfekVnGqjI07yVg* heap, NI startpos, NI p) {
	NI pos;
	tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA newitem;
	tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA* T1_;
	NimStringDesc* T12_;
	pos = p;
	nimZeroMem((void*)(&newitem), sizeof(tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA));
	T1_ = (tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA*)0;
	T1_ = X5BX5D___lookups_1764((&(*heap)), ((NI) (pos)));
	newitem.dist = (*T1_).dist;
	newitem.depth = (*T1_).depth;
	newitem.msg = (*T1_).msg;
	newitem.sym = (*T1_).sym;
	{
		while (1) {
			NI parentpos;
			tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA parent;
			tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA* T4_;
			if (!(startpos < pos)) goto LA3;
			parentpos = (NI)((NI64)((NI)(pos - ((NI) 1))) >> (NU64)(((NI) 1)));
			nimZeroMem((void*)(&parent), sizeof(tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA));
			T4_ = (tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA*)0;
			T4_ = X5BX5D___lookups_1764((&(*heap)), ((NI) (parentpos)));
			parent.dist = (*T4_).dist;
			parent.depth = (*T4_).depth;
			parent.msg = (*T4_).msg;
			parent.sym = (*T4_).sym;
			{
				NIM_BOOL T7_;
				NimStringDesc* T10_;
				T7_ = (NIM_BOOL)0;
				T7_ = heapCmp__lookups_1843((&newitem), (&parent));
				if (!T7_) goto LA8_;
				(*heap).data->data[pos].dist = parent.dist;
				(*heap).data->data[pos].depth = parent.depth;
				T10_ = NIM_NIL;
				T10_ = (*heap).data->data[pos].msg; (*heap).data->data[pos].msg = copyStringRC1(parent.msg);
				if (T10_) nimGCunrefNoCycle(T10_);
				asgnRef((void**) (&(*heap).data->data[pos].sym), parent.sym);
				pos = parentpos;
			}
			goto LA5_;
			LA8_: ;
			{
				goto LA2;
			}
			LA5_: ;
		} LA3: ;
	} LA2: ;
	(*heap).data->data[pos].dist = newitem.dist;
	(*heap).data->data[pos].depth = newitem.depth;
	T12_ = NIM_NIL;
	T12_ = (*heap).data->data[pos].msg; (*heap).data->data[pos].msg = copyStringRC1(newitem.msg);
	if (T12_) nimGCunrefNoCycle(T12_);
	asgnRef((void**) (&(*heap).data->data[pos].sym), newitem.sym);
}
static N_INLINE(NI, len__lookups_1696)(tyObject_HeapQueue__MBC6eEbMfekVnGqjI07yVg heap) {
	NI result;
	NI T1_;
	result = (NI)0;
	T1_ = (heap.data ? heap.data->Sup.len : 0);
	result = T1_;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, push__lookups_1642)(tyObject_HeapQueue__MBC6eEbMfekVnGqjI07yVg* heap, tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA* item) {
	NI T1_;
	NimStringDesc* T2_;
	NI T3_;
	unsureAsgnRef((void**) (&(*heap).data), (tySequence__wDFGR0GrXEVcAPtPuTlVAA*) incrSeqV3((TGenericSeq*)((*heap).data), (&NTIseqLspellcandidateT__wDFGR0GrXEVcAPtPuTlVAA_)));
	T1_ = (*heap).data->Sup.len++;
	(*heap).data->data[T1_].dist = (*item).dist;
	(*heap).data->data[T1_].depth = (*item).depth;
	T2_ = NIM_NIL;
	T2_ = (*heap).data->data[T1_].msg; (*heap).data->data[T1_].msg = copyStringRC1((*item).msg);
	if (T2_) nimGCunrefNoCycle(T2_);
	asgnRef((void**) (&(*heap).data->data[T1_].sym), (*item).sym);
	T3_ = (NI)0;
	T3_ = len__lookups_1696((*heap));
	siftup__lookups_1704(heap, ((NI) 0), (NI)(T3_ - ((NI) 1)));
}
static N_INLINE(void, pop__lookups_2058)(tySequence__wDFGR0GrXEVcAPtPuTlVAA** s, tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA* Result) {
	NI L;
	NI T1_;
	T1_ = ((*s) ? (*s)->Sup.len : 0);
	L = (NI)(T1_ - ((NI) 1));
	(*Result).dist = (*s)->data[L].dist;
	(*Result).depth = (*s)->data[L].depth;
	unsureAsgnRef((void**) (&(*Result).msg), copyString((*s)->data[L].msg));
	unsureAsgnRef((void**) (&(*Result).sym), (*s)->data[L].sym);
	unsureAsgnRef((void**) (&(*s)), (tySequence__wDFGR0GrXEVcAPtPuTlVAA*) setLengthSeqV2(((*s))?&((*s))->Sup:NIM_NIL, (&NTIseqLspellcandidateT__wDFGR0GrXEVcAPtPuTlVAA_), ((NI) (L))));
}
N_LIB_PRIVATE N_NIMCALL(void, siftdownToBottom__lookups_2178)(tyObject_HeapQueue__MBC6eEbMfekVnGqjI07yVg* heap, NI p) {
	NI endpos;
	NI pos;
	NI startpos;
	tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA newitem;
	tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA* T1_;
	NI childpos;
	NimStringDesc* T15_;
	endpos = len__lookups_1696((*heap));
	pos = p;
	startpos = pos;
	nimZeroMem((void*)(&newitem), sizeof(tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA));
	T1_ = (tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA*)0;
	T1_ = X5BX5D___lookups_1764((&(*heap)), ((NI) (pos)));
	newitem.dist = (*T1_).dist;
	newitem.depth = (*T1_).depth;
	newitem.msg = (*T1_).msg;
	newitem.sym = (*T1_).sym;
	childpos = (NI)((NI)(((NI) 2) * pos) + ((NI) 1));
	{
		while (1) {
			NI rightpos;
			tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA* T13_;
			NimStringDesc* T14_;
			if (!(childpos < endpos)) goto LA3;
			rightpos = (NI)(childpos + ((NI) 1));
			{
				NIM_BOOL T6_;
				tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA* T8_;
				tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA* T9_;
				NIM_BOOL T10_;
				T6_ = (NIM_BOOL)0;
				T6_ = (rightpos < endpos);
				if (!(T6_)) goto LA7_;
				T8_ = (tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA*)0;
				T8_ = X5BX5D___lookups_1764((&(*heap)), ((NI) (childpos)));
				T9_ = (tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA*)0;
				T9_ = X5BX5D___lookups_1764((&(*heap)), ((NI) (rightpos)));
				T10_ = (NIM_BOOL)0;
				T10_ = heapCmp__lookups_1843((&(*T8_)), (&(*T9_)));
				T6_ = !(T10_);
				LA7_: ;
				if (!T6_) goto LA11_;
				childpos = rightpos;
			}
			LA11_: ;
			T13_ = (tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA*)0;
			T13_ = X5BX5D___lookups_1764((&(*heap)), ((NI) (childpos)));
			(*heap).data->data[pos].dist = (*T13_).dist;
			(*heap).data->data[pos].depth = (*T13_).depth;
			T14_ = NIM_NIL;
			T14_ = (*heap).data->data[pos].msg; (*heap).data->data[pos].msg = copyStringRC1((*T13_).msg);
			if (T14_) nimGCunrefNoCycle(T14_);
			asgnRef((void**) (&(*heap).data->data[pos].sym), (*T13_).sym);
			pos = childpos;
			childpos = (NI)((NI)(((NI) 2) * pos) + ((NI) 1));
		} LA3: ;
	}
	(*heap).data->data[pos].dist = newitem.dist;
	(*heap).data->data[pos].depth = newitem.depth;
	T15_ = NIM_NIL;
	T15_ = (*heap).data->data[pos].msg; (*heap).data->data[pos].msg = copyStringRC1(newitem.msg);
	if (T15_) nimGCunrefNoCycle(T15_);
	asgnRef((void**) (&(*heap).data->data[pos].sym), newitem.sym);
	siftup__lookups_1704(heap, startpos, pos);
}
N_LIB_PRIVATE N_NIMCALL(void, pop__lookups_2054)(tyObject_HeapQueue__MBC6eEbMfekVnGqjI07yVg* heap, tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA* Result) {
	tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA lastelt;
	nimZeroMem((void*)(&lastelt), sizeof(tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA));
	pop__lookups_2058((&(*heap).data), (&lastelt));
	{
		NI T3_;
		tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA* T6_;
		NimStringDesc* T7_;
		T3_ = (NI)0;
		T3_ = len__lookups_1696((*heap));
		if (!(((NI) 0) < T3_)) goto LA4_;
		T6_ = (tyObject_SpellCandidate__ZxujMy1bsXT9c9b7Yfb24WoA*)0;
		T6_ = X5BX5D___lookups_1764((&(*heap)), ((NI) 0));
		(*Result).dist = (*T6_).dist;
		(*Result).depth = (*T6_).depth;
		unsureAsgnRef((void**) (&(*Result).msg), copyString((*T6_).msg));
		unsureAsgnRef((void**) (&(*Result).sym), (*T6_).sym);
		(*heap).data->data[((NI) 0)].dist = lastelt.dist;
		(*heap).data->data[((NI) 0)].depth = lastelt.depth;
		T7_ = NIM_NIL;
		T7_ = (*heap).data->data[((NI) 0)].msg; (*heap).data->data[((NI) 0)].msg = copyStringRC1(lastelt.msg);
		if (T7_) nimGCunrefNoCycle(T7_);
		asgnRef((void**) (&(*heap).data->data[((NI) 0)].sym), lastelt.sym);
		siftdownToBottom__lookups_2178(heap, ((NI) 0));
	}
	goto LA1_;
	LA4_: ;
	{
		(*Result).dist = lastelt.dist;
		(*Result).depth = lastelt.depth;
		unsureAsgnRef((void**) (&(*Result).msg), copyString(lastelt.msg));
		unsureAsgnRef((void**) (&(*Result).sym), lastelt.sym);
	}
	LA1_: ;
}
