Skip to content

Instantly share code, notes, and snippets.

@cuevasclemente
Created February 20, 2015 17:06
Embed
What would you like to do?
Weather App
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
#include <stdio.h>
typedef struct response182008 response182008;
typedef struct NimStringDesc NimStringDesc;
typedef struct TGenericSeq TGenericSeq;
typedef struct stringtableobj145012 stringtableobj145012;
typedef struct sslcontextHEX3Aobjecttype182420 sslcontextHEX3Aobjecttype182420;
typedef struct proxyHEX3Aobjecttype182023 proxyHEX3Aobjecttype182023;
typedef struct TNimType TNimType;
typedef struct TNimNode TNimNode;
typedef struct tcell45148 tcell45148;
typedef struct tcellseq45164 tcellseq45164;
typedef struct tgcheap47416 tgcheap47416;
typedef struct tcellset45160 tcellset45160;
typedef struct tpagedesc45156 tpagedesc45156;
typedef struct tmemregion27410 tmemregion27410;
typedef struct tsmallchunk26640 tsmallchunk26640;
typedef struct tllchunk27404 tllchunk27404;
typedef struct tbigchunk26642 tbigchunk26642;
typedef struct tintset26617 tintset26617;
typedef struct ttrunk26613 ttrunk26613;
typedef struct tavlnode27408 tavlnode27408;
typedef struct tgcstat47414 tgcstat47414;
typedef struct slice84575 slice84575;
typedef struct regexdesc190011 regexdesc190011;
typedef struct TNimObject TNimObject;
typedef struct keyvaluepairseq145010 keyvaluepairseq145010;
typedef struct keyvaluepair145008 keyvaluepair145008;
typedef struct uri141012 uri141012;
typedef struct tbasechunk26638 tbasechunk26638;
typedef struct tfreecell26630 tfreecell26630;
typedef struct tpcre188621 tpcre188621;
typedef struct textra188632 textra188632;
struct TGenericSeq {
NI len;
NI reserved;
};
struct NimStringDesc {
TGenericSeq Sup;
NIM_CHAR data[SEQ_DECL_SIZE];
};
struct response182008 {
NimStringDesc* Field0;
NimStringDesc* Field1;
stringtableobj145012* Field2;
NimStringDesc* Field3;
};
typedef N_NIMCALL_PTR(void, TY3289) (void* p, NI op);
typedef N_NIMCALL_PTR(void*, TY3294) (void* p);
struct TNimType {
NI size;
NU8 kind;
NU8 flags;
TNimType* base;
TNimNode* node;
void* finalizer;
TY3289 marker;
TY3294 deepcopy;
};
struct TNimNode {
NU8 kind;
NI offset;
TNimType* typ;
NCSTRING name;
NI len;
TNimNode** sons;
};
struct tcell45148 {
NI Refcount;
TNimType* Typ;
};
struct tcellseq45164 {
NI Len;
NI Cap;
tcell45148** D;
};
struct tcellset45160 {
NI Counter;
NI Max;
tpagedesc45156* Head;
tpagedesc45156** Data;
};
typedef tsmallchunk26640* TY27422[512];
typedef ttrunk26613* ttrunkbuckets26615[256];
struct tintset26617 {
ttrunkbuckets26615 Data;
};
struct tmemregion27410 {
NI Minlargeobj;
NI Maxlargeobj;
TY27422 Freesmallchunks;
tllchunk27404* Llmem;
NI Currmem;
NI Maxmem;
NI Freemem;
NI Lastsize;
tbigchunk26642* Freechunkslist;
tintset26617 Chunkstarts;
tavlnode27408* Root;
tavlnode27408* Deleted;
tavlnode27408* Last;
tavlnode27408* Freeavlnodes;
};
struct tgcstat47414 {
NI Stackscans;
NI Cyclecollections;
NI Maxthreshold;
NI Maxstacksize;
NI Maxstackcells;
NI Cycletablesize;
NI64 Maxpause;
};
struct tgcheap47416 {
void* Stackbottom;
NI Cyclethreshold;
tcellseq45164 Zct;
tcellseq45164 Decstack;
tcellset45160 Cycleroots;
tcellseq45164 Tempstack;
NI Recgclock;
tmemregion27410 Region;
tgcstat47414 Stat;
};
struct slice84575 {
NI A;
NI B;
};
struct TNimObject {
TNimType* m_type;
};
struct keyvaluepair145008 {
NimStringDesc* Field0;
NimStringDesc* Field1;
};
struct stringtableobj145012 {
TNimObject Sup;
NI Counter;
keyvaluepairseq145010* Data;
NU8 Mode;
};
struct sslcontextHEX3Aobjecttype182420 {
char dummy;
};
struct uri141012 {
NimStringDesc* Scheme;
NimStringDesc* Username;
NimStringDesc* Password;
NimStringDesc* Hostname;
NimStringDesc* Port;
NimStringDesc* Path;
NimStringDesc* Query;
NimStringDesc* Anchor;
NIM_BOOL Opaque;
};
struct proxyHEX3Aobjecttype182023 {
uri141012 Url;
NimStringDesc* Auth;
};
typedef NI TY26620[8];
struct tpagedesc45156 {
tpagedesc45156* Next;
NI Key;
TY26620 Bits;
};
struct tbasechunk26638 {
NI Prevsize;
NI Size;
NIM_BOOL Used;
};
struct tsmallchunk26640 {
tbasechunk26638 Sup;
tsmallchunk26640* Next;
tsmallchunk26640* Prev;
tfreecell26630* Freelist;
NI Free;
NI Acc;
NF Data;
};
struct tllchunk27404 {
NI Size;
NI Acc;
tllchunk27404* Next;
};
struct tbigchunk26642 {
tbasechunk26638 Sup;
tbigchunk26642* Next;
tbigchunk26642* Prev;
NI Align;
NF Data;
};
struct ttrunk26613 {
ttrunk26613* Next;
NI Key;
TY26620 Bits;
};
typedef tavlnode27408* TY27414[2];
struct tavlnode27408 {
TY27414 Link;
NI Key;
NI Upperbound;
NI Level;
};
struct regexdesc190011 {
tpcre188621* H;
textra188632* E;
};
struct tfreecell26630 {
tfreecell26630* Next;
NI Zerofield;
};
struct tpcre188621 {
char dummy;
};
struct textra188632 {
NI Flags;
void* Studydata;
NI Matchlimit;
void* Calloutdata;
NCSTRING Tables;
NI Matchlimitrecursion;
NCSTRING* Mark;
void* Executablejit;
};
struct keyvaluepairseq145010 {
TGenericSeq Sup;
keyvaluepair145008 data[SEQ_DECL_SIZE];
};
N_NIMCALL(void, get_183540)(NimStringDesc* url, NimStringDesc* extraheaders, NI maxredirects, sslcontextHEX3Aobjecttype182420* sslcontext, NI timeout, NimStringDesc* useragent, proxyHEX3Aobjecttype182023* proxy, response182008* Result);
N_NOINLINE(void, chckNil)(void* p);
N_NIMCALL(void, genericReset)(void* dest, TNimType* mt);
N_NIMCALL(NimStringDesc*, copyStringRC1)(NimStringDesc* src);
static N_INLINE(void, nimGCunrefNoCycle)(void* p);
static N_INLINE(tcell45148*, usrtocell_49046)(void* usr);
static N_INLINE(void, rtladdzct_50604)(tcell45148* c);
N_NOINLINE(void, addzct_49017)(tcellseq45164* s, tcell45148* c);
N_NIMCALL(NimStringDesc*, copyStrLast)(NimStringDesc* s, NI start_75228, NI last);
N_NIMCALL(NimStringDesc*, copyStrLast)(NimStringDesc* s, NI first, NI last);
static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src);
static N_INLINE(NimStringDesc*, HEX5BHEX5D_84568)(NimStringDesc* s, slice84575 x);
static N_INLINE(slice84575, HEX2EHEX2E_104074)(NI a_104078, NI b_104080);
static N_INLINE(NIM_BOOL, eqStrings)(NimStringDesc* a, NimStringDesc* b);
N_NIMCALL(NimStringDesc*, replace_191089)(NimStringDesc* s, regexdesc190011* sub, NimStringDesc* by);
N_NIMCALL(regexdesc190011*, re_190118)(NimStringDesc* s, NU8 flags);
static N_INLINE(void, initStackBottomWith)(void* locals);
N_NOINLINE(void, setStackBottom)(void* thestackbottom);
NIM_EXTERNC N_NOINLINE(void, systemInit)(void);
NIM_EXTERNC N_NOINLINE(void, systemDatInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_unsignedInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_unsignedDatInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_parseutilsInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_parseutilsDatInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_strutilsInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_strutilsDatInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_timesInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_timesDatInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_posixInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_posixDatInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_osInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_osDatInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_rawsocketsInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_rawsocketsDatInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_netInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_netDatInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_uriInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_uriDatInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_hashesInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_hashesDatInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_strtabsInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_strtabsDatInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_base64Init)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_base64DatInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_mimetypesInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_mimetypesDatInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_mathInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_mathDatInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_endiansInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_endiansDatInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_oidsInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_oidsDatInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_tablesInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_tablesDatInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_macrosInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_macrosDatInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_selectorsInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_selectorsDatInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_asyncdispatchInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_asyncdispatchDatInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_asyncnetInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_asyncnetDatInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_httpclientInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_httpclientDatInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_pcreInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_pcreDatInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_rtarraysInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_rtarraysDatInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_reInit)(void);
NIM_EXTERNC N_NOINLINE(void, HEX00_reDatInit)(void);
NIM_EXTERNC N_NOINLINE(void, weatherInit)(void);
NIM_EXTERNC N_NOINLINE(void, weatherDatInit)(void);
STRING_LITERAL(TMP147, "http://forecast.weather.gov/MapClick.php?zoneid=NYZ075&TextType"
"=1", 65);
STRING_LITERAL(TMP148, "", 0);
STRING_LITERAL(TMP149, "Nim httpclient/0.1", 18);
STRING_LITERAL(TMP150, "<b>", 3);
STRING_LITERAL(TMP151, "</table>", 8);
STRING_LITERAL(TMP168, "\\<(.*?)>", 8);
STRING_LITERAL(TMP169, "\012", 1);
response182008 resp_192004;
extern sslcontextHEX3Aobjecttype182420* defaultsslcontext_182422;
extern TNimType NTI182008; /* Response */
NimStringDesc* text_192008;
extern tgcheap47416 gch_47444;
NimStringDesc* line_192012;
static N_INLINE(tcell45148*, usrtocell_49046)(void* usr) {
tcell45148* result;
result = 0;
result = ((tcell45148*) ((NI)((NU64)(((NI) (usr))) - (NU64)(((NI)sizeof(tcell45148))))));
return result;
}
static N_INLINE(void, rtladdzct_50604)(tcell45148* c) {
addzct_49017((&gch_47444.Zct), c);
}
static N_INLINE(void, nimGCunrefNoCycle)(void* p) {
tcell45148* c;
c = usrtocell_49046(p);
{
(*c).Refcount -= 8;
if (!((NU64)((*c).Refcount) < (NU64)(8))) goto LA3;
rtladdzct_50604(c);
}
LA3: ;
}
static N_INLINE(void, asgnRefNoCycle)(void** dest, void* src) {
{
tcell45148* c;
if (!!((src == NIM_NIL))) goto LA3;
c = usrtocell_49046(src);
(*c).Refcount += 8;
}
LA3: ;
{
tcell45148* c;
if (!!(((*dest) == NIM_NIL))) goto LA7;
c = usrtocell_49046((*dest));
{
(*c).Refcount -= 8;
if (!((NU64)((*c).Refcount) < (NU64)(8))) goto LA11;
rtladdzct_50604(c);
}
LA11: ;
}
LA7: ;
(*dest) = src;
}
static N_INLINE(NimStringDesc*, HEX5BHEX5D_84568)(NimStringDesc* s, slice84575 x) {
NimStringDesc* result;
NI LOC1;
NI LOC7;
result = 0;
LOC1 = 0;
{
if (!(0 <= x.A)) goto LA4;
LOC1 = x.A;
}
goto LA2;
LA4: ;
{
LOC1 = (NI64)(s->Sup.len + x.A);
}
LA2: ;
LOC7 = 0;
{
if (!(0 <= x.B)) goto LA10;
LOC7 = x.B;
}
goto LA8;
LA10: ;
{
LOC7 = (NI64)(s->Sup.len + x.B);
}
LA8: ;
result = copyStrLast(s, LOC1, LOC7);
return result;
}
static N_INLINE(slice84575, HEX2EHEX2E_104074)(NI a_104078, NI b_104080) {
slice84575 result;
memset((void*)(&result), 0, sizeof(result));
result.A = a_104078;
result.B = b_104080;
return result;
}
static N_INLINE(NIM_BOOL, eqStrings)(NimStringDesc* a, NimStringDesc* b) {
NIM_BOOL result;
NIM_BOOL LOC11;
int LOC13;
{ result = 0;
{
if (!(a == b)) goto LA3;
result = NIM_TRUE;
goto BeforeRet;
}
LA3: ;
{
NIM_BOOL LOC7;
LOC7 = 0;
LOC7 = (a == NIM_NIL);
if (LOC7) goto LA8;
LOC7 = (b == NIM_NIL);
LA8: ;
if (!LOC7) goto LA9;
result = NIM_FALSE;
goto BeforeRet;
}
LA9: ;
LOC11 = 0;
LOC11 = ((*a).Sup.len == (*b).Sup.len);
if (!(LOC11)) goto LA12;
LOC13 = 0;
LOC13 = memcmp(((NCSTRING) ((*a).data)), ((NCSTRING) ((*b).data)), (NI64)((*a).Sup.len * 1));
LOC11 = (LOC13 == ((NI32) 0));
LA12: ;
result = LOC11;
goto BeforeRet;
}BeforeRet: ;
return result;
}
static N_INLINE(void, initStackBottomWith)(void* locals) {
setStackBottom(locals);
}
void PreMainInner() {
systemInit();
HEX00_unsignedDatInit();
HEX00_parseutilsDatInit();
HEX00_strutilsDatInit();
HEX00_timesDatInit();
HEX00_posixDatInit();
HEX00_osDatInit();
HEX00_rawsocketsDatInit();
HEX00_netDatInit();
HEX00_uriDatInit();
HEX00_hashesDatInit();
HEX00_strtabsDatInit();
HEX00_base64DatInit();
HEX00_mimetypesDatInit();
HEX00_mathDatInit();
HEX00_endiansDatInit();
HEX00_oidsDatInit();
HEX00_tablesDatInit();
HEX00_macrosDatInit();
HEX00_selectorsDatInit();
HEX00_asyncdispatchDatInit();
HEX00_asyncnetDatInit();
HEX00_httpclientDatInit();
HEX00_pcreDatInit();
HEX00_rtarraysDatInit();
HEX00_reDatInit();
weatherDatInit();
HEX00_unsignedInit();
HEX00_parseutilsInit();
HEX00_strutilsInit();
HEX00_timesInit();
HEX00_posixInit();
HEX00_osInit();
HEX00_rawsocketsInit();
HEX00_netInit();
HEX00_uriInit();
HEX00_hashesInit();
HEX00_strtabsInit();
HEX00_base64Init();
HEX00_mimetypesInit();
HEX00_mathInit();
HEX00_endiansInit();
HEX00_oidsInit();
HEX00_tablesInit();
HEX00_macrosInit();
HEX00_selectorsInit();
HEX00_asyncdispatchInit();
HEX00_asyncnetInit();
HEX00_httpclientInit();
HEX00_pcreInit();
HEX00_rtarraysInit();
HEX00_reInit();
}
void PreMain() {
void (*volatile inner)();
systemDatInit();
inner = PreMainInner;
initStackBottomWith((void *)&inner);
(*inner)();
}
int cmdCount;
char** cmdLine;
char** gEnv;
N_CDECL(void, NimMainInner)(void) {
weatherInit();
}
N_CDECL(void, NimMain)(void) {
void (*volatile inner)();
PreMain();
inner = NimMainInner;
initStackBottomWith((void *)&inner);
(*inner)();
}
int main(int argc, char** args, char** env) {
cmdLine = args;
cmdCount = argc;
gEnv = env;
NimMain();
return nim_program_result;
}
NIM_EXTERNC N_NOINLINE(void, weatherInit)(void) {
NimStringDesc* LOC1;
chckNil((void*)(&resp_192004));
genericReset((void*)(&resp_192004), (&NTI182008));
get_183540(((NimStringDesc*) &TMP147), ((NimStringDesc*) &TMP148), 5, defaultsslcontext_182422, -1, ((NimStringDesc*) &TMP149), NIM_NIL, (&resp_192004));
LOC1 = 0;
LOC1 = text_192008; text_192008 = copyStringRC1(resp_192004.Field3);
if (LOC1) nimGCunrefNoCycle(LOC1);
{
NI first_192047;
NI last_192049;
first_192047 = 0;
last_192049 = 0;
{
while (1) {
{
while (1) {
if (!!((((NU8)(text_192008->data[last_192049])) == ((NU8)(0)) || ((NU8)(text_192008->data[last_192049])) == ((NU8)(13)) || ((NU8)(text_192008->data[last_192049])) == ((NU8)(10))))) goto LA6;
last_192049 += 1;
} LA6: ;
}
asgnRefNoCycle((void**) (&line_192012), copyStrLast(text_192008, first_192047, (NI64)(last_192049 - 1)));
{
NIM_BOOL LOC9;
slice84575 LOC10;
NimStringDesc* LOC11;
slice84575 LOC13;
NimStringDesc* LOC14;
regexdesc190011* LOC17;
NimStringDesc* LOC18;
LOC9 = 0;
LOC10 = HEX2EHEX2E_104074(0, 2);
LOC11 = 0;
LOC11 = HEX5BHEX5D_84568(line_192012, LOC10);
LOC9 = eqStrings(LOC11, ((NimStringDesc*) &TMP150));
if (LOC9) goto LA12;
LOC13 = HEX2EHEX2E_104074(0, 7);
LOC14 = 0;
LOC14 = HEX5BHEX5D_84568(line_192012, LOC13);
LOC9 = eqStrings(LOC14, ((NimStringDesc*) &TMP151));
LA12: ;
if (!LOC9) goto LA15;
LOC17 = 0;
LOC17 = re_190118(((NimStringDesc*) &TMP168), 24);
LOC18 = 0;
LOC18 = replace_191089(line_192012, LOC17, ((NimStringDesc*) &TMP148));
printf("%s%s\012", LOC18? (LOC18)->data:"nil", ((NimStringDesc*) &TMP169)? (((NimStringDesc*) &TMP169))->data:"nil");
printf("%s\012", ((NimStringDesc*) &TMP169)? (((NimStringDesc*) &TMP169))->data:"nil");
}
LA15: ;
{
if (!((NU8)(text_192008->data[last_192049]) == (NU8)(10))) goto LA21;
last_192049 += 1;
}
goto LA19;
LA21: ;
{
if (!((NU8)(text_192008->data[last_192049]) == (NU8)(13))) goto LA24;
last_192049 += 1;
{
if (!((NU8)(text_192008->data[last_192049]) == (NU8)(10))) goto LA28;
last_192049 += 1;
}
LA28: ;
}
goto LA19;
LA24: ;
{
goto LA3;
}
LA19: ;
first_192047 = last_192049;
}
} LA3: ;
}
}
NIM_EXTERNC N_NOINLINE(void, weatherDatInit)(void) {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment