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

/* section: NIM_merge_HEADERS */

#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

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

/* section: NIM_merge_FORWARD_TYPES */
typedef struct tySequence__76wc9cnTOK9c6epudv8uYE0w tySequence__76wc9cnTOK9c6epudv8uYE0w;
typedef struct TGenericSeq TGenericSeq;
typedef struct tyObject_DepNcolonObjectType___eVONEEaK4II8kv8La51d2Q tyObject_DepNcolonObjectType___eVONEEaK4II8kv8La51d2Q;
typedef struct tyObject_TNode__bROa11lyF5vxEN9aYNbHmhw tyObject_TNode__bROa11lyF5vxEN9aYNbHmhw;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct tyObject_SuggestcolonObjectType___bkMuTTb2G70XfpzAiyNrnQ tyObject_SuggestcolonObjectType___bkMuTTb2G70XfpzAiyNrnQ;
typedef struct tySequence__i7xpiUsxyv6cQ1xK3JbcGQ tySequence__i7xpiUsxyv6cQ1xK3JbcGQ;
typedef struct tySequence__sM4lkSb7zS6F7OVMvW9cffQ tySequence__sM4lkSb7zS6F7OVMvW9cffQ;
typedef struct NimStringDesc NimStringDesc;

/* section: NIM_merge_TYPES */
struct TGenericSeq {
NI len;
NI reserved;
};
typedef struct {
N_NIMCALL_PTR(NI, ClP_0) (tyObject_DepNcolonObjectType___eVONEEaK4II8kv8La51d2Q* x, tyObject_DepNcolonObjectType___eVONEEaK4II8kv8La51d2Q* y, void* ClE_0);
void* ClE_0;
} tyProc__WrsL3l9cLQ31FpOtAGcGovA;
typedef NU8 tyEnum_SortOrder__8iBc6wlNqBa9cju9cUAhUAxA;
struct tyObject_DepNcolonObjectType___eVONEEaK4II8kv8La51d2Q {
tyObject_TNode__bROa11lyF5vxEN9aYNbHmhw* pnode;
NI id;
NI idx;
NI lowLink;
NIM_BOOL onStack;
tySequence__76wc9cnTOK9c6epudv8uYE0w* kids;
NI hAQ;
NI hIS;
NI hB;
NI hCmd;
};
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;
};
typedef N_CLOSURE_PTR(NI, TM__JdC9c6SaUkvO1XjYuWP1JWQ_2) (tyObject_DepNcolonObjectType___eVONEEaK4II8kv8La51d2Q* x, tyObject_DepNcolonObjectType___eVONEEaK4II8kv8La51d2Q* y);
typedef N_CLOSURE_PTR(NI, TM__JdC9c6SaUkvO1XjYuWP1JWQ_3) (tyObject_DepNcolonObjectType___eVONEEaK4II8kv8La51d2Q* x, tyObject_DepNcolonObjectType___eVONEEaK4II8kv8La51d2Q* y);
typedef struct {
N_NIMCALL_PTR(NI, ClP_0) (tyObject_SuggestcolonObjectType___bkMuTTb2G70XfpzAiyNrnQ* x, tyObject_SuggestcolonObjectType___bkMuTTb2G70XfpzAiyNrnQ* y, void* ClE_0);
void* ClE_0;
} tyProc__pNH4eLNN9aK2oskAhILvUcw;
typedef N_CLOSURE_PTR(NI, TM__JdC9c6SaUkvO1XjYuWP1JWQ_4) (tyObject_SuggestcolonObjectType___bkMuTTb2G70XfpzAiyNrnQ* x, tyObject_SuggestcolonObjectType___bkMuTTb2G70XfpzAiyNrnQ* y);
typedef NU8 tyEnum_IdeCmd__1Ced39bl5eePmZ1PKMPXigQ;
struct NimStringDesc {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef NU8 tyEnum_PrefixMatch__Dkww2nY9cxJVLF9cfoQS5U6Q;
struct tyObject_SuggestcolonObjectType___bkMuTTb2G70XfpzAiyNrnQ {
tyEnum_IdeCmd__1Ced39bl5eePmZ1PKMPXigQ section;
tySequence__sM4lkSb7zS6F7OVMvW9cffQ* qualifiedPath;
NimStringDesc** name;
NimStringDesc* filePath;
NI line;
NI column;
NimStringDesc* doc;
NimStringDesc* forth;
NI quality;
NIM_BOOL isGlobal;
NIM_BOOL contextFits;
tyEnum_PrefixMatch__Dkww2nY9cxJVLF9cfoQS5U6Q prefix;
NU8 symkind;
NI scope;
NI localUsages;
NI globalUsages;
NI tokenLen;
NI version;
};
typedef N_CLOSURE_PTR(NI, TM__JdC9c6SaUkvO1XjYuWP1JWQ_5) (tyObject_SuggestcolonObjectType___bkMuTTb2G70XfpzAiyNrnQ* x, tyObject_SuggestcolonObjectType___bkMuTTb2G70XfpzAiyNrnQ* y);
typedef struct {
N_NIMCALL_PTR(NI, ClP_0) (NimStringDesc* x, NimStringDesc* y, void* ClE_0);
void* ClE_0;
} tyProc__3pmh9bG9bLpdxUjFu9cDtbZaA;
typedef N_CLOSURE_PTR(NI, TM__JdC9c6SaUkvO1XjYuWP1JWQ_6) (NimStringDesc* x, NimStringDesc* y);
typedef N_CLOSURE_PTR(NI, TM__JdC9c6SaUkvO1XjYuWP1JWQ_7) (NimStringDesc* x, NimStringDesc* y);
typedef N_CLOSURE_PTR(NI, TM__JdC9c6SaUkvO1XjYuWP1JWQ_8) (NimStringDesc* x, NimStringDesc* y, void* ClE_0);

/* section: NIM_merge_SEQ_TYPES */
struct tySequence__76wc9cnTOK9c6epudv8uYE0w {
  TGenericSeq Sup;
  tyObject_DepNcolonObjectType___eVONEEaK4II8kv8La51d2Q* data[SEQ_DECL_SIZE];
};
struct tySequence__i7xpiUsxyv6cQ1xK3JbcGQ {
  TGenericSeq Sup;
  tyObject_SuggestcolonObjectType___bkMuTTb2G70XfpzAiyNrnQ* data[SEQ_DECL_SIZE];
};
struct tySequence__sM4lkSb7zS6F7OVMvW9cffQ {
  TGenericSeq Sup;
  NimStringDesc* data[SEQ_DECL_SIZE];
};

/* section: NIM_merge_PROC_HEADERS */
N_LIB_PRIVATE N_NIMCALL(tySequence__76wc9cnTOK9c6epudv8uYE0w*, newSeq__hJ5RQ2a9bsrV6HM2KvQcKQw)(NI len);
N_LIB_PRIVATE N_NIMCALL(void, sort__RFNExLdTcWqapKF59arOtJQ)(tyObject_DepNcolonObjectType___eVONEEaK4II8kv8La51d2Q** a, NI aLen_0, tyProc__WrsL3l9cLQ31FpOtAGcGovA cmp, tyEnum_SortOrder__8iBc6wlNqBa9cju9cUAhUAxA order);
N_LIB_PRIVATE N_NIMCALL(void*, newSeq)(TNimType* typ, NI len);
N_LIB_PRIVATE N_NIMCALL(void, merge__GEs8FtZ7U5DvzlL6FPXvnw)(tyObject_DepNcolonObjectType___eVONEEaK4II8kv8La51d2Q** a, NI aLen_0, tyObject_DepNcolonObjectType___eVONEEaK4II8kv8La51d2Q** b, NI bLen_0, NI lo, NI m, NI hi, tyProc__WrsL3l9cLQ31FpOtAGcGovA cmp, tyEnum_SortOrder__8iBc6wlNqBa9cju9cUAhUAxA order);
static N_INLINE(NI, star___kgZDSIMT2vrZak9bMmeL40walgorithm)(NI x, tyEnum_SortOrder__8iBc6wlNqBa9cju9cUAhUAxA order);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
N_LIB_PRIVATE N_NIMCALL(void, merge__wN9cmUNLRXkCO9a9bI9c7HoOfQ)(tyObject_SuggestcolonObjectType___bkMuTTb2G70XfpzAiyNrnQ** a, NI aLen_0, tyObject_SuggestcolonObjectType___bkMuTTb2G70XfpzAiyNrnQ** b, NI bLen_0, NI lo, NI m, NI hi, tyProc__pNH4eLNN9aK2oskAhILvUcw cmp, tyEnum_SortOrder__8iBc6wlNqBa9cju9cUAhUAxA order);
N_LIB_PRIVATE N_NIMCALL(void, sort__v7Qa2ifMjpImR01uviBTZg)(NimStringDesc** a, NI aLen_0, tyProc__3pmh9bG9bLpdxUjFu9cDtbZaA cmp, tyEnum_SortOrder__8iBc6wlNqBa9cju9cUAhUAxA order);
N_LIB_PRIVATE N_NIMCALL(void, merge__Al6iooUALE9cV6RcaUdKM6Q)(NimStringDesc** a, NI aLen_0, NimStringDesc** b, NI bLen_0, NI lo, NI m, NI hi, tyProc__3pmh9bG9bLpdxUjFu9cDtbZaA cmp, tyEnum_SortOrder__8iBc6wlNqBa9cju9cUAhUAxA order);
N_LIB_PRIVATE N_NIMCALL(NI, cmp__NAicU5bAGXmkx2NJujGi7g_2)(NimStringDesc* x, NimStringDesc* y);
static N_INLINE(void, nimZeroMem)(void* p, NI size);
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(void* a, int v, NI size);

/* section: NIM_merge_DATA */
extern TNimType NTI__76wc9cnTOK9c6epudv8uYE0w_;
extern TNimType NTI__i7xpiUsxyv6cQ1xK3JbcGQ_;
extern TNimType NTI__sM4lkSb7zS6F7OVMvW9cffQ_;

/* section: NIM_merge_VARS */
extern NIM_BOOL nimInErrorMode__759bT87luu8XGcbkw13FUjA;

/* section: NIM_merge_PROCS */
static N_INLINE(NI, star___kgZDSIMT2vrZak9bMmeL40walgorithm)(NI x, tyEnum_SortOrder__8iBc6wlNqBa9cju9cUAhUAxA order) {
	NI result;
	NI y;
	result = (NI)0;
	y = (NI)(order - ((NI) 1));
	result = (NI)((NI)(x ^ y) - y);
	return result;
}
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
	NIM_BOOL* result;
	result = (NIM_BOOL*)0;
	result = (&nimInErrorMode__759bT87luu8XGcbkw13FUjA);
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, merge__GEs8FtZ7U5DvzlL6FPXvnw)(tyObject_DepNcolonObjectType___eVONEEaK4II8kv8La51d2Q** a, NI aLen_0, tyObject_DepNcolonObjectType___eVONEEaK4II8kv8La51d2Q** b, NI bLen_0, NI lo, NI m, NI hi, tyProc__WrsL3l9cLQ31FpOtAGcGovA cmp, tyEnum_SortOrder__8iBc6wlNqBa9cju9cUAhUAxA order) {
	NI j;
	NI bb;
	NI i;
	NI k;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	{
		tyObject_DepNcolonObjectType___eVONEEaK4II8kv8La51d2Q* T3_;
		NI T4_;
		NI T5_;
		T3_ = (tyObject_DepNcolonObjectType___eVONEEaK4II8kv8La51d2Q*)0;
		T3_ = a[m];
		T4_ = (NI)0;
		T4_ = cmp.ClE_0? cmp.ClP_0(T3_, a[(NI)(m + ((NI) 1))], cmp.ClE_0):((TM__JdC9c6SaUkvO1XjYuWP1JWQ_2)(cmp.ClP_0))(T3_, a[(NI)(m + ((NI) 1))]);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		T5_ = (NI)0;
		T5_ = star___kgZDSIMT2vrZak9bMmeL40walgorithm(T4_, order);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		if (!(T5_ <= ((NI) 0))) goto LA6_;
		goto BeforeRet_;
	}
	LA6_: ;
	j = lo;
	bb = ((NI) 0);
	{
		while (1) {
			if (!(j <= m)) goto LA9;
			b[bb] = a[j];
			bb += ((NI) 1);
			j += ((NI) 1);
		} LA9: ;
	}
	i = ((NI) 0);
	k = lo;
	{
		while (1) {
			NIM_BOOL T12_;
			T12_ = (NIM_BOOL)0;
			T12_ = (k < j);
			if (!(T12_)) goto LA13_;
			T12_ = (j <= hi);
			LA13_: ;
			if (!T12_) goto LA11;
			{
				NI T16_;
				NI T17_;
				T16_ = (NI)0;
				T16_ = cmp.ClE_0? cmp.ClP_0(b[i], a[j], cmp.ClE_0):((TM__JdC9c6SaUkvO1XjYuWP1JWQ_3)(cmp.ClP_0))(b[i], a[j]);
				if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
				T17_ = (NI)0;
				T17_ = star___kgZDSIMT2vrZak9bMmeL40walgorithm(T16_, order);
				if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
				if (!(T17_ <= ((NI) 0))) goto LA18_;
				a[k] = b[i];
				i += ((NI) 1);
			}
			goto LA14_;
			LA18_: ;
			{
				a[k] = a[j];
				j += ((NI) 1);
			}
			LA14_: ;
			k += ((NI) 1);
		} LA11: ;
	}
	{
		while (1) {
			if (!(k < j)) goto LA22;
			a[k] = b[i];
			k += ((NI) 1);
			i += ((NI) 1);
		} LA22: ;
	}
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(void, sort__RFNExLdTcWqapKF59arOtJQ)(tyObject_DepNcolonObjectType___eVONEEaK4II8kv8La51d2Q** a, NI aLen_0, tyProc__WrsL3l9cLQ31FpOtAGcGovA cmp, tyEnum_SortOrder__8iBc6wlNqBa9cju9cUAhUAxA order) {
	NI n;
	tySequence__76wc9cnTOK9c6epudv8uYE0w* b;
	NI s;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	n = aLen_0;
	b = (tySequence__76wc9cnTOK9c6epudv8uYE0w*)0;
	b = (tySequence__76wc9cnTOK9c6epudv8uYE0w*) newSeq((&NTI__76wc9cnTOK9c6epudv8uYE0w_), ((NI) ((NI)(n / ((NI) 2)))));
	s = ((NI) 1);
	{
		while (1) {
			NI m;
			if (!(s < n)) goto LA2;
			m = (NI)((NI)(n - ((NI) 1)) - s);
			{
				while (1) {
					NI T5_;
					NI T6_;
					if (!(((NI) 0) <= m)) goto LA4;
					T5_ = (NI)0;
					T5_ = (((NI)((NI)(m - s) + ((NI) 1)) >= ((NI) 0)) ? (NI)((NI)(m - s) + ((NI) 1)) : ((NI) 0));
					T6_ = (NI)0;
					T6_ = m;
					merge__GEs8FtZ7U5DvzlL6FPXvnw(a, aLen_0, b->data, (b ? b->Sup.len : 0), T5_, T6_, (NI)(m + s), cmp, order);
					if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
					m -= (NI)(s * ((NI) 2));
				} LA4: ;
			}
			s = (NI)(s * ((NI) 2));
		} LA2: ;
	}
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(tySequence__76wc9cnTOK9c6epudv8uYE0w*, sorted__Ts2pk9ca7fHEXfn1pvOuyMw)(tyObject_DepNcolonObjectType___eVONEEaK4II8kv8La51d2Q** a, NI aLen_0, tyProc__WrsL3l9cLQ31FpOtAGcGovA cmp, tyEnum_SortOrder__8iBc6wlNqBa9cju9cUAhUAxA order) {
	tySequence__76wc9cnTOK9c6epudv8uYE0w* result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (tySequence__76wc9cnTOK9c6epudv8uYE0w*)0;
	result = newSeq__hJ5RQ2a9bsrV6HM2KvQcKQw(((NI) (aLen_0)));
	{
		NI i;
		NI colontmp_;
		NI res;
		i = (NI)0;
		colontmp_ = (NI)0;
		colontmp_ = (aLen_0-1);
		res = ((NI) 0);
		{
			while (1) {
				if (!(res <= colontmp_)) goto LA3;
				i = res;
				result->data[i] = a[i];
				res += ((NI) 1);
			} LA3: ;
		}
	}
	sort__RFNExLdTcWqapKF59arOtJQ(result->data, (result ? result->Sup.len : 0), cmp, order);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, merge__wN9cmUNLRXkCO9a9bI9c7HoOfQ)(tyObject_SuggestcolonObjectType___bkMuTTb2G70XfpzAiyNrnQ** a, NI aLen_0, tyObject_SuggestcolonObjectType___bkMuTTb2G70XfpzAiyNrnQ** b, NI bLen_0, NI lo, NI m, NI hi, tyProc__pNH4eLNN9aK2oskAhILvUcw cmp, tyEnum_SortOrder__8iBc6wlNqBa9cju9cUAhUAxA order) {
	NI j;
	NI bb;
	NI i;
	NI k;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	{
		tyObject_SuggestcolonObjectType___bkMuTTb2G70XfpzAiyNrnQ* T3_;
		NI T4_;
		NI T5_;
		T3_ = (tyObject_SuggestcolonObjectType___bkMuTTb2G70XfpzAiyNrnQ*)0;
		T3_ = a[m];
		T4_ = (NI)0;
		T4_ = cmp.ClE_0? cmp.ClP_0(T3_, a[(NI)(m + ((NI) 1))], cmp.ClE_0):((TM__JdC9c6SaUkvO1XjYuWP1JWQ_4)(cmp.ClP_0))(T3_, a[(NI)(m + ((NI) 1))]);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		T5_ = (NI)0;
		T5_ = star___kgZDSIMT2vrZak9bMmeL40walgorithm(T4_, order);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		if (!(T5_ <= ((NI) 0))) goto LA6_;
		goto BeforeRet_;
	}
	LA6_: ;
	j = lo;
	bb = ((NI) 0);
	{
		while (1) {
			if (!(j <= m)) goto LA9;
			b[bb] = a[j];
			bb += ((NI) 1);
			j += ((NI) 1);
		} LA9: ;
	}
	i = ((NI) 0);
	k = lo;
	{
		while (1) {
			NIM_BOOL T12_;
			T12_ = (NIM_BOOL)0;
			T12_ = (k < j);
			if (!(T12_)) goto LA13_;
			T12_ = (j <= hi);
			LA13_: ;
			if (!T12_) goto LA11;
			{
				NI T16_;
				NI T17_;
				T16_ = (NI)0;
				T16_ = cmp.ClE_0? cmp.ClP_0(b[i], a[j], cmp.ClE_0):((TM__JdC9c6SaUkvO1XjYuWP1JWQ_5)(cmp.ClP_0))(b[i], a[j]);
				if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
				T17_ = (NI)0;
				T17_ = star___kgZDSIMT2vrZak9bMmeL40walgorithm(T16_, order);
				if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
				if (!(T17_ <= ((NI) 0))) goto LA18_;
				a[k] = b[i];
				i += ((NI) 1);
			}
			goto LA14_;
			LA18_: ;
			{
				a[k] = a[j];
				j += ((NI) 1);
			}
			LA14_: ;
			k += ((NI) 1);
		} LA11: ;
	}
	{
		while (1) {
			if (!(k < j)) goto LA22;
			a[k] = b[i];
			k += ((NI) 1);
			i += ((NI) 1);
		} LA22: ;
	}
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(void, sort__9bZAwMDiICxVWu0iUtdMZaw)(tyObject_SuggestcolonObjectType___bkMuTTb2G70XfpzAiyNrnQ** a, NI aLen_0, tyProc__pNH4eLNN9aK2oskAhILvUcw cmp, tyEnum_SortOrder__8iBc6wlNqBa9cju9cUAhUAxA order) {
	NI n;
	tySequence__i7xpiUsxyv6cQ1xK3JbcGQ* b;
	NI s;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	n = aLen_0;
	b = (tySequence__i7xpiUsxyv6cQ1xK3JbcGQ*)0;
	b = (tySequence__i7xpiUsxyv6cQ1xK3JbcGQ*) newSeq((&NTI__i7xpiUsxyv6cQ1xK3JbcGQ_), ((NI) ((NI)(n / ((NI) 2)))));
	s = ((NI) 1);
	{
		while (1) {
			NI m;
			if (!(s < n)) goto LA2;
			m = (NI)((NI)(n - ((NI) 1)) - s);
			{
				while (1) {
					NI T5_;
					NI T6_;
					if (!(((NI) 0) <= m)) goto LA4;
					T5_ = (NI)0;
					T5_ = (((NI)((NI)(m - s) + ((NI) 1)) >= ((NI) 0)) ? (NI)((NI)(m - s) + ((NI) 1)) : ((NI) 0));
					T6_ = (NI)0;
					T6_ = m;
					merge__wN9cmUNLRXkCO9a9bI9c7HoOfQ(a, aLen_0, b->data, (b ? b->Sup.len : 0), T5_, T6_, (NI)(m + s), cmp, order);
					if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
					m -= (NI)(s * ((NI) 2));
				} LA4: ;
			}
			s = (NI)(s * ((NI) 2));
		} LA2: ;
	}
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(void, merge__Al6iooUALE9cV6RcaUdKM6Q)(NimStringDesc** a, NI aLen_0, NimStringDesc** b, NI bLen_0, NI lo, NI m, NI hi, tyProc__3pmh9bG9bLpdxUjFu9cDtbZaA cmp, tyEnum_SortOrder__8iBc6wlNqBa9cju9cUAhUAxA order) {
	NI j;
	NI bb;
	NI i;
	NI k;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	{
		NimStringDesc* T3_;
		NI T4_;
		NI T5_;
		T3_ = (NimStringDesc*)0;
		T3_ = a[m];
		T4_ = (NI)0;
		T4_ = cmp.ClE_0? cmp.ClP_0(T3_, a[(NI)(m + ((NI) 1))], cmp.ClE_0):((TM__JdC9c6SaUkvO1XjYuWP1JWQ_6)(cmp.ClP_0))(T3_, a[(NI)(m + ((NI) 1))]);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		T5_ = (NI)0;
		T5_ = star___kgZDSIMT2vrZak9bMmeL40walgorithm(T4_, order);
		if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
		if (!(T5_ <= ((NI) 0))) goto LA6_;
		goto BeforeRet_;
	}
	LA6_: ;
	j = lo;
	bb = ((NI) 0);
	{
		while (1) {
			if (!(j <= m)) goto LA9;
			b[bb] = a[j];
			bb += ((NI) 1);
			j += ((NI) 1);
		} LA9: ;
	}
	i = ((NI) 0);
	k = lo;
	{
		while (1) {
			NIM_BOOL T12_;
			T12_ = (NIM_BOOL)0;
			T12_ = (k < j);
			if (!(T12_)) goto LA13_;
			T12_ = (j <= hi);
			LA13_: ;
			if (!T12_) goto LA11;
			{
				NI T16_;
				NI T17_;
				T16_ = (NI)0;
				T16_ = cmp.ClE_0? cmp.ClP_0(b[i], a[j], cmp.ClE_0):((TM__JdC9c6SaUkvO1XjYuWP1JWQ_7)(cmp.ClP_0))(b[i], a[j]);
				if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
				T17_ = (NI)0;
				T17_ = star___kgZDSIMT2vrZak9bMmeL40walgorithm(T16_, order);
				if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
				if (!(T17_ <= ((NI) 0))) goto LA18_;
				a[k] = b[i];
				i += ((NI) 1);
			}
			goto LA14_;
			LA18_: ;
			{
				a[k] = a[j];
				j += ((NI) 1);
			}
			LA14_: ;
			k += ((NI) 1);
		} LA11: ;
	}
	{
		while (1) {
			if (!(k < j)) goto LA22;
			a[k] = b[i];
			k += ((NI) 1);
			i += ((NI) 1);
		} LA22: ;
	}
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(void, sort__v7Qa2ifMjpImR01uviBTZg)(NimStringDesc** a, NI aLen_0, tyProc__3pmh9bG9bLpdxUjFu9cDtbZaA cmp, tyEnum_SortOrder__8iBc6wlNqBa9cju9cUAhUAxA order) {
	NI n;
	tySequence__sM4lkSb7zS6F7OVMvW9cffQ* b;
	NI s;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	n = aLen_0;
	b = (tySequence__sM4lkSb7zS6F7OVMvW9cffQ*)0;
	b = (tySequence__sM4lkSb7zS6F7OVMvW9cffQ*) newSeq((&NTI__sM4lkSb7zS6F7OVMvW9cffQ_), ((NI) ((NI)(n / ((NI) 2)))));
	s = ((NI) 1);
	{
		while (1) {
			NI m;
			if (!(s < n)) goto LA2;
			m = (NI)((NI)(n - ((NI) 1)) - s);
			{
				while (1) {
					NI T5_;
					NI T6_;
					if (!(((NI) 0) <= m)) goto LA4;
					T5_ = (NI)0;
					T5_ = (((NI)((NI)(m - s) + ((NI) 1)) >= ((NI) 0)) ? (NI)((NI)(m - s) + ((NI) 1)) : ((NI) 0));
					T6_ = (NI)0;
					T6_ = m;
					merge__Al6iooUALE9cV6RcaUdKM6Q(a, aLen_0, b->data, (b ? b->Sup.len : 0), T5_, T6_, (NI)(m + s), cmp, order);
					if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
					m -= (NI)(s * ((NI) 2));
				} LA4: ;
			}
			s = (NI)(s * ((NI) 2));
		} LA2: ;
	}
	}BeforeRet_: ;
}
static N_INLINE(void, nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory)(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) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	nimSetMem__zxfKBYntu9cBapkhrCOk1fgmemory(p, ((int) 0), size);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(void, sort__QeVk9c1PKgtuLn69cFZt89cSg)(NimStringDesc** a, NI aLen_0, tyEnum_SortOrder__8iBc6wlNqBa9cju9cUAhUAxA order) {
	tyProc__3pmh9bG9bLpdxUjFu9cDtbZaA T1_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	nimZeroMem((void*)(&T1_), sizeof(tyProc__3pmh9bG9bLpdxUjFu9cDtbZaA));
	T1_.ClP_0 = ((TM__JdC9c6SaUkvO1XjYuWP1JWQ_8) (cmp__NAicU5bAGXmkx2NJujGi7g_2)); T1_.ClE_0 = NIM_NIL;
	sort__v7Qa2ifMjpImR01uviBTZg(a, aLen_0, T1_, order);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
}
