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

if ( !a2 )
return 1LL;
if ( *a2 != a1 )
return one_lft(a1, (__int64)a2, a3);
result = one_lft(a1, *((_QWORD *)a2 + 2), a3);
if ( (_DWORD)result )
result = all_lfts(a1, *((_QWORD *)a2 + 3), a3);
return result;
}

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

if ( !a2 )
return 1LL;
if ( *a2 != a1 )
return func8(a1, (__int64)a2, a3);
result = func8(a1, *((_QWORD *)a2 + 2), a3);
if ( (_DWORD)result )
result = func9(a1, *((_QWORD *)a2 + 3), a3);
return result;
}

original_code:
int
all_lfts(int ntyp, Node *from, Node *in)
{
 if (!from) return 1;
 if (from->ntyp != ntyp)
  return one_lft(ntyp, from, in);
 if (!one_lft(ntyp, from->lft, in))
  return 0;
 return all_lfts(ntyp, from->rgt, in);
}

canonical_original_code:
int all_lfts(int ntyp, struct Node *from, struct Node *in)
{
 if (!from) return 1;
 if (from->ntyp != ntyp)
  return one_lft(ntyp, from, in);
 if (!one_lft(ntyp, from->lft, in))
  return 0;
 return all_lfts(ntyp, from->rgt, in);
}


sametrees

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

result = all_lfts(a1, a2, a3);
if ( (_DWORD)result )
result = all_lfts(a1, a3, a2);
return result;
}

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

result = func9(a1, a2, a3);
if ( (_DWORD)result )
result = func9(a1, a3, a2);
return result;
}

original_code:
int
sametrees(int ntyp, Node *a, Node *b)
{
 if (!all_lfts(ntyp, a, b))
  return 0;
 return all_lfts(ntyp, b, a);
}

canonical_original_code:
int sametrees(int ntyp, struct Node *a, struct Node *b)
{
 if (!all_lfts(ntyp, a, b))
  return 0;
 return all_lfts(ntyp, b, a);
}

variable_types: ntyp int

variable_types: struct Node { short ntyp; struct Symbol { char *name; struct Symbol *next; } *sym; struct Node *lft; struct Node *rgt; struct Node *nxt; } *

variable_types:
b
struct Node *

return_type: int

user_defined_types: struct Node { short ntyp; struct Symbol *sym; struct Node *lft; struct Node *rgt; struct Node *nxt; }


isequal

decompiled_code:
__int64 __fastcall isequal(__int128 a1)
{
__int64 result; // rax
const char **v2; // rax
const char **v3; // rdx
int v4; // edx
int v5; // edx

result = 1LL;
if ( a1 != 0 )
{
if ( (_QWORD)a1 && *((_QWORD *)&a1 + 1) )
{
result = 0LL;
if ( *(_WORD *)a1 == **((_WORD **)&a1 + 1) )
{
v2 = *(const char ***)(a1 + 8);
if ( !v2
|| (v3 = *(const char ***)(*((_QWORD *)&a1 + 1) + 8LL)) == 0LL
|| (v4 = strcmp(*v2, *v3), result = 0LL, !v4) )
{
if ( !(unsigned int)isequal(*(_QWORD *)(a1 + 16), *(_QWORD *)(*((_QWORD *)&a1 + 1) + 16LL))
|| (v5 = isequal(*(_QWORD *)(a1 + 24), *(_QWORD *)(*((_QWORD *)&a1 + 1) + 24LL)), result = 1LL, !v5) )
{
result = sameform(a1);
}
}
}
}
else if ( (_QWORD)a1 )
{
result = *(_WORD *)a1 == 266;
}
else
{
result = **((_WORD **)&a1 + 1) == 266;
}
}
return result;
}

original_code:
int
isequal(Node *a, Node *b)
{
 if (!a && !b)
  return 1;
 if (!a || !b)
 { if (!a)
  { if (b->ntyp == TRUE)
    return 1;
  } else
  { if (a->ntyp == TRUE)
    return 1;
  }
  return 0;
 }
 if (a->ntyp != b->ntyp)
  return 0;
 if (a->sym
 && b->sym
 && strcmp(a->sym->name, b->sym->name) != 0)
  return 0;
 if (isequal(a->lft, b->lft)
 && isequal(a->rgt, b->rgt))
  return 1;
 return sameform(a, b);
}

canonical_original_code:
int isequal(struct Node *a, struct Node *b)
{
 if (!a && !b)
  return 1;
 if (!a || !b)
 { if (!a)
  { if (b->ntyp == TRUE)
    return 1;
  } else
  { if (a->ntyp == TRUE)
    return 1;
  }
  return 0;
 }
 if (a->ntyp != b->ntyp)
  return 0;
 if (a->sym
 && b->sym
 && strcmp(a->sym->name, b->sym->name) != 0)
  return 0;
 if (isequal(a->lft, b->lft)
 && isequal(a->rgt, b->rgt))
  return 1;
 return sameform(a, b);
}

user_defined_types: struct Symbol { char *name; struct Symbol *next; }


decompiled_code:
__int64 __fastcall in_cache(__int64 a1)
{
__int64 v2; // rbx
__int128 v3; // rdi
__int128 v5; // rdi

v2 = stored;
if ( stored )
{
while ( 1 )
{
*((_QWORD *)&v3 + 1) = a1;
*(_QWORD *)&v3 = *(_QWORD *)v2;
if ( (unsigned int)isequal(v3) )
break;
v2 = *(_QWORD *)(v2 + 24);
if ( !v2 )
return v2;
}
++CacheHits;
if ( *(_DWORD *)(v2 + 16) && (*((_QWORD *)&v5 + 1) = *(_QWORD *)v2, *(_QWORD *)&v5 = a1, (unsigned int)ismatch(v5)) )
v2 = a1;
else
v2 = dupnode(*(_QWORD *)(v2 + 8));
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1)
{
__int64 v2; // rbx
__int128 v3; // rdi
__int128 v5; // rdi

v2 = stored;
if ( stored )
{
while ( 1 )
{
*((_QWORD *)&v3 + 1) = a1;
*(_QWORD *)&v3 = *(_QWORD *)v2;
if ( (unsigned int)func11(v3) )
break;
v2 = *(_QWORD *)(v2 + 24);
if ( !v2 )
return v2;
}
++CacheHits;
if ( *(_DWORD *)(v2 + 16) && (*((_QWORD *)&v5 + 1) = *(_QWORD *)v2, *(_QWORD *)&v5 = a1, (unsigned int)func0(v5)) )
v2 = a1;
else
v2 = func6(*(_QWORD *)(v2 + 8));
}
return v2;
}

original_code:
Node *
in_cache(Node *n)
{ Cache *d; int nr=0;
 for (d = stored; d; d = d->nxt, nr++)
  if (isequal(d->before, n))
  { CacheHits++;
   if (d->same && ismatch(n, d->before)) return n;
   return dupnode(d->after);
  }
 return (Node *)0;
}

canonical_original_code:
struct Node *in_cache(struct Node *n)
{ struct Cache *d; int nr = 0;
 for (d = stored; d; d = d->nxt, nr++)
  if (isequal(d->before, n))
  { CacheHits++;
   if (d->same && ismatch(n, d->before)) return n;
   return dupnode(d->after);
  }
 return (struct Node *)0;
}

variable_types:
n
struct Node *

variable_types: struct Cache { struct Node { short ntyp; struct Symbol { char *name; struct Symbol *next; } *sym; struct Node *lft; struct Node *rgt; struct Node *nxt; } *before; struct Node *after; int same; struct Cache *nxt; } *

variable_types: nr int

user_defined_types: struct Cache { struct Node *before; struct Node *after; int same; struct Cache *nxt; }


cached

decompiled_code:
__int64 __fastcall cached(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rbp
__int64 v3; // rbx
__int128 v4; // rdi

result = a1;
if ( a1 )
{
result = in_cache(a1);
if ( !result )
{
++Caches;
v2 = tl_emalloc(32LL);
*(_QWORD *)v2 = dupnode(a1);
v3 = Canonical(a1);
*(_QWORD *)(v2 + 8) = v3;
*((_QWORD *)&v4 + 1) = v3;
*(_QWORD *)&v4 = *(_QWORD *)v2;
if ( (unsigned int)ismatch(v4) )
{
*(_DWORD *)(v2 + 16) = 1;
releasenode(1, v3);
*(_QWORD *)(v2 + 8) = *(_QWORD *)v2;
}
*(_QWORD *)(v2 + 24) = stored;
stored = v2;
result = dupnode(*(_QWORD *)(v2 + 8));
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1)
{
__int64 result; // rax
__int64 v2; // rbp
__int64 v3; // rbx
__int128 v4; // rdi

result = a1;
if ( a1 )
{
result = func12(a1);
if ( !result )
{
++Caches;
v2 = tl_emalloc(32LL);
*(_QWORD *)v2 = func6(a1);
v3 = Canonical(a1);
*(_QWORD *)(v2 + 8) = v3;
*((_QWORD *)&v4 + 1) = v3;
*(_QWORD *)&v4 = *(_QWORD *)v2;
if ( (unsigned int)func0(v4) )
{
*(_DWORD *)(v2 + 16) = 1;
func3(1, v3);
*(_QWORD *)(v2 + 8) = *(_QWORD *)v2;
}
*(_QWORD *)(v2 + 24) = stored;
stored = v2;
result = func6(*(_QWORD *)(v2 + 8));
}
}
return result;
}

original_code:
Node *
cached(Node *n)
{ Cache *d;
 Node *m;
 if (!n) return n;
 if (m = in_cache(n))
  return m;
 Caches++;
 d = (Cache *) tl_emalloc(sizeof(Cache));
 d->before = dupnode(n);
 d->after = Canonical(n);
 if (ismatch(d->before, d->after))
 { d->same = 1;
  releasenode(1, d->after);
  d->after = d->before;
 }
 d->nxt = stored;
 stored = d;
 return dupnode(d->after);
}

canonical_original_code:
struct Node *cached(struct Node *n)
{ struct Cache *d;
 struct Node *m;
 if (!n) return n;
 if (m = in_cache(n))
  return m;
 Caches++;
 d = (struct Cache *) tl_emalloc(sizeof(Cache));
 d->before = dupnode(n);
 d->after = Canonical(n);
 if (ismatch(d->before, d->after))
 { d->same = 1;
  releasenode(1, d->after);
  d->after = d->before;
 }
 d->nxt = stored;
 stored = d;
 return dupnode(d->after);
}

return_type: struct Node { short ntyp; struct Symbol { char *name; struct Symbol *next; } *sym; struct Node *lft; struct Node *rgt; struct Node *nxt; } *


decompiled_code:
__int64 __fastcall any_term(__int64 a1, __int64 a2)
{
__int128 v3; // rdi
__int64 result; // rax
int v5; // edx

if ( !a2 )
return 0LL;
if ( *(_WORD *)a2 == 258 )
{
v5 = any_term(a1, *(_QWORD *)(a2 + 16));
result = 1LL;
if ( !v5 )
result = (unsigned int)any_term(a1, *(_QWORD *)(a2 + 24)) != 0;
}
else
{
*((_QWORD *)&v3 + 1) = a1;
*(_QWORD *)&v3 = a2;
result = isequal(v3);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, __int64 a2)
{
__int128 v3; // rdi
__int64 result; // rax
int v5; // edx

if ( !a2 )
return 0LL;
if ( *(_WORD *)a2 == 258 )
{
v5 = func14(a1, *(_QWORD *)(a2 + 16));
result = 1LL;
if ( !v5 )
result = (unsigned int)func14(a1, *(_QWORD *)(a2 + 24)) != 0;
}
else
{
*((_QWORD *)&v3 + 1) = a1;
*(_QWORD *)&v3 = a2;
result = func11(v3);
}
return result;
}

original_code:
int
any_term(Node *srch, Node *in)
{
 if (!in) return 0;
 if (in->ntyp == AND)
  return any_term(srch, in->lft) ||
   any_term(srch, in->rgt);
 return isequal(in, srch);
}

canonical_original_code:
int any_term(struct Node *srch, struct Node *in)
{
 if (!in) return 0;
 if (in->ntyp == AND)
  return any_term(srch, in->lft) ||
   any_term(srch, in->rgt);
 return isequal(in, srch);
}

variable_types:
in
struct Node *


decompiled_code:
__int64 __fastcall any_and(__int64 a1, __int64 a2)
{
__int64 result; // rax

if ( !a2 )
return 0LL;
if ( *(_WORD *)a1 != 258 )
return any_term(a1, a2);
result = any_and(*(_QWORD *)(a1 + 16));
if ( (_DWORD)result )
result = (unsigned int)any_and(*(_QWORD *)(a1 + 24)) != 0;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1, __int64 a2)
{
__int64 result; // rax

if ( !a2 )
return 0LL;
if ( *(_WORD *)a1 != 258 )
return func14(a1, a2);
result = func15(*(_QWORD *)(a1 + 16));
if ( (_DWORD)result )
result = (unsigned int)func15(*(_QWORD *)(a1 + 24)) != 0;
return result;
}

original_code:
int
any_and(Node *srch, Node *in)
{
 if (!in) return 0;
 if (srch->ntyp == AND)
  return any_and(srch->lft, in) &&
   any_and(srch->rgt, in);
 return any_term(srch, in);
}

canonical_original_code:
int any_and(struct Node *srch, struct Node *in)
{
 if (!in) return 0;
 if (srch->ntyp == AND)
  return any_and(srch->lft, in) &&
   any_and(srch->rgt, in);
 return any_term(srch, in);
}


decompiled_code:
__int64 __fastcall any_lor(__int64 a1, __int64 a2)
{
__int128 v3; // rdi
__int64 result; // rax
int v5; // edx

if ( !a2 )
return 0LL;
if ( *(_WORD *)a2 == 264 )
{
v5 = any_lor(a1, *(_QWORD *)(a2 + 16));
result = 1LL;
if ( !v5 )
result = (unsigned int)any_lor(a1, *(_QWORD *)(a2 + 24)) != 0;
}
else
{
*((_QWORD *)&v3 + 1) = a1;
*(_QWORD *)&v3 = a2;
result = isequal(v3);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1, __int64 a2)
{
__int128 v3; // rdi
__int64 result; // rax
int v5; // edx

if ( !a2 )
return 0LL;
if ( *(_WORD *)a2 == 264 )
{
v5 = func16(a1, *(_QWORD *)(a2 + 16));
result = 1LL;
if ( !v5 )
result = (unsigned int)func16(a1, *(_QWORD *)(a2 + 24)) != 0;
}
else
{
*((_QWORD *)&v3 + 1) = a1;
*(_QWORD *)&v3 = a2;
result = func11(v3);
}
return result;
}

original_code:
int
any_lor(Node *srch, Node *in)
{
 if (!in) return 0;
 if (in->ntyp == OR)
  return any_lor(srch, in->lft) ||
   any_lor(srch, in->rgt);
 return isequal(in, srch);
}

canonical_original_code:
int any_lor(struct Node *srch, struct Node *in)
{
 if (!in) return 0;
 if (in->ntyp == OR)
  return any_lor(srch, in->lft) ||
   any_lor(srch, in->rgt);
 return isequal(in, srch);
}


anywhere

decompiled_code:
__int64 __fastcall anywhere(int a1, __int64 a2, __int64 a3)
{
if ( !a3 )
return 0LL;
switch ( a1 )
{
case 258:
return any_and(a2, a3);
case 264:
return any_lor(a2, a3);
case 0:
return any_term(a2, a3);
}
fatal("cannot happen, anywhere", 0LL);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func17(int a1, __int64 a2, __int64 a3)
{
if ( !a3 )
return 0LL;
switch ( a1 )
{
case 258:
return func15(a2, a3);
case 264:
return func16(a2, a3);
case 0:
return func14(a2, a3);
}
fatal("cannot happen, anywhere", 0LL);
return 0LL;
}

original_code:
int
anywhere(int tok, Node *srch, Node *in)
{
 if (!in) return 0;
 switch (tok) {
 case AND: return any_and(srch, in);
 case OR: return any_lor(srch, in);
 case 0: return any_term(srch, in);
 }
 fatal("cannot happen, anywhere", (char *) 0);
 return 0;
}

canonical_original_code:
int anywhere(int tok, struct Node *srch, struct Node *in)
{
 if (!in) return 0;
 switch (tok) {
 case AND: return any_and(srch, in);
 case OR: return any_lor(srch, in);
 case 0: return any_term(srch, in);
 }
 fatal("cannot happen, anywhere", (char *) 0);
 return 0;
}

variable_types: tok int


repo: sluchin/calc

decompiled_code:
__int64 __fastcall set_hostname(struct in_addr *a1, const char *a2)
{
struct hostent *v3; // rax
__int64 v4; // rax
struct in_addr inp; // [rsp+0h] [rbp-1Ch] BYREF

if ( !a1 )
return 0xFFFFFFFFLL;
if ( !a2 )
return 0xFFFFFFFFLL;
inp.s_addr = 0;
if ( !inet_aton(a2, &inp) )
{
v3 = gethostbyname(a2);
if ( !v3 )
{
v4 = get_progname();
system_log(6LL, 1LL, v4, "net.c", 70LL, "set_hostname", "gethostbyname: host=%s", a2);
return 0xFFFFFFFFLL;
}
memcpy(&inp, *(const void **)v3->h_addr_list, v3->h_length);
}
a1[1].s_addr = inp.s_addr;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(struct in_addr *a1, const char *a2)
{
struct hostent *v3; // rax
__int64 v4; // rax
struct in_addr inp; // [rsp+0h] [rbp-1Ch] BYREF

if ( !a1 )
return 0xFFFFFFFFLL;
if ( !a2 )
return 0xFFFFFFFFLL;
inp.s_addr = 0;
if ( !inet_aton(a2, &inp) )
{
v3 = gethostbyname(a2);
if ( !v3 )
{
v4 = get_progname();
system_log(6LL, 1LL, v4, "net.c", 70LL, "set_hostname", "gethostbyname: host=%s", a2);
return 0xFFFFFFFFLL;
}
memcpy(&inp, *(const void **)v3->h_addr_list, v3->h_length);
}
a1[1].s_addr = inp.s_addr;
return 0LL;
}

original_code:
int
set_hostname(struct sockaddr_in *addr, const char *host)
{
    struct hostent *hp = ((void *)0);
    struct in_addr s_addr;
    int retval = 0;
    do { } while (0);
    if (!addr || !host)
        return EX_NG;
    (void)memset(&s_addr, 0, sizeof(struct in_addr));
    retval = inet_aton(host, &s_addr);
    if (!retval) {
        do { } while (0);
        hp = gethostbyname(host);
        if (!hp) {
            system_log(6, 0x01, get_progname(), "net.c", 70, __FUNCTION__, "gethostbyname: host=%s", host);
            return EX_NG;
        }
        do { } while (0);
        (void)memcpy(&s_addr, (struct in_addr *)*hp->h_addr_list,
                     hp->h_length);
    }
    (void)memcpy(&addr->sin_addr, &s_addr, sizeof(struct in_addr));
    do { } while (0);
    return EX_OK;
}

canonical_original_code:
int set_hostname(struct sockaddr_in *addr, char *host)
{
    struct hostent *hp = ((void *)0);
    struct in_addr s_addr;
    int retval = 0;
    do { } while (0);
    if (!addr || !host)
        return EX_NG;
    (void)memset(&s_addr, 0, sizeof(struct in_addr));
    retval = inet_aton(host, &s_addr);
    if (!retval) {
        do { } while (0);
        hp = gethostbyname(host);
        if (!hp) {
            system_log(6, 0x01, get_progname(), "net.c", 70, __FUNCTION__, "gethostbyname: host=%s", host);
            return EX_NG;
        }
        do { } while (0);
        (void)memcpy(&s_addr, (struct in_addr *)*hp->h_addr_list,
                     hp->h_length);
    }
    (void)memcpy(&addr->sin_addr, &s_addr, sizeof(struct in_addr));
    do { } while (0);
    return EX_OK;
}

variable_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; } *

variable_types:
host
char *

variable_types: struct hostent { char *h_name; char **h_aliases; int h_addrtype; int h_length; char **h_addr_list; } *

variable_types: retval int

user_defined_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr sin_addr; unsigned char sin_zero[-1]; }


decompiled_code:
__int64 __fastcall set_port(__int64 a1, const char *a2)
{
unsigned __int16 v2; // bx
__int64 result; // rax
__int64 v4; // rax
struct servent *v5; // rax
__int64 v6; // rax

if ( !a1 )
return 0xFFFFFFFFLL;
if ( !a2 )
return 0xFFFFFFFFLL;
if ( ((*_ctype_b_loc())[*a2] & 0x800) != 0 )
{
v2 = strtol(a2, 0LL, 10);
if ( (unsigned __int16)(v2 - 1) > 0xFFFDu )
{
v4 = get_progname();
system_log(6LL, 1LL, v4, "net.c", 111LL, "set_port", "portno=%d", v2);
result = 0xFFFFFFFFLL;
}
else
{
*(_WORD *)(a1 + 2) = _bswap_16(v2);
result = 0LL;
}
}
else
{
v5 = getservbyname(a2, "tcp");
if ( v5 )
{
*(_WORD *)(a1 + 2) = v5->s_port;
result = 0LL;
}
else
{
v6 = get_progname();
system_log(6LL, 1LL, v6, "net.c", 119LL, "set_port", "getservbyname: port=%s", a2);
result = 0xFFFFFFFFLL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, const char *a2)
{
unsigned __int16 v2; // bx
__int64 result; // rax
__int64 v4; // rax
struct servent *v5; // rax
__int64 v6; // rax

if ( !a1 )
return 0xFFFFFFFFLL;
if ( !a2 )
return 0xFFFFFFFFLL;
if ( ((*_ctype_b_loc())[*a2] & 0x800) != 0 )
{
v2 = strtol(a2, 0LL, 10);
if ( (unsigned __int16)(v2 - 1) > 0xFFFDu )
{
v4 = get_progname();
system_log(6LL, 1LL, v4, "net.c", 111LL, "set_port", "portno=%d", v2);
result = 0xFFFFFFFFLL;
}
else
{
*(_WORD *)(a1 + 2) = func0(v2);
result = 0LL;
}
}
else
{
v5 = getservbyname(a2, "tcp");
if ( v5 )
{
*(_WORD *)(a1 + 2) = v5->s_port;
result = 0LL;
}
else
{
v6 = get_progname();
system_log(6LL, 1LL, v6, "net.c", 119LL, "set_port", "getservbyname: port=%s", a2);
result = 0xFFFFFFFFLL;
}
}
return result;
}

original_code:
int
set_port(struct sockaddr_in *addr, const char *port)
{
    struct servent *sp = ((void *)0);
    uint16_t portno = 0;
    const int base = 10;
    do { } while (0);
    if (!addr || !port)
        return EX_NG;
    if (((*__ctype_b_loc ())[(int) ((port[0]))] & (unsigned short int) _ISdigit)) {
        portno = (uint16_t)strtol(port, ((void *)0), base);
        do { } while (0);
        if (portno <= 0 || 65535 <= portno) {
            system_log(6, 0x01, get_progname(), "net.c", 111, __FUNCTION__, "portno=%d", portno);
            return EX_NG;
        }
        do { } while (0);
        addr->sin_port = (u_short)htons(portno);
    } else {
        sp = getservbyname(port, "tcp");
        if (!sp) {
            system_log(6, 0x01, get_progname(), "net.c", 119, __FUNCTION__, "getservbyname: port=%s", port);
            return EX_NG;
        }
        addr->sin_port = sp->s_port;
    }
    do { } while (0);
    return EX_OK;
}

canonical_original_code:
int set_port(struct sockaddr_in *addr, char *port)
{
    struct servent *sp = ((void *)0);
    unsigned short portno = 0;
    int base = 10;
    do { } while (0);
    if (!addr || !port)
        return EX_NG;
    if (((*__ctype_b_loc ())[(int) ((port[0]))] & (unsigned short) _ISdigit)) {
        portno = (unsigned short)strtol(port, ((void *)0), base);
        do { } while (0);
        if (portno <= 0 || 65535 <= portno) {
            system_log(6, 0x01, get_progname(), "net.c", 111, __FUNCTION__, "portno=%d", portno);
            return EX_NG;
        }
        do { } while (0);
        addr->sin_port = (unsigned short)htons(portno);
    } else {
        sp = getservbyname(port, "tcp");
        if (!sp) {
            system_log(6, 0x01, get_progname(), "net.c", 119, __FUNCTION__, "getservbyname: port=%s", port);
            return EX_NG;
        }
        addr->sin_port = sp->s_port;
    }
    do { } while (0);
    return EX_OK;
}

variable_types:
port
char *

variable_types: struct servent { char *s_name; char **s_aliases; int s_port; char *s_proto; } *

variable_types:
portno
unsigned short

variable_types: base int


decompiled_code:
__int64 __fastcall set_block(int fd, unsigned int a2)
{
int v2; // eax
__int64 v3; // rbx
__int64 v4; // rdx
__int64 v5; // rbx
__int64 result; // rax
__int64 v7; // rax
__int64 v8; // rbx
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax

v2 = fcntl(fd, 3, 0LL);
v3 = (unsigned int)v2;
if ( v2 < 0 )
{
v7 = get_progname();
system_log(6LL, 1LL, v7, "net.c", 143LL, "set_block", "fcntl=0x%x", v3);
result = 0xFFFFFFFFLL;
}
else if ( a2 )
{
if ( a2 == 1 )
{
v4 = (unsigned int)v2;
BYTE1(v4) = BYTE1(v2) & 0xF7;
v5 = (unsigned int)fcntl(fd, 4, v4);
result = 0LL;
if ( (int)v5 < 0 )
{
v10 = get_progname();
system_log(6LL, 1LL, v10, "net.c", 155LL, "set_block", "fcntl=%d", v5);
result = 0LL;
}
}
else
{
v11 = get_progname();
system_log(6LL, 1LL, v11, "net.c", 157LL, "set_block", "mode=%d", a2);
result = 0xFFFFFFFFLL;
}
}
else
{
BYTE1(v3) = BYTE1(v2) | 8;
v8 = (unsigned int)fcntl(fd, 4, (unsigned int)v3);
result = 0LL;
if ( (int)v8 < 0 )
{
v9 = get_progname();
system_log(6LL, 1LL, v9, "net.c", 151LL, "set_block", "fcntl=%d", v8);
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(int fd, unsigned int a2)
{
int v2; // eax
__int64 v3; // rbx
__int64 v4; // rdx
__int64 v5; // rbx
__int64 result; // rax
__int64 v7; // rax
__int64 v8; // rbx
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax

v2 = fcntl(fd, 3, 0LL);
v3 = (unsigned int)v2;
if ( v2 < 0 )
{
v7 = get_progname();
system_log(6LL, 1LL, v7, "net.c", 143LL, "set_block", "fcntl=0x%x", v3);
result = 0xFFFFFFFFLL;
}
else if ( a2 )
{
if ( a2 == 1 )
{
v4 = (unsigned int)v2;
BYTE1(v4) = BYTE1(v2) & 0xF7;
v5 = (unsigned int)fcntl(fd, 4, v4);
result = 0LL;
if ( (int)v5 < 0 )
{
v10 = get_progname();
system_log(6LL, 1LL, v10, "net.c", 155LL, "set_block", "fcntl=%d", v5);
result = 0LL;
}
}
else
{
v11 = get_progname();
system_log(6LL, 1LL, v11, "net.c", 157LL, "set_block", "mode=%d", a2);
result = 0xFFFFFFFFLL;
}
}
else
{
BYTE1(v3) = BYTE1(v2) | 8;
v8 = (unsigned int)fcntl(fd, 4, (unsigned int)v3);
result = 0LL;
if ( (int)v8 < 0 )
{
v9 = get_progname();
system_log(6LL, 1LL, v9, "net.c", 151LL, "set_block", "fcntl=%d", v8);
result = 0LL;
}
}
return result;
}

original_code:
int
set_block(int fd, blockmode mode)
{
    int flags = 0;
    int retval = 0;
    flags = fcntl(fd, 3, 0);
    if (flags < 0) {
        system_log(6, 0x01, get_progname(), "net.c", 143, __FUNCTION__, "fcntl=0x%x", flags);
        return EX_NG;
    }
    do { } while (0);
    if (mode == NONBLOCK) {
        retval = fcntl(fd, 4, flags | 04000);
        if (retval < 0)
            system_log(6, 0x01, get_progname(), "net.c", 151, __FUNCTION__, "fcntl=%d", retval);
    } else if (mode == BLOCKING) {
        retval = fcntl(fd, 4, flags & ~04000);
        if (retval < 0)
            system_log(6, 0x01, get_progname(), "net.c", 155, __FUNCTION__, "fcntl=%d", retval);
    } else {
        system_log(6, 0x01, get_progname(), "net.c", 157, __FUNCTION__, "mode=%d", mode);
        return EX_NG;
    }
    return EX_OK;
}

canonical_original_code:
int set_block(int fd, enum _blockmode mode)
{
    int flags = 0;
    int retval = 0;
    flags = fcntl(fd, 3, 0);
    if (flags < 0) {
        system_log(6, 0x01, get_progname(), "net.c", 143, __FUNCTION__, "fcntl=0x%x", flags);
        return EX_NG;
    }
    do { } while (0);
    if (mode == NONBLOCK) {
        retval = fcntl(fd, 4, flags | 04000);
        if (retval < 0)
            system_log(6, 0x01, get_progname(), "net.c", 151, __FUNCTION__, "fcntl=%d", retval);
    } else if (mode == BLOCKING) {
        retval = fcntl(fd, 4, flags & ~04000);
        if (retval < 0)
            system_log(6, 0x01, get_progname(), "net.c", 155, __FUNCTION__, "fcntl=%d", retval);
    } else {
        system_log(6, 0x01, get_progname(), "net.c", 157, __FUNCTION__, "mode=%d", mode);
        return EX_NG;
    }
    return EX_OK;
}

variable_types: fd int

variable_types: enum _blockmode { NONBLOCK=0, BLOCKING=1 }

variable_types: flags int


decompiled_code:
__int64 __fastcall send_data(int fd, void *buf, size_t *a3)
{
size_t v3; // rbp
char *v5; // r12
ssize_t v6; // rbx
int v7; // eax
size_t v8; // r14
__int64 v9; // rax

v3 = *a3;
if ( *a3 )
{
v5 = (char *)buf;
do
{
v6 = send(fd, buf, *a3, 0);
if ( v6 <= 0 )
{
v7 = *_errno_location();
if ( v7 != 4 && v7 != 11 )
{
v8 = *a3 - v3;
*a3 = v8;
v9 = get_progname();
system_log(
6LL,
1LL,
v9,
"net.c",
210LL,
"send_data",
"send=%zd, sock=%d, ptr=%p, left=%zu, length=%zu",
v6,
(unsigned int)fd,
v5,
v3,
v8);
return 0xFFFFFFFFLL;
}
v6 = 0LL;
}
v5 += v6;
v3 -= v6;
}
while ( v3 );
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(int fd, void *buf, size_t *a3)
{
size_t v3; // rbp
char *v5; // r12
ssize_t v6; // rbx
int v7; // eax
size_t v8; // r14
__int64 v9; // rax

v3 = *a3;
if ( *a3 )
{
v5 = (char *)buf;
do
{
v6 = send(fd, buf, *a3, 0);
if ( v6 <= 0 )
{
v7 = *_errno_location();
if ( v7 != 4 && v7 != 11 )
{
v8 = *a3 - v3;
*a3 = v8;
v9 = get_progname();
system_log(
6LL,
1LL,
v9,
"net.c",
210LL,
"send_data",
"send=%zd, sock=%d, ptr=%p, left=%zu, length=%zu",
v6,
(unsigned int)fd,
v5,
v3,
v8);
return 0xFFFFFFFFLL;
}
v6 = 0LL;
}
v5 += v6;
v3 -= v6;
}
while ( v3 );
}
return 0LL;
}

original_code:
int
send_data(const int sock, const void *sdata, size_t *length)
{
    ssize_t len = 0;
    size_t left = 0;
    const unsigned char *ptr = ((void *)0);
    do { } while (0);
    ptr = (unsigned char *)sdata;
    left = *length;
    while (left > 0) {
        len = send(sock, sdata, *length, 0);
        do { } while (0);
        if (len <= 0) {
            if (((*__errno_location ()) == 4) ||
                ((*__errno_location ()) == 11) || ((*__errno_location ()) == 11))
                len = 0;
            else
                goto error_handler;
        }
        left -= len;
        ptr += len;
    }
    *length -= left;
    do { } while (0);
    return EX_OK;
error_handler:
    *length -= left;
    system_log(6, 0x01, get_progname(), "net.c", 210, __FUNCTION__, "send=%zd, sock=%d, ptr=%p, left=%zu, length=%zu", len, sock, ptr, left, *length);
    return EX_NG;
}

canonical_original_code:
int send_data(int sock, void *sdata, unsigned long *length)
{
    long len = 0;
    unsigned long left = 0;
    unsigned char *ptr = ((void *)0);
    do { } while (0);
    ptr = (unsigned char *)sdata;
    left = *length;
    while (left > 0) {
        len = send(sock, sdata, *length, 0);
        do { } while (0);
        if (len <= 0) {
            if (((*__errno_location ()) == 4) ||
                ((*__errno_location ()) == 11) || ((*__errno_location ()) == 11))
                len = 0;
            else
                goto error_handler;
        }
        left -= len;
        ptr += len;
    }
    *length -= left;
    do { } while (0);
    return EX_OK;
error_handler:
    *length -= left;
    system_log(6, 0x01, get_progname(), "net.c", 210, __FUNCTION__, "send=%zd, sock=%d, ptr=%p, left=%zu, length=%zu", len, sock, ptr, left, *length);
    return EX_NG;
}

variable_types: sock int

variable_types:
sdata
void *

variable_types:
length
unsigned long *

variable_types: len long

variable_types:
left
unsigned long

variable_types:
ptr
unsigned char *


decompiled_code:
__int64 __fastcall recv_data(int fd, void *buf, size_t *a3)
{
size_t v5; // rbp
int v7; // eax
ssize_t v8; // rax
ssize_t v9; // rbx
__int64 v10; // rax
size_t v11; // r15
__int64 v12; // rax

v5 = *a3;
if ( !*a3 )
return 0LL;
while ( 1 )
{
v8 = recv(fd, buf, v5, 0);
v9 = v8;
if ( v8 >= 0 )
break;
v7 = *_errno_location();
if ( v7 != 4 && v7 != 11 )
goto LABEL_10;
LABEL_5:
if ( !v5 )
return 0LL;
}
if ( v8 )
{
v5 -= v8;
buf = (char *)buf + v8;
goto LABEL_5;
}
v10 = get_progname();
system_log(6LL, 1LL, v10, "net.c", 244LL, "recv_data", "The socket is not connected.");
LABEL_10:
v11 = *a3 - v5;
*a3 = v11;
v12 = get_progname();
system_log(
6LL,
1LL,
v12,
"net.c",
258LL,
"recv_data",
"recv=%zd, sock=%d, ptr=%p, left=%zu, length=%zu",
v9,
(unsigned int)fd,
buf,
v5,
v11);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func5(int fd, void *buf, size_t *a3)
{
size_t v5; // rbp
int v7; // eax
ssize_t v8; // rax
ssize_t v9; // rbx
__int64 v10; // rax
size_t v11; // r15
__int64 v12; // rax

v5 = *a3;
if ( !*a3 )
return 0LL;
while ( 1 )
{
v8 = recv(fd, buf, v5, 0);
v9 = v8;
if ( v8 >= 0 )
break;
v7 = *_errno_location();
if ( v7 != 4 && v7 != 11 )
goto LABEL_10;
LABEL_5:
if ( !v5 )
return 0LL;
}
if ( v8 )
{
v5 -= v8;
buf = (char *)buf + v8;
goto LABEL_5;
}
v10 = get_progname();
system_log(6LL, 1LL, v10, "net.c", 244LL, "recv_data", "The socket is not connected.");
LABEL_10:
v11 = *a3 - v5;
*a3 = v11;
v12 = get_progname();
system_log(
6LL,
1LL,
v12,
"net.c",
258LL,
"recv_data",
"recv=%zd, sock=%d, ptr=%p, left=%zu, length=%zu",
v9,
(unsigned int)fd,
buf,
v5,
v11);
return 0xFFFFFFFFLL;
}

original_code:
int
recv_data(const int sock, void *rdata, size_t *length)
{
    ssize_t len = 0;
    size_t left = 0;
    unsigned char *ptr = ((void *)0);
    do { } while (0);
    ptr = (unsigned char *)rdata;
    left = *length;
    while (left > 0) {
        len = recv(sock, ptr, left, 0);
        do { } while (0);
        if (len < 0) {
            if (((*__errno_location ()) == 4) ||
                ((*__errno_location ()) == 11) || ((*__errno_location ()) == 11))
                len = 0;
            else
                goto error_handler;
        } else if (len == 0) {
            system_log(6, 0x01, get_progname(), "net.c", 244, __FUNCTION__, "The socket is not connected.");
            goto error_handler;
        } else {
            left -= len;
            ptr += len;
        }
    }
    *length -= left;
    do { } while (0);
    return EX_OK;
error_handler:
    *length -= left;
    system_log(6, 0x01, get_progname(), "net.c", 258, __FUNCTION__, "recv=%zd, sock=%d, ptr=%p, left=%zu, length=%zu", len, sock, ptr, left, *length);
    return EX_NG;
}

canonical_original_code:
int recv_data(int sock, void *rdata, unsigned long *length)
{
    long len = 0;
    unsigned long left = 0;
    unsigned char *ptr = ((void *)0);
    do { } while (0);
    ptr = (unsigned char *)rdata;
    left = *length;
    while (left > 0) {
        len = recv(sock, ptr, left, 0);
        do { } while (0);
        if (len < 0) {
            if (((*__errno_location ()) == 4) ||
                ((*__errno_location ()) == 11) || ((*__errno_location ()) == 11))
                len = 0;
            else
                goto error_handler;
        } else if (len == 0) {
            system_log(6, 0x01, get_progname(), "net.c", 244, __FUNCTION__, "The socket is not connected.");
            goto error_handler;
        } else {
            left -= len;
            ptr += len;
        }
    }
    *length -= left;
    do { } while (0);
    return EX_OK;
error_handler:
    *length -= left;
    system_log(6, 0x01, get_progname(), "net.c", 258, __FUNCTION__, "recv=%zd, sock=%d, ptr=%p, left=%zu, length=%zu", len, sock, ptr, left, *length);
    return EX_NG;
}

variable_types:
rdata
void *


decompiled_code:
void *__fastcall recv_data_new(int fd, size_t *a2)
{
size_t v2; // rbp
void *v3; // rax
void *v4; // rbx
__int64 v6; // rax
size_t v7[6]; // [rsp+8h] [rbp-30h] BYREF

v2 = *a2;
v7[0] = v2;
v3 = malloc(v2);
v4 = v3;
if ( v3 )
{
memset(v3, 0, v2);
if ( (int)recv_data(fd, v4, v7) < 0 )
*a2 = 0LL;
else
*a2 = v7[0];
}
else
{
v6 = get_progname();
system_log(6LL, 1LL, v6, "net.c", 285LL, "recv_data_new", "malloc: len= %zu", v2);
}
return v4;
}

canonical_decompiled_code:
void *__fastcall func6(int fd, size_t *a2)
{
size_t v2; // rbp
void *v3; // rax
void *v4; // rbx
__int64 v6; // rax
size_t v7[6]; // [rsp+8h] [rbp-30h] BYREF

v2 = *a2;
v7[0] = v2;
v3 = malloc(v2);
v4 = v3;
if ( v3 )
{
memset(v3, 0, v2);
if ( (int)func5(fd, v4, v7) < 0 )
*a2 = 0LL;
else
*a2 = v7[0];
}
else
{
v6 = get_progname();
system_log(6LL, 1LL, v6, "net.c", 285LL, "recv_data_new", "malloc: len= %zu", v2);
}
return v4;
}

original_code:
void *
recv_data_new(const int sock, size_t *length)
{
    size_t len = *length;
    int retval = 0;
    void *rdata = ((void *)0);
    do { } while (0);
    rdata = malloc(len);
    if (!rdata) {
        system_log(6, 0x01, get_progname(), "net.c", 285, __FUNCTION__, "malloc: len= %zu", len);
        return ((void *)0);
    }
    (void)memset(rdata, 0, len);
    retval = recv_data(sock, rdata, &len);
    if (retval < 0) {
        *length = 0;
        return rdata;
    }
    *length = len;
    return rdata;
}

canonical_original_code:
void *recv_data_new(int sock, unsigned long *length)
{
    unsigned long len = *length;
    int retval = 0;
    void *rdata = ((void *)0);
    do { } while (0);
    rdata = malloc(len);
    if (!rdata) {
        system_log(6, 0x01, get_progname(), "net.c", 285, __FUNCTION__, "malloc: len= %zu", len);
        return ((void *)0);
    }
    (void)memset(rdata, 0, len);
    retval = recv_data(sock, rdata, &len);
    if (retval < 0) {
        *length = 0;
        return rdata;
    }
    *length = len;
    return rdata;
}

variable_types:
len
unsigned long

return_type: void *


decompiled_code:
__int64 __fastcall close_sock(_DWORD *a1)
{
__int64 v1; // rbp
__int64 result; // rax
__int64 v3; // rax

v1 = (unsigned int)*a1;
result = 0LL;
if ( (int)v1 >= 0 )
{
if ( close(v1) < 0 )
{
v3 = get_progname();
system_log(6LL, 1LL, v3, "net.c", 321LL, "close_sock", "close: sockfd=%d", v1);
result = 0xFFFFFFFFLL;
}
else
{
*a1 = -1;
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(_DWORD *a1)
{
__int64 v1; // rbp
__int64 result; // rax
__int64 v3; // rax

v1 = (unsigned int)*a1;
result = 0LL;
if ( (int)v1 >= 0 )
{
if ( close(v1) < 0 )
{
v3 = get_progname();
system_log(6LL, 1LL, v3, "net.c", 321LL, "close_sock", "close: sockfd=%d", v1);
result = 0xFFFFFFFFLL;
}
else
{
*a1 = -1;
result = 0LL;
}
}
return result;
}

original_code:
int
close_sock(int *sock)
{
    int retval = 0;
    const int sockfd = *sock;
    do { } while (0);
    if (sockfd < 0)
        return EX_OK;
    retval = close(sockfd);
    if (retval < 0) {
        system_log(6, 0x01, get_progname(), "net.c", 321, __FUNCTION__, "close: sockfd=%d", sockfd);
        return EX_NG;
    }
    *sock = -1;
    return EX_OK;
}

canonical_original_code:
int close_sock(int *sock)
{
    int retval = 0;
    int sockfd = *sock;
    do { } while (0);
    if (sockfd < 0)
        return EX_OK;
    retval = close(sockfd);
    if (retval < 0) {
        system_log(6, 0x01, get_progname(), "net.c", 321, __FUNCTION__, "close: sockfd=%d", sockfd);
        return EX_NG;
    }
    *sock = -1;
    return EX_OK;
}

variable_types:
sock
int *

variable_types: sockfd int


readn

decompiled_code:
size_t __fastcall readn(int fd, void *buf, size_t nbytes)
{
size_t v3; // r13
size_t v5; // rbx
ssize_t v6; // rax

v3 = nbytes;
if ( nbytes )
{
v5 = nbytes;
while ( 1 )
{
v6 = read(fd, buf, v5);
if ( v6 < 0 )
{
if ( *_errno_location() != 4 )
return -1LL;
v6 = 0LL;
}
else if ( !v6 )
{
return v3 - v5;
}
buf = (char *)buf + v6;
v5 -= v6;
if ( !v5 )
return v3 - v5;
}
}
v5 = 0LL;
return v3 - v5;
}

canonical_decompiled_code:
size_t __fastcall func0(int fd, void *buf, size_t nbytes)
{
size_t v3; // r13
size_t v5; // rbx
ssize_t v6; // rax

v3 = nbytes;
if ( nbytes )
{
v5 = nbytes;
while ( 1 )
{
v6 = read(fd, buf, v5);
if ( v6 < 0 )
{
if ( *_errno_location() != 4 )
return -1LL;
v6 = 0LL;
}
else if ( !v6 )
{
return v3 - v5;
}
buf = (char *)buf + v6;
v5 -= v6;
if ( !v5 )
return v3 - v5;
}
}
v5 = 0LL;
return v3 - v5;
}

original_code:
ssize_t
readn(int fd, void *vptr, size_t n)
{
    size_t nleft = 0;
    ssize_t nread = 0;
    char *ptr = ((void *)0);
    ptr = (char *)vptr;
    nleft = n;
    while (nleft > 0) {
        nread = read(fd, ptr, nleft);
        if (nread < 0) {
            if ((*__errno_location ()) == 4)
                nread = 0;
            else
                return EX_NG;
        } else if (nread == 0) {
            break;
        }
        nleft -= nread;
        ptr += nread;
    }
    return n - nleft;
}

canonical_original_code:
long readn(int fd, void *vptr, unsigned long n)
{
    unsigned long nleft = 0;
    long nread = 0;
    char *ptr = ((void *)0);
    ptr = (char *)vptr;
    nleft = n;
    while (nleft > 0) {
        nread = read(fd, ptr, nleft);
        if (nread < 0) {
            if ((*__errno_location ()) == 4)
                nread = 0;
            else
                return EX_NG;
        } else if (nread == 0) {
            break;
        }
        nleft -= nread;
        ptr += nread;
    }
    return n - nleft;
}

variable_types:
vptr
void *

variable_types:
n
unsigned long

variable_types:
nleft
unsigned long

variable_types: nread long

variable_types:
ptr
char *

return_type: long


writen

decompiled_code:
size_t __fastcall writen(int fd, void *buf, size_t n)
{
size_t v3; // r13
size_t v5; // rbx
ssize_t v6; // rax

v3 = n;
if ( !n )
return v3;
v5 = n;
while ( 1 )
{
v6 = write(fd, buf, v5);
if ( v6 <= 0 )
break;
LABEL_3:
buf = (char *)buf + v6;
v5 -= v6;
if ( !v5 )
return v3;
}
if ( *_errno_location() == 4 )
{
v6 = 0LL;
goto LABEL_3;
}
return -1LL;
}

canonical_decompiled_code:
size_t __fastcall func1(int fd, void *buf, size_t n)
{
size_t v3; // r13
size_t v5; // rbx
ssize_t v6; // rax

v3 = n;
if ( !n )
return v3;
v5 = n;
while ( 1 )
{
v6 = write(fd, buf, v5);
if ( v6 <= 0 )
break;
LABEL_3:
buf = (char *)buf + v6;
v5 -= v6;
if ( !v5 )
return v3;
}
if ( *_errno_location() == 4 )
{
v6 = 0LL;
goto LABEL_3;
}
return -1LL;
}

original_code:
ssize_t
writen(int fd, const void *vptr, size_t n)
{
    size_t nleft = 0;
    ssize_t nwritten = 0;
    const char *ptr = ((void *)0);
    ptr = (char *)vptr;
    nleft = n;
    while (nleft > 0) {
        nwritten = write(fd, ptr, nleft);
        if (nwritten <= 0) {
            if ((*__errno_location ()) == 4)
                nwritten = 0;
            else
                return EX_NG;
        }
        nleft -= nwritten;
        ptr += nwritten;
    }
    return n;
}

canonical_original_code:
long writen(int fd, void *vptr, unsigned long n)
{
    unsigned long nleft = 0;
    long nwritten = 0;
    char *ptr = ((void *)0);
    ptr = (char *)vptr;
    nleft = n;
    while (nleft > 0) {
        nwritten = write(fd, ptr, nleft);
        if (nwritten <= 0) {
            if ((*__errno_location ()) == 4)
                nwritten = 0;
            else
                return EX_NG;
        }
        nleft -= nwritten;
        ptr += nwritten;
    }
    return n;
}

variable_types: fd int

variable_types: nwritten long


decompiled_code:
__int64 __fastcall pipe_fd(int fd2, double a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9)
{
double v9; // xmm4_8
double v10; // xmm5_8
__int64 result; // rax
__int64 v12; // rax
__int64 v13; // rax
__int64 v14; // rbp
__int64 v15; // rax
double v16; // xmm4_8
double v17; // xmm5_8
int pipedes[2]; // [rsp+8h] [rbp-20h] BYREF

pipedes[0] = -1;
pipedes[1] = -1;
if ( fd2 < 0 )
return 0xFFFFFFFFLL;
if ( pipe(pipedes) < 0 )
{
v12 = get_progname();
system_log(6LL, 1LL, v12, "fileio.c", 122LL, "pipe_fd", "pipe: pfd=%p", pipedes);
result = 0xFFFFFFFFLL;
}
else if ( close(fd2) < 0 )
{
v13 = get_progname();
system_log(6LL, 1LL, v13, "fileio.c", 128LL, "pipe_fd", "close: fd=%d", (unsigned int)fd2);
result = 0xFFFFFFFFLL;
}
else if ( dup2(pipedes[1], fd2) < 0 )
{
v14 = (unsigned int)pipedes[1];
v15 = get_progname();
system_log(6LL, 1LL, v15, "fileio.c", 134LL, "pipe_fd", "dup2: pfd[PIPE_W]=%d, fd=%d", v14, (unsigned int)fd2);
close_fd(pipedes, a2, a3, a4, a5, v16, v17, a8, a9, &pipedes[1], 0LL);
result = 0xFFFFFFFFLL;
}
else
{
close_fd(&pipedes[1], a2, a3, a4, a5, v9, v10, a8, a9, 0LL);
result = (unsigned int)pipedes[0];
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(int fd2, double a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9)
{
double v9; // xmm4_8
double v10; // xmm5_8
__int64 result; // rax
__int64 v12; // rax
__int64 v13; // rax
__int64 v14; // rbp
__int64 v15; // rax
double v16; // xmm4_8
double v17; // xmm5_8
int pipedes[2]; // [rsp+8h] [rbp-20h] BYREF

pipedes[0] = -1;
pipedes[1] = -1;
if ( fd2 < 0 )
return 0xFFFFFFFFLL;
if ( pipe(pipedes) < 0 )
{
v12 = get_progname();
system_log(6LL, 1LL, v12, "fileio.c", 122LL, "pipe_fd", "pipe: pfd=%p", pipedes);
result = 0xFFFFFFFFLL;
}
else if ( close(fd2) < 0 )
{
v13 = get_progname();
system_log(6LL, 1LL, v13, "fileio.c", 128LL, "pipe_fd", "close: fd=%d", (unsigned int)fd2);
result = 0xFFFFFFFFLL;
}
else if ( dup2(pipedes[1], fd2) < 0 )
{
v14 = (unsigned int)pipedes[1];
v15 = get_progname();
system_log(6LL, 1LL, v15, "fileio.c", 134LL, "pipe_fd", "dup2: pfd[PIPE_W]=%d, fd=%d", v14, (unsigned int)fd2);
func3(pipedes, a2, a3, a4, a5, v16, v17, a8, a9, &pipedes[1], 0LL);
result = 0xFFFFFFFFLL;
}
else
{
func3(&pipedes[1], a2, a3, a4, a5, v9, v10, a8, a9, 0LL);
result = (unsigned int)pipedes[0];
}
return result;
}

original_code:
int
pipe_fd(const int fd)
{
    int pfd[] = {-1, -1};
    int retval = 0;
    int newfd = 0;
    if (fd < 0)
        return EX_NG;
    retval = pipe(pfd);
    if (retval < 0) {
        system_log(6, 0x01, get_progname(), "fileio.c", 122, __FUNCTION__, "pipe: pfd=%p", pfd);
        return EX_NG;
    }
    retval = close(fd);
    if (retval < 0) {
        system_log(6, 0x01, get_progname(), "fileio.c", 128, __FUNCTION__, "close: fd=%d", fd);
        return EX_NG;
    }
    newfd = dup2(pfd[PIPE_W], fd);
    if (newfd < 0) {
        system_log(6, 0x01, get_progname(), "fileio.c", 134, __FUNCTION__, "dup2: pfd[PIPE_W]=%d, fd=%d", pfd[PIPE_W], fd);
        close_fd(&pfd[PIPE_R], &pfd[PIPE_W], ((void *)0));
        return EX_NG;
    }
    do { } while (0);
    close_fd(&pfd[PIPE_W], ((void *)0));
    return pfd[PIPE_R];
}

canonical_original_code:
int pipe_fd(int fd)
{
    int pfd[] = {-1, -1};
    int retval = 0;
    int newfd = 0;
    if (fd < 0)
        return EX_NG;
    retval = pipe(pfd);
    if (retval < 0) {
        system_log(6, 0x01, get_progname(), "fileio.c", 122, __FUNCTION__, "pipe: pfd=%p", pfd);
        return EX_NG;
    }
    retval = close(fd);
    if (retval < 0) {
        system_log(6, 0x01, get_progname(), "fileio.c", 128, __FUNCTION__, "close: fd=%d", fd);
        return EX_NG;
    }
    newfd = dup2(pfd[PIPE_W], fd);
    if (newfd < 0) {
        system_log(6, 0x01, get_progname(), "fileio.c", 134, __FUNCTION__, "dup2: pfd[PIPE_W]=%d, fd=%d", pfd[PIPE_W], fd);
        close_fd(&pfd[PIPE_R], &pfd[PIPE_W], ((void *)0));
        return EX_NG;
    }
    do { } while (0);
    close_fd(&pfd[PIPE_W], ((void *)0));
    return pfd[PIPE_R];
}

variable_types:
pfd
int []

variable_types: retval int

variable_types: newfd int


decompiled_code:
__int64 __fastcall pipe_fd2(int *a1, int *a2, int a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10, double a11)
{
int v12; // eax
__int64 v13; // r12
int v14; // ebx
double v15; // xmm4_8
double v16; // xmm5_8
__int64 v18; // rax
__int64 v19; // rax
double v20; // xmm4_8
double v21; // xmm5_8

close_fd(a1, a4, a5, a6, a7, a8, a9, a10, a11, 0LL);
v12 = close(a3);
v13 = (unsigned int)v12;
if ( v12 < 0 )
{
v18 = get_progname();
system_log(6LL, 1LL, v18, "fileio.c", 162LL, "pipe_fd2", "close=%d", v13);
}
v14 = dup2(*a2, a3);
if ( v14 < 0 )
{
v19 = get_progname();
system_log(6LL, 1LL, v19, "fileio.c", 166LL, "pipe_fd2", "dup2=%d", v13);
close_fd(a2, a4, a5, a6, a7, v20, v21, a10, a11, 0LL);
v14 = -1;
}
else
{
close_fd(a2, a4, a5, a6, a7, v15, v16, a10, a11, 0LL);
}
return (unsigned int)v14;
}

canonical_decompiled_code:
__int64 __fastcall func5(int *a1, int *a2, int a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10, double a11)
{
int v12; // eax
__int64 v13; // r12
int v14; // ebx
double v15; // xmm4_8
double v16; // xmm5_8
__int64 v18; // rax
__int64 v19; // rax
double v20; // xmm4_8
double v21; // xmm5_8

func3(a1, a4, a5, a6, a7, a8, a9, a10, a11, 0LL);
v12 = close(a3);
v13 = (unsigned int)v12;
if ( v12 < 0 )
{
v18 = get_progname();
system_log(6LL, 1LL, v18, "fileio.c", 162LL, "pipe_fd2", "close=%d", v13);
}
v14 = dup2(*a2, a3);
if ( v14 < 0 )
{
v19 = get_progname();
system_log(6LL, 1LL, v19, "fileio.c", 166LL, "pipe_fd2", "dup2=%d", v13);
func3(a2, a4, a5, a6, a7, v20, v21, a10, a11, 0LL);
v14 = -1;
}
else
{
func3(a2, a4, a5, a6, a7, v15, v16, a10, a11, 0LL);
}
return (unsigned int)v14;
}

original_code:
int
pipe_fd2(int *pipefd, int *oldfd, const int newfd)
{
    int retval = 0;
    int fd = 0;
    close_fd(pipefd, ((void *)0));
    retval = close(newfd);
    if (retval < 0)
        system_log(6, 0x01, get_progname(), "fileio.c", 162, __FUNCTION__, "close=%d", retval);
    fd = dup2(*oldfd, newfd);
    if (fd < 0) {
        system_log(6, 0x01, get_progname(), "fileio.c", 166, __FUNCTION__, "dup2=%d", retval);
        close_fd(oldfd, ((void *)0));
        return EX_NG;
    }
    close_fd(oldfd, ((void *)0));
    return fd;
}

canonical_original_code:
int pipe_fd2(int *pipefd, int *oldfd, int newfd)
{
    int retval = 0;
    int fd = 0;
    close_fd(pipefd, ((void *)0));
    retval = close(newfd);
    if (retval < 0)
        system_log(6, 0x01, get_progname(), "fileio.c", 162, __FUNCTION__, "close=%d", retval);
    fd = dup2(*oldfd, newfd);
    if (fd < 0) {
        system_log(6, 0x01, get_progname(), "fileio.c", 166, __FUNCTION__, "dup2=%d", retval);
        close_fd(oldfd, ((void *)0));
        return EX_NG;
    }
    close_fd(oldfd, ((void *)0));
    return fd;
}

variable_types:
pipefd
int *

variable_types:
oldfd
int *


decompiled_code:
__int64 __fastcall set_client_data(_QWORD *a1, const void *a2, size_t a3)
{
unsigned __int64 v4; // r14
_DWORD *v5; // rax
_DWORD *v6; // rbx
__int64 result; // rax
__int64 v8; // rax

if ( !a2 )
return -1LL;
v4 = (a3 + 7) & 0xFFFFFFFFFFFFFFF8LL;
v5 = malloc(v4 + 8);
v6 = v5;
*a1 = v5;
if ( v5 )
{
memset(v5, 0, v4 + 8);
*v6 = _bswap_32(v4);
memcpy(v6 + 2, a2, a3);
result = v4 + 8;
}
else
{
v8 = get_progname();
system_log(6LL, 1LL, v8, "data.c", 66LL, "set_client_data", "malloc: length=%zu", v4 + 8);
result = -1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1, const void *a2, size_t a3)
{
unsigned __int64 v4; // r14
_DWORD *v5; // rax
_DWORD *v6; // rbx
__int64 result; // rax
__int64 v8; // rax

if ( !a2 )
return -1LL;
v4 = (a3 + 7) & 0xFFFFFFFFFFFFFFF8LL;
v5 = malloc(v4 + 8);
v6 = v5;
*a1 = v5;
if ( v5 )
{
memset(v5, 0, v4 + 8);
*v6 = func0(v4);
memcpy(v6 + 2, a2, a3);
result = v4 + 8;
}
else
{
v8 = get_progname();
system_log(6LL, 1LL, v8, "data.c", 66LL, "set_client_data", "malloc: length=%zu", v4 + 8);
result = -1LL;
}
return result;
}

original_code:
ssize_t
set_client_data(struct client_data **dt,
                const unsigned char *buf, const size_t len)
{
    size_t length = 0;
    size_t datalen = 0;
    do { } while (0);
    if (!buf)
        return EX_NG;
    datalen = (((len)+7) & ~7);
    length = sizeof(struct header) + datalen;
    do { } while (0);
    (*dt) = (struct client_data *)malloc(length);
    if (!(*dt)) {
        system_log(6, 0x01, get_progname(), "data.c", 66, __FUNCTION__, "malloc: length=%zu", length);
        return EX_NG;
    }
    (void)memset((*dt), 0, length);
    do { } while (0);
    (*dt)->hd.length = htonl((uint32_t)datalen);
    (void)memcpy((*dt)->expression, buf, len);
    do { } while (0);
    return (ssize_t)length;
}

canonical_original_code:
long set_client_data(struct client_data **dt, unsigned char *buf, unsigned long len)
{
    unsigned long length = 0;
    unsigned long datalen = 0;
    do { } while (0);
    if (!buf)
        return EX_NG;
    datalen = (((len)+7) & ~7);
    length = sizeof(struct header) + datalen;
    do { } while (0);
    (*dt) = (struct client_data *)malloc(length);
    if (!(*dt)) {
        system_log(6, 0x01, get_progname(), "data.c", 66, __FUNCTION__, "malloc: length=%zu", length);
        return EX_NG;
    }
    (void)memset((*dt), 0, length);
    do { } while (0);
    (*dt)->hd.length = htonl((unsigned int)datalen);
    (void)memcpy((*dt)->expression, buf, len);
    do { } while (0);
    return (long)length;
}

variable_types: struct client_data { struct header { unsigned int length; unsigned char padding[4]; } hd; unsigned char expression[1]; } **

variable_types:
buf
unsigned char *

variable_types:
length
unsigned long

variable_types:
datalen
unsigned long

user_defined_types: struct client_data { struct header hd; unsigned char expression[1]; }


decompiled_code:
__int64 __fastcall set_server_data(_QWORD *a1, const void *a2, size_t a3)
{
unsigned __int64 v4; // r14
_DWORD *v5; // rax
_DWORD *v6; // rbx
__int64 result; // rax
__int64 v8; // rax

if ( !a2 )
return -1LL;
v4 = (a3 + 7) & 0xFFFFFFFFFFFFFFF8LL;
v5 = malloc(v4 + 8);
v6 = v5;
*a1 = v5;
if ( v5 )
{
memset(v5, 0, v4 + 8);
*v6 = _bswap_32(v4);
memcpy(v6 + 2, a2, a3);
result = v4 + 8;
}
else
{
v8 = get_progname();
system_log(6LL, 1LL, v8, "data.c", 106LL, "set_server_data", "malloc: length=%zu", v4 + 8);
result = -1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD *a1, const void *a2, size_t a3)
{
unsigned __int64 v4; // r14
_DWORD *v5; // rax
_DWORD *v6; // rbx
__int64 result; // rax
__int64 v8; // rax

if ( !a2 )
return -1LL;
v4 = (a3 + 7) & 0xFFFFFFFFFFFFFFF8LL;
v5 = malloc(v4 + 8);
v6 = v5;
*a1 = v5;
if ( v5 )
{
memset(v5, 0, v4 + 8);
*v6 = func0(v4);
memcpy(v6 + 2, a2, a3);
result = v4 + 8;
}
else
{
v8 = get_progname();
system_log(6LL, 1LL, v8, "data.c", 106LL, "set_server_data", "malloc: length=%zu", v4 + 8);
result = -1LL;
}
return result;
}

original_code:
ssize_t
set_server_data(struct server_data **dt,
                const unsigned char *buf, const size_t len)
{
    size_t length = 0;
    size_t datalen = 0;
    do { } while (0);
    if (!buf)
        return EX_NG;
    datalen = (((len)+7) & ~7);
    length = sizeof(struct header) + datalen;
    do { } while (0);
    (*dt) = (struct server_data *)malloc(length);
    if (!(*dt)) {
        system_log(6, 0x01, get_progname(), "data.c", 106, __FUNCTION__, "malloc: length=%zu", length);
        return EX_NG;
    }
    (void)memset((*dt), 0, length);
    do { } while (0);
    (*dt)->hd.length = htonl((uint32_t)datalen);
    (void)memcpy((*dt)->answer, buf, len);
    do { } while (0);
    return (ssize_t)length;
}

canonical_original_code:
long set_server_data(struct server_data **dt, unsigned char *buf, unsigned long len)
{
    unsigned long length = 0;
    unsigned long datalen = 0;
    do { } while (0);
    if (!buf)
        return EX_NG;
    datalen = (((len)+7) & ~7);
    length = sizeof(struct header) + datalen;
    do { } while (0);
    (*dt) = (struct server_data *)malloc(length);
    if (!(*dt)) {
        system_log(6, 0x01, get_progname(), "data.c", 106, __FUNCTION__, "malloc: length=%zu", length);
        return EX_NG;
    }
    (void)memset((*dt), 0, length);
    do { } while (0);
    (*dt)->hd.length = htonl((unsigned int)datalen);
    (void)memcpy((*dt)->answer, buf, len);
    do { } while (0);
    return (long)length;
}

variable_types: struct server_data { struct header { unsigned int length; unsigned char padding[4]; } hd; unsigned char answer[1]; } **

variable_types:
len
unsigned long

user_defined_types: struct server_data { struct header hd; unsigned char answer[1]; }


readch

decompiled_code:
const unsigned __int16 *__fastcall readch(__int64 a1)
{
const unsigned __int16 *result; // rax
unsigned __int8 v2; // bl

do
{
result = *(const unsigned __int16 **)(a1 + 8);
v2 = *(_BYTE *)result;
*(_DWORD *)a1 = *(unsigned __int8 *)result;
if ( !v2 )
break;
*(_QWORD *)(a1 + 8) = (char *)result + 1;
result = *_ctype_b_loc();
}
while ( (result[v2] & 1) != 0 );
return result;
}

canonical_decompiled_code:
const unsigned __int16 *__fastcall func0(__int64 a1)
{
const unsigned __int16 *result; // rax
unsigned __int8 v2; // bl

do
{
result = *(const unsigned __int16 **)(a1 + 8);
v2 = *(_BYTE *)result;
*(_DWORD *)a1 = *(unsigned __int8 *)result;
if ( !v2 )
break;
*(_QWORD *)(a1 + 8) = (char *)result + 1;
result = *_ctype_b_loc();
}
while ( (result[v2] & 1) != 0 );
return result;
}

original_code:
static void
readch(calcinfo *calc)
{
    do { } while (0);
    do {
        calc->ch = (int)*calc->ptr;
        do { } while (0);
        if (calc->ch == '\0')
            break;
        calc->ptr++;
    } while (((*__ctype_b_loc ())[(int) ((calc->ch))] & (unsigned short int) _ISblank));
}

canonical_original_code:
static void readch(struct _calcinfo *calc)
{
    do { } while (0);
    do {
        calc->ch = (int)*calc->ptr;
        do { } while (0);
        if (calc->ch == '\0')
            break;
        calc->ptr++;
    } while (((*__ctype_b_loc ())[(int) ((calc->ch))] & (unsigned short) _ISblank));
}

variable_types: struct _calcinfo { int ch; unsigned char *ptr; unsigned char *answer; char fmt[-1]; enum _ER { E_NONE=0, E_DIVBYZERO=1, E_SYNTAX=2, E_NOFUNC=3, E_NAN=4, E_INFINITY=5, MAXERROR=6 } errorcode; } *

return_type: void

user_defined_types: struct _calcinfo { int ch; unsigned char *ptr; unsigned char *answer; char fmt[-1]; enum _ER errorcode; }


number

decompiled_code:
double __fastcall number(int *a1)
{
const unsigned __int16 **v1; // rbx
int v2; // eax
double i; // [rsp+0h] [rbp-28h]
double j; // [rsp+8h] [rbp-20h]

for ( i = (double)(*a1 - 48); ; i = (double)(v2 - 48) + i * 10.0 )
{
readch((__int64)a1);
v1 = _ctype_b_loc();
v2 = *a1;
if ( ((*v1)[*a1] & 0x800) == 0 )
break;
}
if ( v2 == 46 )
{
for ( j = *(double *)&LC0; ; i = (double)(*a1 - 48) * j + i )
{
readch((__int64)a1);
if ( ((*v1)[*a1] & 0x800) == 0 )
break;
j = j / 10.0;
}
}
check_validate(a1, i);
return i;
}

original_code:
static double
number(calcinfo *calc)
{
    double x = 0.0, y = 1.0;
    do { } while (0);
    x = calc->ch - '0';
    while (readch(calc), ((*__ctype_b_loc ())[(int) ((calc->ch))] & (unsigned short int) _ISdigit))
        x = (x * 10) + (calc->ch - '0');
    do { } while (0);
    if (calc->ch == '.') {
        while (readch(calc), ((*__ctype_b_loc ())[(int) ((calc->ch))] & (unsigned short int) _ISdigit))
            x += (y /= 10) * (calc->ch - '0');
    }
    do { } while (0);
    check_validate(calc, x);
    return x;
}

canonical_original_code:
static double number(struct _calcinfo *calc)
{
    double x = 0.0; double y = 1.0;
    do { } while (0);
    x = calc->ch - '0';
    while (readch(calc), ((*__ctype_b_loc ())[(int) ((calc->ch))] & (unsigned short) _ISdigit))
        x = (x * 10) + (calc->ch - '0');
    do { } while (0);
    if (calc->ch == '.') {
        while (readch(calc), ((*__ctype_b_loc ())[(int) ((calc->ch))] & (unsigned short) _ISdigit))
            x += (y /= 10) * (calc->ch - '0');
    }
    do { } while (0);
    check_validate(calc, x);
    return x;
}

variable_types: x double

variable_types: y double

return_type: double

user_defined_types: enum _ER { E_NONE=0, E_DIVBYZERO=1, E_SYNTAX=2, E_NOFUNC=3, E_NAN=4, E_INFINITY=5, MAXERROR=6 }


token

original_code:
static double
token(calcinfo *calc)
{
    double result = 0.0;
    int sign = '+';
    char func[4 + 1];
    int pos = 0;
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    (void)memset(func, 0, sizeof(func));
    if (calc->ch == '+' || calc->ch == '-') {
        sign = calc->ch;
        readch(calc);
    }
    if (((*__ctype_b_loc ())[(int) ((calc->ch))] & (unsigned short int) _ISdigit)) {
        result = number(calc);
    } else if (((*__ctype_b_loc ())[(int) ((calc->ch))] & (unsigned short int) _ISalpha)) {
        while (((*__ctype_b_loc ())[(int) ((calc->ch))] & (unsigned short int) _ISalpha) && calc->ch != '\0' &&
               pos <= 4) {
            func[pos++] = calc->ch;
            readch(calc);
        }
        do { } while (0);
        result = exec_func(calc, func);
    } else {
        do { } while (0);
        set_errorcode(calc, E_SYNTAX);
    }
    do { } while (0);
    return (sign == '+') ? result : -result;
}

canonical_original_code:
static double token(struct _calcinfo *calc)
{
    double result = 0.0;
    int sign = '+';
    char func[-1];
    int pos = 0;
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    (void)memset(func, 0, sizeof(func));
    if (calc->ch == '+' || calc->ch == '-') {
        sign = calc->ch;
        readch(calc);
    }
    if (((*__ctype_b_loc ())[(int) ((calc->ch))] & (unsigned short) _ISdigit)) {
        result = number(calc);
    } else if (((*__ctype_b_loc ())[(int) ((calc->ch))] & (unsigned short) _ISalpha)) {
        while (((*__ctype_b_loc ())[(int) ((calc->ch))] & (unsigned short) _ISalpha) && calc->ch != '\0' &&
               pos <= 4) {
            func[pos++] = calc->ch;
            readch(calc);
        }
        do { } while (0);
        result = exec_func(calc, func);
    } else {
        do { } while (0);
        set_errorcode(calc, E_SYNTAX);
    }
    do { } while (0);
    return (sign == '+') ? result : -result;
}

variable_types: result double

variable_types: sign int

variable_types:
func
char [-1]

variable_types: pos int


factor

decompiled_code:
double __fastcall factor(int *a1)
{
double v1; // rbp
double v3; // xmm0_8

v1 = *(double *)&LC2;
if ( !(unsigned __int8)is_error() )
{
if ( *a1 == 40 )
{
readch((__int64)a1);
v3 = expression(a1);
v1 = v3;
if ( *a1 == 41 )
{
readch((__int64)a1);
}
else
{
set_errorcode(a1, 2LL, v3);
v1 = *(double *)&LC2;
}
}
else
{
*(_QWORD *)&v1 = *(_OWORD *)&token(a1);
}
}
return v1;
}

canonical_decompiled_code:
double __fastcall func3(int *a1)
{
double v1; // rbp
double v3; // xmm0_8

v1 = *(double *)&LC2;
if ( !(unsigned __int8)is_error() )
{
if ( *a1 == 40 )
{
func0((__int64)a1);
v3 = func5(a1);
v1 = v3;
if ( *a1 == 41 )
{
func0((__int64)a1);
}
else
{
set_errorcode(a1, 2LL, v3);
v1 = *(double *)&LC2;
}
}
else
{
*(_QWORD *)&v1 = *(_OWORD *)&func2(a1);
}
}
return v1;
}

original_code:
static double
factor(calcinfo *calc)
{
    double x = 0.0;
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    if (calc->ch != '(')
        return token(calc);
    readch(calc);
    x = expression(calc);
    if (calc->ch != ')') {
        set_errorcode(calc, E_SYNTAX);
        return EX_ERROR;
    }
    readch(calc);
    do { } while (0);
    return x;
}

canonical_original_code:
static double factor(struct _calcinfo *calc)
{
    double x = 0.0;
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    if (calc->ch != '(')
        return token(calc);
    readch(calc);
    x = expression(calc);
    if (calc->ch != ')') {
        set_errorcode(calc, E_SYNTAX);
        return EX_ERROR;
    }
    readch(calc);
    do { } while (0);
    return x;
}


term

decompiled_code:
double __fastcall term(int *a1)
{
double i; // rbp
int v3; // eax
double v4; // xmm1_8
double v5; // xmm0_8

i = *(double *)&LC2;
if ( !(unsigned __int8)is_error() )
{
for ( i = factor(a1); ; i = i / v5 )
{
while ( 1 )
{
while ( 1 )
{
v3 = *a1;
if ( *a1 != 42 )
break;
readch((__int64)a1);
i = i * factor(a1);
}
if ( v3 == 47 )
break;
if ( v3 != 94 )
return i;
readch((__int64)a1);
v4 = factor(a1);
i = get_pow(a1, i, v4);
}
readch((__int64)a1);
v5 = factor(a1);
if ( v5 == 0.0 )
break;
}
set_errorcode(a1, 1LL, v5);
i = *(double *)&LC2;
}
return i;
}

canonical_decompiled_code:
double __fastcall func4(int *a1)
{
double i; // rbp
int v3; // eax
double v4; // xmm1_8
double v5; // xmm0_8

i = *(double *)&LC2;
if ( !(unsigned __int8)is_error() )
{
for ( i = func3(a1); ; i = i / v5 )
{
while ( 1 )
{
while ( 1 )
{
v3 = *a1;
if ( *a1 != 42 )
break;
func0((__int64)a1);
i = i * func3(a1);
}
if ( v3 == 47 )
break;
if ( v3 != 94 )
return i;
func0((__int64)a1);
v4 = func3(a1);
i = get_pow(a1, i, v4);
}
func0((__int64)a1);
v5 = func3(a1);
if ( v5 == 0.0 )
break;
}
set_errorcode(a1, 1LL, v5);
i = *(double *)&LC2;
}
return i;
}

original_code:
static double
term(calcinfo *calc)
{
    double x = 0.0, y = 0.0;
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    x = factor(calc);
    do { } while (0);
    while (1) {
        if (calc->ch == '*') {
            readch(calc);
            x *= factor(calc);
        } else if (calc->ch == '/') {
            readch(calc);
            y = factor(calc);
            if (y == 0) {
                set_errorcode(calc, E_DIVBYZERO);
                return EX_ERROR;
            }
            x /= y;
        } else if (calc->ch == '^') {
            readch(calc);
            y = factor(calc);
            x = get_pow(calc, x, y);
        } else {
            break;
        }
    }
    do { } while (0);
    return x;
}

canonical_original_code:
static double term(struct _calcinfo *calc)
{
    double x = 0.0; double y = 0.0;
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    x = factor(calc);
    do { } while (0);
    while (1) {
        if (calc->ch == '*') {
            readch(calc);
            x *= factor(calc);
        } else if (calc->ch == '/') {
            readch(calc);
            y = factor(calc);
            if (y == 0) {
                set_errorcode(calc, E_DIVBYZERO);
                return EX_ERROR;
            }
            x /= y;
        } else if (calc->ch == '^') {
            readch(calc);
            y = factor(calc);
            x = get_pow(calc, x, y);
        } else {
            break;
        }
    }
    do { } while (0);
    return x;
}


expression

decompiled_code:
double __fastcall expression(int *a1)
{
double i; // rbp

i = *(double *)&LC2;
if ( !(unsigned __int8)is_error() )
{
for ( i = term(a1); ; i = i - term(a1) )
{
while ( *a1 == 43 )
{
readch((__int64)a1);
i = i + term(a1);
}
if ( *a1 != 45 )
break;
readch((__int64)a1);
}
}
return i;
}

canonical_decompiled_code:
double __fastcall func5(int *a1)
{
double i; // rbp

i = *(double *)&LC2;
if ( !(unsigned __int8)is_error() )
{
for ( i = func4(a1); ; i = i - func4(a1) )
{
while ( *a1 == 43 )
{
func0((__int64)a1);
i = i + func4(a1);
}
if ( *a1 != 45 )
break;
func0((__int64)a1);
}
}
return i;
}

original_code:
static double
expression(calcinfo *calc)
{
    double x = 0.0;
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    x = term(calc);
    do { } while (0);
    while (1) {
        if (calc->ch == '+') {
            readch(calc);
            x += term(calc);
        } else if (calc->ch == '-') {
            readch(calc);
            x -= term(calc);
        } else {
            break;
        }
    }
    do { } while (0);
    return x;
}

canonical_original_code:
static double expression(struct _calcinfo *calc)
{
    double x = 0.0;
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    x = term(calc);
    do { } while (0);
    while (1) {
        if (calc->ch == '+') {
            readch(calc);
            x += term(calc);
        } else if (calc->ch == '-') {
            readch(calc);
            x -= term(calc);
        } else {
            break;
        }
    }
    do { } while (0);
    return x;
}


decompiled_code:
char *__fastcall create_answer(__int64 a1, __int64 a2)
{
char *v2; // r14
double v3; // xmm0_8
char *v4; // rbp
__int64 v6; // rax
int v7; // eax
int v8; // eax
__int64 v9; // r12
size_t v10; // r12
char *v11; // rax
const void *v12; // rbx
__int64 v13; // rax
__int64 v14; // rax
__int64 v15; // rax
int v16[11]; // [rsp+Ch] [rbp-2Ch] BYREF

v16[0] = 0;
*(_QWORD *)(a1 + 8) = a2;
v2 = (char *)(a1 + 24);
if ( snprintf((char *)(a1 + 24), 6uLL, "%s%ld%s", "%.", digit, "g") < 0 )
{
v6 = get_progname();
system_log(6LL, 1LL, v6, "calc.c", 98LL, "create_answer", "snprintf");
return 0LL;
}
readch(a1);
if ( g_tflag )
start_timer(v16);
v3 = expression((int *)a1);
check_validate(a1, v3);
if ( *(_DWORD *)a1 )
set_errorcode(a1, 2LL, v3);
if ( g_tflag )
{
v7 = stop_timer(v16);
fprintf(stderr, "time of %s: %f[msec]\n", "calc_time", (double)v7 * 0.001);
}
if ( !(unsigned __int8)is_error(a1) )
{
v8 = get_strlen(v2, v3);
v9 = (unsigned int)v8;
if ( v8 <= 0 )
{
v14 = get_progname();
system_log(6LL, 1LL, v14, "calc.c", 131LL, "create_answer", "get_strlen=%d", v9);
return 0LL;
}
v10 = v8 + 1LL;
v11 = (char *)malloc(v10);
v4 = v11;
*(_QWORD *)(a1 + 16) = v11;
if ( !v11 )
{
v15 = get_progname();
system_log(6LL, 1LL, v15, "calc.c", 140LL, "create_answer", "malloc: length=%zu", v10);
return v4;
}
memset(v11, 0, v10);
if ( snprintf(v4, v10, v2, v3) < 0 )
{
v12 = *(const void **)(a1 + 16);
v13 = get_progname();
system_log(6LL, 1LL, v13, "calc.c", 148LL, "create_answer", "snprintf: answer=%p, length=%zu", v12, v10);
return 0LL;
}
return *(char **)(a1 + 16);
}
*(_QWORD *)(a1 + 16) = get_errormsg(a1);
clear_error(a1);
v4 = *(char **)(a1 + 16);
if ( v4 )
return *(char **)(a1 + 16);
return v4;
}

canonical_decompiled_code:
char *__fastcall func7(__int64 a1, __int64 a2)
{
char *v2; // r14
double v3; // xmm0_8
char *v4; // rbp
__int64 v6; // rax
int v7; // eax
int v8; // eax
__int64 v9; // r12
size_t v10; // r12
char *v11; // rax
const void *v12; // rbx
__int64 v13; // rax
__int64 v14; // rax
__int64 v15; // rax
int v16[11]; // [rsp+Ch] [rbp-2Ch] BYREF

v16[0] = 0;
*(_QWORD *)(a1 + 8) = a2;
v2 = (char *)(a1 + 24);
if ( snprintf((char *)(a1 + 24), 6uLL, "%s%ld%s", "%.", digit, "g") < 0 )
{
v6 = get_progname();
system_log(6LL, 1LL, v6, "calc.c", 98LL, "create_answer", "snprintf");
return 0LL;
}
func0(a1);
if ( g_tflag )
start_timer(v16);
v3 = func5((int *)a1);
check_validate(a1, v3);
if ( *(_DWORD *)a1 )
set_errorcode(a1, 2LL, v3);
if ( g_tflag )
{
v7 = stop_timer(v16);
fprintf(stderr, "time of %s: %f[msec]\n", "calc_time", (double)v7 * 0.001);
}
if ( !(unsigned __int8)is_error(a1) )
{
v8 = func6(v2, v3);
v9 = (unsigned int)v8;
if ( v8 <= 0 )
{
v14 = get_progname();
system_log(6LL, 1LL, v14, "calc.c", 131LL, "create_answer", "get_strlen=%d", v9);
return 0LL;
}
v10 = v8 + 1LL;
v11 = (char *)malloc(v10);
v4 = v11;
*(_QWORD *)(a1 + 16) = v11;
if ( !v11 )
{
v15 = get_progname();
system_log(6LL, 1LL, v15, "calc.c", 140LL, "create_answer", "malloc: length=%zu", v10);
return v4;
}
memset(v11, 0, v10);
if ( snprintf(v4, v10, v2, v3) < 0 )
{
v12 = *(const void **)(a1 + 16);
v13 = get_progname();
system_log(6LL, 1LL, v13, "calc.c", 148LL, "create_answer", "snprintf: answer=%p, length=%zu", v12, v10);
return 0LL;
}
return *(char **)(a1 + 16);
}
*(_QWORD *)(a1 + 16) = get_errormsg(a1);
clear_error(a1);
v4 = *(char **)(a1 + 16);
if ( v4 )
return *(char **)(a1 + 16);
return v4;
}

original_code:
unsigned char *
create_answer(calcinfo *calc, const unsigned char *expr)
{
    double val = 0.0;
    size_t length = 0;
    int retval = 0;
    unsigned int start = 0;
    do { } while (0);
    calc->ptr = (unsigned char *)expr;
    do { } while (0);
    retval = snprintf(calc->fmt, sizeof(calc->fmt),
                      "%s%ld%s", "%.", digit, "g");
    if (retval < 0) {
        system_log(6, 0x01, get_progname(), "calc.c", 98, __FUNCTION__, "snprintf");
        return ((void *)0);
    }
    do { } while (0);
    readch(calc);
    if (g_tflag)
        start_timer(&start);
    val = expression(calc);
    do { } while (0);
    do { } while (0);
    check_validate(calc, val);
    if (calc->ch != '\0')
        set_errorcode(calc, E_SYNTAX);
    if (g_tflag) {
        unsigned int calc_time = stop_timer(&start);
        { (void)fprintf(stderr, "time of %s: %f[msec]\n", "calc_time", calc_time*1.0e-3); };
    }
    if (is_error(calc)) {
        calc->answer = get_errormsg(calc);
        clear_error(calc);
        if (!calc->answer)
            return ((void *)0);
        do { } while (0);
    } else {
        retval = get_strlen(val, calc->fmt);
        if (retval <= 0) {
            system_log(6, 0x01, get_progname(), "calc.c", 131, __FUNCTION__, "get_strlen=%d", retval);
            return ((void *)0);
        }
        do { } while (0);
        length = (size_t)retval + 1;
        calc->answer = (unsigned char *)malloc(length * sizeof(unsigned char));
        if (!calc->answer) {
            system_log(6, 0x01, get_progname(), "calc.c", 140, __FUNCTION__, "malloc: length=%zu", length);
            return ((void *)0);
        }
        (void)memset(calc->answer, 0, length * sizeof(unsigned char));
        retval = snprintf((char *)calc->answer, length, calc->fmt, val);
        if (retval < 0) {
            system_log(6, 0x01, get_progname(), "calc.c", 148, __FUNCTION__, "snprintf: answer=%p, length=%zu", calc->answer, length);
            return ((void *)0);
        }
        do { } while (0);
        do { } while (0);
    }
    return calc->answer;
}

canonical_original_code:
unsigned char *create_answer(struct _calcinfo *calc, unsigned char *expr)
{
    double val = 0.0;
    unsigned long length = 0;
    int retval = 0;
    unsigned int start = 0;
    do { } while (0);
    calc->ptr = (unsigned char *)expr;
    do { } while (0);
    retval = snprintf(calc->fmt, sizeof(calc->fmt),
                      "%s%ld%s", "%.", digit, "g");
    if (retval < 0) {
        system_log(6, 0x01, get_progname(), "calc.c", 98, __FUNCTION__, "snprintf");
        return ((void *)0);
    }
    do { } while (0);
    readch(calc);
    if (g_tflag)
        start_timer(&start);
    val = expression(calc);
    do { } while (0);
    do { } while (0);
    check_validate(calc, val);
    if (calc->ch != '\0')
        set_errorcode(calc, E_SYNTAX);
    if (g_tflag) {
        unsigned int calc_time = stop_timer(&start);
        { (void)fprintf(stderr, "time of %s: %f[msec]\n", "calc_time", calc_time*1.0e-3); };
    }
    if (is_error(calc)) {
        calc->answer = get_errormsg(calc);
        clear_error(calc);
        if (!calc->answer)
            return ((void *)0);
        do { } while (0);
    } else {
        retval = get_strlen(val, calc->fmt);
        if (retval <= 0) {
            system_log(6, 0x01, get_progname(), "calc.c", 131, __FUNCTION__, "get_strlen=%d", retval);
            return ((void *)0);
        }
        do { } while (0);
        length = (unsigned long)retval + 1;
        calc->answer = (unsigned char *)malloc(length * sizeof(unsigned char));
        if (!calc->answer) {
            system_log(6, 0x01, get_progname(), "calc.c", 140, __FUNCTION__, "malloc: length=%zu", length);
            return ((void *)0);
        }
        (void)memset(calc->answer, 0, length * sizeof(unsigned char));
        retval = snprintf((char *)calc->answer, length, calc->fmt, val);
        if (retval < 0) {
            system_log(6, 0x01, get_progname(), "calc.c", 148, __FUNCTION__, "snprintf: answer=%p, length=%zu", calc->answer, length);
            return ((void *)0);
        }
        do { } while (0);
        do { } while (0);
    }
    return calc->answer;
}

variable_types:
expr
unsigned char *

variable_types: val double

variable_types: retval int

variable_types:
start
unsigned int

return_type: unsigned char *


decompiled_code:
__int64 __fastcall destroy_answer(__int64 a1)
{
return memfree(a1 + 16, 0LL);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
return memfree(a1 + 16, 0LL);
}

original_code:
void
destroy_answer(void *calc)
{
    calcinfo *ptr = (calcinfo *)calc;
    do { } while (0);
    memfree((void **)&ptr->answer, ((void *)0));
}

canonical_original_code:
void destroy_answer(void *calc)
{
    struct _calcinfo *ptr = (calcinfo *)calc;
    do { } while (0);
    memfree((void **)&ptr->answer, ((void *)0));
}

variable_types:
calc
void *


decompiled_code:
void __fastcall set_digit(__int64 a1)
{
digit = a1;
}

canonical_decompiled_code:
void __fastcall func10(__int64 a1)
{
digit = a1;
}

original_code:
void
set_digit(long dgt)
{
    digit = dgt;
}

variable_types: dgt long


decompiled_code:
double __fastcall get_deg(double a1)
{
double result; // xmm0_8

result = 0.0;
if ( !(unsigned __int8)is_error() )
result = a1 * 180.0 / 3.141592653589793;
return result;
}

canonical_decompiled_code:
double __fastcall func0(double a1)
{
double result; // xmm0_8

result = 0.0;
if ( !(unsigned __int8)is_error() )
result = a1 * 180.0 / 3.141592653589793;
return result;
}

original_code:
static double
get_deg(calcinfo *calc, double x)
{
    double result = 0.0;
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    result = x * 180 / DEF_PI;
    return result;
}

canonical_original_code:
static double get_deg(struct _calcinfo *calc, double x)
{
    double result = 0.0;
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    result = x * 180 / DEF_PI;
    return result;
}


decompiled_code:
double __fastcall get_rad(double a1)
{
double result; // xmm0_8

result = 0.0;
if ( !(unsigned __int8)is_error() )
result = a1 * 3.141592653589793 / 180.0;
return result;
}

canonical_decompiled_code:
double __fastcall func1(double a1)
{
double result; // xmm0_8

result = 0.0;
if ( !(unsigned __int8)is_error() )
result = a1 * 3.141592653589793 / 180.0;
return result;
}

original_code:
static double
get_rad(calcinfo *calc, double x)
{
    double result = 0.0;
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    result = x * DEF_PI / 180;
    return result;
}

canonical_original_code:
static double get_rad(struct _calcinfo *calc, double x)
{
    double result = 0.0;
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    result = x * DEF_PI / 180;
    return result;
}


decompiled_code:
double get_e()
{
double result; // xmm0_8

result = *(double *)&LC3;
if ( (unsigned __int8)is_error() )
result = 0.0;
return result;
}

canonical_decompiled_code:
double func2()
{
double result; // xmm0_8

result = *(double *)&LC3;
if ( (unsigned __int8)is_error() )
result = 0.0;
return result;
}

original_code:
static double
get_e(calcinfo *calc)
{
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    return DEF_E;
}

canonical_original_code:
static double get_e(struct _calcinfo *calc)
{
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    return DEF_E;
}


decompiled_code:
double get_pi()
{
double result; // xmm0_8

result = *(double *)&LC2;
if ( (unsigned __int8)is_error() )
result = 0.0;
return result;
}

canonical_decompiled_code:
double func3()
{
double result; // xmm0_8

result = *(double *)&LC2;
if ( (unsigned __int8)is_error() )
result = 0.0;
return result;
}

original_code:
static double
get_pi(calcinfo *calc)
{
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    return DEF_PI;
}

canonical_original_code:
static double get_pi(struct _calcinfo *calc)
{
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    return DEF_PI;
}


original_code:
static double
get_factorial(calcinfo *calc, double n)
{
    double result = 1.0;
    double decimal = 0.0;
    double integer = 0.0;
    _Bool minus = 0;
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    decimal = modf(n, &integer);
    do { } while (0);
    if (decimal) {
        set_errorcode(calc, E_NAN);
        return EX_ERROR;
    }
    if (__builtin_isless(n, 0)) {
        n *= -1;
        minus = 1;
    }
    while (n > 0)
        result *= n--;
    if (minus)
        result *= -1;
    minus = 0;
    do { } while (0);
    return result;
}

canonical_original_code:
static double get_factorial(struct _calcinfo *calc, double n)
{
    double result = 1.0;
    double decimal = 0.0;
    double integer = 0.0;
    _Bool minus = 0;
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    decimal = modf(n, &integer);
    do { } while (0);
    if (decimal) {
        set_errorcode(calc, E_NAN);
        return EX_ERROR;
    }
    if (__builtin_isless(n, 0)) {
        n *= -1;
        minus = 1;
    }
    while (n > 0)
        result *= n--;
    if (minus)
        result *= -1;
    minus = 0;
    do { } while (0);
    return result;
}

variable_types: n double

variable_types: decimal double

variable_types: integer double


decompiled_code:
double __fastcall get_combination(__int64 a1, double a2, double a3)
{
double result; // xmm0_8
double v5; // r12
double v6; // r14
double v7; // xmm0_8
double v8; // xmm1_8

result = 0.0;
if ( !(unsigned __int8)is_error() )
{
if ( a3 <= a2 && a2 >= 0.0 && a3 >= 0.0 )
{
*(_QWORD *)&v5 = *(_OWORD *)&get_factorial(a1, a2);
*(_QWORD *)&v6 = *(_OWORD *)&get_factorial(a1, a3);
v7 = a2 - a3;
v8 = *(double *)&LC4;
if ( a2 - a3 > 0.0 )
*(_QWORD *)&v8 = *(_OWORD *)&get_factorial(a1, v7);
result = v5 / (v8 * v6);
}
else
{
set_errorcode(a1, 4LL, 0.0, a3);
result = 0.0;
}
}
return result;
}

canonical_decompiled_code:
double __fastcall func5(__int64 a1, double a2, double a3)
{
double result; // xmm0_8
double v5; // r12
double v6; // r14
double v7; // xmm0_8
double v8; // xmm1_8

result = 0.0;
if ( !(unsigned __int8)is_error() )
{
if ( a3 <= a2 && a2 >= 0.0 && a3 >= 0.0 )
{
*(_QWORD *)&v5 = *(_OWORD *)&func4(a1, a2);
*(_QWORD *)&v6 = *(_OWORD *)&func4(a1, a3);
v7 = a2 - a3;
v8 = *(double *)&LC4;
if ( a2 - a3 > 0.0 )
*(_QWORD *)&v8 = *(_OWORD *)&func4(a1, v7);
result = v5 / (v8 * v6);
}
else
{
set_errorcode(a1, 4LL, 0.0, a3);
result = 0.0;
}
}
return result;
}

original_code:
static double
get_combination(calcinfo *calc, double n, double r)
{
    double result = 0.0;
    double x = 0.0, y = 0.0, z = 1.0;
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    if (__builtin_isless(n, 0) || __builtin_isless(r, 0) ||
        __builtin_isless(n, r)) {
        set_errorcode(calc, E_NAN);
        return EX_ERROR;
    }
    x = get_factorial(calc, n);
    y = get_factorial(calc, r);
    if (__builtin_isgreater((n - r), 0))
        z = get_factorial(calc, n - r);
    do { } while (0);
    result = x / (y * z);
    do { } while (0);
    return result;
}

canonical_original_code:
static double get_combination(struct _calcinfo *calc, double n, double r)
{
    double result = 0.0;
    double x = 0.0; double y = 0.0; double z = 1.0;
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    if (__builtin_isless(n, 0) || __builtin_isless(r, 0) ||
        __builtin_isless(n, r)) {
        set_errorcode(calc, E_NAN);
        return EX_ERROR;
    }
    x = get_factorial(calc, n);
    y = get_factorial(calc, r);
    if (__builtin_isgreater((n - r), 0))
        z = get_factorial(calc, n - r);
    do { } while (0);
    result = x / (y * z);
    do { } while (0);
    return result;
}

variable_types: r double

variable_types: z double


decompiled_code:
double __fastcall get_permutation(__int64 a1, double a2, double a3)
{
double result; // xmm0_8
double v5; // r12
double v6; // xmm0_8
double v7; // xmm1_8

result = 0.0;
if ( !(unsigned __int8)is_error() )
{
if ( a3 <= a2 && a2 >= 0.0 && a3 >= 0.0 )
{
*(_QWORD *)&v5 = *(_OWORD *)&get_factorial(a1, a2);
v6 = a2 - a3;
v7 = *(double *)&LC4;
if ( a2 - a3 > 0.0 )
*(_QWORD *)&v7 = *(_OWORD *)&get_factorial(a1, v6);
result = v5 / v7;
}
else
{
set_errorcode(a1, 4LL, 0.0, a3);
result = 0.0;
}
}
return result;
}

canonical_decompiled_code:
double __fastcall func6(__int64 a1, double a2, double a3)
{
double result; // xmm0_8
double v5; // r12
double v6; // xmm0_8
double v7; // xmm1_8

result = 0.0;
if ( !(unsigned __int8)is_error() )
{
if ( a3 <= a2 && a2 >= 0.0 && a3 >= 0.0 )
{
*(_QWORD *)&v5 = *(_OWORD *)&func4(a1, a2);
v6 = a2 - a3;
v7 = *(double *)&LC4;
if ( a2 - a3 > 0.0 )
*(_QWORD *)&v7 = *(_OWORD *)&func4(a1, v6);
result = v5 / v7;
}
else
{
set_errorcode(a1, 4LL, 0.0, a3);
result = 0.0;
}
}
return result;
}

original_code:
static double
get_permutation(calcinfo *calc, double n, double r)
{
    double result = 0.0;
    double x = 0.0, y = 1.0;
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    if (__builtin_isless(n, 0) || __builtin_isless(r, 0) ||
        __builtin_isless(n, r)) {
        set_errorcode(calc, E_NAN);
        return EX_ERROR;
    }
    x = get_factorial(calc, n);
    do { } while (0);
    if (__builtin_isgreater((n - r), 0))
        y = get_factorial(calc, n - r);
    do { } while (0);
    result = x / y;
    do { } while (0);
    return result;
}

canonical_original_code:
static double get_permutation(struct _calcinfo *calc, double n, double r)
{
    double result = 0.0;
    double x = 0.0; double y = 1.0;
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    if (__builtin_isless(n, 0) || __builtin_isless(r, 0) ||
        __builtin_isless(n, r)) {
        set_errorcode(calc, E_NAN);
        return EX_ERROR;
    }
    x = get_factorial(calc, n);
    do { } while (0);
    if (__builtin_isgreater((n - r), 0))
        y = get_factorial(calc, n - r);
    do { } while (0);
    result = x / y;
    do { } while (0);
    return result;
}

variable_types: struct _calcinfo { int ch; unsigned char *ptr; unsigned char *answer; char fmt[-1]; enum _ER { E_NONE=0, E_DIVBYZERO=1, E_SYNTAX=2, E_NOFUNC=3, E_NAN=4, E_INFINITY=5, MAXERROR=6 } errorcode; } *

variable_types: x double


decompiled_code:
double __fastcall get_log(__int64 a1, double a2)
{
double result; // xmm0_8

result = 0.0;
if ( !(unsigned __int8)is_error() )
{
if ( a2 < 0.0 )
{
set_errorcode(a1, 4LL, 0.0, a2);
result = 0.0;
}
else
{
result = log10(a2);
}
}
return result;
}

canonical_decompiled_code:
double __fastcall func7(__int64 a1, double a2)
{
double result; // xmm0_8

result = 0.0;
if ( !(unsigned __int8)is_error() )
{
if ( a2 < 0.0 )
{
set_errorcode(a1, 4LL, 0.0, a2);
result = 0.0;
}
else
{
result = log10(a2);
}
}
return result;
}

original_code:
static double
get_log(calcinfo *calc, double x)
{
    double result = 0.0;
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    if (__builtin_isless(x, 0)) {
        set_errorcode(calc, E_NAN);
        return EX_ERROR;
    }
    result = log10(x);
    return result;
}

canonical_original_code:
static double get_log(struct _calcinfo *calc, double x)
{
    double result = 0.0;
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    if (__builtin_isless(x, 0)) {
        set_errorcode(calc, E_NAN);
        return EX_ERROR;
    }
    result = log10(x);
    return result;
}

variable_types: result double


decompiled_code:
double __fastcall get_ln(__int64 a1, double a2)
{
double result; // xmm0_8

result = 0.0;
if ( !(unsigned __int8)is_error() )
{
if ( a2 < 0.0 )
{
set_errorcode(a1, 4LL, 0.0, a2);
result = 0.0;
}
else
{
result = log(a2);
}
}
return result;
}

canonical_decompiled_code:
double __fastcall func8(__int64 a1, double a2)
{
double result; // xmm0_8

result = 0.0;
if ( !(unsigned __int8)is_error() )
{
if ( a2 < 0.0 )
{
set_errorcode(a1, 4LL, 0.0, a2);
result = 0.0;
}
else
{
result = log(a2);
}
}
return result;
}

original_code:
static double
get_ln(calcinfo *calc, double x)
{
    double result = 0.0;
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    if (__builtin_isless(x, 0)) {
        set_errorcode(calc, E_NAN);
        return EX_ERROR;
    }
    result = log(x);
    return result;
}

canonical_original_code:
static double get_ln(struct _calcinfo *calc, double x)
{
    double result = 0.0;
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    if (__builtin_isless(x, 0)) {
        set_errorcode(calc, E_NAN);
        return EX_ERROR;
    }
    result = log(x);
    return result;
}


decompiled_code:
double __fastcall get_sqrt(__int64 a1, double a2)
{
double result; // xmm0_8

result = 0.0;
if ( !(unsigned __int8)is_error() )
{
if ( a2 < 0.0 )
{
set_errorcode(a1, 4LL, 0.0, a2);
result = 0.0;
}
else
{
result = sqrt(a2);
}
}
return result;
}

canonical_decompiled_code:
double __fastcall func9(__int64 a1, double a2)
{
double result; // xmm0_8

result = 0.0;
if ( !(unsigned __int8)is_error() )
{
if ( a2 < 0.0 )
{
set_errorcode(a1, 4LL, 0.0, a2);
result = 0.0;
}
else
{
result = sqrt(a2);
}
}
return result;
}

original_code:
static double
get_sqrt(calcinfo *calc, double x)
{
    double result = 0.0;
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    if (__builtin_isless(x, 0)) {
        set_errorcode(calc, E_NAN);
        return EX_ERROR;
    }
    result = sqrt(x);
    return result;
}

canonical_original_code:
static double get_sqrt(struct _calcinfo *calc, double x)
{
    double result = 0.0;
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    if (__builtin_isless(x, 0)) {
        set_errorcode(calc, E_NAN);
        return EX_ERROR;
    }
    result = sqrt(x);
    return result;
}


decompiled_code:
double __fastcall exec_func(__int64 a1, const char *a2, double a3, double a4)
{
const char *v4; // rbp
int v5; // ebx
double v6; // rbx
__int64 v8; // rax
__int64 v9; // rcx
unsigned int v10; // ebx
unsigned int v11; // eax
double v12; // [rsp+0h] [rbp-38h] BYREF
__int64 v13[6]; // [rsp+8h] [rbp-30h] BYREF

v13[0] = 0LL;
v12 = 0.0;
clear_math_feexcept();
v4 = s1;
v5 = 0;
while ( strcmp(v4, a2) )
{
++v5;
v4 += 12;
if ( v5 == 18 )
{
set_errorcode(a1, 3LL, a3, a4);
v6 = *(double *)&LC0;
goto LABEL_5;
}
}
v10 = *((_DWORD *)&fstring + 3 * v5);
v11 = finfo[2 * v10];
if ( v11 == 2 )
{
parse_func_args(a1, v13, &v12, 0LL);
v6 = ((double (__fastcall *)(__int64, double, double))finfo[2 * v10 + 1])(a1, *(double *)v13, v12);
}
else if ( v11 > 2 )
{
if ( v11 == 3 )
{
parse_func_args(a1, v13, 0LL, v9);
v6 = ((double (__fastcall *)(double))finfo[2 * v10 + 1])(*(double *)v13);
}
else
{
v8 = get_progname();
system_log(6LL, 1LL, v8, "func.c", 170LL, "exec_func", "no functype");
v6 = *(double *)&LC0;
}
}
else if ( v11 )
{
parse_func_args(a1, v13, 0LL, v9);
v6 = ((double (__fastcall *)(__int64, double))finfo[2 * v10 + 1])(a1, *(double *)v13);
}
else
{
v6 = ((double (__fastcall *)(__int64))finfo[2 * v10 + 1])(a1);
}
LABEL_5:
check_math_feexcept(a1);
return v6;
}

canonical_decompiled_code:
double __fastcall func10(__int64 a1, const char *a2, double a3, double a4)
{
const char *v4; // rbp
int v5; // ebx
double v6; // rbx
__int64 v8; // rax
__int64 v9; // rcx
unsigned int v10; // ebx
unsigned int v11; // eax
double v12; // [rsp+0h] [rbp-38h] BYREF
__int64 v13[6]; // [rsp+8h] [rbp-30h] BYREF

v13[0] = 0LL;
v12 = 0.0;
clear_math_feexcept();
v4 = s1;
v5 = 0;
while ( strcmp(v4, a2) )
{
++v5;
v4 += 12;
if ( v5 == 18 )
{
set_errorcode(a1, 3LL, a3, a4);
v6 = *(double *)&LC0;
goto LABEL_5;
}
}
v10 = *((_DWORD *)&fstring + 3 * v5);
v11 = finfo[2 * v10];
if ( v11 == 2 )
{
parse_func_args(a1, v13, &v12, 0LL);
v6 = ((double (__fastcall *)(__int64, double, double))finfo[2 * v10 + 1])(a1, *(double *)v13, v12);
}
else if ( v11 > 2 )
{
if ( v11 == 3 )
{
parse_func_args(a1, v13, 0LL, v9);
v6 = ((double (__fastcall *)(double))finfo[2 * v10 + 1])(*(double *)v13);
}
else
{
v8 = get_progname();
system_log(6LL, 1LL, v8, "func.c", 170LL, "exec_func", "no functype");
v6 = *(double *)&LC0;
}
}
else if ( v11 )
{
parse_func_args(a1, v13, 0LL, v9);
v6 = ((double (__fastcall *)(__int64, double))finfo[2 * v10 + 1])(a1, *(double *)v13);
}
else
{
v6 = ((double (__fastcall *)(__int64))finfo[2 * v10 + 1])(a1);
}
LABEL_5:
check_math_feexcept(a1);
return v6;
}

original_code:
double
exec_func(calcinfo *calc, const char *func)
{
    double result = 0.0;
    double x = 0.0, y = 0.0;
    _Bool exec;
    enum functype ftype;
    do { } while (0);
    clear_math_feexcept();
    int i;
    for (i = 0, exec = 0; i < MAXFUNC && !exec; i++) {
        if (!strcmp(fstring[i].funcname, func)) {
            ftype = fstring[i].type;
            do { } while (0);
            switch (finfo[ftype].type) {
                do { } while (0);
            case FUNC0:
                result = finfo[ftype].func.func0(calc);
                break;
            case FUNC1:
                parse_func_args(calc, &x, ((void *)0));
                result = finfo[ftype].func.func1(calc, x);
                break;
            case FUNC2:
                parse_func_args(calc, &x, &y, ((void *)0));
                result = finfo[ftype].func.func2(calc, x, y);
                break;
            case MATH:
                parse_func_args(calc, &x, ((void *)0));
                result = finfo[ftype].func.math(x);
                break;
            default:
                system_log(6, 0x01, get_progname(), "func.c", 170, __FUNCTION__, "no functype");
                break;
            }
            exec = 1;
        }
    }
    if (!exec)
        set_errorcode(calc, E_NOFUNC);
    check_math_feexcept(calc);
    do { } while (0);
    do { } while (0);
    return result;
}

canonical_original_code:
double exec_func(struct _calcinfo *calc, char *func)
{
    double result = 0.0;
    double x = 0.0; double y = 0.0;
    _Bool exec;
    enum functype ftype;
    do { } while (0);
    clear_math_feexcept();
    int i;
    for (i = 0, exec = 0; i < MAXFUNC && !exec; i++) {
        if (!strcmp(fstring[i].funcname, func)) {
            ftype = fstring[i].type;
            do { } while (0);
            switch (finfo[ftype].type) {
                do { } while (0);
            case FUNC0:
                result = finfo[ftype].func.func0(calc);
                break;
            case FUNC1:
                parse_func_args(calc, &x, ((void *)0));
                result = finfo[ftype].func.func1(calc, x);
                break;
            case FUNC2:
                parse_func_args(calc, &x, &y, ((void *)0));
                result = finfo[ftype].func.func2(calc, x, y);
                break;
            case MATH:
                parse_func_args(calc, &x, ((void *)0));
                result = finfo[ftype].func.math(x);
                break;
            default:
                system_log(6, 0x01, get_progname(), "func.c", 170, __FUNCTION__, "no functype");
                break;
            }
            exec = 1;
        }
    }
    if (!exec)
        set_errorcode(calc, E_NOFUNC);
    check_math_feexcept(calc);
    do { } while (0);
    do { } while (0);
    return result;
}

variable_types:
func
char *

variable_types: y double

variable_types: enum functype { FN_PI=0, FN_E=1, FN_ABS=2, FN_SQRT=3, FN_SIN=4, FN_COS=5, FN_TAN=6, FN_ASIN=7, FN_ACOS=8, FN_ATAN=9, FN_EXP=10, FN_LN=11, FN_LOG=12, FN_RAD=13, FN_DEG=14, FN_FACT=15, FN_PERM=16, FN_COMB=17, MAXFUNC=18 }

variable_types: i int


decompiled_code:
double __fastcall get_pow(__int64 a1, double a2, double a3)
{
double v4; // xmm0_8
double v5; // rbp

if ( (unsigned __int8)is_error() )
return *(double *)&LC0;
*(_QWORD *)&v4 = *(_QWORD *)&a2 & LC8;
if ( v4 <= 1.797693134862316e308 && v4 < 2.225073858507201e-308 && a2 == 0.0 && a3 < 0.0 )
{
set_errorcode(a1, 4LL, 0.0, a3);
v5 = *(double *)&LC0;
}
else
{
clear_math_feexcept();
v5 = pow(a2, a3);
check_math_feexcept(a1);
}
return v5;
}

canonical_decompiled_code:
double __fastcall func11(__int64 a1, double a2, double a3)
{
double v4; // xmm0_8
double v5; // rbp

if ( (unsigned __int8)is_error() )
return *(double *)&LC0;
*(_QWORD *)&v4 = *(_QWORD *)&a2 & LC8;
if ( v4 <= 1.797693134862316e308 && v4 < 2.225073858507201e-308 && a2 == 0.0 && a3 < 0.0 )
{
set_errorcode(a1, 4LL, 0.0, a3);
v5 = *(double *)&LC0;
}
else
{
clear_math_feexcept();
v5 = pow(a2, a3);
check_math_feexcept(a1);
}
return v5;
}

original_code:
double
get_pow(calcinfo *calc, double x, double y)
{
    double result = 0.0;
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    if ((__builtin_fpclassify (0, 1, 4, 3, 2, x) == 2) && __builtin_isless(y, 0)) {
        set_errorcode(calc, E_NAN);
        return EX_ERROR;
    }
    clear_math_feexcept();
    result = pow(x, y);
    check_math_feexcept(calc);
    return result;
}

canonical_original_code:
double get_pow(struct _calcinfo *calc, double x, double y)
{
    double result = 0.0;
    do { } while (0);
    if (is_error(calc))
        return EX_ERROR;
    if ((__builtin_fpclassify (0, 1, 4, 3, 2, x) == 2) && __builtin_isless(y, 0)) {
        set_errorcode(calc, E_NAN);
        return EX_ERROR;
    }
    clear_math_feexcept();
    result = pow(x, y);
    check_math_feexcept(calc);
    return result;
}


decompiled_code:
char *__fastcall get_errormsg(__int64 a1)
{
unsigned int v1; // eax
char *v2; // rbx
__int64 v4; // rax

v1 = *(_DWORD *)(a1 + 32);
v2 = 0LL;
if ( v1 - 1 <= 4 )
{
v2 = strdup(*((const char **)&errormsg + v1));
if ( !v2 )
{
v4 = get_progname();
system_log(6LL, 1LL, v4, "error.c", 71LL, "get_errormsg", "strdup");
}
}
return v2;
}

canonical_decompiled_code:
char *__fastcall func0(__int64 a1)
{
unsigned int v1; // eax
char *v2; // rbx
__int64 v4; // rax

v1 = *(_DWORD *)(a1 + 32);
v2 = 0LL;
if ( v1 - 1 <= 4 )
{
v2 = strdup(*((const char **)&errormsg + v1));
if ( !v2 )
{
v4 = get_progname();
system_log(6LL, 1LL, v4, "error.c", 71LL, "get_errormsg", "strdup");
}
}
return v2;
}

original_code:
unsigned char *
get_errormsg(calcinfo *calc)
{
    unsigned char *msg = ((void *)0);
    do { } while (0);
    ((void) (0));
    if (calc->errorcode <= E_NONE ||
        MAXERROR <= calc->errorcode)
        return ((void *)0);
    do { } while (0);
    msg = (unsigned char *)strdup(errormsg[calc->errorcode]);
    if (!msg) {
        system_log(6, 0x01, get_progname(), "error.c", 71, __FUNCTION__, "strdup");
        return ((void *)0);
    }
    return msg;
}

canonical_original_code:
unsigned char *get_errormsg(struct _calcinfo *calc)
{
    unsigned char *msg = ((void *)0);
    do { } while (0);
    ((void) (0));
    if (calc->errorcode <= E_NONE ||
        MAXERROR <= calc->errorcode)
        return ((void *)0);
    do { } while (0);
    msg = (unsigned char *)strdup(errormsg[calc->errorcode]);
    if (!msg) {
        system_log(6, 0x01, get_progname(), "error.c", 71, __FUNCTION__, "strdup");
        return ((void *)0);
    }
    return msg;
}

variable_types:
msg
unsigned char *


decompiled_code:
void __fastcall set_errorcode(__int64 a1, int a2)
{
if ( !*(_DWORD *)(a1 + 32) )
*(_DWORD *)(a1 + 32) = a2;
}

original_code:
void
set_errorcode(calcinfo *calc, ER error)
{
    do { } while (0);
    if (calc->errorcode == E_NONE)
        calc->errorcode = error;
}

canonical_original_code:
void set_errorcode(struct _calcinfo *calc, enum _ER error)
{
    do { } while (0);
    if (calc->errorcode == E_NONE)
        calc->errorcode = error;
}

variable_types: enum _ER { E_NONE=0, E_DIVBYZERO=1, E_SYNTAX=2, E_NOFUNC=3, E_NAN=4, E_INFINITY=5, MAXERROR=6 }


decompiled_code:
void __fastcall clear_error(__int64 a1)
{
*(_DWORD *)(a1 + 32) = 0;
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1)
{
*(_DWORD *)(a1 + 32) = 0;
}

original_code:
void
clear_error(calcinfo *calc)
{
    do { } while (0);
    calc->errorcode = E_NONE;
}

canonical_original_code:
void clear_error(struct _calcinfo *calc)
{
    do { } while (0);
    calc->errorcode = E_NONE;
}


decompiled_code:
bool __fastcall is_error(__int64 a1)
{
return *(_DWORD *)(a1 + 32) != 0;
}

canonical_decompiled_code:
bool __fastcall func3(__int64 a1)
{
return *(_DWORD *)(a1 + 32) != 0;
}

original_code:
_Bool
is_error(calcinfo *calc)
{
    do { } while (0);
    if (calc->errorcode)
        return 1;
    return 0;
}

canonical_original_code:
_Bool is_error(struct _calcinfo *calc)
{
    do { } while (0);
    if (calc->errorcode)
        return 1;
    return 0;
}


decompiled_code:
void __fastcall check_validate(__int64 a1, double a2)
{
if ( COERCE_DOUBLE(*(_QWORD *)&a2 & LC2) > 1.797693134862316e308 )
set_errorcode(a1, 5);
}

original_code:
void
check_validate(calcinfo *calc, double val)
{
    do { } while (0);
    if (__builtin_isnan (val))
        set_errorcode(calc, E_NAN);
    else if (__builtin_isinf_sign (val) != 0)
        set_errorcode(calc, E_INFINITY);
    do { } while (0);
}

canonical_original_code:
void check_validate(struct _calcinfo *calc, double val)
{
    do { } while (0);
    if (__builtin_isnan (val))
        set_errorcode(calc, E_NAN);
    else if (__builtin_isinf_sign (val) != 0)
        set_errorcode(calc, E_INFINITY);
    do { } while (0);
}

variable_types: val double


decompiled_code:
void __fastcall check_math_feexcept(__int64 a1)
{
if ( fetestexcept(28) )
{
set_errorcode(a1, 5);
}
else if ( fetestexcept(1) )
{
set_errorcode(a1, 4);
}
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1)
{
if ( fetestexcept(28) )
{
func1(a1, 5);
}
else if ( fetestexcept(1) )
{
func1(a1, 4);
}
}

original_code:
void
check_math_feexcept(calcinfo *calc)
{
    do { } while (0);
    if (fetestexcept(0x04 |
                     0x08 |
                     0x10)) {
        set_errorcode(calc, E_INFINITY);
    } else {
        if (fetestexcept(0x01))
            set_errorcode(calc, E_NAN);
    }
    do { } while (0);
}

canonical_original_code:
void check_math_feexcept(struct _calcinfo *calc)
{
    do { } while (0);
    if (fetestexcept(0x04 |
                     0x08 |
                     0x10)) {
        set_errorcode(calc, E_INFINITY);
    } else {
        if (fetestexcept(0x01))
            set_errorcode(calc, E_NAN);
    }
    do { } while (0);
}


decompiled_code:
int *clear_math_feexcept()
{
int *result; // rax
__int64 v1; // rax

if ( feclearexcept(61) )
{
v1 = get_progname();
system_log(6LL, 1LL, v1, "error.c", 184LL, "clear_math_feexcept", "feclearexcept");
}
result = _errno_location();
*result = 0;
return result;
}

canonical_decompiled_code:
int *func6()
{
int *result; // rax
__int64 v1; // rax

if ( feclearexcept(61) )
{
v1 = get_progname();
system_log(6LL, 1LL, v1, "error.c", 184LL, "clear_math_feexcept", "feclearexcept");
}
result = _errno_location();
*result = 0;
return result;
}

original_code:
void
clear_math_feexcept(void)
{
    if (feclearexcept((0x20 | 0x04 | 0x10 | 0x08 | 0x01)))
        system_log(6, 0x01, get_progname(), "error.c", 184, __FUNCTION__, "feclearexcept");
    (*__errno_location ()) = 0;
}

canonical_original_code:
void clear_math_feexcept()
{
    if (feclearexcept((0x20 | 0x04 | 0x10 | 0x08 | 0x01)))
        system_log(6, 0x01, get_progname(), "error.c", 184, __FUNCTION__, "feclearexcept");
    (*__errno_location ()) = 0;
}


decompiled_code:
int __fastcall print_version(const char *a1)
{
return fprintf(stderr, "%s %s\n", a1, "version 0.05");
}

canonical_decompiled_code:
int __fastcall func2(const char *a1)
{
return fprintf(stderr, "%s %s\n", a1, "version 0.05");
}

original_code:
static void
print_version(const char *progname)
{
    (void)fprintf(stderr, "%s %s\n", progname, "version 0.05");
}

canonical_original_code:
static void print_version(char *progname)
{
    (void)fprintf(stderr, "%s %s\n", progname, "version 0.05");
}

variable_types:
progname
char *


decompiled_code:
size_t __fastcall parse_error(unsigned int a1, const char *a2)
{
if ( a2 )
fprintf(stderr, "getopt[%d]: %s\n", a1, a2);
return fwrite("Try `getopt --help' for more information\n", 1uLL, 0x29uLL, stderr);
}

canonical_decompiled_code:
size_t __fastcall func3(unsigned int a1, const char *a2)
{
if ( a2 )
fprintf(stderr, "getopt[%d]: %s\n", a1, a2);
return fwrite("Try `getopt --help' for more information\n", 1uLL, 0x29uLL, stderr);
}

original_code:
static void
parse_error(const int c, const char *msg)
{
    if (msg)
        (void)fprintf(stderr, "getopt[%d]: %s\n", c, msg);
    (void)fprintf(stderr, "Try `getopt --help' for more information\n");
}

canonical_original_code:
static void parse_error(int c, char *msg)
{
    if (msg)
        (void)fprintf(stderr, "getopt[%d]: %s\n", c, msg);
    (void)fprintf(stderr, "Try `getopt --help' for more information\n");
}

variable_types: c int

variable_types:
msg
char *


decompiled_code:
__int64 check_state()
{
if ( sig_handled )
{
rl_delete_text(0LL, rl_end);
rl_done = 1;
}
return 0LL;
}

canonical_decompiled_code:
__int64 func2()
{
if ( sig_handled )
{
rl_delete_text(0LL, rl_end);
rl_done = 1;
}
return 0LL;
}

original_code:
static int check_state(void) {
    if (sig_handled) {
        rl_delete_text(0, rl_end);
        rl_done = 1;
    }
    return EX_OK;
}

canonical_original_code:
static int check_state() {
    if (sig_handled) {
        rl_delete_text(0, rl_end);
        rl_done = 1;
    }
    return EX_OK;
}