InitMittenHook

decompiled_code:
__int64 InitMittenHook()
{
__int64 v1[2]; // [rsp+8h] [rbp-10h] BYREF

MitnCell_GetCellAsMitnFunc(v1, &pop);
MitnDict_DefineOperator(&unk_AC9, v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &exch);
MitnDict_DefineOperator("exch", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &dup);
MitnDict_DefineOperator("dup", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &copy);
MitnDict_DefineOperator("copy", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &roll);
MitnDict_DefineOperator("roll", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &clear);
MitnDict_DefineOperator("clear", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &count);
MitnDict_DefineOperator("count", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &mark);
MitnDict_DefineOperator("mark", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &cleartomark);
MitnDict_DefineOperator("cleartomark", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &counttomark);
MitnDict_DefineOperator("counttomark", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &MitnMath_Neg);
MitnDict_DefineOperator("neg", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &MitnMath_Add);
MitnDict_DefineOperator("add", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &MitnMath_Sub);
MitnDict_DefineOperator("sub", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &MitnMath_Mul);
MitnDict_DefineOperator("mul", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &MitnMath_Div);
MitnDict_DefineOperator("idiv", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &help);
MitnDict_DefineOperator("help", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &PopAndPrint);
MitnDict_DefineOperator("==", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &MitnStack_Status);
MitnDict_DefineOperator("stack-status", v1[0]);
MitnCell_GetCellAsTradFunc(v1, &echo, 1LL);
MitnDict_DefineOperator("echo", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &MitnStack_GarbageCollect);
MitnDict_DefineOperator("gc", v1[0]);
MitnCell_GetCellAsTradFunc(v1, &open_fd, 4095LL);
MitnDict_DefineOperator("openfd", v1[0]);
MitnCell_GetCellAsTradFunc(v1, &read_fd, 4095LL);
MitnDict_DefineOperator("readfd", v1[0]);
MitnCell_GetCellAsTradFunc(v1, &write_fd, 4095LL);
MitnDict_DefineOperator("writefd", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &reset);
MitnDict_DefineOperator("reset", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &falldown);
MitnDict_DefineOperator("falldown", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &vget_region);
MitnDict_DefineOperator("vget", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &print_task_list);
MitnDict_DefineOperator("task-list", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &pmemstat);
MitnDict_DefineOperator("pmemstat", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &cexec);
MitnDict_DefineOperator("cexec", v1[0]);
MitnCell_GetCellAsTradFunc(v1, &posix_cat, 2LL);
MitnDict_DefineOperator("pcat", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &posix_dir);
MitnDict_DefineOperator("pdir", v1[0]);
MitnCell_GetCellAsTradFunc(v1, &posix_dump, 1LL);
MitnDict_DefineOperator("pdump", v1[0]);
MitnCell_GetCellAsTradFunc(v1, &posix_exec_test, 1LL);
MitnDict_DefineOperator("pexec", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &posix_fork_test);
MitnDict_DefineOperator("pfork", v1[0]);
MitnCell_GetCellAsTradFunc(v1, &posix_mount, 2LL);
MitnDict_DefineOperator("pmount", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &posix_noaction);
MitnDict_DefineOperator("pnoaction", v1[0]);
MitnCell_GetCellAsTradFunc(v1, &posix, 1LL);
MitnDict_DefineOperator("posix", v1[0]);
MitnCell_GetCellAsTradFunc(v1, &posix_vm_dump, 1LL);
MitnDict_DefineOperator("pvmdump", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &p_open);
MitnDict_DefineOperator("posix-open", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &p_write);
MitnDict_DefineOperator("posix-write", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &p_close);
MitnDict_DefineOperator("posix-close", v1[0]);
MitnCell_GetCellAsTradFunc(v1, &posix_writefile, 2LL);
MitnDict_DefineOperator("pwrite", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &graphic_mode);
MitnDict_DefineOperator("graphic-mode", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &text_mode);
MitnDict_DefineOperator("text-mode", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &gsave);
MitnDict_DefineOperator("gsave", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &translate);
MitnDict_DefineOperator("translate", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &moveto);
MitnDict_DefineOperator("moveto", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &rmoveto);
MitnDict_DefineOperator("rmoveto", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &setcolor);
MitnDict_DefineOperator("setcolor", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &setmode);
MitnDict_DefineOperator("setmode", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &box);
MitnDict_DefineOperator("box", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &fillbox);
MitnDict_DefineOperator("fillbox", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &lineto);
MitnDict_DefineOperator("lineto", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &rlineto);
MitnDict_DefineOperator("rlineto", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &draw_window);
MitnDict_DefineOperator("draw-window", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &scroll);
MitnDict_DefineOperator("scroll", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &lowlib_stat);
MitnDict_DefineOperator("lowlib", v1[0]);
MitnCell_GetCellAsTradFunc(v1, &lowlib_load, 1LL);
MitnDict_DefineOperator("load", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &ide_stat);
MitnDict_DefineOperator("idestat", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &ide_geometric);
MitnDict_DefineOperator("idegeo", v1[0]);
MitnCell_GetCellAsTradFunc(v1, &ide_read, 1LL);
MitnDict_DefineOperator("ideread", v1[0]);
MitnCell_GetCellAsTradFunc(v1, &ether, 4095LL);
MitnDict_DefineOperator("ether", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &malloc_test);
MitnDict_DefineOperator("malloc", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &root_info);
MitnDict_DefineOperator("rootinfo", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &k106jp);
MitnDict_DefineOperator("k106jp", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &k101us);
MitnDict_DefineOperator("k101us", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &pmemdump);
return MitnDict_DefineOperator("pmemdump", v1[0]);
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v1[2]; // [rsp+8h] [rbp-10h] BYREF

MitnCell_GetCellAsMitnFunc(v1, &pop);
MitnDict_DefineOperator(&unk_AC9, v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &exch);
MitnDict_DefineOperator("exch", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &dup);
MitnDict_DefineOperator("dup", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &copy);
MitnDict_DefineOperator("copy", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &roll);
MitnDict_DefineOperator("roll", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &clear);
MitnDict_DefineOperator("clear", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &count);
MitnDict_DefineOperator("count", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &mark);
MitnDict_DefineOperator("mark", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &cleartomark);
MitnDict_DefineOperator("cleartomark", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &counttomark);
MitnDict_DefineOperator("counttomark", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &MitnMath_Neg);
MitnDict_DefineOperator("neg", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &MitnMath_Add);
MitnDict_DefineOperator("add", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &MitnMath_Sub);
MitnDict_DefineOperator("sub", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &MitnMath_Mul);
MitnDict_DefineOperator("mul", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &MitnMath_Div);
MitnDict_DefineOperator("idiv", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &help);
MitnDict_DefineOperator("help", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &PopAndPrint);
MitnDict_DefineOperator("==", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &MitnStack_Status);
MitnDict_DefineOperator("stack-status", v1[0]);
MitnCell_GetCellAsTradFunc(v1, &echo, 1LL);
MitnDict_DefineOperator("echo", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &MitnStack_GarbageCollect);
MitnDict_DefineOperator("gc", v1[0]);
MitnCell_GetCellAsTradFunc(v1, &open_fd, 4095LL);
MitnDict_DefineOperator("openfd", v1[0]);
MitnCell_GetCellAsTradFunc(v1, &read_fd, 4095LL);
MitnDict_DefineOperator("readfd", v1[0]);
MitnCell_GetCellAsTradFunc(v1, &write_fd, 4095LL);
MitnDict_DefineOperator("writefd", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &reset);
MitnDict_DefineOperator("reset", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &falldown);
MitnDict_DefineOperator("falldown", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &vget_region);
MitnDict_DefineOperator("vget", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &print_task_list);
MitnDict_DefineOperator("task-list", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &pmemstat);
MitnDict_DefineOperator("pmemstat", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &cexec);
MitnDict_DefineOperator("cexec", v1[0]);
MitnCell_GetCellAsTradFunc(v1, &posix_cat, 2LL);
MitnDict_DefineOperator("pcat", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &posix_dir);
MitnDict_DefineOperator("pdir", v1[0]);
MitnCell_GetCellAsTradFunc(v1, &posix_dump, 1LL);
MitnDict_DefineOperator("pdump", v1[0]);
MitnCell_GetCellAsTradFunc(v1, &posix_exec_test, 1LL);
MitnDict_DefineOperator("pexec", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &posix_fork_test);
MitnDict_DefineOperator("pfork", v1[0]);
MitnCell_GetCellAsTradFunc(v1, &posix_mount, 2LL);
MitnDict_DefineOperator("pmount", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &posix_noaction);
MitnDict_DefineOperator("pnoaction", v1[0]);
MitnCell_GetCellAsTradFunc(v1, &posix, 1LL);
MitnDict_DefineOperator("posix", v1[0]);
MitnCell_GetCellAsTradFunc(v1, &posix_vm_dump, 1LL);
MitnDict_DefineOperator("pvmdump", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &p_open);
MitnDict_DefineOperator("posix-open", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &p_write);
MitnDict_DefineOperator("posix-write", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &p_close);
MitnDict_DefineOperator("posix-close", v1[0]);
MitnCell_GetCellAsTradFunc(v1, &posix_writefile, 2LL);
MitnDict_DefineOperator("pwrite", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &graphic_mode);
MitnDict_DefineOperator("graphic-mode", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &text_mode);
MitnDict_DefineOperator("text-mode", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &gsave);
MitnDict_DefineOperator("gsave", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &translate);
MitnDict_DefineOperator("translate", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &moveto);
MitnDict_DefineOperator("moveto", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &rmoveto);
MitnDict_DefineOperator("rmoveto", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &setcolor);
MitnDict_DefineOperator("setcolor", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &setmode);
MitnDict_DefineOperator("setmode", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &box);
MitnDict_DefineOperator("box", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &fillbox);
MitnDict_DefineOperator("fillbox", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &lineto);
MitnDict_DefineOperator("lineto", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &rlineto);
MitnDict_DefineOperator("rlineto", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &draw_window);
MitnDict_DefineOperator("draw-window", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &scroll);
MitnDict_DefineOperator("scroll", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &lowlib_stat);
MitnDict_DefineOperator("lowlib", v1[0]);
MitnCell_GetCellAsTradFunc(v1, &lowlib_load, 1LL);
MitnDict_DefineOperator("load", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &ide_stat);
MitnDict_DefineOperator("idestat", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &ide_geometric);
MitnDict_DefineOperator("idegeo", v1[0]);
MitnCell_GetCellAsTradFunc(v1, &ide_read, 1LL);
MitnDict_DefineOperator("ideread", v1[0]);
MitnCell_GetCellAsTradFunc(v1, &ether, 4095LL);
MitnDict_DefineOperator("ether", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &malloc_test);
MitnDict_DefineOperator("malloc", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &root_info);
MitnDict_DefineOperator("rootinfo", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &k106jp);
MitnDict_DefineOperator("k106jp", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &k101us);
MitnDict_DefineOperator("k101us", v1[0]);
MitnCell_GetCellAsMitnFunc(v1, &pmemdump);
return MitnDict_DefineOperator("pmemdump", v1[0]);
}

original_code:
void InitMittenHook(void)
{
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (pop)); MitnDict_DefineOperator(("pop"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (exch)); MitnDict_DefineOperator(("exch"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (dup)); MitnDict_DefineOperator(("dup"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (copy)); MitnDict_DefineOperator(("copy"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (roll)); MitnDict_DefineOperator(("roll"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (clear)); MitnDict_DefineOperator(("clear"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (count)); MitnDict_DefineOperator(("count"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (mark)); MitnDict_DefineOperator(("mark"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (cleartomark)); MitnDict_DefineOperator(("cleartomark"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (counttomark)); MitnDict_DefineOperator(("counttomark"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (MitnMath_Neg)); MitnDict_DefineOperator(("neg"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (MitnMath_Add)); MitnDict_DefineOperator(("add"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (MitnMath_Sub)); MitnDict_DefineOperator(("sub"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (MitnMath_Mul)); MitnDict_DefineOperator(("mul"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (MitnMath_Div)); MitnDict_DefineOperator(("idiv"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (help)); MitnDict_DefineOperator(("help"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (PopAndPrint)); MitnDict_DefineOperator(("=="), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (MitnStack_Status)); MitnDict_DefineOperator(("stack-status"), c); }
{ Cell *c; MitnCell_GetCellAsTradFunc(&c, (echo), 0xFFF & (1)); MitnDict_DefineOperator(("echo"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (MitnStack_GarbageCollect)); MitnDict_DefineOperator(("gc"), c); }
{ Cell *c; MitnCell_GetCellAsTradFunc(&c, (open_fd), 0xFFF & ((0xFFF))); MitnDict_DefineOperator(("openfd"), c); }
{ Cell *c; MitnCell_GetCellAsTradFunc(&c, (read_fd), 0xFFF & ((0xFFF))); MitnDict_DefineOperator(("readfd"), c); }
{ Cell *c; MitnCell_GetCellAsTradFunc(&c, (write_fd), 0xFFF & ((0xFFF))); MitnDict_DefineOperator(("writefd"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (reset)); MitnDict_DefineOperator(("reset"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (falldown)); MitnDict_DefineOperator(("falldown"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (vget_region)); MitnDict_DefineOperator(("vget"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (print_task_list)); MitnDict_DefineOperator(("task-list"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (pmemstat)); MitnDict_DefineOperator(("pmemstat"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (cexec)); MitnDict_DefineOperator(("cexec"), c); }
{ Cell *c; MitnCell_GetCellAsTradFunc(&c, (posix_cat), 0xFFF & (2)); MitnDict_DefineOperator(("pcat"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (posix_dir)); MitnDict_DefineOperator(("pdir"), c); }
{ Cell *c; MitnCell_GetCellAsTradFunc(&c, (posix_dump), 0xFFF & (1)); MitnDict_DefineOperator(("pdump"), c); }
{ Cell *c; MitnCell_GetCellAsTradFunc(&c, (posix_exec_test), 0xFFF & (1)); MitnDict_DefineOperator(("pexec"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (posix_fork_test)); MitnDict_DefineOperator(("pfork"), c); }
{ Cell *c; MitnCell_GetCellAsTradFunc(&c, (posix_mount), 0xFFF & (2)); MitnDict_DefineOperator(("pmount"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (posix_noaction)); MitnDict_DefineOperator(("pnoaction"), c); }
{ Cell *c; MitnCell_GetCellAsTradFunc(&c, (posix), 0xFFF & (1)); MitnDict_DefineOperator(("posix"), c); }
{ Cell *c; MitnCell_GetCellAsTradFunc(&c, (posix_vm_dump), 0xFFF & (1)); MitnDict_DefineOperator(("pvmdump"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (p_open)); MitnDict_DefineOperator(("posix-open"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (p_write)); MitnDict_DefineOperator(("posix-write"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (p_close)); MitnDict_DefineOperator(("posix-close"), c); }
{ Cell *c; MitnCell_GetCellAsTradFunc(&c, (posix_writefile), 0xFFF & (2)); MitnDict_DefineOperator(("pwrite"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (graphic_mode)); MitnDict_DefineOperator(("graphic-mode"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (text_mode)); MitnDict_DefineOperator(("text-mode"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (gsave)); MitnDict_DefineOperator(("gsave"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (translate)); MitnDict_DefineOperator(("translate"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (moveto)); MitnDict_DefineOperator(("moveto"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (rmoveto)); MitnDict_DefineOperator(("rmoveto"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (setcolor)); MitnDict_DefineOperator(("setcolor"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (setmode)); MitnDict_DefineOperator(("setmode"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (box)); MitnDict_DefineOperator(("box"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (fillbox)); MitnDict_DefineOperator(("fillbox"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (lineto)); MitnDict_DefineOperator(("lineto"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (rlineto)); MitnDict_DefineOperator(("rlineto"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (draw_window)); MitnDict_DefineOperator(("draw-window"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (scroll)); MitnDict_DefineOperator(("scroll"), c); };
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (lowlib_stat)); MitnDict_DefineOperator(("lowlib"), c); }
{ Cell *c; MitnCell_GetCellAsTradFunc(&c, (lowlib_load), 0xFFF & (1)); MitnDict_DefineOperator(("load"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (ide_stat)); MitnDict_DefineOperator(("idestat"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (ide_geometric)); MitnDict_DefineOperator(("idegeo"), c); }
{ Cell *c; MitnCell_GetCellAsTradFunc(&c, (ide_read), 0xFFF & (1)); MitnDict_DefineOperator(("ideread"), c); }
{ Cell *c; MitnCell_GetCellAsTradFunc(&c, (ether), 0xFFF & ((0xFFF))); MitnDict_DefineOperator(("ether"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (malloc_test)); MitnDict_DefineOperator(("malloc"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (root_info)); MitnDict_DefineOperator(("rootinfo"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (k106jp)); MitnDict_DefineOperator(("k106jp"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (k101us)); MitnDict_DefineOperator(("k101us"), c); }
{ Cell *c; MitnCell_GetCellAsMitnFunc(&c, (pmemdump)); MitnDict_DefineOperator(("pmemdump"), c); }
}

canonical_original_code:
void InitMittenHook()
{
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (pop)); MitnDict_DefineOperator(("pop"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (exch)); MitnDict_DefineOperator(("exch"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (dup)); MitnDict_DefineOperator(("dup"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (copy)); MitnDict_DefineOperator(("copy"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (roll)); MitnDict_DefineOperator(("roll"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (clear)); MitnDict_DefineOperator(("clear"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (count)); MitnDict_DefineOperator(("count"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (mark)); MitnDict_DefineOperator(("mark"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (cleartomark)); MitnDict_DefineOperator(("cleartomark"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (counttomark)); MitnDict_DefineOperator(("counttomark"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (MitnMath_Neg)); MitnDict_DefineOperator(("neg"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (MitnMath_Add)); MitnDict_DefineOperator(("add"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (MitnMath_Sub)); MitnDict_DefineOperator(("sub"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (MitnMath_Mul)); MitnDict_DefineOperator(("mul"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (MitnMath_Div)); MitnDict_DefineOperator(("idiv"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (help)); MitnDict_DefineOperator(("help"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (PopAndPrint)); MitnDict_DefineOperator(("=="), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (MitnStack_Status)); MitnDict_DefineOperator(("stack-status"), c); }
{ struct _cell *c; MitnCell_GetCellAsTradFunc(&c, (echo), 0xFFF & (1)); MitnDict_DefineOperator(("echo"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (MitnStack_GarbageCollect)); MitnDict_DefineOperator(("gc"), c); }
{ struct _cell *c; MitnCell_GetCellAsTradFunc(&c, (open_fd), 0xFFF & ((0xFFF))); MitnDict_DefineOperator(("openfd"), c); }
{ struct _cell *c; MitnCell_GetCellAsTradFunc(&c, (read_fd), 0xFFF & ((0xFFF))); MitnDict_DefineOperator(("readfd"), c); }
{ struct _cell *c; MitnCell_GetCellAsTradFunc(&c, (write_fd), 0xFFF & ((0xFFF))); MitnDict_DefineOperator(("writefd"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (reset)); MitnDict_DefineOperator(("reset"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (falldown)); MitnDict_DefineOperator(("falldown"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (vget_region)); MitnDict_DefineOperator(("vget"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (print_task_list)); MitnDict_DefineOperator(("task-list"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (pmemstat)); MitnDict_DefineOperator(("pmemstat"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (cexec)); MitnDict_DefineOperator(("cexec"), c); }
{ struct _cell *c; MitnCell_GetCellAsTradFunc(&c, (posix_cat), 0xFFF & (2)); MitnDict_DefineOperator(("pcat"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (posix_dir)); MitnDict_DefineOperator(("pdir"), c); }
{ struct _cell *c; MitnCell_GetCellAsTradFunc(&c, (posix_dump), 0xFFF & (1)); MitnDict_DefineOperator(("pdump"), c); }
{ struct _cell *c; MitnCell_GetCellAsTradFunc(&c, (posix_exec_test), 0xFFF & (1)); MitnDict_DefineOperator(("pexec"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (posix_fork_test)); MitnDict_DefineOperator(("pfork"), c); }
{ struct _cell *c; MitnCell_GetCellAsTradFunc(&c, (posix_mount), 0xFFF & (2)); MitnDict_DefineOperator(("pmount"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (posix_noaction)); MitnDict_DefineOperator(("pnoaction"), c); }
{ struct _cell *c; MitnCell_GetCellAsTradFunc(&c, (posix), 0xFFF & (1)); MitnDict_DefineOperator(("posix"), c); }
{ struct _cell *c; MitnCell_GetCellAsTradFunc(&c, (posix_vm_dump), 0xFFF & (1)); MitnDict_DefineOperator(("pvmdump"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (p_open)); MitnDict_DefineOperator(("posix-open"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (p_write)); MitnDict_DefineOperator(("posix-write"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (p_close)); MitnDict_DefineOperator(("posix-close"), c); }
{ struct _cell *c; MitnCell_GetCellAsTradFunc(&c, (posix_writefile), 0xFFF & (2)); MitnDict_DefineOperator(("pwrite"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (graphic_mode)); MitnDict_DefineOperator(("graphic-mode"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (text_mode)); MitnDict_DefineOperator(("text-mode"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (gsave)); MitnDict_DefineOperator(("gsave"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (translate)); MitnDict_DefineOperator(("translate"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (moveto)); MitnDict_DefineOperator(("moveto"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (rmoveto)); MitnDict_DefineOperator(("rmoveto"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (setcolor)); MitnDict_DefineOperator(("setcolor"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (setmode)); MitnDict_DefineOperator(("setmode"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (box)); MitnDict_DefineOperator(("box"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (fillbox)); MitnDict_DefineOperator(("fillbox"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (lineto)); MitnDict_DefineOperator(("lineto"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (rlineto)); MitnDict_DefineOperator(("rlineto"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (draw_window)); MitnDict_DefineOperator(("draw-window"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (scroll)); MitnDict_DefineOperator(("scroll"), c); };
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (lowlib_stat)); MitnDict_DefineOperator(("lowlib"), c); }
{ struct _cell *c; MitnCell_GetCellAsTradFunc(&c, (lowlib_load), 0xFFF & (1)); MitnDict_DefineOperator(("load"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (ide_stat)); MitnDict_DefineOperator(("idestat"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (ide_geometric)); MitnDict_DefineOperator(("idegeo"), c); }
{ struct _cell *c; MitnCell_GetCellAsTradFunc(&c, (ide_read), 0xFFF & (1)); MitnDict_DefineOperator(("ideread"), c); }
{ struct _cell *c; MitnCell_GetCellAsTradFunc(&c, (ether), 0xFFF & ((0xFFF))); MitnDict_DefineOperator(("ether"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (malloc_test)); MitnDict_DefineOperator(("malloc"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (root_info)); MitnDict_DefineOperator(("rootinfo"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (k106jp)); MitnDict_DefineOperator(("k106jp"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (k101us)); MitnDict_DefineOperator(("k101us"), c); }
{ struct _cell *c; MitnCell_GetCellAsMitnFunc(&c, (pmemdump)); MitnDict_DefineOperator(("pmemdump"), c); }
}

variable_types: struct _cell { char mark; unsigned long type; struct _cell *prev; struct _cell *next; union { long inum; double dnum; struct { char str[48]; long length; } string; struct { struct _cell *link; char str[48]; } name; int (*mitn_func)(); struct { long arg_num; int (*func)(int argc, char *argv[]); } trad; struct _cell *link; } value; } *


repo: monaka/B-Free

decompiled_code:
__int64 __fastcall psys_stat(__int64 *a1)
{
__int64 v2; // [rsp+0h] [rbp-C8h] BYREF
__int64 v3; // [rsp+18h] [rbp-B0h]
unsigned int v4; // [rsp+20h] [rbp-A8h]
char v5[32]; // [rsp+40h] [rbp-88h] BYREF
__int64 v6; // [rsp+60h] [rbp-68h]
__int64 v7; // [rsp+68h] [rbp-60h]

v6 = *a1;
v7 = a1[1];
if ( (unsigned int)make_connection(32LL, v5, &v2) || !v3 )
return v4;
MEMORY[0x7FFF0028] = v3;
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 *a1)
{
__int64 v2; // [rsp+0h] [rbp-C8h] BYREF
__int64 v3; // [rsp+18h] [rbp-B0h]
unsigned int v4; // [rsp+20h] [rbp-A8h]
char v5[32]; // [rsp+40h] [rbp-88h] BYREF
__int64 v6; // [rsp+60h] [rbp-68h]
__int64 v7; // [rsp+68h] [rbp-60h]

v6 = *a1;
v7 = a1[1];
if ( (unsigned int)make_connection(32LL, v5, &v2) || !v3 )
return v4;
MEMORY[0x7FFF0028] = v3;
return 0xFFFFFFFFLL;
}

original_code:
int
psys_stat (void *argp)
{
  struct a
    {
    } *args = (struct a *)argp;
  errno = 26;
  return ((0));
}

canonical_original_code:
int psys_stat(void *argp)
{
  struct a *args = (struct a *)argp;
  errno = 26;
  return ((0));
}

variable_types:
argp
void *

variable_types:
args
struct a {  } *

return_type: int


utime

decompiled_code:
__int64 __fastcall utime(const char *a1, __int64 a2)
{
unsigned int v2; // eax

v2 = strlen(a1);
return call_lowlib(37LL, v2, a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1, __int64 a2)
{
unsigned int v2; // eax

v2 = strlen(a1);
return call_lowlib(37LL, v2, a1, a2);
}

original_code:
int
utime (char *path, struct utimbuf *buf)
{
  return (call_lowlib (37, strlen (path), path, buf));
}

canonical_original_code:
int utime(char *path, struct utimbuf *buf)
{
  return (call_lowlib (37, strlen (path), path, buf));
}

variable_types:
path
char *

variable_types:
buf
struct utimbuf {  } *


getdents

decompiled_code:
__int64 __fastcall getdents(unsigned int a1, __int64 a2, unsigned int a3)
{
return call_lowlib(42LL, a1, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1, __int64 a2, unsigned int a3)
{
return call_lowlib(42LL, a1, a2, a3);
}

original_code:
int
getdents (unsigned int fd, struct dirent *dirp, unsigned int count)
{
  return (call_lowlib (42, fd, dirp, count));
}

canonical_original_code:
int getdents(unsigned int fd, struct dirent *dirp, unsigned int count)
{
  return (call_lowlib (42, fd, dirp, count));
}

variable_types:
fd
unsigned int

variable_types: struct dirent { long d_ino; unsigned long d_off; unsigned short d_reclen; char d_name[1]; } *

variable_types:
count
unsigned int


decompiled_code:
__int64 __fastcall psys_open(__int64 *a1)
{
__int64 v2; // [rsp+0h] [rbp-C8h] BYREF
__int64 v3; // [rsp+18h] [rbp-B0h]
unsigned int v4; // [rsp+20h] [rbp-A8h]
char v5[32]; // [rsp+40h] [rbp-88h] BYREF
__int64 v6; // [rsp+60h] [rbp-68h]
__int64 v7; // [rsp+68h] [rbp-60h]
__int64 v8; // [rsp+70h] [rbp-58h]
__int64 v9; // [rsp+78h] [rbp-50h]

v6 = *a1;
v7 = a1[1];
v8 = a1[2];
v9 = a1[3];
if ( (unsigned int)make_connection(23LL, v5, &v2) || !v3 )
return v4;
MEMORY[0x7FFF0028] = v3;
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 *a1)
{
__int64 v2; // [rsp+0h] [rbp-C8h] BYREF
__int64 v3; // [rsp+18h] [rbp-B0h]
unsigned int v4; // [rsp+20h] [rbp-A8h]
char v5[32]; // [rsp+40h] [rbp-88h] BYREF
__int64 v6; // [rsp+60h] [rbp-68h]
__int64 v7; // [rsp+68h] [rbp-60h]
__int64 v8; // [rsp+70h] [rbp-58h]
__int64 v9; // [rsp+78h] [rbp-50h]

v6 = *a1;
v7 = a1[1];
v8 = a1[2];
v9 = a1[3];
if ( (unsigned int)make_connection(23LL, v5, &v2) || !v3 )
return v4;
MEMORY[0x7FFF0028] = v3;
return 0xFFFFFFFFLL;
}

original_code:
int
psys_open (void *argp)
{
  struct a
    {
    } *args = (struct a *)argp;
  errno = 26;
  return ((0));
}

canonical_original_code:
int psys_open(void *argp)
{
  struct a *args = (struct a *)argp;
  errno = 26;
  return ((0));
}


getegid

decompiled_code:
__int64 getegid()
{
return call_lowlib(13LL);
}

canonical_decompiled_code:
__int64 func0()
{
return call_lowlib(13LL);
}

original_code:
int
getegid (void)
{
  return (call_lowlib (13));
}

canonical_original_code:
int getegid()
{
  return (call_lowlib (13));
}


decompiled_code:
__int64 psys_lseek()
{
errno = 26;
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
errno = 26;
return 0LL;
}

original_code:
off_t
psys_lseek (void *argp)
{
  struct a
    {
    } *args = (struct a *)argp;
  errno = 26;
  return ((0));
}

canonical_original_code:
unsigned long long psys_lseek(void *argp)
{
  struct a *args = (struct a *)argp;
  errno = 26;
  return ((0));
}

return_type: unsigned long long


decompiled_code:
__int64 psys_sigpending()
{
errno = 26;
return 0LL;
}

original_code:
int
psys_sigpending (void *argp)
{
  struct a
    {
    } *args = (struct a *)argp;
  errno = 26;
  return ((0));
}

canonical_original_code:
int psys_sigpending(void *argp)
{
  struct a *args = (struct a *)argp;
  errno = 26;
  return ((0));
}


decompiled_code:
__int64 psys_creat()
{
errno = 26;
return 0LL;
}

original_code:
int
psys_creat (void *argp)
{
  struct a
    {
    } *args = (struct a *)argp;
  errno = 26;
  return ((0));
}

canonical_original_code:
int psys_creat(void *argp)
{
  struct a *args = (struct a *)argp;
  errno = 26;
  return ((0));
}


sigfillset

decompiled_code:
void sigfillset()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
int
sigfillset (sigset_t *set)
{
  return (call_lowlib (61, set));
}

canonical_original_code:
int sigfillset(int *set)
{
  return (call_lowlib (61, set));
}

variable_types:
set
int *


setsid

decompiled_code:
void setsid()
{
;
}

original_code:
int
setsid (void)
{
  return (call_lowlib (30));
}

canonical_original_code:
int setsid()
{
  return (call_lowlib (30));
}


uname

decompiled_code:
__int64 __fastcall uname(const char *a1)
{
unsigned int v1; // eax

v1 = strlen(a1);
return call_lowlib(80LL, v1, a1);
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1)
{
unsigned int v1; // eax

v1 = strlen(a1);
return call_lowlib(80LL, v1, a1);
}

original_code:
int
uname (char *buf)
{
  return (call_lowlib (80, strlen (buf), buf));
}

canonical_original_code:
int uname(char *buf)
{
  return (call_lowlib (80, strlen (buf), buf));
}

variable_types:
buf
char *


decompiled_code:
__int64 __fastcall internal_echo(int a1, __int64 a2)
{
_QWORD *v2; // rbx

if ( a1 <= 1 )
return 0LL;
v2 = (_QWORD *)(a2 + 8);
do
sh_printf(&unk_F1, *v2++);
while ( v2 != (_QWORD *)(a2 + 8LL * (unsigned int)(a1 - 2) + 16) );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, __int64 a2)
{
_QWORD *v2; // rbx

if ( a1 <= 1 )
return 0LL;
v2 = (_QWORD *)(a2 + 8);
do
sh_printf(&unk_F1, *v2++);
while ( v2 != (_QWORD *)(a2 + 8LL * (unsigned int)(a1 - 2) + 16) );
return 0LL;
}

original_code:
int
internal_echo (int ac, char **av)
{
  int i;
  for (i = 1; i < ac; i++)
    {
      sh_printf ("%s\n", av[i]);
    }
  return (0);
}

canonical_original_code:
int internal_echo(int ac, char **av)
{
  int i;
  for (i = 1; i < ac; i++)
    {
      sh_printf ("%s\n", av[i]);
    }
  return (0);
}

variable_types: ac int

variable_types:
av
char **

variable_types: i int


mountroot

decompiled_code:
__int64 __fastcall mountroot(unsigned int a1)
{
unsigned int v1; // ebx

printf("mountroot: begin.");
v1 = call_lowlib(45LL, a1);
printf("mountroot: end.");
return v1;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1)
{
unsigned int v1; // ebx

printf("mountroot: begin.");
v1 = call_lowlib(45LL, a1);
printf("mountroot: end.");
return v1;
}

original_code:
int
mountroot (int devnum)
{
  int result;
  printf("mountroot: begin.");
  result = call_lowlib (45, devnum);
  printf("mountroot: end.");
  return (result);
}

canonical_original_code:
int mountroot(int devnum)
{
  int result;
  printf("mountroot: begin.");
  result = call_lowlib (45, devnum);
  printf("mountroot: end.");
  return (result);
}

variable_types: devnum int

variable_types: result int


execve

decompiled_code:
__int64 __fastcall execve(__int64 a1, __int64 a2, __int64 a3)
{
return call_lowlib(8LL, a1, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, __int64 a3)
{
return call_lowlib(8LL, a1, a2, a3);
}

original_code:
int
execve(char *name, char (*argv)[], char (*envp)[])
{
  return(call_lowlib(8, name, argv, envp));
}

variable_types:
name
char *

variable_types:
argv
char (*)[]

variable_types:
envp
char (*)[]


decompiled_code:
__int64 psys_getegid()
{
__int64 v1; // [rsp+0h] [rbp-C8h] BYREF
__int64 v2; // [rsp+18h] [rbp-B0h]
unsigned int v3; // [rsp+20h] [rbp-A8h]
char v4[136]; // [rsp+40h] [rbp-88h] BYREF

if ( (unsigned int)make_connection(13LL, v4, &v1) || !v2 )
return v3;
MEMORY[0x7FFF0028] = v2;
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 func0()
{
__int64 v1; // [rsp+0h] [rbp-C8h] BYREF
__int64 v2; // [rsp+18h] [rbp-B0h]
unsigned int v3; // [rsp+20h] [rbp-A8h]
char v4[136]; // [rsp+40h] [rbp-88h] BYREF

if ( (unsigned int)make_connection(13LL, v4, &v1) || !v2 )
return v3;
MEMORY[0x7FFF0028] = v2;
return 0xFFFFFFFFLL;
}

original_code:
gid_t
psys_getegid (void *argp)
{
  struct a
    {
    } *args = (struct a *)argp;
  errno = 26;
  return ((0));
}

canonical_original_code:
unsigned short psys_getegid(void *argp)
{
  struct a *args = (struct a *)argp;
  errno = 26;
  return ((0));
}

variable_types:
argp
void *

return_type: unsigned short


sigaddset

decompiled_code:
__int64 __fastcall sigaddset(__int64 a1, unsigned int a2)
{
return call_lowlib(58LL, a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, unsigned int a2)
{
return call_lowlib(58LL, a1, a2);
}

original_code:
int
sigaddset (sigset_t *set, int signo)
{
  return (call_lowlib (58, set, signo));
}

canonical_original_code:
int sigaddset(int *set, int signo)
{
  return (call_lowlib (58, set, signo));
}

variable_types: signo int


setuid

decompiled_code:
void setuid()
{
;
}

original_code:
int
setuid (int uid)
{
  return (call_lowlib (31, uid));
}

canonical_original_code:
int setuid(int uid)
{
  return (call_lowlib (31, uid));
}

variable_types: uid int


sigsuspend

decompiled_code:
__int64 sigsuspend()
{
return call_lowlib(57LL);
}

canonical_decompiled_code:
__int64 func0()
{
return call_lowlib(57LL);
}

original_code:
int
sigsuspend (void)
{
  return (call_lowlib (57));
}

canonical_original_code:
int sigsuspend()
{
  return (call_lowlib (57));
}


decompiled_code:
__int64 __fastcall read_key(__int64 a1)
{
__int64 *i; // rbx
__int64 v2; // rbp
char v4[28]; // [rsp+Ch] [rbp-1Ch] BYREF

if ( a1 == 1 )
{
i = (__int64 *)current;
v2 = 0LL;
if ( !current )
return v2;
}
else
{
for ( i = (__int64 *)current; !current; i = (__int64 *)current )
wai_flg(v4, waitflag, 1LL, 2LL);
}
v2 = i[1];
if ( (__int64 *)*(&current + 1) == i )
{
*(&current + 1) = 0LL;
current = 0LL;
clr_flg(waitflag, 0LL);
}
else
{
current = *i;
}
*i = freelist;
freelist = (__int64)i;
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
__int64 *i; // rbx
__int64 v2; // rbp
char v4[28]; // [rsp+Ch] [rbp-1Ch] BYREF

if ( a1 == 1 )
{
i = (__int64 *)current;
v2 = 0LL;
if ( !current )
return v2;
}
else
{
for ( i = (__int64 *)current; !current; i = (__int64 *)current )
wai_flg(v4, waitflag, 1LL, 2LL);
}
v2 = i[1];
if ( (__int64 *)*(&current + 1) == i )
{
*(&current + 1) = 0LL;
current = 0LL;
clr_flg(waitflag, 0LL);
}
else
{
current = *i;
}
*i = freelist;
freelist = (__int64)i;
return v2;
}

original_code:
W
read_key (W mode)
{
  W retval;
  struct key_entry *p;
  UINT rflag;
  if ((mode == 0x0001) && (current.first == (0)))
    {
      return ((0));
    }
retry:
  if (current.first)
    {
      retval = current.first->key;
      p = current.first;
      if (current.first == current.last)
 {
   current.first = current.last = (0);
   clr_flg (waitflag, 0);
 }
      else
 {
   current.first = current.first->next;
 }
      p->next = freelist;
      freelist = p;
      return (retval);
    }
  wai_flg (&rflag, waitflag, 1, (0x00000002));
  goto retry;
}

canonical_original_code:
long read_key(long mode)
{
  long retval;
  struct key_entry *p;
  unsigned int rflag;
  if ((mode == 0x0001) && (current.first == (0)))
    {
      return ((0));
    }
retry:
  if (current.first)
    {
      retval = current.first->key;
      p = current.first;
      if (current.first == current.last)
 {
   current.first = current.last = (0);
   clr_flg (waitflag, 0);
 }
      else
 {
   current.first = current.first->next;
 }
      p->next = freelist;
      freelist = p;
      return (retval);
    }
  wai_flg (&rflag, waitflag, 1, (0x00000002));
  goto retry;
}

variable_types: mode long

variable_types: retval long

variable_types: struct key_entry { struct key_entry *next; long key; } *

variable_types:
rflag
unsigned int

return_type: long


decompiled_code:
__int64 __fastcall allocate_trad_cmdline(char *a1, const char *a2, int a3, char **a4)
{
char *v6; // r13
__int64 v7; // r12
unsigned int v8; // ebp
int v9; // ebx
char *v10; // rax
__int64 v12; // [rsp+8h] [rbp-60h] BYREF
char s[88]; // [rsp+10h] [rbp-58h] BYREF

*a4 = a1;
strcpy(a1, a2);
v6 = &a1[strlen(a2) + 1];
LODWORD(v7) = a3 - 1;
if ( (int)v7 <= 0 )
return 0;
v7 = (int)v7;
do
{
v8 = MitnStack_Pop(1LL, &v12);
if ( v8 )
break;
v8 = MitnCell_ToString(s, v12, 48LL);
if ( v8 )
break;
a4[v7] = v6;
v9 = strlen(s);
strcpy(v6, s);
v10 = &v6[v9];
v6 = v10 + 1;
*v10 = 0;
--v7;
}
while ( (int)v7 > 0 );
return v8;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *a1, const char *a2, int a3, char **a4)
{
char *v6; // r13
__int64 v7; // r12
unsigned int v8; // ebp
int v9; // ebx
char *v10; // rax
__int64 v12; // [rsp+8h] [rbp-60h] BYREF
char s[88]; // [rsp+10h] [rbp-58h] BYREF

*a4 = a1;
strcpy(a1, a2);
v6 = &a1[strlen(a2) + 1];
LODWORD(v7) = a3 - 1;
if ( (int)v7 <= 0 )
return 0;
v7 = (int)v7;
do
{
v8 = MitnStack_Pop(1LL, &v12);
if ( v8 )
break;
v8 = MitnCell_ToString(s, v12, 48LL);
if ( v8 )
break;
a4[v7] = v6;
v9 = strlen(s);
strcpy(v6, s);
v10 = &v6[v9];
v6 = v10 + 1;
*v10 = 0;
--v7;
}
while ( (int)v7 > 0 );
return v8;
}

original_code:
ER
allocate_trad_cmdline(B *line, B *cmd, W ac, B **av)
{
  int i;
  B* pos;
  ER result;
  av[0] = line;
  strcpy(line, cmd);
  pos = line + strlen(cmd) + 1;
  for(i = ac - 1; i > 0; i--)
    {
      Cell *c;
      B str[48];
      int len;
      result = MitnStack_Pop(1, &c);
      if (result != (0))
 {
   return result;
 }
      result = MitnCell_ToString(str, c, sizeof(str));
      if (result != (0))
 {
   return result;
 }
      av[i] = pos;
      len = strlen(str);
      strcpy(pos, str);
      pos += len;
      *(pos++) = '\0';
    }
  return (0);
}

canonical_original_code:
int allocate_trad_cmdline(char *line, char *cmd, long ac, char **av)
{
  int i;
  char *pos;
  int result;
  av[0] = line;
  strcpy(line, cmd);
  pos = line + strlen(cmd) + 1;
  for(i = ac - 1; i > 0; i--)
    {
      struct _cell *c;
      char str[48];
      int len;
      result = MitnStack_Pop(1, &c);
      if (result != (0))
 {
   return result;
 }
      result = MitnCell_ToString(str, c, sizeof(str));
      if (result != (0))
 {
   return result;
 }
      av[i] = pos;
      len = strlen(str);
      strcpy(pos, str);
      pos += len;
      *(pos++) = '\0';
    }
  return (0);
}

variable_types:
line
char *

variable_types:
cmd
char *

variable_types: ac long

variable_types:
pos
char *

variable_types: struct _cell { char mark; unsigned long type; struct _cell *prev; struct _cell *next; union { long inum; double dnum; struct { char str[48]; long length; } string; struct { struct _cell *link; char str[48]; } name; int (*mitn_func)(); struct { long arg_num; int (*func)(int argc, char *argv[]); } trad; struct _cell *link; } value; } *

variable_types:
str
char [48]

variable_types: len int


decompiled_code:
__int64 psys_kill()
{
errno = 26;
return 0LL;
}

original_code:
int
psys_kill (void *argp)
{
  struct a
    {
    } *args = (struct a *)argp;
  errno = 26;
  return ((0));
}

canonical_original_code:
int psys_kill(void *argp)
{
  struct a *args = (struct a *)argp;
  errno = 26;
  return ((0));
}

variable_types:
args
struct a {  } *


decompiled_code:
__int64 psys_sigsuspend()
{
errno = 26;
return 0LL;
}

original_code:
int
psys_sigsuspend (void *argp)
{
  struct a
    {
    } *args = (struct a *)argp;
  errno = 26;
  return ((0));
}

canonical_original_code:
int psys_sigsuspend(void *argp)
{
  struct a *args = (struct a *)argp;
  errno = 26;
  return ((0));
}


decompiled_code:
__int64 psys_sigfillset()
{
errno = 26;
return 0LL;
}

original_code:
int
psys_sigfillset (void *argp)
{
  struct a
    {
    } *args = (struct a *)argp;
  errno = 26;
  return ((0));
}

canonical_original_code:
int psys_sigfillset(void *argp)
{
  struct a *args = (struct a *)argp;
  errno = 26;
  return ((0));
}


decompiled_code:
void psys_rewinddir()
{
errno = 26;
}

canonical_decompiled_code:
void func0()
{
errno = 26;
}

original_code:
void
psys_rewinddir (void *argp)
{
  struct a
    {
    } *args = (struct a *)argp;
  errno = 26;
}

canonical_original_code:
void psys_rewinddir(void *argp)
{
  struct a *args = (struct a *)argp;
  errno = 26;
}

return_type: void


decompiled_code:
__int64 psys_utime()
{
errno = 26;
return 0LL;
}

original_code:
int
psys_utime (void *argp)
{
  struct a
    {
    } *args = (struct a *)argp;
  errno = 26;
  return ((0));
}

canonical_original_code:
int psys_utime(void *argp)
{
  struct a *args = (struct a *)argp;
  errno = 26;
  return ((0));
}


decompiled_code:
__int64 __fastcall psys_ttyname(__int64 *a1)
{
__int64 v2; // [rsp+0h] [rbp-C8h] BYREF
__int64 v3; // [rsp+18h] [rbp-B0h]
unsigned int v4; // [rsp+20h] [rbp-A8h]
char v5[32]; // [rsp+40h] [rbp-88h] BYREF
__int64 v6; // [rsp+60h] [rbp-68h]
__int64 v7; // [rsp+68h] [rbp-60h]

v6 = *a1;
v7 = a1[1];
if ( (unsigned int)make_connection(78LL, v5, &v2) || !v3 )
return v4;
MEMORY[0x7FFF0028] = v3;
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 *a1)
{
__int64 v2; // [rsp+0h] [rbp-C8h] BYREF
__int64 v3; // [rsp+18h] [rbp-B0h]
unsigned int v4; // [rsp+20h] [rbp-A8h]
char v5[32]; // [rsp+40h] [rbp-88h] BYREF
__int64 v6; // [rsp+60h] [rbp-68h]
__int64 v7; // [rsp+68h] [rbp-60h]

v6 = *a1;
v7 = a1[1];
if ( (unsigned int)make_connection(78LL, v5, &v2) || !v3 )
return v4;
MEMORY[0x7FFF0028] = v3;
return 0xFFFFFFFFLL;
}

original_code:
char *
psys_ttyname (void *argp)
{
  struct a
    {
    } *args = (struct a *)argp;
  errno = 26;
  return ((0));
}

canonical_original_code:
char *psys_ttyname(void *argp)
{
  struct a *args = (struct a *)argp;
  errno = 26;
  return ((0));
}

return_type: char *


decompiled_code:
__int64 psys_fseek()
{
errno = 26;
return 0LL;
}

original_code:
int
psys_fseek (void *argp)
{
  struct a
    {
    } *args = (struct a *)argp;
  errno = 26;
  return ((0));
}

canonical_original_code:
int psys_fseek(void *argp)
{
  struct a *args = (struct a *)argp;
  errno = 26;
  return ((0));
}


decompiled_code:
__int64 __fastcall psys_sleep(__int64 *a1)
{
__int64 v2; // [rsp+0h] [rbp-C8h] BYREF
__int64 v3; // [rsp+18h] [rbp-B0h]
unsigned int v4; // [rsp+20h] [rbp-A8h]
char v5[32]; // [rsp+40h] [rbp-88h] BYREF
__int64 v6; // [rsp+60h] [rbp-68h]

v6 = *a1;
if ( (unsigned int)make_connection(77LL, v5, &v2) || !v3 )
return v4;
MEMORY[0x7FFF0028] = v3;
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 *a1)
{
__int64 v2; // [rsp+0h] [rbp-C8h] BYREF
__int64 v3; // [rsp+18h] [rbp-B0h]
unsigned int v4; // [rsp+20h] [rbp-A8h]
char v5[32]; // [rsp+40h] [rbp-88h] BYREF
__int64 v6; // [rsp+60h] [rbp-68h]

v6 = *a1;
if ( (unsigned int)make_connection(77LL, v5, &v2) || !v3 )
return v4;
MEMORY[0x7FFF0028] = v3;
return 0xFFFFFFFFLL;
}

original_code:
unsigned int
psys_sleep (void *argp)
{
  struct a
    {
      int second;
    } *args = (struct a *)argp;
  errno = 26;
  return ((0));
}

canonical_original_code:
unsigned int psys_sleep(void *argp)
{
  struct a *args = (struct a *)argp;
  errno = 26;
  return ((0));
}

variable_types:
args
struct a { int second; } *

return_type: unsigned int


kill

decompiled_code:
__int64 __fastcall kill(unsigned int a1)
{
return call_lowlib(51LL, a1);
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1)
{
return call_lowlib(51LL, a1);
}

original_code:
int
kill (int pid)
{
  return (call_lowlib (51, pid));
}

canonical_original_code:
int kill(int pid)
{
  return (call_lowlib (51, pid));
}

variable_types: pid int


decompiled_code:
__int64 psys_time()
{
errno = 26;
return 0LL;
}

original_code:
time_t
psys_time (void *argp)
{
  struct a
    {
    } *args = (struct a *)argp;
  errno = 26;
  return ((0));
}

canonical_original_code:
unsigned long psys_time(void *argp)
{
  struct a *args = (struct a *)argp;
  errno = 26;
  return ((0));
}

variable_types:
argp
void *

return_type: unsigned long


fork

decompiled_code:
void fork()
{
;
}

original_code:
W
fork (struct proc *parent, W *childid, ID main_task, ID signal_task)
{
  struct proc *newproc;
  W errno;
  struct lowlib_data lowlib_data;
  errno = proc_alloc_proc (&newproc);
  if (errno)
    {
      return (errno);
    }
  *childid = newproc->proc_pid;
  newproc->proc_maintask = main_task;
  newproc->proc_signal_handler = signal_task;
  errno = proc_duplicate (parent, newproc);
  if (errno)
    {
      destroy_proc_memory (newproc, 0);
      return (errno);
    }
  newproc->proc_status = PS_RUN;
  newproc->proc_ppid = parent->proc_pid;
  lod_low(main_task, "lowlib.posix");
  errno = vget_reg (main_task, ((struct lowlib_data *)(0x7fff0000)),
      sizeof (struct lowlib_data), &lowlib_data);
  lowlib_data.main_task = main_task;
  lowlib_data.my_pid = *childid;
  errno = vput_reg (main_task, ((struct lowlib_data *)(0x7fff0000)),
      sizeof (struct lowlib_data), &lowlib_data);
  return ((0));
}

canonical_original_code:
long fork(struct proc *parent, long *childid, int main_task, int signal_task)
{
  struct proc *newproc;
  long errno;
  struct lowlib_data lowlib_data;
  errno = proc_alloc_proc (&newproc);
  if (errno)
    {
      return (errno);
    }
  *childid = newproc->proc_pid;
  newproc->proc_maintask = main_task;
  newproc->proc_signal_handler = signal_task;
  errno = proc_duplicate (parent, newproc);
  if (errno)
    {
      destroy_proc_memory (newproc, 0);
      return (errno);
    }
  newproc->proc_status = PS_RUN;
  newproc->proc_ppid = parent->proc_pid;
  lod_low(main_task, "lowlib.posix");
  errno = vget_reg (main_task, ((struct lowlib_data *)(0x7fff0000)),
      sizeof (struct lowlib_data), &lowlib_data);
  lowlib_data.main_task = main_task;
  lowlib_data.my_pid = *childid;
  errno = vput_reg (main_task, ((struct lowlib_data *)(0x7fff0000)),
      sizeof (struct lowlib_data), &lowlib_data);
  return ((0));
}

variable_types: struct proc { struct proc *proc_next; enum proc_status { PS_DORMANT=0, PS_SLEEP=1, PS_WAIT=2, PS_RUN=3, PS_ZOMBIE=4 } proc_status; int proc_maintask; int proc_signal_handler; long proc_uid; long proc_gid; long proc_euid; long proc_egid; long proc_umask; struct inode { struct inode *i_prev; struct inode *i_next; struct fs { struct fs *fs_prev; struct fs *fs_next; long fs_magicid; long fs_typeid; long fs_refcount; long fs_rflag; struct fsops { long (*fs_mount)(); long (*fs_mountroot)(); long (*fs_umount)(); long (*fs_statfs)(); long (*fs_syncfs)(); long (*fs_read_inode)(); long (*fs_write_inode)(); long (*fs_read_super)(); long (*fs_write_super)(); long (*fs_get_inode)(); long (*fs_put_inode)(); } *fs_ops; long fs_lock; unsigned long fs_device; struct inode *fs_ilist; long fs_blksize; struct inode *rootdir; long fs_allblock; long fs_freeblock; long fs_usedblock; long fs_allinode; long fs_freeinode; long fs_usedinode; unsigned long fs_isearch; unsigned long fs_bsearch; union { struct sfs_superblock { unsigned long sfs_magic; short sfs_version_hi; short sfs_version_lo; unsigned long sfs_mountcount; short sfs_blocksize; unsigned long sfs_nblock; unsigned long sfs_freeblock; unsigned long sfs_bitmapsize; unsigned long sfs_ninode; unsigned long sfs_freeinode; unsigned long sfs_isearch; unsigned long sfs_bsearch; unsigned long sfs_datablock; } sfs_fs; } fs_private; } *i_fs; unsigned long i_device; unsigned long i_lock; struct iops { long (*i_lookup)(); long (*i_create)(); long (*i_close)(); long (*i_read)(); long (*i_write)(); long (*i_stat)(); long (*i_truncate)(); long (*i_link)(); long (*i_unlink)(); long (*i_symlink)(); long (*i_chmod)(); long (*i_chown)(); long (*i_chgrp)(); long (*i_rename)(); long (*i_sync)(); long (*i_mkdir)(); long (*i_rmdir)(); long (*i_getdents)(); } *i_ops; long i_refcount; long i_dirty; struct inode *coverfile; unsigned long i_mode; unsigned long i_link; unsigned long i_index; unsigned long i_uid; unsigned long i_gid; unsigned long i_dev; unsigned long i_size; unsigned long i_atime; unsigned long i_ctime; unsigned long i_mtime; unsigned long i_size_blk; union { struct sfs_inode { unsigned long sfs_i_index; unsigned long sfs_i_nlink; unsigned long sfs_i_size; unsigned long sfs_i_size_blk; unsigned long sfs_i_perm; unsigned long sfs_i_uid; unsigned long sfs_i_gid; unsigned long sfs_i_dev; unsigned long sfs_i_atime; unsigned long sfs_i_ctime; unsigned long sfs_i_mtime; unsigned long sfs_i_direct[70]; unsigned long sfs_i_indirect[20]; unsigned long sfs_i_dindirect[26]; unsigned long sfs_i_tindirect[1]; } sfs_inode; } i_private; } *proc_workdir; struct file { struct proc *f_procp; struct inode *f_inode; long f_flag; long f_offset; long f_omode; } proc_open_file[100]; unsigned long proc_pid; unsigned long proc_ppid; unsigned long proc_pgid; unsigned long proc_wpid; unsigned long proc_exst; unsigned long proc_rvpt; struct vm_tree { unsigned long access; unsigned long start; unsigned long size; void (*vm_handler)(); struct vm_directory { unsigned long access; struct vm_tree *tree_top; unsigned long start; unsigned long size; struct vm_page { unsigned long access; struct vm_directory *directory; unsigned long addr; struct inode *swap_file; long swap_page; } *page_table[1024]; } *directory_table[1024]; } *vm_tree; unsigned long text_start_addr; unsigned long text_length; unsigned long data_start_addr; unsigned long data_length; unsigned long bss_start_addr; unsigned long bss_length; } *

variable_types:
childid
long *

variable_types: errno long

variable_types: struct lowlib_data { int recv_port; int my_pid; int main_task; int signal_task; int fifo_task; int alarm_task; void (*start_func)(); int efile; long errno; }

user_defined_types: struct proc { struct proc *proc_next; enum proc_status proc_status; int proc_maintask; int proc_signal_handler; long proc_uid; long proc_gid; long proc_euid; long proc_egid; long proc_umask; struct inode *proc_workdir; struct file proc_open_file[100]; unsigned long proc_pid; unsigned long proc_ppid; unsigned long proc_pgid; unsigned long proc_wpid; unsigned long proc_exst; unsigned long proc_rvpt; struct vm_tree *vm_tree; unsigned long text_start_addr; unsigned long text_length; unsigned long data_start_addr; unsigned long data_length; unsigned long bss_start_addr; unsigned long bss_length; }

user_defined_types: struct inode { struct inode *i_prev; struct inode *i_next; struct fs *i_fs; unsigned long i_device; unsigned long i_lock; struct iops *i_ops; long i_refcount; long i_dirty; struct inode *coverfile; unsigned long i_mode; unsigned long i_link; unsigned long i_index; unsigned long i_uid; unsigned long i_gid; unsigned long i_dev; unsigned long i_size; unsigned long i_atime; unsigned long i_ctime; unsigned long i_mtime; unsigned long i_size_blk; union { struct sfs_inode sfs_inode; } i_private; }

user_defined_types: struct vm_tree { unsigned long access; unsigned long start; unsigned long size; void (*vm_handler)(); struct vm_directory *directory_table[1024]; }

user_defined_types: struct fs { struct fs *fs_prev; struct fs *fs_next; long fs_magicid; long fs_typeid; long fs_refcount; long fs_rflag; struct fsops *fs_ops; long fs_lock; unsigned long fs_device; struct inode *fs_ilist; long fs_blksize; struct inode *rootdir; long fs_allblock; long fs_freeblock; long fs_usedblock; long fs_allinode; long fs_freeinode; long fs_usedinode; unsigned long fs_isearch; unsigned long fs_bsearch; union { struct sfs_superblock sfs_fs; } fs_private; }

user_defined_types: struct vm_directory { unsigned long access; struct vm_tree *tree_top; unsigned long start; unsigned long size; struct vm_page *page_table[1024]; }


InitFileTable

decompiled_code:
int *InitFileTable()
{
int *result; // rax

result = &_file_table__;
do
{
*result = -1;
*((_QWORD *)result + 1) = 0LL;
*((_QWORD *)result + 2) = 0LL;
*((_QWORD *)result + 3) = 1024LL;
result += 264;
}
while ( result != (int *)(unsigned int)((_DWORD)&_file_table__ + 10560) );
return result;
}

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

result = &_file_table__;
do
{
*result = -1;
*((_QWORD *)result + 1) = 0LL;
*((_QWORD *)result + 2) = 0LL;
*((_QWORD *)result + 3) = 1024LL;
result += 264;
}
while ( result != (int *)(unsigned int)((_DWORD)&_file_table__ + 10560) );
return result;
}

original_code:
static void
InitFileTable(void)
{
  int i;
  for(i = 0; i < 10; i++)
    {
      __file_table__[i].device = -1;
      __file_table__[i].count = 0;
      __file_table__[i].length = 0;
      __file_table__[i].bufsize = 1024;
    }
}

canonical_original_code:
static void InitFileTable()
{
  int i;
  for(i = 0; i < 10; i++)
    {
      __file_table__[i].device = -1;
      __file_table__[i].count = 0;
      __file_table__[i].length = 0;
      __file_table__[i].bufsize = 1024;
    }
}

variable_types: i int


fork

decompiled_code:
__pid_t fork(void)
{
unsigned int v0; // edi
unsigned int v1; // esi

return call_lowlib(11LL, v0, v1);
}

canonical_decompiled_code:
__pid_t func0(void)
{
unsigned int v0; // edi
unsigned int v1; // esi

return call_lowlib(11LL, v0, v1);
}

user_defined_types: struct lowlib_data { int recv_port; int my_pid; int main_task; int signal_task; int fifo_task; int alarm_task; void (*start_func)(); int efile; long errno; }

user_defined_types: enum proc_status { PS_DORMANT=0, PS_SLEEP=1, PS_WAIT=2, PS_RUN=3, PS_ZOMBIE=4 }

user_defined_types: struct file { struct proc *f_procp; struct inode *f_inode; long f_flag; long f_offset; long f_omode; }

user_defined_types: struct iops { long (*i_lookup)(); long (*i_create)(); long (*i_close)(); long (*i_read)(); long (*i_write)(); long (*i_stat)(); long (*i_truncate)(); long (*i_link)(); long (*i_unlink)(); long (*i_symlink)(); long (*i_chmod)(); long (*i_chown)(); long (*i_chgrp)(); long (*i_rename)(); long (*i_sync)(); long (*i_mkdir)(); long (*i_rmdir)(); long (*i_getdents)(); }

user_defined_types: struct sfs_inode { unsigned long sfs_i_index; unsigned long sfs_i_nlink; unsigned long sfs_i_size; unsigned long sfs_i_size_blk; unsigned long sfs_i_perm; unsigned long sfs_i_uid; unsigned long sfs_i_gid; unsigned long sfs_i_dev; unsigned long sfs_i_atime; unsigned long sfs_i_ctime; unsigned long sfs_i_mtime; unsigned long sfs_i_direct[70]; unsigned long sfs_i_indirect[20]; unsigned long sfs_i_dindirect[26]; unsigned long sfs_i_tindirect[1]; }

user_defined_types: struct fsops { long (*fs_mount)(); long (*fs_mountroot)(); long (*fs_umount)(); long (*fs_statfs)(); long (*fs_syncfs)(); long (*fs_read_inode)(); long (*fs_write_inode)(); long (*fs_read_super)(); long (*fs_write_super)(); long (*fs_get_inode)(); long (*fs_put_inode)(); }

user_defined_types: struct sfs_superblock { unsigned long sfs_magic; short sfs_version_hi; short sfs_version_lo; unsigned long sfs_mountcount; short sfs_blocksize; unsigned long sfs_nblock; unsigned long sfs_freeblock; unsigned long sfs_bitmapsize; unsigned long sfs_ninode; unsigned long sfs_freeinode; unsigned long sfs_isearch; unsigned long sfs_bsearch; unsigned long sfs_datablock; }

user_defined_types: struct vm_page { unsigned long access; struct vm_directory *directory; unsigned long addr; struct inode *swap_file; long swap_page; }


sigaction

decompiled_code:
void sigaction()
{
;
}

original_code:
int
sigaction (int signo, struct sigaction *action, struct sigaction *oldaction)
{
  return (call_lowlib (53, signo, action, oldaction));
}

canonical_original_code:
int sigaction(int signo, struct sigaction *action, struct sigaction *oldaction)
{
  return (call_lowlib (53, signo, action, oldaction));
}

variable_types: signo int

variable_types:
action
struct sigaction {  } *

variable_types:
oldaction
struct sigaction *


repo: mondaugen/libcm

original_code:
void
cm_ftn_free_tree(FormTreeNode *parent)
{
    if( parent != ((void *)0)){
 if( parent->num_children > 0 ){
     int i = 0;
     for(i = 0; i < parent->num_children; i++)
  cm_ftn_free_tree((parent->children)[i]);
 }
 free(parent);
    }
}

canonical_original_code:
void cm_ftn_free_tree(struct __ftreenode *parent)
{
    if( parent != ((void *)0)){
 if( parent->num_children > 0 ){
     int i = 0;
     for(i = 0; i < parent->num_children; i++)
  cm_ftn_free_tree((parent->children)[i]);
 }
 free(parent);
    }
}

variable_types: struct __ftreenode { char val; struct __ftreenode *parent; struct __ftreenode **children; int num_children; } *


decompiled_code:
__int64 __fastcall cm_ftn_dflt_node_namer(int a1)
{
return (unsigned int)(a1 + 97);
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
return (unsigned int)(a1 + 97);
}

original_code:
char
cm_ftn_dflt_node_namer( int i )
{
    return 'a' + i;
}

canonical_original_code:
char cm_ftn_dflt_node_namer(int i)
{
    return 'a' + i;
}

return_type: char


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

if ( !a1 )
return 0LL;
LODWORD(result) = 0;
do
{
result = (unsigned int)(result + 1);
a1 = *(_QWORD *)(a1 + 8);
}
while ( a1 );
return result;
}

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

if ( !a1 )
return 0LL;
LODWORD(result) = 0;
do
{
result = (unsigned int)(result + 1);
a1 = *(_QWORD *)(a1 + 8);
}
while ( a1 );
return result;
}

original_code:
int
cm_ftn_get_depth(FormTreeNode *t)
{
    if(t == ((void *)0))
 return 0;
    int depth = 0;
    do{
 depth++;
 t = t->parent;
    }while(t != ((void *)0));
    return depth;
}

canonical_original_code:
int cm_ftn_get_depth(struct __ftreenode *t)
{
    if(t == ((void *)0))
 return 0;
    int depth = 0;
    do{
 depth++;
 t = t->parent;
    }while(t != ((void *)0));
    return depth;
}

variable_types: depth int

user_defined_types: struct __ftreenode { char val; struct __ftreenode *parent; struct __ftreenode **children; int num_children; }


decompiled_code:
__int64 __fastcall cm_ftn_get_num_leaves(__int64 a1)
{
int v1; // eax
unsigned int v2; // ebp
_QWORD *v3; // rbx
__int64 v4; // r12

v1 = *(_DWORD *)(a1 + 24);
v2 = 1;
if ( v1 )
{
v2 = 0;
if ( v1 > 0 )
{
v3 = *(_QWORD **)(a1 + 16);
v4 = (__int64)&v3[(unsigned int)(v1 - 1) + 1];
do
v2 += cm_ftn_get_num_leaves(*v3++);
while ( v3 != (_QWORD *)v4 );
}
}
return v2;
}

original_code:
int
cm_ftn_get_num_leaves(FormTreeNode *t)
{
    if(t->num_children == 0)
 return 1;
    int sum = 0;
    int i;
    for(i = 0; i < t->num_children; i++)
 sum += cm_ftn_get_num_leaves((t->children)[i]);
    return sum;
}

canonical_original_code:
int cm_ftn_get_num_leaves(struct __ftreenode *t)
{
    if(t->num_children == 0)
 return 1;
    int sum = 0;
    int i;
    for(i = 0; i < t->num_children; i++)
 sum += cm_ftn_get_num_leaves((t->children)[i]);
    return sum;
}

variable_types: sum int


decompiled_code:
__int64 __fastcall cm_set_cm_ff_entry(unsigned __int64 *a1, unsigned __int64 a2, int a3, unsigned __int64 a4)
{
unsigned __int64 *v4; // rdi

if ( *a1 <= a2 )
return 4294967195LL;
v4 = &a1[2 * a2];
*((_DWORD *)v4 + 2) = a3;
v4[2] = a4;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int64 *a1, unsigned __int64 a2, int a3, unsigned __int64 a4)
{
unsigned __int64 *v4; // rdi

if ( *a1 <= a2 )
return 4294967195LL;
v4 = &a1[2 * a2];
*((_DWORD *)v4 + 2) = a3;
v4[2] = a4;
return 0LL;
}

original_code:
int
cm_set_cm_ff_entry(cm_file_formatter_t *cf, size_t i, cm_file_entry_type_e t,
      cm_file_entry_u data)
{
    if((i < 0) || (i >= cf->length))
 return -101;
    cf->entries[i].type = t;
    cf->entries[i].entry = data;
    return 0;
}

canonical_original_code:
int cm_set_cm_ff_entry(struct __cm_file_formatter_t *cf, unsigned long i, enum __cm_file_entry_type_e t, union __cm_file_entry_u data)
{
    if((i < 0) || (i >= cf->length))
 return -101;
    cf->entries[i].type = t;
    cf->entries[i].entry = data;
    return 0;
}

variable_types: struct __cm_file_formatter_t { unsigned long length; struct __cm_file_entry_t { enum __cm_file_entry_type_e { SIZE_T=0, DOUBLE_T=1, INT_T=2 } type; union __cm_file_entry_u { unsigned long s; double d; int i; } entry; } entries[]; } *

variable_types:
i
unsigned long

variable_types:
data
union __cm_file_entry_u

user_defined_types: struct __cm_file_formatter_t { unsigned long length; struct __cm_file_entry_t entries[]; }

user_defined_types: struct __cm_file_entry_t { enum __cm_file_entry_type_e type; union __cm_file_entry_u entry; }


decompiled_code:
__int64 __fastcall cm_file_entry_size(int *a1)
{
int v1; // edx
__int64 result; // rax

v1 = *a1;
result = 8LL;
if ( *a1 != 1 )
{
result = 4LL;
if ( v1 != 2 )
result = 8LL * (v1 == 0);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int *a1)
{
int v1; // edx
__int64 result; // rax

v1 = *a1;
result = 8LL;
if ( *a1 != 1 )
{
result = 4LL;
if ( v1 != 2 )
result = 8LL * (v1 == 0);
}
return result;
}

original_code:
size_t
cm_file_entry_size(cm_file_entry_t *e)
{
    size_t size;
    switch(e->type){
 case INT_T:
     size = sizeof(int);
     break;
 case DOUBLE_T:
     size = sizeof(double);
     break;
 case SIZE_T:
     size = sizeof(size_t);
     break;
 default:
     return 0;
    }
    return size;
}

canonical_original_code:
unsigned long cm_file_entry_size(struct __cm_file_entry_t *e)
{
    unsigned long size;
    switch(e->type){
 case INT_T:
     size = sizeof(int);
     break;
 case DOUBLE_T:
     size = sizeof(double);
     break;
 case SIZE_T:
     size = sizeof(unsigned long);
     break;
 default:
     return 0;
    }
    return size;
}

variable_types: struct __cm_file_entry_t { enum __cm_file_entry_type_e { SIZE_T=0, DOUBLE_T=1, INT_T=2 } type; union __cm_file_entry_u { unsigned long s; double d; int i; } entry; } *

variable_types:
size
unsigned long


decompiled_code:
int __fastcall cm_sprintf_cm_file_entry(char *a1, double *a2)
{
int v2; // eax

v2 = *(_DWORD *)a2;
if ( *(_DWORD *)a2 == 1 )
return sprintf(a1, "%g", a2[1]);
if ( v2 == 2 )
return sprintf(a1, "%d", *((unsigned int *)a2 + 2));
if ( v2 )
return -102;
return sprintf(a1, "%lu", *((_QWORD *)a2 + 1));
}

canonical_decompiled_code:
int __fastcall func4(char *a1, double *a2)
{
int v2; // eax

v2 = *(_DWORD *)a2;
if ( *(_DWORD *)a2 == 1 )
return sprintf(a1, "%g", a2[1]);
if ( v2 == 2 )
return sprintf(a1, "%d", *((unsigned int *)a2 + 2));
if ( v2 )
return -102;
return sprintf(a1, "%lu", *((_QWORD *)a2 + 1));
}

original_code:
int
cm_sprintf_cm_file_entry(char *c, cm_file_entry_t *e)
{
    switch(e->type){
 case INT_T:
     return sprintf(c, "%d", (e->entry).i);
 case DOUBLE_T:
     return sprintf(c, "%g", (e->entry).d);
 case SIZE_T:
     return sprintf(c, "%lu", (e->entry).s);
 default:
     return -102;
    }
    return -2;
}

canonical_original_code:
int cm_sprintf_cm_file_entry(char *c, struct __cm_file_entry_t *e)
{
    switch(e->type){
 case INT_T:
     return sprintf(c, "%d", (e->entry).i);
 case DOUBLE_T:
     return sprintf(c, "%g", (e->entry).d);
 case SIZE_T:
     return sprintf(c, "%lu", (e->entry).s);
 default:
     return -102;
    }
    return -2;
}

variable_types:
c
char *

user_defined_types: enum __cm_file_entry_type_e { SIZE_T=0, DOUBLE_T=1, INT_T=2 }

user_defined_types: union __cm_file_entry_u { unsigned long s; double d; int i; }


decompiled_code:
__int64 __fastcall cm_fl_shift_n(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 16) = cm_wrap((unsigned int)(*(_DWORD *)(a1 + 16) + a2), 0LL, *(unsigned int *)(a1 + 8));
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int a2)
{
*(_DWORD *)(a1 + 16) = cm_wrap((unsigned int)(*(_DWORD *)(a1 + 16) + a2), 0LL, *(unsigned int *)(a1 + 8));
return 0LL;
}

original_code:
int
cm_fl_shift_n(cm_filter_line_t *fl, int n)
{
    fl->offset = cm_wrap(fl->offset + n, 0, fl->length);
    return 0;
}

canonical_original_code:
int cm_fl_shift_n(struct __cm_filter_line *fl, int n)
{
    fl->offset = cm_wrap(fl->offset + n, 0, fl->length);
    return 0;
}

variable_types: struct __cm_filter_line { double *data; unsigned long length; int offset; } *

variable_types: n int


decompiled_code:
double __fastcall cm_fl_get_ith(__int64 *a1, int a2)
{
__int64 v2; // rbx

v2 = *a1;
return *(double *)(v2 + 8LL * (int)cm_wrap((unsigned int)(*((_DWORD *)a1 + 4) + a2), 0LL, a1[1]));
}

canonical_decompiled_code:
double __fastcall func1(__int64 *a1, int a2)
{
__int64 v2; // rbx

v2 = *a1;
return *(double *)(v2 + 8LL * (int)cm_wrap((unsigned int)(*((_DWORD *)a1 + 4) + a2), 0LL, a1[1]));
}

original_code:
double
cm_fl_get_ith(cm_filter_line_t *fl, int i)
{
    return fl->data[cm_wrap(fl->offset + i, 0, fl->length)];
}

canonical_original_code:
double cm_fl_get_ith(struct __cm_filter_line *fl, int i)
{
    return fl->data[cm_wrap(fl->offset + i, 0, fl->length)];
}

return_type: double

user_defined_types: struct __cm_filter_line { double *data; unsigned long length; int offset; }


decompiled_code:
__int64 __fastcall cm_fl_set_ith(__int64 *a1, int a2, double a3)
{
__int64 v3; // rbp

v3 = *a1;
*(double *)(v3 + 8LL * (int)cm_wrap((unsigned int)(*((_DWORD *)a1 + 4) + a2), 0LL, a1[1])) = a3;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 *a1, int a2, double a3)
{
__int64 v3; // rbp

v3 = *a1;
*(double *)(v3 + 8LL * (int)cm_wrap((unsigned int)(*((_DWORD *)a1 + 4) + a2), 0LL, a1[1])) = a3;
return 0LL;
}

original_code:
int
cm_fl_set_ith(cm_filter_line_t *fl, int i, double val)
{
    fl->data[cm_wrap(fl->offset + i, 0, fl->length)] = val;
    return 0;
}

canonical_original_code:
int cm_fl_set_ith(struct __cm_filter_line *fl, int i, double val)
{
    fl->data[cm_wrap(fl->offset + i, 0, fl->length)] = val;
    return 0;
}

variable_types: val double


decompiled_code:
void __fastcall cm_fl_free(void *ptr)
{
if ( ptr )
{
free(*(void **)ptr);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func3(void *ptr)
{
if ( ptr )
{
free(*(void **)ptr);
free(ptr);
}
}

original_code:
void
cm_fl_free(cm_filter_line_t *fl)
{
    if(fl != ((void *)0)) {
 free(fl->data);
 free(fl);
    }
}

canonical_original_code:
void cm_fl_free(struct __cm_filter_line *fl)
{
    if(fl != ((void *)0)) {
 free(fl->data);
 free(fl);
    }
}


decompiled_code:
__int64 __fastcall cm_allpole_filter_init(void **a1, __int64 a2)
{
void *v2; // rax
_QWORD *v3; // rbx
_QWORD *v4; // rax

v2 = malloc(0x28uLL);
*a1 = v2;
if ( !v2 )
return 4294967196LL;
v3 = v2;
v4 = cm_fl_alloc(a2 + 1);
*v3 = v4;
if ( v4 )
return 0LL;
free(*a1);
return 4294967196LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(void **a1, __int64 a2)
{
void *v2; // rax
_QWORD *v3; // rbx
_QWORD *v4; // rax

v2 = malloc(0x28uLL);
*a1 = v2;
if ( !v2 )
return 4294967196LL;
v3 = v2;
v4 = cm_fl_alloc(a2 + 1);
*v3 = v4;
if ( v4 )
return 0LL;
free(*a1);
return 4294967196LL;
}

original_code:
int
cm_allpole_filter_init(cm_allpole_filter_t **ap, size_t order)
{
    if(!((*ap) = (cm_allpole_filter_t*)malloc(sizeof(cm_allpole_filter_t))))
 return -100;
    if(!((*ap)->y = cm_fl_alloc(order+1))){
 free(*ap);
 return -100;
    }
    return 0;
}

canonical_original_code:
int cm_allpole_filter_init(struct __cm_allpole_filter **ap, unsigned long order)
{
    if(!((*ap) = (struct __cm_allpole_filter *)malloc(sizeof(cm_allpole_filter_t))))
 return -100;
    if(!((*ap)->y = cm_fl_alloc(order+1))){
 free(*ap);
 return -100;
    }
    return 0;
}

variable_types: struct __cm_allpole_filter { struct __cm_filter_line { double *data; unsigned long length; int offset; } *y; double *a; double g; unsigned long order; int owna; } **

variable_types:
order
unsigned long

user_defined_types: struct __cm_allpole_filter { struct __cm_filter_line *y; double *a; double g; unsigned long order; int owna; }


decompiled_code:
void __fastcall cm_allpole_filter_free(void *ptr)
{
if ( ptr )
{
cm_fl_free(*(void **)ptr);
if ( *((_DWORD *)ptr + 8) )
free(*((void **)ptr + 1));
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func5(void *ptr)
{
if ( ptr )
{
func3(*(void **)ptr);
if ( *((_DWORD *)ptr + 8) )
free(*((void **)ptr + 1));
free(ptr);
}
}

original_code:
void
cm_allpole_filter_free(cm_allpole_filter_t *ap)
{
    if(ap != ((void *)0)){
 cm_fl_free(ap->y);
 if(ap->owna)
     free(ap->a);
 free(ap);
    }
}

canonical_original_code:
void cm_allpole_filter_free(struct __cm_allpole_filter *ap)
{
    if(ap != ((void *)0)){
 cm_fl_free(ap->y);
 if(ap->owna)
     free(ap->a);
 free(ap);
    }
}

variable_types: struct __cm_allpole_filter { struct __cm_filter_line { double *data; unsigned long length; int offset; } *y; double *a; double g; unsigned long order; int owna; } *


decompiled_code:
double __fastcall cm_allpole_filter(__int64 a1, double *a2)
{
double v2; // r14
unsigned __int64 v3; // rbx
double v4; // rbp

v2 = *(double *)(a1 + 16) * *a2;
if ( *(_QWORD *)(a1 + 24) )
{
v3 = 0LL;
do
{
v4 = *(double *)(*(_QWORD *)(a1 + 8) + 8 * v3);
v2 = v2 - v4 * cm_fl_get_ith(*(__int64 **)a1, (int)v3++ + 1);
}
while ( *(_QWORD *)(a1 + 24) > v3 );
}
cm_fl_set_ith(*(__int64 **)a1, 0, v2);
cm_fl_shift_n(*(_QWORD *)a1, -1);
return v2;
}

original_code:
double
cm_allpole_filter(cm_allpole_filter_t *A, double *x)
{
    double y0 = A->g * (*x);
    int i;
    for(i = 0; i < A->order; i++)
 y0 -= A->a[i] * cm_fl_get_ith(A->y, i+1);
    cm_fl_set_ith(A->y, 0, y0);
    cm_fl_shift_n(A->y, -1);
    return y0;
}

canonical_original_code:
double cm_allpole_filter(struct __cm_allpole_filter *A, double *x)
{
    double y0 = A->g * (*x);
    int i;
    for(i = 0; i < A->order; i++)
 y0 -= A->a[i] * cm_fl_get_ith(A->y, i+1);
    cm_fl_set_ith(A->y, 0, y0);
    cm_fl_shift_n(A->y, -1);
    return y0;
}

variable_types:
x
double *

variable_types: i int


original_code:
int
cm_fill_sin_sum(double *tab, long int len, double *amps, int num)
{
    int i, j;
    for(i=0; i<len; i++){
 tab[i] = 0.0;
 for(j=0; j<num; j++)
     tab[i] += sin(2.0*3.14159265358979323846*((double)i/(double)len)
   *((double)j+1))*amps[j];
    }
    return 0;
}

canonical_original_code:
int cm_fill_sin_sum(double *tab, long len, double *amps, int num)
{
    int i; int j;
    for(i=0; i<len; i++){
 tab[i] = 0.0;
 for(j=0; j<num; j++)
     tab[i] += sin(2.0*3.14159265358979323846*((double)i/(double)len)
   *((double)j+1))*amps[j];
    }
    return 0;
}

variable_types:
tab
double *

variable_types: len long

variable_types:
amps
double *

variable_types: num int

variable_types: j int


decompiled_code:
double *__fastcall cm_make_sin_sum(__int64 a1, __int64 a2, int a3)
{
double *v4; // rbx

v4 = (double *)malloc(8 * a1);
if ( (unsigned int)cm_fill_sin_sum(v4, a1, a2, a3) )
v4 = 0LL;
return v4;
}

canonical_decompiled_code:
double *__fastcall func1(__int64 a1, __int64 a2, int a3)
{
double *v4; // rbx

v4 = (double *)malloc(8 * a1);
if ( (unsigned int)func0(v4, a1, a2, a3) )
v4 = 0LL;
return v4;
}

original_code:
double *
cm_make_sin_sum(long int len, double *amps, int num)
{
    double *tab = (double*)malloc(len*sizeof(double));
    int err;
    if(err = cm_fill_sin_sum(tab, len, amps, num))
 return ((void *)0);
    return tab;
}

canonical_original_code:
double *cm_make_sin_sum(long len, double *amps, int num)
{
    double *tab = (double*)malloc(len*sizeof(double));
    int err;
    if(err = cm_fill_sin_sum(tab, len, amps, num))
 return ((void *)0);
    return tab;
}

variable_types: err int

return_type: double *


clip

decompiled_code:
__int64 __fastcall clip(signed int a1, unsigned int a2, unsigned int a3)
{
__int64 result; // rax

result = a3;
if ( a1 <= (int)a3 )
{
result = a2;
if ( a1 >= (int)a2 )
result = (unsigned int)a1;
}
return result;
}

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

result = a3;
if ( a1 <= (int)a3 )
{
result = a2;
if ( a1 >= (int)a2 )
result = (unsigned int)a1;
}
return result;
}

original_code:
static int
clip( int val, int min, int max )
{
    if( val > max )
 return max ;
    else if( val < min )
 return min ;
    else
 return val ;
}

canonical_original_code:
static int clip(int val, int min, int max)
{
    if( val > max )
 return max ;
    else if( val < min )
 return min ;
    else
 return val ;
}

variable_types: val int

variable_types: min int

variable_types: max int


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

result = 0LL;
if ( a1 > 0 )
result = (unsigned int)(random() % a1);
return result;
}

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

result = 0LL;
if ( a1 > 0 )
result = (unsigned int)(random() % a1);
return result;
}

original_code:
static int
scaled_pos_rand( int val )
{
    if( val <= 0 )
 return 0 ;
    else
 return random() % val;
}

canonical_original_code:
static int scaled_pos_rand(int val)
{
    if( val <= 0 )
 return 0 ;
    else
 return random() % val;
}


decompiled_code:
__int64 __fastcall rand_range(int a1, int a2)
{
return a1 + (unsigned int)scaled_pos_rand(a2 - a1 + 1);
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, int a2)
{
return a1 + (unsigned int)func1(a2 - a1 + 1);
}

original_code:
static int
rand_range( int min, int max )
{
    return min + scaled_pos_rand( max - min + 1 ) ;
}

canonical_original_code:
static int rand_range(int min, int max)
{
    return min + scaled_pos_rand( max - min + 1 ) ;
}


swanderdev

decompiled_code:
__int64 swanderdev()
{
return srandomdev();
}

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

original_code:
void
swanderdev(void)
{
    srandomdev();
}

canonical_original_code:
void swanderdev()
{
    srandomdev();
}


wander

original_code:
int
wander(int s, int g, int kmi, int kma, int lbnd, int ubnd, int *a, int len)
{
    if(len<1)
 return -2;
    if(kmi>kma)
 return -3;
    if(!(((g-s) >= kmi*(len-1)) && ((g-s) <= kma*(len-1))))
 return -1;
    if((lbnd>s)||(lbnd>g)||(ubnd<s)||(ubnd<g))
 return -4;
    int i = 0;
    a[i] = s;
    i++;
    while(i < len){
 int max = g - s - kmi*(len - 1 - i) ;
 int min = g - s - kma*(len - 1 - i) ;
 s += rand_range(clip(kmi,min,max)>lbnd-s?clip(kmi,min,max):lbnd-s,
  clip(kma,min,max)<ubnd-s?clip(kma,min,max):ubnd-s);
 a[i] = s;
 i++;
    }
    return 0;
}

canonical_original_code:
int wander(int s, int g, int kmi, int kma, int lbnd, int ubnd, int *a, int len)
{
    if(len<1)
 return -2;
    if(kmi>kma)
 return -3;
    if(!(((g-s) >= kmi*(len-1)) && ((g-s) <= kma*(len-1))))
 return -1;
    if((lbnd>s)||(lbnd>g)||(ubnd<s)||(ubnd<g))
 return -4;
    int i = 0;
    a[i] = s;
    i++;
    while(i < len){
 int max = g - s - kmi*(len - 1 - i);
 int min = g - s - kma*(len - 1 - i);
 s += rand_range(clip(kmi,min,max)>lbnd-s?clip(kmi,min,max):lbnd-s,
  clip(kma,min,max)<ubnd-s?clip(kma,min,max):ubnd-s);
 a[i] = s;
 i++;
    }
    return 0;
}

variable_types: s int

variable_types: g int

variable_types: kmi int

variable_types: kma int

variable_types: lbnd int

variable_types: ubnd int

variable_types:
a
int *

variable_types: len int


decompiled_code:
double __fastcall cm_flinterp(double a1, double a2, double a3, double a4, double a5)
{
if ( a3 == a1 )
raise(8);
return (a4 - a2) / (a3 - a1) * (a5 - a1) + a2;
}

canonical_decompiled_code:
double __fastcall func0(double a1, double a2, double a3, double a4, double a5)
{
if ( a3 == a1 )
raise(8);
return (a4 - a2) / (a3 - a1) * (a5 - a1) + a2;
}

original_code:
double
cm_flinterp(double x1, double y1, double x2, double y2, double x)
{
    if(x2 == x1)
 raise(8);
    return ((y2 - y1)/(x2 - x1)) * (x - x1) + y1;
}

variable_types: x double


decompiled_code:
double __fastcall cm_flinterp_norm(double a1, double a2, double a3)
{
return cm_flinterp(0.0, a1, 1.0, a2, a3);
}

canonical_decompiled_code:
double __fastcall func1(double a1, double a2, double a3)
{
return func0(0.0, a1, 1.0, a2, a3);
}

original_code:
double
cm_flinterp_norm(double y1, double y2, double x)
{
    return cm_flinterp(0,y1,1,y2,x);
}


original_code:
int
cm_flinterp_a(double *x1, double *y1, double *x2, double *y2, double *y, double x, size_t len)
{
    int i;
    for( i = 0; i < len; i++)
 y[i] = (((((double)(y2[i])) - ((double)(y1[i]))) /(((double)(x2[i])) - ((double)(x1[i])))) * (((double)(x)) - ((double)(x1[i]))) + ((double)(y1[i])));
    return 0;
}

canonical_original_code:
int cm_flinterp_a(double *x1, double *y1, double *x2, double *y2, double *y, double x, unsigned long len)
{
    int i;
    for( i = 0; i < len; i++)
 y[i] = (((((double)(y2[i])) - ((double)(y1[i]))) /(((double)(x2[i])) - ((double)(x1[i])))) * (((double)(x)) - ((double)(x1[i]))) + ((double)(y1[i])));
    return 0;
}

variable_types:
y
double *

variable_types:
len
unsigned long

variable_types: i int


original_code:
int
cm_flinterp_a_norm(double *y1, double *y2, double *y, double x, size_t len)
{
    int i;
    for( i = 0; i < len; i++)
 y[i] = (((((double)(y2[i])) - ((double)(y1[i]))) /(((double)(1)) - ((double)(0)))) * (((double)(x)) - ((double)(0))) + ((double)(y1[i])));
    return 0;
}

canonical_original_code:
int cm_flinterp_a_norm(double *y1, double *y2, double *y, double x, unsigned long len)
{
    int i;
    for( i = 0; i < len; i++)
 y[i] = (((((double)(y2[i])) - ((double)(y1[i]))) /(((double)(1)) - ((double)(0)))) * (((double)(x)) - ((double)(0))) + ((double)(y1[i])));
    return 0;
}


decompiled_code:
__int64 __fastcall cm_wrap(int a1, signed int a2, unsigned int a3)
{
signed int v3; // ecx

v3 = a3;
if ( a2 <= (int)a3 )
{
if ( a2 == a3 )
return a3;
v3 = a2;
a2 = a3;
}
if ( a1 < v3 )
a3 = a2 + (a1 - v3) % (a2 - v3);
else
a3 = v3 + (a1 - v3) % (a2 - v3);
return a3;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, signed int a2, unsigned int a3)
{
signed int v3; // ecx

v3 = a3;
if ( a2 <= (int)a3 )
{
if ( a2 == a3 )
return a3;
v3 = a2;
a2 = a3;
}
if ( a1 < v3 )
a3 = a2 + (a1 - v3) % (a2 - v3);
else
a3 = v3 + (a1 - v3) % (a2 - v3);
return a3;
}

original_code:
int cm_wrap(int x, int a, int b)
{
    if(a>b){
 int tmp = a;
 a = b;
 b = tmp;
    }
    if(a==b)
 return a;
    if(x >= a){
 return ((x-a)%(b-a)) + a;
    }else{
 return (b-a) + ((x-a)%(b-a)) + a;
    }
}

variable_types: x int

variable_types: a int

variable_types: b int

variable_types: tmp int


decompiled_code:
double __fastcall cm_fwrap(double a1, double a2, double a3)
{
double result; // xmm0_8
double v4; // [rsp+0h] [rbp-18h]

v4 = a3;
if ( a2 <= a3 )
{
if ( a2 == a3 )
return a2;
v4 = a2;
a2 = a3;
}
if ( a1 < v4 )
result = fmod(a1 - v4, a2 - v4) + a2 - v4 + v4;
else
result = fmod(a1 - v4, a2 - v4) + v4;
return result;
}

canonical_decompiled_code:
double __fastcall func1(double a1, double a2, double a3)
{
double result; // xmm0_8
double v4; // [rsp+0h] [rbp-18h]

v4 = a3;
if ( a2 <= a3 )
{
if ( a2 == a3 )
return a2;
v4 = a2;
a2 = a3;
}
if ( a1 < v4 )
result = fmod(a1 - v4, a2 - v4) + a2 - v4 + v4;
else
result = fmod(a1 - v4, a2 - v4) + v4;
return result;
}

original_code:
double cm_fwrap(double x, double a, double b)
{
    if(a>b){
 double tmp = a;
 a = b;
 b = tmp;
    }
    if(a==b)
 return a;
    if(x >= a){
 return fmod(x-a, b-a) + a;
    }else{
 return (b-a) + fmod(x-a, b-a) + a;
    }
}

variable_types: a double

variable_types: b double

variable_types: tmp double


decompiled_code:
__int64 __fastcall cm_normalize_signal(__int64 a1, __int64 a2, double a3)
{
double v4; // xmm1_8
_BYTE v6[56]; // [rsp+0h] [rbp-38h] BYREF

gsl_vector_view_array(v6, a1, a2);
v4 = gsl_vector_max(v6);
return gsl_vector_scale(v6, 1.0 / v4 * a3);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, double a3)
{
double v4; // xmm1_8
_BYTE v6[56]; // [rsp+0h] [rbp-38h] BYREF

gsl_vector_view_array(v6, a1, a2);
v4 = gsl_vector_max(v6);
return gsl_vector_scale(v6, 1.0 / v4 * a3);
}

original_code:
void
cm_normalize_signal(double *x, size_t len, double s)
{
    gsl_vector_view X = gsl_vector_view_array(x,len);
    double max = gsl_vector_max(&X.vector);
    gsl_vector_scale(&X.vector, (1.0/max)*s);
}

canonical_original_code:
void cm_normalize_signal(double *x, unsigned long len, double s)
{
    struct _gsl_vector_view X = gsl_vector_view_array(x,len);
    double max = gsl_vector_max(&X.vector);
    gsl_vector_scale(&X.vector, (1.0/max)*s);
}

variable_types:
x
double *

variable_types: s double

variable_types: struct _gsl_vector_view { struct gsl_vector { unsigned long size; unsigned long stride; double *data; struct gsl_block_struct { unsigned long size; double *data; } *block; int owner; } vector; }

variable_types: max double

user_defined_types: struct _gsl_vector_view { struct gsl_vector vector; }

user_defined_types: struct gsl_vector { unsigned long size; unsigned long stride; double *data; struct gsl_block_struct *block; int owner; }


decompiled_code:
double __fastcall cm_atodb(double a1)
{
return log(a1) / 0.6931471805599453 * 6.0;
}

canonical_decompiled_code:
double __fastcall func0(double a1)
{
return log(a1) / 0.6931471805599453 * 6.0;
}

original_code:
double cm_atodb(double a)
{
    return (log(a)/log(2.0))*6.0;
}


decompiled_code:
double __fastcall cm_dbtoa(double a1)
{
return pow(2.0, a1 / 6.0);
}

canonical_decompiled_code:
double __fastcall func1(double a1)
{
return pow(2.0, a1 / 6.0);
}

original_code:
double cm_dbtoa(double db)
{
    return pow(2,db/6.0);
}

variable_types: db double


decompiled_code:
double __fastcall cm_mtof(double a1)
{
return pow(2.0, (a1 - 69.0) / 12.0) * 440.0;
}

canonical_decompiled_code:
double __fastcall func2(double a1)
{
return pow(2.0, (a1 - 69.0) / 12.0) * 440.0;
}

original_code:
double cm_mtof(double m)
{
    return 440.0*pow(2.0,(m - 69.0)/12);
}

variable_types: m double


decompiled_code:
double __fastcall cm_ftowtr(double a1, double a2, double a3)
{
return a1 * a3 / a2;
}

canonical_decompiled_code:
double __fastcall func3(double a1, double a2, double a3)
{
return a1 * a3 / a2;
}

original_code:
double cm_ftowtr(double f, double sr, double tablen)
{
    return (f*tablen)/sr;
}

variable_types: f double

variable_types: sr double

variable_types: tablen double


decompiled_code:
double __fastcall cm_time_dist(double a1)
{
return a1 / 340.2900085449219;
}

canonical_decompiled_code:
double __fastcall func4(double a1)
{
return a1 / 340.2900085449219;
}

original_code:
double cm_time_dist(double dist)
{
    return dist/340.29f;
}

variable_types: dist double


decompiled_code:
__m128 __fastcall cm_dist_press(double a1, __m128 a2)
{
*(double *)a2.m128_u64 = *(double *)a2.m128_u64 / a1;
return a2;
}

original_code:
double cm_dist_press(double dist, double sp_1_m)
{
    return sp_1_m/dist;
}


decompiled_code:
__int64 __fastcall cm_fill_rand_tab_uni(__int64 a1, __int64 a2, double a3, double a4)
{
__int64 v4; // rbp
time_t v5; // rax
__int64 v6; // rbx
double v8; // [rsp+0h] [rbp-38h]
double v9; // [rsp+8h] [rbp-30h]

v8 = a3;
v9 = a4;
if ( a3 > a4 )
{
v8 = a4;
v9 = a3;
}
else if ( a3 == a4 )
{
return (unsigned int)(int)a3;
}
v4 = gsl_rng_alloc(gsl_rng_ranlxs0);
if ( !v4 )
return 0xFFFFFFFFLL;
v5 = time(0LL);
gsl_rng_set(v4, v5);
v6 = a2 - 1;
if ( a2 > 0 )
{
do
*(double *)(a1 + 8 * v6--) = (v9 - v8) * gsl_rng_uniform(v4) + v8;
while ( v6 != -1 );
}
gsl_rng_free(v4);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2, double a3, double a4)
{
__int64 v4; // rbp
time_t v5; // rax
__int64 v6; // rbx
double v8; // [rsp+0h] [rbp-38h]
double v9; // [rsp+8h] [rbp-30h]

v8 = a3;
v9 = a4;
if ( a3 > a4 )
{
v8 = a4;
v9 = a3;
}
else if ( a3 == a4 )
{
return (unsigned int)(int)a3;
}
v4 = gsl_rng_alloc(gsl_rng_ranlxs0);
if ( !v4 )
return 0xFFFFFFFFLL;
v5 = time(0LL);
gsl_rng_set(v4, v5);
v6 = a2 - 1;
if ( a2 > 0 )
{
do
*(double *)(a1 + 8 * v6--) = (v9 - v8) * gsl_rng_uniform(v4) + v8;
while ( v6 != -1 );
}
gsl_rng_free(v4);
return 0LL;
}

original_code:
int
cm_fill_rand_tab_uni(double *tab, long int len, double a, double b)
{
    if(a>b){
 double tmp = a;
 a = b;
 b = tmp;
    }else if(a==b){
 return a;
    }
    gsl_rng *rng = gsl_rng_alloc(gsl_rng_ranlxs0);
    if(rng == ((void *)0))
 return -1;
    gsl_rng_set(rng, time(((void *)0)));
    while(len-- > 0)
 tab[len] = gsl_rng_uniform(rng) * (b - a) + a;
    gsl_rng_free(rng);
    return 0;
}

canonical_original_code:
int cm_fill_rand_tab_uni(double *tab, long len, double a, double b)
{
    if(a>b){
 double tmp = a;
 a = b;
 b = tmp;
    }else if(a==b){
 return a;
    }
    struct gsl_rng *rng = gsl_rng_alloc(gsl_rng_ranlxs0);
    if(rng == ((void *)0))
 return -1;
    gsl_rng_set(rng, time(((void *)0)));
    while(len-- > 0)
 tab[len] = gsl_rng_uniform(rng) * (b - a) + a;
    gsl_rng_free(rng);
    return 0;
}

variable_types:
tab
double *

variable_types: len long

variable_types: struct gsl_rng { struct gsl_rng_type { char *name; unsigned long max; unsigned long min; unsigned long size; void (*set)(void *state, unsigned long seed); unsigned long (*get)(void *state); double (*get_double)(void *state); } *type; void *state; } *

user_defined_types: struct gsl_rng { struct gsl_rng_type *type; void *state; }


decompiled_code:
__int64 __fastcall cm_rng_fill_rand_tab_uni(__int64 a1, __int64 a2, __int64 a3, double a4, double a5)
{
double v5; // rbp
__int64 v6; // rbx
double v8; // [rsp+8h] [rbp-30h]

v5 = a4;
v8 = a5;
if ( a4 <= a5 )
{
if ( a4 == a5 )
return (unsigned int)(int)a4;
v8 = a4;
v5 = a5;
}
if ( !a1 )
return 0xFFFFFFFFLL;
v6 = a3 - 1;
if ( a3 <= 0 )
return 0LL;
do
*(double *)(a2 + 8 * v6--) = (v5 - v8) * gsl_rng_uniform(a1) + v8;
while ( v6 != -1 );
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, __int64 a3, double a4, double a5)
{
double v5; // rbp
__int64 v6; // rbx
double v8; // [rsp+8h] [rbp-30h]

v5 = a4;
v8 = a5;
if ( a4 <= a5 )
{
if ( a4 == a5 )
return (unsigned int)(int)a4;
v8 = a4;
v5 = a5;
}
if ( !a1 )
return 0xFFFFFFFFLL;
v6 = a3 - 1;
if ( a3 <= 0 )
return 0LL;
do
*(double *)(a2 + 8 * v6--) = (v5 - v8) * gsl_rng_uniform(a1) + v8;
while ( v6 != -1 );
return 0LL;
}

original_code:
int
cm_rng_fill_rand_tab_uni(gsl_rng *rng, double *tab, long int len,
 double a, double b)
{
    if(a>b){
 double tmp = a;
 a = b;
 b = tmp;
    }else if(a==b){
 return a;
    }
    if(rng == ((void *)0))
 return -1;
    while(len-- > 0)
 tab[len] = gsl_rng_uniform(rng) * (b - a) + a;
    return 0;
}

canonical_original_code:
int cm_rng_fill_rand_tab_uni(struct gsl_rng *rng, double *tab, long len, double a, double b)
{
    if(a>b){
 double tmp = a;
 a = b;
 b = tmp;
    }else if(a==b){
 return a;
    }
    if(rng == ((void *)0))
 return -1;
    while(len-- > 0)
 tab[len] = gsl_rng_uniform(rng) * (b - a) + a;
    return 0;
}

user_defined_types: struct gsl_rng_type { char *name; unsigned long max; unsigned long min; unsigned long size; void (*set)(void *state, unsigned long seed); unsigned long (*get)(void *state); double (*get_double)(void *state); }


decompiled_code:
void *__fastcall cm_gen_rand_tab_uni(__int64 a1, double a2, double a3)
{
void *v3; // rbx

v3 = malloc(8 * a1);
if ( (unsigned int)cm_fill_rand_tab_uni((__int64)v3, a1, a2, a3) )
v3 = 0LL;
return v3;
}

canonical_decompiled_code:
void *__fastcall func2(__int64 a1, double a2, double a3)
{
void *v3; // rbx

v3 = malloc(8 * a1);
if ( (unsigned int)func0((__int64)v3, a1, a2, a3) )
v3 = 0LL;
return v3;
}

original_code:
double *
cm_gen_rand_tab_uni(long int len, double a, double b)
{
    double *tab = (double*)malloc(len*sizeof(double));
    int err;
    if(err = cm_fill_rand_tab_uni(tab, len, a, b))
 return ((void *)0);
    else
 return tab;
}

canonical_original_code:
double *cm_gen_rand_tab_uni(long len, double a, double b)
{
    double *tab = (double*)malloc(len*sizeof(double));
    int err;
    if(err = cm_fill_rand_tab_uni(tab, len, a, b))
 return ((void *)0);
    else
 return tab;
}

variable_types: err int


decompiled_code:
__int64 __fastcall cm_write_sf_from_dbl_ary_params(__int64 a1, const char *a2, __int64 a3, int a4, int a5, unsigned int a6)
{
__int64 v7; // [rsp+0h] [rbp-28h] BYREF
int v8; // [rsp+8h] [rbp-20h]
int v9; // [rsp+Ch] [rbp-1Ch]
__int64 v10; // [rsp+10h] [rbp-18h]
__int64 v11; // [rsp+18h] [rbp-10h]

v11 = 0LL;
v7 = a3;
v8 = a4;
v9 = a5;
v10 = a6;
return cm_write_sf_from_dbl_ary(a1, a2, &v7);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, const char *a2, __int64 a3, int a4, int a5, unsigned int a6)
{
__int64 v7; // [rsp+0h] [rbp-28h] BYREF
int v8; // [rsp+8h] [rbp-20h]
int v9; // [rsp+Ch] [rbp-1Ch]
__int64 v10; // [rsp+10h] [rbp-18h]
__int64 v11; // [rsp+18h] [rbp-10h]

v11 = 0LL;
v7 = a3;
v8 = a4;
v9 = a5;
v10 = a6;
return func1(a1, a2, &v7);
}

original_code:
long int
cm_write_sf_from_dbl_ary_params(double *tab, const char *filepath,
 sf_count_t frames, int samplerate, int channels, int format)
{
    SF_INFO sfinfo;
    memset(&sfinfo, 0, sizeof(SF_INFO));
    sfinfo.frames = frames;
    sfinfo.samplerate = samplerate;
    sfinfo.channels = channels;
    sfinfo.format = format;
    return cm_write_sf_from_dbl_ary(tab, filepath, &sfinfo);
}

canonical_original_code:
long cm_write_sf_from_dbl_ary_params(double *tab, char *filepath, long frames, int samplerate, int channels, int format)
{
    struct SF_INFO sfinfo;
    memset(&sfinfo, 0, sizeof(SF_INFO));
    sfinfo.frames = frames;
    sfinfo.samplerate = samplerate;
    sfinfo.channels = channels;
    sfinfo.format = format;
    return cm_write_sf_from_dbl_ary(tab, filepath, &sfinfo);
}

variable_types:
filepath
char *

variable_types: frames long

variable_types: samplerate int

variable_types: channels int

variable_types: format int

variable_types: struct SF_INFO { long frames; int samplerate; int channels; int format; int sections; int seekable; }


canonical_original_code:
int cm_fill_raised_cos(double *a, unsigned long N, double amp, double freq, double phase)
{
    unsigned long i;
    for(i = 0; i < N; i++)
 a[i] = amp*(1.0 + cos(3.14159265358979323846*2.0*(((double)i) + 0.5)*freq/((double)N)
      + 3.14159265358979323846*2.0*phase))/2.0;
    return 0;
}

variable_types:
a
double *

variable_types:
N
unsigned long

variable_types: amp double

variable_types: freq double

variable_types: phase double

variable_types:
i
unsigned long


repo: mondonc/myscreen

decompiled_code:
void calculate_disks()
{
__int64 v0; // rbx
char *v1; // rbp
int v2; // esi

if ( nb_disks > 0 )
{
v0 = 0LL;
v1 = &disk_result;
do
{
v2 = (int)(float)((float)(*(_DWORD *)(disks_new + 8 * v0) - *(_DWORD *)(disks + 8 * v0)) / 20.0);
if ( v2 )
{
v1 += (int)myprint_percentage_s(v1, (unsigned __int16)v2);
}
else
{
*v1 = disks_name[4 * v0];
v1[1] = byte_421[4 * v0];
v1[2] = byte_422[4 * v0];
v1[3] = 32;
v1[4] = 0;
v1 += 4;
}
++v0;
}
while ( nb_disks > (int)v0 );
}
}

original_code:
static void calculate_disks(){
 int percentage;
 int cpt,i;
 char * ptr;
 ptr = disk_result;
 ((void) (0));
 ((void) (0));
 ((void) (0));
 ((void) (0));
 percentage=0;
 for(cpt=0;cpt<nb_disks;cpt++){
  percentage= (int) (( (float)( (disks_new[cpt] - disks[cpt] )) ) / (2 * 10) );
  if (percentage != 0 ){
   ptr+=myprint_percentage_s(ptr, percentage);
  } else {
   for (i=0;i<3;i++){
    (*(ptr++)) = disks_name[cpt][i];
   }
   (*(ptr++))=' ';
   (*ptr)='\0';
  }
 }
}

canonical_original_code:
static void calculate_disks(){
 int percentage;
 int cpt; int i;
 char *ptr;
 ptr = disk_result;
 ((void) (0));
 ((void) (0));
 ((void) (0));
 ((void) (0));
 percentage=0;
 for(cpt=0;cpt<nb_disks;cpt++){
  percentage= (int) (( (float)( (disks_new[cpt] - disks[cpt] )) ) / (2 * 10) );
  if (percentage != 0 ){
   ptr+=myprint_percentage_s(ptr, percentage);
  } else {
   for (i=0;i<3;i++){
    (*(ptr++)) = disks_name[cpt][i];
   }
   (*(ptr++))=' ';
   (*ptr)='\0';
  }
 }
}

variable_types: percentage int

variable_types: cpt int

variable_types: i int

variable_types:
ptr
char *


decompiled_code:
char *disks_access()
{
__int64 v0; // rax

disk_result = 0;
nb_disks = update_disks(disks_new);
if ( !disk_result )
calculate_disks();
v0 = disks;
disks = disks_new;
disks_new = v0;
return &disk_result;
}

canonical_decompiled_code:
char *func3()
{
__int64 v0; // rax

disk_result = 0;
nb_disks = func1(disks_new);
if ( !disk_result )
func2();
v0 = disks;
disks = disks_new;
disks_new = v0;
return &disk_result;
}

original_code:
char * disks_access(){
 long * disks_temp;
 ((void) (0));
 ((void) (0));
 disk_result[0]='\0';
 nb_disks = update_disks(disks_new);
 if (disk_result[0] == '\0' ){
  calculate_disks();
 }
 disks_temp=disks;
 disks=disks_new;
 disks_new=disks_temp;
 return disk_result;
}

canonical_original_code:
char *disks_access(){
 long *disks_temp;
 ((void) (0));
 ((void) (0));
 disk_result[0]='\0';
 nb_disks = update_disks(disks_new);
 if (disk_result[0] == '\0' ){
  calculate_disks();
 }
 disks_temp=disks;
 disks=disks_new;
 disks_new=disks_temp;
 return disk_result;
}


decompiled_code:
const char *init_disks_access()
{
char *v0; // rax

disks = (__int64)&disks_static;
disks_new = (__int64)&disks_new_static;
v0 = disks_name;
do
{
*v0 = 0;
v0 += 4;
}
while ( v0 != (char *)&unk_448 );
nb_disks = update_disks((__int64)&disks_static);
return "Disk access ";
}

canonical_decompiled_code:
const char *func4()
{
char *v0; // rax

disks = (__int64)&disks_static;
disks_new = (__int64)&disks_new_static;
v0 = disks_name;
do
{
*v0 = 0;
v0 += 4;
}
while ( v0 != (char *)&unk_448 );
nb_disks = func1((__int64)&disks_static);
return "Disk access ";
}

original_code:
char * init_disks_access(char * UNUSED_conf_line __attribute__((__unused__))){
 int cpt;
 disks = disks_static;
 disks_new = disks_new_static;
 for (cpt=0;cpt< 10;cpt++) {
  disks_name[cpt][0]='\0';
 }
 nb_disks = update_disks(disks);
 return "Disk access ";
}

canonical_original_code:
char *init_disks_access(char *UNUSED_conf_line){
 int cpt;
 disks = disks_static;
 disks_new = disks_new_static;
 for (cpt=0;cpt< 10;cpt++) {
  disks_name[cpt][0]='\0';
 }
 nb_disks = update_disks(disks);
 return "Disk access ";
}


decompiled_code:
void exit_disks_access()
{
;
}

canonical_decompiled_code:
void func5()
{
;
}

original_code:
void exit_disks_access(){
}

canonical_original_code:
void exit_disks_access(){
}


decompiled_code:
__int64 __fastcall exit_modules(int a1)
{
__int64 i; // rbx
__int64 result; // rax

if ( a1 > 0 )
{
for ( i = 0LL; i != a1; result = (*(&exit_mod + current_conf[i++]))() )
;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
__int64 i; // rbx
__int64 result; // rax

if ( a1 > 0 )
{
for ( i = 0LL; i != a1; result = (*(&exit_mod + current_conf[i++]))() )
;
}
return result;
}

original_code:
static void exit_modules(int nb_modules){
 int cpt;
 for (cpt = 0; cpt < nb_modules ; cpt++ ){
  ((void) (0));
  exit_mod[current_conf[cpt]]();
 }
}


decompiled_code:
__int64 __fastcall update_stats(int a1)
{
__int64 i; // rbx
__int64 result; // rax

if ( a1 > 0 )
{
for ( i = 0LL; i != a1; result = (*(&main_mod + current_conf[i++]))() )
;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
__int64 i; // rbx
__int64 result; // rax

if ( a1 > 0 )
{
for ( i = 0LL; i != a1; result = (*(&main_mod + current_conf[i++]))() )
;
}
return result;
}

original_code:
static void update_stats(int nb_modules)
{
  int cpt;
  for (cpt = 0; cpt < nb_modules; cpt++)
    {
      (void)main_mod[current_conf[cpt]]();
    }
}


decompiled_code:
__int64 display_message()
{
FILE *v0; // rbx
const char *v1; // rdi

v0 = stdout;
v1 = (const char *)msg_queue_peek();
fputs(v1, v0);
return msg_queue_pop();
}

canonical_decompiled_code:
__int64 func2()
{
FILE *v0; // rbx
const char *v1; // rdi

v0 = stdout;
v1 = (const char *)msg_queue_peek();
fputs(v1, v0);
return msg_queue_pop();
}

original_code:
static void display_message()
{
  ((void) (0));
  ;;
  ((void) (0));
  ; fputs(msg_queue_peek(), stdout);
  ; (void)msg_queue_pop();
}


decompiled_code:
int get_sysinfo()
{
int result; // eax

result = sysinfo(&info);
if ( result == -1 )
{
perror("Fatal error of syscall sysinfo used at least by LOADAVERAGE,USERS,PROCS,RAM,SWAP");
exit(1);
}
return result;
}

canonical_decompiled_code:
int func3()
{
int result; // eax

result = sysinfo(&info);
if ( result == -1 )
{
perror("Fatal error of syscall sysinfo used at least by LOADAVERAGE,USERS,PROCS,RAM,SWAP");
exit(1);
}
return result;
}

original_code:
void get_sysinfo() {
 if (sysinfo(&si) == -1){
  perror("Fatal error of syscall sysinfo used at least by LOADAVERAGE,USERS,PROCS,RAM,SWAP");
  exit(1);
 }
}