stopclock

decompiled_code:
void __noreturn stopclock()
{
unsigned int v0; // ebp
const char *v1; // rax
char *v2; // rbx
const char *v3; // rax
time_t timer; // [rsp+8h] [rbp-20h] BYREF

if ( !clock_done_init )
exit(0);
runq_disable();
v0 = meth_shutdown();
if ( v0 )
{
timer = time(0LL);
elog_fprintf(4LL, "cmd/clockwork.c", 251LL, "stopclock", "%d jobs did not shutdown normally", v0);
v2 = ctime(&timer);
v3 = (const char *)cf_getstr(iiab_cmdarg, "argv0");
fprintf(stderr, "%s: shutdown, meth_shutdown() %d at %s", v3, v0, v2);
}
else
{
v1 = (const char *)cf_getstr(iiab_cmdarg, "argv0");
elog_fprintf(3LL, "cmd/clockwork.c", 256LL, "stopclock", "%s successfully shutdown", v1);
}
job_fini();
runq_fini();
meth_fini();
iiab_stop();
exit(v0);
}

canonical_decompiled_code:
void __noreturn func0()
{
unsigned int v0; // ebp
const char *v1; // rax
char *v2; // rbx
const char *v3; // rax
time_t timer; // [rsp+8h] [rbp-20h] BYREF

if ( !clock_done_init )
exit(0);
runq_disable();
v0 = meth_shutdown();
if ( v0 )
{
timer = time(0LL);
elog_fprintf(4LL, "cmd/clockwork.c", 251LL, "stopclock", "%d jobs did not shutdown normally", v0);
v2 = ctime(&timer);
v3 = (const char *)cf_getstr(iiab_cmdarg, "argv0");
fprintf(stderr, "%s: shutdown, meth_shutdown() %d at %s", v3, v0, v2);
}
else
{
v1 = (const char *)cf_getstr(iiab_cmdarg, "argv0");
elog_fprintf(3LL, "cmd/clockwork.c", 256LL, "stopclock", "%s successfully shutdown", v1);
}
job_fini();
runq_fini();
meth_fini();
iiab_stop();
exit(v0);
}

original_code:
void stopclock() {
     int r;
     time_t clock;
     if (!clock_done_init)
          _exit(0);
     runq_disable();
     r = meth_shutdown();
     if (r) {
   clock = time(((void *)0));
          elog_fprintf(WARNING,"cmd/clockwork.c",251,__PRETTY_FUNCTION__,"%d jobs did not shutdown normally", r);
   fprintf(stderr, "%s: shutdown, meth_shutdown() %d "
    "at %s", cf_getstr(iiab_cmdarg, "argv0"),
    r, ctime(&clock));
     } else {
          elog_fprintf(INFO,"cmd/clockwork.c",256,__PRETTY_FUNCTION__,"%s successfully shutdown", cf_getstr(iiab_cmdarg, "argv0"));
     }
     job_fini();
     runq_fini();
     meth_fini();
     iiab_stop();
     exit(r);
}

canonical_original_code:
void stopclock() {
     int r;
     long clock;
     if (!clock_done_init)
          _exit(0);
     runq_disable();
     r = meth_shutdown();
     if (r) {
   clock = time(((void *)0));
          elog_fprintf(WARNING,"cmd/clockwork.c",251,__PRETTY_FUNCTION__,"%d jobs did not shutdown normally", r);
   fprintf(stderr, "%s: shutdown, meth_shutdown() %d "
    "at %s", cf_getstr(iiab_cmdarg, "argv0"),
    r, ctime(&clock));
     } else {
          elog_fprintf(INFO,"cmd/clockwork.c",256,__PRETTY_FUNCTION__,"%s successfully shutdown", cf_getstr(iiab_cmdarg, "argv0"));
     }
     job_fini();
     runq_fini();
     meth_fini();
     iiab_stop();
     exit(r);
}

variable_types: clock long


repo: SystemGarden/habitat

decompiled_code:
void __noreturn stopclock_meth()
{
elog_fprintf(3LL, "cmd/clockwork.c", 228LL, "stopclock_meth", "clockwork shutting down from a method");
stopclock();
}

canonical_decompiled_code:
void __noreturn func1()
{
elog_fprintf(3LL, "cmd/clockwork.c", 228LL, "stopclock_meth", "clockwork shutting down from a method");
func0();
}

original_code:
void stopclock_meth() {
     elog_fprintf(INFO,"cmd/clockwork.c",228,__PRETTY_FUNCTION__,"clockwork shutting down from a method");
     stopclock();
}

return_type: void


decompiled_code:
void __fastcall __noreturn stopclock_sig(unsigned int a1)
{
sig_off();
elog_fprintf(3LL, "cmd/clockwork.c", 235LL, "stopclock_sig", "clockwork shutting down from signal %d", a1);
stopclock();
}

canonical_decompiled_code:
void __fastcall __noreturn func2(unsigned int a1)
{
sig_off();
elog_fprintf(3LL, "cmd/clockwork.c", 235LL, "stopclock_sig", "clockwork shutting down from signal %d", a1);
func0();
}

original_code:
void stopclock_sig(int sig ) {
     sig_off();
     elog_fprintf(INFO,"cmd/clockwork.c",235,__PRETTY_FUNCTION__,"clockwork shutting down from signal %d", sig);
     stopclock();
}

canonical_original_code:
void stopclock_sig(int sig) {
     sig_off();
     elog_fprintf(INFO,"cmd/clockwork.c",235,__PRETTY_FUNCTION__,"clockwork shutting down from signal %d", sig);
     stopclock();
}

variable_types: sig int


main

canonical_name: main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // er13
int v4; // er12
__int64 v5; // rax
const char *v6; // rax
__int64 v7; // rax
__int64 v8; // r15
__int64 v9; // rax
time_t v10; // rax
unsigned int v11; // eax
char *v12; // r14
const char *v13; // rdx
const char *v14; // rax
const char *v15; // r9
unsigned int v16; // eax
char *v17; // rax
int v18; // [rsp+8h] [rbp-450h]
int v19; // [rsp+Ch] [rbp-44Ch]
time_t timer; // [rsp+18h] [rbp-440h] BYREF
char v21[1080]; // [rsp+20h] [rbp-438h] BYREF

iiab_start("sfj:J:", (unsigned int)argc, argv, usagetxt, cfdefaults);
timer = time(0LL);
if ( (unsigned int)cf_defined(iiab_cf, "d") && (unsigned int)cf_getint(iiab_cf, "d") == -1 )
++debug;
v19 = cf_defined(iiab_cf, &LC5) != 0;
v18 = cf_defined(iiab_cf, &LC6) != 0;
v3 = cf_defined(iiab_cf, &LC7);
v4 = cf_defined(iiab_cf, &LC8);
if ( v4 )
{
if ( v3 )
{
elog_fprintf(
6LL,
"cmd/clockwork.c",
89LL,
"main",
"Can't specify -j and -J together, please pick one only\n%s %s",
*argv,
usagetxt);
iiab_stop();
exit(10);
}
++v19;
v4 = 1;
++v18;
v9 = cf_getstr(iiab_cf, &LC8);
cf_putstr(iiab_cf, "jobs", v9);
}
else if ( v3 )
{
v7 = cf_getstr(iiab_cf, &LC7);
v8 = util_strjoin("file:%l/jobs.", v7, 0LL);
cf_putstr(iiab_cf, "jobs", v8);
nm_nfree(v8, "cmd/clockwork.c", 100LL, "main");
}
v5 = cf_getstr(iiab_cf, "jobs");
route_expand(v21, v5, "NOJOB", 0LL);
if ( v21[0] )
{
if ( (unsigned int)route_access(v21, 0LL, 1LL) != 1 )
{
elog_fprintf(6LL, "cmd/clockwork.c", 127LL, "main", "Unable to access %s to read jobs", v21);
if ( v4 )
{
fprintf(
stderr,
"Unable to access route '%s' to read jobs\nPlease check the name & location and start again\n",
v21);
}
else if ( v3 )
{
v6 = (const char *)cf_getstr(iiab_cf, &LC7);
fprintf(
stderr,
"Unable to read standard jobs '%s'\n"
" (looking for %s)\n"
" Please check the name of the job file and start again\n",
v6,
v21);
}
else
{
fprintf(
stderr,
"Unable to read default jobs\n"
" (looking for %s)\n"
" Please check the installation to ensure all support files are in place\n",
v21);
}
iiab_stop();
exit(2);
}
sig_init();
meth_init((unsigned int)argc, argv, stopclock_meth);
meth_add(&probe_cbinfo);
v10 = time(0LL);
runq_init(v10);
job_init();
++clock_done_init;
if ( !v18 )
{
iiab_daemonise();
iiab_lockordie("clockwork");
if ( !v19 )
{
httpd_init();
httpd_addpath("/ping", &httpd_builtin_ping);
httpd_addpath("/cf", &httpd_builtin_cf);
httpd_addpath("/cftsv", &httpd_builtin_cf);
httpd_addpath("/elog", &httpd_builtin_elog);
httpd_addpath("/info", &httpd_builtin_info);
httpd_addpath("/local/", &httpd_builtin_local);
httpd_addpath("/localtsv/", &httpd_builtin_local);
httpd_start();
}
}
sig_setexit(stopclock_sig);
v11 = job_loadroute(v21);
if ( v11 != -1 )
{
elog_fprintf(3LL, "cmd/clockwork.c", 192LL, "main", "loaded %d jobs", v11);
v12 = ctime(&timer);
if ( v4 )
{
v13 = (const char *)cf_getstr(iiab_cf, &LC8);
}
else
{
v13 = "norm";
if ( v3 )
v13 = (const char *)cf_getstr(iiab_cf, &LC7);
}
v14 = " not";
v15 = *argv;
if ( !v19 )
v14 = (const char *)&LC2;
if ( v18 )
{
elog_fprintf(
3LL,
"cmd/clockwork.c",
194LL,
"main",
"Running %s in %s,%s listening to network, jobs from '%s', started at %s",
v15,
"foreground",
v14,
v13,
v12);
}
else
{
elog_fprintf(
3LL,
"cmd/clockwork.c",
194LL,
"main",
"Running %s in %s,%s listening to network, jobs from '%s', started at %s",
v15,
"background",
v14,
v13,
v12);
chdir(iiab_dir_var);
}
while ( 1 )
{
v16 = meth_relay();
elog_fprintf(1LL, "cmd/clockwork.c", 208LL, "main", "relay returns %d", v16);
}
}
elog_fdie(
6LL,
"cmd/clockwork.c",
186LL,
"main",
"unable to start due to a failure to read jobs from %s. Please check that the file is readable and that the table location exists.",
v21);
job_fini();
runq_fini();
meth_fini();
iiab_stop();
v17 = ctime(&timer);
fprintf(stderr, "%s: exit with errorstatus %d at %s", *argv, 5LL, v17);
exit(5);
}
fwrite(
"Unable to load jobs, as there was no valid configuration directive. Please specify -j, -J or set the directive `jobs"
"' in the configuration file to the route containing a job table. For example, `jobs=file:/etc/jobs.norm' will look f"
"or the file /etc/jobs.norm",
1uLL,
0x102uLL,
stderr);
elog_fprintf(
6LL,
"cmd/clockwork.c",
117LL,
"main",
"Unable to load jobs without valid config directive (looking for 'jobs' in cf)");
iiab_stop();
exit(1);
}

original_code:
int main(int argc, char **argv) {
     int njobs, opt_s=0, opt_f=0, opt_j=0, opt_J=0, errorstatus=0;
     char *jobpurl, jobpurl_t[1024], *jobcf=((void *)0);
     time_t clock;
     iiab_start("sfj:J:", argc, argv, usagetxt, cfdefaults);
     clock = time(((void *)0));
     if (cf_defined(iiab_cf, "d") && cf_getint(iiab_cf, "d") == -1)
   debug++;
     if (cf_defined(iiab_cf, "s"))
   opt_s++;
     if (cf_defined(iiab_cf, "f"))
   opt_f++;
     if (cf_defined(iiab_cf, "j"))
   opt_j++;
     if (cf_defined(iiab_cf, "J")) {
   opt_J++;
   opt_s++;
   opt_f++;
     }
     if (opt_j && opt_J) {
          elog_fprintf(FATAL,"cmd/clockwork.c",89,__PRETTY_FUNCTION__,"Can't specify -j and -J together, please pick " "one only\n" "%s %s", argv[0], usagetxt);
   iiab_stop();
   exit(10);
     }
     if (opt_j) {
          jobcf = util_strjoin("file:%l/jobs.", cf_getstr(iiab_cf, "j"),
          ((void *)0));
          cf_putstr(iiab_cf, "jobs", jobcf);
   nm_nfree(jobcf,"cmd/clockwork.c",100,__PRETTY_FUNCTION__);
     }
     if (opt_J) {
          cf_putstr(iiab_cf, "jobs", cf_getstr(iiab_cf, "J"));
     }
     jobpurl = cf_getstr(iiab_cf, "jobs");
     route_expand(jobpurl_t, jobpurl, "NOJOB", 0);
     if (*jobpurl_t == '\0') {
   fprintf(stderr, "Unable to load jobs, as there was no valid "
    "configuration directive. Please specify -j, -J or set "
    "the directive `jobs' in the configuration file to the "
    "route containing a job table. For example, "
    "`jobs=file:/etc/jobs.norm' will look for the "
    "file /etc/jobs.norm");
   elog_fprintf(FATAL,"cmd/clockwork.c",117,__PRETTY_FUNCTION__,"Unable to load jobs without valid config " "directive (looking for 'jobs' in cf)");
   iiab_stop();
   exit(1);
     }
     if ( route_access(jobpurl_t, ((void *)0), 1) != 1 ) {
          elog_fprintf(FATAL,"cmd/clockwork.c",127,__PRETTY_FUNCTION__,"Unable to access %s to read jobs", jobpurl_t);
   if (opt_J) {
        fprintf(stderr, "Unable to access route '%s' to read jobs\n"
         "Please check the name & location and start again\n",
         jobpurl_t);
   } else if (opt_j) {
        fprintf(stderr, "Unable to read standard jobs '%s'\n"
         "  (looking for %s)\n"
         "  Please check the name of the job file and start "
         "again\n", cf_getstr(iiab_cf, "j"), jobpurl_t);
   } else {
        fprintf(stderr, "Unable to read default jobs\n"
         "  (looking for %s)\n"
         "  Please check the installation to ensure all support "
         "files are in place\n", jobpurl_t);
   }
   iiab_stop();
   exit(2);
     }
     sig_init();
     meth_init(argc, argv, stopclock_meth);
     meth_add(&probe_cbinfo);
     runq_init(time(((void *)0)));
     job_init();
     clock_done_init++;
     if ( ! opt_f ) {
          iiab_daemonise();
   iiab_lockordie("clockwork");
   if ( ! opt_s ) {
        httpd_init();
        httpd_addpath("/ping", httpd_builtin_ping);
        httpd_addpath("/cf", httpd_builtin_cf);
        httpd_addpath("/cftsv", httpd_builtin_cf);
        httpd_addpath("/elog", httpd_builtin_elog);
        httpd_addpath("/info", httpd_builtin_info);
        httpd_addpath("/local/", httpd_builtin_local);
        httpd_addpath("/localtsv/",httpd_builtin_local);
        httpd_start();
   }
     }
     sig_setexit(stopclock_sig);
     njobs = job_loadroute( jobpurl_t );
     if (njobs == -1) {
          elog_fdie(FATAL,"cmd/clockwork.c",186,__PRETTY_FUNCTION__,"unable to start due to a failure to read jobs " "from %s. Please check that the file is readable and that " "the table location exists.", jobpurl_t);
   errorstatus = 5;
   goto end_app;
     } else
          elog_fprintf(INFO,"cmd/clockwork.c",192,__PRETTY_FUNCTION__,"loaded %d jobs", njobs);
     elog_fprintf(INFO,"cmd/clockwork.c",194,__PRETTY_FUNCTION__,"Running %s in %s,%s listening to network, " "jobs from '%s', started at %s", argv[0], opt_f ? "foreground" : "background", opt_s ? " not" : "", (opt_J ? cf_getstr(iiab_cf, "J") : (opt_j ? cf_getstr(iiab_cf, "j") : "norm") ), ctime(&clock));
     if ( ! opt_f )
   chdir(iiab_dir_var);
     while(1) {
          elog_fprintf(DEBUG,"cmd/clockwork.c",208,__PRETTY_FUNCTION__,"relay returns %d", meth_relay());
     }
 end_app:
     job_fini();
     runq_fini();
     meth_fini();
     iiab_stop();
     if (errorstatus) {
   fprintf(stderr, "%s: exit with errorstatus %d at %s", argv[0],
    errorstatus, ctime(&clock));
     }
     exit(errorstatus);
}

canonical_original_code:
int main(int argc, char **argv) {
     int njobs; int opt_s = 0; int opt_f = 0; int opt_j = 0; int opt_J = 0; int errorstatus = 0;
     char *jobpurl; char jobpurl_t[1024]; char *jobcf = ((void *)0);
     long clock;
     iiab_start("sfj:J:", argc, argv, usagetxt, cfdefaults);
     clock = time(((void *)0));
     if (cf_defined(iiab_cf, "d") && cf_getint(iiab_cf, "d") == -1)
   debug++;
     if (cf_defined(iiab_cf, "s"))
   opt_s++;
     if (cf_defined(iiab_cf, "f"))
   opt_f++;
     if (cf_defined(iiab_cf, "j"))
   opt_j++;
     if (cf_defined(iiab_cf, "J")) {
   opt_J++;
   opt_s++;
   opt_f++;
     }
     if (opt_j && opt_J) {
          elog_fprintf(FATAL,"cmd/clockwork.c",89,__PRETTY_FUNCTION__,"Can't specify -j and -J together, please pick " "one only\n" "%s %s", argv[0], usagetxt);
   iiab_stop();
   exit(10);
     }
     if (opt_j) {
          jobcf = util_strjoin("file:%l/jobs.", cf_getstr(iiab_cf, "j"),
          ((void *)0));
          cf_putstr(iiab_cf, "jobs", jobcf);
   nm_nfree(jobcf,"cmd/clockwork.c",100,__PRETTY_FUNCTION__);
     }
     if (opt_J) {
          cf_putstr(iiab_cf, "jobs", cf_getstr(iiab_cf, "J"));
     }
     jobpurl = cf_getstr(iiab_cf, "jobs");
     route_expand(jobpurl_t, jobpurl, "NOJOB", 0);
     if (*jobpurl_t == '\0') {
   fprintf(stderr, "Unable to load jobs, as there was no valid "
    "configuration directive. Please specify -j, -J or set "
    "the directive `jobs' in the configuration file to the "
    "route containing a job table. For example, "
    "`jobs=file:/etc/jobs.norm' will look for the "
    "file /etc/jobs.norm");
   elog_fprintf(FATAL,"cmd/clockwork.c",117,__PRETTY_FUNCTION__,"Unable to load jobs without valid config " "directive (looking for 'jobs' in cf)");
   iiab_stop();
   exit(1);
     }
     if ( route_access(jobpurl_t, ((void *)0), 1) != 1 ) {
          elog_fprintf(FATAL,"cmd/clockwork.c",127,__PRETTY_FUNCTION__,"Unable to access %s to read jobs", jobpurl_t);
   if (opt_J) {
        fprintf(stderr, "Unable to access route '%s' to read jobs\n"
         "Please check the name & location and start again\n",
         jobpurl_t);
   } else if (opt_j) {
        fprintf(stderr, "Unable to read standard jobs '%s'\n"
         "  (looking for %s)\n"
         "  Please check the name of the job file and start "
         "again\n", cf_getstr(iiab_cf, "j"), jobpurl_t);
   } else {
        fprintf(stderr, "Unable to read default jobs\n"
         "  (looking for %s)\n"
         "  Please check the installation to ensure all support "
         "files are in place\n", jobpurl_t);
   }
   iiab_stop();
   exit(2);
     }
     sig_init();
     meth_init(argc, argv, stopclock_meth);
     meth_add(&probe_cbinfo);
     runq_init(time(((void *)0)));
     job_init();
     clock_done_init++;
     if ( ! opt_f ) {
          iiab_daemonise();
   iiab_lockordie("clockwork");
   if ( ! opt_s ) {
        httpd_init();
        httpd_addpath("/ping", httpd_builtin_ping);
        httpd_addpath("/cf", httpd_builtin_cf);
        httpd_addpath("/cftsv", httpd_builtin_cf);
        httpd_addpath("/elog", httpd_builtin_elog);
        httpd_addpath("/info", httpd_builtin_info);
        httpd_addpath("/local/", httpd_builtin_local);
        httpd_addpath("/localtsv/",httpd_builtin_local);
        httpd_start();
   }
     }
     sig_setexit(stopclock_sig);
     njobs = job_loadroute( jobpurl_t );
     if (njobs == -1) {
          elog_fdie(FATAL,"cmd/clockwork.c",186,__PRETTY_FUNCTION__,"unable to start due to a failure to read jobs " "from %s. Please check that the file is readable and that " "the table location exists.", jobpurl_t);
   errorstatus = 5;
   goto end_app;
     } else
          elog_fprintf(INFO,"cmd/clockwork.c",192,__PRETTY_FUNCTION__,"loaded %d jobs", njobs);
     elog_fprintf(INFO,"cmd/clockwork.c",194,__PRETTY_FUNCTION__,"Running %s in %s,%s listening to network, " "jobs from '%s', started at %s", argv[0], opt_f ? "foreground" : "background", opt_s ? " not" : "", (opt_J ? cf_getstr(iiab_cf, "J") : (opt_j ? cf_getstr(iiab_cf, "j") : "norm") ), ctime(&clock));
     if ( ! opt_f )
   chdir(iiab_dir_var);
     while(1) {
          elog_fprintf(DEBUG,"cmd/clockwork.c",208,__PRETTY_FUNCTION__,"relay returns %d", meth_relay());
     }
 end_app:
     job_fini();
     runq_fini();
     meth_fini();
     iiab_stop();
     if (errorstatus) {
   fprintf(stderr, "%s: exit with errorstatus %d at %s", argv[0],
    errorstatus, ctime(&clock));
     }
     exit(errorstatus);
}

variable_types: argc int

variable_types:
argv
char **

variable_types: njobs int

variable_types: errorstatus int

variable_types:
jobpurl
char *

variable_types:
jobcf
char *

return_type: int


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

result = a1 != a2;
if ( a1 < a2 )
result = 0xFFFFFFFFLL;
return result;
}

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

result = a1 != a2;
if ( a1 < a2 )
result = 0xFFFFFFFFLL;
return result;
}

original_code:
int ptree_cmp(char *a, char *b) {
     if (a<b)
          return -1;
     if (a==b)
          return 0;
     else
          return 1;
}

variable_types:
a
char *

variable_types:
b
char *


decompiled_code:
__int64 *ptree_create()
{
__int64 *v0; // r12
__int64 v1; // rax

v0 = (__int64 *)nm_xnmalloc(16LL, "iiab/ptree.c", 29LL, "ptree_create");
v1 = make_rb();
*v0 = v1;
if ( !v1 )
v0 = 0LL;
return v0;
}

canonical_decompiled_code:
__int64 *func1()
{
__int64 *v0; // r12
__int64 v1; // rax

v0 = (__int64 *)nm_xnmalloc(16LL, "iiab/ptree.c", 29LL, "ptree_create");
v1 = make_rb();
*v0 = v1;
if ( !v1 )
v0 = 0LL;
return v0;
}

original_code:
PTREE *ptree_create() {
 PTREE *t;
 t = nm_xnmalloc(sizeof(PTREE),"iiab/ptree.c",29,__PRETTY_FUNCTION__);
 t->root = make_rb();
 if (t->root)
  return t;
 else
  return ((void *)0);
}

canonical_original_code:
struct ptree_head *ptree_create() {
 struct ptree_head *t;
 t = nm_xnmalloc(sizeof(PTREE),"iiab/ptree.c",29,__PRETTY_FUNCTION__);
 t->root = make_rb();
 if (t->root)
  return t;
 else
  return ((void *)0);
}

variable_types: struct ptree_head { struct rb_node { union { struct { struct rb_node *flink; struct rb_node *blink; } list; struct { struct rb_node *left; struct rb_node *right; } child; } c; union { struct rb_node *parent; struct rb_node *root; } p; struct status { unsigned int red; unsigned int internal; unsigned int left; unsigned int root; unsigned int head; } s; union { unsigned int ikey; char *key; struct rb_node *lext; } k; union { char *val; struct rb_node *rext; } v; } *root; struct rb_node *node; } *

user_defined_types: struct ptree_head { struct rb_node *root; struct rb_node *node; }

user_defined_types: struct rb_node { union { struct { struct rb_node *flink; struct rb_node *blink; } list; struct { struct rb_node *left; struct rb_node *right; } child; } c; union { struct rb_node *parent; struct rb_node *root; } p; struct status s; union { unsigned int ikey; char *key; struct rb_node *lext; } k; union { char *val; struct rb_node *rext; } v; }


decompiled_code:
__int64 __fastcall ptree_destroy(_QWORD *a1)
{
if ( !a1 )
{
fwrite("(ptree_destroy) t == NULL\n", 1uLL, 0x1AuLL, stderr);
abort();
}
rb_free_tree(*a1);
return nm_nfree(a1, "iiab/ptree.c", 48LL, "ptree_destroy");
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD *a1)
{
if ( !a1 )
{
fwrite("(ptree_destroy) t == NULL\n", 1uLL, 0x1AuLL, stderr);
abort();
}
rb_free_tree(*a1);
return nm_nfree(a1, "iiab/ptree.c", 48LL, "ptree_destroy");
}

original_code:
void ptree_destroy(PTREE *t) {
 if (t == ((void *)0)) {
  fprintf(stderr, "(ptree_destroy) t == NULL\n");
  abort();
 }
 rb_free_tree(t->root);
 nm_nfree(t,"iiab/ptree.c",48,__PRETTY_FUNCTION__);
}

canonical_original_code:
void ptree_destroy(struct ptree_head *t) {
 if (t == ((void *)0)) {
  fprintf(stderr, "(ptree_destroy) t == NULL\n");
  abort();
 }
 rb_free_tree(t->root);
 nm_nfree(t,"iiab/ptree.c",48,__PRETTY_FUNCTION__);
}

user_defined_types: struct status { unsigned int red; unsigned int internal; unsigned int left; unsigned int root; unsigned int head; }


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

if ( !a1 )
{
fwrite("(ptree_add) t == NULL\n", 1uLL, 0x16uLL, stderr);
abort();
}
result = rb_insertg(*a1, a2, a3, ptree_cmp);
a1[1] = result;
return result;
}

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

if ( !a1 )
{
fwrite("(ptree_add) t == NULL\n", 1uLL, 0x16uLL, stderr);
abort();
}
result = rb_insertg(*a1, a2, a3, ptree_cmp);
a1[1] = result;
return result;
}

original_code:
void ptree_add(PTREE *t,
        void *key,
        void *datum ) {
 if (t == ((void *)0)) {
  fprintf(stderr, "(ptree_add) t == NULL\n");
  abort();
 }
 t->node = rb_insertg(t->root, key, datum, ptree_cmp);
}

canonical_original_code:
void ptree_add(struct ptree_head *t, void *key, void *datum) {
 if (t == ((void *)0)) {
  fprintf(stderr, "(ptree_add) t == NULL\n");
  abort();
 }
 t->node = rb_insertg(t->root, key, datum, ptree_cmp);
}

variable_types:
key
void *

variable_types:
datum
void *


decompiled_code:
__int64 __fastcall ptree_rm(__int64 a1)
{
_QWORD *v1; // r8

if ( !a1 )
{
fwrite("(ptree_rm) t == NULL\n", 1uLL, 0x15uLL, stderr);
abort();
}
v1 = *(_QWORD **)(a1 + 8);
*(_QWORD *)(a1 + 8) = *v1;
return rb_delete_node(v1);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
_QWORD *v1; // r8

if ( !a1 )
{
fwrite("(ptree_rm) t == NULL\n", 1uLL, 0x15uLL, stderr);
abort();
}
v1 = *(_QWORD **)(a1 + 8);
*(_QWORD *)(a1 + 8) = *v1;
return rb_delete_node(v1);
}

original_code:
void ptree_rm(PTREE *t) {
 Rb_node wasteme;
 if (t == ((void *)0)) {
  fprintf(stderr, "(ptree_rm) t == NULL\n");
  abort();
 }
 wasteme = t->node;
 t->node = (t->node->c.list.flink);
 rb_delete_node(wasteme);
}

canonical_original_code:
void ptree_rm(struct ptree_head *t) {
 struct rb_node *wasteme;
 if (t == ((void *)0)) {
  fprintf(stderr, "(ptree_rm) t == NULL\n");
  abort();
 }
 wasteme = t->node;
 t->node = (t->node->c.list.flink);
 rb_delete_node(wasteme);
}

variable_types: struct rb_node { union { struct { struct rb_node *flink; struct rb_node *blink; } list; struct { struct rb_node *left; struct rb_node *right; } child; } c; union { struct rb_node *parent; struct rb_node *root; } p; struct status { unsigned int red; unsigned int internal; unsigned int left; unsigned int root; unsigned int head; } s; union { unsigned int ikey; char *key; struct rb_node *lext; } k; union { char *val; struct rb_node *rext; } v; } *


decompiled_code:
__int64 __fastcall ptree_get(__int64 a1)
{
if ( !a1 )
{
fwrite("(ptree_get) t == NULL\n", 1uLL, 0x16uLL, stderr);
abort();
}
return rb_val(*(_QWORD *)(a1 + 8));
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
if ( !a1 )
{
fwrite("(ptree_get) t == NULL\n", 1uLL, 0x16uLL, stderr);
abort();
}
return rb_val(*(_QWORD *)(a1 + 8));
}

original_code:
void *ptree_get(PTREE *t) {
 if (t == ((void *)0)) {
  fprintf(stderr, "(ptree_get) t == NULL\n");
  abort();
 }
 return rb_val(t->node);
}

canonical_original_code:
void *ptree_get(struct ptree_head *t) {
 if (t == ((void *)0)) {
  fprintf(stderr, "(ptree_get) t == NULL\n");
  abort();
 }
 return rb_val(t->node);
}

return_type: void *


decompiled_code:
__int64 __fastcall ptree_getkey(__int64 a1)
{
if ( !a1 )
{
fwrite("(ptree_getkey) t == NULL\n", 1uLL, 0x19uLL, stderr);
abort();
}
return *(_QWORD *)(*(_QWORD *)(a1 + 8) + 32LL);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
if ( !a1 )
{
fwrite("(ptree_getkey) t == NULL\n", 1uLL, 0x19uLL, stderr);
abort();
}
return *(_QWORD *)(*(_QWORD *)(a1 + 8) + 32LL);
}

original_code:
void *ptree_getkey(PTREE *t) {
 if (t == ((void *)0)) {
  fprintf(stderr, "(ptree_getkey) t == NULL\n");
  abort();
 }
 return t->node->k.key;
}

canonical_original_code:
void *ptree_getkey(struct ptree_head *t) {
 if (t == ((void *)0)) {
  fprintf(stderr, "(ptree_getkey) t == NULL\n");
  abort();
 }
 return t->node->k.key;
}


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

if ( !a1 )
{
fwrite("(ptree_put) t == NULL\n", 1uLL, 0x16uLL, stderr);
abort();
}
result = rb_val(*(_QWORD *)(a1 + 8));
*(_QWORD *)(*(_QWORD *)(a1 + 8) + 40LL) = a2;
return result;
}

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

if ( !a1 )
{
fwrite("(ptree_put) t == NULL\n", 1uLL, 0x16uLL, stderr);
abort();
}
result = rb_val(*(_QWORD *)(a1 + 8));
*(_QWORD *)(*(_QWORD *)(a1 + 8) + 40LL) = a2;
return result;
}

original_code:
void *ptree_put(PTREE *t, void *dat) {
 void *old;
 if (t == ((void *)0)) {
  fprintf(stderr, "(ptree_put) t == NULL\n");
  abort();
 }
 old = rb_val(t->node);
 t->node->v.val = dat;
 return old;
}

canonical_original_code:
void *ptree_put(struct ptree_head *t, void *dat) {
 void *old;
 if (t == ((void *)0)) {
  fprintf(stderr, "(ptree_put) t == NULL\n");
  abort();
 }
 old = rb_val(t->node);
 t->node->v.val = dat;
 return old;
}

variable_types:
dat
void *

variable_types:
old
void *


decompiled_code:
__int64 __fastcall ptree_find(_QWORD *a1, __int64 a2)
{
__int64 v3; // rdi
__int64 result; // rax
int v5[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( !a1 )
{
fwrite("(ptree_find) t == NULL\n", 1uLL, 0x17uLL, stderr);
abort();
}
v3 = rb_find_gkey_n(*a1, a2, ptree_cmp, v5);
result = 0LL;
if ( v5[0] )
{
a1[1] = v3;
result = rb_val(v3);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(_QWORD *a1, __int64 a2)
{
__int64 v3; // rdi
__int64 result; // rax
int v5[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( !a1 )
{
fwrite("(ptree_find) t == NULL\n", 1uLL, 0x17uLL, stderr);
abort();
}
v3 = rb_find_gkey_n(*a1, a2, ptree_cmp, v5);
result = 0LL;
if ( v5[0] )
{
a1[1] = v3;
result = rb_val(v3);
}
return result;
}

original_code:
void *ptree_find(PTREE *t, void *key) {
 int found;
 Rb_node n;
 if (t == ((void *)0)) {
  fprintf(stderr, "(ptree_find) t == NULL\n");
  abort();
 }
 n = rb_find_gkey_n(t->root, key, ptree_cmp, &found);
 if (found) {
  t->node = n;
  return rb_val(n);
 }
 else
  return (void *) ((void *)0);
}

canonical_original_code:
void *ptree_find(struct ptree_head *t, void *key) {
 int found;
 struct rb_node *n;
 if (t == ((void *)0)) {
  fprintf(stderr, "(ptree_find) t == NULL\n");
  abort();
 }
 n = rb_find_gkey_n(t->root, key, ptree_cmp, &found);
 if (found) {
  t->node = n;
  return rb_val(n);
 }
 else
  return (void *) ((void *)0);
}

variable_types: found int


decompiled_code:
__int64 __fastcall ptree_search(__int64 a1, const void *a2, int a3)
{
_QWORD *v3; // rcx
_QWORD *v4; // rax
size_t v5; // rbx
__int64 v6; // rax
const void *v7; // rax

v3 = *(_QWORD **)a1;
v4 = **(_QWORD ***)a1;
*(_QWORD *)(a1 + 8) = v4;
if ( v3 == v4 )
return 0LL;
v5 = a3;
do
{
v7 = (const void *)ptree_get(a1);
if ( !memcmp(a2, v7, v5) )
return ptree_getkey(a1);
v6 = **(_QWORD **)(a1 + 8);
*(_QWORD *)(a1 + 8) = v6;
}
while ( v6 != *(_QWORD *)a1 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, const void *a2, int a3)
{
_QWORD *v3; // rcx
_QWORD *v4; // rax
size_t v5; // rbx
__int64 v6; // rax
const void *v7; // rax

v3 = *(_QWORD **)a1;
v4 = **(_QWORD ***)a1;
*(_QWORD *)(a1 + 8) = v4;
if ( v3 == v4 )
return 0LL;
v5 = a3;
do
{
v7 = (const void *)func5(a1);
if ( !memcmp(a2, v7, v5) )
return func6(a1);
v6 = **(_QWORD **)(a1 + 8);
*(_QWORD *)(a1 + 8) = v6;
}
while ( v6 != *(_QWORD *)a1 );
return 0LL;
}

original_code:
void *ptree_search(PTREE *haystack, void *needle, int needlelen) {
     for((haystack)->node = ((haystack)->root->c.list.flink); (haystack)->node != ((haystack)->root); (haystack)->node = ((haystack)->node->c.list.flink)) {
   if (memcmp(needle, ptree_get(haystack), needlelen) == 0)
        return ptree_getkey(haystack);
     }
     return ((void *)0);
}

canonical_original_code:
void *ptree_search(struct ptree_head *haystack, void *needle, int needlelen) {
     for((haystack)->node = ((haystack)->root->c.list.flink); (haystack)->node != ((haystack)->root); (haystack)->node = ((haystack)->node->c.list.flink)) {
   if (memcmp(needle, ptree_get(haystack), needlelen) == 0)
        return ptree_getkey(haystack);
     }
     return ((void *)0);
}

variable_types:
needle
void *

variable_types: needlelen int


decompiled_code:
__int64 __fastcall ptree_n(__int64 a1)
{
_QWORD **v1; // rdx
unsigned int v2; // er8
_QWORD *v3; // rax

if ( !a1 )
{
fwrite("(ptree_n) t == NULL\n", 1uLL, 0x14uLL, stderr);
abort();
}
v1 = *(_QWORD ***)a1;
v2 = 0;
v3 = **(_QWORD ***)a1;
*(_QWORD *)(a1 + 8) = v3;
if ( v1 != v3 )
{
do
{
v3 = (_QWORD *)*v3;
++v2;
}
while ( v1 != v3 );
*(_QWORD *)(a1 + 8) = v1;
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
_QWORD **v1; // rdx
unsigned int v2; // er8
_QWORD *v3; // rax

if ( !a1 )
{
fwrite("(ptree_n) t == NULL\n", 1uLL, 0x14uLL, stderr);
abort();
}
v1 = *(_QWORD ***)a1;
v2 = 0;
v3 = **(_QWORD ***)a1;
*(_QWORD *)(a1 + 8) = v3;
if ( v1 != v3 )
{
do
{
v3 = (_QWORD *)*v3;
++v2;
}
while ( v1 != v3 );
*(_QWORD *)(a1 + 8) = v1;
}
return v2;
}

original_code:
int ptree_n(PTREE *t) {
 int n=0;
 if (t == ((void *)0)) {
  fprintf(stderr, "(ptree_n) t == NULL\n");
  abort();
 }
 for((t)->node = ((t)->root->c.list.flink); (t)->node != ((t)->root); (t)->node = ((t)->node->c.list.flink))
  n++;
 return n;
}

canonical_original_code:
int ptree_n(struct ptree_head *t) {
 int n = 0;
 if (t == ((void *)0)) {
  fprintf(stderr, "(ptree_n) t == NULL\n");
  abort();
 }
 for((t)->node = ((t)->root->c.list.flink); (t)->node != ((t)->root); (t)->node = ((t)->node->c.list.flink))
  n++;
 return n;
}

variable_types: n int


decompiled_code:
__int64 __fastcall ptree_present(_QWORD *a1, __int64 a2)
{
unsigned int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( !a1 )
{
fwrite("(ptree_present) t == NULL\n", 1uLL, 0x1AuLL, stderr);
exit(0);
}
rb_find_gkey_n(*a1, a2, ptree_cmp, v3);
return v3[0];
}

canonical_decompiled_code:
__int64 __fastcall func11(_QWORD *a1, __int64 a2)
{
unsigned int v3[3]; // [rsp+Ch] [rbp-Ch] BYREF

if ( !a1 )
{
fwrite("(ptree_present) t == NULL\n", 1uLL, 0x1AuLL, stderr);
exit(0);
}
rb_find_gkey_n(*a1, a2, ptree_cmp, v3);
return v3[0];
}

original_code:
int ptree_present(PTREE *t, void *key) {
 int found;
 if (t == ((void *)0)) {
  fprintf(stderr, "(ptree_present) t == NULL\n");
  exit(0);
 }
 rb_find_gkey_n(t->root, key, ptree_cmp, &found);
 return found;
}

canonical_original_code:
int ptree_present(struct ptree_head *t, void *key) {
 int found;
 if (t == ((void *)0)) {
  fprintf(stderr, "(ptree_present) t == NULL\n");
  exit(0);
 }
 rb_find_gkey_n(t->root, key, ptree_cmp, &found);
 return found;
}


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

if ( a1 )
result = nm_nfree(a1, "iiab/ptree.c", 247LL, "ptree_infreemem");
return result;
}

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

if ( a1 )
result = nm_nfree(a1, "iiab/ptree.c", 247LL, "ptree_infreemem");
return result;
}

original_code:
void ptree_infreemem(void *memtofree) {
     if (memtofree)
          nm_nfree(memtofree,"iiab/ptree.c",247,__PRETTY_FUNCTION__);
}

variable_types:
memtofree
void *


decompiled_code:
__int64 rt_gtkgui_magic()
{
return 1152194LL;
}

original_code: int rt_gtkgui_magic() { return 1152194; }


decompiled_code:
const char *rt_gtkgui_prefix()
{
return "gtkgui";
}

canonical_decompiled_code:
const char *func1()
{
return "gtkgui";
}

original_code: char * rt_gtkgui_prefix() { return "gtkgui"; }

return_type: char *


decompiled_code:
const char *rt_gtkgui_description()
{
return "MyHabitat GTk+ graphical interface";
}

canonical_decompiled_code:
const char *func2()
{
return "MyHabitat GTk+ graphical interface";
}

original_code: char * rt_gtkgui_description() { return "MyHabitat GTk+ graphical interface"; }


decompiled_code:
void rt_gtkgui_init()
{
;
}

canonical_decompiled_code:
void func3()
{
;
}

original_code: void rt_gtkgui_init (CF_VALS cf, int debug) {}

canonical_original_code: void rt_gtkgui_init(struct tree_head *cf, int debug) {}

variable_types: struct tree_head { struct rb_node { union { struct { struct rb_node *flink; struct rb_node *blink; } list; struct { struct rb_node *left; struct rb_node *right; } child; } c; union { struct rb_node *parent; struct rb_node *root; } p; struct status { unsigned int red; unsigned int internal; unsigned int left; unsigned int root; unsigned int head; } s; union { unsigned int ikey; char *key; struct rb_node *lext; } k; union { char *val; struct rb_node *rext; } v; } *root; struct rb_node *node; } *

variable_types: debug int

user_defined_types: struct tree_head { struct rb_node *root; struct rb_node *node; }


decompiled_code:
void rt_gtkgui_fini()
{
;
}

canonical_decompiled_code:
void func4()
{
;
}

original_code: void rt_gtkgui_fini () {}

canonical_original_code: void rt_gtkgui_fini() {}


decompiled_code:
__int64 rt_gtkgui_access()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func5()
{
return 1LL;
}

original_code:
int rt_gtkgui_access(char *p_url, char *password, char *basename, int flag)
                       {return 1;}

variable_types:
password
char *

variable_types:
basename
char *

variable_types: flag int


decompiled_code:
__int64 rt_gtkgui_open()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func6()
{
return 1LL;
}

original_code:
RT_LLD rt_gtkgui_open (char *p_url, char *comment, char *password, int keep,
         char *basename) {return (RT_LLD) 1;}

canonical_original_code: void *rt_gtkgui_open(char *p_url, char *comment, char *password, int keep, char *basename) {return (void *) 1;}

variable_types:
comment
char *

variable_types: keep int


decompiled_code:
void rt_gtkgui_close()
{
;
}

canonical_decompiled_code:
void func7()
{
;
}

original_code: void rt_gtkgui_close (RT_LLD lld) {}

canonical_original_code: void rt_gtkgui_close(void *lld) {}

variable_types:
lld
void *


decompiled_code:
__int64 rt_gtkgui_twrite()
{
return 1LL;
}

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

original_code: int rt_gtkgui_twrite(RT_LLD lld, TABLE tab) {return 1;}

canonical_original_code: int rt_gtkgui_twrite(void *lld, struct table_info *tab) {return 1;}

variable_types: struct table_info { int ncols; int nrows; int minrowkey; int maxrowkey; struct tree_head { struct rb_node { union { struct { struct rb_node *flink; struct rb_node *blink; } list; struct { struct rb_node *left; struct rb_node *right; } child; } c; union { struct rb_node *parent; struct rb_node *root; } p; struct status { unsigned int red; unsigned int internal; unsigned int left; unsigned int root; unsigned int head; } s; union { unsigned int ikey; char *key; struct rb_node *lext; } k; union { char *val; struct rb_node *rext; } v; } *root; struct rb_node *node; } *data; struct itree_head { struct rb_node *root; struct rb_node *node; } *colorder; struct tree_head *info; struct tree_head *infolookup; struct itree_head *tobegarbage; int refcount; struct itree_head *roworder; char separator; } *

user_defined_types: struct table_info { int ncols; int nrows; int minrowkey; int maxrowkey; struct tree_head *data; struct itree_head *colorder; struct tree_head *info; struct tree_head *infolookup; struct itree_head *tobegarbage; int refcount; struct itree_head *roworder; char separator; }


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

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

original_code:
int rt_gtkgui_tell (RT_LLD lld, int *seq, int *size, time_t *modt)
                       {return 0;}

canonical_original_code:
int rt_gtkgui_tell(void *lld, int *seq, int *size, long *modt)
                       {return 0;}

variable_types:
seq
int *

variable_types:
size
int *

variable_types:
modt
long *


decompiled_code:
__int64 __fastcall rt_gtkgui_write(__int64 a1, __int64 a2, unsigned int a3)
{
uilog_elog_raise(a2, a3);
return a3;
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, __int64 a2, unsigned int a3)
{
uilog_elog_raise(a2, a3);
return a3;
}

original_code:
int rt_gtkgui_write (RT_LLD lld, const void *buf, int buflen)
{
     uilog_elog_raise(buf, buflen);
     return buflen;
}

canonical_original_code:
int rt_gtkgui_write(void *lld, void *buf, int buflen)
{
     uilog_elog_raise(buf, buflen);
     return buflen;
}

variable_types:
buf
void *

variable_types: buflen int


decompiled_code:
// attributes: thunk
__int64 rt_gtkgui_tread()
{
return rt_gtkgui_read_localalias();
}

canonical_decompiled_code:
__int64 func12()
{
return func10();
}

original_code: TABLE rt_gtkgui_tread (RT_LLD lld, int seq, int offset) {return ((void *)0);}

canonical_original_code: struct table_info *rt_gtkgui_tread(void *lld, int seq, int offset) {return ((void *)0);}

variable_types: seq int

variable_types: offset int

return_type: struct table_info { int ncols; int nrows; int minrowkey; int maxrowkey; struct tree_head { struct rb_node { union { struct { struct rb_node *flink; struct rb_node *blink; } list; struct { struct rb_node *left; struct rb_node *right; } child; } c; union { struct rb_node *parent; struct rb_node *root; } p; struct status { unsigned int red; unsigned int internal; unsigned int left; unsigned int root; unsigned int head; } s; union { unsigned int ikey; char *key; struct rb_node *lext; } k; union { char *val; struct rb_node *rext; } v; } *root; struct rb_node *node; } *data; struct itree_head { struct rb_node *root; struct rb_node *node; } *colorder; struct tree_head *info; struct tree_head *infolookup; struct itree_head *tobegarbage; int refcount; struct itree_head *roworder; char separator; } *


decompiled_code:
__int64 dyndata_config()
{
__int64 v0; // rax
__int64 v1; // r12
int v2; // eax
__int64 result; // rax

v0 = cf_getstatus(iiab_cf);
v1 = v0;
if ( v0 )
{
v2 = table_nrows(v0);
if ( v2 )
{
if ( v2 < 0 )
{
v1 = 0LL;
elog_fprintf(
5LL,
"myhabitat/dyndata.c",
38LL,
"dyndata_config",
"Unable to get configuration rows. Please check that Habitat is installed correctly");
}
}
else
{
v1 = 0LL;
elog_fprintf(
5LL,
"myhabitat/dyndata.c",
34LL,
"dyndata_config",
"Empty configuration. Please check that Habitat is installed correctly");
}
result = v1;
}
else
{
elog_fprintf(
6LL,
"myhabitat/dyndata.c",
29LL,
"dyndata_config",
"No configuration at all, please check that Habitat is installed correctly");
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v0; // rax
__int64 v1; // r12
int v2; // eax
__int64 result; // rax

v0 = cf_getstatus(iiab_cf);
v1 = v0;
if ( v0 )
{
v2 = table_nrows(v0);
if ( v2 )
{
if ( v2 < 0 )
{
v1 = 0LL;
elog_fprintf(
5LL,
"myhabitat/dyndata.c",
38LL,
"dyndata_config",
"Unable to get configuration rows. Please check that Habitat is installed correctly");
}
}
else
{
v1 = 0LL;
elog_fprintf(
5LL,
"myhabitat/dyndata.c",
34LL,
"dyndata_config",
"Empty configuration. Please check that Habitat is installed correctly");
}
result = v1;
}
else
{
elog_fprintf(
6LL,
"myhabitat/dyndata.c",
29LL,
"dyndata_config",
"No configuration at all, please check that Habitat is installed correctly");
result = 0LL;
}
return result;
}

original_code:
TABLE dyndata_config(time_t from, time_t to)
{
     TABLE tab;
     int r;
     tab = cf_getstatus ( iiab_cf );
     if ( ! tab ) {
          elog_fprintf(FATAL,"myhabitat/dyndata.c",29,__PRETTY_FUNCTION__,"No configuration at all, please check that " "Habitat is installed correctly");
     } else {
          r = table_nrows(tab);
          if ( r == 0) {
        elog_fprintf(ERROR,"myhabitat/dyndata.c",34,__PRETTY_FUNCTION__,"Empty configuration. Please check that " "Habitat is installed correctly");
        return ((void *)0);
   } else if (r < 0) {
        elog_fprintf(ERROR,"myhabitat/dyndata.c",38,__PRETTY_FUNCTION__,"Unable to get configuration rows. Please " "check that Habitat is installed correctly");
        return ((void *)0);
   }
     }
     return tab;
}

canonical_original_code:
struct table_info *dyndata_config(long from, long to)
{
     struct table_info *tab;
     int r;
     tab = cf_getstatus ( iiab_cf );
     if ( ! tab ) {
          elog_fprintf(FATAL,"myhabitat/dyndata.c",29,__PRETTY_FUNCTION__,"No configuration at all, please check that " "Habitat is installed correctly");
     } else {
          r = table_nrows(tab);
          if ( r == 0) {
        elog_fprintf(ERROR,"myhabitat/dyndata.c",34,__PRETTY_FUNCTION__,"Empty configuration. Please check that " "Habitat is installed correctly");
        return ((void *)0);
   } else if (r < 0) {
        elog_fprintf(ERROR,"myhabitat/dyndata.c",38,__PRETTY_FUNCTION__,"Unable to get configuration rows. Please " "check that Habitat is installed correctly");
        return ((void *)0);
   }
     }
     return tab;
}

variable_types: from long

variable_types: to long

variable_types: r int

user_defined_types: struct itree_head { struct rb_node *root; struct rb_node *node; }


decompiled_code:
_BOOL8 __fastcall event_execute(char *s, __int64 a2, __int64 a3, __int64 a4, unsigned int a5)
{
__int64 v7; // r12
int v8; // eax
char *v9; // r15
__int64 v10; // rax
__int64 v11; // rbp
__int64 v12; // rax
__int64 v13; // r12
time_t v14; // rax
int v15; // ebx
char v17[120]; // [rsp+0h] [rbp-78h] BYREF

v7 = (int)(strlen(s) + 1);
util_strgsub(s, &LC6, &LC5, v7);
util_strgsub(s, "%", "\n", v7);
util_strgsub(s, &LC5, "%", v7);
s[(int)strcspn(s, "\n")] = 0;
v8 = strcspn(s, " \t");
s[v8] = 0;
v9 = &s[v8 + 1];
v10 = route_getpurl(a2);
v11 = nm_xnstrdup(v10, "iiab/event.c", 155LL, "event_execute");
v12 = route_getpurl(a3);
v13 = nm_xnstrdup(v12, "iiab/event.c", 156LL, "event_execute");
snprintf(v17, 0x40uLL, "event-%d", a5);
v14 = time(0LL);
v15 = job_add(v14, 0LL, 0LL, 1LL, v17, "(event)", v11, v13, 1000LL, s, v9);
nm_nfree(v11, "iiab/event.c", 163LL, "event_execute");
nm_nfree(v13, "iiab/event.c", 164LL, "event_execute");
return v15 != -1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(char *s, __int64 a2, __int64 a3, __int64 a4, unsigned int a5)
{
__int64 v7; // r12
int v8; // eax
char *v9; // r15
__int64 v10; // rax
__int64 v11; // rbp
__int64 v12; // rax
__int64 v13; // r12
time_t v14; // rax
int v15; // ebx
char v17[120]; // [rsp+0h] [rbp-78h] BYREF

v7 = (int)(strlen(s) + 1);
util_strgsub(s, &LC6, &LC5, v7);
util_strgsub(s, "%", "\n", v7);
util_strgsub(s, &LC5, "%", v7);
s[(int)strcspn(s, "\n")] = 0;
v8 = strcspn(s, " \t");
s[v8] = 0;
v9 = &s[v8 + 1];
v10 = route_getpurl(a2);
v11 = nm_xnstrdup(v10, "iiab/event.c", 155LL, "event_execute");
v12 = route_getpurl(a3);
v13 = nm_xnstrdup(v12, "iiab/event.c", 156LL, "event_execute");
snprintf(v17, 0x40uLL, "event-%d", a5);
v14 = time(0LL);
v15 = job_add(v14, 0LL, 0LL, 1LL, v17, "(event)", v11, v13, 1000LL, s, v9);
nm_nfree(v11, "iiab/event.c", 163LL, "event_execute");
nm_nfree(v13, "iiab/event.c", 164LL, "event_execute");
return v15 != -1;
}

original_code:
int event_execute(char *cmdln, ROUTE output, ROUTE error, char *rtname,
    int seq)
{
     char *cmd, *input, jobid[64], *outpurl, *errpurl;
     int lnlen, len, r;
     lnlen = strlen(cmdln);
     util_strgsub(cmdln, "\\%", "\001\001", lnlen+1);
     util_strgsub(cmdln, "%", "\n", lnlen+1);
     util_strgsub(cmdln, "\001\001", "%", lnlen+1);
     len = strcspn(cmdln, "\n");
     *(cmdln+len) = '\0';
     input = cmdln + len + 1;
     len = strcspn(cmdln, " \t");
     *(cmdln+len) = '\0';
     cmd = cmdln + len + 1;
     outpurl = nm_xnstrdup(route_getpurl(output),"iiab/event.c",155,__PRETTY_FUNCTION__);
     errpurl = nm_xnstrdup(route_getpurl(error),"iiab/event.c",156,__PRETTY_FUNCTION__);
     snprintf(jobid, 64, "event-%d", seq);
     r = job_add(time(((void *)0)), 0, 0, 1, jobid, "(event)", outpurl, errpurl,
   1000, cmdln , cmd);
     nm_nfree(outpurl,"iiab/event.c",163,__PRETTY_FUNCTION__);
     nm_nfree(errpurl,"iiab/event.c",164,__PRETTY_FUNCTION__);
     if (r == -1)
   return 0;
     else
   return 1;
}

canonical_original_code:
int event_execute(char *cmdln, struct route_handle *output, struct route_handle *error, char *rtname, int seq)
{
     char *cmd; char *input; char jobid[64]; char *outpurl; char *errpurl;
     int lnlen; int len; int r;
     lnlen = strlen(cmdln);
     util_strgsub(cmdln, "\\%", "\001\001", lnlen+1);
     util_strgsub(cmdln, "%", "\n", lnlen+1);
     util_strgsub(cmdln, "\001\001", "%", lnlen+1);
     len = strcspn(cmdln, "\n");
     *(cmdln+len) = '\0';
     input = cmdln + len + 1;
     len = strcspn(cmdln, " \t");
     *(cmdln+len) = '\0';
     cmd = cmdln + len + 1;
     outpurl = nm_xnstrdup(route_getpurl(output),"iiab/event.c",155,__PRETTY_FUNCTION__);
     errpurl = nm_xnstrdup(route_getpurl(error),"iiab/event.c",156,__PRETTY_FUNCTION__);
     snprintf(jobid, 64, "event-%d", seq);
     r = job_add(time(((void *)0)), 0, 0, 1, jobid, "(event)", outpurl, errpurl,
   1000, cmdln , cmd);
     nm_nfree(outpurl,"iiab/event.c",163,__PRETTY_FUNCTION__);
     nm_nfree(errpurl,"iiab/event.c",164,__PRETTY_FUNCTION__);
     if (r == -1)
   return 0;
     else
   return 1;
}

variable_types:
cmdln
char *

variable_types: struct route_handle { char *p_url; struct route_lowlevel { int (*ll_magic)(); char *(*ll_prefix)(); char *(*ll_description)(); void (*ll_init)(struct tree_head { struct rb_node { union { struct { struct rb_node *flink; struct rb_node *blink; } list; struct { struct rb_node *left; struct rb_node *right; } child; } c; union { struct rb_node *parent; struct rb_node *root; } p; struct status { unsigned int red; unsigned int internal; unsigned int left; unsigned int root; unsigned int head; } s; union { unsigned int ikey; char *key; struct rb_node *lext; } k; union { char *val; struct rb_node *rext; } v; } *root; struct rb_node *node; } *cf, int debug); void (*ll_fini)(); int (*ll_access)(char *p_url, char *password, char *basename, int flag); void *(*ll_open)(char *p_url, char *comment, char *password, int keep, char *basename); void (*ll_close)(void *lld); int (*ll_write)(void *lld, void *buf, int buflen); int (*ll_twrite)(void *lld, struct table_info { int ncols; int nrows; int minrowkey; int maxrowkey; struct tree_head *data; struct itree_head { struct rb_node *root; struct rb_node *node; } *colorder; struct tree_head *info; struct tree_head *infolookup; struct itree_head *tobegarbage; int refcount; struct itree_head *roworder; char separator; } *tab); int (*ll_tell)(void *lld, int *seq, int *size, long *modt); struct itree_head *(*ll_read)(void *lld, int seq, int offset); struct table_info *(*ll_tread)(void *lld, int seq, int offset); void (*ll_status)(void *lld, char **status, char **info); int (*ll_checkpoint)(void *lld); } *method; void *handle; struct route_buffer { int buflen; char *buffer; } unsent; } *

variable_types:
error
struct route_handle *

variable_types:
rtname
char *

variable_types:
cmd
char *

variable_types:
input
char *

variable_types:
jobid
char [64]

variable_types:
outpurl
char *

variable_types:
errpurl
char *

variable_types: lnlen int

variable_types: len int

user_defined_types: struct route_handle { char *p_url; struct route_lowlevel *method; void *handle; struct route_buffer unsent; }

user_defined_types: struct route_lowlevel { int (*ll_magic)(); char *(*ll_prefix)(); char *(*ll_description)(); void (*ll_init)(struct tree_head *cf, int debug); void (*ll_fini)(); int (*ll_access)(char *p_url, char *password, char *basename, int flag); void *(*ll_open)(char *p_url, char *comment, char *password, int keep, char *basename); void (*ll_close)(void *lld); int (*ll_write)(void *lld, void *buf, int buflen); int (*ll_twrite)(void *lld, struct table_info *tab); int (*ll_tell)(void *lld, int *seq, int *size, long *modt); struct itree_head *(*ll_read)(void *lld, int seq, int offset); struct table_info *(*ll_tread)(void *lld, int seq, int offset); void (*ll_status)(void *lld, char **status, char **info); int (*ll_checkpoint)(void *lld); }


decompiled_code:
__int64 __fastcall event_action(__int64 a1, __int64 a2, __int64 a3)
{
_QWORD *v5; // rdi
_QWORD *v6; // rdx
_QWORD *v7; // rax
_QWORD *v8; // rdi
__int64 v9; // rax
_QWORD *v10; // rax
__int64 v11; // rdi
_QWORD *v12; // rbx
__int64 v13; // rax
_QWORD **v14; // rax
_QWORD *v15; // rbp
_QWORD *v16; // rdx
_QWORD *v17; // rax
__int64 v18; // rax
__int64 v19; // r15
signed int v21; // [rsp+0h] [rbp-48h] BYREF
char v22[4]; // [rsp+4h] [rbp-44h] BYREF
char v23[64]; // [rsp+8h] [rbp-40h] BYREF

v5 = *(_QWORD **)a1;
v6 = (_QWORD *)*v5;
v7 = *(_QWORD **)*v5;
v5[1] = v7;
if ( v6 == v7 )
return 0LL;
while ( 1 )
{
v10 = (_QWORD *)tree_get();
v11 = v10[1];
v12 = v10;
if ( v11 || (v13 = route_open(*v10, 0LL, 0LL, 0LL), v12[1] = v13, (v11 = v13) != 0) )
{
route_tell(v11, &v21, v22, v23);
if ( *((_DWORD *)v12 + 4) < v21 )
break;
}
LABEL_4:
v8 = *(_QWORD **)a1;
v9 = **(_QWORD **)(*(_QWORD *)a1 + 8LL);
v8[1] = v9;
if ( v9 == *v8 )
return 0LL;
}
v14 = (_QWORD **)route_seekread(v12[1], (unsigned int)v21, 0LL);
v15 = v14;
if ( v14 )
{
v16 = *v14;
v17 = (_QWORD *)**v14;
v15[1] = v17;
if ( v16 != v17 )
{
do
{
v19 = itree_get(v15);
if ( !event_execute(*(char **)(v19 + 8), a2, a3, *v12, v21) )
elog_fprintf(
5LL,
"iiab/event.c",
108LL,
"event_action",
"unable to create event job for `%s'",
*(const char **)(v19 + 8));
v18 = *(_QWORD *)v15[1];
v15[1] = v18;
}
while ( v18 != *v15 );
}
*((_DWORD *)v12 + 4) = v21;
route_free_routebuf(v15);
goto LABEL_4;
}
elog_fprintf(5LL, "iiab/event.c", 99LL, "event_action", "unable to read changed items");
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3)
{
_QWORD *v5; // rdi
_QWORD *v6; // rdx
_QWORD *v7; // rax
_QWORD *v8; // rdi
__int64 v9; // rax
_QWORD *v10; // rax
__int64 v11; // rdi
_QWORD *v12; // rbx
__int64 v13; // rax
_QWORD **v14; // rax
_QWORD *v15; // rbp
_QWORD *v16; // rdx
_QWORD *v17; // rax
__int64 v18; // rax
__int64 v19; // r15
signed int v21; // [rsp+0h] [rbp-48h] BYREF
char v22[4]; // [rsp+4h] [rbp-44h] BYREF
char v23[64]; // [rsp+8h] [rbp-40h] BYREF

v5 = *(_QWORD **)a1;
v6 = (_QWORD *)*v5;
v7 = *(_QWORD **)*v5;
v5[1] = v7;
if ( v6 == v7 )
return 0LL;
while ( 1 )
{
v10 = (_QWORD *)tree_get();
v11 = v10[1];
v12 = v10;
if ( v11 || (v13 = route_open(*v10, 0LL, 0LL, 0LL), v12[1] = v13, (v11 = v13) != 0) )
{
route_tell(v11, &v21, v22, v23);
if ( *((_DWORD *)v12 + 4) < v21 )
break;
}
LABEL_4:
v8 = *(_QWORD **)a1;
v9 = **(_QWORD **)(*(_QWORD *)a1 + 8LL);
v8[1] = v9;
if ( v9 == *v8 )
return 0LL;
}
v14 = (_QWORD **)route_seekread(v12[1], (unsigned int)v21, 0LL);
v15 = v14;
if ( v14 )
{
v16 = *v14;
v17 = (_QWORD *)**v14;
v15[1] = v17;
if ( v16 != v17 )
{
do
{
v19 = itree_get(v15);
if ( !func0(*(char **)(v19 + 8), a2, a3, *v12, v21) )
elog_fprintf(
5LL,
"iiab/event.c",
108LL,
"event_action",
"unable to create event job for `%s'",
*(const char **)(v19 + 8));
v18 = *(_QWORD *)v15[1];
v15[1] = v18;
}
while ( v18 != *v15 );
}
*((_DWORD *)v12 + 4) = v21;
route_free_routebuf(v15);
goto LABEL_4;
}
elog_fprintf(5LL, "iiab/event.c", 99LL, "event_action", "unable to read changed items");
return 0xFFFFFFFFLL;
}

original_code:
int event_action(EVENTINFO einfo, ROUTE output, ROUTE error)
{
     int seq, size;
     time_t modt;
     ITREE *bufchain;
     ROUTE_BUF *buf;
     struct event_tracking *etrack;
     for((einfo->track)->node = ((einfo->track)->root->c.list.flink); (einfo->track)->node != ((einfo->track)->root); (einfo->track)->node = ((einfo->track)->node->c.list.flink)) {
   etrack = tree_get(einfo->track);
   if (etrack->rt == ((void *)0)) {
        etrack->rt = route_open(etrack->rtname, ((void *)0), ((void *)0), 0);
        if (etrack->rt == ((void *)0))
      continue;
   }
   route_tell(etrack->rt, &seq, &size, &modt);
   if (seq > etrack->lastseq) {
        bufchain = route_seekread(etrack->rt, seq, 0);
        if (bufchain == ((void *)0)) {
      elog_fprintf(ERROR,"iiab/event.c",99,__PRETTY_FUNCTION__,"unable to read changed items");
      return -1;
        }
        for((bufchain)->node = ((bufchain)->root->c.list.flink); (bufchain)->node != ((bufchain)->root); (bufchain)->node = ((bufchain)->node->c.list.flink)) {
      buf = itree_get(bufchain);
      if (event_execute(buf->buffer, output, error,
          etrack->rtname, seq) == 0)
    elog_fprintf(ERROR,"iiab/event.c",108,__PRETTY_FUNCTION__,"unable to create event " "job for `%s'", buf->buffer);
        }
        etrack->lastseq = seq;
        route_free_routebuf(bufchain);
   }
     }
     return 0;
}

canonical_original_code:
int event_action(struct event_information *einfo, struct route_handle *output, struct route_handle *error)
{
     int seq; int size;
     long modt;
     struct itree_head *bufchain;
     struct route_buffer *buf;
     struct event_tracking *etrack;
     for((einfo->track)->node = ((einfo->track)->root->c.list.flink); (einfo->track)->node != ((einfo->track)->root); (einfo->track)->node = ((einfo->track)->node->c.list.flink)) {
   etrack = tree_get(einfo->track);
   if (etrack->rt == ((void *)0)) {
        etrack->rt = route_open(etrack->rtname, ((void *)0), ((void *)0), 0);
        if (etrack->rt == ((void *)0))
      continue;
   }
   route_tell(etrack->rt, &seq, &size, &modt);
   if (seq > etrack->lastseq) {
        bufchain = route_seekread(etrack->rt, seq, 0);
        if (bufchain == ((void *)0)) {
      elog_fprintf(ERROR,"iiab/event.c",99,__PRETTY_FUNCTION__,"unable to read changed items");
      return -1;
        }
        for((bufchain)->node = ((bufchain)->root->c.list.flink); (bufchain)->node != ((bufchain)->root); (bufchain)->node = ((bufchain)->node->c.list.flink)) {
      buf = itree_get(bufchain);
      if (event_execute(buf->buffer, output, error,
          etrack->rtname, seq) == 0)
    elog_fprintf(ERROR,"iiab/event.c",108,__PRETTY_FUNCTION__,"unable to create event " "job for `%s'", buf->buffer);
        }
        etrack->lastseq = seq;
        route_free_routebuf(bufchain);
   }
     }
     return 0;
}

variable_types: struct event_information { struct tree_head { struct rb_node { union { struct { struct rb_node *flink; struct rb_node *blink; } list; struct { struct rb_node *left; struct rb_node *right; } child; } c; union { struct rb_node *parent; struct rb_node *root; } p; struct status { unsigned int red; unsigned int internal; unsigned int left; unsigned int root; unsigned int head; } s; union { unsigned int ikey; char *key; struct rb_node *lext; } k; union { char *val; struct rb_node *rext; } v; } *root; struct rb_node *node; } *track; } *

variable_types: struct route_handle { char *p_url; struct route_lowlevel { int (*ll_magic)(); char *(*ll_prefix)(); char *(*ll_description)(); void (*ll_init)(struct tree_head *cf, int debug); void (*ll_fini)(); int (*ll_access)(char *p_url, char *password, char *basename, int flag); void *(*ll_open)(char *p_url, char *comment, char *password, int keep, char *basename); void (*ll_close)(void *lld); int (*ll_write)(void *lld, void *buf, int buflen); int (*ll_twrite)(void *lld, struct table_info { int ncols; int nrows; int minrowkey; int maxrowkey; struct tree_head *data; struct itree_head { struct rb_node *root; struct rb_node *node; } *colorder; struct tree_head *info; struct tree_head *infolookup; struct itree_head *tobegarbage; int refcount; struct itree_head *roworder; char separator; } *tab); int (*ll_tell)(void *lld, int *seq, int *size, long *modt); struct itree_head *(*ll_read)(void *lld, int seq, int offset); struct table_info *(*ll_tread)(void *lld, int seq, int offset); void (*ll_status)(void *lld, char **status, char **info); int (*ll_checkpoint)(void *lld); } *method; void *handle; struct route_buffer { int buflen; char *buffer; } unsent; } *

variable_types: size int

variable_types: modt long

variable_types: struct itree_head { struct rb_node { union { struct { struct rb_node *flink; struct rb_node *blink; } list; struct { struct rb_node *left; struct rb_node *right; } child; } c; union { struct rb_node *parent; struct rb_node *root; } p; struct status { unsigned int red; unsigned int internal; unsigned int left; unsigned int root; unsigned int head; } s; union { unsigned int ikey; char *key; struct rb_node *lext; } k; union { char *val; struct rb_node *rext; } v; } *root; struct rb_node *node; } *

variable_types: struct route_buffer { int buflen; char *buffer; } *

variable_types: struct event_tracking { char *rtname; struct route_handle { char *p_url; struct route_lowlevel { int (*ll_magic)(); char *(*ll_prefix)(); char *(*ll_description)(); void (*ll_init)(struct tree_head { struct rb_node { union { struct { struct rb_node *flink; struct rb_node *blink; } list; struct { struct rb_node *left; struct rb_node *right; } child; } c; union { struct rb_node *parent; struct rb_node *root; } p; struct status { unsigned int red; unsigned int internal; unsigned int left; unsigned int root; unsigned int head; } s; union { unsigned int ikey; char *key; struct rb_node *lext; } k; union { char *val; struct rb_node *rext; } v; } *root; struct rb_node *node; } *cf, int debug); void (*ll_fini)(); int (*ll_access)(char *p_url, char *password, char *basename, int flag); void *(*ll_open)(char *p_url, char *comment, char *password, int keep, char *basename); void (*ll_close)(void *lld); int (*ll_write)(void *lld, void *buf, int buflen); int (*ll_twrite)(void *lld, struct table_info { int ncols; int nrows; int minrowkey; int maxrowkey; struct tree_head *data; struct itree_head { struct rb_node *root; struct rb_node *node; } *colorder; struct tree_head *info; struct tree_head *infolookup; struct itree_head *tobegarbage; int refcount; struct itree_head *roworder; char separator; } *tab); int (*ll_tell)(void *lld, int *seq, int *size, long *modt); struct itree_head *(*ll_read)(void *lld, int seq, int offset); struct table_info *(*ll_tread)(void *lld, int seq, int offset); void (*ll_status)(void *lld, char **status, char **info); int (*ll_checkpoint)(void *lld); } *method; void *handle; struct route_buffer { int buflen; char *buffer; } unsent; } *rt; int lastseq; } *

user_defined_types: struct event_information { struct tree_head *track; }

user_defined_types: struct event_tracking { char *rtname; struct route_handle *rt; int lastseq; }


decompiled_code:
__int64 __fastcall event_fini(_QWORD *a1)
{
_QWORD *v2; // rdi
_QWORD *v3; // rbp

v2 = (_QWORD *)*a1;
if ( *v2 != *(_QWORD *)*v2 )
{
do
{
tree_first();
v3 = (_QWORD *)tree_get(*a1);
nm_nfree(*v3, "iiab/event.c", 180LL, "event_fini");
if ( v3[1] )
route_close();
nm_nfree(v3, "iiab/event.c", 183LL, "event_fini");
tree_rm(*a1);
v2 = (_QWORD *)*a1;
}
while ( *(_QWORD *)*a1 != **(_QWORD **)*a1 );
}
tree_really_destroy(v2, "iiab/event.c", 186LL, "event_fini");
return nm_nfree(a1, "iiab/event.c", 187LL, "event_fini");
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD *a1)
{
_QWORD *v2; // rdi
_QWORD *v3; // rbp

v2 = (_QWORD *)*a1;
if ( *v2 != *(_QWORD *)*v2 )
{
do
{
tree_first();
v3 = (_QWORD *)tree_get(*a1);
nm_nfree(*v3, "iiab/event.c", 180LL, "event_fini");
if ( v3[1] )
route_close();
nm_nfree(v3, "iiab/event.c", 183LL, "event_fini");
tree_rm(*a1);
v2 = (_QWORD *)*a1;
}
while ( *(_QWORD *)*a1 != **(_QWORD **)*a1 );
}
tree_really_destroy(v2, "iiab/event.c", 186LL, "event_fini");
return nm_nfree(a1, "iiab/event.c", 187LL, "event_fini");
}

original_code:
void event_fini(EVENTINFO einfo)
{
     struct event_tracking *etrack;
     while ( ! ((einfo->track)->root->c.list.flink == (einfo->track)->root) ) {
   tree_first(einfo->track);
   etrack = tree_get(einfo->track);
   nm_nfree(etrack->rtname,"iiab/event.c",180,__PRETTY_FUNCTION__);
   if (etrack->rt)
        route_close(etrack->rt);
   nm_nfree(etrack,"iiab/event.c",183,__PRETTY_FUNCTION__);
   tree_rm(einfo->track);
     }
     tree_really_destroy(einfo->track,"iiab/event.c",186,__PRETTY_FUNCTION__);
     nm_nfree(einfo,"iiab/event.c",187,__PRETTY_FUNCTION__);
}

canonical_original_code:
void event_fini(struct event_information *einfo)
{
     struct event_tracking *etrack;
     while ( ! ((einfo->track)->root->c.list.flink == (einfo->track)->root) ) {
   tree_first(einfo->track);
   etrack = tree_get(einfo->track);
   nm_nfree(etrack->rtname,"iiab/event.c",180,__PRETTY_FUNCTION__);
   if (etrack->rt)
        route_close(etrack->rt);
   nm_nfree(etrack,"iiab/event.c",183,__PRETTY_FUNCTION__);
   tree_rm(einfo->track);
     }
     tree_really_destroy(einfo->track,"iiab/event.c",186,__PRETTY_FUNCTION__);
     nm_nfree(einfo,"iiab/event.c",187,__PRETTY_FUNCTION__);
}

user_defined_types: struct route_buffer { int buflen; char *buffer; }


decompiled_code:
char **plinintr_getcols()
{
return &plinintr_cols;
}

canonical_decompiled_code:
char **func0()
{
return &plinintr_cols;
}

original_code: struct probe_sampletab *plinintr_getcols() {return plinintr_cols;}

return_type: struct probe_sampletab { char *name; char *rname; char *type; char *sense; char *max; char *key; char *info; } *


decompiled_code:
void *plinintr_getrowdiff()
{
return &plinintr_diffs;
}

canonical_decompiled_code:
void *func1()
{
return &plinintr_diffs;
}

original_code: struct probe_rowdiff *plinintr_getrowdiff() {return plinintr_diffs;}

return_type: struct probe_rowdiff { char *source; char *result; } *


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

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

original_code: char **plinintr_getpub() {return ((void *)0);}

return_type: char **


decompiled_code:
__int64 plinintr_init()
{
const char *v0; // rax
const char *v1; // rbp
char *v2; // rax
__int64 result; // rax

v0 = (const char *)probe_readfile("/proc/version");
if ( !v0 )
return elog_fprintf(5LL, "probe/plinintr.c", 67LL, "plinintr_init", "unable to find the linux kernel version file");
v1 = v0;
v2 = strstr(v0, "version ");
if ( v2 )
{
if ( !memcmp(v2 + 8, "2.1.", 4uLL) || !memcmp(v2 + 8, "2.2.", 4uLL) )
{
plinintr_linuxversion = 22;
}
else if ( !memcmp(v2 + 8, "2.3.", 4uLL) || !memcmp(v2 + 8, "2.4.", 4uLL) )
{
plinintr_linuxversion = 24;
}
else if ( !memcmp(v2 + 8, "2.5.", 4uLL) || !memcmp(v2 + 8, "2.6.", 4uLL) )
{
plinintr_linuxversion = 26;
}
else if ( v2[8] == 51 && v2[9] == 46 )
{
plinintr_linuxversion = 30;
}
else
{
elog_fprintf(5LL, "probe/plinintr.c", 87LL, "plinintr_init", "unsupported linux kernel version");
}
result = nm_nfree(v1, "probe/plinintr.c", 91LL, "plinintr_init");
}
else
{
elog_fprintf(5LL, "probe/plinintr.c", 73LL, "plinintr_init", "unable to find the linux kernel version");
result = nm_nfree(v1, "probe/plinintr.c", 74LL, "plinintr_init");
}
return result;
}

canonical_decompiled_code:
__int64 func3()
{
const char *v0; // rax
const char *v1; // rbp
char *v2; // rax
__int64 result; // rax

v0 = (const char *)probe_readfile("/proc/version");
if ( !v0 )
return elog_fprintf(5LL, "probe/plinintr.c", 67LL, "plinintr_init", "unable to find the linux kernel version file");
v1 = v0;
v2 = strstr(v0, "version ");
if ( v2 )
{
if ( !memcmp(v2 + 8, "2.1.", 4uLL) || !memcmp(v2 + 8, "2.2.", 4uLL) )
{
plinintr_linuxversion = 22;
}
else if ( !memcmp(v2 + 8, "2.3.", 4uLL) || !memcmp(v2 + 8, "2.4.", 4uLL) )
{
plinintr_linuxversion = 24;
}
else if ( !memcmp(v2 + 8, "2.5.", 4uLL) || !memcmp(v2 + 8, "2.6.", 4uLL) )
{
plinintr_linuxversion = 26;
}
else if ( v2[8] == 51 && v2[9] == 46 )
{
plinintr_linuxversion = 30;
}
else
{
elog_fprintf(5LL, "probe/plinintr.c", 87LL, "plinintr_init", "unsupported linux kernel version");
}
result = nm_nfree(v1, "probe/plinintr.c", 91LL, "plinintr_init");
}
else
{
elog_fprintf(5LL, "probe/plinintr.c", 73LL, "plinintr_init", "unable to find the linux kernel version");
result = nm_nfree(v1, "probe/plinintr.c", 74LL, "plinintr_init");
}
return result;
}

original_code:
void plinintr_init() {
     char *data, *vpt;
     data = probe_readfile("/proc/version");
     if (!data) {
          elog_fprintf(ERROR,"probe/plinintr.c",67,__PRETTY_FUNCTION__,"unable to find the linux kernel " "version file");
   return;
     }
     vpt = strstr(data, "version ");
     if (!vpt) {
          elog_fprintf(ERROR,"probe/plinintr.c",73,__PRETTY_FUNCTION__,"unable to find the linux kernel version");
   nm_nfree(data,"probe/plinintr.c",74,__PRETTY_FUNCTION__);
   return;
     }
     vpt += 8;
     if (strncmp(vpt, "2.1.", 4) == 0 || strncmp(vpt, "2.2.", 4) == 0) {
          plinintr_linuxversion=22;
     } else if (strncmp(vpt, "2.3.", 4) == 0 || strncmp(vpt, "2.4.", 4) == 0) {
          plinintr_linuxversion=24;
     } else if (strncmp(vpt, "2.5.", 4) == 0 || strncmp(vpt, "2.6.", 4) == 0) {
          plinintr_linuxversion=26;
     } else if (strncmp(vpt, "3.", 2) == 0) {
          plinintr_linuxversion=30;
     } else {
          elog_fprintf(ERROR,"probe/plinintr.c",87,__PRETTY_FUNCTION__,"unsupported linux kernel version");
     }
     nm_nfree(data,"probe/plinintr.c",91,__PRETTY_FUNCTION__);
     return;
}

canonical_original_code:
void plinintr_init() {
     char *data; char *vpt;
     data = probe_readfile("/proc/version");
     if (!data) {
          elog_fprintf(ERROR,"probe/plinintr.c",67,__PRETTY_FUNCTION__,"unable to find the linux kernel " "version file");
   return;
     }
     vpt = strstr(data, "version ");
     if (!vpt) {
          elog_fprintf(ERROR,"probe/plinintr.c",73,__PRETTY_FUNCTION__,"unable to find the linux kernel version");
   nm_nfree(data,"probe/plinintr.c",74,__PRETTY_FUNCTION__);
   return;
     }
     vpt += 8;
     if (strncmp(vpt, "2.1.", 4) == 0 || strncmp(vpt, "2.2.", 4) == 0) {
          plinintr_linuxversion=22;
     } else if (strncmp(vpt, "2.3.", 4) == 0 || strncmp(vpt, "2.4.", 4) == 0) {
          plinintr_linuxversion=24;
     } else if (strncmp(vpt, "2.5.", 4) == 0 || strncmp(vpt, "2.6.", 4) == 0) {
          plinintr_linuxversion=26;
     } else if (strncmp(vpt, "3.", 2) == 0) {
          plinintr_linuxversion=30;
     } else {
          elog_fprintf(ERROR,"probe/plinintr.c",87,__PRETTY_FUNCTION__,"unsupported linux kernel version");
     }
     nm_nfree(data,"probe/plinintr.c",91,__PRETTY_FUNCTION__);
     return;
}

variable_types:
data
char *

variable_types:
vpt
char *


decompiled_code:
__int64 __fastcall plinintr_col_intr(__int64 a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rbp
int v4; // ebx
const char *v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax

result = plinintr_linuxversion;
if ( plinintr_linuxversion == 22 )
{
result = itree_find(a2, 1LL);
if ( result != -1 )
{
v8 = itree_get(a2);
table_replacecurrentcell(a1, "hard", v8);
itree_last(a2);
v9 = itree_get(a2);
result = table_replacecurrentcell(a1, "name", v9);
}
}
else if ( (plinintr_linuxversion & 0xFFFFFFFD) == 24 || plinintr_linuxversion == 30 )
{
if ( plinintr_ncpu <= 0 )
{
v3 = 0LL;
LABEL_10:
if ( (unsigned int)itree_n(a2) == plinintr_ncpu + 1 )
itree_first(a2);
else
itree_last(a2);
v6 = itree_get(a2);
table_replacecurrentcell(a1, "name", v6);
v7 = util_u32toa(v3);
result = table_replacecurrentcell_alloc(a1, "hard", v7);
}
else
{
LODWORD(v3) = 0;
v4 = 1;
while ( 1 )
{
result = itree_find(a2, (unsigned int)v4);
if ( result == -1 )
break;
++v4;
v5 = (const char *)itree_get(a2);
LODWORD(v3) = strtol(v5, 0LL, 10) + v3;
if ( plinintr_ncpu < v4 )
{
v3 = (int)v3;
goto LABEL_10;
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
__int64 result; // rax
__int64 v3; // rbp
int v4; // ebx
const char *v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax

result = plinintr_linuxversion;
if ( plinintr_linuxversion == 22 )
{
result = itree_find(a2, 1LL);
if ( result != -1 )
{
v8 = itree_get(a2);
table_replacecurrentcell(a1, "hard", v8);
itree_last(a2);
v9 = itree_get(a2);
result = table_replacecurrentcell(a1, "name", v9);
}
}
else if ( (plinintr_linuxversion & 0xFFFFFFFD) == 24 || plinintr_linuxversion == 30 )
{
if ( plinintr_ncpu <= 0 )
{
v3 = 0LL;
LABEL_10:
if ( (unsigned int)itree_n(a2) == plinintr_ncpu + 1 )
itree_first(a2);
else
itree_last(a2);
v6 = itree_get(a2);
table_replacecurrentcell(a1, "name", v6);
v7 = util_u32toa(v3);
result = table_replacecurrentcell_alloc(a1, "hard", v7);
}
else
{
LODWORD(v3) = 0;
v4 = 1;
while ( 1 )
{
result = itree_find(a2, (unsigned int)v4);
if ( result == -1 )
break;
++v4;
v5 = (const char *)itree_get(a2);
LODWORD(v3) = strtol(v5, 0LL, 10) + v3;
if ( plinintr_ncpu < v4 )
{
v3 = (int)v3;
goto LABEL_10;
}
}
}
}
return result;
}

original_code:
void plinintr_col_intr(TABLE tab, ITREE *idata) {
     if (plinintr_linuxversion == 22) {
          if (itree_find(idata, 1) == (void *) -1)
        return;
   table_replacecurrentcell(tab, "hard", itree_get(idata));
   itree_last(idata);
   table_replacecurrentcell(tab, "name", itree_get(idata));
     } else if (plinintr_linuxversion == 24 ||
                plinintr_linuxversion == 26 ||
                plinintr_linuxversion == 30) {
          int i, val=0;
   for (i=1; i <= plinintr_ncpu; i++) {
        if (itree_find(idata, i) == (void *) -1)
      return;
        val += strtol(itree_get(idata), ((void *)0), 10);
   }
   if (itree_n(idata) == plinintr_ncpu + 1)
        itree_first(idata);
   else
        itree_last(idata);
   table_replacecurrentcell(tab, "name", itree_get(idata));
   table_replacecurrentcell_alloc(tab, "hard", util_u32toa(val));
     }
}

canonical_original_code:
void plinintr_col_intr(struct table_info *tab, struct itree_head *idata) {
     if (plinintr_linuxversion == 22) {
          if (itree_find(idata, 1) == (void *) -1)
        return;
   table_replacecurrentcell(tab, "hard", itree_get(idata));
   itree_last(idata);
   table_replacecurrentcell(tab, "name", itree_get(idata));
     } else if (plinintr_linuxversion == 24 ||
                plinintr_linuxversion == 26 ||
                plinintr_linuxversion == 30) {
          int i; int val = 0;
   for (i=1; i <= plinintr_ncpu; i++) {
        if (itree_find(idata, i) == (void *) -1)
      return;
        val += strtol(itree_get(idata), ((void *)0), 10);
   }
   if (itree_n(idata) == plinintr_ncpu + 1)
        itree_first(idata);
   else
        itree_last(idata);
   table_replacecurrentcell(tab, "name", itree_get(idata));
   table_replacecurrentcell_alloc(tab, "hard", util_u32toa(val));
     }
}

variable_types: struct table_info { int ncols; int nrows; int minrowkey; int maxrowkey; struct tree_head { struct rb_node { union { struct { struct rb_node *flink; struct rb_node *blink; } list; struct { struct rb_node *left; struct rb_node *right; } child; } c; union { struct rb_node *parent; struct rb_node *root; } p; struct status { unsigned int red; unsigned int internal; unsigned int left; unsigned int root; unsigned int head; } s; union { unsigned int ikey; char *key; struct rb_node *lext; } k; union { char *val; struct rb_node *rext; } v; } *root; struct rb_node *node; } *data; struct itree_head { struct rb_node *root; struct rb_node *node; } *colorder; struct tree_head *info; struct tree_head *infolookup; struct itree_head *tobegarbage; int refcount; struct itree_head *roworder; char separator; } *

variable_types:
idata
struct itree_head *

variable_types: i int

variable_types: val int


decompiled_code:
__int64 __fastcall plinintr_collect(__int64 a1)
{
__int64 result; // rax
__int64 v3; // r12
__int64 v4; // rax
int v5; // eax
_QWORD *v6; // rdi
_QWORD *v7; // rdx
__int64 v8; // rax
__int64 v9; // rsi
__int64 v10[4]; // [rsp+8h] [rbp-20h] BYREF

result = probe_readfile("/proc/interrupts");
if ( result )
{
v3 = result;
util_scantext(result, ": +", 1LL, v10);
itree_first(v10[0]);
v4 = itree_get(v10[0]);
v5 = itree_n(v4);
v6 = (_QWORD *)v10[0];
plinintr_ncpu = v5;
v7 = *(_QWORD **)v10[0];
v8 = **(_QWORD **)v10[0];
for ( *(_QWORD *)(v10[0] + 8) = v8; (_QWORD *)v8 != v7; v6[1] = v8 )
{
if ( *(_QWORD **)(v8 + 8) != v7 )
{
table_addemptyrow(a1);
v9 = itree_get(v10[0]);
plinintr_col_intr(a1, v9);
v6 = (_QWORD *)v10[0];
}
v7 = (_QWORD *)*v6;
v8 = *(_QWORD *)v6[1];
}
util_scanfree();
result = table_freeondestroy(a1, v3);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
__int64 result; // rax
__int64 v3; // r12
__int64 v4; // rax
int v5; // eax
_QWORD *v6; // rdi
_QWORD *v7; // rdx
__int64 v8; // rax
__int64 v9; // rsi
__int64 v10[4]; // [rsp+8h] [rbp-20h] BYREF

result = probe_readfile("/proc/interrupts");
if ( result )
{
v3 = result;
util_scantext(result, ": +", 1LL, v10);
itree_first(v10[0]);
v4 = itree_get(v10[0]);
v5 = itree_n(v4);
v6 = (_QWORD *)v10[0];
plinintr_ncpu = v5;
v7 = *(_QWORD **)v10[0];
v8 = **(_QWORD **)v10[0];
for ( *(_QWORD *)(v10[0] + 8) = v8; (_QWORD *)v8 != v7; v6[1] = v8 )
{
if ( *(_QWORD **)(v8 + 8) != v7 )
{
table_addemptyrow(a1);
v9 = itree_get(v10[0]);
func4(a1, v9);
v6 = (_QWORD *)v10[0];
}
v7 = (_QWORD *)*v6;
v8 = *(_QWORD *)v6[1];
}
util_scanfree();
result = table_freeondestroy(a1, v3);
}
return result;
}

original_code:
void plinintr_collect(TABLE tab) {
     char *data;
     ITREE *lines;
     data = probe_readfile("/proc/interrupts");
     if (data) {
       util_scantext(data, ": +", 1, &lines);
   itree_first(lines);
   plinintr_ncpu = itree_n((ITREE *)itree_get(lines));
   for((lines)->node = ((lines)->root->c.list.flink); (lines)->node != ((lines)->root); (lines)->node = ((lines)->node->c.list.flink)) {
        if (((lines)->root==(lines)->node->c.list.blink))
      continue;
        table_addemptyrow(tab);
        plinintr_col_intr(tab, itree_get(lines) );
   }
   util_scanfree(lines);
   table_freeondestroy(tab, data);
     }
}

canonical_original_code:
void plinintr_collect(struct table_info *tab) {
     char *data;
     struct itree_head *lines;
     data = probe_readfile("/proc/interrupts");
     if (data) {
       util_scantext(data, ": +", 1, &lines);
   itree_first(lines);
   plinintr_ncpu = itree_n((struct itree_head *)itree_get(lines));
   for((lines)->node = ((lines)->root->c.list.flink); (lines)->node != ((lines)->root); (lines)->node = ((lines)->node->c.list.flink)) {
        if (((lines)->root==(lines)->node->c.list.blink))
      continue;
        table_addemptyrow(tab);
        plinintr_col_intr(tab, itree_get(lines) );
   }
   util_scanfree(lines);
   table_freeondestroy(tab, data);
     }
}


decompiled_code:
void plinintr_derive()
{
;
}

canonical_decompiled_code:
void func6()
{
;
}

original_code: void plinintr_derive(TABLE prev, TABLE cur) {}

canonical_original_code: void plinintr_derive(struct table_info *prev, struct table_info *cur) {}

variable_types:
cur
struct table_info *


decompiled_code:
time_t *uitime_forget_data()
{
time_t *result; // rax

uitime_avail_oldest = 0LL;
uitime_avail_youngest = 0LL;
uitime_view_oldest = 0LL;
result = &uitime_view_youngest;
uitime_view_youngest = 0LL;
return result;
}

canonical_decompiled_code:
time_t *func0()
{
time_t *result; // rax

uitime_avail_oldest = 0LL;
uitime_avail_youngest = 0LL;
uitime_view_oldest = 0LL;
result = &uitime_view_youngest;
uitime_view_youngest = 0LL;
return result;
}

original_code:
void uitime_forget_data()
{
     uitime_avail_oldest = 0;
     uitime_avail_youngest = 0;
     uitime_view_oldest = 0;
     uitime_view_youngest = 0;
}


decompiled_code:
_DWORD *uitime_prevent_slider_reload()
{
_DWORD *result; // rax

result = &uitime_prevent_reload;
uitime_prevent_reload = 1;
return result;
}

canonical_decompiled_code:
_DWORD *func2()
{
_DWORD *result; // rax

result = &uitime_prevent_reload;
uitime_prevent_reload = 1;
return result;
}

original_code: void uitime_prevent_slider_reload() { uitime_prevent_reload = 1; }


decompiled_code:
_DWORD *uitime_allow_slider_reload()
{
_DWORD *result; // rax

result = &uitime_prevent_reload;
uitime_prevent_reload = 0;
return result;
}

canonical_decompiled_code:
_DWORD *func3()
{
_DWORD *result; // rax

result = &uitime_prevent_reload;
uitime_prevent_reload = 0;
return result;
}

original_code: void uitime_allow_slider_reload() { uitime_prevent_reload = 0; }


decompiled_code:
char **plinnames_getcols()
{
return &plinnames_cols;
}

canonical_decompiled_code:
char **func0()
{
return &plinnames_cols;
}

original_code: struct probe_sampletab *plinnames_getcols() {return plinnames_cols;}

user_defined_types: struct probe_sampletab { char *name; char *rname; char *type; char *sense; char *max; char *key; char *info; }


decompiled_code:
void *plinnames_getrowdiff()
{
return &plinnames_diffs;
}

canonical_decompiled_code:
void *func1()
{
return &plinnames_diffs;
}

original_code: struct probe_rowdiff *plinnames_getrowdiff() {return plinnames_diffs;}

user_defined_types: struct probe_rowdiff { char *source; char *result; }


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

original_code: char **plinnames_getpub() {return ((void *)0);}


decompiled_code:
void plinnames_init()
{
;
}

canonical_decompiled_code:
void func3()
{
;
}

original_code:
void plinnames_init() {
}

canonical_original_code:
void plinnames_init() {
}


decompiled_code:
__int64 plinnames_fini()
{
tree_clearout(plinnames_sysfiles, &tree_infreemem, &tree_infreemem);
return tree_really_destroy(plinnames_sysfiles, "probe/plinnames.c", 77LL, "plinnames_fini");
}

canonical_decompiled_code:
__int64 func4()
{
tree_clearout(plinnames_sysfiles, &tree_infreemem, &tree_infreemem);
return tree_really_destroy(plinnames_sysfiles, "probe/plinnames.c", 77LL, "plinnames_fini");
}

original_code:
void plinnames_fini()
{
     tree_clearout((plinnames_sysfiles),tree_infreemem,tree_infreemem);
     tree_really_destroy(plinnames_sysfiles,"probe/plinnames.c",77,__PRETTY_FUNCTION__);
}


decompiled_code:
__int64 __fastcall plinnames_collect(__int64 a1)
{
_QWORD *v2; // rdi
__int64 v3; // rdx
__int64 v4; // rax
__int64 v5; // rdx
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
const char *v11; // rax
char *v12; // rax

plinnames_sysfiles = tree_really_create("probe/plinnames.c", 53LL, "plinnames_collect");
plinnames_readalldir_localalias("/proc/sys", plinnames_sysfiles);
v2 = (_QWORD *)plinnames_sysfiles;
v3 = *plinnames_sysfiles;
v4 = *(_QWORD *)*plinnames_sysfiles;
*(_QWORD *)(plinnames_sysfiles + 8LL) = v4;
if ( v3 != v4 )
{
do
{
table_addemptyrow(a1);
v9 = tree_get(plinnames_sysfiles);
table_replacecurrentcell(a1, "value", v9);
v10 = tree_getkey(plinnames_sysfiles);
table_replacecurrentcell(a1, "name", v10);
v11 = (const char *)tree_getkey(plinnames_sysfiles);
v12 = strrchr(v11, 47);
if ( v12 )
v5 = (__int64)(v12 + 1);
else
v5 = tree_getkey(plinnames_sysfiles);
table_replacecurrentcell(a1, "vname", v5);
v6 = tree_getkey(plinnames_sysfiles);
table_freeondestroy(a1, v6);
v7 = tree_get(plinnames_sysfiles);
table_freeondestroy(a1, v7);
v2 = (_QWORD *)plinnames_sysfiles;
v8 = **(_QWORD **)(plinnames_sysfiles + 8LL);
*(_QWORD *)(plinnames_sysfiles + 8LL) = v8;
}
while ( v8 != *v2 );
}
return tree_really_destroy(v2, "probe/plinnames.c", 70LL, "plinnames_collect");
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
_QWORD *v2; // rdi
__int64 v3; // rdx
__int64 v4; // rax
__int64 v5; // rdx
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
const char *v11; // rax
char *v12; // rax

plinnames_sysfiles = tree_really_create("probe/plinnames.c", 53LL, "plinnames_collect");
func5("/proc/sys", plinnames_sysfiles);
v2 = (_QWORD *)plinnames_sysfiles;
v3 = *plinnames_sysfiles;
v4 = *(_QWORD *)*plinnames_sysfiles;
*(_QWORD *)(plinnames_sysfiles + 8LL) = v4;
if ( v3 != v4 )
{
do
{
table_addemptyrow(a1);
v9 = tree_get(plinnames_sysfiles);
table_replacecurrentcell(a1, "value", v9);
v10 = tree_getkey(plinnames_sysfiles);
table_replacecurrentcell(a1, "name", v10);
v11 = (const char *)tree_getkey(plinnames_sysfiles);
v12 = strrchr(v11, 47);
if ( v12 )
v5 = (__int64)(v12 + 1);
else
v5 = tree_getkey(plinnames_sysfiles);
table_replacecurrentcell(a1, "vname", v5);
v6 = tree_getkey(plinnames_sysfiles);
table_freeondestroy(a1, v6);
v7 = tree_get(plinnames_sysfiles);
table_freeondestroy(a1, v7);
v2 = (_QWORD *)plinnames_sysfiles;
v8 = **(_QWORD **)(plinnames_sysfiles + 8LL);
*(_QWORD *)(plinnames_sysfiles + 8LL) = v8;
}
while ( v8 != *v2 );
}
return tree_really_destroy(v2, "probe/plinnames.c", 70LL, "plinnames_collect");
}

original_code:
void plinnames_collect(TABLE tab) {
     char *basename;
     plinnames_sysfiles = tree_really_create("probe/plinnames.c",53,__PRETTY_FUNCTION__);
     plinnames_readalldir("/proc/sys", plinnames_sysfiles);
     for((plinnames_sysfiles)->node = ((plinnames_sysfiles)->root->c.list.flink); (plinnames_sysfiles)->node != ((plinnames_sysfiles)->root); (plinnames_sysfiles)->node = ((plinnames_sysfiles)->node->c.list.flink)) {
   table_addemptyrow(tab);
   table_replacecurrentcell(tab, "value",
       tree_get(plinnames_sysfiles));
   table_replacecurrentcell(tab, "name",
       tree_getkey(plinnames_sysfiles));
   basename = strrchr(tree_getkey(plinnames_sysfiles), '/');
   if (basename)
        basename++;
   else
        basename = tree_getkey(plinnames_sysfiles);
   table_replacecurrentcell(tab, "vname", basename);
   table_freeondestroy(tab, tree_getkey(plinnames_sysfiles));
   table_freeondestroy(tab, tree_get(plinnames_sysfiles));
     }
     tree_really_destroy(plinnames_sysfiles,"probe/plinnames.c",70,__PRETTY_FUNCTION__);
}

canonical_original_code:
void plinnames_collect(struct table_info *tab) {
     char *basename;
     plinnames_sysfiles = tree_really_create("probe/plinnames.c",53,__PRETTY_FUNCTION__);
     plinnames_readalldir("/proc/sys", plinnames_sysfiles);
     for((plinnames_sysfiles)->node = ((plinnames_sysfiles)->root->c.list.flink); (plinnames_sysfiles)->node != ((plinnames_sysfiles)->root); (plinnames_sysfiles)->node = ((plinnames_sysfiles)->node->c.list.flink)) {
   table_addemptyrow(tab);
   table_replacecurrentcell(tab, "value",
       tree_get(plinnames_sysfiles));
   table_replacecurrentcell(tab, "name",
       tree_getkey(plinnames_sysfiles));
   basename = strrchr(tree_getkey(plinnames_sysfiles), '/');
   if (basename)
        basename++;
   else
        basename = tree_getkey(plinnames_sysfiles);
   table_replacecurrentcell(tab, "vname", basename);
   table_freeondestroy(tab, tree_getkey(plinnames_sysfiles));
   table_freeondestroy(tab, tree_get(plinnames_sysfiles));
     }
     tree_really_destroy(plinnames_sysfiles,"probe/plinnames.c",70,__PRETTY_FUNCTION__);
}

variable_types:
basename
char *


decompiled_code:
void plinnames_derive()
{
;
}

canonical_decompiled_code:
void func7()
{
;
}

original_code: void plinnames_derive(TABLE prev, TABLE cur) {}

canonical_original_code: void plinnames_derive(struct table_info *prev, struct table_info *cur) {}


decompiled_code:
void __fastcall __noreturn exit_handler(unsigned int a1)
{
__int64 v1; // rax

sig_off();
LODWORD(v1) = getpid();
elog_fprintf(3LL, "cmd/habmeth.c", 128LL, "exit_handler", "Shutting down from signal %d (I am pid %d)", a1, v1);
meth_fini();
iiab_stop();
exit(0);
}

canonical_decompiled_code:
void __fastcall __noreturn func0(unsigned int a1)
{
__int64 v1; // rax

sig_off();
LODWORD(v1) = getpid();
elog_fprintf(3LL, "cmd/habmeth.c", 128LL, "exit_handler", "Shutting down from signal %d (I am pid %d)", a1, v1);
meth_fini();
iiab_stop();
exit(0);
}

original_code:
void exit_handler(int sig ) {
     sig_off();
     elog_fprintf(INFO,"cmd/habmeth.c",128,__PRETTY_FUNCTION__,"Shutting down from signal %d (I am pid %d)", sig, getpid());
     meth_fini();
     iiab_stop();
     exit(0);
}

canonical_original_code:
void exit_handler(int sig) {
     sig_off();
     elog_fprintf(INFO,"cmd/habmeth.c",128,__PRETTY_FUNCTION__,"Shutting down from signal %d (I am pid %d)", sig, getpid());
     meth_fini();
     iiab_stop();
     exit(0);
}

variable_types: sig int


decompiled_code:
void __noreturn exit_method()
{
unsigned int v0; // eax

sig_off();
v0 = getpid();
elog_fprintf(3LL, "cmd/habmeth.c", 138LL, "exit_method", "Shutting down from a method (I am pid %d)", v0);
meth_fini();
iiab_stop();
exit(0);
}

canonical_decompiled_code:
void __noreturn func1()
{
unsigned int v0; // eax

sig_off();
v0 = getpid();
elog_fprintf(3LL, "cmd/habmeth.c", 138LL, "exit_method", "Shutting down from a method (I am pid %d)", v0);
meth_fini();
iiab_stop();
exit(0);
}

original_code:
void exit_method(int sig ) {
     sig_off();
     elog_fprintf(INFO,"cmd/habmeth.c",138,__PRETTY_FUNCTION__,"Shutting down from a method (I am pid %d)", getpid());
     meth_fini();
     iiab_stop();
     exit(0);
}

canonical_original_code:
void exit_method(int sig) {
     sig_off();
     elog_fprintf(INFO,"cmd/habmeth.c",138,__PRETTY_FUNCTION__,"Shutting down from a method (I am pid %d)", getpid());
     meth_fini();
     iiab_stop();
     exit(0);
}


listmeths

decompiled_code:
__int64 __fastcall listmeths(__int64 a1, int a2)
{
__int64 (**v2)(void); // rbx
unsigned int v3; // er12
const char *v4; // r15
const char *v5; // rax

v2 = (__int64 (**)(void))&meth_builtins;
if ( !meth_builtins )
return 0;
v3 = 0;
do
{
v4 = (const char *)v2[1]();
v5 = (const char *)(*v2)();
v2 += 8;
v3 += snprintf((char *)(a1 + (int)v3), (int)(a2 - v3), " %-11.11s %s\n", v5, v4);
}
while ( *v2 );
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, int a2)
{
__int64 (**v2)(void); // rbx
unsigned int v3; // er12
const char *v4; // r15
const char *v5; // rax

v2 = (__int64 (**)(void))&meth_builtins;
if ( !meth_builtins )
return 0;
v3 = 0;
do
{
v4 = (const char *)v2[1]();
v5 = (const char *)(*v2)();
v2 += 8;
v3 += snprintf((char *)(a1 + (int)v3), (int)(a2 - v3), " %-11.11s %s\n", v5, v4);
}
while ( *v2 );
return v3;
}

original_code:
int listmeths(char *buf, int buflen) {
     int i, curlen=0;
     for (i=0; meth_builtins[i].name; i++)
   curlen += snprintf(buf+curlen, buflen-curlen,
        "      %-11.11s %s\n",
        meth_builtins[i].name(),
        meth_builtins[i].info());
     return curlen;
}

canonical_original_code:
int listmeths(char *buf, int buflen) {
     int i; int curlen = 0;
     for (i=0; meth_builtins[i].name; i++)
   curlen += snprintf(buf+curlen, buflen-curlen,
        "      %-11.11s %s\n",
        meth_builtins[i].name(),
        meth_builtins[i].info());
     return curlen;
}

variable_types:
buf
char *

variable_types: buflen int

variable_types: curlen int


mkusage

decompiled_code:
__int128 *mkusage()
{
int v0; // eax
__int128 *result; // rax

strcpy((char *)&dword_2F0, "are:-\n");
usage_2 = (__int128)_mm_load_si128((const __m128i *)&LC5);
xmmword_2D0 = (__int128)_mm_load_si128((const __m128i *)&LC6);
xmmword_2E0 = (__int128)_mm_load_si128((const __m128i *)&LC7);
v0 = listmeths((__int64)&usage_2 + 54, 1946);
strncpy((char *)&usage_2 + v0 + 54, "excludes probe method, see habprobe(1)\n", 2000 - (v0 + 54));
result = &usage_2;
byte_A8F = 0;
return result;
}

canonical_decompiled_code:
__int128 *func3()
{
int v0; // eax
__int128 *result; // rax

strcpy((char *)&dword_2F0, "are:-\n");
usage_2 = (__int128)_mm_load_si128((const __m128i *)&LC5);
xmmword_2D0 = (__int128)_mm_load_si128((const __m128i *)&LC6);
xmmword_2E0 = (__int128)_mm_load_si128((const __m128i *)&LC7);
v0 = func2((__int64)&usage_2 + 54, 1946);
strncpy((char *)&usage_2 + v0 + 54, "excludes probe method, see habprobe(1)\n", 2000 - (v0 + 54));
result = &usage_2;
byte_A8F = 0;
return result;
}

original_code:
char *mkusage() {
     static char usage[2000];
     int i;
     strcpy(usage, "Run a habitat method stand alone, where methods are:-\n");
     i=strlen(usage);
     i+=listmeths(usage+i, 2000-i);
     strncpy(usage+i, "excludes probe method, see habprobe(1)\n", 2000-i);
     usage[1999] = '\0';
     return usage;
}

variable_types:
usage
char [2000]


main

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // er13
int v4; // ebx
unsigned int v5; // er14
__int64 v6; // rcx
const char *v7; // rax
__int64 v8; // rbp
unsigned int v9; // eax
__int64 v10; // rbp
const char *v11; // rax
const char *v12; // [rsp-8h] [rbp-470h]
__int64 v13; // [rsp+18h] [rbp-450h]
char s[8]; // [rsp+28h] [rbp-440h] BYREF
char v15[1080]; // [rsp+30h] [rbp-438h] BYREF

usagetxt = mkusage();
iiab_start(&LC8, (unsigned int)argc, argv, usagetxt, cfdefaults);
if ( !(unsigned int)cf_defined(iiab_cmdarg, "argv1") )
{
elog_fprintf(6LL, "cmd/habmeth.c", 48LL, "main", "%s\nplease specify which method to run", usagetxt);
iiab_stop();
exit(1);
}
v13 = cf_getstr(iiab_cmdarg, "argv1");
v3 = cf_getint(iiab_cmdarg, "argc");
if ( v3 <= 2 )
goto LABEL_12;
v4 = 0;
v5 = 2;
do
{
v6 = v5++;
snprintf(s, 8uLL, "argv%d", v6);
v7 = (const char *)cf_getstr(iiab_cmdarg, s);
v4 += snprintf(&v15[v4], 1024 - v4, "%s ", v7);
}
while ( v3 != v5 );
if ( v4 <= 0 )
LABEL_12:
v15[0] = 0;
else
v15[v4 - 1] = 0;
elog_setsevpurl(2LL, "stderr:");
meth_init((unsigned int)argc, argv, exit_method);
v8 = tree_find(meth_methods, v13);
if ( v8 != -1 )
{
sig_init();
sig_on();
sig_setexit(exit_handler);
v9 = meth_actiononly(v8, v15, "stdout:", "stderr:", 0LL);
v10 = v9;
if ( v9 )
{
v12 = (const char *)cf_getstr(iiab_cmdarg, "argv1");
elog_fprintf(6LL, "cmd/habmeth.c", 88LL, "main", "Method %s failed, returning %d", v12, v10);
}
meth_fini();
iiab_stop();
exit(v10);
}
v11 = (const char *)cf_getstr(iiab_cmdarg, "argv1");
elog_fprintf(6LL, "cmd/habmeth.c", 77LL, "main", "%s\nmethod %s not recognised", usagetxt, v11);
exit(1);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // er13
int v4; // ebx
unsigned int v5; // er14
__int64 v6; // rcx
const char *v7; // rax
__int64 v8; // rbp
unsigned int v9; // eax
__int64 v10; // rbp
const char *v11; // rax
const char *v12; // [rsp-8h] [rbp-470h]
__int64 v13; // [rsp+18h] [rbp-450h]
char s[8]; // [rsp+28h] [rbp-440h] BYREF
char v15[1080]; // [rsp+30h] [rbp-438h] BYREF

usagetxt = func3();
iiab_start(&LC8, (unsigned int)argc, argv, usagetxt, cfdefaults);
if ( !(unsigned int)cf_defined(iiab_cmdarg, "argv1") )
{
elog_fprintf(6LL, "cmd/habmeth.c", 48LL, "main", "%s\nplease specify which method to run", usagetxt);
iiab_stop();
exit(1);
}
v13 = cf_getstr(iiab_cmdarg, "argv1");
v3 = cf_getint(iiab_cmdarg, "argc");
if ( v3 <= 2 )
goto LABEL_12;
v4 = 0;
v5 = 2;
do
{
v6 = v5++;
snprintf(s, 8uLL, "argv%d", v6);
v7 = (const char *)cf_getstr(iiab_cmdarg, s);
v4 += snprintf(&v15[v4], 1024 - v4, "%s ", v7);
}
while ( v3 != v5 );
if ( v4 <= 0 )
LABEL_12:
v15[0] = 0;
else
v15[v4 - 1] = 0;
elog_setsevpurl(2LL, "stderr:");
meth_init((unsigned int)argc, argv, exit_method);
v8 = tree_find(meth_methods, v13);
if ( v8 != -1 )
{
sig_init();
sig_on();
sig_setexit(exit_handler);
v9 = meth_actiononly(v8, v15, "stdout:", "stderr:", 0LL);
v10 = v9;
if ( v9 )
{
v12 = (const char *)cf_getstr(iiab_cmdarg, "argv1");
elog_fprintf(6LL, "cmd/habmeth.c", 88LL, "main", "Method %s failed, returning %d", v12, v10);
}
meth_fini();
iiab_stop();
exit(v10);
}
v11 = (const char *)cf_getstr(iiab_cmdarg, "argv1");
elog_fprintf(6LL, "cmd/habmeth.c", 77LL, "main", "%s\nmethod %s not recognised", usagetxt, v11);
exit(1);
}

original_code:
int main(int argc, char *argv[]) {
     char *method, command[1024], argstr[8];
     int i, r, limit, clen=0;
     METHID methid;
     usagetxt = mkusage();
     iiab_start("", argc, argv, usagetxt, cfdefaults);
     if ( ! cf_defined(iiab_cmdarg, "argv1")) {
   elog_fprintf(FATAL,"cmd/habmeth.c",48,__PRETTY_FUNCTION__,"%s\nplease specify which method to run", usagetxt);
   iiab_stop();
   exit(1);
     }
     method=cf_getstr(iiab_cmdarg, "argv1");
     limit=cf_getint(iiab_cmdarg, "argc");
     clen=0;
     for (i=2; i<limit; i++) {
   snprintf(argstr, 8, "argv%d", i);
   clen += snprintf(command+clen, 1024-clen, "%s ",
      cf_getstr(iiab_cmdarg, argstr));
     }
     if (clen > 0)
   command[clen-1] = '\0';
     else
   command[0] = '\0';
     elog_setsevpurl(DIAG, "stderr:");
     meth_init(argc, argv, exit_method);
     methid = tree_find(meth_methods, (method));
     if (methid == (void *) -1) {
   elog_fprintf(FATAL,"cmd/habmeth.c",77,__PRETTY_FUNCTION__,"%s\nmethod %s not recognised", usagetxt, cf_getstr(iiab_cmdarg, "argv1"));
   exit(1);
     }
     sig_init();
     sig_on();
     sig_setexit(exit_handler);
     if ((r = meth_actiononly(methid, command, "stdout:", "stderr:", 0)))
       elog_fprintf(FATAL,"cmd/habmeth.c",88,__PRETTY_FUNCTION__,"Method %s failed, returning %d", cf_getstr(iiab_cmdarg, "argv1"), r);
     meth_fini();
     iiab_stop();
     exit(r);
}

canonical_original_code:
int main(int argc, char *argv[]) {
     char *method; char command[1024]; char argstr[8];
     int i; int r; int limit; int clen = 0;
     struct meth_info *methid;
     usagetxt = mkusage();
     iiab_start("", argc, argv, usagetxt, cfdefaults);
     if ( ! cf_defined(iiab_cmdarg, "argv1")) {
   elog_fprintf(FATAL,"cmd/habmeth.c",48,__PRETTY_FUNCTION__,"%s\nplease specify which method to run", usagetxt);
   iiab_stop();
   exit(1);
     }
     method=cf_getstr(iiab_cmdarg, "argv1");
     limit=cf_getint(iiab_cmdarg, "argc");
     clen=0;
     for (i=2; i<limit; i++) {
   snprintf(argstr, 8, "argv%d", i);
   clen += snprintf(command+clen, 1024-clen, "%s ",
      cf_getstr(iiab_cmdarg, argstr));
     }
     if (clen > 0)
   command[clen-1] = '\0';
     else
   command[0] = '\0';
     elog_setsevpurl(DIAG, "stderr:");
     meth_init(argc, argv, exit_method);
     methid = tree_find(meth_methods, (method));
     if (methid == (void *) -1) {
   elog_fprintf(FATAL,"cmd/habmeth.c",77,__PRETTY_FUNCTION__,"%s\nmethod %s not recognised", usagetxt, cf_getstr(iiab_cmdarg, "argv1"));
   exit(1);
     }
     sig_init();
     sig_on();
     sig_setexit(exit_handler);
     if ((r = meth_actiononly(methid, command, "stdout:", "stderr:", 0)))
       elog_fprintf(FATAL,"cmd/habmeth.c",88,__PRETTY_FUNCTION__,"Method %s failed, returning %d", cf_getstr(iiab_cmdarg, "argv1"), r);
     meth_fini();
     iiab_stop();
     exit(r);
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
method
char *

variable_types:
command
char [1024]

variable_types:
argstr
char [8]

variable_types: r int

variable_types: limit int

variable_types: clen int

variable_types: struct meth_info { char *(*name)(); char *(*info)(); enum exectype { METH_NONE=0, METH_FORK=1, METH_THREAD=2, METH_SOURCE=3 } (*type)(); int (*prerun)(); int (*preaction)(); int (*action)(); int (*postrun)(); char *fname; } *

user_defined_types: struct meth_info { char *(*name)(); char *(*info)(); enum exectype (*type)(); int (*prerun)(); int (*preaction)(); int (*action)(); int (*postrun)(); char *fname; }