/* Generated by Nim Compiler v2.2.4 */
#define NIM_INTBITS 64

#include "nimbase.h"
#include <io.h>
#include <string.h>
#include <stdio.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
typedef struct tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg;
typedef struct tyObject_RefHeader__GDnGTjNyvwISJbkIvAst3A tyObject_RefHeader__GDnGTjNyvwISJbkIvAst3A;
typedef struct NimStrPayload NimStrPayload;
typedef struct NimStringV2 NimStringV2;
typedef struct tyObject_CONSOLE_SCREEN_BUFFER_INFO__qa0n9ahHNqSQn9cgENr0664Q tyObject_CONSOLE_SCREEN_BUFFER_INFO__qa0n9ahHNqSQn9cgENr0664Q;
typedef struct tyObject_COORD__gAdCuMlhFe3p5ReyM48CYw tyObject_COORD__gAdCuMlhFe3p5ReyM48CYw;
typedef struct tyObject_SMALL_RECT__p9ahBWMtdL1ta9caHtD9cqveQ tyObject_SMALL_RECT__p9ahBWMtdL1ta9caHtD9cqveQ;
typedef NU16 tySet_tyEnum_Style__eUA1W69bfnUNuraRJtJ0MmA;
struct tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg {
	NIM_BOOL trueColorIsSupported;
	NIM_BOOL trueColorIsEnabled;
	NIM_BOOL fgSetColor;
	NI hStdout;
	NI hStderr;
	NI16 oldStdoutAttr;
	NI16 oldStderrAttr;
};
struct tyObject_RefHeader__GDnGTjNyvwISJbkIvAst3A {
	NI rc;
	NI rootIdx;
};
typedef N_STDCALL_PTR(NI, tyProc__zP2zGemcuVRvOUE82f9a0Pw) (NI32 nStdHandle_p0);
struct NimStrPayload {
	NI cap;
	NIM_CHAR data[SEQ_DECL_SIZE];
};
struct NimStringV2 {
	NI len;
	NimStrPayload* p;
};
typedef N_STDCALL_PTR(NI32, tyProc__oew1DfaGl5XhHmnBK0HYXQ) (NI hSourceProcessHandle_p0, NI hSourceHandle_p1, NI hTargetProcessHandle_p2, NI* lpTargetHandle_p3, NI32 dwDesiredAccess_p4, NI32 bInheritHandle_p5, NI32 dwOptions_p6);
typedef N_STDCALL_PTR(NI, tyProc__uryidYWkntM7ddjZSyxvyQ) (void);
struct tyObject_COORD__gAdCuMlhFe3p5ReyM48CYw {
	NI16 x;
	NI16 y;
};
struct tyObject_SMALL_RECT__p9ahBWMtdL1ta9caHtD9cqveQ {
	NI16 left;
	NI16 top;
	NI16 right;
	NI16 bottom;
};
struct tyObject_CONSOLE_SCREEN_BUFFER_INFO__qa0n9ahHNqSQn9cgENr0664Q {
	tyObject_COORD__gAdCuMlhFe3p5ReyM48CYw dwSize;
	tyObject_COORD__gAdCuMlhFe3p5ReyM48CYw dwCursorPosition;
	NI16 wAttributes;
	tyObject_SMALL_RECT__p9ahBWMtdL1ta9caHtD9cqveQ srWindow;
	tyObject_COORD__gAdCuMlhFe3p5ReyM48CYw dwMaximumWindowSize;
};
typedef N_STDCALL_PTR(NI32, tyProc__Wx9cXkAm67iuspPIC9c89cNXg) (NI hConsoleOutput_p0, tyObject_CONSOLE_SCREEN_BUFFER_INFO__qa0n9ahHNqSQn9cgENr0664Q* lpConsoleScreenBufferInfo_p1);
typedef NU8 tyEnum_Style__eUA1W69bfnUNuraRJtJ0MmA;
typedef N_STDCALL_PTR(NI32, tyProc__oPCjp4xTgEl9a8fqSzOv8lw) (NI hConsoleOutput_p0, NI16 wAttributes_p1);
typedef NU8 tyEnum_ForegroundColor__prdrXkAw6H7iUBRVoWE3cg;
typedef NI tyArray__X1VMP4Gk3zH9b0EJjlUt9csA[10];
N_LIB_PRIVATE N_NIMCALL(int, getFileHandle__stdZsyncio_u303)(FILE* f_p0);
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void);
static N_INLINE(tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg*, getTerminal__pureZterminal_u19)(void);
N_LIB_PRIVATE N_NIMCALL(void, eqsink___pureZterminal_u36)(tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg** dest_p0, tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg* src_p1);
static N_INLINE(NIM_BOOL, nimDecRefIsLast)(void* p_p0);
static N_INLINE(NI, minuspercent___system_u805)(NI x_p0, NI y_p1);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___pureZterminal_u45)(tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg* dest_p0);
N_LIB_PRIVATE N_NIMCALL(void, nimRawDispose)(void* p_p0, NI alignment_p1);
N_LIB_PRIVATE N_NIMCALL(tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg*, newTerminal__pureZterminal_u18)(void);
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___pureZterminal_u27)(tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg* dest_p0);
N_LIB_PRIVATE N_NIMCALL(void*, nimNewObj)(NI size_p0, NI alignment_p1);
N_LIB_PRIVATE N_NIMCALL(void, initTerminal__pureZterminal_u262)(tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg* term_p0);
N_LIB_PRIVATE N_NIMCALL(void*, nimLoadLibrary)(NimStringV2 path_p0);
N_LIB_PRIVATE N_NIMCALL(void, nimLoadLibraryError)(NimStringV2 path_p0);
N_LIB_PRIVATE N_NIMCALL(void*, nimGetProcAddr)(void* lib_p0, NCSTRING name_p1);
N_LIB_PRIVATE N_NIMCALL(NI16, getAttributes__pureZterminal_u258)(NI h_p0);
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1);
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2);
N_LIB_PRIVATE N_NIMCALL(void, eqcopy___pureZterminal_u30)(tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg** dest_p0, tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg* src_p1);
static N_INLINE(void, nimIncRef)(void* p_p0);
static const struct {
  NI cap; NIM_CHAR data[8+1];
} TM__CN3raB9atujkEiPpxYAdlgQ_4 = { 8 | NIM_STRLIT_FLAG, "kernel32" };
static const NimStringV2 TM__CN3raB9atujkEiPpxYAdlgQ_5 = {8, (NimStrPayload*)&TM__CN3raB9atujkEiPpxYAdlgQ_4};
static const struct {
  NI cap; NIM_CHAR data[8+1];
} TM__CN3raB9atujkEiPpxYAdlgQ_6 = { 8 | NIM_STRLIT_FLAG, "kernel32" };
static const NimStringV2 TM__CN3raB9atujkEiPpxYAdlgQ_7 = {8, (NimStrPayload*)&TM__CN3raB9atujkEiPpxYAdlgQ_6};
N_LIB_PRIVATE NIM_CONST tyArray__X1VMP4Gk3zH9b0EJjlUt9csA lookup__pureZterminal_u569 = {((NI)0),
((NI)4),
((NI)2),
((NI)6),
((NI)1),
((NI)5),
((NI)3),
((NI)7),
((NI)0),
((NI)0)}
;
N_LIB_PRIVATE tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg* gTerm__pureZterminal_u17;
N_LIB_PRIVATE NI16 defaultForegroundColor__pureZterminal_u555 = ((NI16)-1);
N_LIB_PRIVATE NI16 defaultBackgroundColor__pureZterminal_u556 = ((NI16)-1);
extern NIM_BOOL nimInErrorMode__system_u4304;
extern tyProc__zP2zGemcuVRvOUE82f9a0Pw Dl_1426063524_;
static void* TM__CN3raB9atujkEiPpxYAdlgQ_2;
tyProc__oew1DfaGl5XhHmnBK0HYXQ Dl_1946157167_;
tyProc__uryidYWkntM7ddjZSyxvyQ Dl_1946157175_;
tyProc__Wx9cXkAm67iuspPIC9c89cNXg Dl_1946157176_;
tyProc__oPCjp4xTgEl9a8fqSzOv8lw Dl_1946157270_;
static N_INLINE(NIM_BOOL*, nimErrorFlag)(void) {
	NIM_BOOL* result;
	result = (&nimInErrorMode__system_u4304);
	return result;
}
N_LIB_PRIVATE N_NIMCALL(NIM_BOOL, isatty__pureZterminal_u732)(FILE* f_p0) {
	NIM_BOOL result;
	int T1_;
	int T2_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = (NIM_BOOL)0;
	T1_ = (int)0;
	T1_ = getFileHandle__stdZsyncio_u303(f_p0);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	T2_ = (int)0;
	T2_ = _isatty(T1_);
	result = !((T2_ == ((NI32)0)));
	}BeforeRet_: ;
	return result;
}
static N_INLINE(NI, minuspercent___system_u805)(NI x_p0, NI y_p1) {
	NI result;
	result = ((NI) ((NU)((NU64)(((NU) (x_p0))) - (NU64)(((NU) (y_p1))))));
	return result;
}
static N_INLINE(NIM_BOOL, nimDecRefIsLast)(void* p_p0) {
	NIM_BOOL result;
	result = NIM_FALSE;
	{
		tyObject_RefHeader__GDnGTjNyvwISJbkIvAst3A* cell_1;
		NI T5_;
		if (!!((p_p0 == NIM_NIL))) goto LA3_;
		T5_ = (NI)0;
		T5_ = minuspercent___system_u805(((NI) (ptrdiff_t) (p_p0)), ((NI)16));
		cell_1 = ((tyObject_RefHeader__GDnGTjNyvwISJbkIvAst3A*) (T5_));
		{
			if (!((NI)((NI64)((*cell_1).rc) >> (NU64)(((NI)4))) == ((NI)0))) goto LA8_;
			result = NIM_TRUE;
		}
		goto LA6_;
LA8_: ;
		{
			(*cell_1).rc -= ((NI)16);
		}
LA6_: ;
	}
LA3_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___pureZterminal_u45)(tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg* dest_p0) {
}
N_LIB_PRIVATE N_NIMCALL(void, eqsink___pureZterminal_u36)(tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg** dest_p0, tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg* src_p1) {
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = nimDecRefIsLast((*dest_p0));
		if (!T3_) goto LA4_;
		eqdestroy___pureZterminal_u45((&(*(*dest_p0))));
		nimRawDispose((*dest_p0), ((NI)8));
	}
LA4_: ;
	(*dest_p0) = src_p1;
}
N_LIB_PRIVATE N_NIMCALL(void, eqdestroy___pureZterminal_u27)(tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg* dest_p0) {
	{
		NIM_BOOL T3_;
		T3_ = (NIM_BOOL)0;
		T3_ = nimDecRefIsLast(dest_p0);
		if (!T3_) goto LA4_;
		eqdestroy___pureZterminal_u45((&(*dest_p0)));
		nimRawDispose(dest_p0, ((NI)8));
	}
LA4_: ;
}
static N_INLINE(void, nimSetMem__systemZmemory_u7)(void* a_p0, int v_p1, NI size_p2) {
	void* T1_;
	T1_ = (void*)0;
	T1_ = memset(a_p0, v_p1, ((size_t) (size_p2)));
}
static N_INLINE(void, nimZeroMem)(void* p_p0, NI size_p1) {
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	nimSetMem__systemZmemory_u7(p_p0, ((int)0), size_p1);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(NI16, getAttributes__pureZterminal_u258)(NI h_p0) {
	NI16 result;
	tyObject_CONSOLE_SCREEN_BUFFER_INFO__qa0n9ahHNqSQn9cgENr0664Q c_1;
{	nimZeroMem((void*)(&c_1), sizeof(tyObject_CONSOLE_SCREEN_BUFFER_INFO__qa0n9ahHNqSQn9cgENr0664Q));
	{
		NI32 T3_;
		T3_ = (NI32)0;
		T3_ = Dl_1946157176_(h_p0, (&c_1));
		if (!!((T3_ == ((NI32)0)))) goto LA4_;
		result = c_1.wAttributes;
		goto BeforeRet_;
	}
LA4_: ;
	result = ((NI16)112);
	goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, initTerminal__pureZterminal_u262)(tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg* term_p0) {
	NI hStdoutTemp_1;
	NI hStderrTemp_1;
	NI16 T15_;
	NI16 T16_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	hStdoutTemp_1 = Dl_1426063524_(((NI32)-11));
	{
		NI T3_;
		NI T4_;
		NI32 T5_;
		T3_ = (NI)0;
		T3_ = Dl_1946157175_();
		T4_ = (NI)0;
		T4_ = Dl_1946157175_();
		T5_ = (NI32)0;
		T5_ = Dl_1946157167_(T3_, hStdoutTemp_1, T4_, (&(*term_p0).hStdout), ((NI32)0), ((NI32)1), ((NI32)2));
		if (!(T5_ == ((NI32)0))) goto LA6_;
	}
LA6_: ;
	hStderrTemp_1 = Dl_1426063524_(((NI32)-12));
	{
		NI T10_;
		NI T11_;
		NI32 T12_;
		T10_ = (NI)0;
		T10_ = Dl_1946157175_();
		T11_ = (NI)0;
		T11_ = Dl_1946157175_();
		T12_ = (NI32)0;
		T12_ = Dl_1946157167_(T10_, hStderrTemp_1, T11_, (&(*term_p0).hStderr), ((NI32)0), ((NI32)1), ((NI32)2));
		if (!(T12_ == ((NI32)0))) goto LA13_;
	}
LA13_: ;
	T15_ = (NI16)0;
	T15_ = getAttributes__pureZterminal_u258((*term_p0).hStdout);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	(*term_p0).oldStdoutAttr = T15_;
	T16_ = (NI16)0;
	T16_ = getAttributes__pureZterminal_u258((*term_p0).hStderr);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	(*term_p0).oldStderrAttr = T16_;
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg*, newTerminal__pureZterminal_u18)(void) {
	tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg* result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = NIM_NIL;
	eqdestroy___pureZterminal_u27(result);
	result = (tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg*) nimNewObj(sizeof(tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg), NIM_ALIGNOF(tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg));
	initTerminal__pureZterminal_u262(result);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	}BeforeRet_: ;
	return result;
}
static N_INLINE(void, nimIncRef)(void* p_p0) {
	NI T1_;
	T1_ = (NI)0;
	T1_ = minuspercent___system_u805(((NI) (ptrdiff_t) (p_p0)), ((NI)16));
	(*((tyObject_RefHeader__GDnGTjNyvwISJbkIvAst3A*) (T1_))).rc += ((NI)16);
}
N_LIB_PRIVATE N_NIMCALL(void, eqcopy___pureZterminal_u30)(tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg** dest_p0, tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg* src_p1) {
	{
		if (!src_p1) goto LA3_;
		nimIncRef(src_p1);
	}
LA3_: ;
	{
		NIM_BOOL T7_;
		T7_ = (NIM_BOOL)0;
		T7_ = nimDecRefIsLast((*dest_p0));
		if (!T7_) goto LA8_;
		eqdestroy___pureZterminal_u45((&(*(*dest_p0))));
		nimRawDispose((*dest_p0), ((NI)8));
	}
LA8_: ;
	(*dest_p0) = src_p1;
}
static N_INLINE(tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg*, getTerminal__pureZterminal_u19)(void) {
	tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg* result;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	result = NIM_NIL;
	{
		tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg* T5_;
		if (!(gTerm__pureZterminal_u17 == 0)) goto LA3_;
		T5_ = NIM_NIL;
		T5_ = newTerminal__pureZterminal_u18();
		if (NIM_UNLIKELY(*nimErr_)) {eqdestroy___pureZterminal_u27(T5_); goto BeforeRet_;}
		eqsink___pureZterminal_u36(&gTerm__pureZterminal_u17, T5_);
	}
LA3_: ;
	eqcopy___pureZterminal_u30(&result, gTerm__pureZterminal_u17);
	}BeforeRet_: ;
	return result;
}
N_LIB_PRIVATE N_NIMCALL(void, setStyle__pureZterminal_u493)(FILE* f_p0, tySet_tyEnum_Style__eUA1W69bfnUNuraRJtJ0MmA style_p1) {
	tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg* termX60gensym16__1;
	NI colontmpD_;
	NI colontmpD__2;
	NI h_1;
	NI16 old_1;
	NI16 T6_;
	NI16 a_1;
	NI32 T23_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	termX60gensym16__1 = NIM_NIL;
	colontmpD_ = (NI)0;
	colontmpD__2 = (NI)0;
	termX60gensym16__1 = getTerminal__pureZterminal_u19();
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	{
		if (!(f_p0 == stderr)) goto LA3_;
		colontmpD_ = (*termX60gensym16__1).hStderr;
		h_1 = colontmpD_;
	}
	goto LA1_;
LA3_: ;
	{
		colontmpD__2 = (*termX60gensym16__1).hStdout;
		h_1 = colontmpD__2;
	}
LA1_: ;
	T6_ = (NI16)0;
	T6_ = getAttributes__pureZterminal_u258(h_1);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	old_1 = (NI16)(T6_ & ((NI16)119));
	a_1 = ((NI16)0);
	{
		if (!((style_p1 &((NU16)1<<((NU)((((tyEnum_Style__eUA1W69bfnUNuraRJtJ0MmA)1) - 1))&15U)))!=0)) goto LA9_;
		a_1 = (NI16)(a_1 | ((NI16)8));
	}
LA9_: ;
	{
		if (!((style_p1 &((NU16)1<<((NU)((((tyEnum_Style__eUA1W69bfnUNuraRJtJ0MmA)5) - 1))&15U)))!=0)) goto LA13_;
		a_1 = (NI16)(a_1 | ((NI16)128));
	}
LA13_: ;
	{
		if (!((style_p1 &((NU16)1<<((NU)((((tyEnum_Style__eUA1W69bfnUNuraRJtJ0MmA)7) - 1))&15U)))!=0)) goto LA17_;
		a_1 = (NI16)(a_1 | ((NI16)16384));
	}
LA17_: ;
	{
		if (!((style_p1 &((NU16)1<<((NU)((((tyEnum_Style__eUA1W69bfnUNuraRJtJ0MmA)4) - 1))&15U)))!=0)) goto LA21_;
		a_1 = (NI16)(a_1 | ((NI16)-32768));
	}
LA21_: ;
	T23_ = (NI32)0;
	T23_ = Dl_1946157270_(h_1, (NI16)(old_1 | a_1));
	(void)(T23_);
	eqdestroy___pureZterminal_u27(termX60gensym16__1);
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(void, resetAttributes__pureZterminal_u433)(FILE* f_p0) {
	tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg* term_1;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	term_1 = NIM_NIL;
	term_1 = getTerminal__pureZterminal_u19();
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	{
		NI32 T5_;
		if (!(f_p0 == stderr)) goto LA3_;
		T5_ = (NI32)0;
		T5_ = Dl_1946157270_((*term_1).hStderr, (*term_1).oldStderrAttr);
		(void)(T5_);
	}
	goto LA1_;
LA3_: ;
	{
		NI32 T7_;
		T7_ = (NI32)0;
		T7_ = Dl_1946157270_((*term_1).hStdout, (*term_1).oldStdoutAttr);
		(void)(T7_);
	}
LA1_: ;
	eqdestroy___pureZterminal_u27(term_1);
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(void, setForegroundColor__pureZterminal_u557)(FILE* f_p0, tyEnum_ForegroundColor__prdrXkAw6H7iUBRVoWE3cg fg_p1, NIM_BOOL bright_p2) {
	tyObject_PTerminalcolonObjectType___xEiAH1Ie7g9cRuFfj2NQJxg* termX60gensym21__1;
	NI colontmpD_;
	NI colontmpD__2;
	NI16 colontmpD__3;
	NI16 colontmpD__4;
	NI h_1;
	NI16 old_1;
	NI16 T6_;
NIM_BOOL* nimErr_;
{nimErr_ = nimErrorFlag();
	termX60gensym21__1 = NIM_NIL;
	colontmpD_ = (NI)0;
	colontmpD__2 = (NI)0;
	colontmpD__3 = (NI16)0;
	colontmpD__4 = (NI16)0;
	termX60gensym21__1 = getTerminal__pureZterminal_u19();
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	{
		if (!(f_p0 == stderr)) goto LA3_;
		colontmpD_ = (*termX60gensym21__1).hStderr;
		h_1 = colontmpD_;
	}
	goto LA1_;
LA3_: ;
	{
		colontmpD__2 = (*termX60gensym21__1).hStdout;
		h_1 = colontmpD__2;
	}
LA1_: ;
	T6_ = (NI16)0;
	T6_ = getAttributes__pureZterminal_u258(h_1);
	if (NIM_UNLIKELY(*nimErr_)) goto BeforeRet_;
	old_1 = (NI16)(T6_ & ((NI16)-8));
	{
		if (!(defaultForegroundColor__pureZterminal_u555 == ((NI16)-1))) goto LA9_;
		defaultForegroundColor__pureZterminal_u555 = old_1;
	}
LA9_: ;
	{
		if (!bright_p2) goto LA13_;
		colontmpD__3 = (NI16)(old_1 | ((NI16)8));
		old_1 = colontmpD__3;
	}
	goto LA11_;
LA13_: ;
	{
		colontmpD__4 = (NI16)(old_1 & ((NI16)-9));
		old_1 = colontmpD__4;
	}
LA11_: ;
	{
		NI32 T20_;
		if (!(fg_p1 == ((tyEnum_ForegroundColor__prdrXkAw6H7iUBRVoWE3cg)39))) goto LA18_;
		T20_ = (NI32)0;
		T20_ = Dl_1946157270_(h_1, ((NI16) ((NU16)(((NU16) (old_1)) | ((NU16) (defaultForegroundColor__pureZterminal_u555))))));
		(void)(T20_);
	}
	goto LA16_;
LA18_: ;
	{
		NI32 T22_;
		T22_ = (NI32)0;
		T22_ = Dl_1946157270_(h_1, ((NI16) ((NU16)(((NU16) (old_1)) | ((NU16) (lookup__pureZterminal_u569[(fg_p1)- 30]))))));
		(void)(T22_);
	}
LA16_: ;
	eqdestroy___pureZterminal_u27(termX60gensym21__1);
	}BeforeRet_: ;
}
N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatslibatspureatsterminaldotnim_DatInit000)(void) {
if (!((TM__CN3raB9atujkEiPpxYAdlgQ_2 = nimLoadLibrary(TM__CN3raB9atujkEiPpxYAdlgQ_5))
)) nimLoadLibraryError(TM__CN3raB9atujkEiPpxYAdlgQ_7);
	Dl_1946157167_ = (tyProc__oew1DfaGl5XhHmnBK0HYXQ) nimGetProcAddr(TM__CN3raB9atujkEiPpxYAdlgQ_2, "DuplicateHandle");
	Dl_1946157175_ = (tyProc__uryidYWkntM7ddjZSyxvyQ) nimGetProcAddr(TM__CN3raB9atujkEiPpxYAdlgQ_2, "GetCurrentProcess");
	Dl_1946157176_ = (tyProc__Wx9cXkAm67iuspPIC9c89cNXg) nimGetProcAddr(TM__CN3raB9atujkEiPpxYAdlgQ_2, "GetConsoleScreenBufferInfo");
	Dl_1946157270_ = (tyProc__oPCjp4xTgEl9a8fqSzOv8lw) nimGetProcAddr(TM__CN3raB9atujkEiPpxYAdlgQ_2, "SetConsoleTextAttribute");
}

