AddRangeToWriteSet

decompiled_code:
void __fastcall AddRangeToWriteSet(_QWORD *a1, unsigned __int64 *a2)
{
int v3; // er14
unsigned int v4; // ebp
_QWORD *v5; // rbx
unsigned __int64 v6; // rax
unsigned __int64 v7; // rdx
unsigned __int64 v8; // rsi
unsigned __int64 v9; // rcx

if ( a2 )
{
if ( *a2 < a2[1] )
{
free(a2);
}
else
{
v3 = al_size(*a1);
if ( v3 > 0 )
{
v4 = 0;
do
{
v5 = (_QWORD *)al_get(*a1, v4);
v6 = *a2;
v7 = v5[1];
if ( *a2 + 1 < v7 || (v8 = a2[1], v9 = *v5, v8 - 1 > *v5) )
{
++v4;
}
else
{
if ( v7 > v8 )
v7 = a2[1];
a2[1] = v7;
if ( v6 < v9 )
v6 = v9;
*a2 = v6;
al_removeAt(*a1, v4);
free(v5);
v3 = al_size(*a1);
}
}
while ( v3 > (int)v4 );
}
al_add(*a1, a2);
}
}
}

canonical_decompiled_code:
void __fastcall func3(_QWORD *a1, unsigned __int64 *a2)
{
int v3; // er14
unsigned int v4; // ebp
_QWORD *v5; // rbx
unsigned __int64 v6; // rax
unsigned __int64 v7; // rdx
unsigned __int64 v8; // rsi
unsigned __int64 v9; // rcx

if ( a2 )
{
if ( *a2 < a2[1] )
{
free(a2);
}
else
{
v3 = al_size(*a1);
if ( v3 > 0 )
{
v4 = 0;
do
{
v5 = (_QWORD *)al_get(*a1, v4);
v6 = *a2;
v7 = v5[1];
if ( *a2 + 1 < v7 || (v8 = a2[1], v9 = *v5, v8 - 1 > *v5) )
{
++v4;
}
else
{
if ( v7 > v8 )
v7 = a2[1];
a2[1] = v7;
if ( v6 < v9 )
v6 = v9;
*a2 = v6;
al_removeAt(*a1, v4);
free(v5);
v3 = al_size(*a1);
}
}
while ( v3 > (int)v4 );
}
al_add(*a1, a2);
}
}
}

original_code:
void AddRangeToWriteSet(WriteSet *ws, Range *r) {
 if(r == ((void *)0)) {
  return;
 }
    if(r->max < r->min) {
     free(r);
        return;
    }
    int i;
    ADDRESS min, max;
    int len = al_size(ws->ranges);
    Range *temp = r;
    i = 0;
    while(i < len) {
        Range *next = (Range *)al_get(ws->ranges, i);
        if( ((temp->max+1) >= next->min) && ((temp->min-1) <= next->max) ) {
            min = temp->min;
            if(next->min < min) {
                min = next->min;
            }
            max = temp->max;
            if(next->max > max) {
                max = next->max;
            }
            temp->min = min;
            temp->max = max;
            al_removeAt(ws->ranges, i);
            free(next);
            len = al_size(ws->ranges);
        } else {
            i++;
        }
    }
    al_add(ws->ranges, temp);
}

canonical_original_code:
void AddRangeToWriteSet(struct WriteSet *ws, struct Range *r) {
 if(r == ((void *)0)) {
  return;
 }
    if(r->max < r->min) {
     free(r);
        return;
    }
    int i;
    unsigned long min; unsigned long max;
    int len = al_size(ws->ranges);
    struct Range *temp = r;
    i = 0;
    while(i < len) {
        struct Range *next = (Range *)al_get(ws->ranges, i);
        if( ((temp->max+1) >= next->min) && ((temp->min-1) <= next->max) ) {
            min = temp->min;
            if(next->min < min) {
                min = next->min;
            }
            max = temp->max;
            if(next->max > max) {
                max = next->max;
            }
            temp->min = min;
            temp->max = max;
            al_removeAt(ws->ranges, i);
            free(next);
            len = al_size(ws->ranges);
        } else {
            i++;
        }
    }
    al_add(ws->ranges, temp);
}

variable_types:
min
unsigned long

variable_types:
max
unsigned long

variable_types: len int

user_defined_types: struct Range { unsigned long max; unsigned long min; }


ValInWriteSet

decompiled_code:
__int64 __fastcall ValInWriteSet(_QWORD *a1, unsigned __int64 a2)
{
__int64 v2; // rbx
unsigned __int64 *v3; // rax
unsigned int v4; // ebp

v2 = al_iterator(*a1);
while ( (*(unsigned int (__fastcall **)(__int64))(v2 + 40))(v2) )
{
v3 = (unsigned __int64 *)(*(__int64 (__fastcall **)(__int64))(v2 + 32))(v2);
if ( v3[1] <= a2 && *v3 >= a2 )
{
v4 = 1;
goto LABEL_7;
}
}
v4 = 0;
LABEL_7:
free((void *)v2);
return v4;
}

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

v2 = al_iterator(*a1);
while ( (*(unsigned int (__fastcall **)(__int64))(v2 + 40))(v2) )
{
v3 = (unsigned __int64 *)(*(__int64 (__fastcall **)(__int64))(v2 + 32))(v2);
if ( v3[1] <= a2 && *v3 >= a2 )
{
v4 = 1;
goto LABEL_7;
}
}
v4 = 0;
LABEL_7:
free((void *)v2);
return v4;
}

original_code:
_Bool ValInWriteSet(WriteSet *ws, ADDRESS val) {
    _Bool valInWS = 0;
    Iterator *itr = al_iterator(ws->ranges);
    while (!valInWS && itr->it_hasNext(itr)) {
        Range *r = (Range *)itr->it_next(itr);
        if ((val >= r->min) && (val <= r->max) ) {
            valInWS = 1;
        }
    }
    free(itr);
    return (valInWS);
}

canonical_original_code:
_Bool ValInWriteSet(struct WriteSet *ws, unsigned long val) {
    _Bool valInWS = 0;
    struct Iterator *itr = al_iterator(ws->ranges);
    while (!valInWS && itr->it_hasNext(itr)) {
        struct Range *r = (Range *)itr->it_next(itr);
        if ((val >= r->min) && (val <= r->max) ) {
            valInWS = 1;
        }
    }
    free(itr);
    return (valInWS);
}

variable_types: struct WriteSet { 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 *); } *ranges; } *

variable_types:
val
unsigned long

variable_types: struct Iterator { void *it_dataStructure; void *it_current; void *it_opaque1; void *it_opaque2; void *(*it_next)(struct Iterator *); int (*it_hasNext)(struct Iterator *); void *(*it_remove)(struct Iterator *); } *

variable_types: struct Range { unsigned long max; unsigned long min; } *

user_defined_types: struct WriteSet { struct ArrayList *ranges; }

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


WriteSetIsEmpty

decompiled_code:
bool __fastcall WriteSetIsEmpty(_QWORD *a1)
{
bool result; // al
int v2; // edx
_QWORD *v3; // rax

result = 1;
if ( a1 )
{
v2 = al_size(*a1);
result = 1;
if ( v2 )
{
v3 = (_QWORD *)al_get(*a1, 0LL);
result = *v3 < v3[1];
}
}
return result;
}

canonical_decompiled_code:
bool __fastcall func5(_QWORD *a1)
{
bool result; // al
int v2; // edx
_QWORD *v3; // rax

result = 1;
if ( a1 )
{
v2 = al_size(*a1);
result = 1;
if ( v2 )
{
v3 = (_QWORD *)al_get(*a1, 0LL);
result = *v3 < v3[1];
}
}
return result;
}

original_code:
_Bool WriteSetIsEmpty(WriteSet *ws) {
 if(ws == ((void *)0)) {
  return (1);
 }
    int len = al_size(ws->ranges);
    if(len == 0) {
        return (1);
    }
    _Bool isEmpty = 0;
    Range *r = al_get(ws->ranges,0);
    if(r->max < r->min) {
        isEmpty = 1;
    }
    return (isEmpty);
}

canonical_original_code:
_Bool WriteSetIsEmpty(struct WriteSet *ws) {
 if(ws == ((void *)0)) {
  return (1);
 }
    int len = al_size(ws->ranges);
    if(len == 0) {
        return (1);
    }
    _Bool isEmpty = 0;
    struct Range *r = al_get(ws->ranges,0);
    if(r->max < r->min) {
        isEmpty = 1;
    }
    return (isEmpty);
}

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


WriteSetEquals

decompiled_code:
__int64 __fastcall WriteSetEquals(_QWORD *a1, _QWORD *a2)
{
unsigned int v2; // ebp
unsigned int i; // er15
unsigned __int64 *v4; // r12
unsigned __int64 j; // rbx
unsigned int v6; // eax
unsigned int k; // er15
unsigned __int64 *v8; // r12
unsigned __int64 l; // rbx
unsigned int v10; // eax
int v12; // [rsp+8h] [rbp-40h]
int v13; // [rsp+Ch] [rbp-3Ch]

v13 = al_size(*a1);
v12 = al_size(*a2);
if ( v13 <= 0 )
{
v2 = 1;
}
else
{
v2 = 1;
for ( i = 0; i != v13; ++i )
{
v4 = (unsigned __int64 *)al_get(*a1, i);
for ( j = v4[1]; *v4 >= j; ++j )
{
v6 = ValInWriteSet(a2, j);
if ( !(_BYTE)v6 )
v2 = v6;
}
}
}
if ( v12 > 0 )
{
for ( k = 0; k != v12; ++k )
{
v8 = (unsigned __int64 *)al_get(*a2, k);
for ( l = v8[1]; *v8 >= l; ++l )
{
v10 = ValInWriteSet(a1, l);
if ( !(_BYTE)v10 )
v2 = v10;
}
}
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func6(_QWORD *a1, _QWORD *a2)
{
unsigned int v2; // ebp
unsigned int i; // er15
unsigned __int64 *v4; // r12
unsigned __int64 j; // rbx
unsigned int v6; // eax
unsigned int k; // er15
unsigned __int64 *v8; // r12
unsigned __int64 l; // rbx
unsigned int v10; // eax
int v12; // [rsp+8h] [rbp-40h]
int v13; // [rsp+Ch] [rbp-3Ch]

v13 = al_size(*a1);
v12 = al_size(*a2);
if ( v13 <= 0 )
{
v2 = 1;
}
else
{
v2 = 1;
for ( i = 0; i != v13; ++i )
{
v4 = (unsigned __int64 *)al_get(*a1, i);
for ( j = v4[1]; *v4 >= j; ++j )
{
v6 = func4(a2, j);
if ( !(_BYTE)v6 )
v2 = v6;
}
}
}
if ( v12 > 0 )
{
for ( k = 0; k != v12; ++k )
{
v8 = (unsigned __int64 *)al_get(*a2, k);
for ( l = v8[1]; *v8 >= l; ++l )
{
v10 = func4(a1, l);
if ( !(_BYTE)v10 )
v2 = v10;
}
}
}
return v2;
}

original_code:
_Bool WriteSetEquals(WriteSet *ws1, WriteSet *ws2) {
    int i = 0;
    ADDRESS j = 0;
    _Bool same = 1;
    int sz1 = al_size(ws1->ranges);
    int sz2 = al_size(ws2->ranges);
    for (i = 0; i < sz1; i++) {
        Range *next1 = (Range *) al_get(ws1->ranges, i);
        for(j = next1->min; j <= next1->max; j++) {
            if(!ValInWriteSet(ws2, j)) {
                same = 0;
            }
        }
    }
    for (i = 0; i < sz2; i++) {
        Range *next2 = (Range *) al_get(ws2->ranges, i);
        for(j = next2->min; j <= next2->max; j++) {
            if(!ValInWriteSet(ws1, j)) {
                same = 0;
            }
        }
    }
    return (same);
}

canonical_original_code:
_Bool WriteSetEquals(struct WriteSet *ws1, struct WriteSet *ws2) {
    int i = 0;
    unsigned long j = 0;
    _Bool same = 1;
    int sz1 = al_size(ws1->ranges);
    int sz2 = al_size(ws2->ranges);
    for (i = 0; i < sz1; i++) {
        struct Range *next1 = (Range *) al_get(ws1->ranges, i);
        for(j = next1->min; j <= next1->max; j++) {
            if(!ValInWriteSet(ws2, j)) {
                same = 0;
            }
        }
    }
    for (i = 0; i < sz2; i++) {
        struct Range *next2 = (Range *) al_get(ws2->ranges, i);
        for(j = next2->min; j <= next2->max; j++) {
            if(!ValInWriteSet(ws1, j)) {
                same = 0;
            }
        }
    }
    return (same);
}

variable_types: i int

variable_types:
j
unsigned long


WriteSetsOverlap

decompiled_code:
__int64 __fastcall WriteSetsOverlap(_QWORD *a1, _QWORD *a2)
{
int v2; // eax
int v3; // er14
unsigned int v4; // er15
unsigned __int64 *v5; // rax
unsigned __int64 v6; // rbp
unsigned __int64 v7; // r12
unsigned int v8; // ebx
unsigned __int64 *v9; // rax
unsigned __int64 v10; // rdx
unsigned __int64 v11; // rcx
int v13; // [rsp+Ch] [rbp-3Ch]

v13 = al_size(*a1);
v2 = al_size(*a2);
if ( v13 <= 0 )
return 0LL;
v3 = v2;
v4 = 0;
while ( 1 )
{
v5 = (unsigned __int64 *)al_get(*a1, v4);
v6 = *v5;
v7 = v5[1];
if ( v3 > 0 )
break;
LABEL_11:
if ( v13 == ++v4 )
return 0LL;
}
v8 = 0;
while ( 1 )
{
v9 = (unsigned __int64 *)al_get(*a2, v8);
v10 = v6;
if ( *v9 <= v6 )
v10 = *v9;
v11 = v7;
if ( v9[1] >= v7 )
v11 = v9[1];
if ( v10 >= v11 )
return 1LL;
if ( v3 == ++v8 )
goto LABEL_11;
}
}

canonical_decompiled_code:
__int64 __fastcall func7(_QWORD *a1, _QWORD *a2)
{
int v2; // eax
int v3; // er14
unsigned int v4; // er15
unsigned __int64 *v5; // rax
unsigned __int64 v6; // rbp
unsigned __int64 v7; // r12
unsigned int v8; // ebx
unsigned __int64 *v9; // rax
unsigned __int64 v10; // rdx
unsigned __int64 v11; // rcx
int v13; // [rsp+Ch] [rbp-3Ch]

v13 = al_size(*a1);
v2 = al_size(*a2);
if ( v13 <= 0 )
return 0LL;
v3 = v2;
v4 = 0;
while ( 1 )
{
v5 = (unsigned __int64 *)al_get(*a1, v4);
v6 = *v5;
v7 = v5[1];
if ( v3 > 0 )
break;
LABEL_11:
if ( v13 == ++v4 )
return 0LL;
}
v8 = 0;
while ( 1 )
{
v9 = (unsigned __int64 *)al_get(*a2, v8);
v10 = v6;
if ( *v9 <= v6 )
v10 = *v9;
v11 = v7;
if ( v9[1] >= v7 )
v11 = v9[1];
if ( v10 >= v11 )
return 1LL;
if ( v3 == ++v8 )
goto LABEL_11;
}
}

original_code:
_Bool WriteSetsOverlap(WriteSet *ws1, WriteSet *ws2)
{
  Range *r1, *r2;
  int sz1 = al_size(ws1->ranges), sz2 = al_size(ws2->ranges);
  int i, j;
  ADDRESS max1, min1, max2, min2, newMax, newMin;
    for (i = 0; i < sz1; i++) {
      r1 = (Range *) al_get(ws1->ranges, i);
      max1 = r1->max;
      min1 = r1->min;
      for (j = 0; j < sz2; j++) {
        r2 = (Range *) al_get(ws2->ranges, j);
        max2 = r2->max;
        min2 = r2->min;
        newMax = (max1 < max2 ? max1 : max2);
        newMin = (min1 > min2 ? min1 : min2);
        if (newMin <= newMax) {
          return 1;
        }
      }
    }
    return 0;
}

canonical_original_code:
_Bool WriteSetsOverlap(struct WriteSet *ws1, struct WriteSet *ws2)
{
  struct Range *r1; struct Range *r2;
  int sz1 = al_size(ws1->ranges); int sz2 = al_size(ws2->ranges);
  int i; int j;
  unsigned long max1; unsigned long min1; unsigned long max2; unsigned long min2; unsigned long newMax; unsigned long newMin;
    for (i = 0; i < sz1; i++) {
      r1 = (struct Range *) al_get(ws1->ranges, i);
      max1 = r1->max;
      min1 = r1->min;
      for (j = 0; j < sz2; j++) {
        r2 = (struct Range *) al_get(ws2->ranges, j);
        max2 = r2->max;
        min2 = r2->min;
        newMax = (max1 < max2 ? max1 : max2);
        newMin = (min1 > min2 ? min1 : min2);
        if (newMin <= newMax) {
          return 1;
        }
      }
    }
    return 0;
}

variable_types: j int

variable_types:
newMax
unsigned long

variable_types:
newMin
unsigned long


RangeIsEmpty

decompiled_code:
bool __fastcall RangeIsEmpty(_QWORD *a1)
{
bool result; // al

result = 1;
if ( a1 )
result = *a1 < a1[1];
return result;
}

canonical_decompiled_code:
bool __fastcall func8(_QWORD *a1)
{
bool result; // al

result = 1;
if ( a1 )
result = *a1 < a1[1];
return result;
}

original_code:
_Bool RangeIsEmpty(Range *r) {
    _Bool isEmpty = 1;
    if(r && r->max >= r->min) {
        isEmpty = 0;
    }
    return (isEmpty);
}

canonical_original_code:
_Bool RangeIsEmpty(struct Range *r) {
    _Bool isEmpty = 1;
    if(r && r->max >= r->min) {
        isEmpty = 0;
    }
    return (isEmpty);
}


ScrubWriteSet

decompiled_code:
char __fastcall ScrubWriteSet(_QWORD *a1)
{
int v1; // eax
int v2; // er12
unsigned int v3; // ebp
_QWORD *v4; // rbx

v1 = al_size(*a1);
if ( v1 > 0 )
{
v2 = v1;
v3 = 0;
do
{
v4 = (_QWORD *)al_get(*a1, v3);
LOBYTE(v1) = RangeIsEmpty(v4);
if ( (_BYTE)v1 )
{
al_removeAt(*a1, v3);
free(v4);
v1 = al_size(*a1);
v2 = v1;
}
else
{
++v3;
}
}
while ( v2 > (int)v3 );
}
return v1;
}

canonical_decompiled_code:
char __fastcall func9(_QWORD *a1)
{
int v1; // eax
int v2; // er12
unsigned int v3; // ebp
_QWORD *v4; // rbx

v1 = al_size(*a1);
if ( v1 > 0 )
{
v2 = v1;
v3 = 0;
do
{
v4 = (_QWORD *)al_get(*a1, v3);
LOBYTE(v1) = func8(v4);
if ( (_BYTE)v1 )
{
al_removeAt(*a1, v3);
free(v4);
v1 = al_size(*a1);
v2 = v1;
}
else
{
++v3;
}
}
while ( v2 > (int)v3 );
}
return v1;
}

original_code:
void ScrubWriteSet(WriteSet *ws) {
    int size = al_size(ws->ranges);
    int cur = 0;
    while(cur < size) {
        Range *next = (Range *)al_get(ws->ranges, cur);
        if(RangeIsEmpty(next)) {
            al_removeAt(ws->ranges, cur);
            free(next);
            size = al_size(ws->ranges);
        } else {
            cur++;
        }
    }
}

canonical_original_code:
void ScrubWriteSet(struct WriteSet *ws) {
    int size = al_size(ws->ranges);
    int cur = 0;
    while(cur < size) {
        struct Range *next = (Range *)al_get(ws->ranges, cur);
        if(RangeIsEmpty(next)) {
            al_removeAt(ws->ranges, cur);
            free(next);
            size = al_size(ws->ranges);
        } else {
            cur++;
        }
    }
}

variable_types: size int

variable_types: cur int

return_type: void


RangeInWriteSet

decompiled_code:
__int64 __fastcall RangeInWriteSet(_QWORD *a1, _QWORD *a2)
{
__int64 result; // rax
int v3; // er13
unsigned int i; // ebx
_QWORD *v5; // rax

if ( !a2 )
return 0LL;
result = 0LL;
if ( *a2 >= a2[1] )
{
v3 = al_size(*a1);
if ( v3 <= 0 )
{
result = 0LL;
}
else
{
for ( i = 0; i != v3; ++i )
{
v5 = (_QWORD *)al_get(*a1, i);
if ( *a2 >= v5[1] && a2[1] <= *v5 )
return 1LL;
}
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(_QWORD *a1, _QWORD *a2)
{
__int64 result; // rax
int v3; // er13
unsigned int i; // ebx
_QWORD *v5; // rax

if ( !a2 )
return 0LL;
result = 0LL;
if ( *a2 >= a2[1] )
{
v3 = al_size(*a1);
if ( v3 <= 0 )
{
result = 0LL;
}
else
{
for ( i = 0; i != v3; ++i )
{
v5 = (_QWORD *)al_get(*a1, i);
if ( *a2 >= v5[1] && a2[1] <= *v5 )
return 1LL;
}
result = 0LL;
}
}
return result;
}

original_code:
_Bool RangeInWriteSet(WriteSet *ws, Range *r) {
  int i, sz;
    if((r == ((void *)0)) || (r->max < r->min)) {
        return (0);
    }
    _Bool inWS = 0;
    sz = al_size(ws->ranges);
    for (i = 0; i < sz && !inWS; i++) {
      Range *next = (Range *) al_get(ws->ranges, i);
        if( (r->max >= next->min) && (r->min <= next->max) ) {
            inWS = 1;
        }
    }
    return (inWS);
}

canonical_original_code:
_Bool RangeInWriteSet(struct WriteSet *ws, struct Range *r) {
  int i; int sz;
    if((r == ((void *)0)) || (r->max < r->min)) {
        return (0);
    }
    _Bool inWS = 0;
    sz = al_size(ws->ranges);
    for (i = 0; i < sz && !inWS; i++) {
      struct Range *next = (Range *) al_get(ws->ranges, i);
        if( (r->max >= next->min) && (r->min <= next->max) ) {
            inWS = 1;
        }
    }
    return (inWS);
}

variable_types: sz int


PrintWriteSet

decompiled_code:
int __fastcall PrintWriteSet(_QWORD *a1)
{
fPrintWriteSet(stdout, a1);
return fputc(10, stdout);
}

canonical_decompiled_code:
int __fastcall func12(_QWORD *a1)
{
func11(stdout, a1);
return fputc(10, stdout);
}

original_code:
void PrintWriteSet(WriteSet *ws) {
    fPrintWriteSet(stdout, ws);
    fprintf(stdout, "\n");
}

canonical_original_code:
void PrintWriteSet(struct WriteSet *ws) {
    fPrintWriteSet(stdout, ws);
    fprintf(stdout, "\n");
}


WriteSetSubsetOfWriteSet

decompiled_code:
__int64 __fastcall WriteSetSubsetOfWriteSet(_QWORD *a1, _QWORD *a2)
{
unsigned int v2; // eax
unsigned int v3; // ebx
int v5; // er14
unsigned int i; // ebp
_QWORD *v7; // rax

LOBYTE(v2) = WriteSetIsEmpty(a1);
v3 = v2;
if ( !(_BYTE)v2 && !WriteSetIsEmpty(a2) )
{
v5 = al_size(*a1);
if ( v5 <= 0 )
{
v3 = 1;
}
else
{
for ( i = 0; i != v5; ++i )
{
v7 = (_QWORD *)al_get(*a1, i);
v3 = RangeInWriteSet(a2, v7);
if ( !(_BYTE)v3 )
break;
}
}
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func13(_QWORD *a1, _QWORD *a2)
{
unsigned int v2; // eax
unsigned int v3; // ebx
int v5; // er14
unsigned int i; // ebp
_QWORD *v7; // rax

LOBYTE(v2) = func5(a1);
v3 = v2;
if ( !(_BYTE)v2 && !func5(a2) )
{
v5 = al_size(*a1);
if ( v5 <= 0 )
{
v3 = 1;
}
else
{
for ( i = 0; i != v5; ++i )
{
v7 = (_QWORD *)al_get(*a1, i);
v3 = func10(a2, v7);
if ( !(_BYTE)v3 )
break;
}
}
}
return v3;
}

original_code:
_Bool WriteSetSubsetOfWriteSet(WriteSet *ws_sub, WriteSet *ws_super) {
  int i, sz;
  if (WriteSetIsEmpty(ws_sub)) {
    return 1;
  }
  if (WriteSetIsEmpty(ws_super)) {
    return 0;
  }
  sz = al_size(ws_sub->ranges);
  for (i = 0; i < sz; i++) {
    Range *r = (Range *) al_get(ws_sub->ranges, i);
    if (!RangeInWriteSet(ws_super, r)) {
      return 0;
    }
  }
  return 1;
}

canonical_original_code:
_Bool WriteSetSubsetOfWriteSet(struct WriteSet *ws_sub, struct WriteSet *ws_super) {
  int i; int sz;
  if (WriteSetIsEmpty(ws_sub)) {
    return 1;
  }
  if (WriteSetIsEmpty(ws_super)) {
    return 0;
  }
  sz = al_size(ws_sub->ranges);
  for (i = 0; i < sz; i++) {
    struct Range *r = (Range *) al_get(ws_sub->ranges, i);
    if (!RangeInWriteSet(ws_super, r)) {
      return 0;
    }
  }
  return 1;
}


alloc

decompiled_code:
void *__fastcall alloc(int a1)
{
void *v1; // rbx

v1 = malloc(a1);
if ( !v1 )
fwrite("ALLOC: Out of memory\n", 1uLL, 0x15uLL, stderr);
return v1;
}

canonical_decompiled_code:
void *__fastcall func0(int a1)
{
void *v1; // rbx

v1 = malloc(a1);
if ( !v1 )
fwrite("ALLOC: Out of memory\n", 1uLL, 0x15uLL, stderr);
return v1;
}

original_code:
void *alloc(int size) {
    void *new = malloc(size);
    if(new == ((void *)0)) {
        fprintf(stderr,"ALLOC: Out of memory\n");
    }
    return (new);
}

variable_types:
new
void *

return_type: void *


dealloc

decompiled_code:
void __fastcall dealloc(void *a1)
{
free(a1);
}

canonical_decompiled_code:
void __fastcall func1(void *a1)
{
free(a1);
}

original_code:
void dealloc(void *ptr) {
    free(ptr);
}

canonical_original_code:
void dealloc(void *ptr) {
    free(ptr);
}

variable_types:
ptr
void *


resize

decompiled_code:
void *__fastcall resize(void *a1, int a2)
{
void *v2; // rbx

v2 = realloc(a1, a2);
if ( !v2 )
fwrite("RESIZE: Out of memory\n", 1uLL, 0x16uLL, stderr);
return v2;
}

canonical_decompiled_code:
void *__fastcall func2(void *a1, int a2)
{
void *v2; // rbx

v2 = realloc(a1, a2);
if ( !v2 )
fwrite("RESIZE: Out of memory\n", 1uLL, 0x16uLL, stderr);
return v2;
}

original_code:
void *resize(void *address, int newsize) {
    void *mem;
    mem = realloc(address, newsize);
    if (mem == ((void *)0)) {
        fprintf(stderr,"RESIZE: Out of memory\n");
    }
    return (mem);
}

variable_types:
address
void *

variable_types: newsize int

variable_types:
mem
void *


refCompare

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

canonical_decompiled_code:
__int64 __fastcall func3(__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;
}

return_type: int


intCompare

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

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

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


strCompare

decompiled_code:
int __fastcall strCompare(const char *a1, const char *a2)
{
return strcmp(a1, a2);
}

canonical_decompiled_code:
int __fastcall func5(const char *a1, const char *a2)
{
return strcmp(a1, a2);
}

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; // rcx
unsigned __int64 v3; // rdx
__int64 result; // rax

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

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2)
{
unsigned __int64 v2; // rcx
unsigned __int64 v3; // rdx
__int64 result; // rax

v2 = *(_QWORD *)(a1 + 8);
v3 = *(_QWORD *)(a2 + 8);
result = 0xFFFFFFFFLL;
if ( v2 >= v3 )
result = v2 > v3;
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; }


insCompareByOrder

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

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

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

result = 0xFFFFFFFFLL;
if ( *a1 >= *a2 )
result = *a1 > *a2;
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 }


intPrint

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

canonical_decompiled_code:
int __fastcall func8(__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 *


refPrint

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

canonical_decompiled_code:
int __fastcall func9(__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 func10(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; // er12
unsigned int *v5; // r14
__int64 v6; // r13
__int64 v7; // rbx
__int64 v8; // r15
int j; // er12
int result; // eax
__int64 v11; // r15
__int64 v12; // rbx
int m; // er13
unsigned int *v14; // rax
int n; // ebx
__int64 v16; // rbp
__int64 v17; // rax
double v18; // rbx
__int64 v19; // rbx
__int64 v20; // r13
__int64 v21; // r12
__int64 v22; // rbp
int i; // ebx
__int64 v24; // rax
unsigned int *v25; // rax
int k; // ebx
__int64 v27; // rbp
int l; // ebx
__int64 v29; // rax
__int64 v30; // rbx
unsigned int v31; // eax
__int64 v32; // [rsp+0h] [rbp-88h]
__int64 v33; // [rsp+0h] [rbp-88h]
int v34; // [rsp+8h] [rbp-80h]
int v35; // [rsp+10h] [rbp-78h]
int v36; // [rsp+1Ch] [rbp-6Ch]
__int64 v37; // [rsp+20h] [rbp-68h]
__int64 v38; // [rsp+20h] [rbp-68h]
__int64 v39; // [rsp+28h] [rbp-60h]
__int64 v40; // [rsp+30h] [rbp-58h] BYREF
struct timezone tz; // [rsp+38h] [rbp-50h] BYREF
struct timeval tv; // [rsp+40h] [rbp-48h] BYREF

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

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
int v4; // er12
unsigned int *v5; // r14
__int64 v6; // r13
__int64 v7; // rbx
__int64 v8; // r15
int j; // er12
int result; // eax
__int64 v11; // r15
__int64 v12; // rbx
int m; // er13
unsigned int *v14; // rax
int n; // ebx
__int64 v16; // rbp
__int64 v17; // rax
double v18; // rbx
__int64 v19; // rbx
__int64 v20; // r13
__int64 v21; // r12
__int64 v22; // rbp
int i; // ebx
__int64 v24; // rax
unsigned int *v25; // rax
int k; // ebx
__int64 v27; // rbp
int l; // ebx
__int64 v29; // rax
__int64 v30; // rbx
unsigned int v31; // eax
__int64 v32; // [rsp+0h] [rbp-88h]
__int64 v33; // [rsp+0h] [rbp-88h]
int v34; // [rsp+8h] [rbp-80h]
int v35; // [rsp+10h] [rbp-78h]
int v36; // [rsp+1Ch] [rbp-6Ch]
__int64 v37; // [rsp+20h] [rbp-68h]
__int64 v38; // [rsp+20h] [rbp-68h]
__int64 v39; // [rsp+28h] [rbp-60h]
__int64 v40; // [rsp+30h] [rbp-58h] BYREF
struct timezone tz; // [rsp+38h] [rbp-50h] BYREF
struct timeval tv; // [rsp+40h] [rbp-48h] BYREF

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

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: 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 v2; // rdx
__int64 result; // rax
void *v4; // rax

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

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
__int64 v2; // rdx
__int64 result; // rax
void *v4; // rax

if ( !a1 )
_assert_fail("s", "stack_sim.c", 0x46u, "pushOpStack");
if ( *(_DWORD *)(a1 + 4) >= *(_DWORD *)a1 )
{
v4 = realloc(*(void **)(a1 + 8), 16LL * *(_DWORD *)a1);
if ( !v4 )
{
fwrite("ERROR: Memory shortage while resize OpStack\n", 1uLL, 0x2CuLL, stderr);
_assert_fail("0", "stack_sim.c", 0x4Du, "pushOpStack");
}
*(_DWORD *)a1 *= 2;
*(_QWORD *)(a1 + 8) = v4;
}
v2 = *(_QWORD *)(a1 + 8);
LODWORD(result) = *(_DWORD *)(a1 + 4);
*(_DWORD *)(a1 + 4) = result + 1;
result = (int)result;
*(_QWORD *)(v2 + 8LL * (int)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
__int64 v2; // rdx
int v3; // eax
__int64 result; // rax

if ( !a1 )
_assert_fail("s", "stack_sim.c", 0x57u, "popOpStack");
v1 = *(_DWORD *)(a1 + 4);
if ( v1 )
{
v2 = *(_QWORD *)(a1 + 8);
v3 = v1 - 1;
*(_DWORD *)(a1 + 4) = v3;
result = *(_QWORD *)(v2 + 8LL * v3);
}
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
__int64 v2; // rdx
int v3; // eax
__int64 result; // rax

if ( !a1 )
_assert_fail("s", "stack_sim.c", 0x57u, "popOpStack");
v1 = *(_DWORD *)(a1 + 4);
if ( v1 )
{
v2 = *(_QWORD *)(a1 + 8);
v3 = v1 - 1;
*(_DWORD *)(a1 + 4) = v3;
result = *(_QWORD *)(v2 + 8LL * v3);
}
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 *); } *


peekOpStack

decompiled_code:
__int64 __fastcall peekOpStack(__int64 a1)
{
int v1; // eax
__int64 v2; // rdx

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

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
int v1; // eax
__int64 v2; // rdx

if ( !a1 )
_assert_fail("s", "stack_sim.c", 0x60u, "peekOpStack");
v1 = *(_DWORD *)(a1 + 4);
v2 = 0LL;
if ( v1 )
v2 = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL * 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)
{
__int64 i; // rbx
int result; // eax

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

canonical_decompiled_code:
int __fastcall func5(__int64 a1)
{
__int64 i; // rbx
int result; // eax

if ( !a1 )
_assert_fail("s", "stack_sim.c", 0x70u, "printOpStack");
for ( i = 0LL; *(_DWORD *)(a1 + 4) > (int)i; ++i )
{
if ( *(_QWORD *)(a1 + 16) )
{
printf("#%-4d |", (unsigned int)i);
(*(void (__fastcall **)(_QWORD))(a1 + 16))(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 8 * i));
result = putchar(10);
}
else
{
result = printf("#%-4d |_%16p_|\n", (unsigned int)i, *(const void **)(*(_QWORD *)(a1 + 8) + 8 * i));
}
}
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; // er13
__int64 v2; // rbx

if ( !s1 )
_assert_fail("name", "opcode.c", 0x35u, "getOpCodeFromString");
v1 = size;
if ( size )
{
if ( size <= 0 )
{
LABEL_7:
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_7;
}
return LODWORD((&instrNames)[2 * (int)v2 + 1]);
}

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

if ( !s1 )
_assert_fail("name", "opcode.c", 0x35u, "getOpCodeFromString");
v1 = size;
if ( size )
{
if ( size <= 0 )
{
LABEL_7:
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_7;
}
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()
{
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);
operant_initialized = 1;
return 0LL;
}

canonical_decompiled_code:
__int64 func0()
{
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);
operant_initialized = 1;
return 0LL;
}

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