decompiled_code:
_BOOL8 __fastcall zlog_level_list_set_default(__int64 a1)
{
int v1; // edx
_BOOL8 result; // rax
int v3; // edx
int v4; // edx
int v5; // edx
int v6; // edx
int v7; // edx
int v8; // edx
int v9; // edx

v1 = zlog_level_list_set(a1, "* = 0, LOG_INFO");
result = 1LL;
if ( !v1 )
{
v3 = zlog_level_list_set(a1, "DEBUG = 20, LOG_DEBUG");
result = 1LL;
if ( !v3 )
{
v4 = zlog_level_list_set(a1, "INFO = 40, LOG_INFO");
result = 1LL;
if ( !v4 )
{
v5 = zlog_level_list_set(a1, "NOTICE = 60, LOG_NOTICE");
result = 1LL;
if ( !v5 )
{
v6 = zlog_level_list_set(a1, "WARN = 80, LOG_WARNING");
result = 1LL;
if ( !v6 )
{
v7 = zlog_level_list_set(a1, "ERROR = 100, LOG_ERR");
result = 1LL;
if ( !v7 )
{
v8 = zlog_level_list_set(a1, "FATAL = 120, LOG_ALERT");
result = 1LL;
if ( !v8 )
{
v9 = zlog_level_list_set(a1, "UNKNOWN = 254, LOG_ERR");
result = 1LL;
if ( !v9 )
result = (unsigned int)zlog_level_list_set(a1, "! = 255, LOG_INFO") != 0;
}
}
}
}
}
}
}
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(__int64 a1)
{
int v1; // edx
_BOOL8 result; // rax
int v3; // edx
int v4; // edx
int v5; // edx
int v6; // edx
int v7; // edx
int v8; // edx
int v9; // edx

v1 = func2(a1, "* = 0, LOG_INFO");
result = 1LL;
if ( !v1 )
{
v3 = func2(a1, "DEBUG = 20, LOG_DEBUG");
result = 1LL;
if ( !v3 )
{
v4 = func2(a1, "INFO = 40, LOG_INFO");
result = 1LL;
if ( !v4 )
{
v5 = func2(a1, "NOTICE = 60, LOG_NOTICE");
result = 1LL;
if ( !v5 )
{
v6 = func2(a1, "WARN = 80, LOG_WARNING");
result = 1LL;
if ( !v6 )
{
v7 = func2(a1, "ERROR = 100, LOG_ERR");
result = 1LL;
if ( !v7 )
{
v8 = func2(a1, "FATAL = 120, LOG_ALERT");
result = 1LL;
if ( !v8 )
{
v9 = func2(a1, "UNKNOWN = 254, LOG_ERR");
result = 1LL;
if ( !v9 )
result = (unsigned int)func2(a1, "! = 255, LOG_INFO") != 0;
}
}
}
}
}
}
}
return result;
}

original_code:
static int zlog_level_list_set_default(zc_arraylist_t *levels)
{
 return zlog_level_list_set(levels, "* = 0, LOG_INFO")
 || zlog_level_list_set(levels, "DEBUG = 20, LOG_DEBUG")
 || zlog_level_list_set(levels, "INFO = 40, LOG_INFO")
 || zlog_level_list_set(levels, "NOTICE = 60, LOG_NOTICE")
 || zlog_level_list_set(levels, "WARN = 80, LOG_WARNING")
 || zlog_level_list_set(levels, "ERROR = 100, LOG_ERR")
 || zlog_level_list_set(levels, "FATAL = 120, LOG_ALERT")
 || zlog_level_list_set(levels, "UNKNOWN = 254, LOG_ERR")
 || zlog_level_list_set(levels, "! = 255, LOG_INFO");
}

canonical_original_code:
static int zlog_level_list_set_default(struct zc_arraylist_t *levels)
{
 return zlog_level_list_set(levels, "* = 0, LOG_INFO")
 || zlog_level_list_set(levels, "DEBUG = 20, LOG_DEBUG")
 || zlog_level_list_set(levels, "INFO = 40, LOG_INFO")
 || zlog_level_list_set(levels, "NOTICE = 60, LOG_NOTICE")
 || zlog_level_list_set(levels, "WARN = 80, LOG_WARNING")
 || zlog_level_list_set(levels, "ERROR = 100, LOG_ERR")
 || zlog_level_list_set(levels, "FATAL = 120, LOG_ALERT")
 || zlog_level_list_set(levels, "UNKNOWN = 254, LOG_ERR")
 || zlog_level_list_set(levels, "! = 255, LOG_INFO");
}


decompiled_code:
__int64 zlog_level_list_new()
{
__int64 v0; // rax
__int64 v1; // rbx

v0 = zc_arraylist_new(&zlog_level_del);
v1 = v0;
if ( v0 )
{
if ( zlog_level_list_set_default(v0) )
{
zc_profile_inner(2LL, "level_list.c", 78LL, "zlog_level_set_default fail");
zc_arraylist_del(v1);
v1 = 0LL;
}
}
else
{
zc_profile_inner(2LL, "level_list.c", 73LL, "zc_arraylist_new fail");
}
return v1;
}

canonical_decompiled_code:
__int64 func4()
{
__int64 v0; // rax
__int64 v1; // rbx

v0 = zc_arraylist_new(&zlog_level_del);
v1 = v0;
if ( v0 )
{
if ( func3(v0) )
{
zc_profile_inner(2LL, "level_list.c", 78LL, "zlog_level_set_default fail");
zc_arraylist_del(v1);
v1 = 0LL;
}
}
else
{
zc_profile_inner(2LL, "level_list.c", 73LL, "zc_arraylist_new fail");
}
return v1;
}

original_code:
zc_arraylist_t *zlog_level_list_new(void)
{
 zc_arraylist_t *levels;
 levels = zc_arraylist_new((zc_arraylist_del_fn)zlog_level_del);
 if (!levels) {
  zc_profile_inner(ZC_ERROR, "level_list.c", 73, "zc_arraylist_new fail");
  return ((void *)0);
 }
 if (zlog_level_list_set_default(levels)) {
  zc_profile_inner(ZC_ERROR, "level_list.c", 78, "zlog_level_set_default fail");
  goto err;
 }
 return levels;
err:
 zc_arraylist_del(levels);
 return ((void *)0);
}

canonical_original_code:
struct zc_arraylist_t *zlog_level_list_new()
{
 struct zc_arraylist_t *levels;
 levels = zc_arraylist_new((void (*)(void *data))zlog_level_del);
 if (!levels) {
  zc_profile_inner(ZC_ERROR, "level_list.c", 73, "zc_arraylist_new fail");
  return ((void *)0);
 }
 if (zlog_level_list_set_default(levels)) {
  zc_profile_inner(ZC_ERROR, "level_list.c", 78, "zlog_level_set_default fail");
  goto err;
 }
 return levels;
err:
 zc_arraylist_del(levels);
 return ((void *)0);
}

variable_types: struct zc_arraylist_t { void **array; int len; int size; void (*del)(void *data); } *


decompiled_code:
__int64 __fastcall zlog_level_list_get(int *a1, int a2)
{
__int64 result; // rax

if ( a1[2] <= a2 || (result = *(_QWORD *)(*(_QWORD *)a1 + 8LL * a2)) == 0 )
{
zc_profile_inner(
2LL,
"level_list.c",
129LL,
"l[%d] not in (0,254), or has no level defined,see configure file define, set to UNKOWN",
(unsigned int)a2);
result = 0LL;
if ( a1[2] > 254 )
result = *(_QWORD *)(*(_QWORD *)a1 + 2032LL);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(int *a1, int a2)
{
__int64 result; // rax

if ( a1[2] <= a2 || (result = *(_QWORD *)(*(_QWORD *)a1 + 8LL * a2)) == 0 )
{
zc_profile_inner(
2LL,
"level_list.c",
129LL,
"l[%d] not in (0,254), or has no level defined,see configure file define, set to UNKOWN",
(unsigned int)a2);
result = 0LL;
if ( a1[2] > 254 )
result = *(_QWORD *)(*(_QWORD *)a1 + 2032LL);
}
return result;
}

original_code:
zlog_level_t *zlog_level_list_get(zc_arraylist_t *levels, int l)
{
 zlog_level_t *a_level;
 a_level = ((l >= levels->len) ? ((void *)0) : levels->array[l]);
 if (a_level) {
  return a_level;
 } else {
  zc_profile_inner(ZC_ERROR, "level_list.c", 129, "l[%d] not in (0,254), or has no level defined," "see configure file define, set to UNKOWN", l);
  return ((254 >= levels->len) ? ((void *)0) : levels->array[254]);
 }
}

canonical_original_code:
struct zlog_level_s *zlog_level_list_get(struct zc_arraylist_t *levels, int l)
{
 struct zlog_level_s *a_level;
 a_level = ((l >= levels->len) ? ((void *)0) : levels->array[l]);
 if (a_level) {
  return a_level;
 } else {
  zc_profile_inner(ZC_ERROR, "level_list.c", 129, "l[%d] not in (0,254), or has no level defined," "see configure file define, set to UNKOWN", l);
  return ((254 >= levels->len) ? ((void *)0) : levels->array[254]);
 }
}

variable_types: l int

variable_types: struct zlog_level_s { int int_level; char str_uppercase[-1]; char str_lowercase[-1]; unsigned long str_len; int syslog_level; } *

user_defined_types: struct zc_arraylist_t { void **array; int len; int size; void (*del)(void *data); }


decompiled_code:
__int64 __fastcall zlog_level_list_atoi(__int64 *a1, const char *a2)
{
__int64 v3; // r14
int v4; // ebp
__int64 v5; // rbx
unsigned int v6; // er13
__int64 v7; // rsi

if ( a2 && *a2 )
{
v3 = *a1;
v4 = *((_DWORD *)a1 + 2);
if ( v4 <= 0 )
{
LABEL_10:
zc_profile_inner(2LL, "level_list.c", 153LL, "str[%s] can't found in level list", a2);
v6 = -1;
}
else
{
v5 = 0LL;
while ( 1 )
{
v6 = v5;
v7 = *(_QWORD *)(v3 + 8 * v5);
if ( v7 )
{
if ( !strcasecmp(a2, (const char *)(v7 + 4)) )
break;
}
if ( ++v5 == v4 )
goto LABEL_10;
}
}
}
else
{
zc_profile_inner(2LL, "level_list.c", 143LL, "str is [%s], can't find level", a2);
v6 = -1;
}
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 *a1, const char *a2)
{
__int64 v3; // r14
int v4; // ebp
__int64 v5; // rbx
unsigned int v6; // er13
__int64 v7; // rsi

if ( a2 && *a2 )
{
v3 = *a1;
v4 = *((_DWORD *)a1 + 2);
if ( v4 <= 0 )
{
LABEL_10:
zc_profile_inner(2LL, "level_list.c", 153LL, "str[%s] can't found in level list", a2);
v6 = -1;
}
else
{
v5 = 0LL;
while ( 1 )
{
v6 = v5;
v7 = *(_QWORD *)(v3 + 8 * v5);
if ( v7 )
{
if ( !strcasecmp(a2, (const char *)(v7 + 4)) )
break;
}
if ( ++v5 == v4 )
goto LABEL_10;
}
}
}
else
{
zc_profile_inner(2LL, "level_list.c", 143LL, "str is [%s], can't find level", a2);
v6 = -1;
}
return v6;
}

original_code:
int zlog_level_list_atoi(zc_arraylist_t *levels, char *str)
{
 int i;
 zlog_level_t *a_level;
 if (str == ((void *)0) || *str == '\0') {
  zc_profile_inner(ZC_ERROR, "level_list.c", 143, "str is [%s], can't find level", str);
  return -1;
 }
 for(i = 0, a_level = levels->array[0]; (i < levels->len) && (a_level = levels->array[i], 1) ; i++) {
  if (a_level && ( strcasecmp(str,a_level->str_uppercase) == 0 )) {
   return i;
  }
 }
 zc_profile_inner(ZC_ERROR, "level_list.c", 153, "str[%s] can't found in level list", str);
 return -1;
}

canonical_original_code:
int zlog_level_list_atoi(struct zc_arraylist_t *levels, char *str)
{
 int i;
 struct zlog_level_s *a_level;
 if (str == ((void *)0) || *str == '\0') {
  zc_profile_inner(ZC_ERROR, "level_list.c", 143, "str is [%s], can't find level", str);
  return -1;
 }
 for(i = 0, a_level = levels->array[0]; (i < levels->len) && (a_level = levels->array[i], 1) ; i++) {
  if (a_level && ( strcasecmp(str,a_level->str_uppercase) == 0 )) {
   return i;
  }
 }
 zc_profile_inner(ZC_ERROR, "level_list.c", 153, "str[%s] can't found in level list", str);
 return -1;
}

variable_types:
str
char *

variable_types: i int

return_type: int

user_defined_types: struct zlog_level_s { int int_level; char str_uppercase[-1]; char str_lowercase[-1]; unsigned long str_len; int syslog_level; }


decompiled_code:
int __fastcall syslog_level_atoi(char *s1)
{
int result; // eax
int v2; // edx
int v3; // edx
int v4; // edx
int v5; // edx
int v6; // edx
int v7; // edx
int v8; // edx

if ( s1 )
{
result = strcasecmp(s1, "LOG_EMERG");
if ( result )
{
v2 = strcasecmp(s1, "LOG_ALERT");
result = 1;
if ( v2 )
{
v3 = strcasecmp(s1, "LOG_CRIT");
result = 2;
if ( v3 )
{
v4 = strcasecmp(s1, "LOG_ERR");
result = 3;
if ( v4 )
{
v5 = strcasecmp(s1, "LOG_WARNING");
result = 4;
if ( v5 )
{
v6 = strcasecmp(s1, "LOG_NOTICE");
result = 5;
if ( v6 )
{
v7 = strcasecmp(s1, "LOG_INFO");
result = 6;
if ( v7 )
{
v8 = strcasecmp(s1, "LOG_DEBUG");
result = 7;
if ( v8 )
{
zc_profile_inner(2LL, "level.c", 75LL, "wrong syslog level[%s]", s1);
result = -187;
}
}
}
}
}
}
}
}
}
else
{
zc_profile_inner(2LL, "level.c", 56LL, "str is null or 0");
result = -187;
}
return result;
}

canonical_decompiled_code:
int __fastcall func0(char *s1)
{
int result; // eax
int v2; // edx
int v3; // edx
int v4; // edx
int v5; // edx
int v6; // edx
int v7; // edx
int v8; // edx

if ( s1 )
{
result = strcasecmp(s1, "LOG_EMERG");
if ( result )
{
v2 = strcasecmp(s1, "LOG_ALERT");
result = 1;
if ( v2 )
{
v3 = strcasecmp(s1, "LOG_CRIT");
result = 2;
if ( v3 )
{
v4 = strcasecmp(s1, "LOG_ERR");
result = 3;
if ( v4 )
{
v5 = strcasecmp(s1, "LOG_WARNING");
result = 4;
if ( v5 )
{
v6 = strcasecmp(s1, "LOG_NOTICE");
result = 5;
if ( v6 )
{
v7 = strcasecmp(s1, "LOG_INFO");
result = 6;
if ( v7 )
{
v8 = strcasecmp(s1, "LOG_DEBUG");
result = 7;
if ( v8 )
{
zc_profile_inner(2LL, "level.c", 75LL, "wrong syslog level[%s]", s1);
result = -187;
}
}
}
}
}
}
}
}
}
else
{
zc_profile_inner(2LL, "level.c", 56LL, "str is null or 0");
result = -187;
}
return result;
}

original_code:
static int syslog_level_atoi(char *str)
{
 if(!(str)) { zc_profile_inner(ZC_ERROR, "level.c", 56, "str"" is null or 0"); return -187; };
 if (( strcasecmp(str,"LOG_EMERG") == 0 ))
  return 0;
 if (( strcasecmp(str,"LOG_ALERT") == 0 ))
  return 1;
 if (( strcasecmp(str,"LOG_CRIT") == 0 ))
  return 2;
 if (( strcasecmp(str,"LOG_ERR") == 0 ))
  return 3;
 if (( strcasecmp(str,"LOG_WARNING") == 0 ))
  return 4;
 if (( strcasecmp(str,"LOG_NOTICE") == 0 ))
  return 5;
 if (( strcasecmp(str,"LOG_INFO") == 0 ))
  return 6;
 if (( strcasecmp(str,"LOG_DEBUG") == 0 ))
  return 7;
 zc_profile_inner(ZC_ERROR, "level.c", 75, "wrong syslog level[%s]", str);
 return -187;
}


decompiled_code:
__int64 __fastcall zlog_level_profile(unsigned int *a1, unsigned int a2)
{
__int64 result; // rax

if ( a1 )
result = zc_profile_inner(
a2,
"level.c",
32LL,
"---level[%p][%d,%s,%s,%d,%d]---",
a1,
*a1,
(const char *)a1 + 4,
(const char *)a1 + 1029,
*((_QWORD *)a1 + 257),
a1[516]);
else
result = zc_profile_inner(2LL, "level.c", 31LL, "a_level is null or 0");
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int *a1, unsigned int a2)
{
__int64 result; // rax

if ( a1 )
result = zc_profile_inner(
a2,
"level.c",
32LL,
"---level[%p][%d,%s,%s,%d,%d]---",
a1,
*a1,
(const char *)a1 + 4,
(const char *)a1 + 1029,
*((_QWORD *)a1 + 257),
a1[516]);
else
result = zc_profile_inner(2LL, "level.c", 31LL, "a_level is null or 0");
return result;
}

original_code:
void zlog_level_profile(zlog_level_t *a_level, int flag)
{
 if(!(a_level)) { zc_profile_inner(ZC_ERROR, "level.c", 31, "a_level"" is null or 0"); return ; };
 zc_profile_inner(flag, "level.c", 32, "---level[%p][%d,%s,%s,%d,%d]---", a_level, a_level->int_level, a_level->str_uppercase, a_level->str_lowercase, (int) a_level->str_len, a_level->syslog_level);
 return;
}

canonical_original_code:
void zlog_level_profile(struct zlog_level_s *a_level, int flag)
{
 if(!(a_level)) { zc_profile_inner(ZC_ERROR, "level.c", 31, "a_level"" is null or 0"); return ; };
 zc_profile_inner(flag, "level.c", 32, "---level[%p][%d,%s,%s,%d,%d]---", a_level, a_level->int_level, a_level->str_uppercase, a_level->str_lowercase, (int) a_level->str_len, a_level->syslog_level);
 return;
}

variable_types: flag int

return_type: void


decompiled_code:
__int64 __fastcall zlog_level_del(void *a1)
{
if ( !a1 )
return zc_profile_inner(2LL, "level.c", 45LL, "a_level is null or 0");
free(a1);
return zc_profile_inner(0LL, "level.c", 47LL, "zlog_level_del[%p]", a1);
}

canonical_decompiled_code:
__int64 __fastcall func2(void *a1)
{
if ( !a1 )
return zc_profile_inner(2LL, "level.c", 45LL, "a_level is null or 0");
free(a1);
return zc_profile_inner(0LL, "level.c", 47LL, "zlog_level_del[%p]", a1);
}

original_code:
void zlog_level_del(zlog_level_t *a_level)
{
 if(!(a_level)) { zc_profile_inner(ZC_ERROR, "level.c", 45, "a_level"" is null or 0"); return ; };
 free(a_level);
 zc_profile_inner(ZC_DEBUG, "level.c", 47, "zlog_level_del[%p]", a_level);
 return;
}

canonical_original_code:
void zlog_level_del(struct zlog_level_s *a_level)
{
 if(!(a_level)) { zc_profile_inner(ZC_ERROR, "level.c", 45, "a_level"" is null or 0"); return ; };
 free(a_level);
 zc_profile_inner(ZC_DEBUG, "level.c", 47, "zlog_level_del[%p]", a_level);
 return;
}


decompiled_code:
__int64 __fastcall zlog_record_profile(const void **a1, unsigned int a2)
{
__int64 result; // rax

if ( a1 )
result = zc_profile_inner(a2, "record.c", 26LL, "--record:[%p][%s:%p]--", a1, (const char *)a1, a1[129]);
else
result = zc_profile_inner(2LL, "record.c", 25LL, "a_record is null or 0");
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(const void **a1, unsigned int a2)
{
__int64 result; // rax

if ( a1 )
result = zc_profile_inner(a2, "record.c", 26LL, "--record:[%p][%s:%p]--", a1, (const char *)a1, a1[129]);
else
result = zc_profile_inner(2LL, "record.c", 25LL, "a_record is null or 0");
return result;
}

original_code:
void zlog_record_profile(zlog_record_t *a_record, int flag)
{
 if(!(a_record)) { zc_profile_inner(ZC_ERROR, "record.c", 25, "a_record"" is null or 0"); return ; };
 zc_profile_inner(flag, "record.c", 26, "--record:[%p][%s:%p]--", a_record, a_record->name, a_record->output);
 return;
}

canonical_original_code:
void zlog_record_profile(struct zlog_record_s *a_record, int flag)
{
 if(!(a_record)) { zc_profile_inner(ZC_ERROR, "record.c", 25, "a_record"" is null or 0"); return ; };
 zc_profile_inner(flag, "record.c", 26, "--record:[%p][%s:%p]--", a_record, a_record->name, a_record->output);
 return;
}

variable_types: struct zlog_record_s { char name[-1]; int (*output)(struct zlog_msg_s { char *buf; unsigned long len; char *path; } *msg); } *

user_defined_types: struct zlog_record_s { char name[-1]; int (*output)(struct zlog_msg_s *msg); }


decompiled_code:
__int64 __fastcall zlog_record_del(void *a1)
{
if ( !a1 )
return zc_profile_inner(2LL, "record.c", 32LL, "a_record is null or 0");
free(a1);
return zc_profile_inner(0LL, "record.c", 34LL, "zlog_record_del[%p]", a1);
}

canonical_decompiled_code:
__int64 __fastcall func1(void *a1)
{
if ( !a1 )
return zc_profile_inner(2LL, "record.c", 32LL, "a_record is null or 0");
free(a1);
return zc_profile_inner(0LL, "record.c", 34LL, "zlog_record_del[%p]", a1);
}

original_code:
void zlog_record_del(zlog_record_t *a_record)
{
 if(!(a_record)) { zc_profile_inner(ZC_ERROR, "record.c", 32, "a_record"" is null or 0"); return ; };
 free(a_record);
 zc_profile_inner(ZC_DEBUG, "record.c", 34, "zlog_record_del[%p]", a_record);
 return;
}

canonical_original_code:
void zlog_record_del(struct zlog_record_s *a_record)
{
 if(!(a_record)) { zc_profile_inner(ZC_ERROR, "record.c", 32, "a_record"" is null or 0"); return ; };
 free(a_record);
 zc_profile_inner(ZC_DEBUG, "record.c", 34, "zlog_record_del[%p]", a_record);
 return;
}

user_defined_types: struct zlog_msg_s { char *buf; unsigned long len; char *path; }


decompiled_code:
__int64 __fastcall zc_arraylist_expand_inner(__int64 a1, int a2)
{
int v2; // ebx
char *v3; // rax
__int64 result; // rax
int *v5; // rax

v2 = 2 * *(_DWORD *)(a1 + 12);
if ( v2 < a2 )
v2 = a2;
v3 = (char *)realloc(*(void **)a1, 8LL * v2);
if ( v3 )
{
*(_QWORD *)a1 = v3;
memset(&v3[8 * *(int *)(a1 + 12)], 0, 8LL * (v2 - *(_DWORD *)(a1 + 12)));
*(_DWORD *)(a1 + 12) = v2;
result = 0LL;
}
else
{
v5 = _errno_location();
zc_profile_inner(2LL, "zc_arraylist.c", 79LL, "realloc fail, errno[%d]", (unsigned int)*v5);
free(*(void **)a1);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int a2)
{
int v2; // ebx
char *v3; // rax
__int64 result; // rax
int *v5; // rax

v2 = 2 * *(_DWORD *)(a1 + 12);
if ( v2 < a2 )
v2 = a2;
v3 = (char *)realloc(*(void **)a1, 8LL * v2);
if ( v3 )
{
*(_QWORD *)a1 = v3;
memset(&v3[8 * *(int *)(a1 + 12)], 0, 8LL * (v2 - *(_DWORD *)(a1 + 12)));
*(_DWORD *)(a1 + 12) = v2;
result = 0LL;
}
else
{
v5 = _errno_location();
zc_profile_inner(2LL, "zc_arraylist.c", 79LL, "realloc fail, errno[%d]", (unsigned int)*v5);
free(*(void **)a1);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
static int zc_arraylist_expand_inner(zc_arraylist_t * a_list, int max)
{
 void *tmp;
 int new_size;
 new_size = ((a_list->size * 2) > (max) ? (a_list->size * 2) : (max));
 tmp = realloc(a_list->array, new_size * sizeof(void *));
 if (!tmp) {
  zc_profile_inner(ZC_ERROR, "zc_arraylist.c", 79, "realloc fail, errno[%d]", (*__errno_location ()));
  free(a_list->array);
  return -1;
 }
 a_list->array = (void **)tmp;
 memset(a_list->array + a_list->size, 0x00,
        (new_size - a_list->size) * sizeof(void *));
 a_list->size = new_size;
 return 0;
}

canonical_original_code:
static int zc_arraylist_expand_inner(struct zc_arraylist_t *a_list, int max)
{
 void *tmp;
 int new_size;
 new_size = ((a_list->size * 2) > (max) ? (a_list->size * 2) : (max));
 tmp = realloc(a_list->array, new_size * sizeof(void *));
 if (!tmp) {
  zc_profile_inner(ZC_ERROR, "zc_arraylist.c", 79, "realloc fail, errno[%d]", (*__errno_location ()));
  free(a_list->array);
  return -1;
 }
 a_list->array = (void **)tmp;
 memset(a_list->array + a_list->size, 0x00,
        (new_size - a_list->size) * sizeof(void *));
 a_list->size = new_size;
 return 0;
}

variable_types: max int

variable_types:
tmp
void *


decompiled_code:
__int64 __fastcall zc_arraylist_insert_inner(__int64 a1, int a2, __int64 a3)
{
_QWORD *v4; // rax
__int64 result; // rax

v4 = (_QWORD *)(*(_QWORD *)a1 + 8LL * a2);
if ( *v4 )
{
if ( *(_DWORD *)(a1 + 12) <= *(_DWORD *)(a1 + 8) && (unsigned int)zc_arraylist_expand_inner(a1, 0) )
{
zc_profile_inner(2LL, "zc_arraylist.c", 120LL, "expand_internal fail");
result = 0xFFFFFFFFLL;
}
else
{
memmove(
(void *)(*(_QWORD *)a1 + 8LL * a2 + 8),
(const void *)(*(_QWORD *)a1 + 8LL * a2),
8LL * (*(_DWORD *)(a1 + 8) - a2));
*(_QWORD *)(*(_QWORD *)a1 + 8LL * a2) = a3;
++*(_DWORD *)(a1 + 8);
result = 0LL;
}
}
else
{
*v4 = a3;
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, int a2, __int64 a3)
{
_QWORD *v4; // rax
__int64 result; // rax

v4 = (_QWORD *)(*(_QWORD *)a1 + 8LL * a2);
if ( *v4 )
{
if ( *(_DWORD *)(a1 + 12) <= *(_DWORD *)(a1 + 8) && (unsigned int)func0(a1, 0) )
{
zc_profile_inner(2LL, "zc_arraylist.c", 120LL, "expand_internal fail");
result = 0xFFFFFFFFLL;
}
else
{
memmove(
(void *)(*(_QWORD *)a1 + 8LL * a2 + 8),
(const void *)(*(_QWORD *)a1 + 8LL * a2),
8LL * (*(_DWORD *)(a1 + 8) - a2));
*(_QWORD *)(*(_QWORD *)a1 + 8LL * a2) = a3;
++*(_DWORD *)(a1 + 8);
result = 0LL;
}
}
else
{
*v4 = a3;
result = 0LL;
}
return result;
}

original_code:
static int zc_arraylist_insert_inner(zc_arraylist_t * a_list, int idx,
         void *data)
{
 if (a_list->array[idx] == ((void *)0)) {
  a_list->array[idx] = data;
  return 0;
 }
 if (a_list->len > a_list->size - 1) {
  if (zc_arraylist_expand_inner(a_list, 0)) {
   zc_profile_inner(ZC_ERROR, "zc_arraylist.c", 120, "expand_internal fail");
   return -1;
  }
 }
 memmove(a_list->array + idx + 1, a_list->array + idx,
  (a_list->len - idx) * sizeof(void *));
 a_list->array[idx] = data;
 a_list->len++;
 return 0;
}

canonical_original_code:
static int zc_arraylist_insert_inner(struct zc_arraylist_t *a_list, int idx, void *data)
{
 if (a_list->array[idx] == ((void *)0)) {
  a_list->array[idx] = data;
  return 0;
 }
 if (a_list->len > a_list->size - 1) {
  if (zc_arraylist_expand_inner(a_list, 0)) {
   zc_profile_inner(ZC_ERROR, "zc_arraylist.c", 120, "expand_internal fail");
   return -1;
  }
 }
 memmove(a_list->array + idx + 1, a_list->array + idx,
  (a_list->len - idx) * sizeof(void *));
 a_list->array[idx] = data;
 a_list->len++;
 return 0;
}

variable_types: idx int

variable_types:
data
void *


decompiled_code:
void __fastcall zc_arraylist_del(void *ptr)
{
__int64 v2; // rbp
void *v3; // rdi

if ( ptr )
{
if ( *((_QWORD *)ptr + 2) && *((int *)ptr + 2) > 0 )
{
v2 = 0LL;
do
{
if ( *(_QWORD *)(*(_QWORD *)ptr + 8 * v2) )
(*((void (**)(void))ptr + 2))();
++v2;
}
while ( *((_DWORD *)ptr + 2) > (int)v2 );
}
v3 = *(void **)ptr;
if ( *(_QWORD *)ptr )
free(v3);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func2(void *ptr)
{
__int64 v2; // rbp
void *v3; // rdi

if ( ptr )
{
if ( *((_QWORD *)ptr + 2) && *((int *)ptr + 2) > 0 )
{
v2 = 0LL;
do
{
if ( *(_QWORD *)(*(_QWORD *)ptr + 8 * v2) )
(*((void (**)(void))ptr + 2))();
++v2;
}
while ( *((_DWORD *)ptr + 2) > (int)v2 );
}
v3 = *(void **)ptr;
if ( *(_QWORD *)ptr )
free(v3);
free(ptr);
}
}

original_code:
void zc_arraylist_del(zc_arraylist_t * a_list)
{
 int i;
 if (!a_list)
  return;
 if (a_list->del) {
  for (i = 0; i < a_list->len; i++) {
   if (a_list->array[i])
    a_list->del(a_list->array[i]);
  }
 }
 if (a_list->array)
  free(a_list->array);
 free(a_list);
 return;
}

canonical_original_code:
void zc_arraylist_del(struct zc_arraylist_t *a_list)
{
 int i;
 if (!a_list)
  return;
 if (a_list->del) {
  for (i = 0; i < a_list->len; i++) {
   if (a_list->array[i])
    a_list->del(a_list->array[i]);
  }
 }
 if (a_list->array)
  free(a_list->array);
 free(a_list);
 return;
}


decompiled_code:
__int64 __fastcall zc_arraylist_set(__int64 a1, int a2, __int64 a3)
{
void (*v4)(void); // rax
__int64 result; // rax

if ( *(_DWORD *)(a1 + 12) <= a2 && (unsigned int)zc_arraylist_expand_inner(a1, a2) )
{
zc_profile_inner(2LL, "zc_arraylist.c", 94LL, "expand_internal fail");
result = 0xFFFFFFFFLL;
}
else
{
if ( *(_QWORD *)(*(_QWORD *)a1 + 8LL * a2) )
{
v4 = *(void (**)(void))(a1 + 16);
if ( v4 )
v4();
}
*(_QWORD *)(*(_QWORD *)a1 + 8LL * a2) = a3;
result = 0LL;
if ( *(_DWORD *)(a1 + 8) <= a2 )
*(_DWORD *)(a1 + 8) = a2 + 1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, int a2, __int64 a3)
{
void (*v4)(void); // rax
__int64 result; // rax

if ( *(_DWORD *)(a1 + 12) <= a2 && (unsigned int)func0(a1, a2) )
{
zc_profile_inner(2LL, "zc_arraylist.c", 94LL, "expand_internal fail");
result = 0xFFFFFFFFLL;
}
else
{
if ( *(_QWORD *)(*(_QWORD *)a1 + 8LL * a2) )
{
v4 = *(void (**)(void))(a1 + 16);
if ( v4 )
v4();
}
*(_QWORD *)(*(_QWORD *)a1 + 8LL * a2) = a3;
result = 0LL;
if ( *(_DWORD *)(a1 + 8) <= a2 )
*(_DWORD *)(a1 + 8) = a2 + 1;
}
return result;
}

original_code:
int zc_arraylist_set(zc_arraylist_t * a_list, int idx, void *data)
{
 if (idx > a_list->size - 1) {
  if (zc_arraylist_expand_inner(a_list, idx)) {
   zc_profile_inner(ZC_ERROR, "zc_arraylist.c", 94, "expand_internal fail");
   return -1;
  }
 }
 if (a_list->array[idx] && a_list->del) a_list->del(a_list->array[idx]);
 a_list->array[idx] = data;
 if (a_list->len <= idx)
  a_list->len = idx + 1;
 return 0;
}

canonical_original_code:
int zc_arraylist_set(struct zc_arraylist_t *a_list, int idx, void *data)
{
 if (idx > a_list->size - 1) {
  if (zc_arraylist_expand_inner(a_list, idx)) {
   zc_profile_inner(ZC_ERROR, "zc_arraylist.c", 94, "expand_internal fail");
   return -1;
  }
 }
 if (a_list->array[idx] && a_list->del) a_list->del(a_list->array[idx]);
 a_list->array[idx] = data;
 if (a_list->len <= idx)
  a_list->len = idx + 1;
 return 0;
}


decompiled_code:
__int64 __fastcall zc_arraylist_add(__int64 a1, __int64 a2)
{
return zc_arraylist_set(a1, *(_DWORD *)(a1 + 8), a2);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
return func3(a1, *(_DWORD *)(a1 + 8), a2);
}

original_code:
int zc_arraylist_add(zc_arraylist_t * a_list, void *data)
{
 return zc_arraylist_set(a_list, a_list->len, data);
}

canonical_original_code:
int zc_arraylist_add(struct zc_arraylist_t *a_list, void *data)
{
 return zc_arraylist_set(a_list, a_list->len, data);
}


decompiled_code:
__int64 __fastcall zc_arraylist_sortadd(__int64 a1, int (__fastcall *a2)(_QWORD, __int64), __int64 a3)
{
__int64 v4; // rbx
int v5; // er12
__int64 result; // rax

if ( *(int *)(a1 + 8) <= 0 )
{
v5 = 0;
}
else
{
v4 = 0LL;
do
{
v5 = v4;
if ( a2(*(_QWORD *)(*(_QWORD *)a1 + 8 * v4), a3) > 0 )
break;
v5 = ++v4;
}
while ( *(_DWORD *)(a1 + 8) > (int)v4 );
}
if ( *(_DWORD *)(a1 + 8) == v5 )
result = zc_arraylist_add(a1, a3);
else
result = zc_arraylist_insert_inner(a1, v5, a3);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, int (__fastcall *a2)(_QWORD, __int64), __int64 a3)
{
__int64 v4; // rbx
int v5; // er12
__int64 result; // rax

if ( *(int *)(a1 + 8) <= 0 )
{
v5 = 0;
}
else
{
v4 = 0LL;
do
{
v5 = v4;
if ( a2(*(_QWORD *)(*(_QWORD *)a1 + 8 * v4), a3) > 0 )
break;
v5 = ++v4;
}
while ( *(_DWORD *)(a1 + 8) > (int)v4 );
}
if ( *(_DWORD *)(a1 + 8) == v5 )
result = func4(a1, a3);
else
result = func1(a1, v5, a3);
return result;
}

original_code:
int zc_arraylist_sortadd(zc_arraylist_t * a_list, zc_arraylist_cmp_fn cmp,
    void *data)
{
 int i;
 for (i = 0; i < a_list->len; i++) {
  if ((*cmp) (a_list->array[i], data) > 0)
   break;
 }
 if (i == a_list->len)
  return zc_arraylist_add(a_list, data);
 else
  return zc_arraylist_insert_inner(a_list, i, data);
}

canonical_original_code:
int zc_arraylist_sortadd(struct zc_arraylist_t *a_list, int (*cmp)(void *data1, void *data2), void *data)
{
 int i;
 for (i = 0; i < a_list->len; i++) {
  if ((*cmp) (a_list->array[i], data) > 0)
   break;
 }
 if (i == a_list->len)
  return zc_arraylist_add(a_list, data);
 else
  return zc_arraylist_insert_inner(a_list, i, data);
}

variable_types:
cmp
int (*)(void *data1, void *data2)


decompiled_code:
__int64 __fastcall zlog_mdc_kv_del(void *a1)
{
free(a1);
return zc_profile_inner(0LL, "mdc.c", 56LL, "zlog_mdc_kv_del[%p]", a1);
}

canonical_decompiled_code:
__int64 __fastcall func0(void *a1)
{
free(a1);
return zc_profile_inner(0LL, "mdc.c", 56LL, "zlog_mdc_kv_del[%p]", a1);
}

original_code:
static void zlog_mdc_kv_del(zlog_mdc_kv_t * a_mdc_kv)
{
 free(a_mdc_kv);
 zc_profile_inner(ZC_DEBUG, "mdc.c", 56, "zlog_mdc_kv_del[%p]", a_mdc_kv);
}

canonical_original_code:
static void zlog_mdc_kv_del(struct zlog_mdc_kv_s *a_mdc_kv)
{
 free(a_mdc_kv);
 zc_profile_inner(ZC_DEBUG, "mdc.c", 56, "zlog_mdc_kv_del[%p]", a_mdc_kv);
}

variable_types: struct zlog_mdc_kv_s { char key[-1]; char value[-1]; unsigned long value_len; } *


decompiled_code:
__int64 __fastcall zc_parse_byte_size(char *nptr)
{
char *v1; // rbp
char v2; // bl
char *v3; // rcx
const unsigned __int16 **v4; // rdi
char *v5; // rdx
__int64 result; // rax
size_t v7; // r12
__int64 v8; // rbx
int v9; // er12
int v10; // eax

if ( nptr )
{
v1 = nptr;
v2 = *nptr;
v3 = nptr;
if ( *nptr )
{
v4 = _ctype_b_loc();
v3 = v1;
v5 = v1;
do
{
if ( ((*v4)[v2] & 0x2000) == 0 )
*v3++ = v2;
v2 = *++v5;
}
while ( *v5 );
}
*v3 = 0;
v7 = strlen(v1);
v8 = strtol(v1, 0LL, 10);
result = 0LL;
if ( v8 > 0 )
{
if ( (v1[v7 - 1] & 0xDF) == 66 )
{
v9 = v1[v7 - 2];
v10 = 1024;
}
else
{
v9 = v1[v7 - 1];
v10 = 1000;
}
switch ( v9 )
{
case 'G':
case 'g':
v8 *= v10 * v10 * v10;
break;
case 'K':
case 'k':
v8 *= v10;
break;
case 'M':
case 'm':
v8 *= v10 * v10;
break;
default:
if ( ((*_ctype_b_loc())[v9] & 0x800) == 0 )
zc_profile_inner(
2LL,
"zc_util.c",
81LL,
"Wrong suffix parsing size in bytes for string [%s], ignoring suffix",
v1);
break;
}
result = v8;
}
}
else
{
zc_profile_inner(2LL, "zc_util.c", 39LL, "astring is null or 0");
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *nptr)
{
char *v1; // rbp
char v2; // bl
char *v3; // rcx
const unsigned __int16 **v4; // rdi
char *v5; // rdx
__int64 result; // rax
size_t v7; // r12
__int64 v8; // rbx
int v9; // er12
int v10; // eax

if ( nptr )
{
v1 = nptr;
v2 = *nptr;
v3 = nptr;
if ( *nptr )
{
v4 = _ctype_b_loc();
v3 = v1;
v5 = v1;
do
{
if ( ((*v4)[v2] & 0x2000) == 0 )
*v3++ = v2;
v2 = *++v5;
}
while ( *v5 );
}
*v3 = 0;
v7 = strlen(v1);
v8 = strtol(v1, 0LL, 10);
result = 0LL;
if ( v8 > 0 )
{
if ( (v1[v7 - 1] & 0xDF) == 66 )
{
v9 = v1[v7 - 2];
v10 = 1024;
}
else
{
v9 = v1[v7 - 1];
v10 = 1000;
}
switch ( v9 )
{
case 'G':
case 'g':
v8 *= v10 * v10 * v10;
break;
case 'K':
case 'k':
v8 *= v10;
break;
case 'M':
case 'm':
v8 *= v10 * v10;
break;
default:
if ( ((*_ctype_b_loc())[v9] & 0x800) == 0 )
zc_profile_inner(
2LL,
"zc_util.c",
81LL,
"Wrong suffix parsing size in bytes for string [%s], ignoring suffix",
v1);
break;
}
result = v8;
}
}
else
{
zc_profile_inner(2LL, "zc_util.c", 39LL, "astring is null or 0");
result = 0LL;
}
return result;
}

original_code:
size_t zc_parse_byte_size(char *astring)
{
 char *p;
 char *q;
 size_t sz;
 long res;
 int c, m;
 if(!(astring)) { zc_profile_inner(ZC_ERROR, "zc_util.c", 39, "astring"" is null or 0"); return 0; };
 for (p = q = astring; *p != '\0'; p++) {
  if (((*__ctype_b_loc ())[(int) ((*p))] & (unsigned short int) _ISspace)) {
   continue;
  } else {
   *q = *p;
   q++;
  }
 }
 *q = '\0';
 sz = strlen(astring);
 res = strtol(astring, (char **)((void *)0), 10);
 if (res <= 0)
  return 0;
 if (astring[sz - 1] == 'B' || astring[sz - 1] == 'b') {
  c = astring[sz - 2];
  m = 1024;
 } else {
  c = astring[sz - 1];
  m = 1000;
 }
 switch (c) {
 case 'K':
 case 'k':
  res *= m;
  break;
 case 'M':
 case 'm':
  res *= m * m;
  break;
 case 'G':
 case 'g':
  res *= m * m * m;
  break;
 default:
  if (!((*__ctype_b_loc ())[(int) ((c))] & (unsigned short int) _ISdigit)) {
   zc_profile_inner(ZC_ERROR, "zc_util.c", 81, "Wrong suffix parsing " "size in bytes for string [%s], ignoring suffix", astring);
  }
  break;
 }
 return (res);
}

canonical_original_code:
unsigned long zc_parse_byte_size(char *astring)
{
 char *p;
 char *q;
 unsigned long sz;
 long res;
 int c; int m;
 if(!(astring)) { zc_profile_inner(ZC_ERROR, "zc_util.c", 39, "astring"" is null or 0"); return 0; };
 for (p = q = astring; *p != '\0'; p++) {
  if (((*__ctype_b_loc ())[(int) ((*p))] & (unsigned short) _ISspace)) {
   continue;
  } else {
   *q = *p;
   q++;
  }
 }
 *q = '\0';
 sz = strlen(astring);
 res = strtol(astring, (char **)((void *)0), 10);
 if (res <= 0)
  return 0;
 if (astring[sz - 1] == 'B' || astring[sz - 1] == 'b') {
  c = astring[sz - 2];
  m = 1024;
 } else {
  c = astring[sz - 1];
  m = 1000;
 }
 switch (c) {
 case 'K':
 case 'k':
  res *= m;
  break;
 case 'M':
 case 'm':
  res *= m * m;
  break;
 case 'G':
 case 'g':
  res *= m * m * m;
  break;
 default:
  if (!((*__ctype_b_loc ())[(int) ((c))] & (unsigned short) _ISdigit)) {
   zc_profile_inner(ZC_ERROR, "zc_util.c", 81, "Wrong suffix parsing " "size in bytes for string [%s], ignoring suffix", astring);
  }
  break;
 }
 return (res);
}

variable_types:
astring
char *

variable_types:
p
char *

variable_types:
q
char *

variable_types:
sz
unsigned long

variable_types: res long

variable_types: c int

variable_types: m int

return_type: unsigned long


decompiled_code:
__int64 __fastcall zc_str_replace_env(char *s, __int64 a2)
{
char *v2; // rbp
signed int v3; // er14
int *v5; // rax
char *v6; // rbx
char *v7; // rax
unsigned int v8; // er12
size_t v9; // rax
int v10; // [rsp+Ch] [rbp-306Ch] BYREF
__int64 v11[512]; // [rsp+10h] [rbp-3068h] BYREF
char v12; // [rsp+1010h] [rbp-2068h]
char name[4112]; // [rsp+1020h] [rbp-2058h] BYREF
char v14[4168]; // [rsp+2030h] [rbp-1048h] BYREF

v2 = s;
v3 = strlen(s);
while ( 1 )
{
v10 = 0;
v6 = strchr(v2, 37);
if ( !v6 )
break;
memset(v14, 0, 0x1000uLL);
v14[4096] = 0;
memset(name, 0, 0x1000uLL);
name[4096] = 0;
memset(v11, 0, sizeof(v11));
v12 = 0;
if ( (unsigned int)_isoc99_sscanf(v6 + 1, "%[.0-9-]%n", &v14[1], &v10) == 1 )
{
v14[0] = 37;
v14[v10 + 1] = 115;
}
else
{
v10 = 0;
strcpy(v14, "%s");
}
v2 = &v6[v10 + 1];
if ( (unsigned int)_isoc99_sscanf(v2, "E(%[^)])%n", name, &v10) )
{
v2 += v10;
if ( *(v2 - 1) != 41 )
{
zc_profile_inner(2LL, "zc_util.c", 137LL, "in string[%s] can't find match )", v6);
return 0xFFFFFFFFLL;
}
v7 = getenv(name);
v8 = snprintf_s(v11, 4097LL, v14, v7);
if ( v8 > 0x1000 )
{
v5 = _errno_location();
zc_profile_inner(2LL, "zc_util.c", 143LL, "snprintf fail, errno[%d], evn_value_len[%d]", (unsigned int)*v5, v8);
return 0xFFFFFFFFLL;
}
v3 = v3 - ((_DWORD)v2 - (_DWORD)v6) + v8;
if ( v3 > (unsigned __int64)(a2 - 1) )
{
zc_profile_inner(2LL, "zc_util.c", 150LL, "repalce env_value[%s] cause overlap", (const char *)v11);
return 0xFFFFFFFFLL;
}
v9 = strlen(v2);
memmove(&v6[v8], v2, v9 + 1);
if ( v8 >= 8 )
{
*(_QWORD *)v6 = v11[0];
*(_QWORD *)&v6[v8 - 8] = *(__int64 *)((char *)&v11[-1] + v8);
qmemcpy(
(void *)((unsigned __int64)(v6 + 8) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)((char *)v11 - &v6[-((unsigned __int64)(v6 + 8) & 0xFFFFFFFFFFFFFFF8LL)]),
8LL * ((v8 + (_DWORD)v6 - (((_DWORD)v6 + 8) & 0xFFFFFFF8)) >> 3));
}
else if ( (v8 & 4) != 0 )
{
*(_DWORD *)v6 = v11[0];
*(_DWORD *)&v6[v8 - 4] = *(int *)((char *)&v10 + v8);
}
else if ( v8 )
{
*v6 = v11[0];
if ( (v8 & 2) != 0 )
*(_WORD *)&v6[v8 - 2] = *(_WORD *)((char *)v11 + v8 - 2);
}
}
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *s, __int64 a2)
{
char *v2; // rbp
signed int v3; // er14
int *v5; // rax
char *v6; // rbx
char *v7; // rax
unsigned int v8; // er12
size_t v9; // rax
int v10; // [rsp+Ch] [rbp-306Ch] BYREF
__int64 v11[512]; // [rsp+10h] [rbp-3068h] BYREF
char v12; // [rsp+1010h] [rbp-2068h]
char name[4112]; // [rsp+1020h] [rbp-2058h] BYREF
char v14[4168]; // [rsp+2030h] [rbp-1048h] BYREF

v2 = s;
v3 = strlen(s);
while ( 1 )
{
v10 = 0;
v6 = strchr(v2, 37);
if ( !v6 )
break;
memset(v14, 0, 0x1000uLL);
v14[4096] = 0;
memset(name, 0, 0x1000uLL);
name[4096] = 0;
memset(v11, 0, sizeof(v11));
v12 = 0;
if ( (unsigned int)_isoc99_sscanf(v6 + 1, "%[.0-9-]%n", &v14[1], &v10) == 1 )
{
v14[0] = 37;
v14[v10 + 1] = 115;
}
else
{
v10 = 0;
strcpy(v14, "%s");
}
v2 = &v6[v10 + 1];
if ( (unsigned int)_isoc99_sscanf(v2, "E(%[^)])%n", name, &v10) )
{
v2 += v10;
if ( *(v2 - 1) != 41 )
{
zc_profile_inner(2LL, "zc_util.c", 137LL, "in string[%s] can't find match )", v6);
return 0xFFFFFFFFLL;
}
v7 = getenv(name);
v8 = snprintf_s(v11, 4097LL, v14, v7);
if ( v8 > 0x1000 )
{
v5 = _errno_location();
zc_profile_inner(2LL, "zc_util.c", 143LL, "snprintf fail, errno[%d], evn_value_len[%d]", (unsigned int)*v5, v8);
return 0xFFFFFFFFLL;
}
v3 = v3 - ((_DWORD)v2 - (_DWORD)v6) + v8;
if ( v3 > (unsigned __int64)(a2 - 1) )
{
zc_profile_inner(2LL, "zc_util.c", 150LL, "repalce env_value[%s] cause overlap", (const char *)v11);
return 0xFFFFFFFFLL;
}
v9 = strlen(v2);
memmove(&v6[v8], v2, v9 + 1);
if ( v8 >= 8 )
{
*(_QWORD *)v6 = v11[0];
*(_QWORD *)&v6[v8 - 8] = *(__int64 *)((char *)&v11[-1] + v8);
qmemcpy(
(void *)((unsigned __int64)(v6 + 8) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)((char *)v11 - &v6[-((unsigned __int64)(v6 + 8) & 0xFFFFFFFFFFFFFFF8LL)]),
8LL * ((v8 + (_DWORD)v6 - (((_DWORD)v6 + 8) & 0xFFFFFFF8)) >> 3));
}
else if ( (v8 & 4) != 0 )
{
*(_DWORD *)v6 = v11[0];
*(_DWORD *)&v6[v8 - 4] = *(int *)((char *)&v10 + v8);
}
else if ( v8 )
{
*v6 = v11[0];
if ( (v8 & 2) != 0 )
*(_WORD *)&v6[v8 - 2] = *(_WORD *)((char *)v11 + v8 - 2);
}
}
}
return 0LL;
}

original_code:
int zc_str_replace_env(char *str, size_t str_size)
{
 char *p;
 char *q;
 char fmt[(1024 * 4) + 1];
 char env_key[(1024 * 4) + 1];
 char env_value[(1024 * 4) + 1];
 int str_len;
 int env_value_len;
 str_len = strlen(str);
 q = str;
 do {
  int nscan = 0;
  int nread = 0;
  p = strchr(q, '%');
  if (!p) {
   break;
  }
  memset(fmt, 0x00, sizeof(fmt));
  memset(env_key, 0x00, sizeof(env_key));
  memset(env_value, 0x00, sizeof(env_value));
  nscan = sscanf(p + 1, "%[.0-9-]%n", fmt + 1, &nread);
  if (nscan == 1) {
   fmt[0] = '%';
   fmt[nread + 1] = 's';
  } else {
   nread = 0;
   strcpy(fmt, "%s");
  }
  q = p + 1 + nread;
  nscan = sscanf(q, "E(%[^)])%n", env_key, &nread);
  if (nscan == 0) {
   continue;
  }
  q += nread;
  if (*(q - 1) != ')') {
   zc_profile_inner(ZC_ERROR, "zc_util.c", 137, "in string[%s] can't find match )", p);
   return -1;
  }
  env_value_len = _snprintf_s(env_value, sizeof(env_value), fmt, getenv(env_key));
  if (env_value_len < 0 || env_value_len >= sizeof(env_value)) {
   zc_profile_inner(ZC_ERROR, "zc_util.c", 143, "snprintf fail, errno[%d], evn_value_len[%d]", (*__errno_location ()), env_value_len);
   return -1;
  }
  str_len = str_len - (q - p) + env_value_len;
  if (str_len > str_size - 1) {
   zc_profile_inner(ZC_ERROR, "zc_util.c", 150, "repalce env_value[%s] cause overlap", env_value);
   return -1;
  }
  memmove(p + env_value_len, q, strlen(q) + 1);
  memcpy(p, env_value, env_value_len);
 } while (1);
 return 0;
}

canonical_original_code:
int zc_str_replace_env(char *str, unsigned long str_size)
{
 char *p;
 char *q;
 char fmt[-1];
 char env_key[-1];
 char env_value[-1];
 int str_len;
 int env_value_len;
 str_len = strlen(str);
 q = str;
 do {
  int nscan = 0;
  int nread = 0;
  p = strchr(q, '%');
  if (!p) {
   break;
  }
  memset(fmt, 0x00, sizeof(fmt));
  memset(env_key, 0x00, sizeof(env_key));
  memset(env_value, 0x00, sizeof(env_value));
  nscan = sscanf(p + 1, "%[.0-9-]%n", fmt + 1, &nread);
  if (nscan == 1) {
   fmt[0] = '%';
   fmt[nread + 1] = 's';
  } else {
   nread = 0;
   strcpy(fmt, "%s");
  }
  q = p + 1 + nread;
  nscan = sscanf(q, "E(%[^)])%n", env_key, &nread);
  if (nscan == 0) {
   continue;
  }
  q += nread;
  if (*(q - 1) != ')') {
   zc_profile_inner(ZC_ERROR, "zc_util.c", 137, "in string[%s] can't find match )", p);
   return -1;
  }
  env_value_len = _snprintf_s(env_value, sizeof(env_value), fmt, getenv(env_key));
  if (env_value_len < 0 || env_value_len >= sizeof(env_value)) {
   zc_profile_inner(ZC_ERROR, "zc_util.c", 143, "snprintf fail, errno[%d], evn_value_len[%d]", (*__errno_location ()), env_value_len);
   return -1;
  }
  str_len = str_len - (q - p) + env_value_len;
  if (str_len > str_size - 1) {
   zc_profile_inner(ZC_ERROR, "zc_util.c", 150, "repalce env_value[%s] cause overlap", env_value);
   return -1;
  }
  memmove(p + env_value_len, q, strlen(q) + 1);
  memcpy(p, env_value, env_value_len);
 } while (1);
 return 0;
}

variable_types:
str
char *

variable_types:
fmt
char [-1]

variable_types: nscan int

variable_types: nread int


output

decompiled_code:
__int64 __fastcall output(__int64 a1)
{
printf("[mystd]:[%s][%s][%ld]\n", *(const char **)(a1 + 16), *(const char **)a1, *(_QWORD *)(a1 + 8));
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
printf("[mystd]:[%s][%s][%ld]\n", *(const char **)(a1 + 16), *(const char **)a1, *(_QWORD *)(a1 + 8));
return 0LL;
}

original_code:
int output(zlog_msg_t *msg)
{
 printf("[mystd]:[%s][%s][%ld]\n", msg->path, msg->buf, (long)msg->len);
 return 0;
}

canonical_original_code:
int output(struct zlog_msg_s *msg)
{
 printf("[mystd]:[%s][%s][%ld]\n", msg->path, msg->buf, (long)msg->len);
 return 0;
}

variable_types: struct zlog_msg_s { char *buf; unsigned long len; char *path; } *


run

repo: lornix/tcalc

decompiled_code:
__int64 run()
{
__int64 result; // rax

do
{
displaycell((unsigned int)curcol, (unsigned int)currow, 1LL, 0LL);
curcell = cell[100 * curcol + currow];
showcelltype();
result = getkey();
if ( (_DWORD)result == 47 )
{
result = mainmenu();
}
else if ( (unsigned int)(result - 32) <= 0x5E )
{
result = getinput((unsigned int)result);
}
}
while ( !stop );
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 result; // rax

do
{
displaycell((unsigned int)curcol, (unsigned int)currow, 1LL, 0LL);
curcell = cell[100 * curcol + currow];
showcelltype();
result = getkey();
if ( (_DWORD)result == 47 )
{
result = mainmenu();
}
else if ( (unsigned int)(result - 32) <= 0x5E )
{
result = getinput((unsigned int)result);
}
}
while ( !stop );
return result;
}

original_code:
void run()
{
    int input;
    do {
        displaycell(curcol, currow, 1, 0);
        curcell = cell[curcol][currow];
        showcelltype();
        input = getkey();
        switch(input) {
            case '/' :
                mainmenu();
                break;
            case 315 :
                recalc();
                break;
            case 316 :
                editcell(curcell);
                break;
            case 339 :
                deletecell(curcol, currow, 1);
                printfreemem();
                if (autocalc)
                    recalc();
                break;
            case 329 :
                toprow -= 20;
                currow -= 20;
                if (currow < 0)
                    currow = toprow = 0;
                else if (toprow < 0) {
                    currow -= toprow;
                    toprow = 0;
                }
                setbottomrow();
                displayscreen(0);
                break;
            case 337 :
                toprow += 20;
                currow += 20;
                if ((currow >= 100) && (toprow >= 100)) {
                    currow = 100 - 1;
                    toprow = 100 - 20;
                }
                else if (toprow > (100 - 20)) {
                    currow -= (toprow + 20 - 100);
                    toprow = 100 - 20;
                }
                setbottomrow();
                displayscreen(0);
                break;
            case 371 :
                displaycell(curcol, currow, 0, 0);
                if (leftcol == 0)
                    curcol = 0;
                else {
                    curcol = rightcol = leftcol - 1;
                    setleftcol();
                    setrightcol();
                    displayscreen(0);
                }
                break;
            case 372 :
                displaycell(curcol, currow, 0, 0);
                if (rightcol == 100 - 1)
                    curcol = rightcol;
                else {
                    curcol = leftcol = rightcol + 1;
                    setrightcol();
                    setleftcol();
                    displayscreen(0);
                }
                break;
            case 327 :
                currow = curcol = leftcol = toprow = 0;
                setrightcol();
                setbottomrow();
                displayscreen(0);
                break;
            case 335 :
                rightcol = curcol = lastcol;
                currow = bottomrow = lastrow;
                settoprow();
                setleftcol();
                setrightcol();
                displayscreen(0);
                break;
            case 328 :
                moverowup();
                break;
            case 336 :
                moverowdown();
                break;
            case 331 :
                movecolleft();
                break;
            case 333 :
                movecolright();
                break;
            default :
                if ((input >= ' ') && (input <= '~'))
                    getinput(input);
                break;
        }
    }
    while (!stop);
}

variable_types: input int


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
window(1LL, 1LL, 80LL, 25LL);
initcursor();
initcolortable();
setcursor((unsigned int)nocursor);
setcolor(15LL);
clrscr();
initvars();
memleft = coreleft() - 1000;
redrawscreen();
if ( argc > 1 )
loadsheet(argv[1]);
clearinput();
run();
setcolor(7LL);
clrscr();
setcursor((unsigned int)oldcursor);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
window(1LL, 1LL, 80LL, 25LL);
initcursor();
initcolortable();
setcursor((unsigned int)nocursor);
setcolor(15LL);
clrscr();
initvars();
memleft = coreleft() - 1000;
redrawscreen();
if ( argc > 1 )
loadsheet(argv[1]);
clearinput();
func0();
setcolor(7LL);
clrscr();
setcursor((unsigned int)oldcursor);
return 0;
}

original_code:
int main(int argc, char *argv[])
{
    window(1, 1, 80, 25);
    initcursor();
    initcolortable();
    setcursor(nocursor);
    setcolor(WHITE);
    clrscr();
    initvars();
    memleft = coreleft() - 1000;
    redrawscreen();
    if (argc > 1)
        loadsheet(argv[1]);
    clearinput();
    run();
    setcolor(LIGHTGRAY);
    clrscr();
    setcursor(oldcursor);
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]


setcolor

decompiled_code:
__int64 __fastcall setcolor(int a1)
{
return textattr((unsigned __int8)colortable[a1]);
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
return textattr((unsigned __int8)colortable[a1]);
}

original_code:
void setcolor(int color)
{
    textattr(colortable[color]);
}

variable_types: color int


writef

decompiled_code:
__int64 writef(unsigned int a1, unsigned int a2, int a3, int a4, const char *a5, ...)
{
int v7; // eax
char v9[88]; // [rsp+0h] [rbp-148h] BYREF
gcc_va_list arg; // [rsp+58h] [rbp-F0h] BYREF

va_start(arg, a5);
vsprintf(v9, a5, arg);
v9[a4] = 0;
v7 = strlen(v9);
if ( a4 > v7 )
setmem(&v9[v7], (unsigned int)(a4 - v7), 32LL);
setcolor(a3);
gotoxy(a1, a2);
return cputs(v9);
}

canonical_decompiled_code:
__int64 func1(unsigned int a1, unsigned int a2, int a3, int a4, const char *a5, ...)
{
int v7; // eax
char v9[88]; // [rsp+0h] [rbp-148h] BYREF
gcc_va_list arg; // [rsp+58h] [rbp-F0h] BYREF

va_start(arg, a5);
vsprintf(v9, a5, arg);
v9[a4] = 0;
v7 = strlen(v9);
if ( a4 > v7 )
setmem(&v9[v7], (unsigned int)(a4 - v7), 32LL);
func0(a3);
gotoxy(a1, a2);
return cputs(v9);
}

original_code:
void writef(int col, int row, int color, int width, char *format, ...)
{
    va_list arg_ptr;
    char output[81];
    int len;
    __builtin_va_start(arg_ptr,format);
    vsprintf(output, format, arg_ptr);
    output[width] = 0;
    if ((len = strlen(output)) < width)
        setmem(&output[len], width - len, ' ');
    setcolor(color);
    gotoxy(col, row);
    cputs(output);
}

canonical_original_code:
void writef(int col, int row, int color, int width, char *format, ...)
{
    __builtin_va_list arg_ptr;
    char output[81];
    int len;
    __builtin_va_start(arg_ptr,format);
    vsprintf(output, format, arg_ptr);
    output[width] = 0;
    if ((len = strlen(output)) < width)
        setmem(&output[len], width - len, ' ');
    setcolor(color);
    gotoxy(col, row);
    cputs(output);
}

variable_types: col int

variable_types: row int

variable_types: width int

variable_types:
format
char *

variable_types:
output
char [81]

variable_types: len int


tscroll

decompiled_code:
__int64 __fastcall tscroll(int a1, int a2, unsigned int a3, unsigned int a4, unsigned int a5, unsigned int a6, int a7)
{
int v11; // er15
int v13; // er15

if ( a2 )
{
if ( a1 == 2 )
{
movetext(a3, a4 + a2, a5, a6, a3, a4);
window(a3, a6 - a2 + 1, a5, a6);
}
else if ( a1 > 2 )
{
if ( a1 == 3 )
{
v13 = a2 + a4;
movetext(a3, a4, a5, a6 - a2, a3, a2 + a4);
window(a3, a4, a5, (unsigned int)(v13 - 1));
}
}
else if ( a1 )
{
if ( a1 == 1 )
{
v11 = a2 + a3;
movetext(a3, a4, a5 - a2, a6, a2 + a3, a4);
window(a3, a4, (unsigned int)(v11 - 1), a6);
}
}
else
{
movetext(a2 + a3, a4, a5, a6, a3, a4);
window(a5 - a2 + 1, a4, a5, a6);
}
}
else
{
window(a3, a4, a5, a6);
}
setcolor(a7);
clrscr();
return window(1LL, 1LL, 80LL, 25LL);
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, int a2, unsigned int a3, unsigned int a4, unsigned int a5, unsigned int a6, int a7)
{
int v11; // er15
int v13; // er15

if ( a2 )
{
if ( a1 == 2 )
{
movetext(a3, a4 + a2, a5, a6, a3, a4);
window(a3, a6 - a2 + 1, a5, a6);
}
else if ( a1 > 2 )
{
if ( a1 == 3 )
{
v13 = a2 + a4;
movetext(a3, a4, a5, a6 - a2, a3, a2 + a4);
window(a3, a4, a5, (unsigned int)(v13 - 1));
}
}
else if ( a1 )
{
if ( a1 == 1 )
{
v11 = a2 + a3;
movetext(a3, a4, a5 - a2, a6, a2 + a3, a4);
window(a3, a4, (unsigned int)(v11 - 1), a6);
}
}
else
{
movetext(a2 + a3, a4, a5, a6, a3, a4);
window(a5 - a2 + 1, a4, a5, a6);
}
}
else
{
window(a3, a4, a5, a6);
}
func0(a7);
clrscr();
return window(1LL, 1LL, 80LL, 25LL);
}

original_code:
void tscroll(int direction, int lines, int x1, int y1, int x2, int y2, int attrib)
{
    if (lines == 0)
        window(x1, y1, x2, y2);
    else switch(direction) {
        case 2 :
            movetext(x1, y1 + lines, x2, y2, x1, y1);
            window(x1, y2 - lines + 1, x2, y2);
            break;
        case 3 :
            movetext(x1, y1, x2, y2 - lines, x1, y1 + lines);
            window(x1, y1, x2, y1 + lines - 1);
            break;
        case 0 :
            movetext(x1 + lines, y1, x2, y2, x1, y1);
            window(x2 - lines + 1, y1, x2, y2);
            break;
        case 1 :
            movetext(x1, y1, x2 - lines, y2, x1 + lines, y1);
            window(x1, y1, x1 + lines - 1, y2);
            break;
    }
    setcolor(attrib);
    clrscr();
    window(1, 1, 80, 25);
}

variable_types: direction int

variable_types: lines int

variable_types: attrib int


setcursor

decompiled_code:
__int64 __fastcall setcursor(int a1)
{
_BYTE v2[8]; // [rsp+0h] [rbp-28h] BYREF
int v3; // [rsp+8h] [rbp-20h]

v2[1] = 1;
v3 = a1;
return int86(16LL, v2, v2);
}

canonical_decompiled_code:
__int64 __fastcall func3(int a1)
{
_BYTE v2[8]; // [rsp+0h] [rbp-28h] BYREF
int v3; // [rsp+8h] [rbp-20h]

v2[1] = 1;
v3 = a1;
return int86(16LL, v2, v2);
}

original_code:
void setcursor(unsigned int shape)
{
    union REGS reg;
    reg.h.ah = 1;
    reg.x.cx = shape;
    int86(0X10, &reg, &reg);
}

variable_types:
shape
unsigned int

variable_types: union REGS { struct WORDREGS { unsigned int ax; } x; struct BYTEREGS { unsigned char al; } h; }

user_defined_types: union REGS { struct WORDREGS x; struct BYTEREGS h; }


getcursor

decompiled_code:
__int64 getcursor()
{
_BYTE v1[8]; // [rsp+0h] [rbp-28h] BYREF
unsigned int v2; // [rsp+8h] [rbp-20h]

v1[1] = 3;
v1[3] = 0;
int86(16LL, v1, v1);
return v2;
}

original_code:
unsigned int getcursor(void)
{
    union REGS reg;
    reg.h.ah = 3;
    reg.h.bh = 0;
    int86(0X10, &reg, &reg);
    return(reg.x.cx);
}

canonical_original_code:
unsigned int getcursor()
{
    union REGS reg;
    reg.h.ah = 3;
    reg.h.bh = 0;
    int86(0X10, &reg, &reg);
    return(reg.x.cx);
}

return_type: unsigned int


changecursor

decompiled_code:
__int64 __fastcall changecursor(int a1)
{
__int64 result; // rax

if ( a1 )
result = setcursor(tallcursor);
else
result = setcursor(shortcursor);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1)
{
__int64 result; // rax

if ( a1 )
result = func3(tallcursor);
else
result = func3(shortcursor);
return result;
}

original_code:
void changecursor(int insmode)
{
    if (insmode)
        setcursor(tallcursor);
    else
        setcursor(shortcursor);
}

variable_types: insmode int


printcol

decompiled_code:
__int64 printcol()
{
__int64 result; // rax
__int64 v1; // rbx
char v2[88]; // [rsp+8h] [rbp-58h] BYREF

result = tscroll(2, 0, 1u, 2u, 0x50u, 2u, 79);
if ( leftcol <= rightcol )
{
v1 = leftcol;
do
{
centercolstring((unsigned int)v1, v2);
result = writef(
(unsigned int)*((unsigned __int8 *)&colstart + (int)v1 - leftcol) + 1,
2u,
79,
*((unsigned __int8 *)&colwidth + v1),
v2);
++v1;
}
while ( rightcol >= (int)v1 );
}
return result;
}

canonical_decompiled_code:
__int64 func6()
{
__int64 result; // rax
__int64 v1; // rbx
char v2[88]; // [rsp+8h] [rbp-58h] BYREF

result = func2(2, 0, 1u, 2u, 0x50u, 2u, 79);
if ( leftcol <= rightcol )
{
v1 = leftcol;
do
{
centercolstring((unsigned int)v1, v2);
result = func1(
(unsigned int)*((unsigned __int8 *)&colstart + (int)v1 - leftcol) + 1,
2u,
79,
*((unsigned __int8 *)&colwidth + v1),
v2);
++v1;
}
while ( rightcol >= (int)v1 );
}
return result;
}

original_code:
void printcol(void)
{
    int col;
    char colstr[80 - 3 + 1];
    tscroll(2, 0, 1, 2, 80, 2, WHITE + (RED << 4));
    for (col = leftcol; col <= rightcol; col++) {
        centercolstring(col, colstr);
        writef(colstart[col - leftcol] + 1, 2, WHITE + (RED << 4), colwidth[col], colstr);
    }
}

canonical_original_code:
void printcol()
{
    int col;
    char colstr[-1];
    tscroll(2, 0, 1, 2, 80, 2, WHITE + (RED << 4));
    for (col = leftcol; col <= rightcol; col++) {
        centercolstring(col, colstr);
        writef(colstart[col - leftcol] + 1, 2, WHITE + (RED << 4), colwidth[col], colstr);
    }
}

variable_types:
colstr
char [-1]


clearlastcol

decompiled_code:
__int64 clearlastcol()
{
__int64 result; // rax
int v1; // edx

result = *((unsigned __int8 *)&colwidth + rightcol);
v1 = result + *((unsigned __int8 *)&colstart + rightcol - leftcol);
if ( v1 <= 79 )
result = tscroll(2, 0, v1 + 1, 3u, 0x50u, 0x16u, 15);
return result;
}

canonical_decompiled_code:
__int64 func7()
{
__int64 result; // rax
int v1; // edx

result = *((unsigned __int8 *)&colwidth + rightcol);
v1 = result + *((unsigned __int8 *)&colstart + rightcol - leftcol);
if ( v1 <= 79 )
result = func2(2, 0, v1 + 1, 3u, 0x50u, 0x16u, 15);
return result;
}

original_code:
void clearlastcol()
{
    int col;
    if ((col = colstart[rightcol - leftcol] + colwidth[rightcol]) < 80)
        tscroll(2, 0, col + 1, 3, 80, 20 + 2, WHITE);
}


printrow

decompiled_code:
__int64 printrow()
{
int i; // ebx
__int64 result; // rax

for ( i = 0; i != 20; ++i )
result = writef(1u, i + 3, 79, 3, "%-d", (unsigned int)(toprow + i + 1));
return result;
}

canonical_decompiled_code:
__int64 func8()
{
int i; // ebx
__int64 result; // rax

for ( i = 0; i != 20; ++i )
result = func1(1u, i + 3, 79, 3, "%-d", (unsigned int)(toprow + i + 1));
return result;
}

original_code:
void printrow(void)
{
    int row;
    for (row = 0; row < 20; row++)
        writef(1, row + 3, WHITE + (RED << 4), 3, "%-d", row + toprow + 1);
}

canonical_original_code:
void printrow()
{
    int row;
    for (row = 0; row < 20; row++)
        writef(1, row + 3, WHITE + (RED << 4), 3, "%-d", row + toprow + 1);
}


displayscreen

decompiled_code:
__int64 __fastcall displayscreen(int a1)
{
signed int v1; // ebx

v1 = toprow;
if ( toprow <= bottomrow )
{
do
displayrow(v1++, a1);
while ( bottomrow >= v1 );
}
return clearlastcol();
}

canonical_decompiled_code:
__int64 __fastcall func9(int a1)
{
signed int v1; // ebx

v1 = toprow;
if ( toprow <= bottomrow )
{
do
displayrow(v1++, a1);
while ( bottomrow >= v1 );
}
return func7();
}

original_code:
void displayscreen(int updating)
{
    int row;
    for (row = toprow; row <= bottomrow; row++)
        displayrow(row, updating);
    clearlastcol();
}

variable_types: updating int


clearinput

decompiled_code:
__int64 clearinput()
{
tscroll(2, 0, 1u, 0x19u, 0x50u, 0x19u, 15);
return gotoxy(1LL, 25LL);
}

original_code:
void clearinput(void)
{
    tscroll(2, 0, 1, 25, 80, 25, WHITE);
    gotoxy(1, 25);
}

canonical_original_code:
void clearinput()
{
    tscroll(2, 0, 1, 25, 80, 25, WHITE);
    gotoxy(1, 25);
}


showcelltype

decompiled_code:
__int64 showcelltype()
{
const char *v0; // rbx
char v1; // al
__int64 result; // rax
char v3[5]; // [rsp+8h] [rbp-10h] BYREF
char v4[11]; // [rsp+Dh] [rbp-Bh] BYREF

formdisplay = formdisplay == 0;
v0 = (const char *)cellstring(curcol, currow, v3, 0LL);
colstring(curcol, v4);
if ( curcell )
{
v1 = *curcell;
if ( *curcell == 1 )
{
writef(1u, 0x17u, 10, 80, "%s%d %s", v4, (unsigned int)(currow + 1), "Value");
}
else if ( v1 == 2 )
{
writef(1u, 0x17u, 10, 80, "%s%d %s", v4, (unsigned int)(currow + 1), "Formula");
}
else if ( !v1 )
{
writef(1u, 0x17u, 10, 80, "%s%d %s", v4, (unsigned int)(currow + 1), "Text");
}
}
else
{
writef(1u, 0x17u, 10, 80, "%s%d %s", v4, (unsigned int)(currow + 1), "Empty");
}
result = writef(1u, 0x18u, 14, 80, "%s", v0);
formdisplay = formdisplay == 0;
return result;
}

canonical_decompiled_code:
__int64 func11()
{
const char *v0; // rbx
char v1; // al
__int64 result; // rax
char v3[5]; // [rsp+8h] [rbp-10h] BYREF
char v4[11]; // [rsp+Dh] [rbp-Bh] BYREF

formdisplay = formdisplay == 0;
v0 = (const char *)cellstring(curcol, currow, v3, 0LL);
colstring(curcol, v4);
if ( curcell )
{
v1 = *curcell;
if ( *curcell == 1 )
{
func1(1u, 0x17u, 10, 80, "%s%d %s", v4, (unsigned int)(currow + 1), "Value");
}
else if ( v1 == 2 )
{
func1(1u, 0x17u, 10, 80, "%s%d %s", v4, (unsigned int)(currow + 1), "Formula");
}
else if ( !v1 )
{
func1(1u, 0x17u, 10, 80, "%s%d %s", v4, (unsigned int)(currow + 1), "Text");
}
}
else
{
func1(1u, 0x17u, 10, 80, "%s%d %s", v4, (unsigned int)(currow + 1), "Empty");
}
result = func1(1u, 0x18u, 14, 80, "%s", v0);
formdisplay = formdisplay == 0;
return result;
}

original_code:
void showcelltype(void)
{
    char colstr[3], *s;
    int color;
    formdisplay = !formdisplay;
    s = cellstring(curcol, currow, &color, 0);
    colstring(curcol, colstr);
    if (curcell == ((void *)0))
        writef(1, 23, LIGHTGREEN, 80, "%s%d %s", colstr, currow + 1, "Empty");
    else switch(curcell->attrib) {
        case 0 :
            writef(1, 23, LIGHTGREEN, 80, "%s%d %s", colstr, currow + 1, "Text");
            break;
        case 1 :
            writef(1, 23, LIGHTGREEN, 80, "%s%d %s", colstr, currow + 1, "Value");
            break;
        case 2 :
            writef(1, 23, LIGHTGREEN, 80, "%s%d %s", colstr, currow + 1, "Formula");
            break;
    }
    writef(1, 24, YELLOW, 80, "%s", s);
    formdisplay = !formdisplay;
}

canonical_original_code:
void showcelltype()
{
    char colstr[3]; char *s;
    int color;
    formdisplay = !formdisplay;
    s = cellstring(curcol, currow, &color, 0);
    colstring(curcol, colstr);
    if (curcell == ((void *)0))
        writef(1, 23, LIGHTGREEN, 80, "%s%d %s", colstr, currow + 1, "Empty");
    else switch(curcell->attrib) {
        case 0 :
            writef(1, 23, LIGHTGREEN, 80, "%s%d %s", colstr, currow + 1, "Text");
            break;
        case 1 :
            writef(1, 23, LIGHTGREEN, 80, "%s%d %s", colstr, currow + 1, "Value");
            break;
        case 2 :
            writef(1, 23, LIGHTGREEN, 80, "%s%d %s", colstr, currow + 1, "Formula");
            break;
    }
    writef(1, 24, YELLOW, 80, "%s", s);
    formdisplay = !formdisplay;
}

variable_types:
colstr
char [3]

variable_types:
s
char *


redrawscreen

decompiled_code:
__int64 redrawscreen()
{
setrightcol();
setbottomrow();
writef(1u, 1u, 10, 17, "Memory Available:");
writef(0x20u, 1u, 14, 32, "Press / for the list of commands");
changeautocalc((unsigned int)autocalc);
changeformdisplay((unsigned int)formdisplay);
printfreemem();
return displayscreen(0);
}

canonical_decompiled_code:
__int64 func12()
{
setrightcol();
setbottomrow();
func1(1u, 1u, 10, 17, "Memory Available:");
func1(0x20u, 1u, 14, 32, "Press / for the list of commands");
changeautocalc((unsigned int)autocalc);
changeformdisplay((unsigned int)formdisplay);
printfreemem();
return func9(0);
}

original_code:
void redrawscreen(void)
{
    setrightcol();
    setbottomrow();
    writef(1, 1, LIGHTGREEN, strlen("Memory Available:"), "Memory Available:");
    writef(32, 1, YELLOW, strlen("Press / for the list of commands"), "Press / for the list of commands");
    changeautocalc(autocalc);
    changeformdisplay(formdisplay);
    printfreemem();
    displayscreen(0);
}

canonical_original_code:
void redrawscreen()
{
    setrightcol();
    setbottomrow();
    writef(1, 1, LIGHTGREEN, strlen("Memory Available:"), "Memory Available:");
    writef(32, 1, YELLOW, strlen("Press / for the list of commands"), "Press / for the list of commands");
    changeautocalc(autocalc);
    changeformdisplay(formdisplay);
    printfreemem();
    displayscreen(0);
}


initcursor

decompiled_code:
__int64 initcursor()
{
__int64 result; // rax
char v1[19]; // [rsp+5h] [rbp-13h] BYREF

gettextinfo(v1);
result = getcursor();
oldcursor = result;
shortcursor = 1543;
tallcursor = 1287;
if ( v1[6] == 7 )
{
shortcursor = 2572;
tallcursor = 2316;
}
return result;
}

canonical_decompiled_code:
__int64 func13()
{
__int64 result; // rax
char v1[19]; // [rsp+5h] [rbp-13h] BYREF

gettextinfo(v1);
result = func4();
oldcursor = result;
shortcursor = 1543;
tallcursor = 1287;
if ( v1[6] == 7 )
{
shortcursor = 2572;
tallcursor = 2316;
}
return result;
}

original_code:
void initcursor(void)
{
    struct text_info ti;
    gettextinfo(&ti);
    oldcursor = getcursor();
    shortcursor = 0x0607;
    tallcursor = 0x0507;
    if (ti.currmode == MONO) {
        shortcursor = 0x0A0C;
        tallcursor = 0x090C;
    }
}

canonical_original_code:
void initcursor()
{
    struct text_info ti;
    gettextinfo(&ti);
    oldcursor = getcursor();
    shortcursor = 0x0607;
    tallcursor = 0x0507;
    if (ti.currmode == MONO) {
        shortcursor = 0x0A0C;
        tallcursor = 0x090C;
    }
}

variable_types: struct text_info { unsigned char winleft; unsigned char wintop; unsigned char winright; unsigned char winbottom; unsigned char attribute; unsigned char normattr; unsigned char currmode; unsigned char screenheight; unsigned char screenwidth; unsigned char curx; unsigned char cury; }


initcolortable

decompiled_code:
char *initcolortable()
{
int v0; // er8
int v1; // edx
char *result; // rax
int i; // eax
int v4; // ecx
char v5[19]; // [rsp+5h] [rbp-13h] BYREF

gettextinfo(v5);
v0 = 0;
v1 = 0;
if ( v5[6] == 3 )
{
result = 0LL;
do
{
colortable[(_QWORD)result] = (char)result;
++result;
}
while ( result != (_BYTE *)&loc_FC + 4 );
return result;
}
while ( 2 )
{
v4 = v0;
for ( i = 1; ; ++i )
{
if ( i == 1 )
{
colortable[v4] = v1;
goto LABEL_9;
}
if ( v1 == 15 )
v1 = 0;
colortable[v4] = v1 + 112;
if ( i > 7 )
break;
LABEL_9:
v4 += 16;
}
if ( ++v0 != 16 )
{
v1 = v0;
if ( v0 )
v1 = 8 * (v0 >= 8) + 7;
continue;
}
break;
}
result = colortable;
do
{
result[128] = *result | 0x80;
++result;
}
while ( &unk_920 != (_UNKNOWN *)result );
return result;
}

canonical_decompiled_code:
char *func14()
{
int v0; // er8
int v1; // edx
char *result; // rax
int i; // eax
int v4; // ecx
char v5[19]; // [rsp+5h] [rbp-13h] BYREF

gettextinfo(v5);
v0 = 0;
v1 = 0;
if ( v5[6] == 3 )
{
result = 0LL;
do
{
colortable[(_QWORD)result] = (char)result;
++result;
}
while ( result != (_BYTE *)&loc_FC + 4 );
return result;
}
while ( 2 )
{
v4 = v0;
for ( i = 1; ; ++i )
{
if ( i == 1 )
{
colortable[v4] = v1;
goto LABEL_9;
}
if ( v1 == 15 )
v1 = 0;
colortable[v4] = v1 + 112;
if ( i > 7 )
break;
LABEL_9:
v4 += 16;
}
if ( ++v0 != 16 )
{
v1 = v0;
if ( v0 )
v1 = 8 * (v0 >= 8) + 7;
continue;
}
break;
}
result = colortable;
do
{
result[128] = *result | 0x80;
++result;
}
while ( &unk_920 != (_UNKNOWN *)result );
return result;
}

original_code:
void initcolortable(void)
{
    int color, fg, bg, fcolor, bcolor;
    struct text_info ti;
    gettextinfo(&ti);
    if (ti.currmode == C80) {
        for (color = 0; color <= 255; color++)
            colortable[color] = color;
    }
    else {
        for (fg = BLACK; fg <= WHITE; fg++) {
            if (fg == BLACK)
                fcolor = BLACK;
            else if (fg <= LIGHTGRAY)
                fcolor = LIGHTGRAY;
            else
                fcolor = WHITE;
            for (bg = BLACK; bg <= LIGHTGRAY; bg++) {
                if (bg == BLACK)
                    bcolor = BLACK;
                else {
                    if (fcolor == WHITE)
                        fcolor = BLACK;
                    bcolor = LIGHTGRAY;
                }
                colortable[fg + (bg << 4)] = fcolor + (bcolor << 4);
            }
        }
        for (fg = 128; fg <= 255; fg++)
            colortable[fg] = colortable[fg - 128] | 0x80;
    }
}

canonical_original_code:
void initcolortable()
{
    int color; int fg; int bg; int fcolor; int bcolor;
    struct text_info ti;
    gettextinfo(&ti);
    if (ti.currmode == C80) {
        for (color = 0; color <= 255; color++)
            colortable[color] = color;
    }
    else {
        for (fg = BLACK; fg <= WHITE; fg++) {
            if (fg == BLACK)
                fcolor = BLACK;
            else if (fg <= LIGHTGRAY)
                fcolor = LIGHTGRAY;
            else
                fcolor = WHITE;
            for (bg = BLACK; bg <= LIGHTGRAY; bg++) {
                if (bg == BLACK)
                    bcolor = BLACK;
                else {
                    if (fcolor == WHITE)
                        fcolor = BLACK;
                    bcolor = LIGHTGRAY;
                }
                colortable[fg + (bg << 4)] = fcolor + (bcolor << 4);
            }
        }
        for (fg = 128; fg <= 255; fg++)
            colortable[fg] = colortable[fg - 128] | 0x80;
    }
}

variable_types: color int

variable_types: fg int

variable_types: bg int

variable_types: fcolor int

variable_types: bcolor int

user_defined_types: struct text_info { unsigned char winleft; unsigned char wintop; unsigned char winright; unsigned char winbottom; unsigned char attribute; unsigned char normattr; unsigned char currmode; unsigned char screenheight; unsigned char screenwidth; unsigned char curx; unsigned char cury; }


isfunc

decompiled_code:
__int64 __fastcall isfunc(char *s1)
{
size_t v1; // r13
const char *v2; // r12
int v3; // edx
__int64 result; // rax

v1 = (int)strlen(s1);
v2 = input;
v3 = strncmp(s1, input, v1);
result = 0LL;
if ( !v3 )
{
strncpy(x, v2, v1);
x[v1] = 0;
input = (char *)&v2[v1];
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s1)
{
size_t v1; // r13
const char *v2; // r12
int v3; // edx
__int64 result; // rax

v1 = (int)strlen(s1);
v2 = input;
v3 = strncmp(s1, input, v1);
result = 0LL;
if ( !v3 )
{
strncpy(x, v2, v1);
x[v1] = 0;
input = (char *)&v2[v1];
result = 1LL;
}
return result;
}

original_code:
int isfunc(char *s)
{
    int len = strlen(s);
    if (strncmp(s, input, len) == 0) {
        strncpy(curtoken.x.funcname, input, len);
        curtoken.x.funcname[len] = 0;
        input += len;
        return(1);
    }
    return(0);
}

variable_types: len int


nexttoken

decompiled_code:
__int64 nexttoken()
{
char *v0; // r12
char v1; // bl
char *v2; // rax
__int64 result; // rax
const unsigned __int16 **v4; // r13
int v5; // ebp
int v6; // edx
char *v7; // rbx
char v8; // al
int v9; // edi
int v10; // edx
char *v11; // r8
char *v12; // rax
int v13; // edx
int v14; // edx
int v15; // edx
int v16; // edx
int v17; // edx
int v18; // edx
int v19; // edx
int v20; // edx
int v21; // edx
int v22; // edx
int v23; // edx
char v24[120]; // [rsp+0h] [rbp-78h] BYREF

v0 = input;
v1 = *input;
if ( *input == 32 )
{
v2 = input + 1;
do
{
v0 = v2;
input = v2++;
v1 = *(v2 - 1);
}
while ( v1 == 32 );
}
result = 11LL;
if ( v1 )
{
if ( strchr("0123456789.", v1) )
{
v4 = _ctype_b_loc();
v5 = 0;
v6 = 0;
while ( 1 )
{
v7 = input;
v8 = *input;
if ( ((*v4)[*input] & 0x800) != 0 )
{
if ( v8 == 46 )
v6 = 1;
}
else
{
if ( v8 != 46 || v6 )
{
if ( v5 == 1 && *v0 == 46 )
return 12LL;
if ( v8 == 69 )
{
++input;
v9 = v5 + 1;
if ( strchr("+-", v7[1]) )
{
input = v7 + 2;
v9 = v5 + 2;
}
v10 = (int)input;
if ( ((*v4)[*input] & 0x800) != 0 )
{
v11 = input + 3;
v12 = input;
do
{
input = ++v12;
v5 = v9 + (_DWORD)v12 - v10;
}
while ( ((*v4)[*v12] & 0x800) != 0 && v12 != v11 );
}
else
{
v5 = v9;
}
}
strncpy(v24, v0, v5);
v24[v5] = 0;
*(_QWORD *)x = atof(v24);
return 4 * (unsigned int)(*_errno_location() == 34) + 8;
}
v6 = 1;
}
++input;
++v5;
}
}
if ( ((*_ctype_b_loc())[v1] & 0x400) != 0 )
{
v13 = isfunc("ABS");
result = 10LL;
if ( !v13 )
{
v14 = isfunc("ACOS");
result = 10LL;
if ( !v14 )
{
v15 = isfunc("ASIN");
result = 10LL;
if ( !v15 )
{
v16 = isfunc("ATAN");
result = 10LL;
if ( !v16 )
{
v17 = isfunc("COSH");
result = 10LL;
if ( !v17 )
{
v18 = isfunc("COS");
result = 10LL;
if ( !v18 )
{
v19 = isfunc("EXP");
result = 10LL;
if ( !v19 )
{
v20 = isfunc("LOG10");
result = 10LL;
if ( !v20 )
{
v21 = isfunc("LOG");
result = 10LL;
if ( !v21 )
{
v22 = isfunc("POW10");
result = 10LL;
if ( !v22 )
{
if ( (unsigned int)isfunc("ROUND") )
{
result = 10LL;
}
else if ( (unsigned int)isfunc("SINH") )
{
result = 10LL;
}
else if ( (unsigned int)isfunc("SIN") )
{
result = 10LL;
}
else if ( (unsigned int)isfunc("SQRT") )
{
result = 10LL;
}
else if ( (unsigned int)isfunc("SQR") )
{
result = 10LL;
}
else if ( (unsigned int)isfunc("TANH") )
{
result = 10LL;
}
else if ( (unsigned int)isfunc("TAN") )
{
result = 10LL;
}
else if ( (unsigned int)isfunc("TRUNC") )
{
result = 10LL;
}
else
{
v23 = formulastart(&input, &x[4], x);
result = 12LL;
if ( v23 )
{
isformula = 1;
result = 9LL;
}
}
}
}
}
}
}
}
}
}
}
}
}
else
{
input = v0 + 1;
switch ( *v0 )
{
case '(':
result = 6LL;
break;
case ')':
result = 7LL;
break;
case '*':
result = 2LL;
break;
case '+':
result = 0LL;
break;
case '-':
result = 1LL;
break;
case '/':
result = 3LL;
break;
case ':':
result = 5LL;
break;
case '^':
result = 4LL;
break;
default:
result = 12LL;
break;
}
}
}
return result;
}

original_code:
int nexttoken(void)
{
    char *start, numstring[80];
    int decimal, len, numlen;
    while (*input == ' ')
        input++;
    if (*input == 0)
        return(11);
    if (strchr("0123456789.", *input)) {
        start = input;
        len = 0;
        decimal = 0;
        while ((((*__ctype_b_loc ())[(int) ((*input))] & (unsigned short int) _ISdigit)) ||
                ((*input == '.') && (!decimal))) {
            if (*input == '.')
                decimal = 1;
            input++;
            len++;
        }
        if ((len == 1) && (start[0] == '.'))
            return(12);
        if (*input == 'E') {
            input++;
            len++;
            if (strchr("+-", *input) != ((void *)0)) {
                input++;
                len++;
            }
            numlen = 0;
            while ((((*__ctype_b_loc ())[(int) ((*input))] & (unsigned short int) _ISdigit)) && (++numlen <= 3)) {
                input++;
                len++;
            }
        }
        strncpy(numstring, start, len);
        numstring[len] = 0;
        curtoken.x.value = atof(numstring);
        if ((*__errno_location ()) == 34)
            return(12);
        return(8);
    }
    else if (((*__ctype_b_loc ())[(int) ((*input))] & (unsigned short int) _ISalpha)) {
        if
            (isfunc("ABS") ||
             isfunc("ACOS") ||
             isfunc("ASIN") ||
             isfunc("ATAN") ||
             isfunc("COSH") ||
             isfunc("COS") ||
             isfunc("EXP") ||
             isfunc("LOG10") ||
             isfunc("LOG") ||
             isfunc("POW10") ||
             isfunc("ROUND") ||
             isfunc("SINH") ||
             isfunc("SIN") ||
             isfunc("SQRT") ||
             isfunc("SQR") ||
             isfunc("TANH") ||
             isfunc("TAN") ||
             isfunc("TRUNC"))
                return(10);
        if (formulastart(&input, &curtoken.x.c.col, &curtoken.x.c.row)) {
            isformula = 1;
            return(9);
        }
        else
            return(12);
    }
    else switch(*(input++)) {
        case '+' : return(0);
        case '-' : return(1);
        case '*' : return(2);
        case '/' : return(3);
        case '^' : return(4);
        case ':' : return(5);
        case '(' : return(6);
        case ')' : return(7);
        default : return(12);
    }
}

canonical_original_code:
int nexttoken()
{
    char *start; char numstring[80];
    int decimal; int len; int numlen;
    while (*input == ' ')
        input++;
    if (*input == 0)
        return(11);
    if (strchr("0123456789.", *input)) {
        start = input;
        len = 0;
        decimal = 0;
        while ((((*__ctype_b_loc ())[(int) ((*input))] & (unsigned short) _ISdigit)) ||
                ((*input == '.') && (!decimal))) {
            if (*input == '.')
                decimal = 1;
            input++;
            len++;
        }
        if ((len == 1) && (start[0] == '.'))
            return(12);
        if (*input == 'E') {
            input++;
            len++;
            if (strchr("+-", *input) != ((void *)0)) {
                input++;
                len++;
            }
            numlen = 0;
            while ((((*__ctype_b_loc ())[(int) ((*input))] & (unsigned short) _ISdigit)) && (++numlen <= 3)) {
                input++;
                len++;
            }
        }
        strncpy(numstring, start, len);
        numstring[len] = 0;
        curtoken.x.value = atof(numstring);
        if ((*__errno_location ()) == 34)
            return(12);
        return(8);
    }
    else if (((*__ctype_b_loc ())[(int) ((*input))] & (unsigned short) _ISalpha)) {
        if
            (isfunc("ABS") ||
             isfunc("ACOS") ||
             isfunc("ASIN") ||
             isfunc("ATAN") ||
             isfunc("COSH") ||
             isfunc("COS") ||
             isfunc("EXP") ||
             isfunc("LOG10") ||
             isfunc("LOG") ||
             isfunc("POW10") ||
             isfunc("ROUND") ||
             isfunc("SINH") ||
             isfunc("SIN") ||
             isfunc("SQRT") ||
             isfunc("SQR") ||
             isfunc("TANH") ||
             isfunc("TAN") ||
             isfunc("TRUNC"))
                return(10);
        if (formulastart(&input, &curtoken.x.c.col, &curtoken.x.c.row)) {
            isformula = 1;
            return(9);
        }
        else
            return(12);
    }
    else switch(*(input++)) {
        case '+' : return(0);
        case '-' : return(1);
        case '*' : return(2);
        case '/' : return(3);
        case '^' : return(4);
        case ':' : return(5);
        case '(' : return(6);
        case ')' : return(7);
        default : return(12);
    }
}

variable_types:
start
char *

variable_types:
numstring
char [80]

variable_types: decimal int

variable_types: numlen int


push

decompiled_code:
__int64 __fastcall push(const __m128i *a1)
{
int v1; // eax
__int64 result; // rax

v1 = stacktop;
if ( stacktop == 19 )
{
result = errormsg("Parser stack overflow.");
error = 1;
}
else
{
++stacktop;
result = 16LL * (v1 + 1);
*(__int128 *)((char *)&stack + result) = (__int128)_mm_loadu_si128(a1);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(const __m128i *a1)
{
int v1; // eax
__int64 result; // rax

v1 = stacktop;
if ( stacktop == 19 )
{
result = errormsg("Parser stack overflow.");
error = 1;
}
else
{
++stacktop;
result = 16LL * (v1 + 1);
*(__int128 *)((char *)&stack + result) = (__int128)_mm_loadu_si128(a1);
}
return result;
}

original_code:
void push(struct TOKENREC *token)
{
    if (stacktop == 20 - 1) {
        errormsg("Parser stack overflow.");
        error = 1;
    }
    else
        stack[++stacktop] = *token;
}

variable_types: struct TOKENREC { char state; union { double value; struct { int row; } c; char funcname[-1]; } x; } *


pop

decompiled_code:
__int64 pop()
{
int v0; // eax

v0 = stacktop--;
return (unsigned int)*(_QWORD *)&stack[v0];
}

canonical_decompiled_code:
__int64 func3()
{
int v0; // eax

v0 = stacktop--;
return (unsigned int)*(_QWORD *)&stack[v0];
}

original_code:
struct TOKENREC pop(void)
{
    return(stack[stacktop--]);
}

canonical_original_code:
struct TOKENREC pop()
{
    return(stack[stacktop--]);
}

return_type: struct TOKENREC { char state; union { double value; struct { int row; } c; char funcname[-1]; } x; }


gotostate

decompiled_code:
__int64 __fastcall gotostate(int a1)
{
unsigned __int8 v1; // cl
__int64 result; // rax

v1 = stack[stacktop];
if ( a1 > 3 )
{
if ( a1 > 6 )
{
if ( a1 > 8 )
{
if ( a1 > 10 )
{
if ( a1 > 12 )
{
switch ( v1 )
{
case 0u:
case 5u:
case 9u:
case 0xCu:
case 0xDu:
case 0xEu:
case 0xFu:
case 0x10u:
case 0x14u:
result = 8LL;
break;
default:
result = 30LL;
break;
}
}
else
{
switch ( v1 )
{
case 0u:
case 9u:
case 0xCu:
case 0xDu:
case 0xEu:
case 0xFu:
case 0x10u:
case 0x14u:
result = 6LL;
break;
case 5u:
result = 17LL;
break;
default:
result = 30LL;
break;
}
}
}
else if ( v1 > 0x14u )
{
result = 30LL;
}
else
{
result = ((1LL << v1) & 0x11F201) == 0 ? 30 : 4;
}
}
else
{
switch ( v1 )
{
case 0u:
case 9u:
case 0xCu:
case 0xDu:
case 0x14u:
result = 3LL;
break;
case 0xEu:
result = 23LL;
break;
case 0xFu:
result = 24LL;
break;
case 0x10u:
result = 25LL;
break;
default:
result = 30LL;
break;
}
}
}
else
{
switch ( v1 )
{
case 0u:
case 9u:
case 0x14u:
result = 2LL;
break;
case 0xCu:
result = 21LL;
break;
case 0xDu:
result = 22LL;
break;
default:
result = 30LL;
break;
}
}
}
else
{
result = 19LL;
if ( v1 != 9 )
{
result = 28LL;
if ( v1 != 20 )
result = v1 == 0 ? 1 : 30;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1)
{
unsigned __int8 v1; // cl
__int64 result; // rax

v1 = stack[stacktop];
if ( a1 > 3 )
{
if ( a1 > 6 )
{
if ( a1 > 8 )
{
if ( a1 > 10 )
{
if ( a1 > 12 )
{
switch ( v1 )
{
case 0u:
case 5u:
case 9u:
case 0xCu:
case 0xDu:
case 0xEu:
case 0xFu:
case 0x10u:
case 0x14u:
result = 8LL;
break;
default:
result = 30LL;
break;
}
}
else
{
switch ( v1 )
{
case 0u:
case 9u:
case 0xCu:
case 0xDu:
case 0xEu:
case 0xFu:
case 0x10u:
case 0x14u:
result = 6LL;
break;
case 5u:
result = 17LL;
break;
default:
result = 30LL;
break;
}
}
}
else if ( v1 > 0x14u )
{
result = 30LL;
}
else
{
result = ((1LL << v1) & 0x11F201) == 0 ? 30 : 4;
}
}
else
{
switch ( v1 )
{
case 0u:
case 9u:
case 0xCu:
case 0xDu:
case 0x14u:
result = 3LL;
break;
case 0xEu:
result = 23LL;
break;
case 0xFu:
result = 24LL;
break;
case 0x10u:
result = 25LL;
break;
default:
result = 30LL;
break;
}
}
}
else
{
switch ( v1 )
{
case 0u:
case 9u:
case 0x14u:
result = 2LL;
break;
case 0xCu:
result = 21LL;
break;
case 0xDu:
result = 22LL;
break;
default:
result = 30LL;
break;
}
}
}
else
{
result = 19LL;
if ( v1 != 9 )
{
result = 28LL;
if ( v1 != 20 )
result = v1 == 0 ? 1 : 30;
}
}
return result;
}

original_code:
int gotostate(int production)
{
    int state = stack[stacktop].state;
    if (production <= 3) {
        switch(state) {
            case 0 : return(1);
            case 9 : return(19);
            case 20 : return(28);
        }
    }
    else if (production <= 6) {
        switch(state) {
            case 0 :
            case 9 :
            case 20 : return(2);
            case 12 : return(21);
            case 13 : return(22);
        }
    }
    else if (production <= 8) {
        switch(state) {
            case 0 :
            case 9 :
            case 12 :
            case 13 :
            case 20 : return(3);
            case 14 : return(23);
            case 15 : return(24);
            case 16 : return(25);
        }
    }
    else if (production <= 10) {
        switch(state) {
            case 0 :
            case 9 :
            case 12 :
            case 13 :
            case 14 :
            case 15 :
            case 16 :
            case 20 : return(4);
        }
    }
    else if (production <= 12) {
        switch(state) {
            case 0 :
            case 9 :
            case 12 :
            case 13 :
            case 14 :
            case 15 :
            case 16 :
            case 20 : return(6);
            case 5 : return(17);
        }
    }
    else {
        switch(state) {
            case 0 :
            case 5 :
            case 9 :
            case 12 :
            case 13 :
            case 14 :
            case 15 :
            case 16 :
            case 20 : return(8);
        }
    }
    return(30);
}

variable_types: production int

variable_types: state int


cellvalue

decompiled_code:
double __fastcall cellvalue(int a1, int a2)
{
__int64 v2; // rax
double result; // xmm0_8

v2 = cell[100 * a1 + a2];
if ( !v2 )
return 0.0;
result = *(double *)&LC22;
if ( *(_BYTE *)v2 )
result = *(double *)(v2 + 8);
return result;
}

canonical_decompiled_code:
double __fastcall func5(int a1, int a2)
{
__int64 v2; // rax
double result; // xmm0_8

v2 = cell[100 * a1 + a2];
if ( !v2 )
return 0.0;
result = *(double *)&LC22;
if ( *(_BYTE *)v2 )
result = *(double *)(v2 + 8);
return result;
}

original_code:
double cellvalue(int col, int row)
{
    if (cell[col][row] == ((void *)0))
        return(0);
    if (cell[col][row]->attrib == 0)
        return((__builtin_huge_val ()));
    if (cell[col][row]->attrib == 2)
        return(cell[col][row]->v.f.fvalue);
    return(cell[col][row]->v.value);
}

variable_types: col int

variable_types: row int

return_type: double


shift

decompiled_code:
__int64 __fastcall shift(char a1)
{
__int64 result; // rax

LOBYTE(curtoken) = a1;
push((const __m128i *)&curtoken);
result = nexttoken();
tokentype = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(char a1)
{
__int64 result; // rax

LOBYTE(curtoken) = a1;
func2((const __m128i *)&curtoken);
result = func1();
tokentype = result;
return result;
}

original_code:
void shift(int state)
{
    curtoken.state = state;
    push(&curtoken);
    tokentype = nexttoken();
}


reduce

decompiled_code:
__int64 __fastcall reduce(int a1)
{
double v1; // rdx
double v2; // rdx
double v4; // rdx
double v5; // rdx
double v6; // rdx
double v7; // rdx
double v8; // rdx
double v9; // rdx
double v10; // rdx
double v11; // rdx
double v12; // rdx
double v13; // rdx
int v14; // edx
int v15; // rdx^4
int v16; // ebp
int v17; // ebp
__int64 v18; // rdx
__int64 v19; // rdx
__int64 v20; // rdx
double v21; // rdx
__int64 v22; // rdx
double y[6]; // [rsp+18h] [rbp-30h] BYREF

switch ( a1 )
{
case 1:
pop();
y[0] = v1;
pop();
pop();
*(double *)x = y[0] + v2;
break;
case 2:
pop();
y[0] = v4;
pop();
pop();
*(double *)x = v5 - y[0];
break;
case 3:
case 6:
case 8:
case 10:
case 12:
case 15:
curtoken = pop();
*(_QWORD *)x = v22;
break;
case 4:
pop();
y[0] = v6;
pop();
pop();
*(double *)x = y[0] * v7;
break;
case 5:
pop();
y[0] = v8;
pop();
pop();
if ( y[0] == 0.0 )
*(_QWORD *)x = LC22;
else
*(double *)x = v9 / y[0];
break;
case 7:
pop();
y[0] = v10;
pop();
pop();
*(_QWORD *)x = pow(v11, y[0]);
break;
case 9:
pop();
y[0] = v12;
pop();
*(_QWORD *)x = *(_QWORD *)&y[0] ^ LC23;
break;
case 11:
pop();
y[0] = v13;
pop();
pop();
v16 = v14;
*(_QWORD *)x = 0LL;
if ( LODWORD(y[0]) == v14 )
{
v17 = v15;
if ( SHIDWORD(y[0]) < v15 )
{
error = 1;
}
else
{
do
*(double *)x = cellvalue(v17++, SLODWORD(y[0])) + *(double *)x;
while ( v17 != HIDWORD(y[0]) + 1 );
}
}
else if ( HIDWORD(y[0]) == v15 )
{
if ( SLODWORD(y[0]) < v14 )
{
error = 1;
}
else
{
do
*(double *)x = cellvalue(SHIDWORD(y[0]), v16++) + *(double *)x;
while ( LODWORD(y[0]) + 1 != v16 );
}
}
else
{
error = 1;
}
break;
case 13:
curtoken = pop();
*(_QWORD *)x = v18;
*(_QWORD *)x = cellvalue(SHIDWORD(v18), v18);
break;
case 14:
pop();
curtoken = pop();
*(_QWORD *)x = v19;
pop();
break;
case 16:
pop();
curtoken = pop();
*(_QWORD *)x = v20;
pop();
pop();
y[0] = v21;
if ( !strcmp((const char *)y, "ABS") )
{
*(_QWORD *)x &= LC24;
}
else if ( !strcmp((const char *)y, "ACOS") )
{
*(_QWORD *)x = acos(*(double *)x);
}
else if ( !strcmp((const char *)y, "ASIN") )
{
*(_QWORD *)x = asin(*(double *)x);
}
else if ( !strcmp((const char *)y, "ATAN") )
{
*(_QWORD *)x = atan(*(double *)x);
}
else if ( !strcmp((const char *)y, "COSH") )
{
*(_QWORD *)x = cosh(*(double *)x);
}
else if ( !strcmp((const char *)y, "COS") )
{
*(_QWORD *)x = cos(*(double *)x);
}
else if ( !strcmp((const char *)y, "EXP") )
{
*(_QWORD *)x = exp(*(double *)x);
}
else if ( !strcmp((const char *)y, "LOG10") )
{
*(_QWORD *)x = log10(*(double *)x);
}
else if ( !strcmp((const char *)y, "LOG") )
{
*(_QWORD *)x = log(*(double *)x);
}
else if ( !strcmp((const char *)y, "ROUND") )
{
*(double *)x = (double)(int)(*(double *)x + 0.5);
}
else if ( !strcmp((const char *)y, "POW10") )
{
*(_QWORD *)x = pow10(*(double *)x);
}
else if ( !strcmp((const char *)y, "SINH") )
{
*(_QWORD *)x = sinh(*(double *)x);
}
else if ( !strcmp((const char *)y, "SIN") )
{
*(_QWORD *)x = sin(*(double *)x);
}
else if ( !strcmp((const char *)y, "SQRT") )
{
*(_QWORD *)x = sqrt(*(double *)x);
}
else if ( !strcmp((const char *)y, "SQR") )
{
*(double *)x = *(double *)x * *(double *)x;
}
else if ( !strcmp((const char *)y, "TANH") )
{
*(_QWORD *)x = tanh(*(double *)x);
}
else if ( !strcmp((const char *)y, "TAN") )
{
*(_QWORD *)x = tan(*(double *)x);
}
else if ( !strcmp((const char *)y, "TRUNC") )
{
*(double *)x = (double)(int)*(double *)x;
}
break;
default:
break;
}
LOBYTE(curtoken) = gotostate(a1);
return push((const __m128i *)&curtoken);
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1)
{
double v1; // rdx
double v2; // rdx
double v4; // rdx
double v5; // rdx
double v6; // rdx
double v7; // rdx
double v8; // rdx
double v9; // rdx
double v10; // rdx
double v11; // rdx
double v12; // rdx
double v13; // rdx
int v14; // edx
int v15; // rdx^4
int v16; // ebp
int v17; // ebp
__int64 v18; // rdx
__int64 v19; // rdx
__int64 v20; // rdx
double v21; // rdx
__int64 v22; // rdx
double y[6]; // [rsp+18h] [rbp-30h] BYREF

switch ( a1 )
{
case 1:
func3();
y[0] = v1;
func3();
func3();
*(double *)x = y[0] + v2;
break;
case 2:
func3();
y[0] = v4;
func3();
func3();
*(double *)x = v5 - y[0];
break;
case 3:
case 6:
case 8:
case 10:
case 12:
case 15:
curtoken = func3();
*(_QWORD *)x = v22;
break;
case 4:
func3();
y[0] = v6;
func3();
func3();
*(double *)x = y[0] * v7;
break;
case 5:
func3();
y[0] = v8;
func3();
func3();
if ( y[0] == 0.0 )
*(_QWORD *)x = LC22;
else
*(double *)x = v9 / y[0];
break;
case 7:
func3();
y[0] = v10;
func3();
func3();
*(_QWORD *)x = pow(v11, y[0]);
break;
case 9:
func3();
y[0] = v12;
func3();
*(_QWORD *)x = *(_QWORD *)&y[0] ^ LC23;
break;
case 11:
func3();
y[0] = v13;
func3();
func3();
v16 = v14;
*(_QWORD *)x = 0LL;
if ( LODWORD(y[0]) == v14 )
{
v17 = v15;
if ( SHIDWORD(y[0]) < v15 )
{
error = 1;
}
else
{
do
*(double *)x = func5(v17++, SLODWORD(y[0])) + *(double *)x;
while ( v17 != HIDWORD(y[0]) + 1 );
}
}
else if ( HIDWORD(y[0]) == v15 )
{
if ( SLODWORD(y[0]) < v14 )
{
error = 1;
}
else
{
do
*(double *)x = func5(SHIDWORD(y[0]), v16++) + *(double *)x;
while ( LODWORD(y[0]) + 1 != v16 );
}
}
else
{
error = 1;
}
break;
case 13:
curtoken = func3();
*(_QWORD *)x = v18;
*(_QWORD *)x = func5(SHIDWORD(v18), v18);
break;
case 14:
func3();
curtoken = func3();
*(_QWORD *)x = v19;
func3();
break;
case 16:
func3();
curtoken = func3();
*(_QWORD *)x = v20;
func3();
func3();
y[0] = v21;
if ( !strcmp((const char *)y, "ABS") )
{
*(_QWORD *)x &= LC24;
}
else if ( !strcmp((const char *)y, "ACOS") )
{
*(_QWORD *)x = acos(*(double *)x);
}
else if ( !strcmp((const char *)y, "ASIN") )
{
*(_QWORD *)x = asin(*(double *)x);
}
else if ( !strcmp((const char *)y, "ATAN") )
{
*(_QWORD *)x = atan(*(double *)x);
}
else if ( !strcmp((const char *)y, "COSH") )
{
*(_QWORD *)x = cosh(*(double *)x);
}
else if ( !strcmp((const char *)y, "COS") )
{
*(_QWORD *)x = cos(*(double *)x);
}
else if ( !strcmp((const char *)y, "EXP") )
{
*(_QWORD *)x = exp(*(double *)x);
}
else if ( !strcmp((const char *)y, "LOG10") )
{
*(_QWORD *)x = log10(*(double *)x);
}
else if ( !strcmp((const char *)y, "LOG") )
{
*(_QWORD *)x = log(*(double *)x);
}
else if ( !strcmp((const char *)y, "ROUND") )
{
*(double *)x = (double)(int)(*(double *)x + 0.5);
}
else if ( !strcmp((const char *)y, "POW10") )
{
*(_QWORD *)x = pow10(*(double *)x);
}
else if ( !strcmp((const char *)y, "SINH") )
{
*(_QWORD *)x = sinh(*(double *)x);
}
else if ( !strcmp((const char *)y, "SIN") )
{
*(_QWORD *)x = sin(*(double *)x);
}
else if ( !strcmp((const char *)y, "SQRT") )
{
*(_QWORD *)x = sqrt(*(double *)x);
}
else if ( !strcmp((const char *)y, "SQR") )
{
*(double *)x = *(double *)x * *(double *)x;
}
else if ( !strcmp((const char *)y, "TANH") )
{
*(_QWORD *)x = tanh(*(double *)x);
}
else if ( !strcmp((const char *)y, "TAN") )
{
*(_QWORD *)x = tan(*(double *)x);
}
else if ( !strcmp((const char *)y, "TRUNC") )
{
*(double *)x = (double)(int)*(double *)x;
}
break;
default:
break;
}
LOBYTE(curtoken) = func4(a1);
return func2((const __m128i *)&curtoken);
}

original_code:
void reduce(int reduction)
{
    struct TOKENREC token1, token2;
    int counter;
    switch (reduction) {
        case 1 :
            token1 = pop();
            pop();
            token2 = pop();
            curtoken.x.value = token1.x.value + token2.x.value;
            break;
        case 2 :
            token1 = pop();
            pop();
            token2 = pop();
            curtoken.x.value = token2.x.value - token1.x.value;
            break;
        case 4 :
            token1 = pop();
            pop();
            token2 = pop();
            curtoken.x.value = token1.x.value * token2.x.value;
            break;
        case 5 :
            token1 = pop();
            pop();
            token2 = pop();
            if (token1.x.value == 0)
                curtoken.x.value = (__builtin_huge_val ());
            else
                curtoken.x.value = token2.x.value / token1.x.value;
            break;
        case 7 :
            token1 = pop();
            pop();
            token2 = pop();
            curtoken.x.value = pow(token2.x.value, token1.x.value);
            break;
        case 9 :
            token1 = pop();
            pop();
            curtoken.x.value = -token1.x.value;
            break;
        case 11 :
            token1 = pop();
            pop();
            token2 = pop();
            curtoken.x.value = 0;
            if (token1.x.c.row == token2.x.c.row) {
                if (token1.x.c.col < token2.x.c.col)
                    error = 1;
                else {
                    for (counter = token2.x.c.col; counter <= token1.x.c.col; counter++)
                        curtoken.x.value += cellvalue(counter, token1.x.c.row);
                }
            }
            else if (token1.x.c.col == token2.x.c.col) {
                if (token1.x.c.row < token2.x.c.row)
                    error = 1;
                else {
                    for (counter = token2.x.c.row; counter <= token1.x.c.row; counter++)
                        curtoken.x.value += cellvalue(token1.x.c.col, counter);
                }
            }
            else
                error = 1;
            break;
        case 13 :
            curtoken = pop();
            curtoken.x.value = cellvalue(curtoken.x.c.col, curtoken.x.c.row);
            break;
        case 14 :
            pop();
            curtoken = pop();
            pop();
            break;
        case 16 :
            pop();
            curtoken = pop();
            pop();
            token1 = pop();
            if (strcmp(token1.x.funcname, "ABS") == 0)
                curtoken.x.value = fabs(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "ACOS") == 0)
                curtoken.x.value = acos(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "ASIN") == 0)
                curtoken.x.value = asin(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "ATAN") == 0)
                curtoken.x.value = atan(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "COSH") == 0)
                curtoken.x.value = cosh(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "COS") == 0)
                curtoken.x.value = cos(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "EXP") == 0)
                curtoken.x.value = exp(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "LOG10") == 0)
                curtoken.x.value = log10(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "LOG") == 0)
                curtoken.x.value = log(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "ROUND") == 0)
                curtoken.x.value = (int)(curtoken.x.value + 0.5);
            else if (strcmp(token1.x.funcname, "POW10") == 0)
                curtoken.x.value = pow10(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "SINH") == 0)
                curtoken.x.value = sinh(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "SIN") == 0)
                curtoken.x.value = sin(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "SQRT") == 0)
                curtoken.x.value = sqrt(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "SQR") == 0)
                curtoken.x.value *= curtoken.x.value;
            else if (strcmp(token1.x.funcname, "TANH") == 0)
                curtoken.x.value = tanh(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "TAN") == 0)
                curtoken.x.value = tan(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "TRUNC") == 0)
                curtoken.x.value = (int)curtoken.x.value;
            break;
        case 3 :
        case 6 :
        case 8 :
        case 10 :
        case 12 :
        case 15 :
            curtoken = pop();
            break;
    }
    curtoken.state = gotostate(reduction);
    push(&curtoken);
}

canonical_original_code:
void reduce(int reduction)
{
    struct TOKENREC token1; struct TOKENREC token2;
    int counter;
    switch (reduction) {
        case 1 :
            token1 = pop();
            pop();
            token2 = pop();
            curtoken.x.value = token1.x.value + token2.x.value;
            break;
        case 2 :
            token1 = pop();
            pop();
            token2 = pop();
            curtoken.x.value = token2.x.value - token1.x.value;
            break;
        case 4 :
            token1 = pop();
            pop();
            token2 = pop();
            curtoken.x.value = token1.x.value * token2.x.value;
            break;
        case 5 :
            token1 = pop();
            pop();
            token2 = pop();
            if (token1.x.value == 0)
                curtoken.x.value = (__builtin_huge_val ());
            else
                curtoken.x.value = token2.x.value / token1.x.value;
            break;
        case 7 :
            token1 = pop();
            pop();
            token2 = pop();
            curtoken.x.value = pow(token2.x.value, token1.x.value);
            break;
        case 9 :
            token1 = pop();
            pop();
            curtoken.x.value = -token1.x.value;
            break;
        case 11 :
            token1 = pop();
            pop();
            token2 = pop();
            curtoken.x.value = 0;
            if (token1.x.c.row == token2.x.c.row) {
                if (token1.x.c.col < token2.x.c.col)
                    error = 1;
                else {
                    for (counter = token2.x.c.col; counter <= token1.x.c.col; counter++)
                        curtoken.x.value += cellvalue(counter, token1.x.c.row);
                }
            }
            else if (token1.x.c.col == token2.x.c.col) {
                if (token1.x.c.row < token2.x.c.row)
                    error = 1;
                else {
                    for (counter = token2.x.c.row; counter <= token1.x.c.row; counter++)
                        curtoken.x.value += cellvalue(token1.x.c.col, counter);
                }
            }
            else
                error = 1;
            break;
        case 13 :
            curtoken = pop();
            curtoken.x.value = cellvalue(curtoken.x.c.col, curtoken.x.c.row);
            break;
        case 14 :
            pop();
            curtoken = pop();
            pop();
            break;
        case 16 :
            pop();
            curtoken = pop();
            pop();
            token1 = pop();
            if (strcmp(token1.x.funcname, "ABS") == 0)
                curtoken.x.value = fabs(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "ACOS") == 0)
                curtoken.x.value = acos(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "ASIN") == 0)
                curtoken.x.value = asin(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "ATAN") == 0)
                curtoken.x.value = atan(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "COSH") == 0)
                curtoken.x.value = cosh(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "COS") == 0)
                curtoken.x.value = cos(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "EXP") == 0)
                curtoken.x.value = exp(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "LOG10") == 0)
                curtoken.x.value = log10(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "LOG") == 0)
                curtoken.x.value = log(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "ROUND") == 0)
                curtoken.x.value = (int)(curtoken.x.value + 0.5);
            else if (strcmp(token1.x.funcname, "POW10") == 0)
                curtoken.x.value = pow10(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "SINH") == 0)
                curtoken.x.value = sinh(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "SIN") == 0)
                curtoken.x.value = sin(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "SQRT") == 0)
                curtoken.x.value = sqrt(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "SQR") == 0)
                curtoken.x.value *= curtoken.x.value;
            else if (strcmp(token1.x.funcname, "TANH") == 0)
                curtoken.x.value = tanh(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "TAN") == 0)
                curtoken.x.value = tan(curtoken.x.value);
            else if (strcmp(token1.x.funcname, "TRUNC") == 0)
                curtoken.x.value = (int)curtoken.x.value;
            break;
        case 3 :
        case 6 :
        case 8 :
        case 10 :
        case 12 :
        case 15 :
            curtoken = pop();
            break;
    }
    curtoken.state = gotostate(reduction);
    push(&curtoken);
}

variable_types: reduction int

variable_types: struct TOKENREC { char state; union { double value; struct { int row; } c; char funcname[-1]; } x; }

variable_types: counter int