original_code:
struct ifi_info *get_ifi_info(int family, int doaliases)
{
    int junk;
    struct ifi_info *ifi, *ifihead, **ifipnext;
    int sockfd, len, lastlen, flags, myflags;
    char *ptr, *buf, lastname[16], *cptr;
    struct ifconf ifc;
    struct ifreq *ifr, ifrcopy;
    struct sockaddr_in *sinptr;
    sockfd = -1;
    buf = ((void *)0);
    ifihead = ((void *)0);
    sockfd = socket(2, SOCK_DGRAM, 0);
    if (sockfd < 0) {
        goto gotError;
    }
    lastlen = 0;
    len = 100 * sizeof(struct ifreq);
    for ( ; ; ) {
        buf = malloc(len);
        if (buf == ((void *)0)) {
            goto gotError;
        }
        ifc.ifc_len = len;
        ifc.ifc_ifcu.ifcu_buf = buf;
        if (ioctl(sockfd, 0x8912, &ifc) < 0) {
            if ((*__errno_location ()) != 22 || lastlen != 0) {
                goto gotError;
            }
        } else {
            if (ifc.ifc_len == lastlen)
                break;
            lastlen = ifc.ifc_len;
        }
        len += 10 * sizeof(struct ifreq);
        free(buf);
    }
    ifihead = ((void *)0);
    ifipnext = &ifihead;
    lastname[0] = 0;
    for (ptr = buf; ptr < buf + ifc.ifc_len; ) {
        ifr = (struct ifreq *) ptr;
  len = ((ifr->ifr_ifru.ifru_addr).sa_family == 2 ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr));
        ptr += sizeof(ifr->ifr_ifrn.ifrn_name) + len;
        if (ifr->ifr_ifru.ifru_addr.sa_family != family)
            continue;
        myflags = 0;
        if ( (cptr = strchr(ifr->ifr_ifrn.ifrn_name, ':')) != ((void *)0))
            *cptr = 0;
        if (strncmp(lastname, ifr->ifr_ifrn.ifrn_name, 16) == 0) {
            if (doaliases == 0)
                continue;
            myflags = 1;
        }
        memcpy(lastname, ifr->ifr_ifrn.ifrn_name, 16);
        ifrcopy = *ifr;
        if (ioctl(sockfd, 0x8913, &ifrcopy) < 0) {
            goto gotError;
        }
        flags = ifrcopy.ifr_ifru.ifru_flags;
        if ((flags & IFF_UP) == 0)
            continue;
        ifi = calloc(1, sizeof(struct ifi_info));
        if (ifi == ((void *)0)) {
            goto gotError;
        }
        *ifipnext = ifi;
        ifipnext = &ifi->ifi_next;
        ifi->ifi_flags = flags;
        ifi->ifi_myflags = myflags;
        ifi->ifi_index = if_nametoindex(ifr->ifr_ifrn.ifrn_name);
        memcpy(ifi->ifi_name, ifr->ifr_ifrn.ifrn_name, 16);
        ifi->ifi_name[16 -1] = '\0';
        switch (ifr->ifr_ifru.ifru_addr.sa_family) {
        case 2:
            sinptr = (struct sockaddr_in *) &ifr->ifr_ifru.ifru_addr;
            if (ifi->ifi_addr == ((void *)0)) {
                ifi->ifi_addr = calloc(1, sizeof(struct sockaddr_in));
                if (ifi->ifi_addr == ((void *)0)) {
                    goto gotError;
                }
                memcpy(ifi->ifi_addr, sinptr, sizeof(struct sockaddr_in));
                if (flags & IFF_BROADCAST) {
                    if (ioctl(sockfd, 0x8919, &ifrcopy) < 0) {
                        goto gotError;
                    }
                    sinptr = (struct sockaddr_in *) &ifrcopy.ifr_ifru.ifru_broadaddr;
                    ifi->ifi_brdaddr = calloc(1, sizeof(struct sockaddr_in));
                    if (ifi->ifi_brdaddr == ((void *)0)) {
                        goto gotError;
                    }
                    memcpy(ifi->ifi_brdaddr, sinptr, sizeof(struct sockaddr_in));
                }
                if (flags & IFF_POINTOPOINT) {
                    if (ioctl(sockfd, 0x8917, &ifrcopy) < 0) {
                        goto gotError;
                    }
                    sinptr = (struct sockaddr_in *) &ifrcopy.ifr_ifru.ifru_dstaddr;
                    ifi->ifi_dstaddr = calloc(1, sizeof(struct sockaddr_in));
                    if (ifi->ifi_dstaddr == ((void *)0)) {
                        goto gotError;
                    }
                    memcpy(ifi->ifi_dstaddr, sinptr, sizeof(struct sockaddr_in));
                }
            }
            break;
        default:
            break;
        }
    }
    goto done;
gotError:
    if (ifihead != ((void *)0)) {
        free_ifi_info(ifihead);
        ifihead = ((void *)0);
    }
done:
    if (buf != ((void *)0)) {
        free(buf);
    }
    if (sockfd != -1) {
        junk = close(sockfd);
        ((void) sizeof ((junk == 0) ? 1 : 0), __extension__ ({ if (junk == 0) ; else __assert_fail ("junk == 0", "mDNS/mDNSUNP.c", 274, __extension__ __PRETTY_FUNCTION__); }));
    }
    return(ifihead);
}

canonical_original_code:
struct ifi_info *get_ifi_info(int family, int doaliases)
{
    int junk;
    struct ifi_info *ifi; struct ifi_info *ifihead; struct ifi_info **ifipnext;
    int sockfd; int len; int lastlen; int flags; int myflags;
    char *ptr; char *buf; char lastname[16]; char *cptr;
    struct ifconf ifc;
    struct ifreq *ifr; struct ifreq ifrcopy;
    struct sockaddr_in *sinptr;
    sockfd = -1;
    buf = ((void *)0);
    ifihead = ((void *)0);
    sockfd = socket(2, SOCK_DGRAM, 0);
    if (sockfd < 0) {
        goto gotError;
    }
    lastlen = 0;
    len = 100 * sizeof(struct ifreq);
    for ( ; ; ) {
        buf = malloc(len);
        if (buf == ((void *)0)) {
            goto gotError;
        }
        ifc.ifc_len = len;
        ifc.ifc_ifcu.ifcu_buf = buf;
        if (ioctl(sockfd, 0x8912, &ifc) < 0) {
            if ((*__errno_location ()) != 22 || lastlen != 0) {
                goto gotError;
            }
        } else {
            if (ifc.ifc_len == lastlen)
                break;
            lastlen = ifc.ifc_len;
        }
        len += 10 * sizeof(struct ifreq);
        free(buf);
    }
    ifihead = ((void *)0);
    ifipnext = &ifihead;
    lastname[0] = 0;
    for (ptr = buf; ptr < buf + ifc.ifc_len; ) {
        ifr = (struct ifreq *) ptr;
  len = ((ifr->ifr_ifru.ifru_addr).sa_family == 2 ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr));
        ptr += sizeof(ifr->ifr_ifrn.ifrn_name) + len;
        if (ifr->ifr_ifru.ifru_addr.sa_family != family)
            continue;
        myflags = 0;
        if ( (cptr = strchr(ifr->ifr_ifrn.ifrn_name, ':')) != ((void *)0))
            *cptr = 0;
        if (strncmp(lastname, ifr->ifr_ifrn.ifrn_name, 16) == 0) {
            if (doaliases == 0)
                continue;
            myflags = 1;
        }
        memcpy(lastname, ifr->ifr_ifrn.ifrn_name, 16);
        ifrcopy = *ifr;
        if (ioctl(sockfd, 0x8913, &ifrcopy) < 0) {
            goto gotError;
        }
        flags = ifrcopy.ifr_ifru.ifru_flags;
        if ((flags & IFF_UP) == 0)
            continue;
        ifi = calloc(1, sizeof(struct ifi_info));
        if (ifi == ((void *)0)) {
            goto gotError;
        }
        *ifipnext = ifi;
        ifipnext = &ifi->ifi_next;
        ifi->ifi_flags = flags;
        ifi->ifi_myflags = myflags;
        ifi->ifi_index = if_nametoindex(ifr->ifr_ifrn.ifrn_name);
        memcpy(ifi->ifi_name, ifr->ifr_ifrn.ifrn_name, 16);
        ifi->ifi_name[16 -1] = '\0';
        switch (ifr->ifr_ifru.ifru_addr.sa_family) {
        case 2:
            sinptr = (struct sockaddr_in *) &ifr->ifr_ifru.ifru_addr;
            if (ifi->ifi_addr == ((void *)0)) {
                ifi->ifi_addr = calloc(1, sizeof(struct sockaddr_in));
                if (ifi->ifi_addr == ((void *)0)) {
                    goto gotError;
                }
                memcpy(ifi->ifi_addr, sinptr, sizeof(struct sockaddr_in));
                if (flags & IFF_BROADCAST) {
                    if (ioctl(sockfd, 0x8919, &ifrcopy) < 0) {
                        goto gotError;
                    }
                    sinptr = (struct sockaddr_in *) &ifrcopy.ifr_ifru.ifru_broadaddr;
                    ifi->ifi_brdaddr = calloc(1, sizeof(struct sockaddr_in));
                    if (ifi->ifi_brdaddr == ((void *)0)) {
                        goto gotError;
                    }
                    memcpy(ifi->ifi_brdaddr, sinptr, sizeof(struct sockaddr_in));
                }
                if (flags & IFF_POINTOPOINT) {
                    if (ioctl(sockfd, 0x8917, &ifrcopy) < 0) {
                        goto gotError;
                    }
                    sinptr = (struct sockaddr_in *) &ifrcopy.ifr_ifru.ifru_dstaddr;
                    ifi->ifi_dstaddr = calloc(1, sizeof(struct sockaddr_in));
                    if (ifi->ifi_dstaddr == ((void *)0)) {
                        goto gotError;
                    }
                    memcpy(ifi->ifi_dstaddr, sinptr, sizeof(struct sockaddr_in));
                }
            }
            break;
        default:
            break;
        }
    }
    goto done;
gotError:
    if (ifihead != ((void *)0)) {
        free_ifi_info(ifihead);
        ifihead = ((void *)0);
    }
done:
    if (buf != ((void *)0)) {
        free(buf);
    }
    if (sockfd != -1) {
        junk = close(sockfd);
        ((void) sizeof ((junk == 0) ? 1 : 0), __extension__ ({ if (junk == 0) ; else __assert_fail ("junk == 0", "mDNS/mDNSUNP.c", 274, __extension__ __PRETTY_FUNCTION__); }));
    }
    return(ifihead);
}

variable_types: family int

variable_types: doaliases int

variable_types: junk int

variable_types: struct ifi_info { char ifi_name[16]; unsigned char ifi_haddr[8]; unsigned short ifi_hlen; short ifi_flags; short ifi_myflags; int ifi_index; struct sockaddr { unsigned short sa_family; char sa_data[14]; } *ifi_addr; struct sockaddr *ifi_brdaddr; struct sockaddr *ifi_dstaddr; struct ifi_info *ifi_next; } **

variable_types: sockfd int

variable_types: len int

variable_types: lastlen int

variable_types: flags int

variable_types: myflags int

variable_types:
ptr
char *

variable_types:
buf
char *

variable_types:
lastname
char [16]

variable_types:
cptr
char *

variable_types: struct ifconf { int ifc_len; union { char *ifcu_buf; struct ifreq { union { char ifrn_name[16]; } ifr_ifrn; union { struct sockaddr { unsigned short sa_family; char sa_data[14]; } ifru_addr; struct sockaddr ifru_dstaddr; struct sockaddr ifru_broadaddr; struct sockaddr ifru_netmask; struct sockaddr ifru_hwaddr; short ifru_flags; int ifru_ivalue; int ifru_mtu; struct ifmap { unsigned long mem_start; unsigned long mem_end; unsigned short base_addr; unsigned char irq; unsigned char dma; unsigned char port; } ifru_map; char ifru_slave[16]; char ifru_newname[16]; char *ifru_data; } ifr_ifru; } *ifcu_req; } ifc_ifcu; }

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]; } *

user_defined_types: struct ifconf { int ifc_len; union { char *ifcu_buf; struct ifreq *ifcu_req; } ifc_ifcu; }

user_defined_types: struct ifreq { union { char ifrn_name[16]; } ifr_ifrn; union { struct sockaddr ifru_addr; struct sockaddr ifru_dstaddr; struct sockaddr ifru_broadaddr; struct sockaddr ifru_netmask; struct sockaddr ifru_hwaddr; short ifru_flags; int ifru_ivalue; int ifru_mtu; struct ifmap ifru_map; char ifru_slave[16]; char ifru_newname[16]; char *ifru_data; } ifr_ifru; }

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


repo: sdbakker/sio-platform

decompiled_code:
void __fastcall list_del(__int64 a1)
{
_QWORD *v1; // rax

_list_del(*(_QWORD **)(a1 + 8), *(_QWORD *)a1);
*v1 = 0LL;
v1[1] = 0LL;
}

original_code:
static inline void list_del(struct list_head *entry)
{
 __list_del(entry->prev, entry->next);
 entry->next = ((void *)0);
 entry->prev = ((void *)0);
}

variable_types: struct list_head { struct list_head *next; } *

return_type: void


decompiled_code:
_QWORD *config_add_module()
{
_QWORD *v0; // r12
__int64 v1; // rax
__int64 v2; // rbp
_QWORD *v3; // rax
_QWORD *v4; // rdi
__int64 *v5; // rax

v0 = 0LL;
v1 = sios_alloc_module();
if ( v1 )
{
v2 = v1;
v3 = malloc(0x20uLL);
v0 = v3;
if ( v3 )
{
v4 = v3 + 2;
INIT_LIST_HEAD(v3 + 2);
*v5 = v2;
list_add(v4, (__int64 *)(config + 56));
}
else
{
sios_destroy_module(v2);
}
}
return v0;
}

canonical_decompiled_code:
_QWORD *func5()
{
_QWORD *v0; // r12
__int64 v1; // rax
__int64 v2; // rbp
_QWORD *v3; // rax
_QWORD *v4; // rdi
__int64 *v5; // rax

v0 = 0LL;
v1 = sios_alloc_module();
if ( v1 )
{
v2 = v1;
v3 = malloc(0x20uLL);
v0 = v3;
if ( v3 )
{
v4 = v3 + 2;
func0(v3 + 2);
*v5 = v2;
func2(v4, (__int64 *)(config + 56));
}
else
{
sios_destroy_module(v2);
}
}
return v0;
}

original_code:
static struct module_entry * config_add_module()
{
 struct sios_module * module = sios_alloc_module();
 if (module) {
  struct module_entry * entry =
   (struct module_entry*)malloc(sizeof(struct module_entry));
  if (!entry) {
   sios_destroy_module(module);
   return ((void *)0);
  }
  INIT_LIST_HEAD(&entry->entry);
  entry->module = module;
  list_add(&entry->entry, &config->module_entries);
  return entry;
 }
 return ((void *)0);
}

canonical_original_code:
static struct module_entry *config_add_module()
{
 struct sios_module *module = sios_alloc_module();
 if (module) {
  struct module_entry *entry = (struct module_entry*)malloc(sizeof(struct module_entry));
  if (!entry) {
   sios_destroy_module(module);
   return ((void *)0);
  }
  INIT_LIST_HEAD(&entry->entry);
  entry->module = module;
  list_add(&entry->entry, &config->module_entries);
  return entry;
 }
 return ((void *)0);
}

variable_types: struct module_entry { struct sios_module { char *basename; char *path; int lazy; char *lazy_id; void *dl_handle; struct list_head { struct list_head *next; } params; struct list_head list; char *module_name; char *module_descr; struct sios_class { char name[64]; char classpath[128]; struct list_head object_list; struct list_head class_head; } *class; struct sios_object { char name[64]; char path[128]; char *desc; char *id; int type; struct sios_class *class; struct list_head class_head; struct list_head object_head; struct list_head osc_methods; struct list_head osc_params; struct list_head listeners; } *obj; int (*init)(); void (*destroy)(); void (*set_name)(char *name); void (*set_descr)(char *descr); void (*set_class)(struct sios_class *class); } *module; char *class; struct list_head entry; } *

user_defined_types: struct sios_module { char *basename; char *path; int lazy; char *lazy_id; void *dl_handle; struct list_head params; struct list_head list; char *module_name; char *module_descr; struct sios_class *class; struct sios_object *obj; int (*init)(); void (*destroy)(); void (*set_name)(char *name); void (*set_descr)(char *descr); void (*set_class)(struct sios_class *class); }

user_defined_types: struct module_entry { struct sios_module *module; char *class; struct list_head entry; }


yyparse

original_code:
int
yyparse (void)
{
    int yystate;
    int yyerrstatus;
    yytype_int16 yyssa[200];
    yytype_int16 *yyss;
    yytype_int16 *yyssp;
    YYSTYPE yyvsa[200];
    YYSTYPE *yyvs;
    YYSTYPE *yyvsp;
    long unsigned int yystacksize;
  int yyn;
  int yyresult;
  int yytoken = 0;
  YYSTYPE yyval;
  int yylen = 0;
  yyssp = yyss = yyssa;
  yyvsp = yyvs = yyvsa;
  yystacksize = 200;
  ;
  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = (-2);
  goto yysetstate;
yynewstate:
  yyssp++;
yysetstate:
  *yyssp = (yytype_int16) yystate;
  if (yyss + yystacksize - 1 <= yyssp)
    {
      long unsigned int yysize = (long unsigned int) (yyssp - yyss + 1);
      if (10000 <= yystacksize)
        goto yyexhaustedlab;
      yystacksize *= 2;
      if (10000 < yystacksize)
        yystacksize = 10000;
      {
        yytype_int16 *yyss1 = yyss;
        union yyalloc *yyptr =
          (union yyalloc *) malloc (((yystacksize) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) + (sizeof (union yyalloc) - 1)));
        if (! yyptr)
          goto yyexhaustedlab;
        do { long unsigned int yynewbytes; __builtin_memcpy (&yyptr->yyss_alloc, yyss, (yysize) * sizeof (*(yyss))); yyss = &yyptr->yyss_alloc; yynewbytes = yystacksize * sizeof (*yyss) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        do { long unsigned int yynewbytes; __builtin_memcpy (&yyptr->yyvs_alloc, yyvs, (yysize) * sizeof (*(yyvs))); yyvs = &yyptr->yyvs_alloc; yynewbytes = yystacksize * sizeof (*yyvs) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        if (yyss1 != yyssa)
          free (yyss1);
      }
      yyssp = yyss + yysize - 1;
      yyvsp = yyvs + yysize - 1;
      ;
      if (yyss + yystacksize - 1 <= yyssp)
        goto yyabortlab;
    }
  ;
  if (yystate == 18)
    goto yyacceptlab;
  goto yybackup;
yybackup:
  yyn = yypact[yystate];
  if ((!!((yyn) == (-27))))
    goto yydefault;
  if (yychar == (-2))
    {
      ;
      yychar = yylex ();
    }
  if (yychar <= 0)
    {
      yychar = yytoken = 0;
      ;
    }
  else
    {
      yytoken = ((unsigned) (yychar) <= 283 ? yytranslate[yychar] : 2);
      ;
    }
  yyn += yytoken;
  if (yyn < 0 || 59 < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if (0)
        goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }
  if (yyerrstatus)
    yyerrstatus--;
  ;
  yychar = (-2);
  yystate = yyn;

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  goto yynewstate;
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;
yyreduce:
  yylen = yyr2[yyn];
  yyval = yyvsp[1-yylen];
  ;
  switch (yyn)
    {
        case 5:
    {
   config_add_class((yyvsp[0].str));
  }
    break;
  case 6:
    {
   config->strict_versioning = (yyvsp[0].bool);
  }
    break;
  case 7:
    {
   use_syslog = 1;
  }
    break;
  case 8:
    {
   config->dump_module_xml = (yyvsp[0].bool);
  }
    break;
  case 9:
    {
   config->xml_dump_path = strdup((yyvsp[0].str));
  }
    break;
  case 10:
    {
   config->xml_module_prefix = strdup((yyvsp[0].str));
  }
    break;
  case 13:
    { (yyval.osc) = ((void *)0); }
    break;
  case 14:
    { (yyval.osc) = &config->osc; }
    break;
  case 17:
    { config->osc.port = (yyvsp[0].num); }
    break;
  case 18:
    { config->osc.root = strdup((yyvsp[0].str)); }
    break;
  case 19:
    { config->osc.do_udp = (yyvsp[0].bool); }
    break;
  case 20:
    { config->osc.do_tcp = (yyvsp[0].bool); }
    break;
  case 21:
    { (yyval.entry) = ((void *)0); }
    break;
  case 22:
    {
   (yyval.entry) = config_add_module();
   module_entry = (yyval.entry);
  }
    break;
  case 23:
    {
   module_entry->module->module_name = strdup((yyvsp[0].str));
   (yyval.str) = (yyvsp[0].str);
  }
    break;
  case 25:
    {
   sios_module_add_param(module_entry->module, (yyvsp[0].param));
  }
    break;
  case 27:
    {
   sios_module_add_param(module_entry->module, (yyvsp[0].param));
  }
    break;
  case 28:
    {
   module_entry->module->path = strdup((yyvsp[0].str));
  }
    break;
  case 29:
    {
   module_entry->class = strdup((yyvsp[0].str));
  }
    break;
  case 30:
    {
   module_entry->module->module_descr = strdup((yyvsp[0].str));
  }
    break;
  case 31:
    {
   module_entry->module->lazy = 1;
  }
    break;
  case 32:
    {
   sios_param_set_val((yyvsp[-1].param), (yyvsp[0].str));
   (yyval.param) = (yyvsp[-1].param);
  }
    break;
  case 33:
    {
  (yyval.param) = sios_param_alloc((yyvsp[0].str));
 }
    break;
      default: break;
    }
  ;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  *++yyvsp = yyval;
  {
    const int yylhs = yyr1[yyn] - 31;
    const int yyi = yypgoto[yylhs] + *yyssp;
    yystate = (0 <= yyi && yyi <= 59 && yycheck[yyi] == *yyssp
               ? yytable[yyi]
               : yydefgoto[yylhs]);
  }
  goto yynewstate;
yyerrlab:
  yytoken = yychar == (-2) ? (-2) : ((unsigned) (yychar) <= 283 ? yytranslate[yychar] : 2);
  if (!yyerrstatus)
    {
      ++yynerrs;
      yyerror ("syntax error");
    }
  if (yyerrstatus == 3)
    {
      if (yychar <= 0)
        {
          if (yychar == 0)
            goto yyabortlab;
        }
      else
        {
          yydestruct ("Error: discarding",
                      yytoken, &yylval);
          yychar = (-2);
        }
    }
  goto yyerrlab1;
yyerrorlab:
  if (0)
    goto yyerrorlab;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  yystate = *yyssp;
  goto yyerrlab1;
yyerrlab1:
  yyerrstatus = 3;
  for (;;)
    {
      yyn = yypact[yystate];
      if (!(!!((yyn) == (-27))))
        {
          yyn += 1;
          if (0 <= yyn && yyn <= 59 && yycheck[yyn] == 1)
            {
              yyn = yytable[yyn];
              if (0 < yyn)
                break;
            }
        }
      if (yyssp == yyss)
        goto yyabortlab;
      yydestruct ("Error: popping",
                  yystos[yystate], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
      yystate = *yyssp;
      ;
    }

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  ;
  yystate = yyn;
  goto yynewstate;
yyacceptlab:
  yyresult = 0;
  goto yyreturn;
yyabortlab:
  yyresult = 1;
  goto yyreturn;
yyexhaustedlab:
  yyerror ("memory exhausted");
  yyresult = 2;
yyreturn:
  if (yychar != (-2))
    {
      yytoken = ((unsigned) (yychar) <= 283 ? yytranslate[yychar] : 2);
      yydestruct ("Cleanup: discarding lookahead",
                  yytoken, &yylval);
    }
  (yyvsp -= (yylen), yyssp -= (yylen));
  ;
  while (yyssp != yyss)
    {
      yydestruct ("Cleanup: popping",
                  yystos[*yyssp], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
    }
  if (yyss != yyssa)
    free (yyss);
  return yyresult;
}

canonical_original_code:
int yyparse()
{
    int yystate;
    int yyerrstatus;
    short yyssa[200];
    short *yyss;
    short *yyssp;
    union YYSTYPE yyvsa[200];
    union YYSTYPE *yyvs;
    union YYSTYPE *yyvsp;
    unsigned long yystacksize;
  int yyn;
  int yyresult;
  int yytoken = 0;
  union YYSTYPE yyval;
  int yylen = 0;
  yyssp = yyss = yyssa;
  yyvsp = yyvs = yyvsa;
  yystacksize = 200;
  ;
  yystate = 0;
  yyerrstatus = 0;
  yynerrs = 0;
  yychar = (-2);
  goto yysetstate;
yynewstate:
  yyssp++;
yysetstate:
  *yyssp = (short) yystate;
  if (yyss + yystacksize - 1 <= yyssp)
    {
      unsigned long yysize = (long unsigned int) (yyssp - yyss + 1);
      if (10000 <= yystacksize)
        goto yyexhaustedlab;
      yystacksize *= 2;
      if (10000 < yystacksize)
        yystacksize = 10000;
      {
        short *yyss1 = yyss;
        union yyalloc *yyptr = (union yyalloc *) malloc (((yystacksize) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) + (sizeof (union yyalloc) - 1)));
        if (! yyptr)
          goto yyexhaustedlab;
        do { unsigned long yynewbytes; __builtin_memcpy (&yyptr->yyss_alloc, yyss, (yysize) * sizeof (*(yyss))); yyss = &yyptr->yyss_alloc; yynewbytes = yystacksize * sizeof (*yyss) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        do { unsigned long yynewbytes; __builtin_memcpy (&yyptr->yyvs_alloc, yyvs, (yysize) * sizeof (*(yyvs))); yyvs = &yyptr->yyvs_alloc; yynewbytes = yystacksize * sizeof (*yyvs) + (sizeof (union yyalloc) - 1); yyptr += yynewbytes / sizeof (*yyptr); } while (0);
        if (yyss1 != yyssa)
          free (yyss1);
      }
      yyssp = yyss + yysize - 1;
      yyvsp = yyvs + yysize - 1;
      ;
      if (yyss + yystacksize - 1 <= yyssp)
        goto yyabortlab;
    }
  ;
  if (yystate == 18)
    goto yyacceptlab;
  goto yybackup;
yybackup:
  yyn = yypact[yystate];
  if ((!!((yyn) == (-27))))
    goto yydefault;
  if (yychar == (-2))
    {
      ;
      yychar = yylex ();
    }
  if (yychar <= 0)
    {
      yychar = yytoken = 0;
      ;
    }
  else
    {
      yytoken = ((unsigned int) (yychar) <= 283 ? yytranslate[yychar] : 2);
      ;
    }
  yyn += yytoken;
  if (yyn < 0 || 59 < yyn || yycheck[yyn] != yytoken)
    goto yydefault;
  yyn = yytable[yyn];
  if (yyn <= 0)
    {
      if (0)
        goto yyerrlab;
      yyn = -yyn;
      goto yyreduce;
    }
  if (yyerrstatus)
    yyerrstatus--;
  ;
  yychar = (-2);
  yystate = yyn;

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  goto yynewstate;
yydefault:
  yyn = yydefact[yystate];
  if (yyn == 0)
    goto yyerrlab;
  goto yyreduce;
yyreduce:
  yylen = yyr2[yyn];
  yyval = yyvsp[1-yylen];
  ;
  switch (yyn)
    {
        case 5:
    {
   config_add_class((yyvsp[0].str));
  }
    break;
  case 6:
    {
   config->strict_versioning = (yyvsp[0].bool);
  }
    break;
  case 7:
    {
   use_syslog = 1;
  }
    break;
  case 8:
    {
   config->dump_module_xml = (yyvsp[0].bool);
  }
    break;
  case 9:
    {
   config->xml_dump_path = strdup((yyvsp[0].str));
  }
    break;
  case 10:
    {
   config->xml_module_prefix = strdup((yyvsp[0].str));
  }
    break;
  case 13:
    { (yyval.osc) = ((void *)0); }
    break;
  case 14:
    { (yyval.osc) = &config->osc; }
    break;
  case 17:
    { config->osc.port = (yyvsp[0].num); }
    break;
  case 18:
    { config->osc.root = strdup((yyvsp[0].str)); }
    break;
  case 19:
    { config->osc.do_udp = (yyvsp[0].bool); }
    break;
  case 20:
    { config->osc.do_tcp = (yyvsp[0].bool); }
    break;
  case 21:
    { (yyval.entry) = ((void *)0); }
    break;
  case 22:
    {
   (yyval.entry) = config_add_module();
   module_entry = (yyval.entry);
  }
    break;
  case 23:
    {
   module_entry->module->module_name = strdup((yyvsp[0].str));
   (yyval.str) = (yyvsp[0].str);
  }
    break;
  case 25:
    {
   sios_module_add_param(module_entry->module, (yyvsp[0].param));
  }
    break;
  case 27:
    {
   sios_module_add_param(module_entry->module, (yyvsp[0].param));
  }
    break;
  case 28:
    {
   module_entry->module->path = strdup((yyvsp[0].str));
  }
    break;
  case 29:
    {
   module_entry->class = strdup((yyvsp[0].str));
  }
    break;
  case 30:
    {
   module_entry->module->module_descr = strdup((yyvsp[0].str));
  }
    break;
  case 31:
    {
   module_entry->module->lazy = 1;
  }
    break;
  case 32:
    {
   sios_param_set_val((yyvsp[-1].param), (yyvsp[0].str));
   (yyval.param) = (yyvsp[-1].param);
  }
    break;
  case 33:
    {
  (yyval.param) = sios_param_alloc((yyvsp[0].str));
 }
    break;
      default: break;
    }
  ;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  *++yyvsp = yyval;
  {
    int yylhs = yyr1[yyn] - 31;
    int yyi = yypgoto[yylhs] + *yyssp;
    yystate = (0 <= yyi && yyi <= 59 && yycheck[yyi] == *yyssp
               ? yytable[yyi]
               : yydefgoto[yylhs]);
  }
  goto yynewstate;
yyerrlab:
  yytoken = yychar == (-2) ? (-2) : ((unsigned int) (yychar) <= 283 ? yytranslate[yychar] : 2);
  if (!yyerrstatus)
    {
      ++yynerrs;
      yyerror ("syntax error");
    }
  if (yyerrstatus == 3)
    {
      if (yychar <= 0)
        {
          if (yychar == 0)
            goto yyabortlab;
        }
      else
        {
          yydestruct ("Error: discarding",
                      yytoken, &yylval);
          yychar = (-2);
        }
    }
  goto yyerrlab1;
yyerrorlab:
  if (0)
    goto yyerrorlab;
  (yyvsp -= (yylen), yyssp -= (yylen));
  yylen = 0;
  ;
  yystate = *yyssp;
  goto yyerrlab1;
yyerrlab1:
  yyerrstatus = 3;
  for (;;)
    {
      yyn = yypact[yystate];
      if (!(!!((yyn) == (-27))))
        {
          yyn += 1;
          if (0 <= yyn && yyn <= 59 && yycheck[yyn] == 1)
            {
              yyn = yytable[yyn];
              if (0 < yyn)
                break;
            }
        }
      if (yyssp == yyss)
        goto yyabortlab;
      yydestruct ("Error: popping",
                  yystos[yystate], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
      yystate = *yyssp;
      ;
    }

#pragma GCC diagnostic push

#pragma GCC diagnostic ignored "-Wuninitialized"

#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"

  *++yyvsp = yylval;

#pragma GCC diagnostic pop

  ;
  yystate = yyn;
  goto yynewstate;
yyacceptlab:
  yyresult = 0;
  goto yyreturn;
yyabortlab:
  yyresult = 1;
  goto yyreturn;
yyexhaustedlab:
  yyerror ("memory exhausted");
  yyresult = 2;
yyreturn:
  if (yychar != (-2))
    {
      yytoken = ((unsigned int) (yychar) <= 283 ? yytranslate[yychar] : 2);
      yydestruct ("Cleanup: discarding lookahead",
                  yytoken, &yylval);
    }
  (yyvsp -= (yylen), yyssp -= (yylen));
  ;
  while (yyssp != yyss)
    {
      yydestruct ("Cleanup: popping",
                  yystos[*yyssp], yyvsp);
      (yyvsp -= (1), yyssp -= (1));
    }
  if (yyss != yyssa)
    free (yyss);
  return yyresult;
}

variable_types: yystate int

variable_types: yyerrstatus int

variable_types:
yyssa
short [200]

variable_types:
yyss
short *

variable_types:
yyssp
short *

variable_types: union YYSTYPE { char *str; long num; float fnum; char bool; struct osc_entry { char *root; int port; char do_udp; char do_tcp; } *osc; struct module_entry { struct sios_module { char *basename; char *path; int lazy; char *lazy_id; void *dl_handle; struct list_head { struct list_head *next; } params; struct list_head list; char *module_name; char *module_descr; struct sios_class { char name[64]; char classpath[128]; struct list_head object_list; struct list_head class_head; } *class; struct sios_object { char name[64]; char path[128]; char *desc; char *id; int type; struct sios_class *class; struct list_head class_head; struct list_head object_head; struct list_head osc_methods; struct list_head osc_params; struct list_head listeners; } *obj; int (*init)(); void (*destroy)(); void (*set_name)(char *name); void (*set_descr)(char *descr); void (*set_class)(struct sios_class *class); } *module; char *class; struct list_head entry; } *entry; struct sios_param_type { char *name; char *val; struct list_head params; } *param; } [200]

variable_types: union YYSTYPE { char *str; long num; float fnum; char bool; struct osc_entry { char *root; int port; char do_udp; char do_tcp; } *osc; struct module_entry { struct sios_module { char *basename; char *path; int lazy; char *lazy_id; void *dl_handle; struct list_head { struct list_head *next; } params; struct list_head list; char *module_name; char *module_descr; struct sios_class { char name[64]; char classpath[128]; struct list_head object_list; struct list_head class_head; } *class; struct sios_object { char name[64]; char path[128]; char *desc; char *id; int type; struct sios_class *class; struct list_head class_head; struct list_head object_head; struct list_head osc_methods; struct list_head osc_params; struct list_head listeners; } *obj; int (*init)(); void (*destroy)(); void (*set_name)(char *name); void (*set_descr)(char *descr); void (*set_class)(struct sios_class *class); } *module; char *class; struct list_head entry; } *entry; struct sios_param_type { char *name; char *val; struct list_head params; } *param; } *

variable_types:
yystacksize
unsigned long

variable_types: yyn int

variable_types: yyresult int

variable_types: yytoken int

variable_types: yylen int

variable_types:
yysize
unsigned long

variable_types: union yyalloc { short yyss_alloc; union YYSTYPE { char *str; long num; float fnum; char bool; struct osc_entry { char *root; int port; char do_udp; char do_tcp; } *osc; struct module_entry { struct sios_module { char *basename; char *path; int lazy; char *lazy_id; void *dl_handle; struct list_head { struct list_head *next; } params; struct list_head list; char *module_name; char *module_descr; struct sios_class { char name[64]; char classpath[128]; struct list_head object_list; struct list_head class_head; } *class; struct sios_object { char name[64]; char path[128]; char *desc; char *id; int type; struct sios_class *class; struct list_head class_head; struct list_head object_head; struct list_head osc_methods; struct list_head osc_params; struct list_head listeners; } *obj; int (*init)(); void (*destroy)(); void (*set_name)(char *name); void (*set_descr)(char *descr); void (*set_class)(struct sios_class *class); } *module; char *class; struct list_head entry; } *entry; struct sios_param_type { char *name; char *val; struct list_head params; } *param; } yyvs_alloc; } *

variable_types:
yynewbytes
unsigned long

variable_types: yylhs int

variable_types: yyi int

return_type: int

user_defined_types: union YYSTYPE { char *str; long num; float fnum; char bool; struct osc_entry *osc; struct module_entry *entry; struct sios_param_type *param; }

user_defined_types: union yyalloc { short yyss_alloc; union YYSTYPE yyvs_alloc; }


decompiled_code:
_BOOL8 __fastcall list_empty(_QWORD *a1)
{
return *a1 == (_QWORD)a1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(_QWORD *a1)
{
return *a1 == (_QWORD)a1;
}

original_code:
static inline int list_empty(const struct list_head *head)
{
 return head->next == head;
}

canonical_original_code:
static inline int list_empty(struct list_head *head)
{
 return head->next == head;
}

variable_types: struct list_head { struct list_head *next; } *


decompiled_code:
void sios_osc_dump_xml()
{
const char *v0; // r13
size_t v1; // rbp
char *v2; // r12
int v3; // eax
int v4; // ebp
__int64 v5; // rax
size_t v6; // r13
size_t v7; // r13
int v8; // edi
char *v9; // rax
char *v10; // rax
char s[1048]; // [rsp+0h] [rbp-418h] BYREF

v0 = *(const char **)(config + 24LL);
v1 = (int)(strlen(v0) + 9);
v2 = (char *)malloc(v1);
snprintf(v2, v1, "%s/osc.xml", v0);
v3 = open(v2, 65, 493LL);
if ( v3 >= 0 )
{
v4 = v3;
v5 = config;
if ( *(_BYTE *)(config + 12LL) )
{
v7 = sprintf(
s,
"<%s %s=\"%d\" %s=\"%s\" %s=\"%s\"/>\n",
"osc",
"port",
*(unsigned int *)(config + 8LL),
"proto",
"udp",
"root",
(const char *)*config);
write(v4, s, v7);
memset(s, 0, v7);
v5 = config;
if ( !*(_BYTE *)(config + 13LL) )
goto LABEL_4;
}
else if ( !*(_BYTE *)(config + 13LL) )
{
LABEL_4:
free(v2);
close(v4);
return;
}
v6 = sprintf(
s,
"<%s %s=\"%d\" %s=\"%s\" %s=\"%s\"/>\n",
"osc",
"port",
*(unsigned int *)(v5 + 8),
"proto",
"tcp",
"root",
*(const char **)v5);
write(v4, s, v6);
memset(s, 0, v6);
goto LABEL_4;
}
v8 = *_errno_location();
if ( use_syslog )
{
v10 = strerror(v8);
syslog(4, "Warning: [%s] Could not open xml dump path '%s': %s", "XMLDUMP", v2, v10);
}
else
{
v9 = strerror(v8);
fprintf(stdout, "Warning: [%s] Could not open xml dump path '%s': %s\n", "XMLDUMP", v2, v9);
}
free(v2);
}

canonical_decompiled_code:
void func1()
{
const char *v0; // r13
size_t v1; // rbp
char *v2; // r12
int v3; // eax
int v4; // ebp
__int64 v5; // rax
size_t v6; // r13
size_t v7; // r13
int v8; // edi
char *v9; // rax
char *v10; // rax
char s[1048]; // [rsp+0h] [rbp-418h] BYREF

v0 = *(const char **)(config + 24LL);
v1 = (int)(strlen(v0) + 9);
v2 = (char *)malloc(v1);
snprintf(v2, v1, "%s/osc.xml", v0);
v3 = open(v2, 65, 493LL);
if ( v3 >= 0 )
{
v4 = v3;
v5 = config;
if ( *(_BYTE *)(config + 12LL) )
{
v7 = sprintf(
s,
"<%s %s=\"%d\" %s=\"%s\" %s=\"%s\"/>\n",
"osc",
"port",
*(unsigned int *)(config + 8LL),
"proto",
"udp",
"root",
(const char *)*config);
write(v4, s, v7);
memset(s, 0, v7);
v5 = config;
if ( !*(_BYTE *)(config + 13LL) )
goto LABEL_4;
}
else if ( !*(_BYTE *)(config + 13LL) )
{
LABEL_4:
free(v2);
close(v4);
return;
}
v6 = sprintf(
s,
"<%s %s=\"%d\" %s=\"%s\" %s=\"%s\"/>\n",
"osc",
"port",
*(unsigned int *)(v5 + 8),
"proto",
"tcp",
"root",
*(const char **)v5);
write(v4, s, v6);
memset(s, 0, v6);
goto LABEL_4;
}
v8 = *_errno_location();
if ( use_syslog )
{
v10 = strerror(v8);
syslog(4, "Warning: [%s] Could not open xml dump path '%s': %s", "XMLDUMP", v2, v10);
}
else
{
v9 = strerror(v8);
fprintf(stdout, "Warning: [%s] Could not open xml dump path '%s': %s\n", "XMLDUMP", v2, v9);
}
free(v2);
}

original_code:
void sios_osc_dump_xml(void)
{
 char * dumppath;
 char linebuf[1024];
 int buflen;
 int pathlen;
 int fd;
 pathlen = strlen(config->xml_dump_path) + 9;
 dumppath = (char*)malloc(pathlen);
 snprintf(dumppath, pathlen, "%s/osc.xml", config->xml_dump_path);
 fd = open(dumppath, 01|0100, 0755);
 if (fd < 0) {
  do { if (use_syslog) { syslog(4, "Warning: [%s] " "Could not open xml dump path '%s': %s","XMLDUMP", dumppath, strerror((*__errno_location ()))); } else { fprintf(stdout, "Warning: [%s] " "Could not open xml dump path '%s': %s" "\n","XMLDUMP", dumppath, strerror((*__errno_location ()))); } } while (0);
  free(dumppath);
  return;
 }
 if (config->osc.do_udp) {
  buflen = sprintf(linebuf, "<%s %s=\"%d\" %s=\"%s\" %s=\"%s\"/>\n",
       "osc",
       "port", config->osc.port,
       "proto", "udp",
       "root", config->osc.root);
  write(fd, linebuf, buflen);
  bzero(linebuf, buflen);
 }
 if (config->osc.do_tcp) {
  buflen = sprintf(linebuf, "<%s %s=\"%d\" %s=\"%s\" %s=\"%s\"/>\n",
       "osc",
       "port", config->osc.port,
       "proto", "tcp",
       "root", config->osc.root);
  write(fd, linebuf, buflen);
  bzero(linebuf, buflen);
 }
 free(dumppath);
 close(fd);
}

canonical_original_code:
void sios_osc_dump_xml()
{
 char *dumppath;
 char linebuf[1024];
 int buflen;
 int pathlen;
 int fd;
 pathlen = strlen(config->xml_dump_path) + 9;
 dumppath = (char *)malloc(pathlen);
 snprintf(dumppath, pathlen, "%s/osc.xml", config->xml_dump_path);
 fd = open(dumppath, 01|0100, 0755);
 if (fd < 0) {
  do { if (use_syslog) { syslog(4, "Warning: [%s] " "Could not open xml dump path '%s': %s","XMLDUMP", dumppath, strerror((*__errno_location ()))); } else { fprintf(stdout, "Warning: [%s] " "Could not open xml dump path '%s': %s" "\n","XMLDUMP", dumppath, strerror((*__errno_location ()))); } } while (0);
  free(dumppath);
  return;
 }
 if (config->osc.do_udp) {
  buflen = sprintf(linebuf, "<%s %s=\"%d\" %s=\"%s\" %s=\"%s\"/>\n",
       "osc",
       "port", config->osc.port,
       "proto", "udp",
       "root", config->osc.root);
  write(fd, linebuf, buflen);
  bzero(linebuf, buflen);
 }
 if (config->osc.do_tcp) {
  buflen = sprintf(linebuf, "<%s %s=\"%d\" %s=\"%s\" %s=\"%s\"/>\n",
       "osc",
       "port", config->osc.port,
       "proto", "tcp",
       "root", config->osc.root);
  write(fd, linebuf, buflen);
  bzero(linebuf, buflen);
 }
 free(dumppath);
 close(fd);
}

variable_types:
dumppath
char *

variable_types:
linebuf
char [1024]

variable_types: buflen int

variable_types: pathlen int

variable_types: fd int


decompiled_code:
void sios_dump_xml()
{
if ( *(_QWORD *)(config + 24LL) )
{
sios_dump_classes();
sios_dump_modules();
sios_osc_dump_xml();
}
}

canonical_decompiled_code:
void func2()
{
if ( *(_QWORD *)(config + 24LL) )
{
sios_dump_classes();
sios_dump_modules();
func1();
}
}

original_code:
void sios_dump_xml(void)
{
 if (config->xml_dump_path) {
  sios_dump_classes();
  sios_dump_modules();
  sios_osc_dump_xml();
 }
}

canonical_original_code:
void sios_dump_xml()
{
 if (config->xml_dump_path) {
  sios_dump_classes();
  sios_dump_modules();
  sios_osc_dump_xml();
 }
}


original_code:
int timeval_subtract (struct timeval * result,
        struct timeval * x,
        struct timeval * y)
{
 if (x->tv_usec < y->tv_usec) {
  int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1;
  y->tv_usec -= 1000000 * nsec;
  y->tv_sec += nsec;
 }
 if (x->tv_usec - y->tv_usec > 1000000) {
  int nsec = (x->tv_usec - y->tv_usec) / 1000000;
  y->tv_usec += 1000000 * nsec;
  y->tv_sec -= nsec;
 }
 result->tv_sec = x->tv_sec - y->tv_sec;
 result->tv_usec = x->tv_usec - y->tv_usec;
 return x->tv_sec < y->tv_sec;
}

canonical_original_code:
int timeval_subtract(struct timeval *result, struct timeval *x, struct timeval *y)
{
 if (x->tv_usec < y->tv_usec) {
  int nsec = (y->tv_usec - x->tv_usec) / 1000000 + 1;
  y->tv_usec -= 1000000 * nsec;
  y->tv_sec += nsec;
 }
 if (x->tv_usec - y->tv_usec > 1000000) {
  int nsec = (x->tv_usec - y->tv_usec) / 1000000;
  y->tv_usec += 1000000 * nsec;
  y->tv_sec -= nsec;
 }
 result->tv_sec = x->tv_sec - y->tv_sec;
 result->tv_usec = x->tv_usec - y->tv_usec;
 return x->tv_sec < y->tv_sec;
}

variable_types: struct timeval { long tv_sec; long tv_usec; } *

variable_types:
x
struct timeval *

variable_types:
y
struct timeval *

variable_types: nsec int


repo: sddelong/ddc-svd

decompiled_code:
int __fastcall print_matrix(__int64 a1, __int64 a2, __int64 a3, const char *a4)
{
int result; // eax
__int64 i; // r13
__int64 v7; // rbx
double *v8; // r15
double v9; // xmm0_8

result = printf("%s \n", a4);
if ( a2 > 0 )
{
for ( i = 0LL; i != a2; ++i )
{
v7 = 0LL;
v8 = (double *)(a1 + 8 * i);
if ( a3 > 0 )
{
do
{
v9 = *v8;
++v7;
v8 += a2;
printf("%11.3E", v9);
}
while ( a3 != v7 );
}
result = putchar(10);
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1, __int64 a2, __int64 a3, const char *a4)
{
int result; // eax
__int64 i; // r13
__int64 v7; // rbx
double *v8; // r15
double v9; // xmm0_8

result = printf("%s \n", a4);
if ( a2 > 0 )
{
for ( i = 0LL; i != a2; ++i )
{
v7 = 0LL;
v8 = (double *)(a1 + 8 * i);
if ( a3 > 0 )
{
do
{
v9 = *v8;
++v7;
v8 += a2;
printf("%11.3E", v9);
}
while ( a3 != v7 );
}
result = putchar(10);
}
}
return result;
}

original_code:
void print_matrix(const double * A, long m, long n, char * message){
    printf("%s \n",message);
    for (int i=0; i<m; i++){
  for (int j=0; j<n; j++){
   printf("%11.3E",A[i+m*j]);
  }
  printf("\n");
 }
 return;
}

canonical_original_code:
void print_matrix(double *A, long m, long n, char *message){
    printf("%s \n",message);
    for (int i = 0; i<m; i++){
  for (int j = 0; j<n; j++){
   printf("%11.3E",A[i+m*j]);
  }
  printf("\n");
 }
 return;
}

variable_types:
A
double *

variable_types: m long

variable_types: n long

variable_types:
message
char *

variable_types: i int

variable_types: j int


original_code:
double l2_normv(int l, const double*restrict v){
  double temp = 0;
  for (int i=0; i<l; i++){
   temp+= v[i]*v[i];
  }
  return sqrt(temp);
 }

canonical_original_code:
double l2_normv(int l, double *v){
  double temp = 0;
  for (int i = 0; i<l; i++){
   temp+= v[i]*v[i];
  }
  return sqrt(temp);
 }

variable_types: l int

variable_types:
v
double *

variable_types: temp double

return_type: double


decompiled_code:
void __fastcall scale_vector(int a1, double *a2, double a3)
{
__int64 v4; // rax
double v5; // xmm0_8

if ( a1 > 0 )
{
v4 = (__int64)&a2[(unsigned int)(a1 - 1) + 1];
do
{
v5 = *a2++;
*(a2 - 1) = v5 * a3;
}
while ( a2 != (double *)v4 );
}
}

canonical_decompiled_code:
void __fastcall func2(int a1, double *a2, double a3)
{
__int64 v4; // rax
double v5; // xmm0_8

if ( a1 > 0 )
{
v4 = (__int64)&a2[(unsigned int)(a1 - 1) + 1];
do
{
v5 = *a2++;
*(a2 - 1) = v5 * a3;
}
while ( a2 != (double *)v4 );
}
}

original_code:
void scale_vector(int l, double*restrict v, double scale){
 for (int i=0; i<l; i++){
  v[i] *= scale;
 }
 return;
}

canonical_original_code:
void scale_vector(int l, double *v, double scale){
 for (int i = 0; i<l; i++){
  v[i] *= scale;
 }
 return;
}

variable_types: scale double


decompiled_code:
void __fastcall l2_norm_mat_row(int a1, __int64 a2, int a3, double *a4)
{
int v4; // eax
double v5; // xmm1_8
double v6; // xmm0_8

if ( a3 > 0 )
{
v4 = 0;
v5 = 0.0;
do
{
v6 = *a4;
++v4;
a4 += a1;
v5 = v5 + v6 * v6;
}
while ( a3 != v4 );
if ( v5 < 0.0 )
sqrt(v5);
}
}

original_code:
double l2_norm_mat_row(int m, int n, int l, const double*restrict row){
  double temp = 0;
  for (int i=0; i<l; i++){
   temp+= row[i*m]*row[i*m];
  }
  return sqrt(temp);
 }

canonical_original_code:
double l2_norm_mat_row(int m, int n, int l, double *row){
  double temp = 0;
  for (int i = 0; i<l; i++){
   temp+= row[i*m]*row[i*m];
  }
  return sqrt(temp);
 }

variable_types: m int

variable_types: n int

variable_types:
row
double *


decompiled_code:
void __fastcall scale_mat_row(int a1, double a2, __int64 a3, int a4, double *a5)
{
int i; // eax

if ( a4 > 0 )
{
for ( i = 0; i != a4; ++i )
{
*a5 = *a5 * a2;
a5 += a1;
}
}
}

canonical_decompiled_code:
void __fastcall func5(int a1, double a2, __int64 a3, int a4, double *a5)
{
int i; // eax

if ( a4 > 0 )
{
for ( i = 0; i != a4; ++i )
{
*a5 = *a5 * a2;
a5 += a1;
}
}
}

original_code:
void scale_mat_row(int m, int n, int l, double*restrict row, double scale){
 for (int i=0; i<l; i++){
  row[i*m] *= scale;
 }
 return;
}

canonical_original_code:
void scale_mat_row(int m, int n, int l, double *row, double scale){
 for (int i = 0; i<l; i++){
  row[i*m] *= scale;
 }
 return;
}


decompiled_code:
void *__fastcall set_vec_to_zero(int a1, void *a2)
{
void *result; // rax

if ( a1 > 0 )
result = memset(a2, 0, 8LL * a1);
return result;
}

canonical_decompiled_code:
void *__fastcall func8(int a1, void *a2)
{
void *result; // rax

if ( a1 > 0 )
result = memset(a2, 0, 8LL * a1);
return result;
}

original_code:
void set_vec_to_zero(int l, double*restrict v){
 for (int i=0; i<l; i++){
  v[i] = 0;
 }
 return;
}

canonical_original_code:
void set_vec_to_zero(int l, double *v){
 for (int i = 0; i<l; i++){
  v[i] = 0;
 }
 return;
}


original_code:
void dgemm_simple( const int M, const int N, const int L, const double *A, const double *B, double *C){
 for (int i=0; i<M; i++){
  for (int j=0; j<N; j++){
   for (int k=0; k<L; k++){
     C[i+j*M] = C[i+j*M] + A[i+k*M]*B[k+j*L];
   }
  }
 }
 return;
}

canonical_original_code:
void dgemm_simple(int M, int N, int L, double *A, double *B, double *C){
 for (int i = 0; i<M; i++){
  for (int j = 0; j<N; j++){
   for (int k = 0; k<L; k++){
     C[i+j*M] = C[i+j*M] + A[i+k*M]*B[k+j*L];
   }
  }
 }
 return;
}

variable_types: M int

variable_types: N int

variable_types: L int

variable_types:
B
double *

variable_types:
C
double *

variable_types: k int


original_code:
void form_bidiag( const int M, const int N, const double *alpha, const double *beta, double * mat){
 for (int j=0; j < N; j++){
  for (int i=0; i < M; i++){
   mat[i+j*M] = 0;
  }
 }
 if (N>M){
  for (int i=0; i < M; i++){
   mat[i+i*M] = alpha[i];
   mat[i+(i+1)*M] = beta[i];
  }
 }
 else{
  for (int i=0; i < N-1; i++){
   mat[i+i*M] = alpha[i];
   mat[i+(i+1)*M] = beta[i];
  }
  mat[N-1 + (N-1)*M] = alpha[N-1];
 }
 return;
}

canonical_original_code:
void form_bidiag(int M, int N, double *alpha, double *beta, double *mat){
 for (int j = 0; j < N; j++){
  for (int i = 0; i < M; i++){
   mat[i+j*M] = 0;
  }
 }
 if (N>M){
  for (int i = 0; i < M; i++){
   mat[i+i*M] = alpha[i];
   mat[i+(i+1)*M] = beta[i];
  }
 }
 else{
  for (int i = 0; i < N-1; i++){
   mat[i+i*M] = alpha[i];
   mat[i+(i+1)*M] = beta[i];
  }
  mat[N-1 + (N-1)*M] = alpha[N-1];
 }
 return;
}

variable_types:
alpha
double *

variable_types:
beta
double *

variable_types:
mat
double *


transpose

original_code:
void transpose( const int M, const int N, const double * A, double * AT){
 for (int i=0; i < N; i++){
  for (int j=0; j < M; j++){
   AT[i+j*N] = A[j + i*M];
  }
 }
 return;
}

canonical_original_code:
void transpose(int M, int N, double *A, double *AT){
 for (int i = 0; i < N; i++){
  for (int j = 0; j < M; j++){
   AT[i+j*N] = A[j + i*M];
  }
 }
 return;
}

variable_types:
A
double *

variable_types:
AT
double *

variable_types: i int

variable_types: j int


decompiled_code:
void __fastcall svd_gpu(int a1, int a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6)
{
int v6; // eax
int v7; // er14
void *v8; // r12
void *v9; // rbp
void *v10; // r14
void *v11; // r13
void *ptr; // [rsp+10h] [rbp-98h]
int v15; // [rsp+18h] [rbp-90h]
unsigned int v16; // [rsp+1Ch] [rbp-8Ch]
__int64 v19[6]; // [rsp+30h] [rbp-78h] BYREF
int v20; // [rsp+60h] [rbp-48h]
int v21; // [rsp+64h] [rbp-44h]
int v22; // [rsp+68h] [rbp-40h]

v6 = a1;
v7 = a2 - 1;
if ( a2 <= a1 )
v6 = a2;
if ( a2 > a1 )
v7 = a1;
v15 = v6;
ptr = malloc(8 * a2 * (__int64)a1);
if ( !ptr )
{
fwrite("in main: failed to allocate AT\n", 1uLL, 0x1FuLL, stderr);
abort();
}
v8 = malloc(8LL * v15);
if ( !v8 )
{
fwrite("in main: failed to allocate alpha\n", 1uLL, 0x22uLL, stderr);
abort();
}
v9 = malloc(8LL * v7);
if ( !v9 )
{
fwrite("in main: failed to allocate beta\n", 1uLL, 0x21uLL, stderr);
abort();
}
v16 = v7 + 1;
v10 = malloc(8LL * v15 * (v7 + 1));
if ( !v10 )
{
fwrite("in main: failed to allocate X\n", 1uLL, 0x1EuLL, stderr);
abort();
}
v11 = malloc(8 * v15 * (__int64)v15);
if ( !v11 )
{
fwrite("in main: failed to allocate Y\n", 1uLL, 0x1EuLL, stderr);
abort();
}
bidiag_par((unsigned int)a1, (unsigned int)a2, a3, v8, v9);
transpose((unsigned int)a1, (unsigned int)a2, a3, ptr);
GetSingularValues_Parallel((unsigned int)v15, v8, v9, a4);
CalcRightSingularVectors((unsigned int)v15, v16, v8, v9, a4, v10);
RighttoLeftSingularVectors((unsigned int)v15, v16, v8, v9, a4, v10, v11);
v19[4] = (__int64)v11;
v22 = v15;
v19[5] = a3;
v19[1] = a6;
v19[2] = (__int64)ptr;
v19[0] = a5;
v19[3] = (__int64)v10;
v21 = a2;
v20 = a1;
GOMP_parallel(svd_gpu__omp_fn_0, v19, 0LL, 0LL);
free(ptr);
free(v8);
free(v9);
free(v10);
free(v11);
}

canonical_decompiled_code:
void __fastcall func1(int a1, int a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6)
{
int v6; // eax
int v7; // er14
void *v8; // r12
void *v9; // rbp
void *v10; // r14
void *v11; // r13
void *ptr; // [rsp+10h] [rbp-98h]
int v15; // [rsp+18h] [rbp-90h]
unsigned int v16; // [rsp+1Ch] [rbp-8Ch]
__int64 v19[6]; // [rsp+30h] [rbp-78h] BYREF
int v20; // [rsp+60h] [rbp-48h]
int v21; // [rsp+64h] [rbp-44h]
int v22; // [rsp+68h] [rbp-40h]

v6 = a1;
v7 = a2 - 1;
if ( a2 <= a1 )
v6 = a2;
if ( a2 > a1 )
v7 = a1;
v15 = v6;
ptr = malloc(8 * a2 * (__int64)a1);
if ( !ptr )
{
fwrite("in main: failed to allocate AT\n", 1uLL, 0x1FuLL, stderr);
abort();
}
v8 = malloc(8LL * v15);
if ( !v8 )
{
fwrite("in main: failed to allocate alpha\n", 1uLL, 0x22uLL, stderr);
abort();
}
v9 = malloc(8LL * v7);
if ( !v9 )
{
fwrite("in main: failed to allocate beta\n", 1uLL, 0x21uLL, stderr);
abort();
}
v16 = v7 + 1;
v10 = malloc(8LL * v15 * (v7 + 1));
if ( !v10 )
{
fwrite("in main: failed to allocate X\n", 1uLL, 0x1EuLL, stderr);
abort();
}
v11 = malloc(8 * v15 * (__int64)v15);
if ( !v11 )
{
fwrite("in main: failed to allocate Y\n", 1uLL, 0x1EuLL, stderr);
abort();
}
bidiag_par((unsigned int)a1, (unsigned int)a2, a3, v8, v9);
transpose((unsigned int)a1, (unsigned int)a2, a3, ptr);
GetSingularValues_Parallel((unsigned int)v15, v8, v9, a4);
CalcRightSingularVectors((unsigned int)v15, v16, v8, v9, a4, v10);
RighttoLeftSingularVectors((unsigned int)v15, v16, v8, v9, a4, v10, v11);
v19[4] = (__int64)v11;
v22 = v15;
v19[5] = a3;
v19[1] = a6;
v19[2] = (__int64)ptr;
v19[0] = a5;
v19[3] = (__int64)v10;
v21 = a2;
v20 = a1;
GOMP_parallel(svd_gpu__omp_fn_0, v19, 0LL, 0LL);
free(ptr);
free(v8);
free(v9);
free(v10);
free(v11);
}

original_code:
void svd_gpu(int m, int n, double* A,double * sigma, double * U, double* V){
  timestamp_type time1, time2;
  double elapsed, flops;
  int mn = (m >= n) ? n : m;
  int len_beta = (m >= n) ? n-1 : m;
  double dmn = (double) mn;
  double dm = (double) m;
  double dn = (double) n;
  double * AT = (double *) malloc(sizeof(double) * m *n);
  if(!AT) { fprintf(stderr,"in main: failed to allocate AT\n"); abort();}
  double * alpha = (double *) malloc(sizeof(double) *mn);
  if(!alpha) { fprintf(stderr,"in main: failed to allocate alpha\n"); abort();}
  double *beta = (double *) malloc(sizeof(double) *len_beta);
  if(!beta) { fprintf(stderr,"in main: failed to allocate beta\n"); abort();}
  double *X = (double *) malloc(sizeof(double) *mn*(len_beta + 1));
  if(!X) { fprintf(stderr,"in main: failed to allocate X\n"); abort();}
  double *Y = (double *) malloc(sizeof(double) *mn*mn);
  if(!Y) { fprintf(stderr,"in main: failed to allocate Y\n"); abort();}
  bidiag_par(m,n,A,alpha,beta);
  transpose(m,n,A,AT);
  GetSingularValues_Parallel( mn , alpha, beta, sigma);
  CalcRightSingularVectors(mn,len_beta + 1,alpha,beta,sigma,X);
  RighttoLeftSingularVectors(mn,len_beta + 1,alpha,beta,sigma,X,Y);

#pragma omp parallel for default(shared) firstprivate(A)
  for(int i = 0; i < mn; i++){
      multU(m,n,i,A,Y,U + i*m);
      multV(m,n,i,AT,X,V + i*n);
  }
  free(AT);
  free(alpha);
  free(beta);
  free(X);
  free(Y);
}

canonical_original_code:
void svd_gpu(int m, int n, double *A, double *sigma, double *U, double *V){
  struct timespec time1; struct timespec time2;
  double elapsed; double flops;
  int mn = (m >= n) ? n : m;
  int len_beta = (m >= n) ? n-1 : m;
  double dmn = (double) mn;
  double dm = (double) m;
  double dn = (double) n;
  double *AT = (double *) malloc(sizeof(double) * m *n);
  if(!AT) { fprintf(stderr,"in main: failed to allocate AT\n"); abort();}
  double *alpha = (double *) malloc(sizeof(double) *mn);
  if(!alpha) { fprintf(stderr,"in main: failed to allocate alpha\n"); abort();}
  double *beta = (double *) malloc(sizeof(double) *len_beta);
  if(!beta) { fprintf(stderr,"in main: failed to allocate beta\n"); abort();}
  double *X = (double *) malloc(sizeof(double) *mn*(len_beta + 1));
  if(!X) { fprintf(stderr,"in main: failed to allocate X\n"); abort();}
  double *Y = (double *) malloc(sizeof(double) *mn*mn);
  if(!Y) { fprintf(stderr,"in main: failed to allocate Y\n"); abort();}
  bidiag_par(m,n,A,alpha,beta);
  transpose(m,n,A,AT);
  GetSingularValues_Parallel( mn , alpha, beta, sigma);
  CalcRightSingularVectors(mn,len_beta + 1,alpha,beta,sigma,X);
  RighttoLeftSingularVectors(mn,len_beta + 1,alpha,beta,sigma,X,Y);

#pragma omp parallel for default(shared) firstprivate(A)
  for(int i = 0; i < mn; i++){
      multU(m,n,i,A,Y,U + i*m);
      multV(m,n,i,AT,X,V + i*n);
  }
  free(AT);
  free(alpha);
  free(beta);
  free(X);
  free(Y);
}

variable_types:
sigma
double *

variable_types:
U
double *

variable_types:
V
double *

variable_types: struct timespec { long tv_sec; long tv_nsec; }

variable_types: elapsed double

variable_types: flops double

variable_types: mn int

variable_types: dmn double

variable_types: dm double

variable_types: dn double

variable_types:
X
double *

variable_types:
Y
double *


main

canonical_name: main

repo: sduverger/ld-shatner

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
int v4; // er12
int v5; // ebp
unsigned __int16 *v6; // rax
unsigned __int64 v7; // r14
unsigned __int16 *v8; // rbp
int v9; // ebx
int v10; // er13
__int64 v11; // rsi
int v12; // edx
unsigned int v13; // edx
int v14; // edi
int v16; // [rsp+4h] [rbp-44h]
size_t len; // [rsp+8h] [rbp-40h]

if ( argc != 2 )
{
v4 = -1;
printf("usage: %s <elf>\n", *argv);
return v4;
}
v3 = open(argv[1], 2, envp);
v4 = v3;
if ( v3 == -1 )
{
printf("can't open file %s\n", argv[1]);
return v4;
}
v5 = lseek(v3, 0LL, 2);
lseek(v4, 0LL, 0);
len = v5;
v6 = (unsigned __int16 *)mmap(0LL, v5, 3, 1, v4, 0LL);
v7 = (unsigned int)(*((_DWORD *)v6 + 7) + (_DWORD)v6);
v8 = v6;
v9 = (int)v6;
if ( v6[22] )
{
v10 = 0;
v16 = (_DWORD)v6 + 15;
do
{
if ( *(_DWORD *)v7 == 3 )
{
v11 = *(unsigned int *)(v7 + 16);
if ( (unsigned int)v11 <= 0xF )
{
v4 = -1;
printf("not enough space to fix interp name (%d)\n", v11);
return v4;
}
v12 = *(_DWORD *)(v7 + 4);
*(_QWORD *)(v7 + 16) = 0x1000000010LL;
v13 = v9 + v12;
*(_QWORD *)v13 = 0x2D646C2F62696C2FLL;
*(_WORD *)(v13 + 0xCLL) = 29486;
*(_DWORD *)(v13 + 8LL) = 1802465128;
*(_BYTE *)(v13 + 0xELL) = 111;
memset((void *)(unsigned int)(*(_DWORD *)(v7 + 4) + v16), 0, (unsigned int)(v11 - 16));
}
++v10;
v7 += 32LL;
}
while ( v8[22] > v10 );
}
munmap(v8, len);
v14 = v4;
v4 = 0;
close(v14);
return v4;
}

original_code:
int main(int argc, char **argv)
{
   Elf32_Ehdr *e_hdr;
   Elf32_Phdr *p_hdr;
   int fd, i;
   off_t fd_sz;
   uint32_t len, old;
   if (argc != 2)
   {
      printf("usage: %s <elf>\n", argv[0]);
      return -1;
   }
   if ((fd = open(argv[1], 02)) == -1)
   {
      printf("can't open file %s\n", argv[1]);
      return -1;
   }
   fd_sz = lseek(fd, 0, 2);
   lseek(fd, 0, 0);
   e_hdr = (Elf32_Ehdr*)mmap(((void *)0), fd_sz, 0x1|0x2, 0x01, fd, 0);
   p_hdr = (Elf32_Phdr*)((uint32_t)e_hdr + e_hdr->e_phoff);
   len = strlen("/lib/ld-hook.so")+1;
   for (i=0 ; i<e_hdr->e_phnum ; i++, p_hdr++)
      if (p_hdr->p_type == 3)
      {
  if (p_hdr->p_filesz < len)
  {
     printf("not enough space to fix interp name (%d)\n", p_hdr->p_filesz);
     return -1;
  }
  old = p_hdr->p_filesz;
  p_hdr->p_filesz = p_hdr->p_memsz = len;
  memcpy((void*)((uint32_t)e_hdr+p_hdr->p_offset), "/lib/ld-hook.so", len-1);
  memset((void*)((uint32_t)e_hdr+p_hdr->p_offset+len-1), 0, old-len);
      }
   munmap((void*)e_hdr, fd_sz);
   close(fd);
   return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
   struct Elf32_Ehdr *e_hdr;
   struct Elf32_Phdr *p_hdr;
   int fd; int i;
   long fd_sz;
   unsigned int len; unsigned int old;
   if (argc != 2)
   {
      printf("usage: %s <elf>\n", argv[0]);
      return -1;
   }
   if ((fd = open(argv[1], 02)) == -1)
   {
      printf("can't open file %s\n", argv[1]);
      return -1;
   }
   fd_sz = lseek(fd, 0, 2);
   lseek(fd, 0, 0);
   e_hdr = (struct Elf32_Ehdr *)mmap(((void *)0), fd_sz, 0x1|0x2, 0x01, fd, 0);
   p_hdr = (struct Elf32_Phdr *)((unsigned int)e_hdr + e_hdr->e_phoff);
   len = strlen("/lib/ld-hook.so")+1;
   for (i=0 ; i<e_hdr->e_phnum ; i++, p_hdr++)
      if (p_hdr->p_type == 3)
      {
  if (p_hdr->p_filesz < len)
  {
     printf("not enough space to fix interp name (%d)\n", p_hdr->p_filesz);
     return -1;
  }
  old = p_hdr->p_filesz;
  p_hdr->p_filesz = p_hdr->p_memsz = len;
  memcpy((void *)((unsigned int)e_hdr+p_hdr->p_offset), "/lib/ld-hook.so", len-1);
  memset((void *)((unsigned int)e_hdr+p_hdr->p_offset+len-1), 0, old-len);
      }
   munmap((void *)e_hdr, fd_sz);
   close(fd);
   return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: struct Elf32_Ehdr { unsigned char e_ident[-1]; unsigned short e_type; unsigned short e_machine; unsigned int e_version; unsigned int e_entry; unsigned int e_phoff; unsigned int e_shoff; unsigned int e_flags; unsigned short e_ehsize; unsigned short e_phentsize; unsigned short e_phnum; unsigned short e_shentsize; unsigned short e_shnum; unsigned short e_shstrndx; } *

variable_types: struct Elf32_Phdr { unsigned int p_type; unsigned int p_offset; unsigned int p_vaddr; unsigned int p_paddr; unsigned int p_filesz; unsigned int p_memsz; unsigned int p_flags; unsigned int p_align; } *

variable_types: fd int

variable_types:
len
unsigned int

variable_types:
old
unsigned int


repo: seabat/TohriSDK

decompiled_code:
void *sbt_malloc_init()
{
return memset(&g_allocate_adrs, 0, 0x3E80uLL);
}

canonical_decompiled_code:
void *func0()
{
return memset(&g_allocate_adrs, 0, 0x3E80uLL);
}

original_code:
static void sbt_malloc_init(){
 memset( g_allocate_adrs, 0x00, sizeof(g_allocate_adrs));
}


decompiled_code:
void *__fastcall sbt_malloc(size_t a1)
{
void *v1; // r12
int v2; // er14
__int64 v3; // rbx
__int64 v4; // r14
__int64 v5; // rbp
unsigned int v6; // eax

v1 = malloc(a1);
if ( v1 )
{
v2 = g_sbt_all_alloc_size;
if ( !g_sbt_all_alloc_size )
sbt_malloc_init();
v3 = 0LL;
while ( *(_QWORD *)&g_allocate_adrs[v3] )
{
if ( ++v3 == 1000 )
return v1;
}
v4 = (unsigned int)(a1 + v2);
v5 = (int)v3;
g_sbt_all_alloc_size = v4;
v6 = getpid();
sbt_logln_tofd(
stderr,
"D",
"src/sbt_alloc.c",
"sbt_malloc",
48LL,
v6,
"Add index=%d and address=0x%p => all size=%d ",
v3,
v1,
v4);
*(_QWORD *)&g_allocate_adrs[v5] = v1;
DWORD2(g_allocate_adrs[v5]) = a1;
}
return v1;
}

canonical_decompiled_code:
void *__fastcall func1(size_t a1)
{
void *v1; // r12
int v2; // er14
__int64 v3; // rbx
__int64 v4; // r14
__int64 v5; // rbp
unsigned int v6; // eax

v1 = malloc(a1);
if ( v1 )
{
v2 = g_sbt_all_alloc_size;
if ( !g_sbt_all_alloc_size )
func0();
v3 = 0LL;
while ( *(_QWORD *)&g_allocate_adrs[v3] )
{
if ( ++v3 == 1000 )
return v1;
}
v4 = (unsigned int)(a1 + v2);
v5 = (int)v3;
g_sbt_all_alloc_size = v4;
v6 = getpid();
sbt_logln_tofd(
stderr,
"D",
"src/sbt_alloc.c",
"sbt_malloc",
48LL,
v6,
"Add index=%d and address=0x%p => all size=%d ",
v3,
v1,
v4);
*(_QWORD *)&g_allocate_adrs[v5] = v1;
DWORD2(g_allocate_adrs[v5]) = a1;
}
return v1;
}

original_code:
void* sbt_malloc(size_t size){
 int i;
 void* adr =((void *)0);
 adr = (void*)malloc(size);
 if( ((void *)0)!=adr ){
  if(0==g_sbt_all_alloc_size){
   sbt_malloc_init();
  }
  for( i=0; i<1000; i++ ){
   if( ((void *)0) == g_allocate_adrs[i].addr ){
    g_sbt_all_alloc_size = g_sbt_all_alloc_size + size;
    if(1) sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", __func__, 48, getpid(), "Add index=%d and address=0x%p => all size=%d ", i, adr, g_sbt_all_alloc_size);
    g_allocate_adrs[i].addr=(void*)adr;
    g_allocate_adrs[i].size= size;
    break;
   }
  }
 }
 return adr;
}

canonical_original_code:
void *sbt_malloc(unsigned long size){
 int i;
 void *adr = ((void *)0);
 adr = (void *)malloc(size);
 if( ((void *)0)!=adr ){
  if(0==g_sbt_all_alloc_size){
   sbt_malloc_init();
  }
  for( i=0; i<1000; i++ ){
   if( ((void *)0) == g_allocate_adrs[i].addr ){
    g_sbt_all_alloc_size = g_sbt_all_alloc_size + size;
    if(1) sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", __func__, 48, getpid(), "Add index=%d and address=0x%p => all size=%d ", i, adr, g_sbt_all_alloc_size);
    g_allocate_adrs[i].addr=(void *)adr;
    g_allocate_adrs[i].size= size;
    break;
   }
  }
 }
 return adr;
}

variable_types:
size
unsigned long

variable_types: i int

variable_types:
adr
void *

return_type: void *


decompiled_code:
void __fastcall sbt_free(void *ptr)
{
__int64 v1; // rbx
__int64 v2; // r13
unsigned int v3; // eax

if ( ptr )
{
v1 = 0LL;
while ( *(void **)&g_allocate_adrs[v1] != ptr )
{
if ( ++v1 == 1000 )
goto LABEL_6;
}
g_sbt_all_alloc_size -= DWORD2(g_allocate_adrs[(int)v1]);
v2 = (unsigned int)g_sbt_all_alloc_size;
v3 = getpid();
sbt_logln_tofd(
stderr,
"D",
"src/sbt_alloc.c",
"sbt_free",
66LL,
v3,
"Delete index=%d and address=0x%p => all size=%d",
v1,
ptr,
v2);
g_allocate_adrs[(int)v1] = 0LL;
LABEL_6:
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func2(void *ptr)
{
__int64 v1; // rbx
__int64 v2; // r13
unsigned int v3; // eax

if ( ptr )
{
v1 = 0LL;
while ( *(void **)&g_allocate_adrs[v1] != ptr )
{
if ( ++v1 == 1000 )
goto LABEL_6;
}
g_sbt_all_alloc_size -= DWORD2(g_allocate_adrs[(int)v1]);
v2 = (unsigned int)g_sbt_all_alloc_size;
v3 = getpid();
sbt_logln_tofd(
stderr,
"D",
"src/sbt_alloc.c",
"sbt_free",
66LL,
v3,
"Delete index=%d and address=0x%p => all size=%d",
v1,
ptr,
v2);
g_allocate_adrs[(int)v1] = 0LL;
LABEL_6:
free(ptr);
}
}

original_code:
void sbt_free(void *ptr){
 int i;
 if( ((void *)0)!=ptr ){
  for(i=0; i<1000; i++){
   if(g_allocate_adrs[i].addr==(void*)ptr){
    g_sbt_all_alloc_size = g_sbt_all_alloc_size - g_allocate_adrs[i].size;
    if(1) sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", __func__, 66, getpid(), "Delete index=%d and address=0x%p => all size=%d", i, ptr ,g_sbt_all_alloc_size);
    memset( &g_allocate_adrs[i], 0x00, sizeof(sbt_alloc_st));
    break;
   }
  }
  free(ptr);
 }
}

canonical_original_code:
void sbt_free(void *ptr){
 int i;
 if( ((void *)0)!=ptr ){
  for(i=0; i<1000; i++){
   if(g_allocate_adrs[i].addr==(void *)ptr){
    g_sbt_all_alloc_size = g_sbt_all_alloc_size - g_allocate_adrs[i].size;
    if(1) sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", __func__, 66, getpid(), "Delete index=%d and address=0x%p => all size=%d", i, ptr ,g_sbt_all_alloc_size);
    memset( &g_allocate_adrs[i], 0x00, sizeof(sbt_alloc_st));
    break;
   }
  }
  free(ptr);
 }
}

variable_types:
ptr
void *


decompiled_code:
__int64 sbt_alloc_print_remnants()
{
__int128 *v0; // rbp
__int64 v1; // rbx
unsigned int v2; // eax
const void *v3; // r12
__int64 v4; // r13
unsigned int v5; // eax
unsigned int v6; // eax

v0 = g_allocate_adrs;
v1 = 0LL;
v2 = getpid();
sbt_logln_tofd(
stderr,
"D",
"src/sbt_alloc.c",
"sbt_alloc_print_remnants",
77LL,
v2,
"Start printing the remant of allocations");
do
{
v3 = *(const void **)v0;
if ( *(_QWORD *)v0 )
{
v4 = *((unsigned int *)v0 + 2);
v5 = getpid();
sbt_logln_tofd(
stderr,
"D",
"src/sbt_alloc.c",
"sbt_alloc_print_remnants",
80LL,
v5,
"index=%d address=0x%p size=%d",
v1,
v3,
v4);
}
v1 = (unsigned int)(v1 + 1);
++v0;
}
while ( (_DWORD)v1 != 1000 );
v6 = getpid();
return sbt_logln_tofd(
stderr,
"D",
"src/sbt_alloc.c",
"sbt_alloc_print_remnants",
83LL,
v6,
"Terminate printing the remant of allocations");
}

canonical_decompiled_code:
__int64 func3()
{
__int128 *v0; // rbp
__int64 v1; // rbx
unsigned int v2; // eax
const void *v3; // r12
__int64 v4; // r13
unsigned int v5; // eax
unsigned int v6; // eax

v0 = g_allocate_adrs;
v1 = 0LL;
v2 = getpid();
sbt_logln_tofd(
stderr,
"D",
"src/sbt_alloc.c",
"sbt_alloc_print_remnants",
77LL,
v2,
"Start printing the remant of allocations");
do
{
v3 = *(const void **)v0;
if ( *(_QWORD *)v0 )
{
v4 = *((unsigned int *)v0 + 2);
v5 = getpid();
sbt_logln_tofd(
stderr,
"D",
"src/sbt_alloc.c",
"sbt_alloc_print_remnants",
80LL,
v5,
"index=%d address=0x%p size=%d",
v1,
v3,
v4);
}
v1 = (unsigned int)(v1 + 1);
++v0;
}
while ( (_DWORD)v1 != 1000 );
v6 = getpid();
return sbt_logln_tofd(
stderr,
"D",
"src/sbt_alloc.c",
"sbt_alloc_print_remnants",
83LL,
v6,
"Terminate printing the remant of allocations");
}

original_code:
void sbt_alloc_print_remnants(){
 int i=0;
 sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", __func__, 77, getpid(), "Start printing the remant of allocations");
 for(i=0; i<1000; i++){
  if(((void *)0) != g_allocate_adrs[i].addr){
   sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", __func__, 80, getpid(), "index=%d address=0x%p size=%d" , i, g_allocate_adrs[i].addr, g_allocate_adrs[i].size);
  }
 }
 sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", __func__, 83, getpid(), "Terminate printing the remant of allocations");
}

canonical_original_code:
void sbt_alloc_print_remnants(){
 int i = 0;
 sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", __func__, 77, getpid(), "Start printing the remant of allocations");
 for(i=0; i<1000; i++){
  if(((void *)0) != g_allocate_adrs[i].addr){
   sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", __func__, 80, getpid(), "index=%d address=0x%p size=%d" , i, g_allocate_adrs[i].addr, g_allocate_adrs[i].size);
  }
 }
 sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", __func__, 83, getpid(), "Terminate printing the remant of allocations");
}


decompiled_code:
__int64 sbt_alloc_get_allocate_size()
{
return (unsigned int)g_sbt_all_alloc_size;
}

canonical_decompiled_code:
__int64 func4()
{
return (unsigned int)g_sbt_all_alloc_size;
}

original_code:
int sbt_alloc_get_allocate_size(){
 return g_sbt_all_alloc_size;
}


decompiled_code:
__int64 sbt_alloc_test()
{
unsigned int v0; // eax
unsigned int v1; // eax
void *v2; // rax
unsigned int v3; // eax
void *v4; // r12
void *v5; // rbp
unsigned int v6; // eax
unsigned int v7; // eax
void *v8; // rbp
unsigned int v9; // eax

v0 = getpid();
sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", "sbt_alloc_test", 96LL, v0, "Start sbt_alloc_test");
v1 = getpid();
sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", "sbt_alloc_test", 99LL, v1, "test1");
v2 = sbt_malloc(0x32uLL);
sbt_free(v2);
if ( (unsigned int)sbt_alloc_get_allocate_size() )
_assert_fail("0 == sbt_alloc_get_allocate_size()", "src/sbt_alloc.c", 0x67u, "sbt_alloc_test");
v3 = getpid();
sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", "sbt_alloc_test", 106LL, v3, "test2");
v4 = sbt_malloc(0x1EuLL);
v5 = sbt_malloc(0x28uLL);
sbt_free(v4);
sbt_free(v5);
if ( (unsigned int)sbt_alloc_get_allocate_size() )
_assert_fail("0 == sbt_alloc_get_allocate_size()", "src/sbt_alloc.c", 0x71u, "sbt_alloc_test");
v6 = getpid();
sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", "sbt_alloc_test", 116LL, v6, "test3 result1 index=0 size=30");
v7 = getpid();
sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", "sbt_alloc_test", 117LL, v7, "test3 result2 index=2 size=40");
sbt_malloc(0x1EuLL);
v8 = sbt_malloc(0x28uLL);
sbt_malloc(0x32uLL);
sbt_free(v8);
sbt_alloc_print_remnants();
v9 = getpid();
return sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", "sbt_alloc_test", 124LL, v9, "End sbt_alloc_test");
}

canonical_decompiled_code:
__int64 func5()
{
unsigned int v0; // eax
unsigned int v1; // eax
void *v2; // rax
unsigned int v3; // eax
void *v4; // r12
void *v5; // rbp
unsigned int v6; // eax
unsigned int v7; // eax
void *v8; // rbp
unsigned int v9; // eax

v0 = getpid();
sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", "sbt_alloc_test", 96LL, v0, "Start sbt_alloc_test");
v1 = getpid();
sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", "sbt_alloc_test", 99LL, v1, "test1");
v2 = func1(0x32uLL);
func2(v2);
if ( (unsigned int)func4() )
_assert_fail("0 == sbt_alloc_get_allocate_size()", "src/sbt_alloc.c", 0x67u, "sbt_alloc_test");
v3 = getpid();
sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", "sbt_alloc_test", 106LL, v3, "test2");
v4 = func1(0x1EuLL);
v5 = func1(0x28uLL);
func2(v4);
func2(v5);
if ( (unsigned int)func4() )
_assert_fail("0 == sbt_alloc_get_allocate_size()", "src/sbt_alloc.c", 0x71u, "sbt_alloc_test");
v6 = getpid();
sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", "sbt_alloc_test", 116LL, v6, "test3 result1 index=0 size=30");
v7 = getpid();
sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", "sbt_alloc_test", 117LL, v7, "test3 result2 index=2 size=40");
func1(0x1EuLL);
v8 = func1(0x28uLL);
func1(0x32uLL);
func2(v8);
func3();
v9 = getpid();
return sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", "sbt_alloc_test", 124LL, v9, "End sbt_alloc_test");
}

original_code:
void sbt_alloc_test(){
 char* a = ((void *)0);
 char* b = ((void *)0);
 char* c = ((void *)0);
 sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", __func__, 96, getpid(), "Start sbt_alloc_test");
 sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", __func__, 99, getpid(), "test1");
 a = sbt_malloc(50);
 sbt_free(a);
 a = ((void *)0);
 ((void) sizeof ((0 == sbt_alloc_get_allocate_size()) ? 1 : 0), __extension__ ({ if (0 == sbt_alloc_get_allocate_size()) ; else __assert_fail ("0 == sbt_alloc_get_allocate_size()", "src/sbt_alloc.c", 103, __extension__ __PRETTY_FUNCTION__); }));
 sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", __func__, 106, getpid(), "test2");
 a = sbt_malloc(30);
 b = sbt_malloc(40);
 sbt_free(a);
 a = ((void *)0);
 sbt_free(b);
 b = ((void *)0);
 ((void) sizeof ((0 == sbt_alloc_get_allocate_size()) ? 1 : 0), __extension__ ({ if (0 == sbt_alloc_get_allocate_size()) ; else __assert_fail ("0 == sbt_alloc_get_allocate_size()", "src/sbt_alloc.c", 113, __extension__ __PRETTY_FUNCTION__); }));
 sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", __func__, 116, getpid(), "test3 result1 index=0  size=30");
 sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", __func__, 117, getpid(), "test3 result2 index=2  size=40");
 a = (char*)sbt_malloc(30);
 b = (char*)sbt_malloc(40);
 c = (char*)sbt_malloc(50);
 sbt_free(b);
 sbt_alloc_print_remnants();
 sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", __func__, 124, getpid(), "End sbt_alloc_test");
}

canonical_original_code:
void sbt_alloc_test(){
 char *a = ((void *)0);
 char *b = ((void *)0);
 char *c = ((void *)0);
 sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", __func__, 96, getpid(), "Start sbt_alloc_test");
 sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", __func__, 99, getpid(), "test1");
 a = sbt_malloc(50);
 sbt_free(a);
 a = ((void *)0);
 ((void) sizeof ((0 == sbt_alloc_get_allocate_size()) ? 1 : 0), __extension__ ({ if (0 == sbt_alloc_get_allocate_size()) ; else __assert_fail ("0 == sbt_alloc_get_allocate_size()", "src/sbt_alloc.c", 103, __extension__ __PRETTY_FUNCTION__); }));
 sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", __func__, 106, getpid(), "test2");
 a = sbt_malloc(30);
 b = sbt_malloc(40);
 sbt_free(a);
 a = ((void *)0);
 sbt_free(b);
 b = ((void *)0);
 ((void) sizeof ((0 == sbt_alloc_get_allocate_size()) ? 1 : 0), __extension__ ({ if (0 == sbt_alloc_get_allocate_size()) ; else __assert_fail ("0 == sbt_alloc_get_allocate_size()", "src/sbt_alloc.c", 113, __extension__ __PRETTY_FUNCTION__); }));
 sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", __func__, 116, getpid(), "test3 result1 index=0  size=30");
 sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", __func__, 117, getpid(), "test3 result2 index=2  size=40");
 a = (char *)sbt_malloc(30);
 b = (char *)sbt_malloc(40);
 c = (char *)sbt_malloc(50);
 sbt_free(b);
 sbt_alloc_print_remnants();
 sbt_logln_tofd(stderr, "D", "src/sbt_alloc.c", __func__, 124, getpid(), "End sbt_alloc_test");
}

variable_types:
a
char *

variable_types:
b
char *

variable_types:
c
char *


decompiled_code:
void *__fastcall sub_thread_void(void *a1)
{
const void *v1; // r12
unsigned int v2; // eax
unsigned int v3; // eax

v1 = (const void *)pthread_self();
v2 = getpid();
printf("%s(0x%x): start thread TID=%p\n", "sub_thread_void", v2, v1);
sleep(1u);
v3 = getpid();
printf("%s(0x%x): end thread TID=%p\n", "sub_thread_void", v3, v1);
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func0(void *a1)
{
const void *v1; // r12
unsigned int v2; // eax
unsigned int v3; // eax

v1 = (const void *)pthread_self();
v2 = getpid();
printf("%s(0x%x): start thread TID=%p\n", "sub_thread_void", v2, v1);
sleep(1u);
v3 = getpid();
printf("%s(0x%x): end thread TID=%p\n", "sub_thread_void", v3, v1);
return 0LL;
}

original_code:
void* sub_thread_void(){
 char sub_buf[1024]={0x00};
 pthread_t tid = pthread_self();
 printf("%s(0x%x): start thread TID=%p\n", __func__, getpid(), tid);
 sleep(1);
 printf("%s(0x%x): end thread   TID=%p\n", __func__, getpid(), tid);
 return ((void *)0);
}

canonical_original_code:
void *sub_thread_void(){
 char sub_buf[1024] = {0x00};
 unsigned long tid = pthread_self();
 printf("%s(0x%x): start thread TID=%p\n", __func__, getpid(), tid);
 sleep(1);
 printf("%s(0x%x): end thread   TID=%p\n", __func__, getpid(), tid);
 return ((void *)0);
}

variable_types:
tid
unsigned long


decompiled_code:
void *__fastcall sub_thread_int(void *a1)
{
pthread_t v1; // rax
unsigned int v2; // er13
const void *v3; // r12
unsigned int v4; // eax
unsigned int v5; // eax

v1 = pthread_self();
v2 = *(_DWORD *)a1;
v3 = (const void *)v1;
v4 = getpid();
printf("%s(0x%x): start thread(no=%d) TID=%p\n", "sub_thread_int", v4, v2, v3);
sleep(1u);
v5 = getpid();
printf("%s(0x%x): end thread TID=%p\n", "sub_thread_int", v5, v3);
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func1(void *a1)
{
pthread_t v1; // rax
unsigned int v2; // er13
const void *v3; // r12
unsigned int v4; // eax
unsigned int v5; // eax

v1 = pthread_self();
v2 = *(_DWORD *)a1;
v3 = (const void *)v1;
v4 = getpid();
printf("%s(0x%x): start thread(no=%d) TID=%p\n", "sub_thread_int", v4, v2, v3);
sleep(1u);
v5 = getpid();
printf("%s(0x%x): end thread TID=%p\n", "sub_thread_int", v5, v3);
return 0LL;
}

original_code:
void* sub_thread_int( int* thread_no ){
 char sub_buf[1024]={0x00};
 pthread_t tid = pthread_self();
 printf("%s(0x%x): start thread(no=%d) TID=%p\n", __func__, getpid(), *thread_no, tid);
 sleep(1);
 printf("%s(0x%x): end thread TID=%p\n", __func__, getpid(), tid);
 return ((void *)0);
}

canonical_original_code:
void *sub_thread_int(int *thread_no){
 char sub_buf[1024] = {0x00};
 unsigned long tid = pthread_self();
 printf("%s(0x%x): start thread(no=%d) TID=%p\n", __func__, getpid(), *thread_no, tid);
 sleep(1);
 printf("%s(0x%x): end thread TID=%p\n", __func__, getpid(), tid);
 return ((void *)0);
}


decompiled_code:
int __fastcall create_thread(int a1)
{
unsigned int v1; // eax
unsigned int v2; // eax
int arg[3]; // [rsp+Ch] [rbp-5Ch] BYREF
pthread_t newthread; // [rsp+18h] [rbp-50h] BYREF
pthread_attr_t attr; // [rsp+20h] [rbp-48h] BYREF

arg[0] = a1;
pthread_attr_init(&attr);
pthread_attr_setstacksize(&attr, 0x10000uLL);
if ( a1 % 2 == 1 )
pthread_create(&newthread, 0LL, sub_thread_void, 0LL);
else
pthread_create(&newthread, 0LL, sub_thread_int, arg);
v1 = getpid();
printf("%s(0x%x): Wait main thread\n", "create_thread", v1);
pthread_join(newthread, 0LL);
v2 = getpid();
printf("%s(0x%x): Resume main thread\n", "create_thread", v2);
return pthread_attr_destroy(&attr);
}

canonical_decompiled_code:
int __fastcall func2(int a1)
{
unsigned int v1; // eax
unsigned int v2; // eax
int arg[3]; // [rsp+Ch] [rbp-5Ch] BYREF
pthread_t newthread; // [rsp+18h] [rbp-50h] BYREF
pthread_attr_t attr; // [rsp+20h] [rbp-48h] BYREF

arg[0] = a1;
pthread_attr_init(&attr);
pthread_attr_setstacksize(&attr, 0x10000uLL);
if ( a1 % 2 == 1 )
pthread_create(&newthread, 0LL, sub_thread_void, 0LL);
else
pthread_create(&newthread, 0LL, sub_thread_int, arg);
v1 = getpid();
printf("%s(0x%x): Wait main thread\n", "create_thread", v1);
pthread_join(newthread, 0LL);
v2 = getpid();
printf("%s(0x%x): Resume main thread\n", "create_thread", v2);
return pthread_attr_destroy(&attr);
}

original_code:
void create_thread( int thread_no ){
    pthread_t thread;
 pthread_attr_t attr;
 pthread_attr_init(&attr);
 pthread_attr_setstacksize(&attr, 64 * 1024);
 if(1==thread_no%2){
  pthread_create( &thread, ((void *)0), sub_thread_void, (void*)((void *)0) );
 }else{
  pthread_create( &thread, ((void *)0), (void*)sub_thread_int, (void*)&thread_no );
 }
 printf("%s(0x%x): Wait   main thread\n",__func__, getpid());
 pthread_join( thread, ((void *)0) );
 printf("%s(0x%x): Resume main thread\n",__func__, getpid());
 pthread_attr_destroy(&attr);
}

canonical_original_code:
void create_thread(int thread_no){
    unsigned long thread;
 union pthread_attr_t attr;
 pthread_attr_init(&attr);
 pthread_attr_setstacksize(&attr, 64 * 1024);
 if(1==thread_no%2){
  pthread_create( &thread, ((void *)0), sub_thread_void, (void *)((void *)0) );
 }else{
  pthread_create( &thread, ((void *)0), (void *)sub_thread_int, (void *)&thread_no );
 }
 printf("%s(0x%x): Wait   main thread\n",__func__, getpid());
 pthread_join( thread, ((void *)0) );
 printf("%s(0x%x): Resume main thread\n",__func__, getpid());
 pthread_attr_destroy(&attr);
}

variable_types:
thread
unsigned long

variable_types: union pthread_attr_t { char __size[56]; long __align; }


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
unsigned int v4; // eax
unsigned int v5; // eax
unsigned int v6; // eax
__int128 v8[3]; // [rsp+0h] [rbp-48h] BYREF
__int16 v9; // [rsp+30h] [rbp-18h]

v8[0] = 0LL;
v8[1] = 0LL;
v8[2] = 0LL;
v9 = 0;
v3 = getpid();
printf("%s(0x%x): start\n", "main", v3);
v4 = getpid();
printf((const char *)v8, "grep VmSize /proc/%d/status", v4);
v5 = getpid();
printf("%s(0x%x): Dump virtual memory\n", "main", v5);
system((const char *)v8);
create_thread(1);
system((const char *)v8);
create_thread(2);
system((const char *)v8);
create_thread(3);
system((const char *)v8);
v6 = getpid();
printf("%s(0x%x): end\n", "main", v6);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
unsigned int v4; // eax
unsigned int v5; // eax
unsigned int v6; // eax
__int128 v8[3]; // [rsp+0h] [rbp-48h] BYREF
__int16 v9; // [rsp+30h] [rbp-18h]

v8[0] = 0LL;
v8[1] = 0LL;
v8[2] = 0LL;
v9 = 0;
v3 = getpid();
printf("%s(0x%x): start\n", "main", v3);
v4 = getpid();
printf((const char *)v8, "grep VmSize /proc/%d/status", v4);
v5 = getpid();
printf("%s(0x%x): Dump virtual memory\n", "main", v5);
system((const char *)v8);
func2(1);
system((const char *)v8);
func2(2);
system((const char *)v8);
func2(3);
system((const char *)v8);
v6 = getpid();
printf("%s(0x%x): end\n", "main", v6);
return 0;
}

original_code:
int main(int argc, char **argv)
{
 int ret = 0;
 char cmd_buf[50] = {0x00};
 int i;
 printf("%s(0x%x): start\n", __func__, getpid());
 printf(cmd_buf, "grep VmSize /proc/%d/status", getpid());
 printf("%s(0x%x): Dump virtual memory\n", __func__, getpid());
 system( cmd_buf );
 for(i=0; i<3; ++i){
  create_thread(i+1);
  system( cmd_buf );
 }
exit:
 printf("%s(0x%x): end\n", __func__, getpid());
 return ret;
}

variable_types: argc int

variable_types: ret int


decompiled_code:
int printf_ex(const char *a1, const char *a2, const char *a3, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a3);
printf("[%s][%s]:", a1, a2);
return vprintf(a3, arg);
}

canonical_decompiled_code:
int func7(const char *a1, const char *a2, const char *a3, ...)
{
gcc_va_list arg; // [rsp+8h] [rbp-D0h] BYREF

va_start(arg, a3);
printf("[%s][%s]:", a1, a2);
return vprintf(a3, arg);
}

original_code:
void printf_ex( const char* file, const char* func, const char* format, ...){
 va_list arg;
 printf("[%s][%s]:", file, func);
 __builtin_va_start(arg,format);
 vprintf( format, arg );
 __builtin_va_end(arg);
}

canonical_original_code:
void printf_ex(char *file, char *func, char *format, ...){
 __builtin_va_list arg;
 printf("[%s][%s]:", file, func);
 __builtin_va_start(arg,format);
 vprintf( format, arg );
 __builtin_va_end(arg);
}

variable_types:
file
char *

variable_types:
func
char *

variable_types:
format
char *


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
printf_ex("hello_command.c", "main", "start\n");
if ( argc <= 3 )
{
printf_ex("hello_command.c", "main", "invalid parameter\n");
}
else
{
printf_ex("hello_command.c", "main", "%s %s %s\n", argv[1], argv[2], argv[3]);
printf_ex("hello_command.c", "main", "result=%d\n", 3LL);
}
printf_ex("hello_command.c", "main", "end\n");
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func7("hello_command.c", "main", "start\n");
if ( argc <= 3 )
{
func7("hello_command.c", "main", "invalid parameter\n");
}
else
{
func7("hello_command.c", "main", "%s %s %s\n", argv[1], argv[2], argv[3]);
func7("hello_command.c", "main", "result=%d\n", 3LL);
}
func7("hello_command.c", "main", "end\n");
return 0;
}

original_code:
int main(int argc, char **argv)
{
 int ret = 0;
 printf_ex( "hello_command.c", __func__, "start\n");;
 if(3>=argc){
  printf_ex( "hello_command.c", __func__, "invalid parameter\n");;
  goto exit;
 }
 printf_ex( "hello_command.c", __func__, "%s %s %s\n", argv[1], argv[2], argv[3]);;
 printf_ex( "hello_command.c", __func__, "result=%d\n",3);;
exit:
 printf_ex( "hello_command.c", __func__, "end\n");;
 return ret;
}

variable_types:
argv
char **


decompiled_code:
__int64 __fastcall sbt_androidxml_get_array_length(char *a1, char *a2)
{
search_res_name_isra_0(a1, a2);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(char *a1, char *a2)
{
func0(a1, a2);
return 0LL;
}

original_code:
int sbt_androidxml_get_array_length(const char* file_name, const char* res_name){
    search_res_name(file_name, res_name);
    return 0;
}

canonical_original_code:
int sbt_androidxml_get_array_length(char *file_name, char *res_name){
    search_res_name(file_name, res_name);
    return 0;
}


decompiled_code:
__int64 sbt_androidxml_get_string_array()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func2()
{
return 0LL;
}

original_code:
char* sbt_androidxml_get_string_array(const char* file_name, const char* res_name){
    return ((void *)0);
}

canonical_original_code:
char *sbt_androidxml_get_string_array(char *file_name, char *res_name){
    return ((void *)0);
}

return_type: char *


decompiled_code:
// attributes: thunk
__int64 sbt_androidxml_get_int_array()
{
return sbt_androidxml_get_string_array();
}

canonical_decompiled_code:
__int64 func3()
{
return func2();
}

original_code:
int* sbt_androidxml_get_int_array(const char* file_name, const char* res_name){
    return ((void *)0);
}

canonical_original_code:
int *sbt_androidxml_get_int_array(char *file_name, char *res_name){
    return ((void *)0);
}

return_type: int *


decompiled_code:
__int64 func_c()
{
puts("func_c");
return 2LL;
}

canonical_decompiled_code:
__int64 func7()
{
puts("func_c");
return 2LL;
}

original_code:
static int func_c(char arg){
 printf("func_c\n");
 return 2;
}

variable_types: arg char


decompiled_code:
__int64 func_b()
{
puts("func_b");
return 1LL;
}

canonical_decompiled_code:
__int64 func8()
{
puts("func_b");
return 1LL;
}

original_code:
static int func_b(char arg){
 printf("func_b\n");
 return 1;
}


decompiled_code:
__int64 func_a()
{
puts("func_a");
return 0LL;
}

canonical_decompiled_code:
__int64 func9()
{
puts("func_a");
return 0LL;
}

original_code:
static int func_a(char arg){
 printf("func_a\n");
 return 0;
}


decompiled_code:
__int64 server_main()
{
char *v0; // rbx
__int64 v1; // rsi
const char *v2; // rdx
void (__fastcall **v3)(__int64); // rbx

v0 = aTokyo;
puts("Enter server_main");
printf("size of the data table = %d\n", 416LL);
printf("count entries in the data table = %d\n", 4LL);
do
{
v1 = *((unsigned int *)v0 - 1);
v2 = v0;
v0 += 104;
printf("id=%d name=%s\n", v1, v2);
}
while ( v0 != (char *)&unk_404244 );
v3 = (void (__fastcall **)(__int64))&funcTable;
printf("size of the function table = %d\n", 48LL);
printf("count entries in the function table = %d\n", 3LL);
do
{
printf("id=%d\n", *(unsigned int *)v3);
v3[1](97LL);
v3 += 2;
}
while ( v3 != (void (__fastcall **)(__int64))&unk_404090 );
puts("Exit server_main");
return 0LL;
}

canonical_decompiled_code:
__int64 func10()
{
char *v0; // rbx
__int64 v1; // rsi
const char *v2; // rdx
void (__fastcall **v3)(__int64); // rbx

v0 = aTokyo;
puts("Enter server_main");
printf("size of the data table = %d\n", 416LL);
printf("count entries in the data table = %d\n", 4LL);
do
{
v1 = *((unsigned int *)v0 - 1);
v2 = v0;
v0 += 104;
printf("id=%d name=%s\n", v1, v2);
}
while ( v0 != (char *)&unk_404244 );
v3 = (void (__fastcall **)(__int64))&funcTable;
printf("size of the function table = %d\n", 48LL);
printf("count entries in the function table = %d\n", 3LL);
do
{
printf("id=%d\n", *(unsigned int *)v3);
v3[1](97LL);
v3 += 2;
}
while ( v3 != (void (__fastcall **)(__int64))&unk_404090 );
puts("Exit server_main");
return 0LL;
}

original_code:
int server_main()
{
 int i;
 printf("Enter server_main\n");
 printf( "size of the data table = %d\n", (int)sizeof(dataTable) );
 printf( "count entries in the data table = %d\n", (int)(sizeof(dataTable)/sizeof(stDataTable)) );
 for( i=0; i < sizeof(dataTable)/sizeof(stDataTable); i++ ){
  printf( "id=%d name=%s\n", dataTable[i].id, dataTable[i].name );
 }
 printf( "size of the function table = %d\n", (int)sizeof(funcTable) );
 printf( "count entries in the function table = %d\n", (int)(sizeof(funcTable)/sizeof(stFuncTable)) );
 for( i=0; i < sizeof(funcTable)/sizeof(stFuncTable); i++ ){
  printf( "id=%d\n", funcTable[i].id );
  funcTable[i].func('a');
 }
 printf("Exit server_main\n");
 return 0;
}


decompiled_code:
__int64 client_main()
{
__int64 v0; // rdx
__int64 v1; // rbp
int v2; // ebx
const char *v3; // rax
__int64 v4; // rbx
__int64 v5; // rbp
int v7; // [rsp+78h] [rbp-30h] BYREF
int v8; // [rsp+7Ch] [rbp-2Ch] BYREF
char *v9; // [rsp+80h] [rbp-28h] BYREF
unsigned int *v10; // [rsp+88h] [rbp-20h] BYREF

v9 = 0LL;
v10 = 0LL;
v7 = 0;
v8 = 0;
puts("Enter client_main");
getDataTable(&v7, &v9);
printf("pDataTable : value=%p size=%d\n", v9, 8LL);
printf("*pDataTable: value=%d size=%d\n", 104LL, v0);
if ( v7 > 0 )
{
v1 = 0LL;
v2 = 0;
do
{
++v2;
v3 = &v9[v1];
v1 += 104LL;
printf("id=%d name=%s\n", *(unsigned int *)v3, v3 + 4);
}
while ( v7 > v2 );
}
getFuncTable(&v8, &v10);
printf("pFuncTable : value=%p size=%d\n", v10, 8LL);
printf("*pFuncTable: value=%d size=%d\n", *v10, *((_QWORD *)v10 + 1));
if ( v8 > 0 )
{
v4 = 0LL;
do
{
v5 = v4++;
v5 *= 16LL;
printf("id=%d\n", *(unsigned int *)((char *)v10 + v5));
(*(void (__fastcall **)(__int64))((char *)v10 + v5 + 8))(97LL);
}
while ( v8 > (int)v4 );
}
puts("Exit client_main");
return 0LL;
}

canonical_decompiled_code:
__int64 func13()
{
__int64 v0; // rdx
__int64 v1; // rbp
int v2; // ebx
const char *v3; // rax
__int64 v4; // rbx
__int64 v5; // rbp
int v7; // [rsp+78h] [rbp-30h] BYREF
int v8; // [rsp+7Ch] [rbp-2Ch] BYREF
char *v9; // [rsp+80h] [rbp-28h] BYREF
unsigned int *v10; // [rsp+88h] [rbp-20h] BYREF

v9 = 0LL;
v10 = 0LL;
v7 = 0;
v8 = 0;
puts("Enter client_main");
func11(&v7, &v9);
printf("pDataTable : value=%p size=%d\n", v9, 8LL);
printf("*pDataTable: value=%d size=%d\n", 104LL, v0);
if ( v7 > 0 )
{
v1 = 0LL;
v2 = 0;
do
{
++v2;
v3 = &v9[v1];
v1 += 104LL;
printf("id=%d name=%s\n", *(unsigned int *)v3, v3 + 4);
}
while ( v7 > v2 );
}
func12(&v8, &v10);
printf("pFuncTable : value=%p size=%d\n", v10, 8LL);
printf("*pFuncTable: value=%d size=%d\n", *v10, *((_QWORD *)v10 + 1));
if ( v8 > 0 )
{
v4 = 0LL;
do
{
v5 = v4++;
v5 *= 16LL;
printf("id=%d\n", *(unsigned int *)((char *)v10 + v5));
(*(void (__fastcall **)(__int64))((char *)v10 + v5 + 8))(97LL);
}
while ( v8 > (int)v4 );
}
puts("Exit client_main");
return 0LL;
}

original_code:
int client_main(){
 stDataTable* pDataTable = ((void *)0);
 stFuncTable* pFuncTable = ((void *)0);
 int dataTableSize = 0;
 int funcTableSize = 0;
    int i =0;
 printf( "Enter client_main\n" );
 getDataTable( &dataTableSize, &pDataTable );
 printf( "pDataTable : value=%p size=%d\n", pDataTable, (int)sizeof(pDataTable) );
 printf( "*pDataTable: value=%d size=%d\n", *pDataTable, (int)sizeof(*pDataTable) );
 for( i=0; i < dataTableSize; i++ ){
  printf( "id=%d name=%s\n", pDataTable[i].id, pDataTable[i].name );
 }
 getFuncTable( &funcTableSize, &pFuncTable );
 printf( "pFuncTable : value=%p size=%d\n", pFuncTable, (int)sizeof(pFuncTable) );
 printf( "*pFuncTable: value=%d size=%d\n", *pFuncTable, (int)sizeof(*pFuncTable) );
 for( i=0; i < funcTableSize; i++ ){
  printf( "id=%d\n", pFuncTable[i].id );
  pFuncTable[i].func('a');
 }
 printf( "Exit client_main\n" );
 return 0;
}

canonical_original_code:
int client_main(){
 struct st_dataTable *pDataTable = ((void *)0);
 struct st_funcTable *pFuncTable = ((void *)0);
 int dataTableSize = 0;
 int funcTableSize = 0;
    int i = 0;
 printf( "Enter client_main\n" );
 getDataTable( &dataTableSize, &pDataTable );
 printf( "pDataTable : value=%p size=%d\n", pDataTable, (int)sizeof(pDataTable) );
 printf( "*pDataTable: value=%d size=%d\n", *pDataTable, (int)sizeof(*pDataTable) );
 for( i=0; i < dataTableSize; i++ ){
  printf( "id=%d name=%s\n", pDataTable[i].id, pDataTable[i].name );
 }
 getFuncTable( &funcTableSize, &pFuncTable );
 printf( "pFuncTable : value=%p size=%d\n", pFuncTable, (int)sizeof(pFuncTable) );
 printf( "*pFuncTable: value=%d size=%d\n", *pFuncTable, (int)sizeof(*pFuncTable) );
 for( i=0; i < funcTableSize; i++ ){
  printf( "id=%d\n", pFuncTable[i].id );
  pFuncTable[i].func('a');
 }
 printf( "Exit client_main\n" );
 return 0;
}

variable_types: struct st_dataTable { int id; char name[100]; } *

variable_types: struct st_funcTable { int id; int (*func)(char arg); } *

variable_types: dataTableSize int

variable_types: funcTableSize int


decompiled_code:
__int64 __fastcall register_func(__int64 *a1)
{
__int64 result; // rax

g_plugin = *a1;
result = a1[1];
qword_4040B8 = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 *a1)
{
__int64 result; // rax

g_plugin = *a1;
result = a1[1];
qword_4040B8 = result;
return result;
}

original_code:
void register_func(plugin_info_st* info){
 g_plugin.name = info->name;
 g_plugin.fp = info->fp;
}

canonical_original_code:
void register_func(struct plugin_info *info){
 g_plugin.name = info->name;
 g_plugin.fp = info->fp;
}

variable_types: struct plugin_info { char *name; struct func_pointer { void (*func_a)(int); int (*func_b)(char); int (*func_c)(int, char); int (*func_d)(struct arg_set { int aa; char bb; } *); } *fp; } *

user_defined_types: struct plugin_info { char *name; struct func_pointer *fp; }

user_defined_types: struct func_pointer { void (*func_a)(int); int (*func_b)(char); int (*func_c)(int, char); int (*func_d)(struct arg_set *); }


decompiled_code:
__int64 matsu_d()
{
printf("%s -- start\n", "matsu_d");
printf("%s -- exit\n", "matsu_d");
return 0LL;
}

canonical_decompiled_code:
__int64 func9()
{
printf("%s -- start\n", "matsu_d");
printf("%s -- exit\n", "matsu_d");
return 0LL;
}

original_code:
static int matsu_d(arg_set_st* st){
 printf("%s -- start\n",__func__);
 printf("%s -- exit\n",__func__);
 return 0;
}

canonical_original_code:
static int matsu_d(struct arg_set *st){
 printf("%s -- start\n",__func__);
 printf("%s -- exit\n",__func__);
 return 0;
}

variable_types:
st
struct arg_set { int aa; char bb; } *


decompiled_code:
__int64 matsu_c()
{
printf("%s -- start\n", "matsu_c");
printf("%s -- exit\n", "matsu_c");
return 0LL;
}

canonical_decompiled_code:
__int64 func10()
{
printf("%s -- start\n", "matsu_c");
printf("%s -- exit\n", "matsu_c");
return 0LL;
}

original_code:
static int matsu_c(int ii, char cc){
 printf("%s -- start\n",__func__);
 printf("%s -- exit\n",__func__);
 return 0;
}

variable_types: ii int

variable_types: cc char


decompiled_code:
__int64 matsu_b()
{
printf("%s -- start\n", "matsu_b");
printf("%s -- exit\n", "matsu_b");
return 0LL;
}

canonical_decompiled_code:
__int64 func11()
{
printf("%s -- start\n", "matsu_b");
printf("%s -- exit\n", "matsu_b");
return 0LL;
}

original_code:
static int matsu_b(char cc){
 printf("%s -- start\n",__func__);
 printf("%s -- exit\n",__func__);
 return 0;
}


decompiled_code:
int matsu_a()
{
printf("%s -- start\n", "matsu_a");
return printf("%s -- exit\n", "matsu_a");
}

canonical_decompiled_code:
int func12()
{
printf("%s -- start\n", "matsu_a");
return printf("%s -- exit\n", "matsu_a");
}

original_code:
static void matsu_a(int ii){
 printf("%s -- start\n",__func__);
 printf("%s -- exit\n",__func__);
 return;
}


decompiled_code:
__int64 plugin_matsu_init()
{
__int64 v1[3]; // [rsp+0h] [rbp-18h] BYREF

v1[0] = (__int64)"plugin-matsu";
v1[1] = (__int64)&fp;
return register_func(v1);
}

original_code:
void plugin_matsu_init(){
 plugin_info_st info;
 info.name = "plugin-matsu";
 info.fp = &fp;
 register_func(&info);
}

canonical_original_code:
void plugin_matsu_init(){
 struct plugin_info info;
 info.name = "plugin-matsu";
 info.fp = &fp;
 register_func(&info);
}

variable_types: struct plugin_info { char *name; struct func_pointer { void (*func_a)(int); int (*func_b)(char); int (*func_c)(int, char); int (*func_d)(struct arg_set { int aa; char bb; } *); } *fp; }


decompiled_code:
__int64 plugin_take_init()
{
__int64 v1[3]; // [rsp+0h] [rbp-18h] BYREF

v1[0] = (__int64)"plugin-take";
v1[1] = (__int64)&fp_0;
return register_func(v1);
}

original_code:
void plugin_take_init(){
 plugin_info_st info;
 info.name = "plugin-take";
 info.fp = &fp;
 register_func(&info);
}

canonical_original_code:
void plugin_take_init(){
 struct plugin_info info;
 info.name = "plugin-take";
 info.fp = &fp;
 register_func(&info);
}


decompiled_code:
__int64 __fastcall plugin_manager_main(int a1)
{
int v2; // [rsp+0h] [rbp-50h] BYREF
char v3; // [rsp+4h] [rbp-4Ch]
char v4; // [rsp+7h] [rbp-49h]
char s[16]; // [rsp+8h] [rbp-48h] BYREF
__int128 v6; // [rsp+18h] [rbp-38h]
__int128 v7; // [rsp+28h] [rbp-28h]
__int16 v8; // [rsp+38h] [rbp-18h]

v8 = 0;
v2 = 1;
v3 = 97;
*(_OWORD *)s = 0LL;
v6 = 0LL;
v7 = 0LL;
printf("%s -- start\n", "plugin_manager_main");
if ( a1 == 1 )
{
plugin_matsu_init();
}
else if ( a1 == 2 )
{
plugin_take_init();
}
printf("[%s]", (const char *)g_plugin);
if ( fgets(s, 50, _bss_start) )
{
*(&v4 + strlen(s)) = 0;
(*(void (__fastcall **)(__int64))qword_4040B8)(1LL);
(*(void (__fastcall **)(__int64))(qword_4040B8 + 8))(97LL);
(*(void (__fastcall **)(__int64, __int64))(qword_4040B8 + 16))(1LL, 97LL);
(*(void (__fastcall **)(int *))(qword_4040B8 + 24))(&v2);
}
else
{
puts("input err!");
}
printf("%s -- end\n", "plugin_manager_main");
return 0LL;
}

original_code:
int plugin_manager_main(int type)
{
 int ret = 0;
 char cmd_buf[50] = {0};
 arg_set_st arg_set = {1, 'a'};
 printf("%s -- start\n",__func__);
 if ( 1 == type ) {
  plugin_matsu_init();
 } else if ( 2 == type ) {
  plugin_take_init();
 }
 printf("[%s]", g_plugin.name);
 if ( (fgets(cmd_buf, sizeof(cmd_buf), stdin)) == ((void *)0) ) {
  printf("input err!\n");
  goto exit;
 }
 cmd_buf[strlen(cmd_buf) - 1] = '\0';
 g_plugin.fp->func_a(1);
 g_plugin.fp->func_b('a');
 g_plugin.fp->func_c(1,'a');
 g_plugin.fp->func_d(&arg_set);
exit:
 printf("%s -- end\n",__func__);
 return ret;
}

canonical_original_code:
int plugin_manager_main(int type)
{
 int ret = 0;
 char cmd_buf[50] = {0};
 struct arg_set arg_set = {1, 'a'};
 printf("%s -- start\n",__func__);
 if ( 1 == type ) {
  plugin_matsu_init();
 } else if ( 2 == type ) {
  plugin_take_init();
 }
 printf("[%s]", g_plugin.name);
 if ( (fgets(cmd_buf, sizeof(cmd_buf), stdin)) == ((void *)0) ) {
  printf("input err!\n");
  goto exit;
 }
 cmd_buf[strlen(cmd_buf) - 1] = '\0';
 g_plugin.fp->func_a(1);
 g_plugin.fp->func_b('a');
 g_plugin.fp->func_c(1,'a');
 g_plugin.fp->func_d(&arg_set);
exit:
 printf("%s -- end\n",__func__);
 return ret;
}

variable_types: type int


decompiled_code:
__int64 take_d()
{
printf("%s -- start\n", "take_d");
printf("%s -- end\n", "take_d");
return 0LL;
}

canonical_decompiled_code:
__int64 func14()
{
printf("%s -- start\n", "take_d");
printf("%s -- end\n", "take_d");
return 0LL;
}

original_code:
static int take_d(arg_set_st* st){
 printf("%s -- start\n",__func__);
 printf("%s -- end\n",__func__);
 return 0;
}

canonical_original_code:
static int take_d(struct arg_set *st){
 printf("%s -- start\n",__func__);
 printf("%s -- end\n",__func__);
 return 0;
}


decompiled_code:
__int64 take_c()
{
printf("%s -- start\n", "take_c");
printf("%s -- end\n", "take_c");
return 0LL;
}

canonical_decompiled_code:
__int64 func15()
{
printf("%s -- start\n", "take_c");
printf("%s -- end\n", "take_c");
return 0LL;
}

original_code:
static int take_c(int ii, char cc){
 printf("%s -- start\n",__func__);
 printf("%s -- end\n",__func__);
 return 0;
}


decompiled_code:
__int64 take_b()
{
printf("%s -- start\n", "take_b");
printf("%s -- end\n", "take_b");
return 0LL;
}

canonical_decompiled_code:
__int64 func16()
{
printf("%s -- start\n", "take_b");
printf("%s -- end\n", "take_b");
return 0LL;
}

original_code:
static int take_b(char cc){
 printf("%s -- start\n",__func__);
 printf("%s -- end\n",__func__);
 return 0;
}


decompiled_code:
int take_a()
{
printf("%s -- start\n", "take_a");
return printf("%s -- end\n", "take_a");
}

canonical_decompiled_code:
int func17()
{
printf("%s -- start\n", "take_a");
return printf("%s -- end\n", "take_a");
}

original_code:
static void take_a(int ii){
 printf("%s -- start\n",__func__);
 printf("%s -- end\n",__func__);
 return;
}


decompiled_code:
char *__fastcall sbt_flog_init(char *src)
{
char *result; // rax

if ( src )
result = strcpy(&g_logfile_path, src);
return result;
}

canonical_decompiled_code:
char *__fastcall func2(char *src)
{
char *result; // rax

if ( src )
result = strcpy(&g_logfile_path, src);
return result;
}

original_code:
void sbt_flog_init(const char* path){
 if(((void *)0)!=path){
  strcpy((char*)g_logfile_path, path);
 }
}

canonical_original_code:
void sbt_flog_init(char *path){
 if(((void *)0)!=path){
  strcpy((char *)g_logfile_path, path);
 }
}

variable_types:
path
char *