This generated C code:
#define NIM_INTBITS 64
/* GENERATED CODE. DO NOT EDIT. */
#ifdef __cplusplus
# if __cplusplus >= 201103L
# /* nullptr is more type safe (less implicit conversions than 0) */
# define NIM_NIL nullptr
# else
# // both `((void*)0)` and `NULL` would cause codegen to emit
# // error: assigning to 'Foo *' from incompatible type 'void *'
# // but codegen could be fixed if need. See also potential caveat regarding
# // NULL.
# // However, `0` causes other issues, see #13798
# define NIM_NIL 0
# endif
#else
# include <stdbool.h>
# define NIM_NIL NULL
#endif
#ifdef __cplusplus
#define NB8 bool
#elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901)
// see #13798: to avoid conflicts for code emitting `#include <stdbool.h>`
#define NB8 _Bool
#else
typedef unsigned char NB8; // best effort
#endif
typedef unsigned char NC8;
typedef float NF32;
typedef double NF64;
#if defined(__BORLANDC__) || defined(_MSC_VER)
typedef signed char NI8;
typedef signed short int NI16;
typedef signed int NI32;
typedef __int64 NI64;
/* XXX: Float128? */
typedef unsigned char NU8;
typedef unsigned short int NU16;
typedef unsigned int NU32;
typedef unsigned __int64 NU64;
#elif defined(HAVE_STDINT_H)
#ifndef USE_NIM_NAMESPACE
# include <stdint.h>
#endif
typedef int8_t NI8;
typedef int16_t NI16;
typedef int32_t NI32;
typedef int64_t NI64;
typedef uint8_t NU8;
typedef uint16_t NU16;
typedef uint32_t NU32;
typedef uint64_t NU64;
#elif defined(HAVE_CSTDINT)
#ifndef USE_NIM_NAMESPACE
# include <cstdint>
#endif
typedef std::int8_t NI8;
typedef std::int16_t NI16;
typedef std::int32_t NI32;
typedef std::int64_t NI64;
typedef std::uint8_t NU8;
typedef std::uint16_t NU16;
typedef std::uint32_t NU32;
typedef std::uint64_t NU64;
#else
/* Unknown compiler/version, do our best */
#ifdef __INT8_TYPE__
typedef __INT8_TYPE__ NI8;
#else
typedef signed char NI8;
#endif
#ifdef __INT16_TYPE__
typedef __INT16_TYPE__ NI16;
#else
typedef signed short int NI16;
#endif
#ifdef __INT32_TYPE__
typedef __INT32_TYPE__ NI32;
#else
typedef signed int NI32;
#endif
#ifdef __INT64_TYPE__
typedef __INT64_TYPE__ NI64;
#else
typedef long long int NI64;
#endif
/* XXX: Float128? */
#ifdef __UINT8_TYPE__
typedef __UINT8_TYPE__ NU8;
#else
typedef unsigned char NU8;
#endif
#ifdef __UINT16_TYPE__
typedef __UINT16_TYPE__ NU16;
#else
typedef unsigned short int NU16;
#endif
#ifdef __UINT32_TYPE__
typedef __UINT32_TYPE__ NU32;
#else
typedef unsigned int NU32;
#endif
#ifdef __UINT64_TYPE__
typedef __UINT64_TYPE__ NU64;
#else
typedef unsigned long long int NU64;
#endif
#endif
#ifdef NIM_INTBITS
# if NIM_INTBITS == 64
typedef NI64 NI;
typedef NU64 NU;
# elif NIM_INTBITS == 32
typedef NI32 NI;
typedef NU32 NU;
# elif NIM_INTBITS == 16
typedef NI16 NI;
typedef NU16 NU;
# elif NIM_INTBITS == 8
typedef NI8 NI;
typedef NU8 NU;
# else
# error "invalid bit width for int"
# endif
#endif
#define NIM_TRUE true
#define NIM_FALSE false
// Include math.h to use `NAN` that should be defined in C compilers supports C99.
#include <math.h>
// Define NAN in case math.h doesn't define it.
// NAN definition copied from math.h included in the Windows SDK version 10.0.14393.0
#ifndef NAN
# ifndef _HUGE_ENUF
# define _HUGE_ENUF 1e+300 // _HUGE_ENUF*_HUGE_ENUF must overflow
# endif
# define NAN_INFINITY ((float)(_HUGE_ENUF * _HUGE_ENUF))
# define NAN ((float)(NAN_INFINITY * 0.0F))
#endif
#ifndef INF
# ifdef INFINITY
# define INF INFINITY
# elif defined(HUGE_VAL)
# define INF HUGE_VAL
# elif defined(_MSC_VER)
# include <float.h>
# define INF (DBL_MAX+DBL_MAX)
# else
# define INF (1.0 / 0.0)
# endif
#endif
#if defined(__GNUC__) || defined(_MSC_VER)
# define IL64(x) x##LL
#else /* works only without LL */
# define IL64(x) ((NI64)x)
#endif
/* ------------ ignore typical warnings in Nim-generated files ------------- */
#if defined(__GNUC__) || defined(__clang__)
# pragma GCC diagnostic ignored "-Wswitch-bool"
# pragma GCC diagnostic ignored "-Wformat"
# pragma GCC diagnostic ignored "-Wpointer-sign"
#endif
/* ------------------------------------------------------------------- */
#ifdef __cplusplus
# define NIM_EXTERNC extern "C"
#else
# define NIM_EXTERNC
#endif
#if defined(WIN32) || defined(_WIN32) /* only Windows has this mess... */
# define N_LIB_PRIVATE
# define N_CDECL(rettype, name) rettype __cdecl name
# define N_STDCALL(rettype, name) rettype __stdcall name
# define N_SYSCALL(rettype, name) rettype __syscall name
# define N_FASTCALL(rettype, name) rettype __fastcall name
# define N_THISCALL(rettype, name) rettype __thiscall name
# define N_SAFECALL(rettype, name) rettype __stdcall name
/* function pointers with calling convention: */
# define N_CDECL_PTR(rettype, name) rettype (__cdecl *name)
# define N_STDCALL_PTR(rettype, name) rettype (__stdcall *name)
# define N_SYSCALL_PTR(rettype, name) rettype (__syscall *name)
# define N_FASTCALL_PTR(rettype, name) rettype (__fastcall *name)
# define N_THISCALL_PTR(rettype, name) rettype (__thiscall *name)
# define N_SAFECALL_PTR(rettype, name) rettype (__stdcall *name)
# ifdef __EMSCRIPTEN__
# define N_LIB_EXPORT NIM_EXTERNC __declspec(dllexport) __attribute__((used))
# define N_LIB_EXPORT_VAR __declspec(dllexport) __attribute__((used))
# else
# define N_LIB_EXPORT NIM_EXTERNC __declspec(dllexport)
# define N_LIB_EXPORT_VAR __declspec(dllexport)
# endif
# define N_LIB_IMPORT extern __declspec(dllimport)
#else
# define N_LIB_PRIVATE __attribute__((visibility("hidden")))
# if defined(__GNUC__)
# define N_CDECL(rettype, name) rettype name
# define N_STDCALL(rettype, name) rettype name
# define N_SYSCALL(rettype, name) rettype name
# define N_FASTCALL(rettype, name) __attribute__((fastcall)) rettype name
# define N_SAFECALL(rettype, name) rettype name
/* function pointers with calling convention: */
# define N_CDECL_PTR(rettype, name) rettype (*name)
# define N_STDCALL_PTR(rettype, name) rettype (*name)
# define N_SYSCALL_PTR(rettype, name) rettype (*name)
# define N_FASTCALL_PTR(rettype, name) __attribute__((fastcall)) rettype (*name)
# define N_SAFECALL_PTR(rettype, name) rettype (*name)
# else
# define N_CDECL(rettype, name) rettype name
# define N_STDCALL(rettype, name) rettype name
# define N_SYSCALL(rettype, name) rettype name
# define N_FASTCALL(rettype, name) rettype name
# define N_SAFECALL(rettype, name) rettype name
/* function pointers with calling convention: */
# define N_CDECL_PTR(rettype, name) rettype (*name)
# define N_STDCALL_PTR(rettype, name) rettype (*name)
# define N_SYSCALL_PTR(rettype, name) rettype (*name)
# define N_FASTCALL_PTR(rettype, name) rettype (*name)
# define N_SAFECALL_PTR(rettype, name) rettype (*name)
# endif
# ifdef __EMSCRIPTEN__
# define N_LIB_EXPORT NIM_EXTERNC __attribute__((visibility("default"), used))
# define N_LIB_EXPORT_VAR __attribute__((visibility("default"), used))
# else
# define N_LIB_EXPORT NIM_EXTERNC __attribute__((visibility("default")))
# define N_LIB_EXPORT_VAR __attribute__((visibility("default")))
# endif
# define N_LIB_IMPORT extern
#endif
#if defined(__BORLANDC__) || defined(_MSC_VER) || defined(WIN32) || defined(_WIN32)
/* these compilers have a fastcall so use it: */
# define N_NIMCALL(rettype, name) rettype __fastcall name
# define N_NIMCALL_PTR(rettype, name) rettype (__fastcall *name)
#else
# define N_NIMCALL(rettype, name) rettype name /* no modifier */
# define N_NIMCALL_PTR(rettype, name) rettype (*name)
#endif
#define N_NOCONV(rettype, name) rettype name
/* specify no calling convention */
#define N_NOCONV_PTR(rettype, name) rettype (*name)
/* calling convention mess ----------------------------------------------- */
#if defined(__GNUC__) || defined(__TINYC__)
/* these should support C99's inline */
# define N_INLINE(rettype, name) inline rettype name
#elif defined(__BORLANDC__) || defined(_MSC_VER)
/* Borland's compiler is really STRANGE here; note that the __fastcall
keyword cannot be before the return type, but __inline cannot be after
the return type, so we do not handle this mess in the code generator
but rather here. */
# define N_INLINE(rettype, name) __inline rettype name
#else /* others are less picky: */
# define N_INLINE(rettype, name) rettype __inline name
#endif
#define N_INLINE_PTR(rettype, name) rettype (*name)
#if defined(__GNUC__) || defined(__ICC__)
# define N_NOINLINE __attribute__((__noinline__))
#elif defined(_MSC_VER)
# define N_NOINLINE __declspec(noinline)
#else
# define N_NOINLINE
#endif
#define N_NOINLINE_PTR(rettype, name) rettype (*name)
#if defined(_MSC_VER)
# define NIM_ALIGN(x) __declspec(align(x))
# define NIM_ALIGNOF(x) __alignof(x)
#else
# define NIM_ALIGN(x) __attribute__((aligned(x)))
# define NIM_ALIGNOF(x) __alignof__(x)
#endif
#include <stddef.h>
/*
NIM_THREADVAR declaration based on
https://stackoverflow.com/questions/18298280/how-to-declare-a-variable-as-thread-local-portably
*/
#if defined _WIN32
# if defined _MSC_VER || defined __BORLANDC__
# define NIM_THREADVAR __declspec(thread)
# else
# define NIM_THREADVAR __thread
# endif
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112 && !defined __STDC_NO_THREADS__
# define NIM_THREADVAR _Thread_local
#elif defined _WIN32 && ( \
defined _MSC_VER || \
defined __ICL || \
defined __BORLANDC__ )
# define NIM_THREADVAR __declspec(thread)
#elif defined(__TINYC__) || defined(__GENODE__)
# define NIM_THREADVAR
/* note that ICC (linux) and Clang are covered by __GNUC__ */
#elif defined __GNUC__ || \
defined __SUNPRO_C || \
defined __xlC__
# define NIM_THREADVAR __thread
#else
# error "Cannot define NIM_THREADVAR"
#endif
N_INLINE(NB8, _Qnifc_div_sll_overflow)(long long int a, long long int b, long long int *res) {
if (b == 0) {
*res = 0;
return NIM_TRUE;
}
if (a == (long long int)(((unsigned long long int)1) << (sizeof(long long int) * 8 - 1)) && b == -1) {
*res = a;
return NIM_TRUE;
}
*res = a / b;
return NIM_FALSE;
}
N_INLINE(NB8, _Qnifc_div_sl_overflow)(long int a, long int b, long int *res) {
if (b == 0) {
*res = 0;
return NIM_TRUE;
}
if (a == (long int)(((unsigned long int)1) << (sizeof(long int) * 8 - 1)) && b == -1) {
*res = a;
return NIM_TRUE;
}
*res = a / b;
return NIM_FALSE;
}
N_INLINE(NB8, _Qnifc_div_ull_overflow)(unsigned long long int a, unsigned long long int b, unsigned long long int *res) {
if (b == 0) {
*res = 0;
return NIM_TRUE; /* Overflow: division by zero */
}
*res = a / b;
return NIM_FALSE;
}
N_INLINE(NB8, _Qnifc_div_ul_overflow)(unsigned long int a, unsigned long int b, unsigned long int *res) {
if (b == 0) {
*res = 0;
return NIM_TRUE;
}
*res = a / b;
return NIM_FALSE;
}
N_INLINE(NB8, _Qnifc_mod_sll_overflow)(long long int a, long long int b, long long int *res) {
if (b == 0) {
*res = 0;
return NIM_TRUE;
}
if (a == (long long int)(((unsigned long long int)1) << (sizeof(long long int) * 8 - 1)) && b == -1) {
*res = 0;
return NIM_TRUE;
}
*res = a % b;
return NIM_FALSE;
}
N_INLINE(NB8, _Qnifc_mod_sl_overflow)(long int a, long int b, long int *res) {
if (b == 0) {
*res = 0;
return NIM_TRUE;
}
if (a == (long int)(((unsigned long int)1) << (sizeof(long int) * 8 - 1)) && b == -1) {
*res = 0;
return NIM_TRUE;
}
*res = a % b;
return NIM_FALSE;
}
N_INLINE(NB8, _Qnifc_mod_ull_overflow)(unsigned long long int a, unsigned long long int b, unsigned long long int *res) {
if (b == 0) {
*res = 0;
return NIM_TRUE;
}
*res = a % b;
return NIM_FALSE;
}
N_INLINE(NB8, _Qnifc_mod_ul_overflow)(unsigned long int a, unsigned long int b, unsigned long int *res) {
if (b == 0) {
*res = 0;
return NIM_TRUE;
}
*res = a % b;
return NIM_FALSE;
}
NIM_THREADVAR NB8 NIFC_ERR_;
#include <string.h>
#include <stdio.h>
typedef struct Rtti_0_sysvq0asl Rtti_0_sysvq0asl;
typedef struct CoroutineBase_0_sysvq0asl CoroutineBase_0_sysvq0asl;
typedef struct Continuation_0_sysvq0asl Continuation_0_sysvq0asl;
typedef struct myecho_0_coro_tepou9hkv1 myecho_0_coro_tepou9hkv1;
typedef struct passiveProc_0_coro_tepou9hkv1 passiveProc_0_coro_tepou9hkv1;
typedef struct RootObj_0_sysvq0asl{
Rtti_0_sysvq0asl* vt_0;}
RootObj_0_sysvq0asl;
typedef N_NIMCALL_PTR(Continuation_0_sysvq0asl, AptrSX43oroutineX42ase0sysvq0aslZSX43ontinuation0R22AnimcallZAfalseZAR61_0_t)(CoroutineBase_0_sysvq0asl*);
typedef struct Continuation_0_sysvq0asl{
AptrSX43oroutineX42ase0sysvq0aslZSX43ontinuation0R22AnimcallZAfalseZAR61_0_t fn_0_sysvq0asl;
CoroutineBase_0_sysvq0asl* env_0_sysvq0asl;}
Continuation_0_sysvq0asl;
typedef struct CoroutineBase_0_sysvq0asl{
RootObj_0_sysvq0asl Q;
Continuation_0_sysvq0asl caller_0_sysvq0asl;}
CoroutineBase_0_sysvq0asl;
typedef struct string_0_sysvq0asl{
NC8* a_0_sysvq0asl;
NI i_0_sysvq0asl;}
string_0_sysvq0asl;
typedef struct myecho_0_coro_tepou9hkv1{
CoroutineBase_0_sysvq0asl Q;
string_0_sysvq0asl xX60Qf_0_tepou9hkv1;}
myecho_0_coro_tepou9hkv1;
typedef struct passiveProc_0_coro_tepou9hkv1{
CoroutineBase_0_sysvq0asl Q;
myecho_0_coro_tepou9hkv1 X60QcoroVarX60Qf_6_tepou9hkv1;
NI i_1_lfX60Qf_4_tepou9hkv1;
NI b_1_lfX60Qf_3_tepou9hkv1;
string_0_sysvq0asl xX60Qf_1_tepou9hkv1;}
passiveProc_0_coro_tepou9hkv1;
typedef struct main_0_coro_tepou9hkv1{
CoroutineBase_0_sysvq0asl Q;
passiveProc_0_coro_tepou9hkv1 X60QcoroVarX60Qf_7_tepou9hkv1;}
main_0_coro_tepou9hkv1;
typedef struct Rtti_0_sysvq0asl{
NI dl_0_sysvq0asl;
NU32* dy_0_sysvq0asl;
void* mt_0_sysvq0asl[];}
Rtti_0_sysvq0asl;
typedef N_NIMCALL_PTR(void, Smyecho0corotepou9hkv1SEAnimcallZAfalseZAR33_0_t)(myecho_0_coro_tepou9hkv1*);
typedef N_NIMCALL_PTR(void, SpassiveX50roc0corotepou9hkv1SEAnimcallZAfalseZAR40_0_t)(passiveProc_0_coro_tepou9hkv1*);
typedef N_NIMCALL_PTR(void, AiSminusQ1ZSEAnimcallZAfalseZAR17_0_t)(NI);
Continuation_0_sysvq0asl passiveProc_0_s3_tepou9hkv1(passiveProc_0_coro_tepou9hkv1* X60Qthis_0);
Continuation_0_sysvq0asl passiveProc_0_s0_tepou9hkv1(passiveProc_0_coro_tepou9hkv1* X60Qthis_0);
Continuation_0_sysvq0asl passiveProc_0_s2_tepou9hkv1(passiveProc_0_coro_tepou9hkv1* X60Qthis_0);
Continuation_0_sysvq0asl passiveProc_0_s1_tepou9hkv1(passiveProc_0_coro_tepou9hkv1* X60Qthis_0);
Continuation_0_sysvq0asl main_0_s0_tepou9hkv1(main_0_coro_tepou9hkv1* X60Qthis_0);
static inline void inc_0_tepou9hkv1(NI* x_3);
void eQdestroyQ_Smyecho0corotepou9hkv1_0_tepou9hkv1(myecho_0_coro_tepou9hkv1* dest_0);
void eQdestroyQ_SpassiveX50roc0corotepou9hkv1_0_tepou9hkv1(passiveProc_0_coro_tepou9hkv1* dest_0);
void eQdestroyQ_Smain0corotepou9hkv1_0_tepou9hkv1(main_0_coro_tepou9hkv1* dest_0);
void eQwasmovedQ_Smain0corotepou9hkv1_0_tepou9hkv1(main_0_coro_tepou9hkv1* dest_0);
void eQwasmovedQ_SpassiveX50roc0corotepou9hkv1_0_tepou9hkv1(passiveProc_0_coro_tepou9hkv1* dest_0);
void eQwasmovedQ_Smyecho0corotepou9hkv1_0_tepou9hkv1(myecho_0_coro_tepou9hkv1* dest_0);
extern void cancel_0_sysvq0asl(CoroutineBase_0_sysvq0asl* coro_1);
static inline /* nimStrDup.c */string_0_sysvq0asl nimStrDup/* nimStrDup.c */(string_0_sysvq0asl s_30);
extern void write_0_syn1lfpjv(FILE* f_4, string_0_sysvq0asl s_0);
extern void write_5_syn1lfpjv(FILE* f_9, NC8 c_1);
extern string_0_sysvq0asl ampQ_0_sysvq0asl(string_0_sysvq0asl a_16, string_0_sysvq0asl b_12);
static inline /* nimStrDestroy.c */void nimStrDestroy/* nimStrDestroy.c */(string_0_sysvq0asl s_29);
extern void complete_0_sysvq0asl(Continuation_0_sysvq0asl c_5);
static inline /* nimStrWasMoved.c */void nimStrWasMoved/* nimStrWasMoved.c */(string_0_sysvq0asl* s_28);
static inline NI len_5_sysvq0asl(string_0_sysvq0asl s_21);
extern void* alloc_0_sysvq0asl(NI size_3);
static inline void copyMem_0_sysvq0asl(void* dest_4, void* src_3, NI size_9);
extern void dealloc_0_sysvq0asl(void* p_3);
extern N_NIMCALL(void, continueAfterOutOfMem_0_sysvq0asl)(NI size_12);
NU32 const passiveProc_0_coro_dy_tepou9hkv1[] = {
1294232418ull, 3326777900ull, 2746927424ull}
;
Rtti_0_sysvq0asl const passiveProc_0_coro_vt_tepou9hkv1 = {
.dl_0_sysvq0asl = IL64(3), .dy_0_sysvq0asl = ((NU32*)passiveProc_0_coro_dy_tepou9hkv1), .mt_0_sysvq0asl = {
((void*)cancel_0_sysvq0asl), ((void*)eQdestroyQ_SpassiveX50roc0corotepou9hkv1_0_tepou9hkv1)}}
;
NU32 const myecho_0_coro_dy_tepou9hkv1[] = {
1294232418ull, 3326777900ull, 4164815769ull}
;
Rtti_0_sysvq0asl const myecho_0_coro_vt_tepou9hkv1 = {
.dl_0_sysvq0asl = IL64(3), .dy_0_sysvq0asl = ((NU32*)myecho_0_coro_dy_tepou9hkv1), .mt_0_sysvq0asl = {
((void*)cancel_0_sysvq0asl), ((void*)eQdestroyQ_Smyecho0corotepou9hkv1_0_tepou9hkv1)}}
;
NU32 const main_0_coro_dy_tepou9hkv1[] = {
1294232418ull, 3326777900ull, 1910435132ull}
;
Rtti_0_sysvq0asl const main_0_coro_vt_tepou9hkv1 = {
.dl_0_sysvq0asl = IL64(3), .dy_0_sysvq0asl = ((NU32*)main_0_coro_dy_tepou9hkv1), .mt_0_sysvq0asl = {
((void*)cancel_0_sysvq0asl), ((void*)eQdestroyQ_Smain0corotepou9hkv1_0_tepou9hkv1)}}
;
extern AiSminusQ1ZSEAnimcallZAfalseZAR17_0_t oomHandler_0_sysvq0asl;
Continuation_0_sysvq0asl myecho_0_tepou9hkv1(myecho_0_coro_tepou9hkv1* X60Qthis_0, string_0_sysvq0asl x_0, Continuation_0_sysvq0asl X60Qcaller_0){
myecho_0_coro_tepou9hkv1 X60Qlhs_0 = (myecho_0_coro_tepou9hkv1){
(&myecho_0_coro_vt_tepou9hkv1), .xX60Qf_0_tepou9hkv1 = nimStrDup(x_0), .Q.caller_0_sysvq0asl = X60Qcaller_0}
;
eQdestroyQ_Smyecho0corotepou9hkv1_0_tepou9hkv1((&(*X60Qthis_0)));
(*X60Qthis_0) = X60Qlhs_0;
Continuation_0_sysvq0asl result_0;
write_0_syn1lfpjv(stdout, (*X60Qthis_0).xX60Qf_0_tepou9hkv1);
write_5_syn1lfpjv(stdout, (NC8)'\012');
result_0 = (*X60Qthis_0).Q.caller_0_sysvq0asl;
return result_0;}
Continuation_0_sysvq0asl passiveProc_0_tepou9hkv1(passiveProc_0_coro_tepou9hkv1* X60Qthis_0, string_0_sysvq0asl x_1, Continuation_0_sysvq0asl X60Qcaller_0){
passiveProc_0_coro_tepou9hkv1 X60Qlhs_1 = (passiveProc_0_coro_tepou9hkv1){
(&passiveProc_0_coro_vt_tepou9hkv1), .xX60Qf_1_tepou9hkv1 = nimStrDup(x_1), .Q.caller_0_sysvq0asl = X60Qcaller_0}
;
eQdestroyQ_SpassiveX50roc0corotepou9hkv1_0_tepou9hkv1((&(*X60Qthis_0)));
(*X60Qthis_0) = X60Qlhs_1;
Continuation_0_sysvq0asl result_0;
NI a_1_lf_1 = IL64(0);
(*X60Qthis_0).b_1_lfX60Qf_3_tepou9hkv1 = IL64(10);
(*X60Qthis_0).i_1_lfX60Qf_4_tepou9hkv1 = a_1_lf_1;
result_0 = passiveProc_0_s3_tepou9hkv1(X60Qthis_0);
return result_0;}
Continuation_0_sysvq0asl passiveProc_0_s3_tepou9hkv1(passiveProc_0_coro_tepou9hkv1* X60Qthis_0){
Continuation_0_sysvq0asl result_0;
if ((*X60Qthis_0).i_1_lfX60Qf_4_tepou9hkv1 < (*X60Qthis_0).b_1_lfX60Qf_3_tepou9hkv1){
result_0 = passiveProc_0_s0_tepou9hkv1(X60Qthis_0);
}
else {
result_0 = passiveProc_0_s1_tepou9hkv1(X60Qthis_0);
}
return result_0;}
Continuation_0_sysvq0asl passiveProc_0_s0_tepou9hkv1(passiveProc_0_coro_tepou9hkv1* X60Qthis_0){
Continuation_0_sysvq0asl result_0;
string_0_sysvq0asl X60Qcf_0 = ampQ_0_sysvq0asl((*X60Qthis_0).xX60Qf_1_tepou9hkv1, (string_0_sysvq0asl){
.a_0_sysvq0asl = (NC8*)"xyz", .i_0_sysvq0asl = IL64(6)}
);
Continuation_0_sysvq0asl X60QcontVar_1 = myecho_0_tepou9hkv1((&(*X60Qthis_0).X60QcoroVarX60Qf_6_tepou9hkv1), X60Qcf_0, (Continuation_0_sysvq0asl){
.fn_0_sysvq0asl = ((AptrSX43oroutineX42ase0sysvq0aslZSX43ontinuation0R22AnimcallZAfalseZAR61_0_t)passiveProc_0_s2_tepou9hkv1), .env_0_sysvq0asl = X60Qthis_0}
);
nimStrDestroy(X60Qcf_0);
return X60QcontVar_1;
}
Continuation_0_sysvq0asl passiveProc_0_s2_tepou9hkv1(passiveProc_0_coro_tepou9hkv1* X60Qthis_0){
Continuation_0_sysvq0asl result_0;
inc_0_tepou9hkv1((&(*X60Qthis_0).i_1_lfX60Qf_4_tepou9hkv1));
result_0 = passiveProc_0_s3_tepou9hkv1(X60Qthis_0);
return result_0;}
Continuation_0_sysvq0asl passiveProc_0_s1_tepou9hkv1(passiveProc_0_coro_tepou9hkv1* X60Qthis_0){
Continuation_0_sysvq0asl result_0;
result_0 = (*X60Qthis_0).Q.caller_0_sysvq0asl;
return result_0;}
Continuation_0_sysvq0asl main_0_tepou9hkv1(main_0_coro_tepou9hkv1* X60Qthis_0, Continuation_0_sysvq0asl X60Qcaller_0){
main_0_coro_tepou9hkv1 X60Qlhs_2 = (main_0_coro_tepou9hkv1){
(&main_0_coro_vt_tepou9hkv1), .Q.caller_0_sysvq0asl = X60Qcaller_0}
;
eQdestroyQ_Smain0corotepou9hkv1_0_tepou9hkv1((&(*X60Qthis_0)));
(*X60Qthis_0) = X60Qlhs_2;
Continuation_0_sysvq0asl result_0;
Continuation_0_sysvq0asl X60QcontVar_1 = passiveProc_0_tepou9hkv1((&(*X60Qthis_0).X60QcoroVarX60Qf_7_tepou9hkv1), (string_0_sysvq0asl){
.a_0_sysvq0asl = (NC8*)"abc", .i_0_sysvq0asl = IL64(6)}
, (Continuation_0_sysvq0asl){
.fn_0_sysvq0asl = ((AptrSX43oroutineX42ase0sysvq0aslZSX43ontinuation0R22AnimcallZAfalseZAR61_0_t)main_0_s0_tepou9hkv1), .env_0_sysvq0asl = X60Qthis_0}
);
return X60QcontVar_1;}
Continuation_0_sysvq0asl main_0_s0_tepou9hkv1(main_0_coro_tepou9hkv1* X60Qthis_0){
Continuation_0_sysvq0asl result_0;
result_0 = (*X60Qthis_0).Q.caller_0_sysvq0asl;
return result_0;}
;
static inline void inc_0_tepou9hkv1(NI* x_3){
(*x_3) = ((NI)((*x_3) + ((NI)IL64(1))));}
void eQdestroyQ_Smyecho0corotepou9hkv1_0_tepou9hkv1(myecho_0_coro_tepou9hkv1* dest_0){
nimStrDestroy((*dest_0).xX60Qf_0_tepou9hkv1);}
void eQdestroyQ_SpassiveX50roc0corotepou9hkv1_0_tepou9hkv1(passiveProc_0_coro_tepou9hkv1* dest_0){
myecho_0_coro_tepou9hkv1* X60QvtableTemp_0 = (&(*dest_0).X60QcoroVarX60Qf_6_tepou9hkv1);
((Smyecho0corotepou9hkv1SEAnimcallZAfalseZAR33_0_t)(*(*X60QvtableTemp_0).Q.Q.vt_0).mt_0_sysvq0asl[IL64(1)])((&(*X60QvtableTemp_0)));
nimStrDestroy((*dest_0).xX60Qf_1_tepou9hkv1);}
void eQdestroyQ_Smain0corotepou9hkv1_0_tepou9hkv1(main_0_coro_tepou9hkv1* dest_0){
passiveProc_0_coro_tepou9hkv1* X60QvtableTemp_1 = (&(*dest_0).X60QcoroVarX60Qf_7_tepou9hkv1);
((SpassiveX50roc0corotepou9hkv1SEAnimcallZAfalseZAR40_0_t)(*(*X60QvtableTemp_1).Q.Q.vt_0).mt_0_sysvq0asl[IL64(1)])((&(*X60QvtableTemp_1)));}
void eQwasmovedQ_Smain0corotepou9hkv1_0_tepou9hkv1(main_0_coro_tepou9hkv1* dest_0){
(*dest_0).Q.Q.vt_0 = (&main_0_coro_vt_tepou9hkv1);
eQwasmovedQ_SpassiveX50roc0corotepou9hkv1_0_tepou9hkv1((&(*dest_0).X60QcoroVarX60Qf_7_tepou9hkv1));}
void eQwasmovedQ_SpassiveX50roc0corotepou9hkv1_0_tepou9hkv1(passiveProc_0_coro_tepou9hkv1* dest_0){
(*dest_0).Q.Q.vt_0 = (&passiveProc_0_coro_vt_tepou9hkv1);
eQwasmovedQ_Smyecho0corotepou9hkv1_0_tepou9hkv1((&(*dest_0).X60QcoroVarX60Qf_6_tepou9hkv1));
nimStrWasMoved((&(*dest_0).xX60Qf_1_tepou9hkv1));}
void eQwasmovedQ_Smyecho0corotepou9hkv1_0_tepou9hkv1(myecho_0_coro_tepou9hkv1* dest_0){
(*dest_0).Q.Q.vt_0 = (&myecho_0_coro_vt_tepou9hkv1);
nimStrWasMoved((&(*dest_0).xX60Qf_0_tepou9hkv1));}
static inline /* nimStrDup.c */string_0_sysvq0asl nimStrDup/* nimStrDup.c */(string_0_sysvq0asl s_30){
string_0_sysvq0asl result_54;
if ((!(((NI64)(s_30.i_0_sysvq0asl & IL64(1))) == IL64(0)))){
NI len_7 = len_5_sysvq0asl(s_30);
result_54 = (string_0_sysvq0asl){
.a_0_sysvq0asl = ((NC8*)alloc_0_sysvq0asl(len_7)), .i_0_sysvq0asl = s_30.i_0_sysvq0asl}
;
if ((!(result_54.a_0_sysvq0asl == NIM_NIL))){
copyMem_0_sysvq0asl(((void*)result_54.a_0_sysvq0asl), ((void*)s_30.a_0_sysvq0asl), len_7);}
else {
oomHandler_0_sysvq0asl(len_7);
result_54.i_0_sysvq0asl = IL64(0);}}
else {
result_54 = s_30;}
return result_54;}
static inline /* nimStrDestroy.c */void nimStrDestroy/* nimStrDestroy.c */(string_0_sysvq0asl s_29){
if ((!(((NI64)(s_29.i_0_sysvq0asl & IL64(1))) == IL64(0)))){
dealloc_0_sysvq0asl(((void*)s_29.a_0_sysvq0asl));}}
static inline /* nimStrWasMoved.c */void nimStrWasMoved/* nimStrWasMoved.c */(string_0_sysvq0asl* s_28){
(*s_28).i_0_sysvq0asl = IL64(0);}
static inline NI len_5_sysvq0asl(string_0_sysvq0asl s_21){
NI result_48;
result_48 = ((NI64)(((NI64)s_21.i_0_sysvq0asl) >> ((NU64)IL64(1))));
return result_48;}
static inline void copyMem_0_sysvq0asl(void* dest_4, void* src_3, NI size_9){
memcpy(dest_4, src_3, ((size_t)size_9));}
int cmdCount;
NC8 **cmdLine;
int main(int argc, char **argv) {
cmdCount = argc;
cmdLine = (NC8**)argv;
main_0_coro_tepou9hkv1 X60QcoroVar_0;
eQwasmovedQ_Smain0corotepou9hkv1_0_tepou9hkv1((&X60QcoroVar_0));
complete_0_sysvq0asl(main_0_tepou9hkv1((&X60QcoroVar_0), (Continuation_0_sysvq0asl){
.fn_0_sysvq0asl = NIM_NIL, .env_0_sysvq0asl = NIM_NIL}
));
eQdestroyQ_Smain0corotepou9hkv1_0_tepou9hkv1((&X60QcoroVar_0));
}
Does not work. Who can spot the problem?
Google Gemini is more than happy to take a stab at it {grin}
The author of Nim ... posted the following challenge:
...
Who can spot the bug?
Response:
https://g.co/gemini/share/41743ad086e3
Above my pay grade to know if this make sense :-(
I don't think that's the issue, provided that we are looking for a C codegen bug and not a bug in the implementation. For some reason Qwen3 Coder also gets stuck with this exact piece of code whenever I try it. Try this prompt instead:
This generated C code @bug.c does not work. There's an issue with the way the coroutines are being managed or used. It is not an issue with string literal handling or with the C define macros! Can you spot the problem? Do NOT edit the generated file!
Maybe string memory management issue?
string_0_sysvq0asl X60Qcf_0 = ampQ_0_sysvq0asl((*X60Qthis_0).xX60Qf_1_tepou9hkv1, (string_0_sysvq0asl){
.a_0_sysvq0asl = (NC8*)"xyz", .i_0_sysvq0asl = IL64(6)}
// string literal "xyz" rodata (also is 6 correct?)
);
Continuation_0_sysvq0asl X60QcontVar_1 = myecho_0_tepou9hkv1((&(*X60Qthis_0).X60QcoroVarX60Qf_6_tepou9hkv1), X60Qcf_0, (Continuation_0_sysvq0asl){
.fn_0_sysvq0asl = ((AptrSX43oroutineX42ase0sysvq0aslZSX43ontinuation0R22AnimcallZAfalseZAR61_0_t)passiveProc_0_s2_tepou9hkv1), .env_0_sysvq0asl = X60Qthis_0}
);
nimStrDestroy(X60Qcf_0); // trying to dealloc rodata "xyz"?
string in Nimony is implemented in: https://github.com/nim-lang/nimony/blob/master/lib/std/system/stringimpl.nim
It has following field:
type
string = object
a: ptr UncheckedArray[char]
i: int
LSB of i indicates if the memory a points to is heap allocated or string literal (data segment). Other bits are string length.
proc len*(s: string): int {.inline, semantics: "string.len", ensures: (0 <= result).} =
result = s.i shr LenShift
template isAllocated(s: string): bool = (s.i and IsAllocatedBit) != 0
The Nimony code is:
import std / [syncio]
proc myecho(x: string) {.passive.} =
echo x
proc passiveProc(x: string) {.passive.} =
for i in 0..<10:
myecho x & "xyz"
proc main {.passive.} =
passiveProc("abc")
main()
void eQdestroyQ_SpassiveX50roc0corotepou9hkv1_0_tepou9hkv1(passiveProc_0_coro_tepou9hkv1 *dest_0) {
// All fields of dest_0 has a garbage value???
myecho_0_coro_tepou9hkv1 *X60QvtableTemp_0 = (&(*dest_0).X60QcoroVarX60Qf_6_tepou9hkv1);
((Smyecho0corotepou9hkv1SEAnimcallZAfalseZAR33_0_t)(*(*X60QvtableTemp_0).Q.Q.vt_0).mt_0_sysvq0asl[IL64(1)])(
(&(*X60QvtableTemp_0)));
nimStrDestroy((*dest_0).xX60Qf_1_tepou9hkv1);
}
For me, fails to build:
nimcache/bugzxrbre.c: In function ‘myecho_0_bugzxrbre’:
nimcache/bugzxrbre.c:505:5: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
505 | (&myecho_0_coro_vt_bugzxrbre), .xX60Qf_0_bugzxrbre = nimStrDup(x_0), .Q.caller_0_sysvq0asl = X60Qcaller_0}
| ^
nimcache/bugzxrbre.c: In function ‘passiveProc_0_bugzxrbre’:
nimcache/bugzxrbre.c:517:5: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
517 | (&passiveProc_0_coro_vt_bugzxrbre), .xX60Qf_1_bugzxrbre = nimStrDup(x_1), .Q.caller_0_sysvq0asl = X60Qcaller_0}
| ^
nimcache/bugzxrbre.c: In function ‘passiveProc_0_s0_bugzxrbre’:
nimcache/bugzxrbre.c:543:150: error: initialization of ‘CoroutineBase_0_sysvq0asl *’ from incompatible pointer type ‘passiveProc_0_coro_bugzxrbre *’ [-Wincompatible-pointer-types]
543 | .fn_0_sysvq0asl = ((AptrSX43oroutineX42ase0sysvq0aslZSX43ontinuation0R22AnimcallZAfalseZAR61_0_t)passiveProc_0_s2_bugzxrbre), .env_0_sysvq0asl = X60Qthis_0}
| ^~~~~~~~~~
nimcache/bugzxrbre.c:543:150: info: (near initialization for ‘(anonymous).env_0_sysvq0asl’)
nimcache/bugzxrbre.c: In function ‘main_0_bugzxrbre’:
nimcache/bugzxrbre.c:562:5: warning: initialization discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
562 | (&main_0_coro_vt_bugzxrbre), .Q.caller_0_sysvq0asl = X60Qcaller_0}
| ^
nimcache/bugzxrbre.c:570:143: error: initialization of ‘CoroutineBase_0_sysvq0asl *’ from incompatible pointer type ‘main_0_coro_bugzxrbre *’ [-Wincompatible-pointer-types]
570 | .fn_0_sysvq0asl = ((AptrSX43oroutineX42ase0sysvq0aslZSX43ontinuation0R22AnimcallZAfalseZAR61_0_t)main_0_s0_bugzxrbre), .env_0_sysvq0asl = X60Qthis_0}
| ^~~~~~~~~~
nimcache/bugzxrbre.c:570:143: info: (near initialization for ‘(anonymous).env_0_sysvq0asl’)
nimcache/bugzxrbre.c: In function ‘eQwasmovedQ_Smain0corobugzxrbre_0_bugzxrbre’:
nimcache/bugzxrbre.c:594:22: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
594 | (*dest_0).Q.Q.vt_0 = (&main_0_coro_vt_bugzxrbre);
| ^
nimcache/bugzxrbre.c: In function ‘eQwasmovedQ_SpassiveX50roc0corobugzxrbre_0_bugzxrbre’:
nimcache/bugzxrbre.c:597:22: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
597 | (*dest_0).Q.Q.vt_0 = (&passiveProc_0_coro_vt_bugzxrbre);
| ^
nimcache/bugzxrbre.c: In function ‘eQwasmovedQ_Smyecho0corobugzxrbre_0_bugzxrbre’:
nimcache/bugzxrbre.c:601:22: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
601 | (*dest_0).Q.Q.vt_0 = (&myecho_0_coro_vt_bugzxrbre);
| ^
FAILURE: ~/Projects/nimony/bin/nifmake -j run nimcache/bugzxrbre.final.build.nif
I just formatted the code and implement/ignore extern call and compiled with clang+ASAN+UBSAN. (I didn't use nimony)
/..../main.c:630:54: runtime error: member access within null pointer of type 'Rtti_0_sysvq0asl' (aka 'struct
Rtti_0_sysvq0asl')
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /..../main.c:630:54
#define NIM_INTBITS 64
/* GENERATED CODE. DO NOT EDIT. */
#ifdef __cplusplus
#if __cplusplus >= 201103L
#/* nullptr is more type safe (less implicit conversions than 0) */
#define NIM_NIL nullptr
#else
#// both `((void*)0)` and `NULL` would cause codegen to emit
#// error: assigning to 'Foo *' from incompatible type 'void *'
#// but codegen could be fixed if need. See also potential caveat regarding
#// NULL.
#// However, `0` causes other issues, see #13798
#define NIM_NIL 0
#endif
#else
#include <stdbool.h>
#define NIM_NIL NULL
#endif
#ifdef __cplusplus
#define NB8 bool
#elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901)
// see #13798: to avoid conflicts for code emitting `#include <stdbool.h>`
#define NB8 _Bool
#else
typedef unsigned char NB8; // best effort
#endif
typedef unsigned char NC8;
typedef float NF32;
typedef double NF64;
#if defined(__BORLANDC__) || defined(_MSC_VER)
typedef signed char NI8;
typedef signed short int NI16;
typedef signed int NI32;
typedef __int64 NI64;
/* XXX: Float128? */
typedef unsigned char NU8;
typedef unsigned short int NU16;
typedef unsigned int NU32;
typedef unsigned __int64 NU64;
#elif defined(HAVE_STDINT_H)
#ifndef USE_NIM_NAMESPACE
#include <stdint.h>
#endif
typedef int8_t NI8;
typedef int16_t NI16;
typedef int32_t NI32;
typedef int64_t NI64;
typedef uint8_t NU8;
typedef uint16_t NU16;
typedef uint32_t NU32;
typedef uint64_t NU64;
#elif defined(HAVE_CSTDINT)
#ifndef USE_NIM_NAMESPACE
#include <cstdint>
#endif
typedef std::int8_t NI8;
typedef std::int16_t NI16;
typedef std::int32_t NI32;
typedef std::int64_t NI64;
typedef std::uint8_t NU8;
typedef std::uint16_t NU16;
typedef std::uint32_t NU32;
typedef std::uint64_t NU64;
#else
/* Unknown compiler/version, do our best */
#ifdef __INT8_TYPE__
typedef __INT8_TYPE__ NI8;
#else
typedef signed char NI8;
#endif
#ifdef __INT16_TYPE__
typedef __INT16_TYPE__ NI16;
#else
typedef signed short int NI16;
#endif
#ifdef __INT32_TYPE__
typedef __INT32_TYPE__ NI32;
#else
typedef signed int NI32;
#endif
#ifdef __INT64_TYPE__
typedef __INT64_TYPE__ NI64;
#else
typedef long long int NI64;
#endif
/* XXX: Float128? */
#ifdef __UINT8_TYPE__
typedef __UINT8_TYPE__ NU8;
#else
typedef unsigned char NU8;
#endif
#ifdef __UINT16_TYPE__
typedef __UINT16_TYPE__ NU16;
#else
typedef unsigned short int NU16;
#endif
#ifdef __UINT32_TYPE__
typedef __UINT32_TYPE__ NU32;
#else
typedef unsigned int NU32;
#endif
#ifdef __UINT64_TYPE__
typedef __UINT64_TYPE__ NU64;
#else
typedef unsigned long long int NU64;
#endif
#endif
#ifdef NIM_INTBITS
#if NIM_INTBITS == 64
typedef NI64 NI;
typedef NU64 NU;
#elif NIM_INTBITS == 32
typedef NI32 NI;
typedef NU32 NU;
#elif NIM_INTBITS == 16
typedef NI16 NI;
typedef NU16 NU;
#elif NIM_INTBITS == 8
typedef NI8 NI;
typedef NU8 NU;
#else
#error "invalid bit width for int"
#endif
#endif
#define NIM_TRUE true
#define NIM_FALSE false
// Include math.h to use `NAN` that should be defined in C compilers supports C99.
#include <math.h>
// Define NAN in case math.h doesn't define it.
// NAN definition copied from math.h included in the Windows SDK version 10.0.14393.0
#ifndef NAN
#ifndef _HUGE_ENUF
#define _HUGE_ENUF 1e+300 // _HUGE_ENUF*_HUGE_ENUF must overflow
#endif
#define NAN_INFINITY ((float)(_HUGE_ENUF * _HUGE_ENUF))
#define NAN ((float)(NAN_INFINITY * 0.0F))
#endif
#ifndef INF
#ifdef INFINITY
#define INF INFINITY
#elif defined(HUGE_VAL)
#define INF HUGE_VAL
#elif defined(_MSC_VER)
#include <float.h>
#define INF (DBL_MAX + DBL_MAX)
#else
#define INF (1.0 / 0.0)
#endif
#endif
#if defined(__GNUC__) || defined(_MSC_VER)
#define IL64(x) x##LL
#else /* works only without LL */
#define IL64(x) ((NI64)x)
#endif
/* ------------ ignore typical warnings in Nim-generated files ------------- */
#if defined(__GNUC__) || defined(__clang__)
#pragma GCC diagnostic ignored "-Wswitch-bool"
#pragma GCC diagnostic ignored "-Wformat"
#pragma GCC diagnostic ignored "-Wpointer-sign"
#endif
/* ------------------------------------------------------------------- */
#ifdef __cplusplus
#define NIM_EXTERNC extern "C"
#else
#define NIM_EXTERNC
#endif
#if defined(WIN32) || defined(_WIN32) /* only Windows has this mess... */
#define N_LIB_PRIVATE
#define N_CDECL(rettype, name) rettype __cdecl name
#define N_STDCALL(rettype, name) rettype __stdcall name
#define N_SYSCALL(rettype, name) rettype __syscall name
#define N_FASTCALL(rettype, name) rettype __fastcall name
#define N_THISCALL(rettype, name) rettype __thiscall name
#define N_SAFECALL(rettype, name) rettype __stdcall name
/* function pointers with calling convention: */
#define N_CDECL_PTR(rettype, name) rettype(__cdecl *name)
#define N_STDCALL_PTR(rettype, name) rettype(__stdcall *name)
#define N_SYSCALL_PTR(rettype, name) rettype(__syscall *name)
#define N_FASTCALL_PTR(rettype, name) rettype(__fastcall *name)
#define N_THISCALL_PTR(rettype, name) rettype(__thiscall *name)
#define N_SAFECALL_PTR(rettype, name) rettype(__stdcall *name)
#ifdef __EMSCRIPTEN__
#define N_LIB_EXPORT NIM_EXTERNC __declspec(dllexport) __attribute__((used))
#define N_LIB_EXPORT_VAR __declspec(dllexport) __attribute__((used))
#else
#define N_LIB_EXPORT NIM_EXTERNC __declspec(dllexport)
#define N_LIB_EXPORT_VAR __declspec(dllexport)
#endif
#define N_LIB_IMPORT extern __declspec(dllimport)
#else
#define N_LIB_PRIVATE __attribute__((visibility("hidden")))
#if defined(__GNUC__)
#define N_CDECL(rettype, name) rettype name
#define N_STDCALL(rettype, name) rettype name
#define N_SYSCALL(rettype, name) rettype name
#define N_FASTCALL(rettype, name) __attribute__((fastcall)) rettype name
#define N_SAFECALL(rettype, name) rettype name
/* function pointers with calling convention: */
#define N_CDECL_PTR(rettype, name) rettype(*name)
#define N_STDCALL_PTR(rettype, name) rettype(*name)
#define N_SYSCALL_PTR(rettype, name) rettype(*name)
#define N_FASTCALL_PTR(rettype, name) __attribute__((fastcall)) rettype(*name)
#define N_SAFECALL_PTR(rettype, name) rettype(*name)
#else
#define N_CDECL(rettype, name) rettype name
#define N_STDCALL(rettype, name) rettype name
#define N_SYSCALL(rettype, name) rettype name
#define N_FASTCALL(rettype, name) rettype name
#define N_SAFECALL(rettype, name) rettype name
/* function pointers with calling convention: */
#define N_CDECL_PTR(rettype, name) rettype(*name)
#define N_STDCALL_PTR(rettype, name) rettype(*name)
#define N_SYSCALL_PTR(rettype, name) rettype(*name)
#define N_FASTCALL_PTR(rettype, name) rettype(*name)
#define N_SAFECALL_PTR(rettype, name) rettype(*name)
#endif
#ifdef __EMSCRIPTEN__
#define N_LIB_EXPORT NIM_EXTERNC __attribute__((visibility("default"), used))
#define N_LIB_EXPORT_VAR __attribute__((visibility("default"), used))
#else
#define N_LIB_EXPORT NIM_EXTERNC __attribute__((visibility("default")))
#define N_LIB_EXPORT_VAR __attribute__((visibility("default")))
#endif
#define N_LIB_IMPORT extern
#endif
#if defined(__BORLANDC__) || defined(_MSC_VER) || defined(WIN32) || defined(_WIN32)
/* these compilers have a fastcall so use it: */
#define N_NIMCALL(rettype, name) rettype __fastcall name
#define N_NIMCALL_PTR(rettype, name) rettype(__fastcall *name)
#else
#define N_NIMCALL(rettype, name) rettype name /* no modifier */
#define N_NIMCALL_PTR(rettype, name) rettype(*name)
#endif
#define N_NOCONV(rettype, name) rettype name
/* specify no calling convention */
#define N_NOCONV_PTR(rettype, name) rettype(*name)
/* calling convention mess ----------------------------------------------- */
#if defined(__GNUC__) || defined(__TINYC__)
/* these should support C99's inline */
#define N_INLINE(rettype, name) inline rettype name
#elif defined(__BORLANDC__) || defined(_MSC_VER)
/* Borland's compiler is really STRANGE here; note that the __fastcall
keyword cannot be before the return type, but __inline cannot be after
the return type, so we do not handle this mess in the code generator
but rather here. */
#define N_INLINE(rettype, name) __inline rettype name
#else /* others are less picky: */
#define N_INLINE(rettype, name) rettype __inline name
#endif
#define N_INLINE_PTR(rettype, name) rettype(*name)
#if defined(__GNUC__) || defined(__ICC__)
#define N_NOINLINE __attribute__((__noinline__))
#elif defined(_MSC_VER)
#define N_NOINLINE __declspec(noinline)
#else
#define N_NOINLINE
#endif
#define N_NOINLINE_PTR(rettype, name) rettype(*name)
#if defined(_MSC_VER)
#define NIM_ALIGN(x) __declspec(align(x))
#define NIM_ALIGNOF(x) __alignof(x)
#else
#define NIM_ALIGN(x) __attribute__((aligned(x)))
#define NIM_ALIGNOF(x) __alignof__(x)
#endif
#include <stddef.h>
/*
NIM_THREADVAR declaration based on
https://stackoverflow.com/questions/18298280/how-to-declare-a-variable-as-thread-local-portably
*/
#if defined _WIN32
#if defined _MSC_VER || defined __BORLANDC__
#define NIM_THREADVAR __declspec(thread)
#else
#define NIM_THREADVAR __thread
#endif
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112 && !defined __STDC_NO_THREADS__
#define NIM_THREADVAR _Thread_local
#elif defined _WIN32 && (defined _MSC_VER || defined __ICL || defined __BORLANDC__)
#define NIM_THREADVAR __declspec(thread)
#elif defined(__TINYC__) || defined(__GENODE__)
#define NIM_THREADVAR
/* note that ICC (linux) and Clang are covered by __GNUC__ */
#elif defined __GNUC__ || defined __SUNPRO_C || defined __xlC__
#define NIM_THREADVAR __thread
#else
#error "Cannot define NIM_THREADVAR"
#endif
N_INLINE(NB8, _Qnifc_div_sll_overflow)(long long int a, long long int b, long long int *res) {
if (b == 0) {
*res = 0;
return NIM_TRUE;
}
if (a == (long long int)(((unsigned long long int)1) << (sizeof(long long int) * 8 - 1)) && b == -1) {
*res = a;
return NIM_TRUE;
}
*res = a / b;
return NIM_FALSE;
}
N_INLINE(NB8, _Qnifc_div_sl_overflow)(long int a, long int b, long int *res) {
if (b == 0) {
*res = 0;
return NIM_TRUE;
}
if (a == (long int)(((unsigned long int)1) << (sizeof(long int) * 8 - 1)) && b == -1) {
*res = a;
return NIM_TRUE;
}
*res = a / b;
return NIM_FALSE;
}
N_INLINE(NB8, _Qnifc_div_ull_overflow)(unsigned long long int a, unsigned long long int b,
unsigned long long int *res) {
if (b == 0) {
*res = 0;
return NIM_TRUE; /* Overflow: division by zero */
}
*res = a / b;
return NIM_FALSE;
}
N_INLINE(NB8, _Qnifc_div_ul_overflow)(unsigned long int a, unsigned long int b, unsigned long int *res) {
if (b == 0) {
*res = 0;
return NIM_TRUE;
}
*res = a / b;
return NIM_FALSE;
}
N_INLINE(NB8, _Qnifc_mod_sll_overflow)(long long int a, long long int b, long long int *res) {
if (b == 0) {
*res = 0;
return NIM_TRUE;
}
if (a == (long long int)(((unsigned long long int)1) << (sizeof(long long int) * 8 - 1)) && b == -1) {
*res = 0;
return NIM_TRUE;
}
*res = a % b;
return NIM_FALSE;
}
N_INLINE(NB8, _Qnifc_mod_sl_overflow)(long int a, long int b, long int *res) {
if (b == 0) {
*res = 0;
return NIM_TRUE;
}
if (a == (long int)(((unsigned long int)1) << (sizeof(long int) * 8 - 1)) && b == -1) {
*res = 0;
return NIM_TRUE;
}
*res = a % b;
return NIM_FALSE;
}
N_INLINE(NB8, _Qnifc_mod_ull_overflow)(unsigned long long int a, unsigned long long int b,
unsigned long long int *res) {
if (b == 0) {
*res = 0;
return NIM_TRUE;
}
*res = a % b;
return NIM_FALSE;
}
N_INLINE(NB8, _Qnifc_mod_ul_overflow)(unsigned long int a, unsigned long int b, unsigned long int *res) {
if (b == 0) {
*res = 0;
return NIM_TRUE;
}
*res = a % b;
return NIM_FALSE;
}
NIM_THREADVAR NB8 NIFC_ERR_;
#include <string.h>
#include <stdio.h>
#include <malloc.h>
typedef struct Rtti_0_sysvq0asl Rtti_0_sysvq0asl;
typedef struct CoroutineBase_0_sysvq0asl CoroutineBase_0_sysvq0asl;
typedef struct Continuation_0_sysvq0asl Continuation_0_sysvq0asl;
typedef struct myecho_0_coro_tepou9hkv1 myecho_0_coro_tepou9hkv1;
typedef struct passiveProc_0_coro_tepou9hkv1 passiveProc_0_coro_tepou9hkv1;
typedef struct RootObj_0_sysvq0asl {
Rtti_0_sysvq0asl *vt_0;
} RootObj_0_sysvq0asl;
typedef N_NIMCALL_PTR(Continuation_0_sysvq0asl,
AptrSX43oroutineX42ase0sysvq0aslZSX43ontinuation0R22AnimcallZAfalseZAR61_0_t)(
CoroutineBase_0_sysvq0asl *);
typedef struct Continuation_0_sysvq0asl {
AptrSX43oroutineX42ase0sysvq0aslZSX43ontinuation0R22AnimcallZAfalseZAR61_0_t fn_0_sysvq0asl;
CoroutineBase_0_sysvq0asl *env_0_sysvq0asl;
} Continuation_0_sysvq0asl;
typedef struct CoroutineBase_0_sysvq0asl {
RootObj_0_sysvq0asl Q;
Continuation_0_sysvq0asl caller_0_sysvq0asl;
} CoroutineBase_0_sysvq0asl;
typedef struct string_0_sysvq0asl {
NC8 *a_0_sysvq0asl;
NI i_0_sysvq0asl;
} string_0_sysvq0asl;
typedef struct myecho_0_coro_tepou9hkv1 {
CoroutineBase_0_sysvq0asl Q;
string_0_sysvq0asl xX60Qf_0_tepou9hkv1;
} myecho_0_coro_tepou9hkv1;
typedef struct passiveProc_0_coro_tepou9hkv1 {
CoroutineBase_0_sysvq0asl Q;
myecho_0_coro_tepou9hkv1 X60QcoroVarX60Qf_6_tepou9hkv1;
NI i_1_lfX60Qf_4_tepou9hkv1;
NI b_1_lfX60Qf_3_tepou9hkv1;
string_0_sysvq0asl xX60Qf_1_tepou9hkv1;
} passiveProc_0_coro_tepou9hkv1;
typedef struct main_0_coro_tepou9hkv1 {
CoroutineBase_0_sysvq0asl Q;
passiveProc_0_coro_tepou9hkv1 X60QcoroVarX60Qf_7_tepou9hkv1;
} main_0_coro_tepou9hkv1;
typedef struct Rtti_0_sysvq0asl {
NI dl_0_sysvq0asl;
NU32 *dy_0_sysvq0asl;
void *mt_0_sysvq0asl[];
} Rtti_0_sysvq0asl;
typedef N_NIMCALL_PTR(void, Smyecho0corotepou9hkv1SEAnimcallZAfalseZAR33_0_t)(myecho_0_coro_tepou9hkv1 *);
typedef N_NIMCALL_PTR(void, SpassiveX50roc0corotepou9hkv1SEAnimcallZAfalseZAR40_0_t)(passiveProc_0_coro_tepou9hkv1 *);
typedef N_NIMCALL_PTR(void, AiSminusQ1ZSEAnimcallZAfalseZAR17_0_t)(NI);
Continuation_0_sysvq0asl passiveProc_0_s3_tepou9hkv1(passiveProc_0_coro_tepou9hkv1 *X60Qthis_0);
Continuation_0_sysvq0asl passiveProc_0_s0_tepou9hkv1(passiveProc_0_coro_tepou9hkv1 *X60Qthis_0);
Continuation_0_sysvq0asl passiveProc_0_s2_tepou9hkv1(passiveProc_0_coro_tepou9hkv1 *X60Qthis_0);
Continuation_0_sysvq0asl passiveProc_0_s1_tepou9hkv1(passiveProc_0_coro_tepou9hkv1 *X60Qthis_0);
Continuation_0_sysvq0asl main_0_s0_tepou9hkv1(main_0_coro_tepou9hkv1 *X60Qthis_0);
static inline void inc_0_tepou9hkv1(NI *x_3);
void eQdestroyQ_Smyecho0corotepou9hkv1_0_tepou9hkv1(myecho_0_coro_tepou9hkv1 *dest_0);
void eQdestroyQ_SpassiveX50roc0corotepou9hkv1_0_tepou9hkv1(passiveProc_0_coro_tepou9hkv1 *dest_0);
void eQdestroyQ_Smain0corotepou9hkv1_0_tepou9hkv1(main_0_coro_tepou9hkv1 *dest_0);
void eQwasmovedQ_Smain0corotepou9hkv1_0_tepou9hkv1(main_0_coro_tepou9hkv1 *dest_0);
void eQwasmovedQ_SpassiveX50roc0corotepou9hkv1_0_tepou9hkv1(passiveProc_0_coro_tepou9hkv1 *dest_0);
void eQwasmovedQ_Smyecho0corotepou9hkv1_0_tepou9hkv1(myecho_0_coro_tepou9hkv1 *dest_0);
void cancel_0_sysvq0asl(CoroutineBase_0_sysvq0asl *coro_1) {}
void write_0_syn1lfpjv(FILE *f_4, string_0_sysvq0asl s_0) {
fprintf(f_4, "%s", s_0);
}
void write_5_syn1lfpjv(FILE *f_9, NC8 c_1) {
fprintf(f_9, "%d", c_1);
}
string_0_sysvq0asl ampQ_0_sysvq0asl(string_0_sysvq0asl a_16, string_0_sysvq0asl b_12) {
// string concat (not important)
string_0_sysvq0asl result;
result.a_0_sysvq0asl = malloc(1);
result.i_0_sysvq0asl = 3;
return result;
}
static inline /* nimStrDup.c */ string_0_sysvq0asl nimStrDup /* nimStrDup.c */ (string_0_sysvq0asl s_30);
static inline /* nimStrDestroy.c */ void nimStrDestroy /* nimStrDestroy.c */ (string_0_sysvq0asl s_29);
static inline /* nimStrWasMoved.c */ void nimStrWasMoved /* nimStrWasMoved.c */ (string_0_sysvq0asl *s_28);
static inline NI len_5_sysvq0asl(string_0_sysvq0asl s_21);
// assume this function is not the issue
extern void complete_0_sysvq0asl(Continuation_0_sysvq0asl c_5);
void *alloc_0_sysvq0asl(NI size_3) {
return malloc(size_3);
}
void dealloc_0_sysvq0asl(void *p_3) {
free(p_3);
}
static inline void copyMem_0_sysvq0asl(void *dest_4, void *src_3, NI size_9);
extern N_NIMCALL(void, continueAfterOutOfMem_0_sysvq0asl)(NI size_12);
NU32 const passiveProc_0_coro_dy_tepou9hkv1[] = {1294232418ull, 3326777900ull, 2746927424ull};
Rtti_0_sysvq0asl const passiveProc_0_coro_vt_tepou9hkv1 = {
.dl_0_sysvq0asl = IL64(3),
.dy_0_sysvq0asl = ((NU32 *)passiveProc_0_coro_dy_tepou9hkv1),
.mt_0_sysvq0asl = {((void *)cancel_0_sysvq0asl), ((void *)eQdestroyQ_SpassiveX50roc0corotepou9hkv1_0_tepou9hkv1)}};
NU32 const myecho_0_coro_dy_tepou9hkv1[] = {1294232418ull, 3326777900ull, 4164815769ull};
Rtti_0_sysvq0asl const myecho_0_coro_vt_tepou9hkv1 = {
.dl_0_sysvq0asl = IL64(3),
.dy_0_sysvq0asl = ((NU32 *)myecho_0_coro_dy_tepou9hkv1),
.mt_0_sysvq0asl = {((void *)cancel_0_sysvq0asl), ((void *)eQdestroyQ_Smyecho0corotepou9hkv1_0_tepou9hkv1)}};
NU32 const main_0_coro_dy_tepou9hkv1[] = {1294232418ull, 3326777900ull, 1910435132ull};
Rtti_0_sysvq0asl const main_0_coro_vt_tepou9hkv1 = {
.dl_0_sysvq0asl = IL64(3),
.dy_0_sysvq0asl = ((NU32 *)main_0_coro_dy_tepou9hkv1),
.mt_0_sysvq0asl = {((void *)cancel_0_sysvq0asl), ((void *)eQdestroyQ_Smain0corotepou9hkv1_0_tepou9hkv1)}};
extern AiSminusQ1ZSEAnimcallZAfalseZAR17_0_t oomHandler_0_sysvq0asl;
Continuation_0_sysvq0asl myecho_0_tepou9hkv1(myecho_0_coro_tepou9hkv1 *X60Qthis_0, string_0_sysvq0asl x_0,
Continuation_0_sysvq0asl X60Qcaller_0) {
myecho_0_coro_tepou9hkv1 X60Qlhs_0 = (myecho_0_coro_tepou9hkv1){
(&myecho_0_coro_vt_tepou9hkv1), .xX60Qf_0_tepou9hkv1 = nimStrDup(x_0), .Q.caller_0_sysvq0asl = X60Qcaller_0};
eQdestroyQ_Smyecho0corotepou9hkv1_0_tepou9hkv1((&(*X60Qthis_0)));
(*X60Qthis_0) = X60Qlhs_0;
Continuation_0_sysvq0asl result_0;
write_0_syn1lfpjv(stdout, (*X60Qthis_0).xX60Qf_0_tepou9hkv1);
write_5_syn1lfpjv(stdout, (NC8)'\012');
result_0 = (*X60Qthis_0).Q.caller_0_sysvq0asl;
return result_0;
}
Continuation_0_sysvq0asl passiveProc_0_tepou9hkv1(passiveProc_0_coro_tepou9hkv1 *X60Qthis_0, string_0_sysvq0asl x_1,
Continuation_0_sysvq0asl X60Qcaller_0) {
passiveProc_0_coro_tepou9hkv1 X60Qlhs_1 = (passiveProc_0_coro_tepou9hkv1){
(&passiveProc_0_coro_vt_tepou9hkv1), .xX60Qf_1_tepou9hkv1 = nimStrDup(x_1), .Q.caller_0_sysvq0asl = X60Qcaller_0};
eQdestroyQ_SpassiveX50roc0corotepou9hkv1_0_tepou9hkv1((&(*X60Qthis_0))); // This destroy X60Qlhs_2(uninitialized).
(*X60Qthis_0) = X60Qlhs_1;
Continuation_0_sysvq0asl result_0;
NI a_1_lf_1 = IL64(0);
(*X60Qthis_0).b_1_lfX60Qf_3_tepou9hkv1 = IL64(10);
(*X60Qthis_0).i_1_lfX60Qf_4_tepou9hkv1 = a_1_lf_1;
result_0 = passiveProc_0_s3_tepou9hkv1(X60Qthis_0);
return result_0;
}
Continuation_0_sysvq0asl passiveProc_0_s3_tepou9hkv1(passiveProc_0_coro_tepou9hkv1 *X60Qthis_0) {
Continuation_0_sysvq0asl result_0;
if ((*X60Qthis_0).i_1_lfX60Qf_4_tepou9hkv1 < (*X60Qthis_0).b_1_lfX60Qf_3_tepou9hkv1) {
result_0 = passiveProc_0_s0_tepou9hkv1(X60Qthis_0);
} else {
result_0 = passiveProc_0_s1_tepou9hkv1(X60Qthis_0);
}
return result_0;
}
Continuation_0_sysvq0asl passiveProc_0_s0_tepou9hkv1(passiveProc_0_coro_tepou9hkv1 *X60Qthis_0) {
Continuation_0_sysvq0asl result_0;
string_0_sysvq0asl X60Qcf_0 = ampQ_0_sysvq0asl(
(*X60Qthis_0).xX60Qf_1_tepou9hkv1, (string_0_sysvq0asl){.a_0_sysvq0asl = (NC8 *)"xyz", .i_0_sysvq0asl = IL64(6)});
Continuation_0_sysvq0asl X60QcontVar_1 = myecho_0_tepou9hkv1(
(&(*X60Qthis_0).X60QcoroVarX60Qf_6_tepou9hkv1), X60Qcf_0,
(Continuation_0_sysvq0asl){
.fn_0_sysvq0asl =
((AptrSX43oroutineX42ase0sysvq0aslZSX43ontinuation0R22AnimcallZAfalseZAR61_0_t)passiveProc_0_s2_tepou9hkv1),
.env_0_sysvq0asl = X60Qthis_0});
nimStrDestroy(X60Qcf_0);
return X60QcontVar_1;
}
Continuation_0_sysvq0asl passiveProc_0_s2_tepou9hkv1(passiveProc_0_coro_tepou9hkv1 *X60Qthis_0) {
Continuation_0_sysvq0asl result_0;
inc_0_tepou9hkv1((&(*X60Qthis_0).i_1_lfX60Qf_4_tepou9hkv1));
result_0 = passiveProc_0_s3_tepou9hkv1(X60Qthis_0);
return result_0;
}
Continuation_0_sysvq0asl passiveProc_0_s1_tepou9hkv1(passiveProc_0_coro_tepou9hkv1 *X60Qthis_0) {
Continuation_0_sysvq0asl result_0;
result_0 = (*X60Qthis_0).Q.caller_0_sysvq0asl;
return result_0;
}
Continuation_0_sysvq0asl main_0_tepou9hkv1(main_0_coro_tepou9hkv1 *X60Qthis_0, Continuation_0_sysvq0asl X60Qcaller_0) {
main_0_coro_tepou9hkv1 X60Qlhs_2 =
(main_0_coro_tepou9hkv1){(&main_0_coro_vt_tepou9hkv1), .Q.caller_0_sysvq0asl = X60Qcaller_0};
eQdestroyQ_Smain0corotepou9hkv1_0_tepou9hkv1((&(*X60Qthis_0)));
(*X60Qthis_0) = X60Qlhs_2;
Continuation_0_sysvq0asl result_0;
Continuation_0_sysvq0asl X60QcontVar_1 = passiveProc_0_tepou9hkv1(
(&(*X60Qthis_0).X60QcoroVarX60Qf_7_tepou9hkv1), // X60QcoroVarX60Qf_7_tepou9hkv1 is uninitialized.
(string_0_sysvq0asl){.a_0_sysvq0asl = (NC8 *)"abc", .i_0_sysvq0asl = IL64(6)},
(Continuation_0_sysvq0asl){
.fn_0_sysvq0asl =
((AptrSX43oroutineX42ase0sysvq0aslZSX43ontinuation0R22AnimcallZAfalseZAR61_0_t)main_0_s0_tepou9hkv1),
.env_0_sysvq0asl = X60Qthis_0});
return X60QcontVar_1;
}
Continuation_0_sysvq0asl main_0_s0_tepou9hkv1(main_0_coro_tepou9hkv1 *X60Qthis_0) {
Continuation_0_sysvq0asl result_0;
result_0 = (*X60Qthis_0).Q.caller_0_sysvq0asl;
return result_0;
};
static inline void inc_0_tepou9hkv1(NI *x_3) {
(*x_3) = ((NI)((*x_3) + ((NI)IL64(1))));
}
void eQdestroyQ_Smyecho0corotepou9hkv1_0_tepou9hkv1(myecho_0_coro_tepou9hkv1 *dest_0) {
nimStrDestroy((*dest_0).xX60Qf_0_tepou9hkv1);
}
void eQdestroyQ_SpassiveX50roc0corotepou9hkv1_0_tepou9hkv1(passiveProc_0_coro_tepou9hkv1 *dest_0) {
// All fields of dest_0 has zero value
myecho_0_coro_tepou9hkv1 *X60QvtableTemp_0 = (&(*dest_0).X60QcoroVarX60Qf_6_tepou9hkv1);
((Smyecho0corotepou9hkv1SEAnimcallZAfalseZAR33_0_t)(*(*X60QvtableTemp_0).Q.Q.vt_0).mt_0_sysvq0asl[IL64(1)])(
(&(*X60QvtableTemp_0)));
nimStrDestroy((*dest_0).xX60Qf_1_tepou9hkv1);
}
void eQdestroyQ_Smain0corotepou9hkv1_0_tepou9hkv1(main_0_coro_tepou9hkv1 *dest_0) {
passiveProc_0_coro_tepou9hkv1 *X60QvtableTemp_1 = (&(*dest_0).X60QcoroVarX60Qf_7_tepou9hkv1);
((SpassiveX50roc0corotepou9hkv1SEAnimcallZAfalseZAR40_0_t)(*(*X60QvtableTemp_1).Q.Q.vt_0).mt_0_sysvq0asl[IL64(1)])(
(&(*X60QvtableTemp_1)));
}
void eQwasmovedQ_Smain0corotepou9hkv1_0_tepou9hkv1(main_0_coro_tepou9hkv1 *dest_0) {
(*dest_0).Q.Q.vt_0 = (&main_0_coro_vt_tepou9hkv1);
eQwasmovedQ_SpassiveX50roc0corotepou9hkv1_0_tepou9hkv1((&(*dest_0).X60QcoroVarX60Qf_7_tepou9hkv1));
}
void eQwasmovedQ_SpassiveX50roc0corotepou9hkv1_0_tepou9hkv1(passiveProc_0_coro_tepou9hkv1 *dest_0) {
(*dest_0).Q.Q.vt_0 = (&passiveProc_0_coro_vt_tepou9hkv1);
eQwasmovedQ_Smyecho0corotepou9hkv1_0_tepou9hkv1((&(*dest_0).X60QcoroVarX60Qf_6_tepou9hkv1));
nimStrWasMoved((&(*dest_0).xX60Qf_1_tepou9hkv1));
}
void eQwasmovedQ_Smyecho0corotepou9hkv1_0_tepou9hkv1(myecho_0_coro_tepou9hkv1 *dest_0) {
(*dest_0).Q.Q.vt_0 = (&myecho_0_coro_vt_tepou9hkv1);
nimStrWasMoved((&(*dest_0).xX60Qf_0_tepou9hkv1));
}
static inline /* nimStrDup.c */ string_0_sysvq0asl nimStrDup /* nimStrDup.c */ (string_0_sysvq0asl s_30) {
string_0_sysvq0asl result_54;
if ((!(((NI64)(s_30.i_0_sysvq0asl & IL64(1))) == IL64(0)))) {
NI len_7 = len_5_sysvq0asl(s_30);
result_54 =
(string_0_sysvq0asl){.a_0_sysvq0asl = ((NC8 *)alloc_0_sysvq0asl(len_7)), .i_0_sysvq0asl = s_30.i_0_sysvq0asl};
if ((!(result_54.a_0_sysvq0asl == NIM_NIL))) {
copyMem_0_sysvq0asl(((void *)result_54.a_0_sysvq0asl), ((void *)s_30.a_0_sysvq0asl), len_7);
} else {
// oomHandler_0_sysvq0asl(len_7);
result_54.i_0_sysvq0asl = IL64(0);
}
} else {
result_54 = s_30;
}
return result_54;
}
static inline /* nimStrDestroy.c */ void nimStrDestroy /* nimStrDestroy.c */ (string_0_sysvq0asl s_29) {
if ((!(((NI64)(s_29.i_0_sysvq0asl & IL64(1))) == IL64(0)))) {
dealloc_0_sysvq0asl(((void *)s_29.a_0_sysvq0asl));
}
}
static inline /* nimStrWasMoved.c */ void nimStrWasMoved /* nimStrWasMoved.c */ (string_0_sysvq0asl *s_28) {
(*s_28).i_0_sysvq0asl = IL64(0);
}
static inline NI len_5_sysvq0asl(string_0_sysvq0asl s_21) {
NI result_48;
result_48 = ((NI64)(((NI64)s_21.i_0_sysvq0asl) >> ((NU64)IL64(1))));
return result_48;
}
static inline void copyMem_0_sysvq0asl(void *dest_4, void *src_3, NI size_9) {
memcpy(dest_4, src_3, ((size_t)size_9));
}
int cmdCount;
NC8 **cmdLine;
int main(int argc, char **argv) {
cmdCount = argc;
cmdLine = (NC8 **)argv;
main_0_coro_tepou9hkv1 X60QcoroVar_0;
// Initialize X60QcoroVar_0
eQwasmovedQ_Smain0corotepou9hkv1_0_tepou9hkv1((&X60QcoroVar_0));
main_0_tepou9hkv1((&X60QcoroVar_0),
(Continuation_0_sysvq0asl){.fn_0_sysvq0asl = NIM_NIL, .env_0_sysvq0asl = NIM_NIL});
// complete_0_sysvq0asl(main_0_tepou9hkv1(
// (&X60QcoroVar_0), (Continuation_0_sysvq0asl){.fn_0_sysvq0asl = NIM_NIL, .env_0_sysvq0asl = NIM_NIL}));
eQdestroyQ_Smain0corotepou9hkv1_0_tepou9hkv1((&X60QcoroVar_0));
}
I guess enabling ASAN+UBSAN for C compiler would catch this kind of bug easily?
Yeah, sure. I am sorry, I meant a "challenge" to find it by reading the code. I know that tooling can find it easily.