Files
bux-lang/tests/golden/fibonacci/expected.c
T

2968 lines
65 KiB
C

/* Generated by Bux Compiler (LIR backend) */
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <string.h>
typedef struct StringBuilder StringBuilder;
typedef struct TaskHandle TaskHandle;
typedef struct Mutex Mutex;
typedef struct RwLock RwLock;
typedef struct JsonValue JsonValue;
typedef struct JsonParser JsonParser;
typedef struct Channel_int Channel_int;
typedef struct Channel_float64 Channel_float64;
/* Extern function declarations */
extern void* bux_alloc(unsigned int size);
extern void* bux_realloc(void* ptr, unsigned int size);
extern void bux_free(void* ptr);
extern void bux_bounds_check(unsigned int index, unsigned int len);
extern void* bux_channel_new(int64_t capacity, int64_t elem_size);
extern void bux_channel_send(void* handle, void* elem);
extern int bux_channel_recv(void* handle, void* out);
extern void bux_channel_close(void* handle);
extern void bux_channel_free(void* handle);
extern int bux_dir_exists(const char* path);
extern int bux_mkdir_if_needed(const char* path);
extern const char** bux_list_dir(const char* dir, const char* ext, int* out_count);
extern void PrintLine(const char* s);
extern void Print(const char* s);
extern void PrintInt(int n);
extern void PrintInt64(int64_t n);
extern void PrintFloat(double f);
extern void PrintBool(bool b);
extern const char* ReadLine(void);
extern const char* bux_read_file(const char* path);
extern int bux_write_file(const char* path, const char* content);
extern int bux_file_exists(const char* path);
extern unsigned int bux_hash_bytes(void* ptr, unsigned int size);
extern unsigned int bux_hash_string(const char* s);
extern double bux_sqrt(double x);
extern double bux_pow(double x, double y);
extern int64_t bux_abs_i64(int64_t x);
extern double bux_abs_f64(double x);
extern int64_t bux_min_i64(int64_t a, int64_t b);
extern int64_t bux_max_i64(int64_t a, int64_t b);
extern double bux_min_f64(double a, double b);
extern double bux_max_f64(double a, double b);
extern void* bux_alloc(unsigned int size);
extern void* bux_realloc(void* ptr, unsigned int size);
extern void bux_free(void* ptr);
extern int bux_mem_eq(void* a, void* b, unsigned int size);
extern const char* bux_path_join(const char* a, const char* b);
extern const char* bux_path_parent(const char* path);
extern const char* bux_path_ext(const char* path);
extern unsigned int bux_hash_bytes(void* ptr, unsigned int size);
extern int bux_mem_eq(void* a, void* b, unsigned int size);
extern void* bux_alloc(unsigned int size);
extern void bux_free(void* ptr);
extern unsigned int bux_strlen(const char* s);
extern int bux_strcmp(const char* a, const char* b);
extern int bux_strncmp(const char* a, const char* b, unsigned int n);
extern char* bux_strcpy(char* dest, const char* src);
extern char* bux_strcat(char* dest, const char* src);
extern char* bux_strncpy(char* dest, const char* src, unsigned int n);
extern const char* bux_strstr(const char* haystack, const char* needle);
extern int bux_str_contains(const char* haystack, const char* needle);
extern const char* bux_str_slice(const char* s, unsigned int start, unsigned int len);
extern const char* bux_str_trim_left(const char* s);
extern const char* bux_str_trim_right(const char* s);
extern const char* bux_str_trim(const char* s);
extern const char* bux_int_to_str(int64_t n);
extern int64_t bux_str_to_int(const char* s);
extern void* bux_sb_new(unsigned int initial_cap);
extern void bux_sb_append(void* sb, const char* s);
extern void bux_sb_append_int(void* sb, int64_t n);
extern void bux_sb_append_float(void* sb, double f);
extern void bux_sb_append_char(void* sb, char c);
extern const char* bux_sb_build(void* sb);
extern void bux_sb_free(void* sb);
extern unsigned int bux_str_split_count(const char* s, const char* delim);
extern const char* bux_str_split_part(const char* s, const char* delim, unsigned int index);
extern const char* bux_str_join2(const char* a, const char* b, const char* sep);
extern const char* bux_float_to_string(double f);
extern const char* bux_str_format(const char* pattern, const char* a0, const char* a1, const char* a2, const char* a3, const char* a4, const char* a5, const char* a6, const char* a7);
extern double bux_str_to_float(const char* s);
extern void* bux_task_spawn(void* fn, void* arg);
extern void bux_task_join(void* handle);
extern void bux_task_sleep(int64_t ms);
extern int bux_argc(void);
extern const char* bux_argv(int index);
extern const char* bux_getenv(const char* name);
extern int bux_setenv(const char* name, const char* value);
extern const char* bux_getcwd(void);
extern int bux_chdir(const char* path);
extern int64_t bux_time_ms(void);
extern int64_t bux_time_us(void);
extern void bux_sleep_ms(int64_t ms);
extern int bux_process_run(const char* cmd);
extern const char* bux_process_output(const char* cmd);
extern int bux_socket_create(void);
extern int bux_socket_reuse(int fd);
extern int bux_socket_bind(int fd, const char* addr, int port);
extern int bux_socket_listen(int fd, int backlog);
extern int bux_socket_accept(int fd);
extern int bux_socket_connect(int fd, const char* addr, int port);
extern int bux_socket_send(int fd, const char* data, int len);
extern const char* bux_socket_recv(int fd, int maxLen);
extern int bux_socket_close(int fd);
extern const char* bux_socket_error(void);
extern void bux_sha256(const char* data, int len, void* out);
extern void bux_hmac_sha256(const char* key, int keylen, const char* msg, int msglen, void* out);
extern int bux_random_bytes(void* buf, int len);
extern const char* bux_base64_encode(const char* data, int len);
extern const char* bux_base64_decode(const char* data, int len, int* outlen);
extern const char* bux_bytes_to_hex(void* data, int len);
extern void* bux_mutex_new(void);
extern void bux_mutex_lock(void* handle);
extern void bux_mutex_unlock(void* handle);
extern void bux_mutex_free(void* handle);
extern void* bux_rwlock_new(void);
extern void bux_rwlock_rdlock(void* handle);
extern void bux_rwlock_wrlock(void* handle);
extern void bux_rwlock_unlock(void* handle);
extern void bux_rwlock_free(void* handle);
extern void bux_exit(int code);
extern void bux_assert(int cond, const char* file, int line, const char* expr);
extern JsonValue JsonParser_ParseValue(JsonParser* p);
/* Constants */
#define JsonTagNull 0
#define JsonTagBool 1
#define JsonTagNumber 2
#define JsonTagString 3
#define JsonTagArray 4
#define JsonTagObject 5
typedef enum {
Result_Ok,
Result_Err
} Result_Tag;
typedef union {
int Ok_0;
const char* Err_0;
} Result_Data;
typedef struct {
Result_Tag tag;
Result_Data data;
} Result;
typedef enum {
Option_Some,
Option_None
} Option_Tag;
typedef union {
int Some_0;
} Option_Data;
typedef struct {
Option_Tag tag;
Option_Data data;
} Option;
typedef struct StringBuilder {
void* handle;
} StringBuilder;
typedef struct TaskHandle {
void* handle;
} TaskHandle;
typedef struct Mutex {
void* handle;
} Mutex;
typedef struct RwLock {
void* handle;
} RwLock;
typedef struct JsonValue {
int tag;
bool boolVal;
double numVal;
const char* strVal;
JsonValue* arrData;
unsigned int arrLen;
unsigned int arrCap;
const char** objKeys;
JsonValue* objValues;
unsigned int objLen;
unsigned int objCap;
} JsonValue;
typedef struct JsonParser {
const char* src;
unsigned int pos;
unsigned int len;
const char* error;
} JsonParser;
typedef struct Channel_int {
void* handle;
} Channel_int;
typedef struct Channel_float64 {
void* handle;
} Channel_float64;
void Channel_SendInt(Channel_int* ch, int value);
int Channel_RecvInt(Channel_int* ch);
void Channel_SendFloat64(Channel_float64* ch, double value);
double Channel_RecvFloat64(Channel_float64* ch);
bool DirExists(const char* path);
bool Mkdir(const char* path);
const char** ListDir(const char* dir, const char* ext, int* count);
const char* ReadFile(const char* path);
bool WriteFile(const char* path, const char* content);
bool FileExists(const char* path);
double Sqrt(double x);
double Pow(double x, double y);
int64_t Abs(int64_t n);
double AbsF(double f);
int64_t Min(int64_t a, int64_t b);
int64_t Max(int64_t a, int64_t b);
double MinF(double a, double b);
double MaxF(double a, double b);
void* Alloc(unsigned int size);
void* Realloc(void* ptr, unsigned int size);
void Free(void* ptr);
bool MemEq(void* a, void* b, unsigned int size);
const char* Path_Join(const char* a, const char* b);
const char* Path_Parent(const char* path);
const char* Path_Ext(const char* path);
unsigned int String_Len(const char* s);
bool String_Eq(const char* a, const char* b);
const char* String_Concat(const char* a, const char* b);
const char* String_Copy(const char* s);
bool String_StartsWith(const char* s, const char* prefix);
bool String_EndsWith(const char* s, const char* suffix);
bool String_Contains(const char* s, const char* substr);
const char* String_Slice(const char* s, unsigned int start, unsigned int len);
const char* String_Trim(const char* s);
const char* String_TrimLeft(const char* s);
const char* String_TrimRight(const char* s);
const char* String_FromInt(int64_t n);
int64_t String_ToInt(const char* s);
StringBuilder StringBuilder_New(void);
StringBuilder StringBuilder_NewCap(unsigned int cap);
void StringBuilder_Append(StringBuilder* sb, const char* s);
void StringBuilder_AppendInt(StringBuilder* sb, int64_t n);
void StringBuilder_AppendFloat(StringBuilder* sb, double f);
void StringBuilder_AppendChar(StringBuilder* sb, char c);
const char* StringBuilder_Build(StringBuilder* sb);
void StringBuilder_Free(StringBuilder* sb);
unsigned int String_SplitCount(const char* s, const char* delim);
const char* String_SplitPart(const char* s, const char* delim, unsigned int index);
const char* String_Join2(const char* a, const char* b, const char* sep);
const char* String_Find(const char* haystack, const char* needle);
const char* String_Replace(const char* s, const char* old, const char* new);
double String_ToFloat(const char* s);
const char* String_FromFloat(double f);
const char* String_Format1(const char* pattern, const char* a0);
const char* String_Format2(const char* pattern, const char* a0, const char* a1);
const char* String_Format3(const char* pattern, const char* a0, const char* a1, const char* a2);
TaskHandle Task_Spawn(void* fn, void* arg);
void Task_Join(TaskHandle t);
void Task_Sleep(int64_t ms);
int Os_ArgsCount(void);
const char* Os_Args(int index);
const char* Os_GetEnv(const char* name);
bool Os_SetEnv(const char* name, const char* value);
const char* Os_GetCwd(void);
bool Os_Chdir(const char* path);
int64_t Time_NowMs(void);
int64_t Time_NowUs(void);
void Time_SleepMs(int64_t ms);
int Process_Run(const char* cmd);
const char* Process_Output(const char* cmd);
int Net_Create(void);
bool Net_SetReuse(int fd);
bool Net_Bind(int fd, const char* addr, int port);
bool Net_Listen(int fd, int backlog);
int Net_Accept(int fd);
bool Net_Connect(int fd, const char* addr, int port);
int Net_Send(int fd, const char* data);
const char* Net_Recv(int fd, int maxLen);
bool Net_Close(int fd);
const char* Net_LastError(void);
const char* Fmt_Fmt1(const char* pattern, const char* a);
const char* Fmt_Fmt2(const char* pattern, const char* a, const char* b);
const char* Fmt_Fmt3(const char* pattern, const char* a, const char* b, const char* c);
const char* Fmt_FmtInt(const char* pattern, int64_t n);
const char* Fmt_FmtInt2(const char* pattern, int64_t n1, int64_t n2);
const char* Fmt_FmtFloat(const char* pattern, double f);
const char* Fmt_FmtBool(const char* pattern, bool b);
const char* Crypto_Sha256(const char* data);
const char* Crypto_HmacSha256(const char* key, const char* message);
const char* Crypto_RandomBytes(int n);
const char* Crypto_Base64Encode(const char* s);
const char* Crypto_HmacSha256Raw(const char* key, const char* message);
const char* Crypto_Base64Decode(const char* s);
Mutex Mutex_New(void);
void Mutex_Lock(Mutex* m);
void Mutex_Unlock(Mutex* m);
void Mutex_Free(Mutex* m);
RwLock RwLock_New(void);
void RwLock_ReadLock(RwLock* rw);
void RwLock_WriteLock(RwLock* rw);
void RwLock_Unlock(RwLock* rw);
void RwLock_Free(RwLock* rw);
void Test_Exit(int code);
void Test_Assert(bool cond);
void Test_AssertEqInt(int a, int b);
void Test_AssertTrue(bool cond);
void Test_AssertFalse(bool cond);
void Test_Fail(const char* msg);
Result Result_NewOk(int value);
Result Result_NewErr(const char* msg);
bool Result_IsOk(Result r);
bool Result_IsErr(Result r);
int Result_Unwrap(Result r);
int Result_UnwrapOr(Result r, int fallback);
Option Option_NewSome(int value);
Option Option_NewNone(void);
bool Option_IsSome(Option o);
bool Option_IsNone(Option o);
int Option_Unwrap(Option o);
int Option_UnwrapOr(Option o, int fallback);
JsonValue Json_Null(void);
JsonValue Json_Bool(bool b);
JsonValue Json_Number(double n);
JsonValue Json_String(const char* s);
JsonValue Json_Array(void);
JsonValue Json_Object(void);
unsigned int Json_ArrayLen(JsonValue v);
JsonValue Json_ArrayGet(JsonValue v, unsigned int index);
void Json_ArrayPush(JsonValue* self, JsonValue val);
unsigned int Json_ObjectLen(JsonValue v);
JsonValue Json_ObjectGet(JsonValue v, const char* key);
bool Json_ObjectHas(JsonValue v, const char* key);
void Json_ObjectSet(JsonValue* self, const char* key, JsonValue val);
bool Json_IsNull(JsonValue v);
bool Json_AsBool(JsonValue v);
double Json_AsNumber(JsonValue v);
const char* Json_AsString(JsonValue v);
int JsonParser_Peek(JsonParser* p);
void JsonParser_Advance(JsonParser* p);
void JsonParser_SkipWhitespace(JsonParser* p);
bool JsonParser_Match(JsonParser* p, const char* expected);
const char* JsonParser_ParseString(JsonParser* p);
JsonValue JsonParser_ParseNumber(JsonParser* p);
JsonValue JsonParser_ParseArray(JsonParser* p);
JsonValue JsonParser_ParseObject(JsonParser* p);
JsonValue JsonParser_ParseValue(JsonParser* p);
JsonValue Json_Parse(const char* s);
void Json_StringifyImpl(StringBuilder* sb, JsonValue v);
const char* Json_Stringify(JsonValue v);
int Fibonacci(int n);
int Main(void);
void Channel_SendInt(Channel_int* ch, int value) {
void* _t2;
void* _t3;
void* _t1;
_t1 = ch->handle;
_t2 = &value;
_t3 = (void*)_t2;
bux_channel_send(_t1, _t3);
}
int Channel_RecvInt(Channel_int* ch) {
void* _t5;
void* _t6;
int result;
result = 0;
void* _t4;
_t4 = ch->handle;
_t5 = &result;
_t6 = (void*)_t5;
bux_channel_recv(_t4, _t6);
return result;
}
void Channel_SendFloat64(Channel_float64* ch, double value) {
void* _t8;
void* _t9;
void* _t7;
_t7 = ch->handle;
_t8 = &value;
_t9 = (void*)_t8;
bux_channel_send(_t7, _t9);
}
double Channel_RecvFloat64(Channel_float64* ch) {
void* _t11;
void* _t12;
double result;
result = 0.0;
void* _t10;
_t10 = ch->handle;
_t11 = &result;
_t12 = (void*)_t11;
bux_channel_recv(_t10, _t12);
return result;
}
bool DirExists(const char* path) {
int _t14;
int _t13;
_t13 = bux_dir_exists(path);
_t14 = (_t13 != 0);
return _t14;
}
bool Mkdir(const char* path) {
int _t16;
int _t15;
_t15 = bux_mkdir_if_needed(path);
_t16 = (_t15 != 0);
return _t16;
}
const char** ListDir(const char* dir, const char* ext, int* count) {
const char** _t17;
_t17 = bux_list_dir(dir, ext, count);
return _t17;
}
const char* ReadFile(const char* path) {
const char* _t18;
_t18 = bux_read_file(path);
return _t18;
}
bool WriteFile(const char* path, const char* content) {
int _t20;
int r;
int _t19;
_t19 = bux_write_file(path, content);
r = _t19;
_t20 = (r != 0);
return _t20;
}
bool FileExists(const char* path) {
int _t22;
int r;
int _t21;
_t21 = bux_file_exists(path);
r = _t21;
_t22 = (r != 0);
return _t22;
}
double Sqrt(double x) {
double _t23;
_t23 = bux_sqrt(x);
return _t23;
}
double Pow(double x, double y) {
double _t24;
_t24 = bux_pow(x, y);
return _t24;
}
int64_t Abs(int64_t n) {
int64_t _t25;
_t25 = bux_abs_i64(n);
return _t25;
}
double AbsF(double f) {
double _t26;
_t26 = bux_abs_f64(f);
return _t26;
}
int64_t Min(int64_t a, int64_t b) {
int64_t _t27;
_t27 = bux_min_i64(a, b);
return _t27;
}
int64_t Max(int64_t a, int64_t b) {
int64_t _t28;
_t28 = bux_max_i64(a, b);
return _t28;
}
double MinF(double a, double b) {
double _t29;
_t29 = bux_min_f64(a, b);
return _t29;
}
double MaxF(double a, double b) {
double _t30;
_t30 = bux_max_f64(a, b);
return _t30;
}
void* Alloc(unsigned int size) {
void* _t31;
_t31 = bux_alloc(size);
return _t31;
}
void* Realloc(void* ptr, unsigned int size) {
void* _t32;
_t32 = bux_realloc(ptr, size);
return _t32;
}
void Free(void* ptr) {
bux_free(ptr);
}
bool MemEq(void* a, void* b, unsigned int size) {
int _t34;
int _t33;
_t33 = bux_mem_eq(a, b, size);
_t34 = (_t33 != 0);
return _t34;
}
const char* Path_Join(const char* a, const char* b) {
const char* _t35;
_t35 = bux_path_join(a, b);
return _t35;
}
const char* Path_Parent(const char* path) {
const char* _t36;
_t36 = bux_path_parent(path);
return _t36;
}
const char* Path_Ext(const char* path) {
const char* _t37;
_t37 = bux_path_ext(path);
return _t37;
}
unsigned int String_Len(const char* s) {
unsigned int _t38;
_t38 = bux_strlen(s);
return _t38;
}
bool String_Eq(const char* a, const char* b) {
int _t40;
int _t39;
_t39 = bux_strcmp(a, b);
_t40 = (_t39 == 0);
return _t40;
}
const char* String_Concat(const char* a, const char* b) {
int _t43;
int _t44;
char* _t46;
unsigned int len_a;
unsigned int _t41;
_t41 = bux_strlen(a);
len_a = _t41;
unsigned int len_b;
unsigned int _t42;
_t42 = bux_strlen(b);
len_b = _t42;
unsigned int total;
_t43 = len_a + len_b;
_t44 = _t43 + 1;
total = _t44;
char* buf;
void* _t45;
_t45 = bux_alloc(total);
_t46 = (char*)_t45;
buf = _t46;
bux_strcpy(buf, a);
bux_strcat(buf, b);
return buf;
}
const char* String_Copy(const char* s) {
int _t48;
char* _t50;
unsigned int len;
unsigned int _t47;
_t47 = bux_strlen(s);
len = _t47;
char* buf;
_t48 = len + 1;
void* _t49;
_t49 = bux_alloc(_t48);
_t50 = (char*)_t49;
buf = _t50;
bux_strcpy(buf, s);
return buf;
}
bool String_StartsWith(const char* s, const char* prefix) {
int _t53;
int _t55;
unsigned int s_len;
unsigned int _t51;
_t51 = bux_strlen(s);
s_len = _t51;
unsigned int p_len;
unsigned int _t52;
_t52 = bux_strlen(prefix);
p_len = _t52;
_t53 = (p_len > s_len);
if (!_t53) goto endif2;
{
return 0;
}
endif2:;
int r;
int _t54;
_t54 = bux_strncmp(s, prefix, p_len);
r = _t54;
_t55 = (r == 0);
return _t55;
}
bool String_EndsWith(const char* s, const char* suffix) {
int _t58;
int _t59;
int _t62;
unsigned int s_len;
unsigned int _t56;
_t56 = bux_strlen(s);
s_len = _t56;
unsigned int suf_len;
unsigned int _t57;
_t57 = bux_strlen(suffix);
suf_len = _t57;
_t58 = (suf_len > s_len);
if (!_t58) goto endif4;
{
return 0;
}
endif4:;
unsigned int start;
_t59 = s_len - suf_len;
start = _t59;
const char* tail;
const char* _t60;
_t60 = bux_str_slice(s, start, suf_len);
tail = _t60;
bool eq;
int _t61;
_t61 = bux_strcmp(tail, suffix);
_t62 = (_t61 == 0);
eq = _t62;
return eq;
}
bool String_Contains(const char* s, const char* substr) {
int _t64;
int r;
int _t63;
_t63 = bux_str_contains(s, substr);
r = _t63;
_t64 = (r != 0);
return _t64;
}
const char* String_Slice(const char* s, unsigned int start, unsigned int len) {
const char* _t65;
_t65 = bux_str_slice(s, start, len);
return _t65;
}
const char* String_Trim(const char* s) {
const char* _t66;
_t66 = bux_str_trim(s);
return _t66;
}
const char* String_TrimLeft(const char* s) {
const char* _t67;
_t67 = bux_str_trim_left(s);
return _t67;
}
const char* String_TrimRight(const char* s) {
const char* _t68;
_t68 = bux_str_trim_right(s);
return _t68;
}
const char* String_FromInt(int64_t n) {
const char* _t69;
_t69 = bux_int_to_str(n);
return _t69;
}
int64_t String_ToInt(const char* s) {
int64_t _t70;
_t70 = bux_str_to_int(s);
return _t70;
}
StringBuilder StringBuilder_New(void) {
StringBuilder _t72;
void* _t71;
_t71 = bux_sb_new(64);
_t72 = (StringBuilder){.handle = _t71};
return _t72;
}
StringBuilder StringBuilder_NewCap(unsigned int cap) {
StringBuilder _t74;
void* _t73;
_t73 = bux_sb_new(cap);
_t74 = (StringBuilder){.handle = _t73};
return _t74;
}
void StringBuilder_Append(StringBuilder* sb, const char* s) {
void* _t75;
_t75 = sb->handle;
bux_sb_append(_t75, s);
}
void StringBuilder_AppendInt(StringBuilder* sb, int64_t n) {
void* _t76;
_t76 = sb->handle;
bux_sb_append_int(_t76, n);
}
void StringBuilder_AppendFloat(StringBuilder* sb, double f) {
void* _t77;
_t77 = sb->handle;
bux_sb_append_float(_t77, f);
}
void StringBuilder_AppendChar(StringBuilder* sb, char c) {
void* _t78;
_t78 = sb->handle;
bux_sb_append_char(_t78, c);
}
const char* StringBuilder_Build(StringBuilder* sb) {
void* _t79;
_t79 = sb->handle;
const char* _t80;
_t80 = bux_sb_build(_t79);
return _t80;
}
void StringBuilder_Free(StringBuilder* sb) {
void* _t81;
_t81 = sb->handle;
bux_sb_free(_t81);
}
unsigned int String_SplitCount(const char* s, const char* delim) {
unsigned int _t82;
_t82 = bux_str_split_count(s, delim);
return _t82;
}
const char* String_SplitPart(const char* s, const char* delim, unsigned int index) {
const char* _t83;
_t83 = bux_str_split_part(s, delim, index);
return _t83;
}
const char* String_Join2(const char* a, const char* b, const char* sep) {
const char* _t84;
_t84 = bux_str_join2(a, b, sep);
return _t84;
}
const char* String_Find(const char* haystack, const char* needle) {
const char* _t85;
_t85 = bux_strstr(haystack, needle);
return _t85;
}
const char* String_Replace(const char* s, const char* old, const char* new) {
unsigned int _t87;
int _t88;
unsigned int _t90;
unsigned int _t91;
int _t92;
int _t94;
int _t96;
int _t97;
const char* pos;
const char* _t86;
_t86 = bux_strstr(s, old);
pos = _t86;
_t87 = (unsigned int)pos;
_t88 = (_t87 == 0);
if (!_t88) goto endif6;
{
return s;
}
endif6:;
unsigned int oldLen;
unsigned int _t89;
_t89 = bux_strlen(old);
oldLen = _t89;
unsigned int prefixLen;
_t90 = (unsigned int)pos;
_t91 = (unsigned int)s;
_t92 = _t90 - _t91;
prefixLen = _t92;
const char* prefix;
const char* _t93;
_t93 = bux_str_slice(s, 0, prefixLen);
prefix = _t93;
const char* suffix;
_t94 = prefixLen + oldLen;
unsigned int _t95;
_t95 = bux_strlen(s);
_t96 = _t95 - prefixLen;
_t97 = _t96 - oldLen;
const char* _t98;
_t98 = bux_str_slice(s, _t94, _t97);
suffix = _t98;
const char* temp;
const char* _t99;
_t99 = String_Concat(prefix, new);
temp = _t99;
const char* result;
const char* _t100;
_t100 = String_Concat(temp, suffix);
result = _t100;
return result;
}
double String_ToFloat(const char* s) {
double _t101;
_t101 = bux_str_to_float(s);
return _t101;
}
const char* String_FromFloat(double f) {
const char* _t102;
_t102 = bux_float_to_string(f);
return _t102;
}
const char* String_Format1(const char* pattern, const char* a0) {
const char* _t103;
_t103 = bux_str_format(pattern, a0, "", "", "", "", "", "", "");
return _t103;
}
const char* String_Format2(const char* pattern, const char* a0, const char* a1) {
const char* _t104;
_t104 = bux_str_format(pattern, a0, a1, "", "", "", "", "", "");
return _t104;
}
const char* String_Format3(const char* pattern, const char* a0, const char* a1, const char* a2) {
const char* _t105;
_t105 = bux_str_format(pattern, a0, a1, a2, "", "", "", "", "");
return _t105;
}
TaskHandle Task_Spawn(void* fn, void* arg) {
TaskHandle _t107;
void* _t106;
_t106 = bux_task_spawn(fn, arg);
_t107 = (TaskHandle){.handle = _t106};
return _t107;
}
void Task_Join(TaskHandle t) {
void* _t108;
_t108 = t.handle;
bux_task_join(_t108);
}
void Task_Sleep(int64_t ms) {
bux_task_sleep(ms);
}
int Os_ArgsCount(void) {
int _t109;
_t109 = bux_argc();
return _t109;
}
const char* Os_Args(int index) {
const char* _t110;
_t110 = bux_argv(index);
return _t110;
}
const char* Os_GetEnv(const char* name) {
const char* _t111;
_t111 = bux_getenv(name);
return _t111;
}
bool Os_SetEnv(const char* name, const char* value) {
int _t113;
int _t112;
_t112 = bux_setenv(name, value);
_t113 = (_t112 == 0);
return _t113;
}
const char* Os_GetCwd(void) {
const char* _t114;
_t114 = bux_getcwd();
return _t114;
}
bool Os_Chdir(const char* path) {
int _t116;
int _t115;
_t115 = bux_chdir(path);
_t116 = (_t115 == 0);
return _t116;
}
int64_t Time_NowMs(void) {
int64_t _t117;
_t117 = bux_time_ms();
return _t117;
}
int64_t Time_NowUs(void) {
int64_t _t118;
_t118 = bux_time_us();
return _t118;
}
void Time_SleepMs(int64_t ms) {
bux_sleep_ms(ms);
}
int Process_Run(const char* cmd) {
int _t119;
_t119 = bux_process_run(cmd);
return _t119;
}
const char* Process_Output(const char* cmd) {
const char* _t120;
_t120 = bux_process_output(cmd);
return _t120;
}
int Net_Create(void) {
int _t121;
_t121 = bux_socket_create();
return _t121;
}
bool Net_SetReuse(int fd) {
int _t123;
int _t122;
_t122 = bux_socket_reuse(fd);
_t123 = (_t122 == 0);
return _t123;
}
bool Net_Bind(int fd, const char* addr, int port) {
int _t125;
int _t124;
_t124 = bux_socket_bind(fd, addr, port);
_t125 = (_t124 == 0);
return _t125;
}
bool Net_Listen(int fd, int backlog) {
int _t127;
int _t126;
_t126 = bux_socket_listen(fd, backlog);
_t127 = (_t126 == 0);
return _t127;
}
int Net_Accept(int fd) {
int _t128;
_t128 = bux_socket_accept(fd);
return _t128;
}
bool Net_Connect(int fd, const char* addr, int port) {
int _t130;
int _t129;
_t129 = bux_socket_connect(fd, addr, port);
_t130 = (_t129 == 0);
return _t130;
}
int Net_Send(int fd, const char* data) {
int _t132;
unsigned int _t131;
_t131 = String_Len(data);
_t132 = (int)_t131;
int _t133;
_t133 = bux_socket_send(fd, data, _t132);
return _t133;
}
const char* Net_Recv(int fd, int maxLen) {
const char* _t134;
_t134 = bux_socket_recv(fd, maxLen);
return _t134;
}
bool Net_Close(int fd) {
int _t136;
int _t135;
_t135 = bux_socket_close(fd);
_t136 = (_t135 == 0);
return _t136;
}
const char* Net_LastError(void) {
const char* _t137;
_t137 = bux_socket_error();
return _t137;
}
const char* Fmt_Fmt1(const char* pattern, const char* a) {
const char* _t138;
_t138 = String_Format1(pattern, a);
return _t138;
}
const char* Fmt_Fmt2(const char* pattern, const char* a, const char* b) {
const char* _t139;
_t139 = String_Format2(pattern, a, b);
return _t139;
}
const char* Fmt_Fmt3(const char* pattern, const char* a, const char* b, const char* c) {
const char* _t140;
_t140 = String_Format3(pattern, a, b, c);
return _t140;
}
const char* Fmt_FmtInt(const char* pattern, int64_t n) {
const char* _t141;
_t141 = String_FromInt(n);
const char* _t142;
_t142 = String_Format1(pattern, _t141);
return _t142;
}
const char* Fmt_FmtInt2(const char* pattern, int64_t n1, int64_t n2) {
const char* _t143;
_t143 = String_FromInt(n1);
const char* _t144;
_t144 = String_FromInt(n2);
const char* _t145;
_t145 = String_Format2(pattern, _t143, _t144);
return _t145;
}
const char* Fmt_FmtFloat(const char* pattern, double f) {
const char* _t146;
_t146 = String_FromFloat(f);
const char* _t147;
_t147 = String_Format1(pattern, _t146);
return _t147;
}
const char* Fmt_FmtBool(const char* pattern, bool b) {
if (!b) goto endif8;
{
const char* _t148;
_t148 = String_Format1(pattern, "true");
return _t148;
}
endif8:;
const char* _t149;
_t149 = String_Format1(pattern, "false");
return _t149;
}
const char* Crypto_Sha256(const char* data) {
int _t151;
void* _t153;
int len;
unsigned int _t150;
_t150 = String_Len(data);
_t151 = (int)_t150;
len = _t151;
void* hashBuf;
void* _t152;
_t152 = Alloc(32);
hashBuf = _t152;
bux_sha256(data, len, hashBuf);
const char* result;
_t153 = (void*)hashBuf;
const char* _t154;
_t154 = bux_bytes_to_hex(_t153, 32);
result = _t154;
Free(hashBuf);
return result;
}
const char* Crypto_HmacSha256(const char* key, const char* message) {
int _t156;
int _t158;
void* _t160;
int keylen;
unsigned int _t155;
_t155 = String_Len(key);
_t156 = (int)_t155;
keylen = _t156;
int msglen;
unsigned int _t157;
_t157 = String_Len(message);
_t158 = (int)_t157;
msglen = _t158;
void* hmacBuf;
void* _t159;
_t159 = Alloc(32);
hmacBuf = _t159;
bux_hmac_sha256(key, keylen, message, msglen, hmacBuf);
const char* result;
_t160 = (void*)hmacBuf;
const char* _t161;
_t161 = bux_bytes_to_hex(_t160, 32);
result = _t161;
Free(hmacBuf);
return result;
}
const char* Crypto_RandomBytes(int n) {
int _t162;
unsigned int _t163;
int _t166;
const char* _t167;
_t162 = (n <= 0);
if (!_t162) goto endif10;
{
return "";
}
endif10:;
void* buf;
_t163 = (unsigned int)n;
void* _t164;
_t164 = Alloc(_t163);
buf = _t164;
int _t165;
_t165 = bux_random_bytes(buf, n);
_t166 = (_t165 != 1);
if (!_t166) goto endif12;
{
Free(buf);
return "";
}
endif12:;
const char* result;
_t167 = (const char*)buf;
const char* _t168;
_t168 = bux_base64_encode(_t167, n);
result = _t168;
Free(buf);
return result;
}
const char* Crypto_Base64Encode(const char* s) {
int _t170;
unsigned int _t169;
_t169 = String_Len(s);
_t170 = (int)_t169;
const char* _t171;
_t171 = bux_base64_encode(s, _t170);
return _t171;
}
const char* Crypto_HmacSha256Raw(const char* key, const char* message) {
int _t173;
int _t175;
const char* _t177;
int keylen;
unsigned int _t172;
_t172 = String_Len(key);
_t173 = (int)_t172;
keylen = _t173;
int msglen;
unsigned int _t174;
_t174 = String_Len(message);
_t175 = (int)_t174;
msglen = _t175;
void* hmacBuf;
void* _t176;
_t176 = Alloc(32);
hmacBuf = _t176;
bux_hmac_sha256(key, keylen, message, msglen, hmacBuf);
const char* result;
_t177 = (const char*)hmacBuf;
const char* _t178;
_t178 = bux_base64_encode(_t177, 32);
result = _t178;
Free(hmacBuf);
return result;
}
const char* Crypto_Base64Decode(const char* s) {
int _t180;
void* _t181;
int outlen;
outlen = 0;
unsigned int _t179;
_t179 = String_Len(s);
_t180 = (int)_t179;
_t181 = &outlen;
const char* _t182;
_t182 = bux_base64_decode(s, _t180, _t181);
return _t182;
}
Mutex Mutex_New(void) {
Mutex _t184;
void* _t183;
_t183 = bux_mutex_new();
_t184 = (Mutex){.handle = _t183};
return _t184;
}
void Mutex_Lock(Mutex* m) {
void* _t185;
_t185 = m->handle;
bux_mutex_lock(_t185);
}
void Mutex_Unlock(Mutex* m) {
void* _t186;
_t186 = m->handle;
bux_mutex_unlock(_t186);
}
void Mutex_Free(Mutex* m) {
void* _t187;
_t187 = m->handle;
bux_mutex_free(_t187);
}
RwLock RwLock_New(void) {
RwLock _t189;
void* _t188;
_t188 = bux_rwlock_new();
_t189 = (RwLock){.handle = _t188};
return _t189;
}
void RwLock_ReadLock(RwLock* rw) {
void* _t190;
_t190 = rw->handle;
bux_rwlock_rdlock(_t190);
}
void RwLock_WriteLock(RwLock* rw) {
void* _t191;
_t191 = rw->handle;
bux_rwlock_wrlock(_t191);
}
void RwLock_Unlock(RwLock* rw) {
void* _t192;
_t192 = rw->handle;
bux_rwlock_unlock(_t192);
}
void RwLock_Free(RwLock* rw) {
void* _t193;
_t193 = rw->handle;
bux_rwlock_free(_t193);
}
void Test_Exit(int code) {
bux_exit(code);
}
void Test_Assert(bool cond) {
int _t194;
_t194 = (int)cond;
bux_assert(_t194, "", 0, "");
}
void Test_AssertEqInt(int a, int b) {
int _t195;
_t195 = (a != b);
if (!_t195) goto endif14;
{
PrintLine("ASSERT_EQ FAILED:");
PrintInt(a);
PrintLine(" != ");
PrintInt(b);
bux_exit(1);
}
endif14:;
}
void Test_AssertTrue(bool cond) {
int _t196;
_t196 = !cond;
if (!_t196) goto endif16;
{
PrintLine("ASSERT_TRUE FAILED");
bux_exit(1);
}
endif16:;
}
void Test_AssertFalse(bool cond) {
if (!cond) goto endif18;
{
PrintLine("ASSERT_FALSE FAILED");
bux_exit(1);
}
endif18:;
}
void Test_Fail(const char* msg) {
PrintLine("FAIL:");
PrintLine(msg);
bux_exit(1);
}
Result Result_NewOk(int value) {
Result _t197;
Result r;
_t197 = (Result){.tag = Result_Ok};
r = _t197;
r.data.Ok_0 = value;
return r;
}
Result Result_NewErr(const char* msg) {
Result _t198;
Result r;
_t198 = (Result){.tag = Result_Err};
r = _t198;
r.data.Err_0 = msg;
return r;
}
bool Result_IsOk(Result r) {
int _t200;
Result_Tag _t199;
_t199 = r.tag;
_t200 = (_t199 == Result_Ok);
return _t200;
}
bool Result_IsErr(Result r) {
int _t202;
Result_Tag _t201;
_t201 = r.tag;
_t202 = (_t201 == Result_Err);
return _t202;
}
int Result_Unwrap(Result r) {
int _t204;
Result_Tag _t203;
_t203 = r.tag;
_t204 = (_t203 != Result_Ok);
if (!_t204) goto endif20;
{
PrintLine("panic: unwrap on Err");
return 0;
}
endif20:;
Result_Data _t205;
_t205 = r.data;
int _t206;
_t206 = _t205.Ok_0;
return _t206;
}
int Result_UnwrapOr(Result r, int fallback) {
int _t208;
Result_Tag _t207;
_t207 = r.tag;
_t208 = (_t207 == Result_Ok);
if (!_t208) goto endif22;
{
Result_Data _t209;
_t209 = r.data;
int _t210;
_t210 = _t209.Ok_0;
return _t210;
}
endif22:;
return fallback;
}
Option Option_NewSome(int value) {
Option _t211;
Option o;
_t211 = (Option){.tag = Option_Some};
o = _t211;
o.data.Some_0 = value;
return o;
}
Option Option_NewNone(void) {
Option _t212;
_t212 = (Option){.tag = Option_None};
return _t212;
}
bool Option_IsSome(Option o) {
int _t214;
Option_Tag _t213;
_t213 = o.tag;
_t214 = (_t213 == Option_Some);
return _t214;
}
bool Option_IsNone(Option o) {
int _t216;
Option_Tag _t215;
_t215 = o.tag;
_t216 = (_t215 == Option_None);
return _t216;
}
int Option_Unwrap(Option o) {
int _t218;
Option_Tag _t217;
_t217 = o.tag;
_t218 = (_t217 != Option_Some);
if (!_t218) goto endif24;
{
PrintLine("panic: unwrap on None");
return 0;
}
endif24:;
Option_Data _t219;
_t219 = o.data;
int _t220;
_t220 = _t219.Some_0;
return _t220;
}
int Option_UnwrapOr(Option o, int fallback) {
int _t222;
Option_Tag _t221;
_t221 = o.tag;
_t222 = (_t221 == Option_Some);
if (!_t222) goto endif26;
{
Option_Data _t223;
_t223 = o.data;
int _t224;
_t224 = _t223.Some_0;
return _t224;
}
endif26:;
return fallback;
}
JsonValue Json_Null(void) {
JsonValue _t225;
_t225 = (JsonValue){.tag = JsonTagNull, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0};
return _t225;
}
JsonValue Json_Bool(bool b) {
JsonValue _t226;
_t226 = (JsonValue){.tag = JsonTagBool, .boolVal = b, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0};
return _t226;
}
JsonValue Json_Number(double n) {
JsonValue _t227;
_t227 = (JsonValue){.tag = JsonTagNumber, .boolVal = 0, .numVal = n, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0};
return _t227;
}
JsonValue Json_String(const char* s) {
JsonValue _t228;
_t228 = (JsonValue){.tag = JsonTagString, .boolVal = 0, .numVal = 0.0, .strVal = s, .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0};
return _t228;
}
JsonValue Json_Array(void) {
JsonValue _t229;
_t229 = (JsonValue){.tag = JsonTagArray, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0};
return _t229;
}
JsonValue Json_Object(void) {
JsonValue _t230;
_t230 = (JsonValue){.tag = JsonTagObject, .boolVal = 0, .numVal = 0.0, .strVal = "", .arrData = 0, .arrLen = 0, .arrCap = 0, .objKeys = 0, .objValues = 0, .objLen = 0, .objCap = 0};
return _t230;
}
unsigned int Json_ArrayLen(JsonValue v) {
int _t232;
int _t231;
_t231 = v.tag;
_t232 = (_t231 != JsonTagArray);
if (!_t232) goto endif28;
{
return 0;
}
endif28:;
unsigned int _t233;
_t233 = v.arrLen;
return _t233;
}
JsonValue Json_ArrayGet(JsonValue v, unsigned int index) {
int _t235;
int _t238;
int _t234;
_t234 = v.tag;
_t235 = (_t234 != JsonTagArray);
if (!_t235) goto endif30;
{
JsonValue _t236;
_t236 = Json_Null();
return _t236;
}
endif30:;
unsigned int _t237;
_t237 = v.arrLen;
_t238 = (index >= _t237);
if (!_t238) goto endif32;
{
JsonValue _t239;
_t239 = Json_Null();
return _t239;
}
endif32:;
JsonValue* _t240;
_t240 = v.arrData;
JsonValue _t241;
_t241 = _t240[index];
return _t241;
}
void Json_ArrayPush(JsonValue* self, JsonValue val) {
int _t243;
int _t246;
int _t248;
int _t250;
JsonValue* _t252;
int _t253;
void* _t255;
int _t257;
JsonValue* _t259;
int _t263;
int _t242;
_t242 = self->tag;
_t243 = (_t242 != JsonTagArray);
if (!_t243) goto endif34;
{
return;
}
endif34:;
unsigned int _t244;
_t244 = self->arrLen;
unsigned int _t245;
_t245 = self->arrCap;
_t246 = (_t244 >= _t245);
if (!_t246) goto endif36;
{
unsigned int arrNewCap;
unsigned int _t247;
_t247 = self->arrCap;
arrNewCap = _t247;
_t248 = (arrNewCap == 0);
if (!_t248) goto else37;
{
self->arrCap = 4;
/* sizeof(JsonValue) */
_t250 = 4 * sizeof(JsonValue);
void* _t251;
_t251 = Alloc(_t250);
_t252 = (JsonValue*)_t251;
self->arrData = _t252;
}
goto endif38;
else37:;
{
unsigned int doubleCap;
_t253 = arrNewCap * 2;
doubleCap = _t253;
self->arrCap = doubleCap;
JsonValue* _t254;
_t254 = self->arrData;
_t255 = (void*)_t254;
/* sizeof(JsonValue) */
_t257 = doubleCap * sizeof(JsonValue);
void* _t258;
_t258 = Realloc(_t255, _t257);
_t259 = (JsonValue*)_t258;
self->arrData = _t259;
}
endif38:;
}
endif36:;
JsonValue* _t260;
_t260 = self->arrData;
unsigned int _t261;
_t261 = self->arrLen;
_t260[_t261] = val;
unsigned int _t262;
_t262 = self->arrLen;
_t263 = _t262 + 1;
self->arrLen = _t263;
}
unsigned int Json_ObjectLen(JsonValue v) {
int _t265;
int _t264;
_t264 = v.tag;
_t265 = (_t264 != JsonTagObject);
if (!_t265) goto endif40;
{
return 0;
}
endif40:;
unsigned int _t266;
_t266 = v.objLen;
return _t266;
}
JsonValue Json_ObjectGet(JsonValue v, const char* key) {
int _t268;
int _t271;
int _t277;
int _t267;
_t267 = v.tag;
_t268 = (_t267 != JsonTagObject);
if (!_t268) goto endif42;
{
JsonValue _t269;
_t269 = Json_Null();
return _t269;
}
endif42:;
unsigned int i;
i = 0;
while43:;
unsigned int _t270;
_t270 = v.objLen;
_t271 = (i < _t270);
if (!_t271) goto wend45;
{
const char** _t272;
_t272 = v.objKeys;
const char* _t273;
_t273 = _t272[i];
bool _t274;
_t274 = String_Eq(_t273, key);
if (!_t274) goto endif47;
{
JsonValue* _t275;
_t275 = v.objValues;
JsonValue _t276;
_t276 = _t275[i];
return _t276;
}
endif47:;
_t277 = i + 1;
i = _t277;
}
goto while43;
wend45:;
JsonValue _t278;
_t278 = Json_Null();
return _t278;
}
bool Json_ObjectHas(JsonValue v, const char* key) {
int _t280;
int _t282;
int _t286;
int _t279;
_t279 = v.tag;
_t280 = (_t279 != JsonTagObject);
if (!_t280) goto endif49;
{
return 0;
}
endif49:;
unsigned int i;
i = 0;
while50:;
unsigned int _t281;
_t281 = v.objLen;
_t282 = (i < _t281);
if (!_t282) goto wend52;
{
const char** _t283;
_t283 = v.objKeys;
const char* _t284;
_t284 = _t283[i];
bool _t285;
_t285 = String_Eq(_t284, key);
if (!_t285) goto endif54;
{
return 1;
}
endif54:;
_t286 = i + 1;
i = _t286;
}
goto while50;
wend52:;
return 0;
}
void Json_ObjectSet(JsonValue* self, const char* key, JsonValue val) {
int _t288;
int _t290;
int _t295;
int _t298;
int _t300;
int _t302;
const char** _t304;
int _t306;
JsonValue* _t308;
int _t309;
void* _t311;
int _t313;
const char** _t315;
void* _t317;
int _t319;
JsonValue* _t321;
int _t327;
int _t287;
_t287 = self->tag;
_t288 = (_t287 != JsonTagObject);
if (!_t288) goto endif56;
{
return;
}
endif56:;
unsigned int i;
i = 0;
while57:;
unsigned int _t289;
_t289 = self->objLen;
_t290 = (i < _t289);
if (!_t290) goto wend59;
{
const char** _t291;
_t291 = self->objKeys;
const char* _t292;
_t292 = _t291[i];
bool _t293;
_t293 = String_Eq(_t292, key);
if (!_t293) goto endif61;
{
JsonValue* _t294;
_t294 = self->objValues;
_t294[i] = val;
return;
}
endif61:;
_t295 = i + 1;
i = _t295;
}
goto while57;
wend59:;
unsigned int _t296;
_t296 = self->objLen;
unsigned int _t297;
_t297 = self->objCap;
_t298 = (_t296 >= _t297);
if (!_t298) goto endif63;
{
unsigned int objNewCap;
unsigned int _t299;
_t299 = self->objCap;
objNewCap = _t299;
_t300 = (objNewCap == 0);
if (!_t300) goto else64;
{
self->objCap = 4;
/* sizeof(const char*) */
_t302 = 4 * sizeof(const char*);
void* _t303;
_t303 = Alloc(_t302);
_t304 = (const char**)_t303;
self->objKeys = _t304;
/* sizeof(JsonValue) */
_t306 = 4 * sizeof(JsonValue);
void* _t307;
_t307 = Alloc(_t306);
_t308 = (JsonValue*)_t307;
self->objValues = _t308;
}
goto endif65;
else64:;
{
unsigned int doubleCap;
_t309 = objNewCap * 2;
doubleCap = _t309;
self->objCap = doubleCap;
const char** _t310;
_t310 = self->objKeys;
_t311 = (void*)_t310;
/* sizeof(const char*) */
_t313 = doubleCap * sizeof(const char*);
void* _t314;
_t314 = Realloc(_t311, _t313);
_t315 = (const char**)_t314;
self->objKeys = _t315;
JsonValue* _t316;
_t316 = self->objValues;
_t317 = (void*)_t316;
/* sizeof(JsonValue) */
_t319 = doubleCap * sizeof(JsonValue);
void* _t320;
_t320 = Realloc(_t317, _t319);
_t321 = (JsonValue*)_t320;
self->objValues = _t321;
}
endif65:;
}
endif63:;
const char** _t322;
_t322 = self->objKeys;
unsigned int _t323;
_t323 = self->objLen;
_t322[_t323] = key;
JsonValue* _t324;
_t324 = self->objValues;
unsigned int _t325;
_t325 = self->objLen;
_t324[_t325] = val;
unsigned int _t326;
_t326 = self->objLen;
_t327 = _t326 + 1;
self->objLen = _t327;
}
bool Json_IsNull(JsonValue v) {
int _t329;
int _t328;
_t328 = v.tag;
_t329 = (_t328 == JsonTagNull);
return _t329;
}
bool Json_AsBool(JsonValue v) {
int _t331;
int _t330;
_t330 = v.tag;
_t331 = (_t330 == JsonTagBool);
if (!_t331) goto endif67;
{
bool _t332;
_t332 = v.boolVal;
return _t332;
}
endif67:;
return 0;
}
double Json_AsNumber(JsonValue v) {
int _t334;
int _t333;
_t333 = v.tag;
_t334 = (_t333 == JsonTagNumber);
if (!_t334) goto endif69;
{
double _t335;
_t335 = v.numVal;
return _t335;
}
endif69:;
return 0.0;
}
const char* Json_AsString(JsonValue v) {
int _t337;
int _t336;
_t336 = v.tag;
_t337 = (_t336 == JsonTagString);
if (!_t337) goto endif71;
{
const char* _t338;
_t338 = v.strVal;
return _t338;
}
endif71:;
return "";
}
int JsonParser_Peek(JsonParser* p) {
int _t341;
int _t345;
unsigned int _t339;
_t339 = p->pos;
unsigned int _t340;
_t340 = p->len;
_t341 = (_t339 >= _t340);
if (!_t341) goto endif73;
{
return 0;
}
endif73:;
const char* _t342;
_t342 = p->src;
unsigned int _t343;
_t343 = p->pos;
int _t344;
_t344 = _t342[_t343];
_t345 = (int)_t344;
return _t345;
}
void JsonParser_Advance(JsonParser* p) {
int _t348;
int _t350;
unsigned int _t346;
_t346 = p->pos;
unsigned int _t347;
_t347 = p->len;
_t348 = (_t346 < _t347);
if (!_t348) goto endif75;
{
unsigned int _t349;
_t349 = p->pos;
_t350 = _t349 + 1;
p->pos = _t350;
}
endif75:;
}
void JsonParser_SkipWhitespace(JsonParser* p) {
int _t352;
int _t353;
int _t355;
int _t357;
while76:;
if (!1) goto wend78;
{
int c;
int _t351;
_t351 = JsonParser_Peek(p);
c = _t351;
bool __or_tmp_0;
bool __or_tmp_1;
bool __or_tmp_2;
_t352 = (c == 32);
if (!_t352) goto else79;
*(bool*)&__or_tmp_2 = 1;
goto endif80;
else79:;
_t353 = (c == 9);
*(bool*)&__or_tmp_2 = _t353;
endif80:;
bool _t354;
_t354 = *(bool*)&__or_tmp_2;
if (!_t354) goto else81;
*(bool*)&__or_tmp_1 = 1;
goto endif82;
else81:;
_t355 = (c == 10);
*(bool*)&__or_tmp_1 = _t355;
endif82:;
bool _t356;
_t356 = *(bool*)&__or_tmp_1;
if (!_t356) goto else83;
*(bool*)&__or_tmp_0 = 1;
goto endif84;
else83:;
_t357 = (c == 13);
*(bool*)&__or_tmp_0 = _t357;
endif84:;
bool _t358;
_t358 = *(bool*)&__or_tmp_0;
if (!_t358) goto else85;
{
JsonParser_Advance(p);
}
goto endif86;
else85:;
{
return;
}
endif86:;
}
goto while76;
wend78:;
}
bool JsonParser_Match(JsonParser* p, const char* expected) {
int _t361;
int _t363;
int _t364;
int _t367;
int _t370;
int _t371;
int _t373;
unsigned int elen;
unsigned int _t359;
_t359 = String_Len(expected);
elen = _t359;
unsigned int _t360;
_t360 = p->pos;
_t361 = _t360 + elen;
unsigned int _t362;
_t362 = p->len;
_t363 = (_t361 > _t362);
if (!_t363) goto endif88;
{
return 0;
}
endif88:;
unsigned int i;
i = 0;
while89:;
_t364 = (i < elen);
if (!_t364) goto wend91;
{
const char* _t365;
_t365 = p->src;
unsigned int _t366;
_t366 = p->pos;
_t367 = _t366 + i;
int _t368;
_t368 = _t365[_t367];
int _t369;
_t369 = expected[i];
_t370 = (_t368 != _t369);
if (!_t370) goto endif93;
{
return 0;
}
endif93:;
_t371 = i + 1;
i = _t371;
}
goto while89;
wend91:;
unsigned int _t372;
_t372 = p->pos;
_t373 = _t372 + elen;
p->pos = _t373;
return 1;
}
const char* JsonParser_ParseString(JsonParser* p) {
int _t375;
int _t378;
int _t379;
int _t381;
int _t383;
void* _t384;
int _t385;
void* _t386;
char _t387;
int _t388;
void* _t389;
char _t390;
int _t391;
void* _t392;
char _t393;
int _t394;
void* _t395;
char _t396;
int _t397;
void* _t398;
char _t399;
int _t400;
void* _t401;
char _t402;
int _t403;
void* _t404;
char _t405;
void* _t406;
char _t407;
void* _t408;
char _t409;
void* _t410;
char _t411;
int _t413;
void* _t414;
void* _t415;
void* _t417;
int _t374;
_t374 = JsonParser_Peek(p);
_t375 = (_t374 != 34);
if (!_t375) goto endif95;
{
p->error = "Expected string";
return "";
}
endif95:;
JsonParser_Advance(p);
StringBuilder sb;
StringBuilder _t376;
_t376 = StringBuilder_New();
sb = _t376;
while96:;
if (!1) goto wend98;
{
int c;
int _t377;
_t377 = JsonParser_Peek(p);
c = _t377;
bool __or_tmp_3;
_t378 = (c == 0);
if (!_t378) goto else99;
*(bool*)&__or_tmp_3 = 1;
goto endif100;
else99:;
_t379 = (c == 34);
*(bool*)&__or_tmp_3 = _t379;
endif100:;
bool _t380;
_t380 = *(bool*)&__or_tmp_3;
if (!_t380) goto endif102;
{
goto wend98;
}
endif102:;
_t381 = (c == 92);
if (!_t381) goto else103;
{
JsonParser_Advance(p);
int esc;
int _t382;
_t382 = JsonParser_Peek(p);
esc = _t382;
_t383 = (esc == 0);
if (!_t383) goto endif106;
{
p->error = "Unterminated string escape";
_t384 = &sb;
StringBuilder_Free(_t384);
return "";
}
endif106:;
_t385 = (esc == 110);
if (!_t385) goto else107;
{
_t386 = &sb;
_t387 = (char)10;
StringBuilder_AppendChar(_t386, _t387);
}
goto endif108;
else107:;
_t388 = (esc == 116);
if (!_t388) goto else109;
{
_t389 = &sb;
_t390 = (char)9;
StringBuilder_AppendChar(_t389, _t390);
}
goto endif110;
else109:;
_t391 = (esc == 114);
if (!_t391) goto else111;
{
_t392 = &sb;
_t393 = (char)13;
StringBuilder_AppendChar(_t392, _t393);
}
goto endif112;
else111:;
_t394 = (esc == 98);
if (!_t394) goto else113;
{
_t395 = &sb;
_t396 = (char)8;
StringBuilder_AppendChar(_t395, _t396);
}
goto endif114;
else113:;
_t397 = (esc == 102);
if (!_t397) goto else115;
{
_t398 = &sb;
_t399 = (char)12;
StringBuilder_AppendChar(_t398, _t399);
}
goto endif116;
else115:;
_t400 = (esc == 34);
if (!_t400) goto else117;
{
_t401 = &sb;
_t402 = (char)34;
StringBuilder_AppendChar(_t401, _t402);
}
goto endif118;
else117:;
_t403 = (esc == 92);
if (!_t403) goto else119;
{
_t404 = &sb;
_t405 = (char)92;
StringBuilder_AppendChar(_t404, _t405);
}
goto endif120;
else119:;
{
_t406 = &sb;
_t407 = (char)92;
StringBuilder_AppendChar(_t406, _t407);
_t408 = &sb;
_t409 = (char)esc;
StringBuilder_AppendChar(_t408, _t409);
}
endif120:;
endif118:;
endif116:;
endif114:;
endif112:;
endif110:;
endif108:;
JsonParser_Advance(p);
}
goto endif104;
else103:;
{
_t410 = &sb;
_t411 = (char)c;
StringBuilder_AppendChar(_t410, _t411);
JsonParser_Advance(p);
}
endif104:;
}
goto while96;
wend98:;
int _t412;
_t412 = JsonParser_Peek(p);
_t413 = (_t412 != 34);
if (!_t413) goto endif122;
{
p->error = "Unterminated string";
_t414 = &sb;
StringBuilder_Free(_t414);
return "";
}
endif122:;
JsonParser_Advance(p);
const char* result;
_t415 = &sb;
const char* _t416;
_t416 = StringBuilder_Build(_t415);
result = _t416;
_t417 = &sb;
StringBuilder_Free(_t417);
return result;
}
JsonValue JsonParser_ParseNumber(JsonParser* p) {
int _t420;
int _t422;
int _t423;
int _t426;
int _t428;
int _t429;
int _t433;
unsigned int start;
unsigned int _t418;
_t418 = p->pos;
start = _t418;
int c0;
int _t419;
_t419 = JsonParser_Peek(p);
c0 = _t419;
_t420 = (c0 == 45);
if (!_t420) goto endif124;
{
JsonParser_Advance(p);
}
endif124:;
while125:;
if (!1) goto wend127;
{
int c;
int _t421;
_t421 = JsonParser_Peek(p);
c = _t421;
bool __and_tmp_4;
_t422 = (c >= 48);
if (!_t422) goto else128;
_t423 = (c <= 57);
*(bool*)&__and_tmp_4 = _t423;
goto endif129;
else128:;
*(bool*)&__and_tmp_4 = 0;
endif129:;
bool _t424;
_t424 = *(bool*)&__and_tmp_4;
if (!_t424) goto else130;
{
JsonParser_Advance(p);
}
goto endif131;
else130:;
{
goto wend127;
}
endif131:;
}
goto while125;
wend127:;
int _t425;
_t425 = JsonParser_Peek(p);
_t426 = (_t425 == 46);
if (!_t426) goto endif133;
{
JsonParser_Advance(p);
while134:;
if (!1) goto wend136;
{
int c;
int _t427;
_t427 = JsonParser_Peek(p);
c = _t427;
bool __and_tmp_5;
_t428 = (c >= 48);
if (!_t428) goto else137;
_t429 = (c <= 57);
*(bool*)&__and_tmp_5 = _t429;
goto endif138;
else137:;
*(bool*)&__and_tmp_5 = 0;
endif138:;
bool _t430;
_t430 = *(bool*)&__and_tmp_5;
if (!_t430) goto else139;
{
JsonParser_Advance(p);
}
goto endif140;
else139:;
{
goto wend136;
}
endif140:;
}
goto while134;
wend136:;
}
endif133:;
const char* numStr;
const char* _t431;
_t431 = p->src;
unsigned int _t432;
_t432 = p->pos;
_t433 = _t432 - start;
const char* _t434;
_t434 = String_Slice(_t431, start, _t433);
numStr = _t434;
double n;
double _t435;
_t435 = String_ToFloat(numStr);
n = _t435;
JsonValue _t436;
_t436 = Json_Number(n);
return _t436;
}
JsonValue JsonParser_ParseArray(JsonParser* p) {
int _t439;
int _t442;
void* _t444;
int _t446;
int _t447;
JsonParser_Advance(p);
JsonValue arr;
JsonValue _t437;
_t437 = Json_Array();
arr = _t437;
JsonParser_SkipWhitespace(p);
int _t438;
_t438 = JsonParser_Peek(p);
_t439 = (_t438 == 93);
if (!_t439) goto endif142;
{
JsonParser_Advance(p);
return arr;
}
endif142:;
while143:;
if (!1) goto wend145;
{
JsonParser_SkipWhitespace(p);
JsonValue val;
JsonValue _t440;
_t440 = JsonParser_ParseValue(p);
val = _t440;
const char* _t441;
_t441 = p->error;
_t442 = (_t441 != "");
if (!_t442) goto endif147;
{
JsonValue _t443;
_t443 = Json_Null();
return _t443;
}
endif147:;
_t444 = &arr;
Json_ArrayPush(_t444, val);
JsonParser_SkipWhitespace(p);
int c;
int _t445;
_t445 = JsonParser_Peek(p);
c = _t445;
_t446 = (c == 93);
if (!_t446) goto endif149;
{
JsonParser_Advance(p);
return arr;
}
endif149:;
_t447 = (c == 44);
if (!_t447) goto else150;
{
JsonParser_Advance(p);
}
goto endif151;
else150:;
{
p->error = "Expected ',' or ']' in array";
JsonValue _t448;
_t448 = Json_Null();
return _t448;
}
endif151:;
}
goto while143;
wend145:;
}
JsonValue JsonParser_ParseObject(JsonParser* p) {
int _t451;
int _t454;
int _t457;
int _t461;
void* _t463;
int _t465;
int _t466;
JsonParser_Advance(p);
JsonValue obj;
JsonValue _t449;
_t449 = Json_Object();
obj = _t449;
JsonParser_SkipWhitespace(p);
int _t450;
_t450 = JsonParser_Peek(p);
_t451 = (_t450 == 125);
if (!_t451) goto endif153;
{
JsonParser_Advance(p);
return obj;
}
endif153:;
while154:;
if (!1) goto wend156;
{
JsonParser_SkipWhitespace(p);
const char* key;
const char* _t452;
_t452 = JsonParser_ParseString(p);
key = _t452;
const char* _t453;
_t453 = p->error;
_t454 = (_t453 != "");
if (!_t454) goto endif158;
{
JsonValue _t455;
_t455 = Json_Null();
return _t455;
}
endif158:;
JsonParser_SkipWhitespace(p);
int _t456;
_t456 = JsonParser_Peek(p);
_t457 = (_t456 != 58);
if (!_t457) goto endif160;
{
p->error = "Expected ':' after object key";
JsonValue _t458;
_t458 = Json_Null();
return _t458;
}
endif160:;
JsonParser_Advance(p);
JsonParser_SkipWhitespace(p);
JsonValue val;
JsonValue _t459;
_t459 = JsonParser_ParseValue(p);
val = _t459;
const char* _t460;
_t460 = p->error;
_t461 = (_t460 != "");
if (!_t461) goto endif162;
{
JsonValue _t462;
_t462 = Json_Null();
return _t462;
}
endif162:;
_t463 = &obj;
Json_ObjectSet(_t463, key, val);
JsonParser_SkipWhitespace(p);
int c;
int _t464;
_t464 = JsonParser_Peek(p);
c = _t464;
_t465 = (c == 125);
if (!_t465) goto endif164;
{
JsonParser_Advance(p);
return obj;
}
endif164:;
_t466 = (c == 44);
if (!_t466) goto else165;
{
JsonParser_Advance(p);
}
goto endif166;
else165:;
{
p->error = "Expected ',' or '}' in object";
JsonValue _t467;
_t467 = Json_Null();
return _t467;
}
endif166:;
}
goto while154;
wend156:;
}
JsonValue JsonParser_ParseValue(JsonParser* p) {
int _t469;
int _t471;
int _t474;
int _t476;
int _t478;
int _t482;
int _t486;
int _t490;
int _t491;
int _t493;
JsonParser_SkipWhitespace(p);
int c;
int _t468;
_t468 = JsonParser_Peek(p);
c = _t468;
_t469 = (c == 0);
if (!_t469) goto endif168;
{
p->error = "Unexpected end of input";
JsonValue _t470;
_t470 = Json_Null();
return _t470;
}
endif168:;
_t471 = (c == 34);
if (!_t471) goto endif170;
{
const char* _t472;
_t472 = JsonParser_ParseString(p);
JsonValue _t473;
_t473 = Json_String(_t472);
return _t473;
}
endif170:;
_t474 = (c == 123);
if (!_t474) goto endif172;
{
JsonValue _t475;
_t475 = JsonParser_ParseObject(p);
return _t475;
}
endif172:;
_t476 = (c == 91);
if (!_t476) goto endif174;
{
JsonValue _t477;
_t477 = JsonParser_ParseArray(p);
return _t477;
}
endif174:;
_t478 = (c == 116);
if (!_t478) goto endif176;
{
bool _t479;
_t479 = JsonParser_Match(p, "true");
if (!_t479) goto endif178;
{
JsonValue _t480;
_t480 = Json_Bool(1);
return _t480;
}
endif178:;
p->error = "Expected 'true'";
JsonValue _t481;
_t481 = Json_Null();
return _t481;
}
endif176:;
_t482 = (c == 102);
if (!_t482) goto endif180;
{
bool _t483;
_t483 = JsonParser_Match(p, "false");
if (!_t483) goto endif182;
{
JsonValue _t484;
_t484 = Json_Bool(0);
return _t484;
}
endif182:;
p->error = "Expected 'false'";
JsonValue _t485;
_t485 = Json_Null();
return _t485;
}
endif180:;
_t486 = (c == 110);
if (!_t486) goto endif184;
{
bool _t487;
_t487 = JsonParser_Match(p, "null");
if (!_t487) goto endif186;
{
JsonValue _t488;
_t488 = Json_Null();
return _t488;
}
endif186:;
p->error = "Expected 'null'";
JsonValue _t489;
_t489 = Json_Null();
return _t489;
}
endif184:;
bool __or_tmp_6;
bool __and_tmp_7;
_t490 = (c >= 48);
if (!_t490) goto else187;
_t491 = (c <= 57);
*(bool*)&__and_tmp_7 = _t491;
goto endif188;
else187:;
*(bool*)&__and_tmp_7 = 0;
endif188:;
bool _t492;
_t492 = *(bool*)&__and_tmp_7;
if (!_t492) goto else189;
*(bool*)&__or_tmp_6 = 1;
goto endif190;
else189:;
_t493 = (c == 45);
*(bool*)&__or_tmp_6 = _t493;
endif190:;
bool _t494;
_t494 = *(bool*)&__or_tmp_6;
if (!_t494) goto endif192;
{
JsonValue _t495;
_t495 = JsonParser_ParseNumber(p);
return _t495;
}
endif192:;
p->error = "Unexpected character";
JsonValue _t496;
_t496 = Json_Null();
return _t496;
}
JsonValue Json_Parse(const char* s) {
JsonParser _t498;
void* _t499;
void* _t501;
int _t503;
int _t506;
JsonParser p;
unsigned int _t497;
_t497 = String_Len(s);
_t498 = (JsonParser){.src = s, .pos = 0, .len = _t497, .error = ""};
p = _t498;
JsonValue result;
_t499 = &p;
JsonValue _t500;
_t500 = JsonParser_ParseValue(_t499);
result = _t500;
_t501 = &p;
JsonParser_SkipWhitespace(_t501);
bool __and_tmp_8;
const char* _t502;
_t502 = p.error;
_t503 = (_t502 == "");
if (!_t503) goto else193;
unsigned int _t504;
_t504 = p.pos;
unsigned int _t505;
_t505 = p.len;
_t506 = (_t504 != _t505);
*(bool*)&__and_tmp_8 = _t506;
goto endif194;
else193:;
*(bool*)&__and_tmp_8 = 0;
endif194:;
bool _t507;
_t507 = *(bool*)&__and_tmp_8;
if (!_t507) goto endif196;
{
p.error = "Trailing data after JSON value";
JsonValue _t508;
_t508 = Json_Null();
return _t508;
}
endif196:;
return result;
}
void Json_StringifyImpl(StringBuilder* sb, JsonValue v) {
int _t510;
int _t512;
int _t515;
int _t518;
char _t519;
char _t521;
int _t523;
char _t524;
int _t526;
int _t527;
char _t528;
int _t531;
char _t532;
int _t534;
char _t535;
int _t537;
int _t538;
char _t539;
char _t540;
char _t543;
char _t544;
int _t547;
char _t548;
int _t509;
_t509 = v.tag;
_t510 = (_t509 == JsonTagNull);
if (!_t510) goto endif198;
{
StringBuilder_Append(sb, "null");
return;
}
endif198:;
int _t511;
_t511 = v.tag;
_t512 = (_t511 == JsonTagBool);
if (!_t512) goto endif200;
{
bool _t513;
_t513 = v.boolVal;
if (!_t513) goto else201;
{
StringBuilder_Append(sb, "true");
}
goto endif202;
else201:;
{
StringBuilder_Append(sb, "false");
}
endif202:;
return;
}
endif200:;
int _t514;
_t514 = v.tag;
_t515 = (_t514 == JsonTagNumber);
if (!_t515) goto endif204;
{
double _t516;
_t516 = v.numVal;
StringBuilder_AppendFloat(sb, _t516);
return;
}
endif204:;
int _t517;
_t517 = v.tag;
_t518 = (_t517 == JsonTagString);
if (!_t518) goto endif206;
{
_t519 = (char)34;
StringBuilder_AppendChar(sb, _t519);
const char* _t520;
_t520 = v.strVal;
StringBuilder_Append(sb, _t520);
_t521 = (char)34;
StringBuilder_AppendChar(sb, _t521);
return;
}
endif206:;
int _t522;
_t522 = v.tag;
_t523 = (_t522 == JsonTagArray);
if (!_t523) goto endif208;
{
_t524 = (char)91;
StringBuilder_AppendChar(sb, _t524);
unsigned int i;
i = 0;
while209:;
unsigned int _t525;
_t525 = v.arrLen;
_t526 = (i < _t525);
if (!_t526) goto wend211;
{
_t527 = (i > 0);
if (!_t527) goto endif213;
{
_t528 = (char)44;
StringBuilder_AppendChar(sb, _t528);
}
endif213:;
JsonValue* _t529;
_t529 = v.arrData;
JsonValue _t530;
_t530 = _t529[i];
Json_StringifyImpl(sb, _t530);
_t531 = i + 1;
i = _t531;
}
goto while209;
wend211:;
_t532 = (char)93;
StringBuilder_AppendChar(sb, _t532);
return;
}
endif208:;
int _t533;
_t533 = v.tag;
_t534 = (_t533 == JsonTagObject);
if (!_t534) goto endif215;
{
_t535 = (char)123;
StringBuilder_AppendChar(sb, _t535);
unsigned int i;
i = 0;
while216:;
unsigned int _t536;
_t536 = v.objLen;
_t537 = (i < _t536);
if (!_t537) goto wend218;
{
_t538 = (i > 0);
if (!_t538) goto endif220;
{
_t539 = (char)44;
StringBuilder_AppendChar(sb, _t539);
}
endif220:;
_t540 = (char)34;
StringBuilder_AppendChar(sb, _t540);
const char** _t541;
_t541 = v.objKeys;
const char* _t542;
_t542 = _t541[i];
StringBuilder_Append(sb, _t542);
_t543 = (char)34;
StringBuilder_AppendChar(sb, _t543);
_t544 = (char)58;
StringBuilder_AppendChar(sb, _t544);
JsonValue* _t545;
_t545 = v.objValues;
JsonValue _t546;
_t546 = _t545[i];
Json_StringifyImpl(sb, _t546);
_t547 = i + 1;
i = _t547;
}
goto while216;
wend218:;
_t548 = (char)125;
StringBuilder_AppendChar(sb, _t548);
return;
}
endif215:;
}
const char* Json_Stringify(JsonValue v) {
void* _t550;
void* _t551;
StringBuilder sb;
StringBuilder _t549;
_t549 = StringBuilder_New();
sb = _t549;
_t550 = &sb;
Json_StringifyImpl(_t550, v);
_t551 = &sb;
const char* _t552;
_t552 = StringBuilder_Build(_t551);
return _t552;
}
int Fibonacci(int n) {
int _t553;
int _t554;
int _t556;
int _t558;
_t553 = (n <= 1);
if (!_t553) goto endif222;
{
return n;
}
endif222:;
_t554 = n - 1;
int _t555;
_t555 = Fibonacci(_t554);
_t556 = n - 2;
int _t557;
_t557 = Fibonacci(_t556);
_t558 = _t555 + _t557;
return _t558;
}
int Main(void) {
int _t559;
int _t563;
PrintLine("Fibonacci sequence:");
int i;
i = 0;
while223:;
_t559 = (i < 10);
if (!_t559) goto wend225;
{
int fib;
int _t560;
_t560 = Fibonacci(i);
fib = _t560;
const char* _t561;
_t561 = String_FromInt(fib);
const char* _t562;
_t562 = Fmt_Fmt1("{0}", _t561);
PrintLine(_t562);
_t563 = i + 1;
i = _t563;
}
goto while223;
wend225:;
return 0;
}
/* C entry point wrapper */
extern int g_argc;
extern char** g_argv;
int main(int argc, char** argv) {
g_argc = argc;
g_argv = argv;
return Main();
}