/* Generated by Nim Compiler v0.12.0 */
/*   (c) 2015 Andreas Rumpf */
/* The generated code is subject to the original license. */
#define NIM_INTBITS 32

#include "nimbase.h"
#include <string.h>
#include "winsock2.h"
typedef struct Guid113614 Guid113614;
typedef struct TGenericSeq TGenericSeq;
typedef struct NimStringDesc NimStringDesc;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct Win32finddata112219 Win32finddata112219;
typedef struct Securityattributes111267 Securityattributes111267;
typedef struct Startupinfo111269 Startupinfo111269;
typedef struct Processinformation111271 Processinformation111271;
typedef struct Filetime111273 Filetime111273;
typedef struct Addrinfo112868 Addrinfo112868;
typedef struct Tfdset112864 Tfdset112864;
typedef struct Timeval112866 Timeval112866;
typedef NI8 TY113628[8];
struct  Guid113614  {
NI32 D1;
NI16 D2;
NI16 D3;
TY113628 D4;
};
typedef NI8 TY113719[8];
struct  TGenericSeq  {
NI len;
NI reserved;
};
struct  NimStringDesc  {
  TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
typedef N_STDCALL_PTR(NI, TY111639) (NI32 nstdhandle);
typedef N_NIMCALL_PTR(void, TY3889) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, TY3894) (void* p);
struct  TNimType  {
NI size;
NU8 kind;
NU8 flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY3889 marker;
TY3894 deepcopy;
};
typedef N_STDCALL_PTR(int, TY113246) (NI16 wversionrequired, WSADATA* Wsdata);
typedef N_STDCALL_PTR(NI32, TY111663) (NI32 dwflags, void* lpsource, NI32 dwmessageid, NI32 dwlanguageid, void* lpbuffer, NI32 nsize, void* Arguments);
typedef N_STDCALL_PTR(void, TY111805) (void* p);
typedef N_STDCALL_PTR(NI32, TY111658) (void);
typedef N_STDCALL_PTR(NI32, TY112411) (NI16* lpfilename, NI32 nbufferlength, NI16* lpbuffer, NI16** lpfilepart);
typedef N_STDCALL_PTR(NI32, TY111829) (NI handle, NI16* buf, NI32 size);
typedef N_STDCALL_PTR(NI, TY112244) (NI16* lpfilename, Win32finddata112219* lpfindfiledata);
typedef N_STDCALL_PTR(NI32, TY112249) (NI hfindfile, Win32finddata112219* lpfindfiledata);
typedef N_STDCALL_PTR(void, TY112405) (NI hfindfile);
typedef N_STDCALL_PTR(NI32, TY111818) (NI16* pathname, void* security);
typedef N_STDCALL_PTR(NI, TY113362) (NI16* lpfilename, NI32 dwdesiredaccess, NI32 dwsharemode, void* lpsecurityattributes, NI32 dwcreationdisposition, NI32 dwflagsandattributes, NI htemplatefile);
typedef N_STDCALL_PTR(NI32, TY111432) (NI hobject);
typedef N_STDCALL_PTR(NI32, TY113411) (NI hfile, NI32 ldistancetomove, NI32* lpdistancetomovehigh, NI32 dwmovemethod);
typedef N_STDCALL_PTR(NI32, TY113405) (NI hfile);
typedef N_STDCALL_PTR(NI, TY113440) (NI hfile, void* lpfilemappingattributes, NI32 flprotect, NI32 dwmaximumsizehigh, NI32 dwmaximumsizelow, void* lpname);
typedef N_STDCALL_PTR(void*, TY113429) (NI hfilemappingobject, NI32 dwdesiredaccess, NI32 dwfileoffsethigh, NI32 dwfileoffsetlow, NI32 dwnumberofbytestomap, void* lpbaseaddress);
typedef N_STDCALL_PTR(NI32, TY113421) (NI hfile, NI32* lpfilesizehigh);
typedef N_STDCALL_PTR(NI32, TY112418) (NI16* lpfilename);
typedef N_STDCALL_PTR(NI32, TY113602) (void* lpbaseaddress);
typedef N_STDCALL_PTR(NI16*, TY112440) (void);
typedef N_STDCALL_PTR(NI16*, TY112435) (void);
typedef N_STDCALL_PTR(NI32, TY112437) (NI16* para1);
typedef N_STDCALL_PTR(NI32, TY111825) (NI16* lpname, NI16* lpvalue);
typedef N_STDCALL_PTR(NI32, TY111811) (NI32 nbufferlength, NI16* lpbuffer);
typedef N_STDCALL_PTR(NI32, TY111460) (NI* hreadpipe, NI* hwritepipe, Securityattributes111267* lppipeattributes, NI32 nsize);
typedef N_STDCALL_PTR(NI, TY111471) (NI16* lpname, NI32 dwopenmode, NI32 dwpipemode, NI32 nmaxinstances, NI32 noutbuffersize, NI32 ninbuffersize, NI32 ndefaulttimeout, Securityattributes111267* lpsecurityattributes);
typedef N_STDCALL_PTR(NI, TY113357) (void);
typedef N_STDCALL_PTR(NI32, TY113344) (NI hsourceprocesshandle, NI hsourcehandle, NI htargetprocesshandle, NI* lptargethandle, NI32 dwdesiredaccess, NI32 binherithandle, NI32 dwoptions);
typedef N_STDCALL_PTR(NI32, TY111499) (NI16* lpapplicationname, NI16* lpcommandline, Securityattributes111267* lpprocessattributes, Securityattributes111267* lpthreadattributes, NI32 binherithandles, NI32 dwcreationflags, NI16* lpenvironment, NI16* lpcurrentdirectory, Startupinfo111269* lpstartupinfo, Processinformation111271* lpprocessinformation);
typedef N_STDCALL_PTR(NI32, TY111438) (NI hfile, void* Buffer, NI32 nnumberofbytestoread, NI32* lpnumberofbytesread, void* lpoverlapped);
typedef N_STDCALL_PTR(NI32, TY111449) (NI hfile, void* Buffer, NI32 nnumberofbytestowrite, NI32* lpnumberofbyteswritten, void* lpoverlapped);
typedef N_STDCALL_PTR(NI32, TY111617) (NI hhandle, NI32 dwmilliseconds);
typedef N_STDCALL_PTR(NI32, TY111631) (NI hprocess, NI32* lpexitcode);
typedef N_STDCALL_PTR(NI32, TY113371) (NI16* pathname);
typedef N_STDCALL_PTR(NI32, TY112421) (NI16* lpfilename, NI32 dwfileattributes);
typedef N_STDCALL_PTR(NI32, TY111822) (NI16* lppathname);
typedef N_STDCALL_PTR(NI32, TY111815) (NI16* lppathname);
typedef N_STDCALL_PTR(int, TY112430) (NI16* lpexistingfilename, NI16* lpnewfilename, int bfailifexists);
typedef N_STDCALL_PTR(int, TY112425) (NI16* lpexistingfilename, NI16* lpnewfilename, int bfailifexists);
struct  Filetime111273  {
NI32 dwlowdatetime;
NI32 dwhighdatetime;
};
typedef N_STDCALL_PTR(void, TY112625) (Filetime111273* lpsystemtimeasfiletime);
typedef N_STDCALL_PTR(void, TY112632) (NI32 dwmilliseconds);
typedef N_STDCALL_PTR(NI, TY113024) (int af, int typ, int protocol);
typedef N_STDCALL_PTR(int, TY113048) (NI s, SOCKADDR* name, unsigned int namelen);
typedef N_STDCALL_PTR(int, TY113254) (NCSTRING nodename, NCSTRING servname, Addrinfo112868* hints, Addrinfo112868** res);
typedef N_STDCALL_PTR(void, TY113266) (Addrinfo112868* ai);
typedef N_STDCALL_PTR(int, TY113107) (NI s, int backlog);
typedef N_STDCALL_PTR(int, TY113148) (NI s, void* buf, int len, int flags);
typedef N_STDCALL_PTR(NI, TY113038) (NI s, SOCKADDR* a, unsigned int* addrlen);
typedef N_STDCALL_PTR(NCSTRING, TY113273) (IN_ADDR i);
typedef NI TY112916[64];
struct  Tfdset112864  {
int fdcount;
TY112916 fdarray;
};
typedef N_STDCALL_PTR(int, TY113136) (int nfds, Tfdset112864* readfds, Tfdset112864* writefds, Tfdset112864* exceptfds, Timeval112866* timeout);
typedef N_STDCALL_PTR(NIM_BOOL, TY113195) (NI s, Tfdset112864* set);
typedef N_STDCALL_PTR(int, TY113114) (NI s, void* buf, int len, int flags);
typedef N_STDCALL_PTR(int, TY113032) (NI s);
struct  TNimNode  {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
typedef NIM_CHAR TY112874[257];
typedef NIM_CHAR TY112877[129];
typedef NI16 TY112230[260];
typedef NI16 TY112234[14];
struct  Win32finddata112219  {
NI32 dwfileattributes;
Filetime111273 ftcreationtime;
Filetime111273 ftlastaccesstime;
Filetime111273 ftlastwritetime;
NI32 nfilesizehigh;
NI32 nfilesizelow;
NI32 dwreserved0;
NI32 dwreserved1;
TY112230 cfilename;
TY112234 calternatefilename;
};
struct  Securityattributes111267  {
NI32 nlength;
void* lpsecuritydescriptor;
NI32 binherithandle;
};
struct  Startupinfo111269  {
NI32 cb;
NCSTRING lpreserved;
NCSTRING lpdesktop;
NCSTRING lptitle;
NI32 dwx;
NI32 dwy;
NI32 dwxsize;
NI32 dwysize;
NI32 dwxcountchars;
NI32 dwycountchars;
NI32 dwfillattribute;
NI32 dwflags;
NI16 wshowwindow;
NI16 cbreserved2;
void* lpreserved2;
NI hstdinput;
NI hstdoutput;
NI hstderror;
};
struct  Processinformation111271  {
NI hprocess;
NI hthread;
NI32 dwprocessid;
NI32 dwthreadid;
};
typedef NIM_CHAR TY112884[14];
struct  Addrinfo112868  {
int aiflags;
int aifamily;
int aisocktype;
int aiprotocol;
NI aiaddrlen;
NCSTRING aicanonname;
SOCKADDR* aiaddr;
Addrinfo112868* ainext;
};
struct  Timeval112866  {
NI32 tvsec;
NI32 tvusec;
};
N_NIMCALL(void*, nimLoadLibrary)(NimStringDesc* path);
N_NOINLINE(void, nimLoadLibraryError)(NimStringDesc* path);
N_NIMCALL(void*, nimGetProcAddr)(void* lib, NCSTRING name);
NIM_CONST TY113719 TMP19 = {((NI8) -114),
((NI8) -23),
((NI8) 118),
((NI8) -27),
((NI8) -116),
((NI8) 116),
((NI8) 6),
((NI8) 62)}
;
NIM_CONST TY113719 TMP20 = {((NI8) -107),
((NI8) -54),
((NI8) 0),
((NI8) -128),
((NI8) 95),
((NI8) 72),
((NI8) -95),
((NI8) -110)}
;
STRING_LITERAL(TMP139, "kernel32", 8);
STRING_LITERAL(TMP140, "kernel32", 8);
STRING_LITERAL(TMP1165, "Ws2_32.dll", 10);
STRING_LITERAL(TMP1166, "Ws2_32.dll", 10);
Guid113614 Wsaidconnectex_113721;
Guid113614 Wsaidacceptex_113725;
Guid113614 Wsaidgetacceptexsockaddrs_113729;
static void* TMP138;
TY111639 Dl_111638;
TNimType NTI111247; /* Handle */
static void* TMP1164;
TY113246 Dl_113245;
TY111663 Dl_111662;
TY111805 Dl_111804;
TY111658 Dl_111657;
TY112411 Dl_112410;
TY111829 Dl_111828;
TY112244 Dl_112243;
TY112249 Dl_112248;
TY112405 Dl_112404;
TY111818 Dl_111817;
TY113362 Dl_113361;
TY111432 Dl_111431;
TY113411 Dl_113410;
TY113405 Dl_113404;
TY113440 Dl_113439;
TY113429 Dl_113428;
TY113421 Dl_113420;
TY112418 Dl_112417;
TY113602 Dl_113601;
TY112440 Dl_112439;
TY112435 Dl_112434;
TY112437 Dl_112436;
TY111825 Dl_111824;
TY111811 Dl_111810;
TY111460 Dl_111459;
TY111471 Dl_111470;
TY113357 Dl_113356;
TY113344 Dl_113343;
TY111499 Dl_111498;
TY111438 Dl_111437;
TY111449 Dl_111448;
TY111617 Dl_111616;
TY111631 Dl_111630;
TY113371 Dl_113370;
TY112421 Dl_112420;
TY111822 Dl_111821;
TY111815 Dl_111814;
TY112430 Dl_112429;
TY112425 Dl_112424;
TY112625 Dl_112624;
TY112632 Dl_112631;
TY113024 Dl_113023;
TY113048 Dl_113047;
TY113254 Dl_113253;
TY113266 Dl_113265;
TY113107 Dl_113106;
TY113148 Dl_113147;
TY113038 Dl_113037;
TY113273 Dl_113272;
TY113136 Dl_113135;
TY113195 Dl_113194;
TY113114 Dl_113113;
TY113032 Dl_113031;

N_NIMCALL(NI64, rdfiletime_112604)(Filetime111273 f) {
	NI64 result;
	result = 0;
	result = (NI64)(((NI64)(NU64)(NU32)(f.dwlowdatetime)) | (NI64)((NU64)(((NI64)(NU64)(NU32)(f.dwhighdatetime))) << (NU64)(IL64(32))));
	return result;
}

N_NIMCALL(void, Fdzero_113235)(Tfdset112864* s) {
	(*s).fdcount = ((int) 0);
}

N_NIMCALL(void, Fdset_113214)(NI socket, Tfdset112864* s) {
	{
		if (!((*s).fdcount < ((NI32) 64))) goto LA3;
		(*s).fdarray[(((NI) ((*s).fdcount)))- 0] = socket;
		(*s).fdcount += ((NI) 1);
	}
	LA3: ;
}

N_NIMCALL(int, Fdisset_113202)(NI socket, Tfdset112864* set) {
	int result;
	result = 0;
	{
		NIM_BOOL LOC3;
		LOC3 = 0;
		LOC3 = Dl_113194(socket, set);
		if (!LOC3) goto LA4;
		result = ((NI32) 1);
	}
	goto LA1;
	LA4: ;
	{
		result = ((NI32) 0);
	}
	LA1: ;
	return result;
}
NIM_EXTERNC N_NOINLINE(void, stdlib_winleanInit000)(void) {
	Guid113614 LOC1;
	Guid113614 LOC2;
	Guid113614 LOC3;
	memset((void*)(&LOC1), 0, sizeof(LOC1));
	LOC1.D1 = ((NI32) 631375801);
	LOC1.D2 = ((NI16) -8717);
	LOC1.D3 = ((NI16) 18016);
	memcpy((void*)LOC1.D4, (NIM_CONST void*)TMP19, sizeof(TY113628));
	Wsaidconnectex_113721 = LOC1;
	memset((void*)(&LOC2), 0, sizeof(LOC2));
	LOC2.D1 = ((NI32) -1254720015);
	LOC2.D2 = ((NI16) -13396);
	LOC2.D3 = ((NI16) 4559);
	memcpy((void*)LOC2.D4, (NIM_CONST void*)TMP20, sizeof(TY113628));
	Wsaidacceptex_113725 = LOC2;
	memset((void*)(&LOC3), 0, sizeof(LOC3));
	LOC3.D1 = ((NI32) -1254720014);
	LOC3.D2 = ((NI16) -13396);
	LOC3.D3 = ((NI16) 4559);
	memcpy((void*)LOC3.D4, (NIM_CONST void*)TMP20, sizeof(TY113628));
	Wsaidgetacceptexsockaddrs_113729 = LOC3;
}

NIM_EXTERNC N_NOINLINE(void, stdlib_winleanDatInit000)(void) {
NTI111247.size = sizeof(NI);
NTI111247.kind = 31;
NTI111247.base = 0;
NTI111247.flags = 3;
if (!((TMP138 = nimLoadLibrary((NimStringDesc*) &TMP139))
)) nimLoadLibraryError((NimStringDesc*) &TMP140);
	Dl_111638 = (TY111639) nimGetProcAddr(TMP138, "GetStdHandle");
if (!((TMP1164 = nimLoadLibrary((NimStringDesc*) &TMP1165))
)) nimLoadLibraryError((NimStringDesc*) &TMP1166);
	Dl_113245 = (TY113246) nimGetProcAddr(TMP1164, "WSAStartup");
	Dl_111662 = (TY111663) nimGetProcAddr(TMP138, "FormatMessageW");
	Dl_111804 = (TY111805) nimGetProcAddr(TMP138, "LocalFree");
	Dl_111657 = (TY111658) nimGetProcAddr(TMP138, "GetLastError");
	Dl_112410 = (TY112411) nimGetProcAddr(TMP138, "GetFullPathNameW");
	Dl_111828 = (TY111829) nimGetProcAddr(TMP138, "GetModuleFileNameW");
	Dl_112243 = (TY112244) nimGetProcAddr(TMP138, "FindFirstFileW");
	Dl_112248 = (TY112249) nimGetProcAddr(TMP138, "FindNextFileW");
	Dl_112404 = (TY112405) nimGetProcAddr(TMP138, "FindClose");
	Dl_111817 = (TY111818) nimGetProcAddr(TMP138, "CreateDirectoryW");
	Dl_113361 = (TY113362) nimGetProcAddr(TMP138, "CreateFileW");
	Dl_111431 = (TY111432) nimGetProcAddr(TMP138, "CloseHandle");
	Dl_113410 = (TY113411) nimGetProcAddr(TMP138, "SetFilePointer");
	Dl_113404 = (TY113405) nimGetProcAddr(TMP138, "SetEndOfFile");
	Dl_113439 = (TY113440) nimGetProcAddr(TMP138, "CreateFileMappingW");
	Dl_113428 = (TY113429) nimGetProcAddr(TMP138, "MapViewOfFileEx");
	Dl_113420 = (TY113421) nimGetProcAddr(TMP138, "GetFileSize");
	Dl_112417 = (TY112418) nimGetProcAddr(TMP138, "GetFileAttributesW");
	Dl_113601 = (TY113602) nimGetProcAddr(TMP138, "UnmapViewOfFile");
	Dl_112439 = (TY112440) nimGetProcAddr(TMP138, "GetCommandLineW");
	Dl_112434 = (TY112435) nimGetProcAddr(TMP138, "GetEnvironmentStringsW");
	Dl_112436 = (TY112437) nimGetProcAddr(TMP138, "FreeEnvironmentStringsW");
	Dl_111824 = (TY111825) nimGetProcAddr(TMP138, "SetEnvironmentVariableW");
	Dl_111810 = (TY111811) nimGetProcAddr(TMP138, "GetCurrentDirectoryW");
	Dl_111459 = (TY111460) nimGetProcAddr(TMP138, "CreatePipe");
	Dl_111470 = (TY111471) nimGetProcAddr(TMP138, "CreateNamedPipeW");
	Dl_113356 = (TY113357) nimGetProcAddr(TMP138, "GetCurrentProcess");
	Dl_113343 = (TY113344) nimGetProcAddr(TMP138, "DuplicateHandle");
	Dl_111498 = (TY111499) nimGetProcAddr(TMP138, "CreateProcessW");
	Dl_111437 = (TY111438) nimGetProcAddr(TMP138, "ReadFile");
	Dl_111448 = (TY111449) nimGetProcAddr(TMP138, "WriteFile");
	Dl_111616 = (TY111617) nimGetProcAddr(TMP138, "WaitForSingleObject");
	Dl_111630 = (TY111631) nimGetProcAddr(TMP138, "GetExitCodeProcess");
	Dl_113370 = (TY113371) nimGetProcAddr(TMP138, "DeleteFileW");
	Dl_112420 = (TY112421) nimGetProcAddr(TMP138, "SetFileAttributesW");
	Dl_111821 = (TY111822) nimGetProcAddr(TMP138, "RemoveDirectoryW");
	Dl_111814 = (TY111815) nimGetProcAddr(TMP138, "SetCurrentDirectoryW");
	Dl_112429 = (TY112430) nimGetProcAddr(TMP138, "MoveFileW");
	Dl_112424 = (TY112425) nimGetProcAddr(TMP138, "CopyFileW");
	Dl_112624 = (TY112625) nimGetProcAddr(TMP138, "GetSystemTimeAsFileTime");
	Dl_112631 = (TY112632) nimGetProcAddr(TMP138, "Sleep");
	Dl_113023 = (TY113024) nimGetProcAddr(TMP1164, "socket");
	Dl_113047 = (TY113048) nimGetProcAddr(TMP1164, "bind");
	Dl_113253 = (TY113254) nimGetProcAddr(TMP1164, "getaddrinfo");
	Dl_113265 = (TY113266) nimGetProcAddr(TMP1164, "freeaddrinfo");
	Dl_113106 = (TY113107) nimGetProcAddr(TMP1164, "listen");
	Dl_113147 = (TY113148) nimGetProcAddr(TMP1164, "send");
	Dl_113037 = (TY113038) nimGetProcAddr(TMP1164, "accept");
	Dl_113272 = (TY113273) nimGetProcAddr(TMP1164, "inet_ntoa");
	Dl_113135 = (TY113136) nimGetProcAddr(TMP1164, "select");
	Dl_113194 = (TY113195) nimGetProcAddr(TMP1164, "__WSAFDIsSet");
	Dl_113113 = (TY113114) nimGetProcAddr(TMP1164, "recv");
	Dl_113031 = (TY113032) nimGetProcAddr(TMP1164, "closesocket");
}

