refCompare

decompiled_code:
__int64 __fastcall refCompare(__int64 a1, __int64 a2)
{
return a1 - a2;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
return a1 - a2;
}

original_code:
int refCompare(void *o1, void *o2) {
    return (long int) o1 - (long int) o2;
}

canonical_original_code:
int refCompare(void *o1, void *o2) {
    return (long) o1 - (long) o2;
}


intCompare

decompiled_code:
// attributes: thunk
__int64 __fastcall intCompare(__int64 a1, __int64 a2)
{
return refCompare(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, __int64 a2)
{
return func4(a1, a2);
}

original_code:
int intCompare(void *o1, void *o2) {
    return refCompare(o1, o2);
}

return_type: int


strCompare

decompiled_code:
// attributes: thunk
int strCompare(const char *s1, const char *s2)
{
return strcmp(s1, s2);
}

canonical_decompiled_code:
int func6(const char *s1, const char *s2)
{
return strcmp(s1, s2);
}

original_code:
int strCompare(void *o1, void *o2) {
    return strcmp(o1, o2);
}


insCompareByAddr

decompiled_code:
__int64 __fastcall insCompareByAddr(__int64 a1, __int64 a2)
{
unsigned __int64 v2; // rax
bool v3; // cf
__int64 result; // rax

v2 = *(_QWORD *)(a2 + 8);
v3 = *(_QWORD *)(a1 + 8) < v2;
result = *(_QWORD *)(a1 + 8) > v2;
if ( v3 )
result = 0xFFFFFFFFLL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2)
{
unsigned __int64 v2; // rax
bool v3; // cf
__int64 result; // rax

v2 = *(_QWORD *)(a2 + 8);
v3 = *(_QWORD *)(a1 + 8) < v2;
result = *(_QWORD *)(a1 + 8) > v2;
if ( v3 )
result = 0xFFFFFFFFLL;
return result;
}

original_code:
int insCompareByAddr(void *i1, void *i2) {
  Instruction *ins1, *ins2;
  ins1 = (Instruction *)i1;
  ins2 = (Instruction *)i2;
  if (ins1->addr < ins2->addr) {
    return -1;
  }
  if (ins1->addr > ins2-> addr) {
    return 1;
  }
  return 0;
}

canonical_original_code:
int insCompareByAddr(void *i1, void *i2) {
  struct Instruction *ins1; struct Instruction *ins2;
  ins1 = (struct Instruction *)i1;
  ins2 = (struct Instruction *)i2;
  if (ins1->addr < ins2->addr) {
    return -1;
  }
  if (ins1->addr > ins2-> addr) {
    return 1;
  }
  return 0;
}

variable_types: struct Instruction { int order; unsigned long addr; unsigned long addr_origin; char opName[15]; enum OpCode { JSOP_NOP=0, JSOP_PUSH=1, JSOP_POPV=2, JSOP_ENTERWITH=3, JSOP_LEAVEWITH=4, JSOP_RETURN=5, JSOP_GOTO=6, JSOP_IFEQ=7, JSOP_IFNE=8, JSOP_ARGUMENTS=9, JSOP_FORARG=10, JSOP_FORVAR=11, JSOP_DUP=12, JSOP_DUP2=13, JSOP_SETCONST=14, JSOP_BITOR=15, JSOP_BITXOR=16, JSOP_BITAND=17, JSOP_EQ=18, JSOP_NE=19, JSOP_LT=20, JSOP_LE=21, JSOP_GT=22, JSOP_GE=23, JSOP_LSH=24, JSOP_RSH=25, JSOP_URSH=26, JSOP_ADD=27, JSOP_SUB=28, JSOP_MUL=29, JSOP_DIV=30, JSOP_MOD=31, JSOP_NOT=32, JSOP_BITNOT=33, JSOP_NEG=34, JSOP_NEW=35, JSOP_DELNAME=36, JSOP_DELPROP=37, JSOP_DELELEM=38, JSOP_TYPEOF=39, JSOP_VOID=40, JSOP_INCNAME=41, JSOP_INCPROP=42, JSOP_INCELEM=43, JSOP_DECNAME=44, JSOP_DECPROP=45, JSOP_DECELEM=46, JSOP_NAMEINC=47, JSOP_PROPINC=48, JSOP_ELEMINC=49, JSOP_NAMEDEC=50, JSOP_PROPDEC=51, JSOP_ELEMDEC=52, JSOP_GETPROP=53, JSOP_SETPROP=54, JSOP_GETELEM=55, JSOP_SETELEM=56, JSOP_CALLNAME=57, JSOP_CALL=58, JSOP_NAME=59, JSOP_DOUBLE=60, JSOP_STRING=61, JSOP_ZERO=62, JSOP_ONE=63, JSOP_NULL=64, JSOP_THIS=65, JSOP_FALSE=66, JSOP_TRUE=67, JSOP_OR=68, JSOP_AND=69, JSOP_TABLESWITCH=70, JSOP_LOOKUPSWITCH=71, JSOP_STRICTEQ=72, JSOP_STRICTNE=73, JSOP_CLOSURE=74, JSOP_EXPORTALL=75, JSOP_EXPORTNAME=76, JSOP_IMPORTALL=77, JSOP_IMPORTPROP=78, JSOP_IMPORTELEM=79, JSOP_OBJECT=80, JSOP_POP=81, JSOP_POS=82, JSOP_TRAP=83, JSOP_GETARG=84, JSOP_SETARG=85, JSOP_GETVAR=86, JSOP_SETVAR=87, JSOP_UINT16=88, JSOP_NEWINIT=89, JSOP_ENDINIT=90, JSOP_INITPROP=91, JSOP_INITELEM=92, JSOP_DEFSHARP=93, JSOP_USESHARP=94, JSOP_INCARG=95, JSOP_INCVAR=96, JSOP_DECARG=97, JSOP_DECVAR=98, JSOP_ARGINC=99, JSOP_VARINC=100, JSOP_ARGDEC=101, JSOP_VARDEC=102, JSOP_FORIN=103, JSOP_FORNAME=104, JSOP_FORPROP=105, JSOP_FORELEM=106, JSOP_POPN=107, JSOP_BINDNAME=108, JSOP_SETNAME=109, JSOP_THROW=110, JSOP_IN=111, JSOP_INSTANCEOF=112, JSOP_DEBUGGER=113, JSOP_GOSUB=114, JSOP_RETSUB=115, JSOP_EXCEPTION=116, JSOP_LINENO=117, JSOP_CONDSWITCH=118, JSOP_CASE=119, JSOP_DEFAULT=120, JSOP_EVAL=121, JSOP_ENUMELEM=122, JSOP_GETTER=123, JSOP_SETTER=124, JSOP_DEFFUN=125, JSOP_DEFCONST=126, JSOP_DEFVAR=127, JSOP_ANONFUNOBJ=128, JSOP_NAMEDFUNOBJ=129, JSOP_SETLOCALPOP=130, JSOP_GROUP=131, JSOP_SETCALL=132, JSOP_TRY=133, JSOP_FINALLY=134, JSOP_SWAP=135, JSOP_ARGSUB=136, JSOP_ARGCNT=137, JSOP_DEFLOCALFUN=138, JSOP_GOTOX=139, JSOP_IFEQX=140, JSOP_IFNEX=141, JSOP_ORX=142, JSOP_ANDX=143, JSOP_GOSUBX=144, JSOP_CASEX=145, JSOP_DEFAULTX=146, JSOP_TABLESWITCHX=147, JSOP_LOOKUPSWITCHX=148, JSOP_BACKPATCH=149, JSOP_BACKPATCH_POP=150, JSOP_THROWING=151, JSOP_SETRVAL=152, JSOP_RETRVAL=153, JSOP_GETGVAR=154, JSOP_SETGVAR=155, JSOP_INCGVAR=156, JSOP_DECGVAR=157, JSOP_GVARINC=158, JSOP_GVARDEC=159, JSOP_REGEXP=160, JSOP_DEFXMLNS=161, JSOP_ANYNAME=162, JSOP_QNAMEPART=163, JSOP_QNAMECONST=164, JSOP_QNAME=165, JSOP_TOATTRNAME=166, JSOP_TOATTRVAL=167, JSOP_ADDATTRNAME=168, JSOP_ADDATTRVAL=169, JSOP_BINDXMLNAME=170, JSOP_SETXMLNAME=171, JSOP_XMLNAME=172, JSOP_DESCENDANTS=173, JSOP_FILTER=174, JSOP_ENDFILTER=175, JSOP_TOXML=176, JSOP_TOXMLLIST=177, JSOP_XMLTAGEXPR=178, JSOP_XMLELTEXPR=179, JSOP_XMLOBJECT=180, JSOP_XMLCDATA=181, JSOP_XMLCOMMENT=182, JSOP_XMLPI=183, JSOP_CALLPROP=184, JSOP_GETFUNNS=185, JSOP_FOREACH=186, JSOP_DELDESC=187, JSOP_UINT24=188, JSOP_INDEXBASE=189, JSOP_RESETBASE=190, JSOP_RESETBASE0=191, JSOP_STARTXML=192, JSOP_STARTXMLEXPR=193, JSOP_CALLELEM=194, JSOP_STOP=195, JSOP_GETXPROP=196, JSOP_CALLXMLNAME=197, JSOP_TYPEOFEXPR=198, JSOP_ENTERBLOCK=199, JSOP_LEAVEBLOCK=200, JSOP_GETLOCAL=201, JSOP_SETLOCAL=202, JSOP_INCLOCAL=203, JSOP_DECLOCAL=204, JSOP_LOCALINC=205, JSOP_LOCALDEC=206, JSOP_FORLOCAL=207, JSOP_FORCONST=208, JSOP_ENDITER=209, JSOP_GENERATOR=210, JSOP_YIELD=211, JSOP_ARRAYPUSH=212, JSOP_FOREACHKEYVAL=213, JSOP_ENUMCONSTELEM=214, JSOP_LEAVEBLOCKEXPR=215, JSOP_GETTHISPROP=216, JSOP_GETARGPROP=217, JSOP_GETVARPROP=218, JSOP_GETLOCALPROP=219, JSOP_INDEXBASE1=220, JSOP_INDEXBASE2=221, JSOP_INDEXBASE3=222, JSOP_CALLGVAR=223, JSOP_CALLVAR=224, JSOP_CALLARG=225, JSOP_CALLLOCAL=226, JSOP_INT8=227, JSOP_INT32=228, JSOP_LENGTH=229 } opCode; int length; unsigned int flags; char *eval_str; char *str; unsigned long objRef; union { char *s; double d; long i; } operand; int stackUse; unsigned long stackUseStart; int stackDef; unsigned long stackDefStart; unsigned long propUseScope; long propUseId; unsigned long propDefScope; long propDefId; unsigned long localUse; unsigned long localDef; unsigned long localDef2; int jmpOffset; int nvars; struct BasicBlock { int id; enum BasicBlockType { BT_UNKNOWN=0, BT_FALL_THROUGH=1, BT_1_BRANCH=2, BT_2_BRANCH=3, BT_N_BRANCH=4, BT_SCRIPT_INVOKE=5, BT_RET=6, BT_AUG_EXIT=7 } type; unsigned long addr; unsigned long end_addr; struct Instruction *lastInstr; struct ArrayList { void **al_elements; int al_size; int al_capacity; enum ATYPE { AL_LIST_UNSORTED=0, AL_LIST_SORTED=1, AL_LIST_SET=2 } al_type; int al_lock; unsigned int flags; int (*al_compare)(void *, void *); void (*al_print)(void *); void (*al_free)(void *); } *instrs; struct ArrayList *preds; int count; int dfn; struct ArrayList *dominators; struct ArrayList *dominate; struct ArrayList *immDomPreds; struct ArrayList *immDomSuccs; struct ArrayList *reverseDominators; struct ArrayList *reverseDominate; struct ArrayList *reverseImmDomPreds; struct ArrayList *reverseImmDomSuccs; struct ArrayList *reverseDomFrontier; unsigned int flags; struct BasicBlock *calltarget; unsigned long inFunction; } *inBlock; struct BasicBlock *nextBlock; unsigned long inCallee; unsigned long inFunction; } *

user_defined_types: struct Instruction { int order; unsigned long addr; unsigned long addr_origin; char opName[15]; enum OpCode opCode; int length; unsigned int flags; char *eval_str; char *str; unsigned long objRef; union { char *s; double d; long i; } operand; int stackUse; unsigned long stackUseStart; int stackDef; unsigned long stackDefStart; unsigned long propUseScope; long propUseId; unsigned long propDefScope; long propDefId; unsigned long localUse; unsigned long localDef; unsigned long localDef2; int jmpOffset; int nvars; struct BasicBlock *inBlock; struct BasicBlock *nextBlock; unsigned long inCallee; unsigned long inFunction; }

user_defined_types: struct BasicBlock { int id; enum BasicBlockType type; unsigned long addr; unsigned long end_addr; struct Instruction *lastInstr; struct ArrayList *instrs; struct ArrayList *preds; int count; int dfn; struct ArrayList *dominators; struct ArrayList *dominate; struct ArrayList *immDomPreds; struct ArrayList *immDomSuccs; struct ArrayList *reverseDominators; struct ArrayList *reverseDominate; struct ArrayList *reverseImmDomPreds; struct ArrayList *reverseImmDomSuccs; struct ArrayList *reverseDomFrontier; unsigned int flags; struct BasicBlock *calltarget; unsigned long inFunction; }

user_defined_types: struct ArrayList { void **al_elements; int al_size; int al_capacity; enum ATYPE al_type; int al_lock; unsigned int flags; int (*al_compare)(void *, void *); void (*al_print)(void *); void (*al_free)(void *); }


insCompareByOrder

decompiled_code:
__int64 __fastcall insCompareByOrder(_DWORD *a1, _DWORD *a2)
{
__int64 result; // rax

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

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

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

original_code:
int insCompareByOrder(void *i1, void *i2) {
  Instruction *ins1, *ins2;
  ins1 = (Instruction *)i1;
  ins2 = (Instruction *)i2;
  if (ins1->order < ins2->order) {
    return -1;
  }
  if (ins1->order > ins2->order) {
    return 1;
  }
  return 0;
}

canonical_original_code:
int insCompareByOrder(void *i1, void *i2) {
  struct Instruction *ins1; struct Instruction *ins2;
  ins1 = (struct Instruction *)i1;
  ins2 = (struct Instruction *)i2;
  if (ins1->order < ins2->order) {
    return -1;
  }
  if (ins1->order > ins2->order) {
    return 1;
  }
  return 0;
}

user_defined_types: enum OpCode { JSOP_NOP=0, JSOP_PUSH=1, JSOP_POPV=2, JSOP_ENTERWITH=3, JSOP_LEAVEWITH=4, JSOP_RETURN=5, JSOP_GOTO=6, JSOP_IFEQ=7, JSOP_IFNE=8, JSOP_ARGUMENTS=9, JSOP_FORARG=10, JSOP_FORVAR=11, JSOP_DUP=12, JSOP_DUP2=13, JSOP_SETCONST=14, JSOP_BITOR=15, JSOP_BITXOR=16, JSOP_BITAND=17, JSOP_EQ=18, JSOP_NE=19, JSOP_LT=20, JSOP_LE=21, JSOP_GT=22, JSOP_GE=23, JSOP_LSH=24, JSOP_RSH=25, JSOP_URSH=26, JSOP_ADD=27, JSOP_SUB=28, JSOP_MUL=29, JSOP_DIV=30, JSOP_MOD=31, JSOP_NOT=32, JSOP_BITNOT=33, JSOP_NEG=34, JSOP_NEW=35, JSOP_DELNAME=36, JSOP_DELPROP=37, JSOP_DELELEM=38, JSOP_TYPEOF=39, JSOP_VOID=40, JSOP_INCNAME=41, JSOP_INCPROP=42, JSOP_INCELEM=43, JSOP_DECNAME=44, JSOP_DECPROP=45, JSOP_DECELEM=46, JSOP_NAMEINC=47, JSOP_PROPINC=48, JSOP_ELEMINC=49, JSOP_NAMEDEC=50, JSOP_PROPDEC=51, JSOP_ELEMDEC=52, JSOP_GETPROP=53, JSOP_SETPROP=54, JSOP_GETELEM=55, JSOP_SETELEM=56, JSOP_CALLNAME=57, JSOP_CALL=58, JSOP_NAME=59, JSOP_DOUBLE=60, JSOP_STRING=61, JSOP_ZERO=62, JSOP_ONE=63, JSOP_NULL=64, JSOP_THIS=65, JSOP_FALSE=66, JSOP_TRUE=67, JSOP_OR=68, JSOP_AND=69, JSOP_TABLESWITCH=70, JSOP_LOOKUPSWITCH=71, JSOP_STRICTEQ=72, JSOP_STRICTNE=73, JSOP_CLOSURE=74, JSOP_EXPORTALL=75, JSOP_EXPORTNAME=76, JSOP_IMPORTALL=77, JSOP_IMPORTPROP=78, JSOP_IMPORTELEM=79, JSOP_OBJECT=80, JSOP_POP=81, JSOP_POS=82, JSOP_TRAP=83, JSOP_GETARG=84, JSOP_SETARG=85, JSOP_GETVAR=86, JSOP_SETVAR=87, JSOP_UINT16=88, JSOP_NEWINIT=89, JSOP_ENDINIT=90, JSOP_INITPROP=91, JSOP_INITELEM=92, JSOP_DEFSHARP=93, JSOP_USESHARP=94, JSOP_INCARG=95, JSOP_INCVAR=96, JSOP_DECARG=97, JSOP_DECVAR=98, JSOP_ARGINC=99, JSOP_VARINC=100, JSOP_ARGDEC=101, JSOP_VARDEC=102, JSOP_FORIN=103, JSOP_FORNAME=104, JSOP_FORPROP=105, JSOP_FORELEM=106, JSOP_POPN=107, JSOP_BINDNAME=108, JSOP_SETNAME=109, JSOP_THROW=110, JSOP_IN=111, JSOP_INSTANCEOF=112, JSOP_DEBUGGER=113, JSOP_GOSUB=114, JSOP_RETSUB=115, JSOP_EXCEPTION=116, JSOP_LINENO=117, JSOP_CONDSWITCH=118, JSOP_CASE=119, JSOP_DEFAULT=120, JSOP_EVAL=121, JSOP_ENUMELEM=122, JSOP_GETTER=123, JSOP_SETTER=124, JSOP_DEFFUN=125, JSOP_DEFCONST=126, JSOP_DEFVAR=127, JSOP_ANONFUNOBJ=128, JSOP_NAMEDFUNOBJ=129, JSOP_SETLOCALPOP=130, JSOP_GROUP=131, JSOP_SETCALL=132, JSOP_TRY=133, JSOP_FINALLY=134, JSOP_SWAP=135, JSOP_ARGSUB=136, JSOP_ARGCNT=137, JSOP_DEFLOCALFUN=138, JSOP_GOTOX=139, JSOP_IFEQX=140, JSOP_IFNEX=141, JSOP_ORX=142, JSOP_ANDX=143, JSOP_GOSUBX=144, JSOP_CASEX=145, JSOP_DEFAULTX=146, JSOP_TABLESWITCHX=147, JSOP_LOOKUPSWITCHX=148, JSOP_BACKPATCH=149, JSOP_BACKPATCH_POP=150, JSOP_THROWING=151, JSOP_SETRVAL=152, JSOP_RETRVAL=153, JSOP_GETGVAR=154, JSOP_SETGVAR=155, JSOP_INCGVAR=156, JSOP_DECGVAR=157, JSOP_GVARINC=158, JSOP_GVARDEC=159, JSOP_REGEXP=160, JSOP_DEFXMLNS=161, JSOP_ANYNAME=162, JSOP_QNAMEPART=163, JSOP_QNAMECONST=164, JSOP_QNAME=165, JSOP_TOATTRNAME=166, JSOP_TOATTRVAL=167, JSOP_ADDATTRNAME=168, JSOP_ADDATTRVAL=169, JSOP_BINDXMLNAME=170, JSOP_SETXMLNAME=171, JSOP_XMLNAME=172, JSOP_DESCENDANTS=173, JSOP_FILTER=174, JSOP_ENDFILTER=175, JSOP_TOXML=176, JSOP_TOXMLLIST=177, JSOP_XMLTAGEXPR=178, JSOP_XMLELTEXPR=179, JSOP_XMLOBJECT=180, JSOP_XMLCDATA=181, JSOP_XMLCOMMENT=182, JSOP_XMLPI=183, JSOP_CALLPROP=184, JSOP_GETFUNNS=185, JSOP_FOREACH=186, JSOP_DELDESC=187, JSOP_UINT24=188, JSOP_INDEXBASE=189, JSOP_RESETBASE=190, JSOP_RESETBASE0=191, JSOP_STARTXML=192, JSOP_STARTXMLEXPR=193, JSOP_CALLELEM=194, JSOP_STOP=195, JSOP_GETXPROP=196, JSOP_CALLXMLNAME=197, JSOP_TYPEOFEXPR=198, JSOP_ENTERBLOCK=199, JSOP_LEAVEBLOCK=200, JSOP_GETLOCAL=201, JSOP_SETLOCAL=202, JSOP_INCLOCAL=203, JSOP_DECLOCAL=204, JSOP_LOCALINC=205, JSOP_LOCALDEC=206, JSOP_FORLOCAL=207, JSOP_FORCONST=208, JSOP_ENDITER=209, JSOP_GENERATOR=210, JSOP_YIELD=211, JSOP_ARRAYPUSH=212, JSOP_FOREACHKEYVAL=213, JSOP_ENUMCONSTELEM=214, JSOP_LEAVEBLOCKEXPR=215, JSOP_GETTHISPROP=216, JSOP_GETARGPROP=217, JSOP_GETVARPROP=218, JSOP_GETLOCALPROP=219, JSOP_INDEXBASE1=220, JSOP_INDEXBASE2=221, JSOP_INDEXBASE3=222, JSOP_CALLGVAR=223, JSOP_CALLVAR=224, JSOP_CALLARG=225, JSOP_CALLLOCAL=226, JSOP_INT8=227, JSOP_INT32=228, JSOP_LENGTH=229 }

user_defined_types: enum BasicBlockType { BT_UNKNOWN=0, BT_FALL_THROUGH=1, BT_1_BRANCH=2, BT_2_BRANCH=3, BT_N_BRANCH=4, BT_SCRIPT_INVOKE=5, BT_RET=6, BT_AUG_EXIT=7 }

user_defined_types: enum ATYPE { AL_LIST_UNSORTED=0, AL_LIST_SORTED=1, AL_LIST_SET=2 }


intPrint

decompiled_code:
int __fastcall intPrint(__int64 a1)
{
return printf("%ld", a1);
}

canonical_decompiled_code:
int __fastcall func9(__int64 a1)
{
return printf("%ld", a1);
}

original_code:
void intPrint(void *item) {
    printf("%ld", (long int) item);
}

canonical_original_code:
void intPrint(void *item) {
    printf("%ld", (long) item);
}

variable_types:
item
void *

return_type: void


refPrint

decompiled_code:
int __fastcall refPrint(__int64 a1)
{
return printf("%16lX", a1);
}

canonical_decompiled_code:
int __fastcall func10(__int64 a1)
{
return printf("%16lX", a1);
}

original_code:
void refPrint(void *item) {
    printf("%16lX", (unsigned long int) item);
}

canonical_original_code:
void refPrint(void *item) {
    printf("%16lX", (unsigned long) item);
}


strPrint

decompiled_code:
int __fastcall strPrint(const char *a1)
{
return printf("\"%s\"", a1);
}

canonical_decompiled_code:
int __fastcall func11(const char *a1)
{
return printf("\"%s\"", a1);
}

original_code:
void strPrint(void *key) {
    printf("\"%s\"", (char *) key);
}

variable_types:
key
void *


initSys

decompiled_code:
void initSys()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
void initSys(void){
}

canonical_original_code:
void initSys(){
}


test

decompiled_code:
int test()
{
__int64 v0; // rbx
_DWORD *v1; // rax
unsigned int *v2; // rax

puts("begin test()");
v0 = initOpStack(0LL);
v1 = malloc(4uLL);
*v1 = 100;
pushOpStack(v0, v1);
printf("sp:%d\n", *(unsigned int *)(v0 + 4));
v2 = (unsigned int *)popOpStack(v0);
printf("%d\n", *v2);
printf("sp:%d\n", *(unsigned int *)(v0 + 4));
return puts("end test()");
}

canonical_decompiled_code:
int func2()
{
__int64 v0; // rbx
_DWORD *v1; // rax
unsigned int *v2; // rax

puts("begin test()");
v0 = initOpStack(0LL);
v1 = malloc(4uLL);
*v1 = 100;
pushOpStack(v0, v1);
printf("sp:%d\n", *(unsigned int *)(v0 + 4));
v2 = (unsigned int *)popOpStack(v0);
printf("%d\n", *v2);
printf("sp:%d\n", *(unsigned int *)(v0 + 4));
return puts("end test()");
}

original_code:
void test(void){
 printf("begin test()\n");
 OpStack *stack = initOpStack(((void *)0));
 int *a = (int *)malloc(sizeof(int));
 *a=100;
 pushOpStack(stack, a);
 printf("sp:%d\n", stack->sp);
 printf("%d\n", *((int *)popOpStack(stack)));
 printf("sp:%d\n", stack->sp);
 printf("end test()\n");
}

canonical_original_code:
void test(){
 printf("begin test()\n");
 struct OpStack *stack = initOpStack(((void *)0));
 int *a = (int *)malloc(sizeof(int));
 *a=100;
 pushOpStack(stack, a);
 printf("sp:%d\n", stack->sp);
 printf("%d\n", *((int *)popOpStack(stack)));
 printf("sp:%d\n", stack->sp);
 printf("end test()\n");
}

variable_types: struct OpStack { int size; int sp; void **stack; void (*printFunc)(void *); } *

variable_types:
a
int *


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
int v4; // ebp
unsigned int *v5; // r12
__int64 v6; // rbp
__int64 v7; // r13
int v8; // ebx
__int64 v9; // r13
int v10; // er15
__int64 v11; // r14
__int64 v12; // rsi
unsigned int *v13; // rax
int v14; // ebx
__int64 v15; // rsi
__int64 v16; // rax
__int64 v17; // r13
unsigned int v18; // eax
__int64 v20; // r13
__int64 v21; // r14
__int64 v22; // rbp
__int64 v23; // rsi
int v24; // er13
__int64 v25; // rbx
__int64 v26; // rsi
__int64 v27; // rax
__int64 v28; // r13
__int64 v29; // r14
int v30; // ebx
int v31; // er15
__int64 v32; // r14
__int64 v33; // rsi
unsigned int *v34; // rax
__int64 v35; // rsi
__int64 v36; // rax
__int64 v37; // [rsp+0h] [rbp-88h]
double v38; // [rsp+0h] [rbp-88h]
__int64 v39; // [rsp+0h] [rbp-88h]
int v40; // [rsp+8h] [rbp-80h]
int v41; // [rsp+10h] [rbp-78h]
int v42; // [rsp+1Ch] [rbp-6Ch]
__int64 v43; // [rsp+20h] [rbp-68h]
__int64 v44; // [rsp+20h] [rbp-68h]
__int64 v45; // [rsp+28h] [rbp-60h]
__int64 v46; // [rsp+30h] [rbp-58h] BYREF
struct timezone tz; // [rsp+38h] [rbp-50h] BYREF
struct timeval tv; // [rsp+40h] [rbp-48h] BYREF

if ( argc != 3 )
goto LABEL_38;
v3 = atoi(argv[2]);
v4 = v3;
if ( v3 > 2 )
{
printf("%d\n", v3);
LABEL_38:
puts(
"usage: js_analysis <js_trace file> <flag>\n"
"\tflag:\n"
"\t 0: decompile entire trace\n"
"\t 1: recover simplified code\n"
"\t 2: generate sig function code");
return -1;
}
gettimeofday(&tv, &tz);
localtime(&tv.tv_sec);
v40 = tv.tv_sec;
v41 = tv.tv_usec;
v5 = (unsigned int *)InitInstrList(argv[1]);
v42 = labelInstructionList(v5);
if ( v4 )
{
if ( v4 == 1 )
{
PrintInfo(2u);
puts("processEvaledInstr...");
processEvaledInstr(v5);
puts("build CFG for entire trace...");
v20 = buildDynamicCFG(v5);
puts("construct functions list from the CFG of entire trace...");
v21 = buildFunctionCFGs(v5, v20, &v46);
findDominators(v20);
buildDFSTree(v20);
printBasicBlockList(v20);
deobfSlicing(v5);
processANDandORExps(v5, v20, v21);
if ( (unsigned int)findBackEdges(v20) )
puts("REDUCIBLE");
else
puts("NOT REDUCIBLE");
v22 = buildNaturalLoopList(v20);
printNaturalLoopList(v22);
puts("Building syntax tree...");
v23 = v20;
v24 = 0;
v25 = buildSyntaxTree(v5, v23, v22, v21, v46, 1LL);
puts("\nTransform syntax tree...");
transformSyntaxTree(v25);
puts("\nRecovered Source Code:");
while ( (int)al_size(v25) > v24 )
{
v26 = (unsigned int)v24++;
v27 = al_get(v25, v26);
printSyntaxTreeNode(v27, 1LL);
}
al_freeWithElements(v46);
destroyNaturalLoopList(v22);
destroyFunctionCFGs(v21);
}
else
{
PrintInfo(3u);
puts("processEvaledInstr...");
processEvaledInstr(v5);
printf("%d\n", *v5);
puts("building CFG...");
v37 = buildDynamicCFG(v5);
puts("building function CFGs...");
v6 = buildFunctionCFGs(v5, v37, &v46);
printBasicBlockList(v37);
puts("adding augmented exit blocks");
v7 = addAugmentedExitBlocks(v37);
puts("finding dominators");
findDominators(v37);
puts("finding reverse dominators");
findReverseDominators(v37);
puts("computing reverse dominance frontiers...");
computeReverseDominanceFrontiers(v37);
printRevDominanceFrontiers(v37);
puts("removing augmented exit blocks");
removeAugmentedExitBlocks(v37, v7);
puts("\nforward slicing");
envBranchSlicing(v5, v37, 1LL);
buildDFSTree(v37);
processANDandORExps(v5, v37, v6);
if ( (unsigned int)findBackEdges(v37) )
puts("REDUCIBLE");
else
puts("NOT REDUCIBLE");
v43 = buildNaturalLoopList(v37);
printNaturalLoopList(v43);
printInstrList(v5);
printBasicBlockList(v37);
puts("Building syntax tree...");
v8 = 0;
v9 = buildSyntaxTree(v5, v37, v43, v6, v46, 1LL);
puts("\nprint all function info:");
if ( (int)al_size(v6) > 0 )
{
do
{
v10 = 0;
v11 = al_get(v6, (unsigned int)v8);
printf("func %s\t", *(const char **)(v11 + 40));
while ( (int)al_size(*(_QWORD *)(v11 + 48)) > v10 )
{
v12 = (unsigned int)v10++;
v13 = (unsigned int *)al_get(*(_QWORD *)(v11 + 48), v12);
printf("%d ", *v13);
}
++v8;
putchar(10);
}
while ( (int)al_size(v6) > v8 );
}
v14 = 0;
puts("\nTransform syntax tree...");
transformSyntaxTree(v9);
puts("\nRecovered Source Code:");
while ( (int)al_size(v9) > v14 )
{
v15 = (unsigned int)v14++;
v16 = al_get(v9, v15);
printSyntaxTreeNode(v16, 1LL);
}
puts("create signature function");
v17 = createSigFunction(v5, v9, v46);
puts("\nsignature function:");
v18 = al_size(*(_QWORD *)(v17 + 40));
printf("alsize %d\n", v18);
printSyntaxTreeNode(v17, 1LL);
destroyFunctionCFGs(v6);
destroyNaturalLoopList(v43);
destroyBasicBlockList(v37);
}
}
else
{
PrintInfo(1u);
puts("processEvaledInstr...");
processEvaledInstr(v5);
printf("%d\n", *v5);
puts("building CFG...");
v44 = buildDynamicCFG(v5);
puts("building function CFGs...");
v28 = buildFunctionCFGs(v5, v44, &v46);
printBasicBlockList(v44);
puts("adding augmented exit blocks");
v29 = addAugmentedExitBlocks(v44);
puts("finding dominators");
findDominators(v44);
puts("finding reverse dominators");
findReverseDominators(v44);
puts("computing reverse dominance frontiers...");
computeReverseDominanceFrontiers(v44);
printRevDominanceFrontiers(v44);
puts("removing augmented exit blocks");
removeAugmentedExitBlocks(v44, v29);
buildDFSTree(v44);
processANDandORExps(v5, v44, v28);
if ( (unsigned int)findBackEdges(v44) )
puts("REDUCIBLE");
else
puts("NOT REDUCIBLE");
v45 = buildNaturalLoopList(v44);
printNaturalLoopList(v45);
printInstrList(v5);
printBasicBlockList(v44);
puts("Building syntax tree...");
v30 = 0;
v39 = buildSyntaxTree(v5, v44, v45, v28, v46, 0LL);
puts("\nprint all function info:");
if ( (int)al_size(v28) > 0 )
{
do
{
v31 = 0;
v32 = al_get(v28, (unsigned int)v30);
printf("func %s\t", *(const char **)(v32 + 40));
while ( (int)al_size(*(_QWORD *)(v32 + 48)) > v31 )
{
v33 = (unsigned int)v31++;
v34 = (unsigned int *)al_get(*(_QWORD *)(v32 + 48), v33);
printf("%d ", *v34);
}
++v30;
putchar(10);
}
while ( (int)al_size(v28) > v30 );
}
puts("\nTransform syntax tree...");
transformSyntaxTree(v39);
puts("\nRecovered Source Code:");
while ( (int)al_size(v39) > v4 )
{
v35 = (unsigned int)v4++;
v36 = al_get(v39, v35);
printSyntaxTreeNode(v36, 0LL);
}
destroyFunctionCFGs(v28);
destroyNaturalLoopList(v45);
destroyBasicBlockList(v44);
}
gettimeofday(&tv, &tz);
localtime(&tv.tv_sec);
v38 = (double)(LODWORD(tv.tv_usec) - v41 + 1000000 * (LODWORD(tv.tv_sec) - v40));
printf("ilist:%d\t ncalls: %d\t time:%fms\n", *v5, (unsigned int)v42, v38);
printf("avg/line: %f\n", v38 / (double)(int)*v5);
printf("avg/ncall: %f\n", v38 / (double)v42);
InstrListDestroy(v5, 1LL);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
int v4; // ebp
unsigned int *v5; // r12
__int64 v6; // rbp
__int64 v7; // r13
int v8; // ebx
__int64 v9; // r13
int v10; // er15
__int64 v11; // r14
__int64 v12; // rsi
unsigned int *v13; // rax
int v14; // ebx
__int64 v15; // rsi
__int64 v16; // rax
__int64 v17; // r13
unsigned int v18; // eax
__int64 v20; // r13
__int64 v21; // r14
__int64 v22; // rbp
__int64 v23; // rsi
int v24; // er13
__int64 v25; // rbx
__int64 v26; // rsi
__int64 v27; // rax
__int64 v28; // r13
__int64 v29; // r14
int v30; // ebx
int v31; // er15
__int64 v32; // r14
__int64 v33; // rsi
unsigned int *v34; // rax
__int64 v35; // rsi
__int64 v36; // rax
__int64 v37; // [rsp+0h] [rbp-88h]
double v38; // [rsp+0h] [rbp-88h]
__int64 v39; // [rsp+0h] [rbp-88h]
int v40; // [rsp+8h] [rbp-80h]
int v41; // [rsp+10h] [rbp-78h]
int v42; // [rsp+1Ch] [rbp-6Ch]
__int64 v43; // [rsp+20h] [rbp-68h]
__int64 v44; // [rsp+20h] [rbp-68h]
__int64 v45; // [rsp+28h] [rbp-60h]
__int64 v46; // [rsp+30h] [rbp-58h] BYREF
struct timezone tz; // [rsp+38h] [rbp-50h] BYREF
struct timeval tv; // [rsp+40h] [rbp-48h] BYREF

if ( argc != 3 )
goto LABEL_38;
v3 = atoi(argv[2]);
v4 = v3;
if ( v3 > 2 )
{
printf("%d\n", v3);
LABEL_38:
puts(
"usage: js_analysis <js_trace file> <flag>\n"
"\tflag:\n"
"\t 0: decompile entire trace\n"
"\t 1: recover simplified code\n"
"\t 2: generate sig function code");
return -1;
}
gettimeofday(&tv, &tz);
localtime(&tv.tv_sec);
v40 = tv.tv_sec;
v41 = tv.tv_usec;
v5 = (unsigned int *)InitInstrList(argv[1]);
v42 = labelInstructionList(v5);
if ( v4 )
{
if ( v4 == 1 )
{
func0(2u);
puts("processEvaledInstr...");
processEvaledInstr(v5);
puts("build CFG for entire trace...");
v20 = buildDynamicCFG(v5);
puts("construct functions list from the CFG of entire trace...");
v21 = buildFunctionCFGs(v5, v20, &v46);
findDominators(v20);
buildDFSTree(v20);
printBasicBlockList(v20);
deobfSlicing(v5);
processANDandORExps(v5, v20, v21);
if ( (unsigned int)findBackEdges(v20) )
puts("REDUCIBLE");
else
puts("NOT REDUCIBLE");
v22 = buildNaturalLoopList(v20);
printNaturalLoopList(v22);
puts("Building syntax tree...");
v23 = v20;
v24 = 0;
v25 = buildSyntaxTree(v5, v23, v22, v21, v46, 1LL);
puts("\nTransform syntax tree...");
transformSyntaxTree(v25);
puts("\nRecovered Source Code:");
while ( (int)al_size(v25) > v24 )
{
v26 = (unsigned int)v24++;
v27 = al_get(v25, v26);
printSyntaxTreeNode(v27, 1LL);
}
al_freeWithElements(v46);
destroyNaturalLoopList(v22);
destroyFunctionCFGs(v21);
}
else
{
func0(3u);
puts("processEvaledInstr...");
processEvaledInstr(v5);
printf("%d\n", *v5);
puts("building CFG...");
v37 = buildDynamicCFG(v5);
puts("building function CFGs...");
v6 = buildFunctionCFGs(v5, v37, &v46);
printBasicBlockList(v37);
puts("adding augmented exit blocks");
v7 = addAugmentedExitBlocks(v37);
puts("finding dominators");
findDominators(v37);
puts("finding reverse dominators");
findReverseDominators(v37);
puts("computing reverse dominance frontiers...");
computeReverseDominanceFrontiers(v37);
printRevDominanceFrontiers(v37);
puts("removing augmented exit blocks");
removeAugmentedExitBlocks(v37, v7);
puts("\nforward slicing");
envBranchSlicing(v5, v37, 1LL);
buildDFSTree(v37);
processANDandORExps(v5, v37, v6);
if ( (unsigned int)findBackEdges(v37) )
puts("REDUCIBLE");
else
puts("NOT REDUCIBLE");
v43 = buildNaturalLoopList(v37);
printNaturalLoopList(v43);
printInstrList(v5);
printBasicBlockList(v37);
puts("Building syntax tree...");
v8 = 0;
v9 = buildSyntaxTree(v5, v37, v43, v6, v46, 1LL);
puts("\nprint all function info:");
if ( (int)al_size(v6) > 0 )
{
do
{
v10 = 0;
v11 = al_get(v6, (unsigned int)v8);
printf("func %s\t", *(const char **)(v11 + 40));
while ( (int)al_size(*(_QWORD *)(v11 + 48)) > v10 )
{
v12 = (unsigned int)v10++;
v13 = (unsigned int *)al_get(*(_QWORD *)(v11 + 48), v12);
printf("%d ", *v13);
}
++v8;
putchar(10);
}
while ( (int)al_size(v6) > v8 );
}
v14 = 0;
puts("\nTransform syntax tree...");
transformSyntaxTree(v9);
puts("\nRecovered Source Code:");
while ( (int)al_size(v9) > v14 )
{
v15 = (unsigned int)v14++;
v16 = al_get(v9, v15);
printSyntaxTreeNode(v16, 1LL);
}
puts("create signature function");
v17 = createSigFunction(v5, v9, v46);
puts("\nsignature function:");
v18 = al_size(*(_QWORD *)(v17 + 40));
printf("alsize %d\n", v18);
printSyntaxTreeNode(v17, 1LL);
destroyFunctionCFGs(v6);
destroyNaturalLoopList(v43);
destroyBasicBlockList(v37);
}
}
else
{
func0(1u);
puts("processEvaledInstr...");
processEvaledInstr(v5);
printf("%d\n", *v5);
puts("building CFG...");
v44 = buildDynamicCFG(v5);
puts("building function CFGs...");
v28 = buildFunctionCFGs(v5, v44, &v46);
printBasicBlockList(v44);
puts("adding augmented exit blocks");
v29 = addAugmentedExitBlocks(v44);
puts("finding dominators");
findDominators(v44);
puts("finding reverse dominators");
findReverseDominators(v44);
puts("computing reverse dominance frontiers...");
computeReverseDominanceFrontiers(v44);
printRevDominanceFrontiers(v44);
puts("removing augmented exit blocks");
removeAugmentedExitBlocks(v44, v29);
buildDFSTree(v44);
processANDandORExps(v5, v44, v28);
if ( (unsigned int)findBackEdges(v44) )
puts("REDUCIBLE");
else
puts("NOT REDUCIBLE");
v45 = buildNaturalLoopList(v44);
printNaturalLoopList(v45);
printInstrList(v5);
printBasicBlockList(v44);
puts("Building syntax tree...");
v30 = 0;
v39 = buildSyntaxTree(v5, v44, v45, v28, v46, 0LL);
puts("\nprint all function info:");
if ( (int)al_size(v28) > 0 )
{
do
{
v31 = 0;
v32 = al_get(v28, (unsigned int)v30);
printf("func %s\t", *(const char **)(v32 + 40));
while ( (int)al_size(*(_QWORD *)(v32 + 48)) > v31 )
{
v33 = (unsigned int)v31++;
v34 = (unsigned int *)al_get(*(_QWORD *)(v32 + 48), v33);
printf("%d ", *v34);
}
++v30;
putchar(10);
}
while ( (int)al_size(v28) > v30 );
}
puts("\nTransform syntax tree...");
transformSyntaxTree(v39);
puts("\nRecovered Source Code:");
while ( (int)al_size(v39) > v4 )
{
v35 = (unsigned int)v4++;
v36 = al_get(v39, v35);
printSyntaxTreeNode(v36, 0LL);
}
destroyFunctionCFGs(v28);
destroyNaturalLoopList(v45);
destroyBasicBlockList(v44);
}
gettimeofday(&tv, &tz);
localtime(&tv.tv_sec);
v38 = (double)(LODWORD(tv.tv_usec) - v41 + 1000000 * (LODWORD(tv.tv_sec) - v40));
printf("ilist:%d\t ncalls: %d\t time:%fms\n", *v5, (unsigned int)v42, v38);
printf("avg/line: %f\n", v38 / (double)(int)*v5);
printf("avg/ncall: %f\n", v38 / (double)v42);
InstrListDestroy(v5, 1LL);
return 0;
}

original_code:
int main (int argc, char *argv[]) {
   struct timeval tv;
   struct timezone tz;
   struct tm *tm;
   long int t1s, t1m, t2s, t2m;
 InstrList *iList = ((void *)0);
 int reducible;
 int i,j;
 int parameter;
 if(argc != 3) {
  printf("usage: js_analysis <js_trace file> <flag>\n\tflag:\n"
    "\t 0: decompile entire trace\n"
    "\t 1: recover simplified code\n"
    "\t 2: generate sig function code\n");
  return(-1);
 }
 parameter = atoi(argv[2]);
 if(parameter!=0 && parameter!=1 && parameter!=2){
  printf("%d\n", parameter);
  printf("usage: js_analysis <js_trace file> <flag>\n\tflag:\n"
    "\t 0: decompile entire trace\n"
    "\t 1: recover simplified code\n"
    "\t 2: generate sig function code\n");
  return(-1);
 }
   gettimeofday(&tv, &tz);
   tm=localtime(&tv.tv_sec);
   t1s=tv.tv_sec;
   t1m=tv.tv_usec;
 initSys();
 iList = InitInstrList(argv[1]);
 int ncalls = labelInstructionList(iList);
 if(parameter==0){
  PrintInfo(1);
  ArrayList *funcBlockList;
  ArrayList *funcLoopList;
  ArrayList *funcCFGs;
  ArrayList *funcSyntaxTree;
  SyntaxTreeNode *funcSyntaxTreeNode;
  ArrayList *funcObjTable;
  printf("processEvaledInstr...\n");
  processEvaledInstr(iList);
  printf("%d\n",iList->numInstrs);
  printf("building CFG...\n");
  funcBlockList = buildDynamicCFG(iList);
  printf("building function CFGs...\n");
  funcCFGs = buildFunctionCFGs(iList, funcBlockList, &funcObjTable);
  printBasicBlockList(funcBlockList);
  printf("adding augmented exit blocks\n");
  ArrayList *augExits = addAugmentedExitBlocks(funcBlockList);
  printf("finding dominators\n");
  findDominators(funcBlockList);
  printf("finding reverse dominators\n");
  findReverseDominators(funcBlockList);
  printf("computing reverse dominance frontiers...\n");
  computeReverseDominanceFrontiers(funcBlockList);
  printRevDominanceFrontiers(funcBlockList);
  printf("removing augmented exit blocks\n");
  removeAugmentedExitBlocks(funcBlockList, augExits);
  buildDFSTree(funcBlockList);
  processANDandORExps(iList, funcBlockList, funcCFGs);
  reducible = findBackEdges(funcBlockList);
  if(reducible)
   printf("REDUCIBLE\n");
  else
   printf("NOT REDUCIBLE\n");
  funcLoopList = buildNaturalLoopList(funcBlockList);
  printNaturalLoopList(funcLoopList);
  printInstrList(iList);
  printBasicBlockList(funcBlockList);
  printf("Building syntax tree...\n");
  funcSyntaxTree = buildSyntaxTree(iList, funcBlockList, funcLoopList, funcCFGs, funcObjTable, parameter);
  printf("\nprint all function info:\n");
  Function *func;
  for(i=0;i<al_size(funcCFGs);i++){
   func = al_get(funcCFGs, i);
   printf("func %s\t", func->funcName);
   for(j=0;j<al_size(func->funcBody);j++){
    printf("%d  ",((BasicBlock*)al_get(func->funcBody, j))->id);
   }
   printf("\n");
  }
  printf("\nTransform syntax tree...\n");
  transformSyntaxTree(funcSyntaxTree);
  printf("\nRecovered Source Code:\n");
  for(i=0;i<al_size(funcSyntaxTree);i++){
   funcSyntaxTreeNode = al_get(funcSyntaxTree, i);
   printSyntaxTreeNode(funcSyntaxTreeNode, parameter);
  }
  destroyFunctionCFGs(funcCFGs);
  destroyNaturalLoopList(funcLoopList);
  destroyBasicBlockList(funcBlockList);
 }
 else if(parameter==1){
  PrintInfo(2);
  ArrayList *blockList;
  ArrayList *funcCFGs;
  ArrayList *loopList;
  ArrayList *funcObjTable;
  ArrayList *sliceSyntaxTree;
  SyntaxTreeNode *sliceSyntaxTreeNode;
  printf("processEvaledInstr...\n");
  processEvaledInstr(iList);
  printf("build CFG for entire trace...\n");
  blockList = buildDynamicCFG(iList);
  printf("construct functions list from the CFG of entire trace...\n");
  funcCFGs = buildFunctionCFGs(iList, blockList, &funcObjTable);
  findDominators(blockList);
  buildDFSTree(blockList);
  printBasicBlockList(blockList);
  deobfSlicing(iList);
  processANDandORExps(iList, blockList, funcCFGs);
  reducible = findBackEdges(blockList);
  if(reducible)
   printf("REDUCIBLE\n");
  else
   printf("NOT REDUCIBLE\n");
  loopList = buildNaturalLoopList(blockList);
  printNaturalLoopList(loopList);
  printf("Building syntax tree...\n");
  sliceSyntaxTree = buildSyntaxTree(iList, blockList, loopList, funcCFGs, funcObjTable, parameter);
  printf("\nTransform syntax tree...\n");
  transformSyntaxTree(sliceSyntaxTree);
  printf("\nRecovered Source Code:\n");
  for(i=0;i<al_size(sliceSyntaxTree);i++){
   sliceSyntaxTreeNode = al_get(sliceSyntaxTree, i);
   printSyntaxTreeNode(sliceSyntaxTreeNode, parameter);
  }
  al_freeWithElements(funcObjTable);
  destroyNaturalLoopList(loopList);
  destroyFunctionCFGs(funcCFGs);
 }
 else if(parameter==2){
  PrintInfo(3);
  parameter = 1;
  ArrayList *funcBlockList;
  ArrayList *funcLoopList;
  ArrayList *funcCFGs;
  ArrayList *funcSyntaxTree;
  SyntaxTreeNode *funcSyntaxTreeNode;
  ArrayList *funcObjTable;
  printf("processEvaledInstr...\n");
  processEvaledInstr(iList);
  printf("%d\n",iList->numInstrs);
  printf("building CFG...\n");
  funcBlockList = buildDynamicCFG(iList);
  printf("building function CFGs...\n");
  funcCFGs = buildFunctionCFGs(iList, funcBlockList, &funcObjTable);
  printBasicBlockList(funcBlockList);
  printf("adding augmented exit blocks\n");
  ArrayList *augExits = addAugmentedExitBlocks(funcBlockList);
  printf("finding dominators\n");
  findDominators(funcBlockList);
  printf("finding reverse dominators\n");
  findReverseDominators(funcBlockList);
  printf("computing reverse dominance frontiers...\n");
  computeReverseDominanceFrontiers(funcBlockList);
  printRevDominanceFrontiers(funcBlockList);
  printf("removing augmented exit blocks\n");
  removeAugmentedExitBlocks(funcBlockList, augExits);
  printf("\nforward slicing\n");
  envBranchSlicing(iList, funcBlockList, (1<<0));
  buildDFSTree(funcBlockList);
  processANDandORExps(iList, funcBlockList, funcCFGs);
  reducible = findBackEdges(funcBlockList);
  if(reducible)
   printf("REDUCIBLE\n");
  else
   printf("NOT REDUCIBLE\n");
  funcLoopList = buildNaturalLoopList(funcBlockList);
  printNaturalLoopList(funcLoopList);
  printInstrList(iList);
  printBasicBlockList(funcBlockList);
  printf("Building syntax tree...\n");
  funcSyntaxTree = buildSyntaxTree(iList, funcBlockList, funcLoopList, funcCFGs, funcObjTable, parameter);
  printf("\nprint all function info:\n");
  Function *func;
  for(i=0;i<al_size(funcCFGs);i++){
   func = al_get(funcCFGs, i);
   printf("func %s\t", func->funcName);
   for(j=0;j<al_size(func->funcBody);j++){
    printf("%d  ",((BasicBlock*)al_get(func->funcBody, j))->id);
   }
   printf("\n");
  }
  printf("\nTransform syntax tree...\n");
  transformSyntaxTree(funcSyntaxTree);
  printf("\nRecovered Source Code:\n");
  for(i=0;i<al_size(funcSyntaxTree);i++){
   funcSyntaxTreeNode = al_get(funcSyntaxTree, i);
   printSyntaxTreeNode(funcSyntaxTreeNode, parameter);
  }
  printf("create signature function\n");
  SyntaxTreeNode *sigFunc = createSigFunction(iList, funcSyntaxTree, funcObjTable);
  printf("\nsignature function:\n");
  printf("alsize %d\n", al_size(sigFunc->u.func.funcBody));
  printSyntaxTreeNode(sigFunc, parameter);
  destroyFunctionCFGs(funcCFGs);
  destroyNaturalLoopList(funcLoopList);
  destroyBasicBlockList(funcBlockList);
 }
 gettimeofday(&tv, &tz);
 tm=localtime(&tv.tv_sec);
 t2s=tv.tv_sec;
 t2m=tv.tv_usec;
 double ttt=(t2s-t1s)*1000000+(t2m-t1m);
 printf("ilist:%d\t ncalls: %d\t time:%fms\n", iList->numInstrs, ncalls, ttt);
 printf("avg/line: %f\n", ttt/iList->numInstrs);
 printf("avg/ncall: %f\n", ttt/ncalls);
 InstrListDestroy(iList, 1);
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[]) {
   struct timeval tv;
   struct timezone tz;
   struct tm *tm;
   long t1s; long t1m; long t2s; long t2m;
 struct InstrList *iList = ((void *)0);
 int reducible;
 int i; int j;
 int parameter;
 if(argc != 3) {
  printf("usage: js_analysis <js_trace file> <flag>\n\tflag:\n"
    "\t 0: decompile entire trace\n"
    "\t 1: recover simplified code\n"
    "\t 2: generate sig function code\n");
  return(-1);
 }
 parameter = atoi(argv[2]);
 if(parameter!=0 && parameter!=1 && parameter!=2){
  printf("%d\n", parameter);
  printf("usage: js_analysis <js_trace file> <flag>\n\tflag:\n"
    "\t 0: decompile entire trace\n"
    "\t 1: recover simplified code\n"
    "\t 2: generate sig function code\n");
  return(-1);
 }
   gettimeofday(&tv, &tz);
   tm=localtime(&tv.tv_sec);
   t1s=tv.tv_sec;
   t1m=tv.tv_usec;
 initSys();
 iList = InitInstrList(argv[1]);
 int ncalls = labelInstructionList(iList);
 if(parameter==0){
  PrintInfo(1);
  struct ArrayList *funcBlockList;
  struct ArrayList *funcLoopList;
  struct ArrayList *funcCFGs;
  struct ArrayList *funcSyntaxTree;
  struct SyntaxTreeNode *funcSyntaxTreeNode;
  struct ArrayList *funcObjTable;
  printf("processEvaledInstr...\n");
  processEvaledInstr(iList);
  printf("%d\n",iList->numInstrs);
  printf("building CFG...\n");
  funcBlockList = buildDynamicCFG(iList);
  printf("building function CFGs...\n");
  funcCFGs = buildFunctionCFGs(iList, funcBlockList, &funcObjTable);
  printBasicBlockList(funcBlockList);
  printf("adding augmented exit blocks\n");
  struct ArrayList *augExits = addAugmentedExitBlocks(funcBlockList);
  printf("finding dominators\n");
  findDominators(funcBlockList);
  printf("finding reverse dominators\n");
  findReverseDominators(funcBlockList);
  printf("computing reverse dominance frontiers...\n");
  computeReverseDominanceFrontiers(funcBlockList);
  printRevDominanceFrontiers(funcBlockList);
  printf("removing augmented exit blocks\n");
  removeAugmentedExitBlocks(funcBlockList, augExits);
  buildDFSTree(funcBlockList);
  processANDandORExps(iList, funcBlockList, funcCFGs);
  reducible = findBackEdges(funcBlockList);
  if(reducible)
   printf("REDUCIBLE\n");
  else
   printf("NOT REDUCIBLE\n");
  funcLoopList = buildNaturalLoopList(funcBlockList);
  printNaturalLoopList(funcLoopList);
  printInstrList(iList);
  printBasicBlockList(funcBlockList);
  printf("Building syntax tree...\n");
  funcSyntaxTree = buildSyntaxTree(iList, funcBlockList, funcLoopList, funcCFGs, funcObjTable, parameter);
  printf("\nprint all function info:\n");
  struct Function *func;
  for(i=0;i<al_size(funcCFGs);i++){
   func = al_get(funcCFGs, i);
   printf("func %s\t", func->funcName);
   for(j=0;j<al_size(func->funcBody);j++){
    printf("%d  ",((struct BasicBlock *)al_get(func->funcBody, j))->id);
   }
   printf("\n");
  }
  printf("\nTransform syntax tree...\n");
  transformSyntaxTree(funcSyntaxTree);
  printf("\nRecovered Source Code:\n");
  for(i=0;i<al_size(funcSyntaxTree);i++){
   funcSyntaxTreeNode = al_get(funcSyntaxTree, i);
   printSyntaxTreeNode(funcSyntaxTreeNode, parameter);
  }
  destroyFunctionCFGs(funcCFGs);
  destroyNaturalLoopList(funcLoopList);
  destroyBasicBlockList(funcBlockList);
 }
 else if(parameter==1){
  PrintInfo(2);
  struct ArrayList *blockList;
  struct ArrayList *funcCFGs;
  struct ArrayList *loopList;
  struct ArrayList *funcObjTable;
  struct ArrayList *sliceSyntaxTree;
  struct SyntaxTreeNode *sliceSyntaxTreeNode;
  printf("processEvaledInstr...\n");
  processEvaledInstr(iList);
  printf("build CFG for entire trace...\n");
  blockList = buildDynamicCFG(iList);
  printf("construct functions list from the CFG of entire trace...\n");
  funcCFGs = buildFunctionCFGs(iList, blockList, &funcObjTable);
  findDominators(blockList);
  buildDFSTree(blockList);
  printBasicBlockList(blockList);
  deobfSlicing(iList);
  processANDandORExps(iList, blockList, funcCFGs);
  reducible = findBackEdges(blockList);
  if(reducible)
   printf("REDUCIBLE\n");
  else
   printf("NOT REDUCIBLE\n");
  loopList = buildNaturalLoopList(blockList);
  printNaturalLoopList(loopList);
  printf("Building syntax tree...\n");
  sliceSyntaxTree = buildSyntaxTree(iList, blockList, loopList, funcCFGs, funcObjTable, parameter);
  printf("\nTransform syntax tree...\n");
  transformSyntaxTree(sliceSyntaxTree);
  printf("\nRecovered Source Code:\n");
  for(i=0;i<al_size(sliceSyntaxTree);i++){
   sliceSyntaxTreeNode = al_get(sliceSyntaxTree, i);
   printSyntaxTreeNode(sliceSyntaxTreeNode, parameter);
  }
  al_freeWithElements(funcObjTable);
  destroyNaturalLoopList(loopList);
  destroyFunctionCFGs(funcCFGs);
 }
 else if(parameter==2){
  PrintInfo(3);
  parameter = 1;
  struct ArrayList *funcBlockList;
  struct ArrayList *funcLoopList;
  struct ArrayList *funcCFGs;
  struct ArrayList *funcSyntaxTree;
  struct SyntaxTreeNode *funcSyntaxTreeNode;
  struct ArrayList *funcObjTable;
  printf("processEvaledInstr...\n");
  processEvaledInstr(iList);
  printf("%d\n",iList->numInstrs);
  printf("building CFG...\n");
  funcBlockList = buildDynamicCFG(iList);
  printf("building function CFGs...\n");
  funcCFGs = buildFunctionCFGs(iList, funcBlockList, &funcObjTable);
  printBasicBlockList(funcBlockList);
  printf("adding augmented exit blocks\n");
  struct ArrayList *augExits = addAugmentedExitBlocks(funcBlockList);
  printf("finding dominators\n");
  findDominators(funcBlockList);
  printf("finding reverse dominators\n");
  findReverseDominators(funcBlockList);
  printf("computing reverse dominance frontiers...\n");
  computeReverseDominanceFrontiers(funcBlockList);
  printRevDominanceFrontiers(funcBlockList);
  printf("removing augmented exit blocks\n");
  removeAugmentedExitBlocks(funcBlockList, augExits);
  printf("\nforward slicing\n");
  envBranchSlicing(iList, funcBlockList, (1<<0));
  buildDFSTree(funcBlockList);
  processANDandORExps(iList, funcBlockList, funcCFGs);
  reducible = findBackEdges(funcBlockList);
  if(reducible)
   printf("REDUCIBLE\n");
  else
   printf("NOT REDUCIBLE\n");
  funcLoopList = buildNaturalLoopList(funcBlockList);
  printNaturalLoopList(funcLoopList);
  printInstrList(iList);
  printBasicBlockList(funcBlockList);
  printf("Building syntax tree...\n");
  funcSyntaxTree = buildSyntaxTree(iList, funcBlockList, funcLoopList, funcCFGs, funcObjTable, parameter);
  printf("\nprint all function info:\n");
  struct Function *func;
  for(i=0;i<al_size(funcCFGs);i++){
   func = al_get(funcCFGs, i);
   printf("func %s\t", func->funcName);
   for(j=0;j<al_size(func->funcBody);j++){
    printf("%d  ",((struct BasicBlock *)al_get(func->funcBody, j))->id);
   }
   printf("\n");
  }
  printf("\nTransform syntax tree...\n");
  transformSyntaxTree(funcSyntaxTree);
  printf("\nRecovered Source Code:\n");
  for(i=0;i<al_size(funcSyntaxTree);i++){
   funcSyntaxTreeNode = al_get(funcSyntaxTree, i);
   printSyntaxTreeNode(funcSyntaxTreeNode, parameter);
  }
  printf("create signature function\n");
  struct SyntaxTreeNode *sigFunc = createSigFunction(iList, funcSyntaxTree, funcObjTable);
  printf("\nsignature function:\n");
  printf("alsize %d\n", al_size(sigFunc->u.func.funcBody));
  printSyntaxTreeNode(sigFunc, parameter);
  destroyFunctionCFGs(funcCFGs);
  destroyNaturalLoopList(funcLoopList);
  destroyBasicBlockList(funcBlockList);
 }
 gettimeofday(&tv, &tz);
 tm=localtime(&tv.tv_sec);
 t2s=tv.tv_sec;
 t2m=tv.tv_usec;
 double ttt = (t2s-t1s)*1000000+(t2m-t1m);
 printf("ilist:%d\t ncalls: %d\t time:%fms\n", iList->numInstrs, ncalls, ttt);
 printf("avg/line: %f\n", ttt/iList->numInstrs);
 printf("avg/ncall: %f\n", ttt/ncalls);
 InstrListDestroy(iList, 1);
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

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

variable_types: struct timezone { int tz_minuteswest; int tz_dsttime; }

variable_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long tm_gmtoff; char *tm_zone; } *

variable_types: struct InstrList { int numInstrs; struct ArrayList { void **al_elements; int al_size; int al_capacity; enum ATYPE { AL_LIST_UNSORTED=0, AL_LIST_SORTED=1, AL_LIST_SET=2 } al_type; int al_lock; unsigned int flags; int (*al_compare)(void *, void *); void (*al_print)(void *); void (*al_free)(void *); } *iList; } *

variable_types: reducible int

variable_types: i int

variable_types: j int

variable_types: parameter int

variable_types: ncalls int

variable_types: struct SyntaxTreeNode { int id; enum SyntaxTreeNodeType { TN_FUNCTION=0, TN_BLOCK=1, TN_IF_ELSE=2, TN_GOTO=3, TN_RETURN=4, TN_RETEXP=5, TN_EXP=6, TN_DEFVAR=7, TN_WHILE=8, TN_TRY_CATCH=9, TN_THROW=10 } type; unsigned int flags; struct SyntaxTreeNode *parent; struct ArrayList { void **al_elements; int al_size; int al_capacity; enum ATYPE { AL_LIST_UNSORTED=0, AL_LIST_SORTED=1, AL_LIST_SET=2 } al_type; int al_lock; unsigned int flags; int (*al_compare)(void *, void *); void (*al_print)(void *); void (*al_free)(void *); } *predsList; union { struct { int cfg_id; struct BasicBlock { int id; enum BasicBlockType { BT_UNKNOWN=0, BT_FALL_THROUGH=1, BT_1_BRANCH=2, BT_2_BRANCH=3, BT_N_BRANCH=4, BT_SCRIPT_INVOKE=5, BT_RET=6, BT_AUG_EXIT=7 } type; unsigned long addr; unsigned long end_addr; struct Instruction { int order; unsigned long addr; unsigned long addr_origin; char opName[15]; enum OpCode { JSOP_NOP=0, JSOP_PUSH=1, JSOP_POPV=2, JSOP_ENTERWITH=3, JSOP_LEAVEWITH=4, JSOP_RETURN=5, JSOP_GOTO=6, JSOP_IFEQ=7, JSOP_IFNE=8, JSOP_ARGUMENTS=9, JSOP_FORARG=10, JSOP_FORVAR=11, JSOP_DUP=12, JSOP_DUP2=13, JSOP_SETCONST=14, JSOP_BITOR=15, JSOP_BITXOR=16, JSOP_BITAND=17, JSOP_EQ=18, JSOP_NE=19, JSOP_LT=20, JSOP_LE=21, JSOP_GT=22, JSOP_GE=23, JSOP_LSH=24, JSOP_RSH=25, JSOP_URSH=26, JSOP_ADD=27, JSOP_SUB=28, JSOP_MUL=29, JSOP_DIV=30, JSOP_MOD=31, JSOP_NOT=32, JSOP_BITNOT=33, JSOP_NEG=34, JSOP_NEW=35, JSOP_DELNAME=36, JSOP_DELPROP=37, JSOP_DELELEM=38, JSOP_TYPEOF=39, JSOP_VOID=40, JSOP_INCNAME=41, JSOP_INCPROP=42, JSOP_INCELEM=43, JSOP_DECNAME=44, JSOP_DECPROP=45, JSOP_DECELEM=46, JSOP_NAMEINC=47, JSOP_PROPINC=48, JSOP_ELEMINC=49, JSOP_NAMEDEC=50, JSOP_PROPDEC=51, JSOP_ELEMDEC=52, JSOP_GETPROP=53, JSOP_SETPROP=54, JSOP_GETELEM=55, JSOP_SETELEM=56, JSOP_CALLNAME=57, JSOP_CALL=58, JSOP_NAME=59, JSOP_DOUBLE=60, JSOP_STRING=61, JSOP_ZERO=62, JSOP_ONE=63, JSOP_NULL=64, JSOP_THIS=65, JSOP_FALSE=66, JSOP_TRUE=67, JSOP_OR=68, JSOP_AND=69, JSOP_TABLESWITCH=70, JSOP_LOOKUPSWITCH=71, JSOP_STRICTEQ=72, JSOP_STRICTNE=73, JSOP_CLOSURE=74, JSOP_EXPORTALL=75, JSOP_EXPORTNAME=76, JSOP_IMPORTALL=77, JSOP_IMPORTPROP=78, JSOP_IMPORTELEM=79, JSOP_OBJECT=80, JSOP_POP=81, JSOP_POS=82, JSOP_TRAP=83, JSOP_GETARG=84, JSOP_SETARG=85, JSOP_GETVAR=86, JSOP_SETVAR=87, JSOP_UINT16=88, JSOP_NEWINIT=89, JSOP_ENDINIT=90, JSOP_INITPROP=91, JSOP_INITELEM=92, JSOP_DEFSHARP=93, JSOP_USESHARP=94, JSOP_INCARG=95, JSOP_INCVAR=96, JSOP_DECARG=97, JSOP_DECVAR=98, JSOP_ARGINC=99, JSOP_VARINC=100, JSOP_ARGDEC=101, JSOP_VARDEC=102, JSOP_FORIN=103, JSOP_FORNAME=104, JSOP_FORPROP=105, JSOP_FORELEM=106, JSOP_POPN=107, JSOP_BINDNAME=108, JSOP_SETNAME=109, JSOP_THROW=110, JSOP_IN=111, JSOP_INSTANCEOF=112, JSOP_DEBUGGER=113, JSOP_GOSUB=114, JSOP_RETSUB=115, JSOP_EXCEPTION=116, JSOP_LINENO=117, JSOP_CONDSWITCH=118, JSOP_CASE=119, JSOP_DEFAULT=120, JSOP_EVAL=121, JSOP_ENUMELEM=122, JSOP_GETTER=123, JSOP_SETTER=124, JSOP_DEFFUN=125, JSOP_DEFCONST=126, JSOP_DEFVAR=127, JSOP_ANONFUNOBJ=128, JSOP_NAMEDFUNOBJ=129, JSOP_SETLOCALPOP=130, JSOP_GROUP=131, JSOP_SETCALL=132, JSOP_TRY=133, JSOP_FINALLY=134, JSOP_SWAP=135, JSOP_ARGSUB=136, JSOP_ARGCNT=137, JSOP_DEFLOCALFUN=138, JSOP_GOTOX=139, JSOP_IFEQX=140, JSOP_IFNEX=141, JSOP_ORX=142, JSOP_ANDX=143, JSOP_GOSUBX=144, JSOP_CASEX=145, JSOP_DEFAULTX=146, JSOP_TABLESWITCHX=147, JSOP_LOOKUPSWITCHX=148, JSOP_BACKPATCH=149, JSOP_BACKPATCH_POP=150, JSOP_THROWING=151, JSOP_SETRVAL=152, JSOP_RETRVAL=153, JSOP_GETGVAR=154, JSOP_SETGVAR=155, JSOP_INCGVAR=156, JSOP_DECGVAR=157, JSOP_GVARINC=158, JSOP_GVARDEC=159, JSOP_REGEXP=160, JSOP_DEFXMLNS=161, JSOP_ANYNAME=162, JSOP_QNAMEPART=163, JSOP_QNAMECONST=164, JSOP_QNAME=165, JSOP_TOATTRNAME=166, JSOP_TOATTRVAL=167, JSOP_ADDATTRNAME=168, JSOP_ADDATTRVAL=169, JSOP_BINDXMLNAME=170, JSOP_SETXMLNAME=171, JSOP_XMLNAME=172, JSOP_DESCENDANTS=173, JSOP_FILTER=174, JSOP_ENDFILTER=175, JSOP_TOXML=176, JSOP_TOXMLLIST=177, JSOP_XMLTAGEXPR=178, JSOP_XMLELTEXPR=179, JSOP_XMLOBJECT=180, JSOP_XMLCDATA=181, JSOP_XMLCOMMENT=182, JSOP_XMLPI=183, JSOP_CALLPROP=184, JSOP_GETFUNNS=185, JSOP_FOREACH=186, JSOP_DELDESC=187, JSOP_UINT24=188, JSOP_INDEXBASE=189, JSOP_RESETBASE=190, JSOP_RESETBASE0=191, JSOP_STARTXML=192, JSOP_STARTXMLEXPR=193, JSOP_CALLELEM=194, JSOP_STOP=195, JSOP_GETXPROP=196, JSOP_CALLXMLNAME=197, JSOP_TYPEOFEXPR=198, JSOP_ENTERBLOCK=199, JSOP_LEAVEBLOCK=200, JSOP_GETLOCAL=201, JSOP_SETLOCAL=202, JSOP_INCLOCAL=203, JSOP_DECLOCAL=204, JSOP_LOCALINC=205, JSOP_LOCALDEC=206, JSOP_FORLOCAL=207, JSOP_FORCONST=208, JSOP_ENDITER=209, JSOP_GENERATOR=210, JSOP_YIELD=211, JSOP_ARRAYPUSH=212, JSOP_FOREACHKEYVAL=213, JSOP_ENUMCONSTELEM=214, JSOP_LEAVEBLOCKEXPR=215, JSOP_GETTHISPROP=216, JSOP_GETARGPROP=217, JSOP_GETVARPROP=218, JSOP_GETLOCALPROP=219, JSOP_INDEXBASE1=220, JSOP_INDEXBASE2=221, JSOP_INDEXBASE3=222, JSOP_CALLGVAR=223, JSOP_CALLVAR=224, JSOP_CALLARG=225, JSOP_CALLLOCAL=226, JSOP_INT8=227, JSOP_INT32=228, JSOP_LENGTH=229 } opCode; int length; unsigned int flags; char *eval_str; char *str; unsigned long objRef; union { char *s; double d; long i; } operand; int stackUse; unsigned long stackUseStart; int stackDef; unsigned long stackDefStart; unsigned long propUseScope; long propUseId; unsigned long propDefScope; long propDefId; unsigned long localUse; unsigned long localDef; unsigned long localDef2; int jmpOffset; int nvars; struct BasicBlock *inBlock; struct BasicBlock *nextBlock; unsigned long inCallee; unsigned long inFunction; } *lastInstr; struct ArrayList *instrs; struct ArrayList *preds; int count; int dfn; struct ArrayList *dominators; struct ArrayList *dominate; struct ArrayList *immDomPreds; struct ArrayList *immDomSuccs; struct ArrayList *reverseDominators; struct ArrayList *reverseDominate; struct ArrayList *reverseImmDomPreds; struct ArrayList *reverseImmDomSuccs; struct ArrayList *reverseDomFrontier; unsigned int flags; struct BasicBlock *calltarget; unsigned long inFunction; } *cfgBlock; struct ArrayList *statements; } block; struct { struct ExpTreeNode { enum ExpTreeNodeType { EXP_NAME=0, EXP_UNDEFINED=1, EXP_CONST_VALUE=2, EXP_BIN=3, EXP_UN=4, EXP_CALL=5, EXP_NEW=6, EXP_ARRAY_ELM=7, EXP_ARRAY_INIT=8, EXP_PROP=9, EXP_EVAL=10, EXP_TOKEN=11 } type; unsigned int flags; union { char *name; double const_value_double; char *const_value_str; long const_value_int; _Bool const_value_bool; struct { char *name; enum Operator { OP_ADD=0, OP_SUB=1, OP_MUL=2, OP_DIV=3, OP_MOD=4, OP_BITAND=5, OP_BITOR=6, OP_GE=7, OP_GT=8, OP_LE=9, OP_LT=10, OP_NE=11, OP_EQ=12, OP_INITPROP=13, OP_ASSIGN=14, OP_NOT=15, OP_VINC=16, OP_VDEC=17, OP_INCV=18, OP_DECV=19, OP_AND=20, OP_OR=21 } op; struct ExpTreeNode *lval; } un_op; struct { enum Operator { OP_ADD=0, OP_SUB=1, OP_MUL=2, OP_DIV=3, OP_MOD=4, OP_BITAND=5, OP_BITOR=6, OP_GE=7, OP_GT=8, OP_LE=9, OP_LT=10, OP_NE=11, OP_EQ=12, OP_INITPROP=13, OP_ASSIGN=14, OP_NOT=15, OP_VINC=16, OP_VDEC=17, OP_INCV=18, OP_DECV=19, OP_AND=20, OP_OR=21 } op; struct ExpTreeNode *lval; struct ExpTreeNode *rval; } bin_op; struct { struct ExpTreeNode *name; int num_paras; struct ArrayList *parameters; struct BasicBlock *funcEntryBlock; } func; struct { struct ExpTreeNode *name; struct ExpTreeNode *index; } array_elm; struct { int size; struct ArrayList *initValues; } array_init; struct { struct ExpTreeNode *objName; struct ExpTreeNode *propName; } prop; struct { unsigned long targetAddr; enum Operator { OP_ADD=0, OP_SUB=1, OP_MUL=2, OP_DIV=3, OP_MOD=4, OP_BITAND=5, OP_BITOR=6, OP_GE=7, OP_GT=8, OP_LE=9, OP_LT=10, OP_NE=11, OP_EQ=12, OP_INITPROP=13, OP_ASSIGN=14, OP_NOT=15, OP_VINC=16, OP_VDEC=17, OP_INCV=18, OP_DECV=19, OP_AND=20, OP_OR=21 } op; } tok; } u; } *cond; struct NaturalLoop { int id; unsigned int flags; struct BasicBlock *header; struct ArrayList *backEdges; struct ArrayList *nodes; } *loopStruct; struct BasicBlock *header; struct SyntaxTreeNode *synHeader; struct ArrayList *loopBody; struct ArrayList *loopBody2; int _bodyBranchType; } loop; struct { struct Function { unsigned int flags; int args; int loc_vars; unsigned long funcEntryAddr; struct ArrayList *funcObj; struct BasicBlock *funcEntryBlock; char *funcName; struct ArrayList *funcBody; } *funcStruct; struct ArrayList *funcBody; struct SyntaxTreeNode *synFuncEntryNode; } func; struct ExpTreeNode *expNode; struct { struct BasicBlock *targetBlock; struct SyntaxTreeNode *synTargetBlock; } go_to; struct { int _ifeq; struct ExpTreeNode *cond; struct ArrayList *if_path; struct ArrayList *else_path; } if_else; struct { struct ArrayList *try_body; struct ArrayList *catch_body; } try_catch; } u; } *

variable_types: struct Function { unsigned int flags; int args; int loc_vars; unsigned long funcEntryAddr; struct ArrayList { void **al_elements; int al_size; int al_capacity; enum ATYPE { AL_LIST_UNSORTED=0, AL_LIST_SORTED=1, AL_LIST_SET=2 } al_type; int al_lock; unsigned int flags; int (*al_compare)(void *, void *); void (*al_print)(void *); void (*al_free)(void *); } *funcObj; struct BasicBlock { int id; enum BasicBlockType { BT_UNKNOWN=0, BT_FALL_THROUGH=1, BT_1_BRANCH=2, BT_2_BRANCH=3, BT_N_BRANCH=4, BT_SCRIPT_INVOKE=5, BT_RET=6, BT_AUG_EXIT=7 } type; unsigned long addr; unsigned long end_addr; struct Instruction { int order; unsigned long addr; unsigned long addr_origin; char opName[15]; enum OpCode { JSOP_NOP=0, JSOP_PUSH=1, JSOP_POPV=2, JSOP_ENTERWITH=3, JSOP_LEAVEWITH=4, JSOP_RETURN=5, JSOP_GOTO=6, JSOP_IFEQ=7, JSOP_IFNE=8, JSOP_ARGUMENTS=9, JSOP_FORARG=10, JSOP_FORVAR=11, JSOP_DUP=12, JSOP_DUP2=13, JSOP_SETCONST=14, JSOP_BITOR=15, JSOP_BITXOR=16, JSOP_BITAND=17, JSOP_EQ=18, JSOP_NE=19, JSOP_LT=20, JSOP_LE=21, JSOP_GT=22, JSOP_GE=23, JSOP_LSH=24, JSOP_RSH=25, JSOP_URSH=26, JSOP_ADD=27, JSOP_SUB=28, JSOP_MUL=29, JSOP_DIV=30, JSOP_MOD=31, JSOP_NOT=32, JSOP_BITNOT=33, JSOP_NEG=34, JSOP_NEW=35, JSOP_DELNAME=36, JSOP_DELPROP=37, JSOP_DELELEM=38, JSOP_TYPEOF=39, JSOP_VOID=40, JSOP_INCNAME=41, JSOP_INCPROP=42, JSOP_INCELEM=43, JSOP_DECNAME=44, JSOP_DECPROP=45, JSOP_DECELEM=46, JSOP_NAMEINC=47, JSOP_PROPINC=48, JSOP_ELEMINC=49, JSOP_NAMEDEC=50, JSOP_PROPDEC=51, JSOP_ELEMDEC=52, JSOP_GETPROP=53, JSOP_SETPROP=54, JSOP_GETELEM=55, JSOP_SETELEM=56, JSOP_CALLNAME=57, JSOP_CALL=58, JSOP_NAME=59, JSOP_DOUBLE=60, JSOP_STRING=61, JSOP_ZERO=62, JSOP_ONE=63, JSOP_NULL=64, JSOP_THIS=65, JSOP_FALSE=66, JSOP_TRUE=67, JSOP_OR=68, JSOP_AND=69, JSOP_TABLESWITCH=70, JSOP_LOOKUPSWITCH=71, JSOP_STRICTEQ=72, JSOP_STRICTNE=73, JSOP_CLOSURE=74, JSOP_EXPORTALL=75, JSOP_EXPORTNAME=76, JSOP_IMPORTALL=77, JSOP_IMPORTPROP=78, JSOP_IMPORTELEM=79, JSOP_OBJECT=80, JSOP_POP=81, JSOP_POS=82, JSOP_TRAP=83, JSOP_GETARG=84, JSOP_SETARG=85, JSOP_GETVAR=86, JSOP_SETVAR=87, JSOP_UINT16=88, JSOP_NEWINIT=89, JSOP_ENDINIT=90, JSOP_INITPROP=91, JSOP_INITELEM=92, JSOP_DEFSHARP=93, JSOP_USESHARP=94, JSOP_INCARG=95, JSOP_INCVAR=96, JSOP_DECARG=97, JSOP_DECVAR=98, JSOP_ARGINC=99, JSOP_VARINC=100, JSOP_ARGDEC=101, JSOP_VARDEC=102, JSOP_FORIN=103, JSOP_FORNAME=104, JSOP_FORPROP=105, JSOP_FORELEM=106, JSOP_POPN=107, JSOP_BINDNAME=108, JSOP_SETNAME=109, JSOP_THROW=110, JSOP_IN=111, JSOP_INSTANCEOF=112, JSOP_DEBUGGER=113, JSOP_GOSUB=114, JSOP_RETSUB=115, JSOP_EXCEPTION=116, JSOP_LINENO=117, JSOP_CONDSWITCH=118, JSOP_CASE=119, JSOP_DEFAULT=120, JSOP_EVAL=121, JSOP_ENUMELEM=122, JSOP_GETTER=123, JSOP_SETTER=124, JSOP_DEFFUN=125, JSOP_DEFCONST=126, JSOP_DEFVAR=127, JSOP_ANONFUNOBJ=128, JSOP_NAMEDFUNOBJ=129, JSOP_SETLOCALPOP=130, JSOP_GROUP=131, JSOP_SETCALL=132, JSOP_TRY=133, JSOP_FINALLY=134, JSOP_SWAP=135, JSOP_ARGSUB=136, JSOP_ARGCNT=137, JSOP_DEFLOCALFUN=138, JSOP_GOTOX=139, JSOP_IFEQX=140, JSOP_IFNEX=141, JSOP_ORX=142, JSOP_ANDX=143, JSOP_GOSUBX=144, JSOP_CASEX=145, JSOP_DEFAULTX=146, JSOP_TABLESWITCHX=147, JSOP_LOOKUPSWITCHX=148, JSOP_BACKPATCH=149, JSOP_BACKPATCH_POP=150, JSOP_THROWING=151, JSOP_SETRVAL=152, JSOP_RETRVAL=153, JSOP_GETGVAR=154, JSOP_SETGVAR=155, JSOP_INCGVAR=156, JSOP_DECGVAR=157, JSOP_GVARINC=158, JSOP_GVARDEC=159, JSOP_REGEXP=160, JSOP_DEFXMLNS=161, JSOP_ANYNAME=162, JSOP_QNAMEPART=163, JSOP_QNAMECONST=164, JSOP_QNAME=165, JSOP_TOATTRNAME=166, JSOP_TOATTRVAL=167, JSOP_ADDATTRNAME=168, JSOP_ADDATTRVAL=169, JSOP_BINDXMLNAME=170, JSOP_SETXMLNAME=171, JSOP_XMLNAME=172, JSOP_DESCENDANTS=173, JSOP_FILTER=174, JSOP_ENDFILTER=175, JSOP_TOXML=176, JSOP_TOXMLLIST=177, JSOP_XMLTAGEXPR=178, JSOP_XMLELTEXPR=179, JSOP_XMLOBJECT=180, JSOP_XMLCDATA=181, JSOP_XMLCOMMENT=182, JSOP_XMLPI=183, JSOP_CALLPROP=184, JSOP_GETFUNNS=185, JSOP_FOREACH=186, JSOP_DELDESC=187, JSOP_UINT24=188, JSOP_INDEXBASE=189, JSOP_RESETBASE=190, JSOP_RESETBASE0=191, JSOP_STARTXML=192, JSOP_STARTXMLEXPR=193, JSOP_CALLELEM=194, JSOP_STOP=195, JSOP_GETXPROP=196, JSOP_CALLXMLNAME=197, JSOP_TYPEOFEXPR=198, JSOP_ENTERBLOCK=199, JSOP_LEAVEBLOCK=200, JSOP_GETLOCAL=201, JSOP_SETLOCAL=202, JSOP_INCLOCAL=203, JSOP_DECLOCAL=204, JSOP_LOCALINC=205, JSOP_LOCALDEC=206, JSOP_FORLOCAL=207, JSOP_FORCONST=208, JSOP_ENDITER=209, JSOP_GENERATOR=210, JSOP_YIELD=211, JSOP_ARRAYPUSH=212, JSOP_FOREACHKEYVAL=213, JSOP_ENUMCONSTELEM=214, JSOP_LEAVEBLOCKEXPR=215, JSOP_GETTHISPROP=216, JSOP_GETARGPROP=217, JSOP_GETVARPROP=218, JSOP_GETLOCALPROP=219, JSOP_INDEXBASE1=220, JSOP_INDEXBASE2=221, JSOP_INDEXBASE3=222, JSOP_CALLGVAR=223, JSOP_CALLVAR=224, JSOP_CALLARG=225, JSOP_CALLLOCAL=226, JSOP_INT8=227, JSOP_INT32=228, JSOP_LENGTH=229 } opCode; int length; unsigned int flags; char *eval_str; char *str; unsigned long objRef; union { char *s; double d; long i; } operand; int stackUse; unsigned long stackUseStart; int stackDef; unsigned long stackDefStart; unsigned long propUseScope; long propUseId; unsigned long propDefScope; long propDefId; unsigned long localUse; unsigned long localDef; unsigned long localDef2; int jmpOffset; int nvars; struct BasicBlock *inBlock; struct BasicBlock *nextBlock; unsigned long inCallee; unsigned long inFunction; } *lastInstr; struct ArrayList *instrs; struct ArrayList *preds; int count; int dfn; struct ArrayList *dominators; struct ArrayList *dominate; struct ArrayList *immDomPreds; struct ArrayList *immDomSuccs; struct ArrayList *reverseDominators; struct ArrayList *reverseDominate; struct ArrayList *reverseImmDomPreds; struct ArrayList *reverseImmDomSuccs; struct ArrayList *reverseDomFrontier; unsigned int flags; struct BasicBlock *calltarget; unsigned long inFunction; } *funcEntryBlock; char *funcName; struct ArrayList *funcBody; } *

variable_types: ttt double

user_defined_types: struct InstrList { int numInstrs; struct ArrayList *iList; }

user_defined_types: struct SyntaxTreeNode { int id; enum SyntaxTreeNodeType type; unsigned int flags; struct SyntaxTreeNode *parent; struct ArrayList *predsList; union { struct { int cfg_id; struct BasicBlock *cfgBlock; struct ArrayList *statements; } block; struct { struct ExpTreeNode *cond; struct NaturalLoop *loopStruct; struct BasicBlock *header; struct SyntaxTreeNode *synHeader; struct ArrayList *loopBody; struct ArrayList *loopBody2; int _bodyBranchType; } loop; struct { struct Function *funcStruct; struct ArrayList *funcBody; struct SyntaxTreeNode *synFuncEntryNode; } func; struct ExpTreeNode *expNode; struct { struct BasicBlock *targetBlock; struct SyntaxTreeNode *synTargetBlock; } go_to; struct { int _ifeq; struct ExpTreeNode *cond; struct ArrayList *if_path; struct ArrayList *else_path; } if_else; struct { struct ArrayList *try_body; struct ArrayList *catch_body; } try_catch; } u; }

user_defined_types: struct ExpTreeNode { enum ExpTreeNodeType type; unsigned int flags; union { char *name; double const_value_double; char *const_value_str; long const_value_int; _Bool const_value_bool; struct { char *name; enum Operator op; struct ExpTreeNode *lval; } un_op; struct { enum Operator op; struct ExpTreeNode *lval; struct ExpTreeNode *rval; } bin_op; struct { struct ExpTreeNode *name; int num_paras; struct ArrayList *parameters; struct BasicBlock *funcEntryBlock; } func; struct { struct ExpTreeNode *name; struct ExpTreeNode *index; } array_elm; struct { int size; struct ArrayList *initValues; } array_init; struct { struct ExpTreeNode *objName; struct ExpTreeNode *propName; } prop; struct { unsigned long targetAddr; enum Operator op; } tok; } u; }


destroyOpStack

decompiled_code:
void __fastcall destroyOpStack(void *ptr)
{
if ( ptr )
{
free(*((void **)ptr + 1));
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
if ( ptr )
{
free(*((void **)ptr + 1));
free(ptr);
}
}

original_code:
void destroyOpStack(OpStack *s){
 if(!s)
  return;
 free(s->stack);
 free(s);
 s=((void *)0);
 return;
}

canonical_original_code:
void destroyOpStack(struct OpStack *s){
 if(!s)
  return;
 free(s->stack);
 free(s);
 s=((void *)0);
 return;
}

user_defined_types: struct OpStack { int size; int sp; void **stack; void (*printFunc)(void *); }


pushOpStack

decompiled_code:
__int64 __fastcall pushOpStack(__int64 a1, __int64 a2)
{
__int64 result; // rax
int v4; // esi
void *v6; // rdi
void *v7; // rax

if ( !a1 )
_assert_fail("s", "stack_sim.c", 0x46u, "pushOpStack");
result = *(int *)(a1 + 4);
v4 = *(_DWORD *)a1;
v6 = *(void **)(a1 + 8);
if ( (int)result >= v4 )
{
v7 = realloc(v6, 16LL * v4);
v6 = v7;
if ( !v7 )
{
fwrite("ERROR: Memory shortage while resize OpStack\n", 1uLL, 0x2CuLL, stderr);
_assert_fail("0", "stack_sim.c", 0x4Du, "pushOpStack");
}
*(_QWORD *)(a1 + 8) = v7;
result = *(int *)(a1 + 4);
*(_DWORD *)a1 *= 2;
}
*(_DWORD *)(a1 + 4) = result + 1;
*((_QWORD *)v6 + result) = a2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
__int64 result; // rax
int v4; // esi
void *v6; // rdi
void *v7; // rax

if ( !a1 )
_assert_fail("s", "stack_sim.c", 0x46u, "pushOpStack");
result = *(int *)(a1 + 4);
v4 = *(_DWORD *)a1;
v6 = *(void **)(a1 + 8);
if ( (int)result >= v4 )
{
v7 = realloc(v6, 16LL * v4);
v6 = v7;
if ( !v7 )
{
fwrite("ERROR: Memory shortage while resize OpStack\n", 1uLL, 0x2CuLL, stderr);
_assert_fail("0", "stack_sim.c", 0x4Du, "pushOpStack");
}
*(_QWORD *)(a1 + 8) = v7;
result = *(int *)(a1 + 4);
*(_DWORD *)a1 *= 2;
}
*(_DWORD *)(a1 + 4) = result + 1;
*((_QWORD *)v6 + result) = a2;
return result;
}

original_code:
void pushOpStack(OpStack *s, void *item){
 ((void) sizeof ((s) ? 1 : 0), __extension__ ({ if (s) ; else __assert_fail ("s", "stack_sim.c", 70, __extension__ __PRETTY_FUNCTION__); }));
 void *temp;
 if(s->sp >= s->size){
  temp = realloc((void *)(s->stack), 2*(s->size)*sizeof(void *));
  if(temp==((void *)0)){
   fprintf(stderr, "ERROR: Memory shortage while resize OpStack\n");
   ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "stack_sim.c", 77, __extension__ __PRETTY_FUNCTION__); }));
  }
  s->size = s->size*2;
  s->stack = temp;
 }
 s->stack[s->sp++] = item;
 return;
}

canonical_original_code:
void pushOpStack(struct OpStack *s, void *item){
 ((void) sizeof ((s) ? 1 : 0), __extension__ ({ if (s) ; else __assert_fail ("s", "stack_sim.c", 70, __extension__ __PRETTY_FUNCTION__); }));
 void *temp;
 if(s->sp >= s->size){
  temp = realloc((void *)(s->stack), 2*(s->size)*sizeof(void *));
  if(temp==((void *)0)){
   fprintf(stderr, "ERROR: Memory shortage while resize OpStack\n");
   ((void) sizeof ((0) ? 1 : 0), __extension__ ({ if (0) ; else __assert_fail ("0", "stack_sim.c", 77, __extension__ __PRETTY_FUNCTION__); }));
  }
  s->size = s->size*2;
  s->stack = temp;
 }
 s->stack[s->sp++] = item;
 return;
}

variable_types:
item
void *

variable_types:
temp
void *


popOpStack

decompiled_code:
__int64 __fastcall popOpStack(__int64 a1)
{
int v1; // eax
int v2; // eax
__int64 v3; // rdx
__int64 result; // rax

if ( !a1 )
_assert_fail("s", "stack_sim.c", 0x57u, "popOpStack");
v1 = *(_DWORD *)(a1 + 4);
if ( v1 )
{
v2 = v1 - 1;
v3 = *(_QWORD *)(a1 + 8);
*(_DWORD *)(a1 + 4) = v2;
result = *(_QWORD *)(v3 + 8LL * v2);
}
else
{
fwrite("ERROR: Pop empty stack\n", 1uLL, 0x17uLL, stderr);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
int v1; // eax
int v2; // eax
__int64 v3; // rdx
__int64 result; // rax

if ( !a1 )
_assert_fail("s", "stack_sim.c", 0x57u, "popOpStack");
v1 = *(_DWORD *)(a1 + 4);
if ( v1 )
{
v2 = v1 - 1;
v3 = *(_QWORD *)(a1 + 8);
*(_DWORD *)(a1 + 4) = v2;
result = *(_QWORD *)(v3 + 8LL * v2);
}
else
{
fwrite("ERROR: Pop empty stack\n", 1uLL, 0x17uLL, stderr);
result = 0LL;
}
return result;
}

original_code:
void *popOpStack(OpStack *s){
 ((void) sizeof ((s) ? 1 : 0), __extension__ ({ if (s) ; else __assert_fail ("s", "stack_sim.c", 87, __extension__ __PRETTY_FUNCTION__); }));
 if(s->sp==0){
  fprintf(stderr, "ERROR: Pop empty stack\n");
  return ((void *)0);
 }
 return s->stack[--s->sp];
}

canonical_original_code:
void *popOpStack(struct OpStack *s){
 ((void) sizeof ((s) ? 1 : 0), __extension__ ({ if (s) ; else __assert_fail ("s", "stack_sim.c", 87, __extension__ __PRETTY_FUNCTION__); }));
 if(s->sp==0){
  fprintf(stderr, "ERROR: Pop empty stack\n");
  return ((void *)0);
 }
 return s->stack[--s->sp];
}

variable_types: struct OpStack { int size; int sp; void **stack; void (*printFunc)(void *); } *

return_type: void *


peekOpStack

decompiled_code:
__int64 __fastcall peekOpStack(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // r8

if ( !a1 )
_assert_fail("s", "stack_sim.c", 0x60u, "peekOpStack");
v1 = *(int *)(a1 + 4);
v2 = 0LL;
if ( (_DWORD)v1 )
v2 = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8 * v1 - 8);
return v2;
}

original_code:
void *peekOpStack(OpStack *s){
 ((void) sizeof ((s) ? 1 : 0), __extension__ ({ if (s) ; else __assert_fail ("s", "stack_sim.c", 96, __extension__ __PRETTY_FUNCTION__); }));
 if(s->sp==0)
  return ((void *)0);
 else
  return s->stack[s->sp-1];
}

canonical_original_code:
void *peekOpStack(struct OpStack *s){
 ((void) sizeof ((s) ? 1 : 0), __extension__ ({ if (s) ; else __assert_fail ("s", "stack_sim.c", 96, __extension__ __PRETTY_FUNCTION__); }));
 if(s->sp==0)
  return ((void *)0);
 else
  return s->stack[s->sp-1];
}


isOpStackEmpty

decompiled_code:
bool __fastcall isOpStackEmpty(__int64 a1)
{
if ( !a1 )
_assert_fail("s", "stack_sim.c", 0x68u, "isOpStackEmpty");
return *(_DWORD *)(a1 + 4) == 0;
}

canonical_decompiled_code:
bool __fastcall func4(__int64 a1)
{
if ( !a1 )
_assert_fail("s", "stack_sim.c", 0x68u, "isOpStackEmpty");
return *(_DWORD *)(a1 + 4) == 0;
}

original_code:
_Bool isOpStackEmpty(OpStack *s){
 ((void) sizeof ((s) ? 1 : 0), __extension__ ({ if (s) ; else __assert_fail ("s", "stack_sim.c", 104, __extension__ __PRETTY_FUNCTION__); }));
 if(s->sp==0)
  return 1;
 else
  return 0;
}

canonical_original_code:
_Bool isOpStackEmpty(struct OpStack *s){
 ((void) sizeof ((s) ? 1 : 0), __extension__ ({ if (s) ; else __assert_fail ("s", "stack_sim.c", 104, __extension__ __PRETTY_FUNCTION__); }));
 if(s->sp==0)
  return 1;
 else
  return 0;
}


printOpStack

decompiled_code:
int __fastcall printOpStack(__int64 a1)
{
int result; // eax
__int64 v3; // rbx
__int64 v4; // rdi
__int64 v5; // rsi
const void *v6; // rdx

if ( !a1 )
_assert_fail("s", "stack_sim.c", 0x70u, "printOpStack");
result = *(_DWORD *)(a1 + 4);
v3 = 0LL;
if ( result > 0 )
{
do
{
while ( *(_QWORD *)(a1 + 16) )
{
printf("#%-4d |", (unsigned int)v3);
v4 = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8 * v3++);
(*(void (__fastcall **)(__int64))(a1 + 16))(v4);
result = putchar(10);
if ( *(_DWORD *)(a1 + 4) <= (int)v3 )
return result;
}
v5 = (unsigned int)v3;
v6 = *(const void **)(*(_QWORD *)(a1 + 8) + 8 * v3++);
result = printf("#%-4d |_%16p_|\n", v5, v6);
}
while ( *(_DWORD *)(a1 + 4) > (int)v3 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func5(__int64 a1)
{
int result; // eax
__int64 v3; // rbx
__int64 v4; // rdi
__int64 v5; // rsi
const void *v6; // rdx

if ( !a1 )
_assert_fail("s", "stack_sim.c", 0x70u, "printOpStack");
result = *(_DWORD *)(a1 + 4);
v3 = 0LL;
if ( result > 0 )
{
do
{
while ( *(_QWORD *)(a1 + 16) )
{
printf("#%-4d |", (unsigned int)v3);
v4 = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8 * v3++);
(*(void (__fastcall **)(__int64))(a1 + 16))(v4);
result = putchar(10);
if ( *(_DWORD *)(a1 + 4) <= (int)v3 )
return result;
}
v5 = (unsigned int)v3;
v6 = *(const void **)(*(_QWORD *)(a1 + 8) + 8 * v3++);
result = printf("#%-4d |_%16p_|\n", v5, v6);
}
while ( *(_DWORD *)(a1 + 4) > (int)v3 );
}
return result;
}

original_code:
void printOpStack(OpStack *s){
 ((void) sizeof ((s) ? 1 : 0), __extension__ ({ if (s) ; else __assert_fail ("s", "stack_sim.c", 112, __extension__ __PRETTY_FUNCTION__); }));
 int i;
 for(i=0;i<s->sp;i++){
  if(s->printFunc==((void *)0))
   printf("#%-4d  |_%16p_|\n", i, s->stack[i]);
  else{
   printf("#%-4d  |", i);
   s->printFunc(s->stack[i]);
   printf("\n");
  }
 }
}

canonical_original_code:
void printOpStack(struct OpStack *s){
 ((void) sizeof ((s) ? 1 : 0), __extension__ ({ if (s) ; else __assert_fail ("s", "stack_sim.c", 112, __extension__ __PRETTY_FUNCTION__); }));
 int i;
 for(i=0;i<s->sp;i++){
  if(s->printFunc==((void *)0))
   printf("#%-4d  |_%16p_|\n", i, s->stack[i]);
  else{
   printf("#%-4d  |", i);
   s->printFunc(s->stack[i]);
   printf("\n");
  }
 }
}


countOpStack

decompiled_code:
__int64 __fastcall countOpStack(__int64 a1)
{
if ( !a1 )
_assert_fail("s", "stack_sim.c", 0x7Fu, "countOpStack");
return *(unsigned int *)(a1 + 4);
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
if ( !a1 )
_assert_fail("s", "stack_sim.c", 0x7Fu, "countOpStack");
return *(unsigned int *)(a1 + 4);
}

original_code:
int countOpStack(OpStack *s){
 ((void) sizeof ((s) ? 1 : 0), __extension__ ({ if (s) ; else __assert_fail ("s", "stack_sim.c", 127, __extension__ __PRETTY_FUNCTION__); }));
 return s->sp;
}

canonical_original_code:
int countOpStack(struct OpStack *s){
 ((void) sizeof ((s) ? 1 : 0), __extension__ ({ if (s) ; else __assert_fail ("s", "stack_sim.c", 127, __extension__ __PRETTY_FUNCTION__); }));
 return s->sp;
}


getOpCodeFromString

decompiled_code:
__int64 __fastcall getOpCodeFromString(char *s1)
{
int v1; // er12
__int64 v2; // rbx

if ( !s1 )
_assert_fail("name", "opcode.c", 0x35u, "getOpCodeFromString");
v1 = size;
if ( size )
{
if ( size <= 0 )
{
LABEL_9:
printf("ERROR: can't find opcode %s\n", s1);
abort();
}
}
else
{
size = 230;
v1 = 230;
}
v2 = 0LL;
while ( strcmp(s1, (&instrNames)[2 * v2]) )
{
if ( v1 <= (int)++v2 )
goto LABEL_9;
}
return LODWORD((&instrNames)[2 * (int)v2 + 1]);
}

canonical_decompiled_code:
__int64 __fastcall func0(char *s1)
{
int v1; // er12
__int64 v2; // rbx

if ( !s1 )
_assert_fail("name", "opcode.c", 0x35u, "getOpCodeFromString");
v1 = size;
if ( size )
{
if ( size <= 0 )
{
LABEL_9:
printf("ERROR: can't find opcode %s\n", s1);
abort();
}
}
else
{
size = 230;
v1 = 230;
}
v2 = 0LL;
while ( strcmp(s1, (&instrNames)[2 * v2]) )
{
if ( v1 <= (int)++v2 )
goto LABEL_9;
}
return LODWORD((&instrNames)[2 * (int)v2 + 1]);
}

original_code:
OpCode getOpCodeFromString(char *name){
 int i;
 int found;
 OpCode op;
 ((void) sizeof ((name) ? 1 : 0), __extension__ ({ if (name) ; else __assert_fail ("name", "opcode.c", 53, __extension__ __PRETTY_FUNCTION__); }));
 if(!size)
  size = sizeof(instrNames)/sizeof(name_op);
 found = 0;
 for(i=0;i<size;i++){
  if(!strcmp(name, instrNames[i].name)){
   op = instrNames[i].op;
   found++;
   break;
  }
 }
 if(!found){
  printf("ERROR: can't find opcode %s\n", name);
  abort();
 }
 return op;
}

canonical_original_code:
enum OpCode getOpCodeFromString(char *name){
 int i;
 int found;
 enum OpCode op;
 ((void) sizeof ((name) ? 1 : 0), __extension__ ({ if (name) ; else __assert_fail ("name", "opcode.c", 53, __extension__ __PRETTY_FUNCTION__); }));
 if(!size)
  size = sizeof(instrNames)/sizeof(name_op);
 found = 0;
 for(i=0;i<size;i++){
  if(!strcmp(name, instrNames[i].name)){
   op = instrNames[i].op;
   found++;
   break;
  }
 }
 if(!found){
  printf("ERROR: can't find opcode %s\n", name);
  abort();
 }
 return op;
}

variable_types:
name
char *

variable_types: found int

variable_types: enum OpCode { JSOP_NOP=0, JSOP_PUSH=1, JSOP_POPV=2, JSOP_ENTERWITH=3, JSOP_LEAVEWITH=4, JSOP_RETURN=5, JSOP_GOTO=6, JSOP_IFEQ=7, JSOP_IFNE=8, JSOP_ARGUMENTS=9, JSOP_FORARG=10, JSOP_FORVAR=11, JSOP_DUP=12, JSOP_DUP2=13, JSOP_SETCONST=14, JSOP_BITOR=15, JSOP_BITXOR=16, JSOP_BITAND=17, JSOP_EQ=18, JSOP_NE=19, JSOP_LT=20, JSOP_LE=21, JSOP_GT=22, JSOP_GE=23, JSOP_LSH=24, JSOP_RSH=25, JSOP_URSH=26, JSOP_ADD=27, JSOP_SUB=28, JSOP_MUL=29, JSOP_DIV=30, JSOP_MOD=31, JSOP_NOT=32, JSOP_BITNOT=33, JSOP_NEG=34, JSOP_NEW=35, JSOP_DELNAME=36, JSOP_DELPROP=37, JSOP_DELELEM=38, JSOP_TYPEOF=39, JSOP_VOID=40, JSOP_INCNAME=41, JSOP_INCPROP=42, JSOP_INCELEM=43, JSOP_DECNAME=44, JSOP_DECPROP=45, JSOP_DECELEM=46, JSOP_NAMEINC=47, JSOP_PROPINC=48, JSOP_ELEMINC=49, JSOP_NAMEDEC=50, JSOP_PROPDEC=51, JSOP_ELEMDEC=52, JSOP_GETPROP=53, JSOP_SETPROP=54, JSOP_GETELEM=55, JSOP_SETELEM=56, JSOP_CALLNAME=57, JSOP_CALL=58, JSOP_NAME=59, JSOP_DOUBLE=60, JSOP_STRING=61, JSOP_ZERO=62, JSOP_ONE=63, JSOP_NULL=64, JSOP_THIS=65, JSOP_FALSE=66, JSOP_TRUE=67, JSOP_OR=68, JSOP_AND=69, JSOP_TABLESWITCH=70, JSOP_LOOKUPSWITCH=71, JSOP_STRICTEQ=72, JSOP_STRICTNE=73, JSOP_CLOSURE=74, JSOP_EXPORTALL=75, JSOP_EXPORTNAME=76, JSOP_IMPORTALL=77, JSOP_IMPORTPROP=78, JSOP_IMPORTELEM=79, JSOP_OBJECT=80, JSOP_POP=81, JSOP_POS=82, JSOP_TRAP=83, JSOP_GETARG=84, JSOP_SETARG=85, JSOP_GETVAR=86, JSOP_SETVAR=87, JSOP_UINT16=88, JSOP_NEWINIT=89, JSOP_ENDINIT=90, JSOP_INITPROP=91, JSOP_INITELEM=92, JSOP_DEFSHARP=93, JSOP_USESHARP=94, JSOP_INCARG=95, JSOP_INCVAR=96, JSOP_DECARG=97, JSOP_DECVAR=98, JSOP_ARGINC=99, JSOP_VARINC=100, JSOP_ARGDEC=101, JSOP_VARDEC=102, JSOP_FORIN=103, JSOP_FORNAME=104, JSOP_FORPROP=105, JSOP_FORELEM=106, JSOP_POPN=107, JSOP_BINDNAME=108, JSOP_SETNAME=109, JSOP_THROW=110, JSOP_IN=111, JSOP_INSTANCEOF=112, JSOP_DEBUGGER=113, JSOP_GOSUB=114, JSOP_RETSUB=115, JSOP_EXCEPTION=116, JSOP_LINENO=117, JSOP_CONDSWITCH=118, JSOP_CASE=119, JSOP_DEFAULT=120, JSOP_EVAL=121, JSOP_ENUMELEM=122, JSOP_GETTER=123, JSOP_SETTER=124, JSOP_DEFFUN=125, JSOP_DEFCONST=126, JSOP_DEFVAR=127, JSOP_ANONFUNOBJ=128, JSOP_NAMEDFUNOBJ=129, JSOP_SETLOCALPOP=130, JSOP_GROUP=131, JSOP_SETCALL=132, JSOP_TRY=133, JSOP_FINALLY=134, JSOP_SWAP=135, JSOP_ARGSUB=136, JSOP_ARGCNT=137, JSOP_DEFLOCALFUN=138, JSOP_GOTOX=139, JSOP_IFEQX=140, JSOP_IFNEX=141, JSOP_ORX=142, JSOP_ANDX=143, JSOP_GOSUBX=144, JSOP_CASEX=145, JSOP_DEFAULTX=146, JSOP_TABLESWITCHX=147, JSOP_LOOKUPSWITCHX=148, JSOP_BACKPATCH=149, JSOP_BACKPATCH_POP=150, JSOP_THROWING=151, JSOP_SETRVAL=152, JSOP_RETRVAL=153, JSOP_GETGVAR=154, JSOP_SETGVAR=155, JSOP_INCGVAR=156, JSOP_DECGVAR=157, JSOP_GVARINC=158, JSOP_GVARDEC=159, JSOP_REGEXP=160, JSOP_DEFXMLNS=161, JSOP_ANYNAME=162, JSOP_QNAMEPART=163, JSOP_QNAMECONST=164, JSOP_QNAME=165, JSOP_TOATTRNAME=166, JSOP_TOATTRVAL=167, JSOP_ADDATTRNAME=168, JSOP_ADDATTRVAL=169, JSOP_BINDXMLNAME=170, JSOP_SETXMLNAME=171, JSOP_XMLNAME=172, JSOP_DESCENDANTS=173, JSOP_FILTER=174, JSOP_ENDFILTER=175, JSOP_TOXML=176, JSOP_TOXMLLIST=177, JSOP_XMLTAGEXPR=178, JSOP_XMLELTEXPR=179, JSOP_XMLOBJECT=180, JSOP_XMLCDATA=181, JSOP_XMLCOMMENT=182, JSOP_XMLPI=183, JSOP_CALLPROP=184, JSOP_GETFUNNS=185, JSOP_FOREACH=186, JSOP_DELDESC=187, JSOP_UINT24=188, JSOP_INDEXBASE=189, JSOP_RESETBASE=190, JSOP_RESETBASE0=191, JSOP_STARTXML=192, JSOP_STARTXMLEXPR=193, JSOP_CALLELEM=194, JSOP_STOP=195, JSOP_GETXPROP=196, JSOP_CALLXMLNAME=197, JSOP_TYPEOFEXPR=198, JSOP_ENTERBLOCK=199, JSOP_LEAVEBLOCK=200, JSOP_GETLOCAL=201, JSOP_SETLOCAL=202, JSOP_INCLOCAL=203, JSOP_DECLOCAL=204, JSOP_LOCALINC=205, JSOP_LOCALDEC=206, JSOP_FORLOCAL=207, JSOP_FORCONST=208, JSOP_ENDITER=209, JSOP_GENERATOR=210, JSOP_YIELD=211, JSOP_ARRAYPUSH=212, JSOP_FOREACHKEYVAL=213, JSOP_ENUMCONSTELEM=214, JSOP_LEAVEBLOCKEXPR=215, JSOP_GETTHISPROP=216, JSOP_GETARGPROP=217, JSOP_GETVARPROP=218, JSOP_GETLOCALPROP=219, JSOP_INDEXBASE1=220, JSOP_INDEXBASE2=221, JSOP_INDEXBASE3=222, JSOP_CALLGVAR=223, JSOP_CALLVAR=224, JSOP_CALLARG=225, JSOP_CALLLOCAL=226, JSOP_INT8=227, JSOP_INT32=228, JSOP_LENGTH=229 }


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

operant_comedi_device = comedi_open("/dev/comedi0");
printf(" fd = %p", (const void *)operant_comedi_device);
operant_comedi_device2 = comedi_open("/dev/comedi1");
printf(" fd2 = %p", (const void *)operant_comedi_device2);
result = 0LL;
operant_initialized = 1;
return result;
}

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

operant_comedi_device = comedi_open("/dev/comedi0");
printf(" fd = %p", (const void *)operant_comedi_device);
operant_comedi_device2 = comedi_open("/dev/comedi1");
printf(" fd2 = %p", (const void *)operant_comedi_device2);
result = 0LL;
operant_initialized = 1;
return result;
}

original_code:
int operant_init(){
  operant_comedi_device=comedi_open("/dev/comedi0");
  printf (" fd  = %p",operant_comedi_device);
  operant_comedi_device2=comedi_open("/dev/comedi1");
  printf (" fd2 = %p",operant_comedi_device2);
  operant_initialized=1;
  return 0;
}


decompiled_code:
__int64 operant_close()
{
comedi_close(operant_comedi_device);
return comedi_close(operant_comedi_device2);
}

canonical_decompiled_code:
__int64 func1()
{
comedi_close(operant_comedi_device);
return comedi_close(operant_comedi_device2);
}

original_code:
void operant_close()
{
  comedi_close(operant_comedi_device);
  comedi_close(operant_comedi_device2);
}


decompiled_code:
__int64 __fastcall set_base_io_chans(_DWORD *a1, _DWORD *a2, _DWORD *a3, _DWORD *a4, unsigned int a5)
{
__int64 result; // rax

switch ( a5 )
{
case 0u:
case 6u:
*a2 = 0;
result = 0LL;
*a4 = 8;
*a1 = 0;
*a3 = 0;
break;
case 1u:
case 7u:
*a2 = 16;
result = 0LL;
*a4 = 0;
*a1 = 0;
*a3 = 1;
break;
case 2u:
case 8u:
*a2 = 8;
result = 0LL;
*a4 = 16;
*a1 = 1;
*a3 = 1;
break;
case 3u:
case 9u:
*a2 = 0;
result = 0LL;
*a4 = 8;
*a1 = 2;
*a3 = 2;
break;
case 4u:
case 0xAu:
*a2 = 16;
result = 0LL;
*a4 = 0;
*a1 = 2;
*a3 = 3;
break;
case 5u:
case 0xBu:
*a2 = 8;
result = 0LL;
*a4 = 16;
*a1 = 3;
*a3 = 3;
break;
default:
printf("Error!: box %d not valid\n", a5);
result = 0LL;
*a4 = 0;
*a2 = 0;
*a3 = 0;
*a1 = 0;
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(_DWORD *a1, _DWORD *a2, _DWORD *a3, _DWORD *a4, unsigned int a5)
{
__int64 result; // rax

switch ( a5 )
{
case 0u:
case 6u:
*a2 = 0;
result = 0LL;
*a4 = 8;
*a1 = 0;
*a3 = 0;
break;
case 1u:
case 7u:
*a2 = 16;
result = 0LL;
*a4 = 0;
*a1 = 0;
*a3 = 1;
break;
case 2u:
case 8u:
*a2 = 8;
result = 0LL;
*a4 = 16;
*a1 = 1;
*a3 = 1;
break;
case 3u:
case 9u:
*a2 = 0;
result = 0LL;
*a4 = 8;
*a1 = 2;
*a3 = 2;
break;
case 4u:
case 0xAu:
*a2 = 16;
result = 0LL;
*a4 = 0;
*a1 = 2;
*a3 = 3;
break;
case 5u:
case 0xBu:
*a2 = 8;
result = 0LL;
*a4 = 16;
*a1 = 3;
*a3 = 3;
break;
default:
printf("Error!: box %d not valid\n", a5);
result = 0LL;
*a4 = 0;
*a2 = 0;
*a3 = 0;
*a1 = 0;
break;
}
return result;
}

original_code:
int set_base_io_chans(int *indev, int *input, int *outdev, int *output, int boxid)
{
  switch (boxid)
    {
    case 6:
    case 0:
      *input = 0;
      *output = 8;
      *indev = 0;
      *outdev = 0;
      break;
    case 7:
    case 1:
      *input = 16;
      *output = 0;
      *indev = 0;
      *outdev = 1;
      break;
    case 8:
    case 2:
      *input = 8;
      *output = 16;
      *indev = 1;
      *outdev = 1;
      break;
    case 9:
    case 3:
      *input = 0;
      *output = 8;
      *indev = 2;
      *outdev = 2;
      break;
    case 10:
    case 4:
      *input = 16;
      *output = 0;
      *indev = 2;
      *outdev = 3;
      break;
    case 11:
    case 5:
      *input = 8;
      *output = 16;
      *indev = 3;
      *outdev = 3;
      break;
    default:
      printf("Error!: box %d not valid\n", boxid);
      *indev=*outdev=*input=*output=0;
      break;
    }
  return 0;
}

variable_types:
indev
int *

variable_types:
input
int *

variable_types:
outdev
int *

variable_types:
output
int *

variable_types: boxid int


decompiled_code:
int __fastcall operant_write(int a1, __int64 a2, int a3)
{
int v3; // ebp
__int64 v6; // rdi
__int64 v7; // rsi
__int64 v8; // rdx
int v9; // [rsp+0h] [rbp-28h] BYREF
int v10; // [rsp+4h] [rbp-24h] BYREF
unsigned int v11; // [rsp+8h] [rbp-20h] BYREF
int v12[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v3 = a2;
if ( (unsigned int)a2 > 7 )
return printf("Channel #%d doesn't exist!\n", a2);
set_base_io_chans(&v9, &v10, &v11, v12, a1 - 1);
if ( a1 - 1 > 5 )
{
v7 = v11;
v6 = operant_comedi_device2;
v8 = (unsigned int)(v12[0] + 7 - v3);
if ( !a3 )
return comedi_dio_write(v6, v7, v8, 1LL);
}
else
{
v6 = operant_comedi_device;
v7 = v11;
v8 = (unsigned int)(v3 + v12[0]);
if ( !a3 )
return comedi_dio_write(v6, v7, v8, 1LL);
}
return comedi_dio_write(v6, v7, v8, 0LL);
}

canonical_decompiled_code:
int __fastcall func3(int a1, __int64 a2, int a3)
{
int v3; // ebp
__int64 v6; // rdi
__int64 v7; // rsi
__int64 v8; // rdx
int v9; // [rsp+0h] [rbp-28h] BYREF
int v10; // [rsp+4h] [rbp-24h] BYREF
unsigned int v11; // [rsp+8h] [rbp-20h] BYREF
int v12[7]; // [rsp+Ch] [rbp-1Ch] BYREF

v3 = a2;
if ( (unsigned int)a2 > 7 )
return printf("Channel #%d doesn't exist!\n", a2);
func2(&v9, &v10, &v11, v12, a1 - 1);
if ( a1 - 1 > 5 )
{
v7 = v11;
v6 = operant_comedi_device2;
v8 = (unsigned int)(v12[0] + 7 - v3);
if ( !a3 )
return comedi_dio_write(v6, v7, v8, 1LL);
}
else
{
v6 = operant_comedi_device;
v7 = v11;
v8 = (unsigned int)(v3 + v12[0]);
if ( !a3 )
return comedi_dio_write(v6, v7, v8, 1LL);
}
return comedi_dio_write(v6, v7, v8, 0LL);
}

original_code:
void operant_write(int box_id, int channel, int state)
{
  int indev, in, outdev,out;
  if(channel > 7 || channel <0)
      printf("Channel #%d doesn't exist!\n", channel);
  else{
    box_id--;
    set_base_io_chans(&indev, &in, &outdev, &out, box_id);
    if(box_id < 6)
      if (state)
 comedi_dio_write(operant_comedi_device,outdev,(out+channel), 0);
      else
 comedi_dio_write(operant_comedi_device,outdev,(out+channel), 1);
    else
      if (state){
 comedi_dio_write(operant_comedi_device2,outdev,(out+(7-channel)), 0);
      }
      else
 comedi_dio_write(operant_comedi_device2,outdev,(out+(7-channel)), 1);
  }
}

canonical_original_code:
void operant_write(int box_id, int channel, int state)
{
  int indev; int in; int outdev; int out;
  if(channel > 7 || channel <0)
      printf("Channel #%d doesn't exist!\n", channel);
  else{
    box_id--;
    set_base_io_chans(&indev, &in, &outdev, &out, box_id);
    if(box_id < 6)
      if (state)
 comedi_dio_write(operant_comedi_device,outdev,(out+channel), 0);
      else
 comedi_dio_write(operant_comedi_device,outdev,(out+channel), 1);
    else
      if (state){
 comedi_dio_write(operant_comedi_device2,outdev,(out+(7-channel)), 0);
      }
      else
 comedi_dio_write(operant_comedi_device2,outdev,(out+(7-channel)), 1);
  }
}

variable_types: channel int

variable_types: state int

variable_types: indev int

variable_types: in int

variable_types: outdev int

variable_types: out int


decompiled_code:
int __fastcall operant_clear(unsigned int a1)
{
unsigned int i; // ebx
__int64 v2; // rsi
int result; // eax

if ( !operant_initialized )
return printf("Attempted to clear box #%d without initializing\n", a1);
for ( i = 0; i != 8; ++i )
{
v2 = i;
result = operant_write(a1, v2, 0);
}
return result;
}

canonical_decompiled_code:
int __fastcall func4(unsigned int a1)
{
unsigned int i; // ebx
__int64 v2; // rsi
int result; // eax

if ( !operant_initialized )
return printf("Attempted to clear box #%d without initializing\n", a1);
for ( i = 0; i != 8; ++i )
{
v2 = i;
result = func3(a1, v2, 0);
}
return result;
}

original_code:
void operant_clear(int box_id)
{
  int i;
  if(operant_initialized)
    for(i=0; i<=7; i++)
      operant_write(box_id, i, 0);
  else
    printf("Attempted to clear box #%d without initializing\n", box_id);
}

variable_types: i int


decompiled_code:
__int64 __fastcall operant_read(int a1, __int64 a2)
{
__int64 result; // rax
unsigned int v3; // [rsp+0h] [rbp-28h] BYREF
int v4; // [rsp+4h] [rbp-24h] BYREF
int v5; // [rsp+8h] [rbp-20h] BYREF
int v6[7]; // [rsp+Ch] [rbp-1Ch] BYREF

if ( (unsigned int)a2 <= 7 )
{
set_base_io_chans(&v3, &v4, &v5, v6, a1 - 1);
if ( a1 - 1 <= 5 )
comedi_dio_read(operant_comedi_device, v3, (unsigned int)(a2 + v4), v6);
else
comedi_dio_read(operant_comedi_device2, v3, (unsigned int)(v4 + 7 - a2), v6);
result = v6[0] == 0;
}
else
{
printf("Channel #%d doesn't exist!\n", a2);
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1, __int64 a2)
{
__int64 result; // rax
unsigned int v3; // [rsp+0h] [rbp-28h] BYREF
int v4; // [rsp+4h] [rbp-24h] BYREF
int v5; // [rsp+8h] [rbp-20h] BYREF
int v6[7]; // [rsp+Ch] [rbp-1Ch] BYREF

if ( (unsigned int)a2 <= 7 )
{
func2(&v3, &v4, &v5, v6, a1 - 1);
if ( a1 - 1 <= 5 )
comedi_dio_read(operant_comedi_device, v3, (unsigned int)(a2 + v4), v6);
else
comedi_dio_read(operant_comedi_device2, v3, (unsigned int)(v4 + 7 - a2), v6);
result = v6[0] == 0;
}
else
{
printf("Channel #%d doesn't exist!\n", a2);
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int operant_read(int box_id, int channel)
{
  int indev, in, outdev,out;
  box_id--;
  if(channel > 7 || channel <0)
    {
      printf("Channel #%d doesn't exist!\n", channel);
      return -1;
    }
  else{
    set_base_io_chans(&indev, &in, &outdev, &out, box_id);
    if(box_id < 6)
      comedi_dio_read(operant_comedi_device,indev,in+channel, &out );
    else
      comedi_dio_read(operant_comedi_device2,indev,in+(7-channel), &out );
    return !out;
  }
}

canonical_original_code:
int operant_read(int box_id, int channel)
{
  int indev; int in; int outdev; int out;
  box_id--;
  if(channel > 7 || channel <0)
    {
      printf("Channel #%d doesn't exist!\n", channel);
      return -1;
    }
  else{
    set_base_io_chans(&indev, &in, &outdev, &out, box_id);
    if(box_id < 6)
      comedi_dio_read(operant_comedi_device,indev,in+channel, &out );
    else
      comedi_dio_read(operant_comedi_device2,indev,in+(7-channel), &out );
    return !out;
  }
}


repo: geodynamics/hc

original_code:
void hc_torsol(struct hcs *hc,
        int nrad,int nvis,int lmax,double *r,
        double **rv,double **visc, struct sh_lms *pvel_tor,
        struct sh_lms *tor_sol,double *tvec,
        unsigned short verbose)
{
  double coef,*vecnor,hold,rlast,rnext,tloc[2],*tvec1,*tvec2;
  double exp_fac[2],p[2][2],diflog,el,elp2,elm1,efdiff;
  int l,jvisp1,jvis,i,j,nvisp1,lmaxp1,os;
  unsigned short qvis;
  nvisp1 = nvis + 1;
  lmaxp1 = lmax+1;
  hc_dvecrealloc(rv,nvisp1,"hc_torsol: rv");
  hc_dvecrealloc(visc,nvisp1,"hc_torsol: visc");
  (*(*rv+(nvis))) = 1.1;
  (*(*visc+(nvis))) = (*(*visc+(nvis-1)));
  if(verbose)
    fprintf(stderr,"hc_torsol: toroidal velocities lmax %i and type %i\n",
     pvel_tor->lmax,pvel_tor->type);
  tvec1 = tvec;
  tvec2 = (tvec + hc->nradp2 * lmaxp1);
  for(l=1;l < lmaxp1;l++){
    el = (double)l;
    elp2 = el + 2.0;
    elm1 = el - 1.0;
    coef = 1.0 / (2.0 * el + 1.0);
    jvisp1 = 1;
    jvis = 0;
    rlast = r[0];
    tloc[0] = 1.0;
    tloc[1] = 0.0;
    os = l;
    tvec1[os] = tloc[0];
    tvec2[os] = tloc[1];
    for(i=1;i < hc->nradp2;i++){
      os += lmaxp1;
      qvis = 0;
      do{
 if((*(*rv+(jvisp1))) > r[i])
   qvis = 1;
 rnext = (*(*rv+(jvisp1)));
 if(qvis)
   rnext = r[i];
 diflog = log(rnext / rlast);
 exp_fac[0] = exp( el * diflog);
 exp_fac[1] = exp(-(el + 1.0) * diflog);
 efdiff = exp_fac[0] - exp_fac[1];
 p[0][0] = elp2 * exp_fac[0] + elm1 * exp_fac[1];
 p[0][1] = efdiff / (*(*visc+(jvis)));
 p[1][0] = elp2 * elm1 * (*(*visc+(jvis))) * efdiff;
 p[1][1] = elm1 * exp_fac[0] + elp2 * exp_fac[1];
 rlast = rnext;
 hold = tloc[0];
  tloc[0] = (p[0][0] * hold + p[0][1] * tloc[1]);
 tloc[1] = (p[1][0] * hold + p[1][1] * tloc[1]);
 tloc[0] *= coef;
 tloc[1] *= coef;
 if(!qvis){
   jvis = jvisp1;
   jvisp1++;
 }
      }while(!qvis);
      tvec1[os] = tloc[0];
      tvec2[os] = tloc[1];
    }
  }
  hc_hvecalloc(&vecnor,lmaxp1,"hc_torsol: vecnor");
  os = (hc->nradp2-1) * lmaxp1;
  vecnor[0] = 1.0;
  for(l=1;l < lmaxp1;l++)
    vecnor[l] = 1.0 / tvec1[os+l];
  for(i=os=0;i < hc->nradp2;i++,os+=lmaxp1)
    for(l=0;l < lmaxp1;l++){
      tvec1[os+l] *= vecnor[l];
      tvec2[os+l] *= vecnor[l];
    }
  free(vecnor);
  for(os=i=j=0;i < hc->nradp2;i++,os+=lmaxp1,j+=2){
    sh_aexp_equals_bexp_coeff((tor_sol+j+0),pvel_tor);
    sh_aexp_equals_bexp_coeff((tor_sol+j+1),pvel_tor);
    sh_scale_expansion_l_factor((tor_sol+j+0),(tvec1+os));
    sh_scale_expansion_l_factor((tor_sol+j+1),(tvec2+os));
  }
  if(verbose)
    fprintf(stderr,"hc_torsol: done\n");
}

canonical_original_code:
void hc_torsol(struct hcs *hc, int nrad, int nvis, int lmax, double *r, double **rv, double **visc, struct sh_lms *pvel_tor, struct sh_lms *tor_sol, double *tvec, unsigned short verbose)
{
  double coef; double *vecnor; double hold; double rlast; double rnext; double tloc[2]; double *tvec1; double *tvec2;
  double exp_fac[2]; double p[2][2]; double diflog; double el; double elp2; double elm1; double efdiff;
  int l; int jvisp1; int jvis; int i; int j; int nvisp1; int lmaxp1; int os;
  unsigned short qvis;
  nvisp1 = nvis + 1;
  lmaxp1 = lmax+1;
  hc_dvecrealloc(rv,nvisp1,"hc_torsol: rv");
  hc_dvecrealloc(visc,nvisp1,"hc_torsol: visc");
  (*(*rv+(nvis))) = 1.1;
  (*(*visc+(nvis))) = (*(*visc+(nvis-1)));
  if(verbose)
    fprintf(stderr,"hc_torsol: toroidal velocities lmax %i and type %i\n",
     pvel_tor->lmax,pvel_tor->type);
  tvec1 = tvec;
  tvec2 = (tvec + hc->nradp2 * lmaxp1);
  for(l=1;l < lmaxp1;l++){
    el = (double)l;
    elp2 = el + 2.0;
    elm1 = el - 1.0;
    coef = 1.0 / (2.0 * el + 1.0);
    jvisp1 = 1;
    jvis = 0;
    rlast = r[0];
    tloc[0] = 1.0;
    tloc[1] = 0.0;
    os = l;
    tvec1[os] = tloc[0];
    tvec2[os] = tloc[1];
    for(i=1;i < hc->nradp2;i++){
      os += lmaxp1;
      qvis = 0;
      do{
 if((*(*rv+(jvisp1))) > r[i])
   qvis = 1;
 rnext = (*(*rv+(jvisp1)));
 if(qvis)
   rnext = r[i];
 diflog = log(rnext / rlast);
 exp_fac[0] = exp( el * diflog);
 exp_fac[1] = exp(-(el + 1.0) * diflog);
 efdiff = exp_fac[0] - exp_fac[1];
 p[0][0] = elp2 * exp_fac[0] + elm1 * exp_fac[1];
 p[0][1] = efdiff / (*(*visc+(jvis)));
 p[1][0] = elp2 * elm1 * (*(*visc+(jvis))) * efdiff;
 p[1][1] = elm1 * exp_fac[0] + elp2 * exp_fac[1];
 rlast = rnext;
 hold = tloc[0];
  tloc[0] = (p[0][0] * hold + p[0][1] * tloc[1]);
 tloc[1] = (p[1][0] * hold + p[1][1] * tloc[1]);
 tloc[0] *= coef;
 tloc[1] *= coef;
 if(!qvis){
   jvis = jvisp1;
   jvisp1++;
 }
      }while(!qvis);
      tvec1[os] = tloc[0];
      tvec2[os] = tloc[1];
    }
  }
  hc_hvecalloc(&vecnor,lmaxp1,"hc_torsol: vecnor");
  os = (hc->nradp2-1) * lmaxp1;
  vecnor[0] = 1.0;
  for(l=1;l < lmaxp1;l++)
    vecnor[l] = 1.0 / tvec1[os+l];
  for(i=os=0;i < hc->nradp2;i++,os+=lmaxp1)
    for(l=0;l < lmaxp1;l++){
      tvec1[os+l] *= vecnor[l];
      tvec2[os+l] *= vecnor[l];
    }
  free(vecnor);
  for(os=i=j=0;i < hc->nradp2;i++,os+=lmaxp1,j+=2){
    sh_aexp_equals_bexp_coeff((tor_sol+j+0),pvel_tor);
    sh_aexp_equals_bexp_coeff((tor_sol+j+1),pvel_tor);
    sh_scale_expansion_l_factor((tor_sol+j+0),(tvec1+os));
    sh_scale_expansion_l_factor((tor_sol+j+1),(tvec2+os));
  }
  if(verbose)
    fprintf(stderr,"hc_torsol: done\n");
}

variable_types: struct hcs { int lmax; int sh_type; int nrad; double *r; double *dvisc; int nvis; double *visc; double *rvisc; int inho; double *dfact; double *rden; double rho_top_kg; struct sh_lms { int type; unsigned short spectral_init; int lmax; int lmaxp1; int lmbig; int lmsmall2; int n_lm; int n_plm; int npoints; unsigned short plm_computed; int old_lmax; double *alm; struct rick_module { double *gauss_z; double *cfac; double *lfac; double *plm_f1; double *sin_theta; double dphi; int nlat; unsigned short initialized; unsigned short was_called; int old_lmax; } rick; } *dens_anom; struct sh_lms *dens_anom_orig; double dens_scale; unsigned short compressible; int npb; double *rpb; double *fpb; unsigned short free_slip; struct pvels { int n; double *t; struct sh_lms *p; } pvel; struct hc_ps { int ncalled; double rho_scale; double alpha; unsigned short rho_init; int solver_kludge_l; unsigned short tor_init; } psp; unsigned short save_solution; struct sh_lms *pol_sol; double *rho; double *rprops; int nprops; unsigned short *qwrite; struct sh_lms *tor_sol; unsigned short initialized; unsigned short orig_danom_saved; double *lfac; int lfac_init; struct prem_model { double crho[-1]; double cvp[-1]; double cvs[-1]; double cvpv[-1]; double cvph[-1]; double cvsv[-1]; double cvsh[-1]; double ceta[-1]; double cqmu[13]; double cqkappa[13]; int n; int np; double rb[13]; double r[13]; double r0; char model_filename[2000]; unsigned short init; } prem[1]; unsigned short prem_init; double timesc; double visnor; double g; double gacc; double re; double avg_den_core; double secyr; double vel_scale; double stress_scale; double r_cmb; double *plm; unsigned short spectral_solution_computed; } *

variable_types: nrad int

variable_types: nvis int

variable_types: lmax int

variable_types:
r
double *

variable_types:
rv
double **

variable_types:
visc
double **

variable_types:
tvec
double *

variable_types:
verbose
unsigned short

variable_types: coef double

variable_types:
vecnor
double *

variable_types: hold double

variable_types: rlast double

variable_types: rnext double

variable_types:
tloc
double [2]

variable_types:
p
double [2][2]

variable_types: diflog double

variable_types: el double

variable_types: efdiff double

variable_types: l int

variable_types: jvis int

variable_types: j int

variable_types: os int

variable_types:
qvis
unsigned short

user_defined_types: struct hcs { int lmax; int sh_type; int nrad; double *r; double *dvisc; int nvis; double *visc; double *rvisc; int inho; double *dfact; double *rden; double rho_top_kg; struct sh_lms *dens_anom; struct sh_lms *dens_anom_orig; double dens_scale; unsigned short compressible; int npb; double *rpb; double *fpb; unsigned short free_slip; struct pvels pvel; struct hc_ps psp; unsigned short save_solution; struct sh_lms *pol_sol; double *rho; double *rprops; int nprops; unsigned short *qwrite; struct sh_lms *tor_sol; unsigned short initialized; unsigned short orig_danom_saved; double *lfac; int lfac_init; struct prem_model prem[1]; unsigned short prem_init; double timesc; double visnor; double g; double gacc; double re; double avg_den_core; double secyr; double vel_scale; double stress_scale; double r_cmb; double *plm; unsigned short spectral_solution_computed; }

user_defined_types: struct sh_lms { int type; unsigned short spectral_init; int lmax; int lmaxp1; int lmbig; int lmsmall2; int n_lm; int n_plm; int npoints; unsigned short plm_computed; int old_lmax; double *alm; struct rick_module rick; }


decompiled_code:
void __fastcall rick_cs2ab(double *a1, int a2)
{
double *v2; // rax
double v3; // xmm0_8

*a1 = *a1 * (double)a2;
if ( a2 > 2 )
{
v2 = a1 + 2;
do
{
v3 = *v2++;
*(v2 - 1) = v3 * ((double)a2 * 0.5);
}
while ( v2 != &a1[(unsigned int)(a2 - 3) + 3] );
}
}

canonical_decompiled_code:
void __fastcall func0(double *a1, int a2)
{
double *v2; // rax
double v3; // xmm0_8

*a1 = *a1 * (double)a2;
if ( a2 > 2 )
{
v2 = a1 + 2;
do
{
v3 = *v2++;
*(v2 - 1) = v3 * ((double)a2 * 0.5);
}
while ( v2 != &a1[(unsigned int)(a2 - 3) + 3] );
}
}

original_code:
void rick_cs2ab(double *rdata,int n)
{
  int i;
  double en;
  en = (double)n;
  rdata[0] *= en;
  en/=2.0;
  for(i=2;i<n;i++)
    rdata[i] *= en;
}

canonical_original_code:
void rick_cs2ab(double *rdata, int n)
{
  int i;
  double en;
  en = (double)n;
  rdata[0] *= en;
  en/=2.0;
  for(i=2;i<n;i++)
    rdata[i] *= en;
}

variable_types:
rdata
double *

variable_types: n int

variable_types: i int

variable_types: en double