/* Generated by Nim Compiler v2.2.0 */ #define NIM_INTBITS 64 #include "nimbase.h" #include #include #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 NimStrPayload NimStrPayload; typedef struct NimStringV2 NimStringV2; struct NimStrPayload { NI cap; NIM_CHAR data[SEQ_DECL_SIZE]; }; struct NimStringV2 { NI len; NimStrPayload* p; }; N_LIB_EXPORT N_CDECL(void, nf_init)(void); N_NIMCALL(void, NimMain)(void); N_LIB_EXPORT N_CDECL(int, nf_add)(int a_p0, int b_p1); N_LIB_EXPORT N_CDECL(NCSTRING, nf_greet)(NCSTRING name_p0); static N_INLINE(void, appendString)(NimStringV2* dest_p0, NimStringV2 src_p1); static N_INLINE(void, copyMem__system_u1726)(void* dest_p0, void* source_p1, NI size_p2); static N_INLINE(void, nimCopyMem)(void* dest_p0, void* source_p1, NI size_p2); N_LIB_PRIVATE N_NIMCALL(NimStringV2, cstrToNimstr)(NCSTRING str_p0); N_LIB_PRIVATE N_NIMCALL(NimStringV2, rawNewString)(NI space_p0); N_LIB_PRIVATE N_NOCONV(void*, allocShared0Impl__system_u1757)(NI size_p0); static N_INLINE(NCSTRING, nimToCStringConv)(NimStringV2 s_p0); N_LIB_PRIVATE N_NOCONV(void, deallocShared)(void* p_p0); N_LIB_EXPORT N_CDECL(void, nf_free)(void* p_p0); N_LIB_EXPORT N_CDECL(void, nf_mandelbrot)(NU8* buf_p0, size_t bufLen_p1, int w_p2, int h_p3, double cx_p4, double cy_p5, double scale_p6, int maxIter_p7, int y0_p8, int y1_p9); N_LIB_PRIVATE N_NIMCALL(void, nimTestErrorFlag)(void); N_LIB_PRIVATE N_NIMCALL(void, atmdotdotatsdotdotatsdotdotatsdotdotatsdotdotatsdotdotatsnimatslibatssystemdotnim_Init000)(void); N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void); static const struct { NI cap; NIM_CHAR data[7+1]; } TM__i7QHfD4JiY9boiF0cHv55ow_2 = { 7 | NIM_STRLIT_FLAG, "Hello, " }; static const NimStringV2 TM__i7QHfD4JiY9boiF0cHv55ow_3 = {7, (NimStrPayload*)&TM__i7QHfD4JiY9boiF0cHv55ow_2}; static const struct { NI cap; NIM_CHAR data[11+1]; } TM__i7QHfD4JiY9boiF0cHv55ow_4 = { 11 | NIM_STRLIT_FLAG, ", from Nim!" }; static const NimStringV2 TM__i7QHfD4JiY9boiF0cHv55ow_5 = {11, (NimStrPayload*)&TM__i7QHfD4JiY9boiF0cHv55ow_4}; N_LIB_PRIVATE NIM_BOOL initialized__nimflutter_u2 = NIM_FALSE; N_LIB_EXPORT N_CDECL(void, nf_init)(void) { { if (!!(initialized__nimflutter_u2)) goto LA3_; NimMain(); initialized__nimflutter_u2 = NIM_TRUE; } LA3_: ; } N_LIB_EXPORT N_CDECL(int, nf_add)(int a_p0, int b_p1) { int result; result = (NI32)(a_p0 + b_p1); return result; } static N_INLINE(void, nimCopyMem)(void* dest_p0, void* source_p1, NI size_p2) { void* T1_; T1_ = (void*)0; T1_ = memcpy(dest_p0, source_p1, ((size_t) (size_p2))); } static N_INLINE(void, copyMem__system_u1726)(void* dest_p0, void* source_p1, NI size_p2) { nimCopyMem(dest_p0, source_p1, size_p2); } static N_INLINE(void, appendString)(NimStringV2* dest_p0, NimStringV2 src_p1) { { if (!(((NI)0) < src_p1.len)) goto LA3_; copyMem__system_u1726(((void*) ((&(*(*dest_p0).p).data[(*dest_p0).len]))), ((void*) ((&(*src_p1.p).data[((NI)0)]))), ((NI)(src_p1.len + ((NI)1)))); (*dest_p0).len += src_p1.len; } LA3_: ; } static N_INLINE(NCSTRING, nimToCStringConv)(NimStringV2 s_p0) { NCSTRING result; { if (!(s_p0.len == ((NI)0))) goto LA3_; result = ""; } goto LA1_; LA3_: ; { result = ((NCSTRING) ((*s_p0.p).data)); } LA1_: ; return result; } N_LIB_EXPORT N_CDECL(NCSTRING, nf_greet)(NCSTRING name_p0) { NCSTRING result; NimStringV2 greeting; NimStringV2 colontmpD_; NimStringV2 T1_; NCSTRING buf; void* T2_; result = (NCSTRING)0; greeting.len = 0; greeting.p = NIM_NIL; colontmpD_.len = 0; colontmpD_.p = NIM_NIL; T1_.len = 0; T1_.p = NIM_NIL; colontmpD_ = cstrToNimstr(name_p0); T1_ = rawNewString(colontmpD_.len + 18); appendString((&T1_), TM__i7QHfD4JiY9boiF0cHv55ow_3); appendString((&T1_), colontmpD_); appendString((&T1_), TM__i7QHfD4JiY9boiF0cHv55ow_5); greeting = T1_; T2_ = (void*)0; T2_ = allocShared0Impl__system_u1757(((NI)(greeting.len + ((NI)1)))); buf = ((NCSTRING) (T2_)); copyMem__system_u1726(((void*) (buf)), ((void*) (nimToCStringConv(greeting))), (greeting.len)); result = buf; if (colontmpD_.p && !(colontmpD_.p->cap & NIM_STRLIT_FLAG)) { deallocShared(colontmpD_.p); } if (greeting.p && !(greeting.p->cap & NIM_STRLIT_FLAG)) { deallocShared(greeting.p); } return result; } N_LIB_EXPORT N_CDECL(void, nf_free)(void* p_p0) { { if (!!((p_p0 == NIM_NIL))) goto LA3_; deallocShared(p_p0); } LA3_: ; } N_LIB_EXPORT N_CDECL(void, nf_mandelbrot)(NU8* buf_p0, size_t bufLen_p1, int w_p2, int h_p3, double cx_p4, double cy_p5, double scale_p6, int maxIter_p7, int y0_p8, int y1_p9) { NI64 needed; NF aspect; NF invW; NF invH; { { NIM_BOOL T3_; NIM_BOOL T4_; NIM_BOOL T5_; NIM_BOOL T6_; NIM_BOOL T7_; T3_ = (NIM_BOOL)0; T4_ = (NIM_BOOL)0; T5_ = (NIM_BOOL)0; T6_ = (NIM_BOOL)0; T7_ = (NIM_BOOL)0; T7_ = (buf_p0 == ((NU8*) NIM_NIL)); if (T7_) goto LA8_; T7_ = (w_p2 <= ((NI32)0)); LA8_: ; T6_ = T7_; if (T6_) goto LA9_; T6_ = (h_p3 <= ((NI32)0)); LA9_: ; T5_ = T6_; if (T5_) goto LA10_; T5_ = (maxIter_p7 <= ((NI32)0)); LA10_: ; T4_ = T5_; if (T4_) goto LA11_; T4_ = (y0_p8 < ((NI32)0)); LA11_: ; T3_ = T4_; if (T3_) goto LA12_; T3_ = (y1_p9 <= y0_p8); LA12_: ; if (!T3_) goto LA13_; goto BeforeRet_; } LA13_: ; needed = (NI64)((NI64)(((NI64) ((NI32)(y1_p9 - y0_p8))) * ((NI64) (w_p2))) * IL64(4)); { NIM_BOOL T17_; T17_ = (NIM_BOOL)0; T17_ = (needed <= IL64(0)); if (T17_) goto LA18_; T17_ = (((NI64) (bufLen_p1)) < needed); LA18_: ; if (!T17_) goto LA19_; goto BeforeRet_; } LA19_: ; aspect = ((NF)(((NF) (w_p2))) / (NF)(((NF) (h_p3)))); invW = ((NF)(1.0) / (NF)(((NF) (w_p2)))); invH = ((NF)(1.0) / (NF)(((NF) (h_p3)))); { NI32 y; NI32 res; y = (NI32)0; res = y0_p8; { while (1) { NF im; NI32 row; if (!(res < y1_p9)) goto LA23; y = res; im = ((NF)(cy_p5) + (NF)(((NF)(((NF)(((NF)(((NF) (y))) * (NF)(invH))) - (NF)(0.5))) * (NF)(scale_p6)))); row = (NI32)((NI32)((NI32)(y - y0_p8) * w_p2) * ((NI32)4)); { NI32 x; NI32 res_2; x = (NI32)0; res_2 = ((NI32)0); { while (1) { if (!(res_2 < w_p2)) goto LA26; x = res_2; { NF re; NF zr; NF zi; NF zr2; NF zi2; int i; NI32 idx; NF mag; NF nu; NF t; NF T46_; NF T47_; NF T48_; re = ((NF)(cx_p4) + (NF)(((NF)(((NF)(((NF)(((NF)(((NF) (x))) * (NF)(invW))) - (NF)(0.5))) * (NF)(scale_p6))) * (NF)(aspect)))); zr = 0.0; zi = 0.0; zr2 = 0.0; zi2 = 0.0; i = ((int)0); { while (1) { if (!(i < maxIter_p7)) goto LA29; zr2 = ((NF)(zr) * (NF)(zr)); zi2 = ((NF)(zi) * (NF)(zi)); { if (!(4.0 < ((NF)(zr2) + (NF)(zi2)))) goto LA32_; goto LA28; } LA32_: ; zi = ((NF)(((NF)(((NF)(2.0) * (NF)(zr))) * (NF)(zi))) + (NF)(im)); zr = ((NF)(((NF)(zr2) - (NF)(zi2))) + (NF)(re)); i += ((NI)1); } LA29: ; } LA28: ; idx = (NI32)(row + (NI32)(x * ((NI32)4))); { if (!(maxIter_p7 <= i)) goto LA36_; buf_p0[idx] = ((NU8)0); buf_p0[(NI32)(idx + ((NI32)1))] = ((NU8)0); buf_p0[(NI32)(idx + ((NI32)2))] = ((NU8)0); buf_p0[(NI32)(idx + ((NI32)3))] = ((NU8)255); goto LA27; } LA36_: ; mag = sqrt(((NF)(zr2) + (NF)(zi2))); nu = ((NF) (i)); { NF T42_; NF T43_; NF T44_; NF T45_; if (!(1.0 < mag)) goto LA40_; T42_ = (NF)0; T42_ = log(mag); T43_ = (NF)0; T43_ = log(2.0); T44_ = (NF)0; T44_ = log(((NF)(T42_) / (NF)(T43_))); T45_ = (NF)0; T45_ = log(2.0); nu = ((NF)(((NF)(((NF) (i))) + (NF)(1.0))) - (NF)(((NF)(T44_) / (NF)(T45_)))); } LA40_: ; t = ((NF)(nu) / (NF)(((NF) (maxIter_p7)))); T46_ = (NF)0; T46_ = sin(((NF)(3.0) + (NF)(((NF)(t) * (NF)(18.0))))); buf_p0[idx] = ((NU8) (((NF)(255.0) * (NF)(((NF)(0.5) + (NF)(((NF)(0.5) * (NF)(T46_)))))))); T47_ = (NF)0; T47_ = sin(((NF)(3.6) + (NF)(((NF)(t) * (NF)(18.0))))); buf_p0[(NI32)(idx + ((NI32)1))] = ((NU8) (((NF)(255.0) * (NF)(((NF)(0.5) + (NF)(((NF)(0.5) * (NF)(T47_)))))))); T48_ = (NF)0; T48_ = sin(((NF)(4.2) + (NF)(((NF)(t) * (NF)(18.0))))); buf_p0[(NI32)(idx + ((NI32)2))] = ((NU8) (((NF)(255.0) * (NF)(((NF)(0.5) + (NF)(((NF)(0.5) * (NF)(T48_)))))))); buf_p0[(NI32)(idx + ((NI32)3))] = ((NU8)255); } LA27: ; res_2 += ((NI)1); } LA26: ; } } res += ((NI)1); } LA23: ; } } }BeforeRet_: ; } N_LIB_PRIVATE N_CDECL(void, NimDestroyGlobals)(void) { } N_LIB_PRIVATE void PreMainInner(void) { } N_LIB_PRIVATE void PreMain(void) { #if 0 void (*volatile inner)(void); inner = PreMainInner; atmdotdotatsdotdotatsdotdotatsdotdotatsdotdotatsdotdotatsnimatslibatssystemdotnim_Init000(); (*inner)(); #else atmdotdotatsdotdotatsdotdotatsdotdotatsdotdotatsdotdotatsnimatslibatssystemdotnim_Init000(); PreMainInner(); #endif } N_LIB_PRIVATE N_CDECL(void, NimMainInner)(void) { NimMainModule(); } N_CDECL(void, NimMain)(void) { #if 0 void (*volatile inner)(void); PreMain(); inner = NimMainInner; (*inner)(); #else PreMain(); NimMainInner(); #endif } N_LIB_PRIVATE N_NIMCALL(void, NimMainModule)(void) { { } }