decompiled_code:
char *__fastcall ucpcal_date_friendly(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, __int64 a9)
{
__int64 v10; // r9
__int64 v11; // rax
const char *v12; // rcx

if ( (unsigned int)a9 <= 0x17
&& (unsigned int)(HIDWORD(a8) - 1) <= 0x1E
&& a7 >= 0
&& (unsigned int)(a8 - 1) <= 0xB
&& HIDWORD(a9) <= 0x3B
&& (_DWORD)a7 )
{
v10 = (unsigned int)((int)a9 % 12);
if ( !((int)a9 % 12) )
v10 = 12LL;
v11 = 112LL;
v12 = (const char *)months_1[(int)a8];
if ( (int)a9 <= 11 )
v11 = 97LL;
if ( HIDWORD(a9) )
sprintf(result_0, "%d %s %d, %d:%02d %cm", HIDWORD(a8), v12, HIDWORD(a7), v10, HIDWORD(a9), v11);
else
sprintf(result_0, "%d %s %d, %d %cm", HIDWORD(a8), v12, HIDWORD(a7), v10, v11);
}
else
{
strcpy((char *)&qword_270, "/or time");
*(__m128i *)result_0 = _mm_load_si128((const __m128i *)&LC8);
}
return result_0;
}

canonical_decompiled_code:
char *__fastcall func1(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, __int64 a7, __int64 a8, __int64 a9)
{
__int64 v10; // r9
__int64 v11; // rax
const char *v12; // rcx

if ( (unsigned int)a9 <= 0x17
&& (unsigned int)(HIDWORD(a8) - 1) <= 0x1E
&& a7 >= 0
&& (unsigned int)(a8 - 1) <= 0xB
&& HIDWORD(a9) <= 0x3B
&& (_DWORD)a7 )
{
v10 = (unsigned int)((int)a9 % 12);
if ( !((int)a9 % 12) )
v10 = 12LL;
v11 = 112LL;
v12 = (const char *)months_1[(int)a8];
if ( (int)a9 <= 11 )
v11 = 97LL;
if ( HIDWORD(a9) )
sprintf(result_0, "%d %s %d, %d:%02d %cm", HIDWORD(a8), v12, HIDWORD(a7), v10, HIDWORD(a9), v11);
else
sprintf(result_0, "%d %s %d, %d %cm", HIDWORD(a8), v12, HIDWORD(a7), v10, v11);
}
else
{
strcpy((char *)&qword_270, "/or time");
*(__m128i *)result_0 = _mm_load_si128((const __m128i *)&LC8);
}
return result_0;
}

original_code:
const char *ucpcal_date_friendly(ucpcal_date date) {
 static char result[64] = "";
 static const char *months[] = {
  ((void *)0), "January", "February", "March", "April",
  "May", "June", "July", "August",
  "September", "October", "November", "December"
 };
 if (
  date.year >= 0 &&
  date.month >= 1 && date.month <= 12 &&
  date.day >= 1 && date.day <= 31 &&
  date.hour >= 0 && date.hour <= 23 &&
  date.minute >= 0 && date.minute <= 59 &&
  date.good
 ) {
  int hour = date.hour % 12;
  if (hour == 0)
   hour = 12;
  if (date.minute)
   sprintf(
    result,
    "%d %s %d, %d:%02d %cm",
    date.day,
    months[date.month],
    date.year,
    hour,
    date.minute,
    date.hour > 11 ? 'p' : 'a'
   );
  else
   sprintf(
    result,
    "%d %s %d, %d %cm",
    date.day,
    months[date.month],
    date.year,
    hour,
    date.hour > 11 ? 'p' : 'a'
   );
 } else {
  strcpy(result, "invalid date and/or time");
 }
 return result;
}

canonical_original_code:
char *ucpcal_date_friendly(struct ucpcal_date date) {
 static char result[64] = "";
 static char *months[] = {
  ((void *)0), "January", "February", "March", "April",
  "May", "June", "July", "August",
  "September", "October", "November", "December"
 };
 if (
  date.year >= 0 &&
  date.month >= 1 && date.month <= 12 &&
  date.day >= 1 && date.day <= 31 &&
  date.hour >= 0 && date.hour <= 23 &&
  date.minute >= 0 && date.minute <= 59 &&
  date.good
 ) {
  int hour = date.hour % 12;
  if (hour == 0)
   hour = 12;
  if (date.minute)
   sprintf(
    result,
    "%d %s %d, %d:%02d %cm",
    date.day,
    months[date.month],
    date.year,
    hour,
    date.minute,
    date.hour > 11 ? 'p' : 'a'
   );
  else
   sprintf(
    result,
    "%d %s %d, %d %cm",
    date.day,
    months[date.month],
    date.year,
    hour,
    date.hour > 11 ? 'p' : 'a'
   );
 } else {
  strcpy(result, "invalid date and/or time");
 }
 return result;
}

variable_types: struct ucpcal_date { int good; int year; int month; int day; int hour; int minute; }

variable_types:
months
char *[]

variable_types: hour int


main

canonical_name: main

repo: dellelce/usleep

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v4; // edi

v4 = 100;
if ( argc > 1 )
{
v4 = atoi(argv[1]);
if ( !v4 )
v4 = 100;
}
usleep(v4);
return 0;
}

original_code:
int
main (int argc, char **argv)
{
  unsigned int secs;
  if (argc < 2)
  {
    secs = 100;
  }
  else
  {
    secs = atoi(argv[1]);
  }
  if (secs == 0) secs = 100;
  usleep((useconds_t)secs);
  return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
  unsigned int secs;
  if (argc < 2)
  {
    secs = 100;
  }
  else
  {
    secs = atoi(argv[1]);
  }
  if (secs == 0) secs = 100;
  usleep((unsigned int)secs);
  return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types:
secs
unsigned int

return_type: int


printUsage

repo: deloschang/search-engine

decompiled_code:
int printUsage()
{
puts("Normal Usage: ./indexer [TARGET DIRECTORY] [RESULTS FILENAME]");
return puts("Testing Usage: ./indexer [TARGET DIRECTORY] [RESULTS FILENAME] [RESULTS FILENAME] [REWRITTEN FILENAME]");
}

canonical_decompiled_code:
int func0()
{
puts("Normal Usage: ./indexer [TARGET DIRECTORY] [RESULTS FILENAME]");
return puts("Testing Usage: ./indexer [TARGET DIRECTORY] [RESULTS FILENAME] [RESULTS FILENAME] [REWRITTEN FILENAME]");
}

original_code:
void printUsage(){
    printf("Normal Usage: ./indexer [TARGET DIRECTORY] [RESULTS FILENAME]\n");
    printf("Testing Usage: ./indexer [TARGET DIRECTORY] [RESULTS FILENAME] [RESULTS FILENAME] [REWRITTEN FILENAME]\n");
}

return_type: void


validateArgs

decompiled_code:
void __fastcall validateArgs(unsigned int a1, __int64 a2)
{
const char *v2; // r13
size_t v3; // r12
char *v4; // rax
char *v5; // rbp
__m128i *v6; // rax
__m128i v7; // xmm0
struct stat v8; // [rsp+0h] [rbp-148h] BYREF
struct stat v9; // [rsp+90h] [rbp-B8h] BYREF

if ( ((a1 - 3) & 0xFFFFFFFD) != 0 )
{
fprintf(stderr, "Error: insufficient arguments. 3 required or 5 (testing), you provided %d \n", a1);
printUsage();
exit(1);
}
if ( stat(*(const char **)(a2 + 8), &v8) )
{
fprintf(
stderr,
"Error: The dir argument %s was not found. Please enter a readable and valid directory. \n",
*(const char **)(a2 + 8));
printUsage();
exit(1);
}
if ( !stat(*(const char **)(a2 + 16), &v9) )
fprintf(stderr, "Warning: The file %s already exists and will be overwritten \n", *(const char **)(a2 + 16));
v2 = *(const char **)(a2 + 8);
v3 = strlen(v2);
v4 = (char *)malloc(v3 + 43);
v5 = v4;
if ( !v4 )
{
fwrite("Out of memory! \n ", 1uLL, 0x11uLL, stderr);
exit(1);
}
v4[8] = 32;
*(_QWORD *)v4 = 0x722D205B5B206669LL;
memcpy(v4 + 9, v2, v3);
v6 = (__m128i *)&v5[strlen(v5)];
*v6 = _mm_load_si128((const __m128i *)&LC7);
v7 = _mm_load_si128((const __m128i *)&LC8);
v6[2].m128i_i16[0] = 105;
v6[1] = v7;
if ( system(v5) )
{
fprintf(
stderr,
"Error: The dir argument %s was not readable. Please enter readable and valid directory. \n",
*(const char **)(a2 + 8));
printUsage();
free(v5);
exit(1);
}
free(v5);
}

canonical_decompiled_code:
void __fastcall func1(unsigned int a1, __int64 a2)
{
const char *v2; // r13
size_t v3; // r12
char *v4; // rax
char *v5; // rbp
__m128i *v6; // rax
__m128i v7; // xmm0
struct stat v8; // [rsp+0h] [rbp-148h] BYREF
struct stat v9; // [rsp+90h] [rbp-B8h] BYREF

if ( ((a1 - 3) & 0xFFFFFFFD) != 0 )
{
fprintf(stderr, "Error: insufficient arguments. 3 required or 5 (testing), you provided %d \n", a1);
func0();
exit(1);
}
if ( stat(*(const char **)(a2 + 8), &v8) )
{
fprintf(
stderr,
"Error: The dir argument %s was not found. Please enter a readable and valid directory. \n",
*(const char **)(a2 + 8));
func0();
exit(1);
}
if ( !stat(*(const char **)(a2 + 16), &v9) )
fprintf(stderr, "Warning: The file %s already exists and will be overwritten \n", *(const char **)(a2 + 16));
v2 = *(const char **)(a2 + 8);
v3 = strlen(v2);
v4 = (char *)malloc(v3 + 43);
v5 = v4;
if ( !v4 )
{
fwrite("Out of memory! \n ", 1uLL, 0x11uLL, stderr);
exit(1);
}
v4[8] = 32;
*(_QWORD *)v4 = 0x722D205B5B206669LL;
memcpy(v4 + 9, v2, v3);
v6 = (__m128i *)&v5[strlen(v5)];
*v6 = _mm_load_si128((const __m128i *)&LC7);
v7 = _mm_load_si128((const __m128i *)&LC8);
v6[2].m128i_i16[0] = 105;
v6[1] = v7;
if ( system(v5) )
{
fprintf(
stderr,
"Error: The dir argument %s was not readable. Please enter readable and valid directory. \n",
*(const char **)(a2 + 8));
func0();
free(v5);
exit(1);
}
free(v5);
}

original_code:
void validateArgs(int argc, char* argv[]){
  struct stat s;
  struct stat checkDest;
  int readableResult = 0;
  char* readableTest = ((void *)0);
  if ( (argc != 3) && (argc != 5) ){
    fprintf(stderr, "Error: insufficient arguments. 3 required or 5 (testing), you provided %d \n", argc);
    printUsage();
    exit(1);
  }
  if ( stat(argv[1], &s) != 0){
    fprintf(stderr, "Error: The dir argument %s was not found.  Please     enter a readable and valid directory. \n", argv[1]);
    printUsage();
    exit(1);
  }
  if ( stat(argv[2], &checkDest) == 0){
    fprintf(stderr, "Warning: The file %s already exists and will be overwritten \n", argv[2]);
  }
  size_t len1 = strlen("if [[ -r "), len2 = strlen(argv[1]), len3 = strlen(" ]]; then exit 0; else exit 1; fi");
  readableTest = (char*) malloc(len1 + len2 + len3 + 1);
  if (readableTest == ((void *)0)){
    fprintf(stderr, "Out of memory! \n ");
    exit(1);
  }
  memcpy(readableTest, "if [[ -r ", len1);
  memcpy(readableTest+len1, argv[1], len2);
  strcat(readableTest, " ]]; then exit 0; else exit 1; fi");
  readableResult = system(readableTest);
  if ( readableResult != 0){
    fprintf(stderr, "Error: The dir argument %s was not readable.     Please enter readable and valid directory. \n", argv[1]);
    printUsage();
    free(readableTest);
    exit(1);
  }
  free(readableTest);
}

canonical_original_code:
void validateArgs(int argc, char *argv[]){
  struct stat s;
  struct stat checkDest;
  int readableResult = 0;
  char *readableTest = ((void *)0);
  if ( (argc != 3) && (argc != 5) ){
    fprintf(stderr, "Error: insufficient arguments. 3 required or 5 (testing), you provided %d \n", argc);
    printUsage();
    exit(1);
  }
  if ( stat(argv[1], &s) != 0){
    fprintf(stderr, "Error: The dir argument %s was not found.  Please     enter a readable and valid directory. \n", argv[1]);
    printUsage();
    exit(1);
  }
  if ( stat(argv[2], &checkDest) == 0){
    fprintf(stderr, "Warning: The file %s already exists and will be overwritten \n", argv[2]);
  }
  unsigned long len1 = strlen("if [[ -r "); unsigned long len2 = strlen(argv[1]); unsigned long len3 = strlen(" ]]; then exit 0; else exit 1; fi");
  readableTest = (char *) malloc(len1 + len2 + len3 + 1);
  if (readableTest == ((void *)0)){
    fprintf(stderr, "Out of memory! \n ");
    exit(1);
  }
  memcpy(readableTest, "if [[ -r ", len1);
  memcpy(readableTest+len1, argv[1], len2);
  strcat(readableTest, " ]]; then exit 0; else exit 1; fi");
  readableResult = system(readableTest);
  if ( readableResult != 0){
    fprintf(stderr, "Error: The dir argument %s was not readable.     Please enter readable and valid directory. \n", argv[1]);
    printUsage();
    free(readableTest);
    exit(1);
  }
  free(readableTest);
}

variable_types:
argv
char *[]

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; long st_atime; unsigned long st_atimensec; long st_mtime; unsigned long st_mtimensec; long st_ctime; unsigned long st_ctimensec; long __glibc_reserved[3]; }

variable_types: readableResult int

variable_types:
readableTest
char *


validateDebugArgs

decompiled_code:
int __fastcall validateDebugArgs(const char *a1, const char *a2)
{
int result; // eax
struct stat v3; // [rsp+0h] [rbp-138h] BYREF
struct stat v4; // [rsp+90h] [rbp-A8h] BYREF

if ( stat(a1, &v3) )
{
fprintf(stderr, "Error: The target file argument %s was not found \n", a1);
printUsage();
exit(1);
}
result = stat(a2, &v4);
if ( !result )
result = fprintf(stderr, "Warning: The target file argument %s will be overwritten \n", a2);
return result;
}

canonical_decompiled_code:
int __fastcall func2(const char *a1, const char *a2)
{
int result; // eax
struct stat v3; // [rsp+0h] [rbp-138h] BYREF
struct stat v4; // [rsp+90h] [rbp-A8h] BYREF

if ( stat(a1, &v3) )
{
fprintf(stderr, "Error: The target file argument %s was not found \n", a1);
func0();
exit(1);
}
result = stat(a2, &v4);
if ( !result )
result = fprintf(stderr, "Warning: The target file argument %s will be overwritten \n", a2);
return result;
}

original_code:
void validateDebugArgs(char* loadFile, char* writeReload){
  struct stat checkLoadFile;
  struct stat checkWriteReload;
  if ( stat(loadFile, &checkLoadFile) != 0){
    fprintf(stderr, "Error: The target file argument %s was not found \n", loadFile);
    printUsage();
    exit(1);
  }
  if ( stat(writeReload, &checkWriteReload) == 0){
    fprintf(stderr, "Warning: The target file argument %s will be overwritten \n", writeReload);
  }
}

canonical_original_code:
void validateDebugArgs(char *loadFile, char *writeReload){
  struct stat checkLoadFile;
  struct stat checkWriteReload;
  if ( stat(loadFile, &checkLoadFile) != 0){
    fprintf(stderr, "Error: The target file argument %s was not found \n", loadFile);
    printUsage();
    exit(1);
  }
  if ( stat(writeReload, &checkWriteReload) == 0){
    fprintf(stderr, "Warning: The target file argument %s will be overwritten \n", writeReload);
  }
}

variable_types:
loadFile
char *

variable_types:
writeReload
char *

user_defined_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; long st_atime; unsigned long st_atimensec; long st_mtime; unsigned long st_mtimensec; long st_ctime; unsigned long st_ctimensec; long __glibc_reserved[3]; }


updateIndex

decompiled_code:
__int64 __fastcall updateIndex(__int64 a1, const char *a2, unsigned int a3)
{
unsigned __int64 v4; // rbp
__int64 v5; // rbx
__int64 *i; // rbx
__int64 v7; // rax
__int64 v8; // rax
__int64 result; // rax

v4 = hash1(a2) % 0x2710uLL + 2;
v5 = *(_QWORD *)(a1 + 8 * v4);
if ( v5 )
{
while ( strncmp((const char *)(v5 + 16), a2, 0x3E8uLL) )
{
v5 = *(_QWORD *)(v5 + 8);
if ( !v5 )
{
v5 = 0LL;
break;
}
}
for ( i = *(__int64 **)(v5 + 1016); ; i = (__int64 *)*i )
{
if ( !i )
return 1LL;
if ( *((_DWORD *)i + 2) == a3 )
{
++*((_DWORD *)i + 3);
return 1LL;
}
if ( !*i )
break;
}
*i = newDocNode(0LL, a3, 1LL);
result = 1LL;
}
else
{
v7 = newDocNode(0LL, a3, 1LL);
v8 = newWordNode(0LL, v7, a2);
*(_QWORD *)(a1 + 8 * v4) = v8;
*(_QWORD *)(a1 + 8) = v8;
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, const char *a2, unsigned int a3)
{
unsigned __int64 v4; // rbp
__int64 v5; // rbx
__int64 *i; // rbx
__int64 v7; // rax
__int64 v8; // rax
__int64 result; // rax

v4 = hash1(a2) % 0x2710uLL + 2;
v5 = *(_QWORD *)(a1 + 8 * v4);
if ( v5 )
{
while ( strncmp((const char *)(v5 + 16), a2, 0x3E8uLL) )
{
v5 = *(_QWORD *)(v5 + 8);
if ( !v5 )
{
v5 = 0LL;
break;
}
}
for ( i = *(__int64 **)(v5 + 1016); ; i = (__int64 *)*i )
{
if ( !i )
return 1LL;
if ( *((_DWORD *)i + 2) == a3 )
{
++*((_DWORD *)i + 3);
return 1LL;
}
if ( !*i )
break;
}
*i = newDocNode(0LL, a3, 1LL);
result = 1LL;
}
else
{
v7 = newDocNode(0LL, a3, 1LL);
v8 = newWordNode(0LL, v7, a2);
*(_QWORD *)(a1 + 8 * v4) = v8;
*(_QWORD *)(a1 + 8) = v8;
result = 1LL;
}
return result;
}

original_code:
int updateIndex(INVERTED_INDEX* index, char* word, int documentId){
  int wordHash = hash1(word) % 10000;
  DocumentNode* docNode = ((void *)0);
  WordNode* wordNode = ((void *)0);
  if (index->hash[wordHash] == ((void *)0)){
    docNode = ((void *)0);
    docNode = newDocNode(docNode, documentId, 1);
    wordNode = ((void *)0);
    wordNode = newWordNode(wordNode, docNode, word);
    index->hash[wordHash] = wordNode;
    index->end = wordNode;
    return 1;
  } else {
    WordNode* checkWordNode = index->hash[wordHash];
    WordNode* matchedWordNode;
    WordNode* endWordNode = ((void *)0);
    if (!strncmp(checkWordNode->word, word, 1000)){
      matchedWordNode = checkWordNode;
    } else {
      while (checkWordNode != ((void *)0)){
        if ( (checkWordNode->next == ((void *)0)) ){
          endWordNode = checkWordNode;
          break;
        }
        checkWordNode = checkWordNode->next;
        if (!strncmp(checkWordNode->word, word, 1000)){
          matchedWordNode = checkWordNode;
          break;
        }
      }
    }
    if (matchedWordNode != ((void *)0)){
      DocumentNode* matchDocNode = matchedWordNode->page;
      DocumentNode* endDocNode;
      while (matchDocNode != ((void *)0)){
        if (matchDocNode->document_id == documentId){
          matchDocNode->page_word_frequency++;
          break;
        }
        if ( (matchDocNode->next == ((void *)0)) ){
          endDocNode = matchDocNode;
          docNode = ((void *)0);
          docNode = newDocNode(docNode, documentId, 1);
          endDocNode->next = docNode;
          break;
        }
        matchDocNode = matchDocNode->next;
      }
    } else {
      docNode = ((void *)0);
      docNode = newDocNode(docNode, documentId, 1);
      wordNode = ((void *)0);
      wordNode = newWordNode(wordNode, docNode, word);
      endWordNode->next = wordNode;
    }
    return 1;
  }
  return 1;
}

canonical_original_code:
int updateIndex(struct _INVERTED_INDEX *index, char *word, int documentId){
  int wordHash = hash1(word) % 10000;
  struct _DocumentNode *docNode = ((void *)0);
  struct _WordNode *wordNode = ((void *)0);
  if (index->hash[wordHash] == ((void *)0)){
    docNode = ((void *)0);
    docNode = newDocNode(docNode, documentId, 1);
    wordNode = ((void *)0);
    wordNode = newWordNode(wordNode, docNode, word);
    index->hash[wordHash] = wordNode;
    index->end = wordNode;
    return 1;
  } else {
    struct _WordNode *checkWordNode = index->hash[wordHash];
    struct _WordNode *matchedWordNode;
    struct _WordNode *endWordNode = ((void *)0);
    if (!strncmp(checkWordNode->word, word, 1000)){
      matchedWordNode = checkWordNode;
    } else {
      while (checkWordNode != ((void *)0)){
        if ( (checkWordNode->next == ((void *)0)) ){
          endWordNode = checkWordNode;
          break;
        }
        checkWordNode = checkWordNode->next;
        if (!strncmp(checkWordNode->word, word, 1000)){
          matchedWordNode = checkWordNode;
          break;
        }
      }
    }
    if (matchedWordNode != ((void *)0)){
      struct _DocumentNode *matchDocNode = matchedWordNode->page;
      struct _DocumentNode *endDocNode;
      while (matchDocNode != ((void *)0)){
        if (matchDocNode->document_id == documentId){
          matchDocNode->page_word_frequency++;
          break;
        }
        if ( (matchDocNode->next == ((void *)0)) ){
          endDocNode = matchDocNode;
          docNode = ((void *)0);
          docNode = newDocNode(docNode, documentId, 1);
          endDocNode->next = docNode;
          break;
        }
        matchDocNode = matchDocNode->next;
      }
    } else {
      docNode = ((void *)0);
      docNode = newDocNode(docNode, documentId, 1);
      wordNode = ((void *)0);
      wordNode = newWordNode(wordNode, docNode, word);
      endWordNode->next = wordNode;
    }
    return 1;
  }
  return 1;
}

variable_types: struct _INVERTED_INDEX { struct _WordNode { struct _WordNode *prev; struct _WordNode *next; char word[1000]; struct _DocumentNode { struct _DocumentNode *next; int document_id; int page_word_frequency; } *page; } *start; struct _WordNode *end; struct _WordNode *hash[10000]; } *

variable_types:
word
char *

variable_types: documentId int

variable_types: wordHash int

user_defined_types: struct _INVERTED_INDEX { struct _WordNode *start; struct _WordNode *end; struct _WordNode *hash[10000]; }

user_defined_types: struct _WordNode { struct _WordNode *prev; struct _WordNode *next; char word[1000]; struct _DocumentNode *page; }


getNextWordFromHTMLDocument

original_code:
int getNextWordFromHTMLDocument(char* loadedDocument, char* word, int position,
INVERTED_INDEX* index, int documentId){
  int tagFlag = 0;
  int recordFlag = 1;
  char character;
  while ( loadedDocument[position] != 0) {
    character = loadedDocument[position];
    if ( character == '<' ){
      if (recordFlag){
        recordFlag = 0;
      }
      tagFlag = 1;
      position++;
    } else if ( character == '>'){
      tagFlag = 0;
      position++;
      if (!recordFlag){
        recordFlag = 1;
      }
    }
    else if ( tagFlag == 0 && recordFlag){
      int validLength = 0;
      char* startRecord = &(loadedDocument[position]);
      while ((loadedDocument[position + 1] != '<' && (loadedDocument[position + 1] != '\0')) ){
        position++;
        validLength++;
      }
      if (validLength > 1){
        char* endRecord = &(loadedDocument[position + 1]);
        char grabWords[(endRecord - startRecord) + 1];
        memset(grabWords, 0, (endRecord - startRecord) + 1);
        strncpy(grabWords, startRecord, (endRecord - startRecord));
        word = strtok(grabWords, " ");
        while (word != ((void *)0)){
          if ( strlen(word) > 2){
            int result = updateIndex(index, word, documentId);
            if (result != 1){
              fprintf(stderr, "Could not successfully index %s", word);
            }
          }
          word = strtok(((void *)0), " ");
        }
        return(position + 1);
      }
      recordFlag = 0;
    } else {
      position++;
    }
  }
  return -1;
}

canonical_original_code:
int getNextWordFromHTMLDocument(char *loadedDocument, char *word, int position, struct _INVERTED_INDEX *index, int documentId){
  int tagFlag = 0;
  int recordFlag = 1;
  char character;
  while ( loadedDocument[position] != 0) {
    character = loadedDocument[position];
    if ( character == '<' ){
      if (recordFlag){
        recordFlag = 0;
      }
      tagFlag = 1;
      position++;
    } else if ( character == '>'){
      tagFlag = 0;
      position++;
      if (!recordFlag){
        recordFlag = 1;
      }
    }
    else if ( tagFlag == 0 && recordFlag){
      int validLength = 0;
      char *startRecord = &(loadedDocument[position]);
      while ((loadedDocument[position + 1] != '<' && (loadedDocument[position + 1] != '\0')) ){
        position++;
        validLength++;
      }
      if (validLength > 1){
        char *endRecord = &(loadedDocument[position + 1]);
        char grabWords[-1];
        memset(grabWords, 0, (endRecord - startRecord) + 1);
        strncpy(grabWords, startRecord, (endRecord - startRecord));
        word = strtok(grabWords, " ");
        while (word != ((void *)0)){
          if ( strlen(word) > 2){
            int result = updateIndex(index, word, documentId);
            if (result != 1){
              fprintf(stderr, "Could not successfully index %s", word);
            }
          }
          word = strtok(((void *)0), " ");
        }
        return(position + 1);
      }
      recordFlag = 0;
    } else {
      position++;
    }
  }
  return -1;
}

variable_types:
loadedDocument
char *

variable_types: position int

variable_types: tagFlag int

variable_types: recordFlag int

variable_types: character char

variable_types: validLength int

variable_types:
startRecord
char *

variable_types:
endRecord
char *

variable_types:
grabWords
char [-1]

variable_types: result int

user_defined_types: struct _DocumentNode { struct _DocumentNode *next; int document_id; int page_word_frequency; }


buildIndexFromDir

decompiled_code:
void __fastcall buildIndexFromDir(__int64 a1, int a2, __int64 a3)
{
unsigned int v3; // er14
void *v4; // rbp
void *v6; // r15
int i; // edx
char v8[1064]; // [rsp-428h] [rbp-428h] BYREF

if ( a2 > 0 )
{
v3 = 1;
v4 = 0LL;
do
{
snprintf(v8, 0x3E8uLL, "%d", v3);
v4 = (void *)createFilepath(v4, a1, v8);
v6 = (void *)loadDocument(v4);
sanitize(v6);
capitalToLower(v6);
free(v4);
for ( i = 0; i != -1; i = getNextWordFromHTMLDocument((__int64)v6, 0LL, i, a3, v3) )
;
free(v6);
printf("Indexing document %d\n", v3++);
}
while ( a2 >= (int)v3 );
}
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1, int a2, __int64 a3)
{
unsigned int v3; // er14
void *v4; // rbp
void *v6; // r15
int i; // edx
char v8[1064]; // [rsp-428h] [rbp-428h] BYREF

if ( a2 > 0 )
{
v3 = 1;
v4 = 0LL;
do
{
snprintf(v8, 0x3E8uLL, "%d", v3);
v4 = (void *)createFilepath(v4, a1, v8);
v6 = (void *)loadDocument(v4);
sanitize(v6);
capitalToLower(v6);
free(v4);
for ( i = 0; i != -1; i = func4((__int64)v6, 0LL, i, a3, v3) )
;
free(v6);
printf("Indexing document %d\n", v3++);
}
while ( a2 >= (int)v3 );
}
}

original_code:
void buildIndexFromDir(char* dir, int numOfFiles, INVERTED_INDEX* index){
  char* writable = ((void *)0);
  char* loadedDocument;
  int currentPosition;
  for (int i = 1; i < numOfFiles + 1; i++){
    char converted_i[1001];
    snprintf(converted_i, 1000, "%d", i);
    writable = createFilepath(writable, dir, converted_i);
    loadedDocument = loadDocument(writable);
    sanitize(loadedDocument);
    capitalToLower(loadedDocument);
    free(writable);
    int documentId = i;
    char* word = ((void *)0);
    currentPosition = 0;
    while ( (currentPosition = getNextWordFromHTMLDocument(
      loadedDocument, word, currentPosition, index, documentId)) != -1){}
    free(loadedDocument);
    printf("Indexing document %d\n", i);
  }
}

canonical_original_code:
void buildIndexFromDir(char *dir, int numOfFiles, struct _INVERTED_INDEX *index){
  char *writable = ((void *)0);
  char *loadedDocument;
  int currentPosition;
  for (int i = 1; i < numOfFiles + 1; i++){
    char converted_i[1001];
    snprintf(converted_i, 1000, "%d", i);
    writable = createFilepath(writable, dir, converted_i);
    loadedDocument = loadDocument(writable);
    sanitize(loadedDocument);
    capitalToLower(loadedDocument);
    free(writable);
    int documentId = i;
    char *word = ((void *)0);
    currentPosition = 0;
    while ( (currentPosition = getNextWordFromHTMLDocument(
      loadedDocument, word, currentPosition, index, documentId)) != -1){}
    free(loadedDocument);
    printf("Indexing document %d\n", i);
  }
}

variable_types:
dir
char *

variable_types: numOfFiles int

variable_types:
writable
char *

variable_types: currentPosition int

variable_types: i int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // r13
const char *v4; // r14
int v5; // er12
const char *v7; // rbp
const char *v8; // r12
__int64 v9; // rbp

validateArgs(argc, (__int64)argv);
v3 = argv[1];
v4 = argv[2];
v5 = dirScan(v3);
index = initStructure(index);
buildIndexFromDir((__int64)v3, v5, index);
printf("[%s:%d]%s\n", "indexer.c", 415LL, "Index finished building");
saveIndexToFile(index, v4);
printf("[%s:%d]%s\n", "indexer.c", 420LL, "Writing index to file finished");
cleanUpIndex(index);
if ( argc == 5 )
{
validateDebugArgs(argv[3], argv[4]);
printf("[%s:%d]%s\n", "indexer.c", 428LL, "Testing index");
v7 = argv[3];
v8 = argv[4];
indexReload = initStructure(indexReload);
v9 = reloadIndexFromFile(v7, indexReload);
if ( !v9 )
exit(1);
printf("[%s:%d]%s\n", "indexer.c", 440LL, "Finished reloading index from file");
saveIndexToFile(v9, v8);
printf("[%s:%d]%s\n", "indexer.c", 447LL, "Cleaning up");
cleanUpIndex(indexReload);
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v3; // r13
const char *v4; // r14
int v5; // er12
const char *v7; // rbp
const char *v8; // r12
__int64 v9; // rbp

func1(argc, (__int64)argv);
v3 = argv[1];
v4 = argv[2];
v5 = dirScan(v3);
index = initStructure(index);
func5((__int64)v3, v5, index);
printf("[%s:%d]%s\n", "indexer.c", 415LL, "Index finished building");
saveIndexToFile(index, v4);
printf("[%s:%d]%s\n", "indexer.c", 420LL, "Writing index to file finished");
cleanUpIndex(index);
if ( argc == 5 )
{
func2(argv[3], argv[4]);
printf("[%s:%d]%s\n", "indexer.c", 428LL, "Testing index");
v7 = argv[3];
v8 = argv[4];
indexReload = initStructure(indexReload);
v9 = reloadIndexFromFile(v7, indexReload);
if ( !v9 )
exit(1);
printf("[%s:%d]%s\n", "indexer.c", 440LL, "Finished reloading index from file");
saveIndexToFile(v9, v8);
printf("[%s:%d]%s\n", "indexer.c", 447LL, "Cleaning up");
cleanUpIndex(indexReload);
}
return 0;
}

original_code:
int main(int argc, char* argv[]){
  char* targetDir;
  char* targetFile;
  int numOfFiles;
  validateArgs(argc, argv);
    targetDir = argv[1];
    targetFile = argv[2];
    numOfFiles = dirScan(targetDir);
    index = initStructure(index);
    buildIndexFromDir(targetDir, numOfFiles, index);
    printf("[%s:%d]%s\n", "indexer.c", 415, "Index finished building");
    saveIndexToFile(index, targetFile);
    printf("[%s:%d]%s\n", "indexer.c", 420, "Writing index to file finished");
    cleanUpIndex(index);
  if ( argc == 5){
    validateDebugArgs(argv[3], argv[4]);
    printf("[%s:%d]%s\n", "indexer.c", 428, "Testing index");
    char* loadFile = argv[3];
    char* writeReload = argv[4];
    indexReload = initStructure(indexReload);
    INVERTED_INDEX* reloadResult = reloadIndexFromFile(loadFile, indexReload);
    if (reloadResult == ((void *)0)){
      exit(1);
    } else {
      printf("[%s:%d]%s\n", "indexer.c", 440, "Finished reloading index from file");
    }
    saveIndexToFile(reloadResult, writeReload);
    printf("[%s:%d]%s\n", "indexer.c", 447, "Cleaning up");
    cleanUpIndex(indexReload);
  }
  return 0;
}

canonical_original_code:
int main(int argc, char *argv[]){
  char *targetDir;
  char *targetFile;
  int numOfFiles;
  validateArgs(argc, argv);
    targetDir = argv[1];
    targetFile = argv[2];
    numOfFiles = dirScan(targetDir);
    index = initStructure(index);
    buildIndexFromDir(targetDir, numOfFiles, index);
    printf("[%s:%d]%s\n", "indexer.c", 415, "Index finished building");
    saveIndexToFile(index, targetFile);
    printf("[%s:%d]%s\n", "indexer.c", 420, "Writing index to file finished");
    cleanUpIndex(index);
  if ( argc == 5){
    validateDebugArgs(argv[3], argv[4]);
    printf("[%s:%d]%s\n", "indexer.c", 428, "Testing index");
    char *loadFile = argv[3];
    char *writeReload = argv[4];
    indexReload = initStructure(indexReload);
    struct _INVERTED_INDEX *reloadResult = reloadIndexFromFile(loadFile, indexReload);
    if (reloadResult == ((void *)0)){
      exit(1);
    } else {
      printf("[%s:%d]%s\n", "indexer.c", 440, "Finished reloading index from file");
    }
    saveIndexToFile(reloadResult, writeReload);
    printf("[%s:%d]%s\n", "indexer.c", 447, "Cleaning up");
    cleanUpIndex(indexReload);
  }
  return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
targetDir
char *

variable_types:
targetFile
char *

variable_types:
loadFile
char *

variable_types:
writeReload
char *

variable_types: struct _INVERTED_INDEX { struct _WordNode { struct _WordNode *prev; struct _WordNode *next; char word[1000]; struct _DocumentNode { struct _DocumentNode *next; int document_id; int page_word_frequency; } *page; } *start; struct _WordNode *end; struct _WordNode *hash[10000]; } *


repo: demmys/desk

decompiled_code:
__int64 get_current_compiler()
{
return static_current_compiler;
}

canonical_decompiled_code:
__int64 func0()
{
return static_current_compiler;
}

canonical_original_code:
struct Compiler *get_current_compiler(){
    return static_current_compiler;
}

return_type: struct Compiler { int function_count; struct FunctionDefinition_tag { char *name; char *descriptor; char *parameter_name; struct Statement { enum StatementType { NONE_TYPE_STATEMENT=0, MAIN_STATEMENT=1, CONSTRUCTOR_STATEMENT=2, FUNCTION_STATEMENT=3, FUNCTION_PATTERN_STATEMENT=4 } type; int line_number; struct Expression_tag { enum ExpressionKind { INT_EXPRESSION=0, IDENTIFIER_EXPRESSION=1, BINARY_EXPRESSION=2, MINUS_EXPRESSION=3, CALL_EXPRESSION=4 } kind; int line_number; union { int int_value; char *identifier; struct BinaryExpression { enum OperatorKind { ADD_OPERATOR=0, SUB_OPERATOR=1, MUL_OPERATOR=2, DIV_OPERATOR=3, MOD_OPERATOR=4 } kind; struct Expression_tag *left; struct Expression_tag *right; } binary_expression; struct Expression_tag *minus_expression; struct CallExpression { char *identifier; struct Expression_tag *parameter_expression; } call_expression; } u; } *expression; } *statement; struct FunctionPattern_tag { int pattern; struct Statement *statement; struct FunctionPattern_tag *prev; struct FunctionPattern_tag *next; } *pattern_list; struct FunctionDefinition_tag *prev; struct FunctionDefinition_tag *next; } *function_list; int current_line_number; char *source_file; struct Storage { struct MemoryPage_tag { int cell_num; int use_cell_num; struct MemoryPage_tag *next; union Cell { long l_dummy; double d_dummy; void *p_dummy; } cell[1]; } *page_list; int current_page_size; } *compile_storage; } *

user_defined_types: struct Compiler { int function_count; struct FunctionDefinition_tag *function_list; int current_line_number; char *source_file; struct Storage *compile_storage; }

user_defined_types: struct FunctionDefinition_tag { char *name; char *descriptor; char *parameter_name; struct Statement *statement; struct FunctionPattern_tag *pattern_list; struct FunctionDefinition_tag *prev; struct FunctionDefinition_tag *next; }

user_defined_types: struct Storage { struct MemoryPage_tag *page_list; int current_page_size; }

user_defined_types: struct Statement { enum StatementType type; int line_number; struct Expression_tag *expression; }

user_defined_types: struct MemoryPage_tag { int cell_num; int use_cell_num; struct MemoryPage_tag *next; union Cell cell[1]; }

user_defined_types: struct Expression_tag { enum ExpressionKind kind; int line_number; union { int int_value; char *identifier; struct BinaryExpression binary_expression; struct Expression_tag *minus_expression; struct CallExpression call_expression; } u; }

user_defined_types: struct BinaryExpression { enum OperatorKind kind; struct Expression_tag *left; struct Expression_tag *right; }


decompiled_code:
__int64 __fastcall compiler_storage_malloc(__int64 a1)
{
return storage_malloc(*(_QWORD *)(static_current_compiler + 32), a1);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
return storage_malloc(*(_QWORD *)(static_current_compiler + 32), a1);
}

original_code:
void *compiler_storage_malloc(size_t size){
    void *p;
    p = storage_malloc(static_current_compiler->compile_storage, size);
    return p;
}

canonical_original_code:
void *compiler_storage_malloc(unsigned long size){
    void *p;
    p = storage_malloc(static_current_compiler->compile_storage, size);
    return p;
}

variable_types:
size
unsigned long

variable_types:
p
void *

return_type: void *


decompiled_code:
__int64 __fastcall create_compiler(__int64 a1)
{
__int64 v1; // rbx
__int64 result; // rax

v1 = open_storage(0LL);
result = storage_malloc(v1, 40LL);
*(_DWORD *)result = 0;
*(_QWORD *)(result + 8) = 0LL;
*(_DWORD *)(result + 16) = 1;
*(_QWORD *)(result + 24) = a1;
*(_QWORD *)(result + 32) = v1;
static_current_compiler = result;
return result;
}

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

v1 = open_storage(0LL);
result = storage_malloc(v1, 40LL);
*(_DWORD *)result = 0;
*(_QWORD *)(result + 8) = 0LL;
*(_DWORD *)(result + 16) = 1;
*(_QWORD *)(result + 24) = a1;
*(_QWORD *)(result + 32) = v1;
static_current_compiler = result;
return result;
}

original_code:
Compiler *create_compiler(char *source_file){
    Storage *storage;
    Compiler *compiler;
    storage = open_storage(0);
    compiler = storage_malloc(storage, sizeof(Compiler));
    compiler->function_count = 0;
    compiler->function_list = ((void *)0);
    compiler->current_line_number = 1;
    compiler->source_file = source_file;
    compiler->compile_storage = storage;
    static_current_compiler = compiler;
    return compiler;
}

canonical_original_code:
struct Compiler *create_compiler(char *source_file){
    struct Storage *storage;
    struct Compiler *compiler;
    storage = open_storage(0);
    compiler = storage_malloc(storage, sizeof(Compiler));
    compiler->function_count = 0;
    compiler->function_list = ((void *)0);
    compiler->current_line_number = 1;
    compiler->source_file = source_file;
    compiler->compile_storage = storage;
    static_current_compiler = compiler;
    return compiler;
}

variable_types: struct Compiler { int function_count; struct FunctionDefinition_tag { char *name; char *descriptor; char *parameter_name; struct Statement { enum StatementType { NONE_TYPE_STATEMENT=0, MAIN_STATEMENT=1, CONSTRUCTOR_STATEMENT=2, FUNCTION_STATEMENT=3, FUNCTION_PATTERN_STATEMENT=4 } type; int line_number; struct Expression_tag { enum ExpressionKind { INT_EXPRESSION=0, IDENTIFIER_EXPRESSION=1, BINARY_EXPRESSION=2, MINUS_EXPRESSION=3, CALL_EXPRESSION=4 } kind; int line_number; union { int int_value; char *identifier; struct BinaryExpression { enum OperatorKind { ADD_OPERATOR=0, SUB_OPERATOR=1, MUL_OPERATOR=2, DIV_OPERATOR=3, MOD_OPERATOR=4 } kind; struct Expression_tag *left; struct Expression_tag *right; } binary_expression; struct Expression_tag *minus_expression; struct CallExpression { char *identifier; struct Expression_tag *parameter_expression; } call_expression; } u; } *expression; } *statement; struct FunctionPattern_tag { int pattern; struct Statement *statement; struct FunctionPattern_tag *prev; struct FunctionPattern_tag *next; } *pattern_list; struct FunctionDefinition_tag *prev; struct FunctionDefinition_tag *next; } *function_list; int current_line_number; char *source_file; struct Storage { struct MemoryPage_tag { int cell_num; int use_cell_num; struct MemoryPage_tag *next; union Cell { long l_dummy; double d_dummy; void *p_dummy; } cell[1]; } *page_list; int current_page_size; } *compile_storage; } *


decompiled_code:
__int64 __fastcall dispose_compiler(__int64 a1)
{
return dispose_storage(*(_QWORD *)(a1 + 32));
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
return dispose_storage(*(_QWORD *)(a1 + 32));
}

original_code:
void dispose_compiler(Compiler *compiler){
    dispose_storage(compiler->compile_storage);
}

canonical_original_code:
void dispose_compiler(struct Compiler *compiler){
    dispose_storage(compiler->compile_storage);
}

user_defined_types: struct FunctionPattern_tag { int pattern; struct Statement *statement; struct FunctionPattern_tag *prev; struct FunctionPattern_tag *next; }

user_defined_types: enum StatementType { NONE_TYPE_STATEMENT=0, MAIN_STATEMENT=1, CONSTRUCTOR_STATEMENT=2, FUNCTION_STATEMENT=3, FUNCTION_PATTERN_STATEMENT=4 }

user_defined_types: union Cell { long l_dummy; double d_dummy; void *p_dummy; }

user_defined_types: enum ExpressionKind { INT_EXPRESSION=0, IDENTIFIER_EXPRESSION=1, BINARY_EXPRESSION=2, MINUS_EXPRESSION=3, CALL_EXPRESSION=4 }

user_defined_types: struct CallExpression { char *identifier; struct Expression_tag *parameter_expression; }

user_defined_types: enum OperatorKind { ADD_OPERATOR=0, SUB_OPERATOR=1, MUL_OPERATOR=2, DIV_OPERATOR=3, MOD_OPERATOR=4 }


original_code:
static AttributeInfo *add_attribute_info(AttributeInfo **ai_list, u2 *list_length, AttributeTag tag){
    AttributeInfo *ai;
    if(*ai_list){
        ai = classfile_storage_malloc(sizeof(AttributeInfo));
        ai->next = ((void *)0);
        ai->prev = (*ai_list)->prev;
        ai->prev->next = ai;
        (*ai_list)->prev = ai;
    } else{
        *ai_list = classfile_storage_malloc(sizeof(AttributeInfo));
        (*ai_list)->next = ((void *)0);
        (*ai_list)->prev = *ai_list;
        ai = *ai_list;
    }
    (*list_length)++;
    ai->tag = tag;
    ai->attribute_name_index = add_constant_utf8_info(attribute_name[tag]);
    ai->attribute_length = 0;
    return ai;
}

canonical_original_code:
static struct AttributeInfo_tag *add_attribute_info(struct AttributeInfo_tag **ai_list, unsigned short *list_length, enum AttributeTag tag){
    struct AttributeInfo_tag *ai;
    if(*ai_list){
        ai = classfile_storage_malloc(sizeof(AttributeInfo));
        ai->next = ((void *)0);
        ai->prev = (*ai_list)->prev;
        ai->prev->next = ai;
        (*ai_list)->prev = ai;
    } else{
        *ai_list = classfile_storage_malloc(sizeof(AttributeInfo));
        (*ai_list)->next = ((void *)0);
        (*ai_list)->prev = *ai_list;
        ai = *ai_list;
    }
    (*list_length)++;
    ai->tag = tag;
    ai->attribute_name_index = add_constant_utf8_info(attribute_name[tag]);
    ai->attribute_length = 0;
    return ai;
}

variable_types: struct AttributeInfo_tag { enum AttributeTag { ATTRIBUTE_ConstantValue=1, ATTRIBUTE_Code=2, ATTRIBUTE_Exceptions=3, ATTRIBUTE_InnerClasses=4, ATTRIBUTE_Synthetic=5, ATTRIBUTE_SourceFile=6, ATTRIBUTE_LineNumberTable=7, ATTRIBUTE_LocalVariableTable=8, ATTRIBUTE_Deprecated=9 } tag; unsigned short attribute_name_index; unsigned int attribute_length; union { unsigned short cp_index; struct CodeAttribute { unsigned short max_stack; unsigned short max_locals; unsigned int code_length; struct Code_tag { enum CodeTag { CODE_OPERATOR=0, CODE_OPERAND_BYTE=1, CODE_OPERAND_SHORT=2 } tag; union { struct OpcodeInfo { unsigned char byte; char *mnemonic; unsigned char operand_count; char *operands_type; unsigned short max_stack; unsigned short max_locals; } *opcode; unsigned char operand_byte; unsigned short operand_short; } u; struct Code_tag *prev; struct Code_tag *next; } *code; unsigned short exception_table_length; struct Exception_tag { unsigned short start_pc; unsigned short end_pc; unsigned short handler_pc; unsigned short catch_type; struct Exception_tag *prev; struct Exception_tag *next; } *exception_table; unsigned short attributes_count; struct AttributeInfo_tag *attributes; unsigned short this_class_index; char *parameter_name; } code_attribute; struct ExceptionsAttribute { unsigned short number_of_exceptions; struct ExceptionIndex_tag { unsigned short exception_index; struct ExceptionIndex_tag *prev; struct ExceptionIndex_tag *next; } *exception_index_table; } exceptions_attribute; struct InnerClassesAttribute { unsigned short number_of_classes; struct InnerClass_tag { unsigned short inner_class_info_index; unsigned short outer_class_info_index; unsigned short inner_name_index; unsigned short inner_class_access_flags; } *classes; } inner_classes_attribute; unsigned char dummy; struct LineNumberTableAttribute { unsigned short line_number_table_length; struct LineNumber_tag { unsigned short start_pc; unsigned short line_number; struct LineNumber_tag *prev; struct LineNumber_tag *next; } *line_number_table; } line_number_table_attribute; struct LocalVariableTableAttribute { unsigned short local_variable_table_length; struct LocalVariable_tag { unsigned short start_pc; unsigned short length; unsigned short name_index; unsigned short descriptor_index; unsigned short index; struct LocalVariable_tag *prev; struct LocalVariable_tag *next; } *local_variable_table; } local_variable_table_attribute; } u; struct AttributeInfo_tag *prev; struct AttributeInfo_tag *next; } *

user_defined_types: struct AttributeInfo_tag { enum AttributeTag tag; unsigned short attribute_name_index; unsigned int attribute_length; union { unsigned short cp_index; struct CodeAttribute code_attribute; struct ExceptionsAttribute exceptions_attribute; struct InnerClassesAttribute inner_classes_attribute; unsigned char dummy; struct LineNumberTableAttribute line_number_table_attribute; struct LocalVariableTableAttribute local_variable_table_attribute; } u; struct AttributeInfo_tag *prev; struct AttributeInfo_tag *next; }

user_defined_types: struct CodeAttribute { unsigned short max_stack; unsigned short max_locals; unsigned int code_length; struct Code_tag *code; unsigned short exception_table_length; struct Exception_tag *exception_table; unsigned short attributes_count; struct AttributeInfo_tag *attributes; unsigned short this_class_index; char *parameter_name; }

user_defined_types: struct ExceptionsAttribute { unsigned short number_of_exceptions; struct ExceptionIndex_tag *exception_index_table; }

user_defined_types: struct InnerClassesAttribute { unsigned short number_of_classes; struct InnerClass_tag *classes; }

user_defined_types: struct LineNumberTableAttribute { unsigned short line_number_table_length; struct LineNumber_tag *line_number_table; }

user_defined_types: struct LocalVariableTableAttribute { unsigned short local_variable_table_length; struct LocalVariable_tag *local_variable_table; }

user_defined_types: struct Code_tag { enum CodeTag tag; union { struct OpcodeInfo *opcode; unsigned char operand_byte; unsigned short operand_short; } u; struct Code_tag *prev; struct Code_tag *next; }


original_code:
static Code *add_code(CodeAttribute *ca, Opcode op, ...){
    OpcodeInfo *oi;
    Code *operator, *operand;
    va_list args;
    int i;
    oi = &(opcode_table[op]);
    if(ca->code){
        operator = classfile_storage_malloc(sizeof(Code));
        operator->next = ((void *)0);
        operator->prev = ca->code->prev;
        operator->prev->next = operator;
        ca->code->prev = operator;
    } else{
        ca->code = classfile_storage_malloc(sizeof(Code));
        ca->code->next = ((void *)0);
        ca->code->prev = ca->code;
        operator = ca->code;
    }
    operator->tag = CODE_OPERATOR;
    operator->u.opcode = oi;
    ca->max_stack += oi->max_stack;
    ca->max_locals += oi->max_locals;
    ca->code_length++;
    __builtin_va_start(args,op);
    for(i = 0; i < oi->operand_count; i++){
        operand = classfile_storage_malloc(sizeof(Code));
        operand->next = ((void *)0);
        operand->prev = ca->code->prev;
        operand->prev->next = operand;
        ca->code->prev = operand;
        switch(oi->operands_type[i]){
            case 'b':
                operand->tag = CODE_OPERAND_BYTE;
                operand->u.operand_byte = __builtin_va_arg(args,int);
                ca->code_length++;
                break;
            case 's':
                operand->tag = CODE_OPERAND_SHORT;
                operand->u.operand_short = __builtin_va_arg(args,int);
                ca->code_length += 2;
        }
    }
    __builtin_va_end(args);
    return operator;
}

canonical_original_code:
static struct Code_tag *add_code(struct CodeAttribute *ca, enum Opcode op, ...){
    struct OpcodeInfo *oi;
    struct Code_tag *operator; struct Code_tag *operand;
    __builtin_va_list args;
    int i;
    oi = &(opcode_table[op]);
    if(ca->code){
        operator = classfile_storage_malloc(sizeof(Code));
        operator->next = ((void *)0);
        operator->prev = ca->code->prev;
        operator->prev->next = operator;
        ca->code->prev = operator;
    } else{
        ca->code = classfile_storage_malloc(sizeof(Code));
        ca->code->next = ((void *)0);
        ca->code->prev = ca->code;
        operator = ca->code;
    }
    operator->tag = CODE_OPERATOR;
    operator->u.opcode = oi;
    ca->max_stack += oi->max_stack;
    ca->max_locals += oi->max_locals;
    ca->code_length++;
    __builtin_va_start(args,op);
    for(i = 0; i < oi->operand_count; i++){
        operand = classfile_storage_malloc(sizeof(Code));
        operand->next = ((void *)0);
        operand->prev = ca->code->prev;
        operand->prev->next = operand;
        ca->code->prev = operand;
        switch(oi->operands_type[i]){
            case 'b':
                operand->tag = CODE_OPERAND_BYTE;
                operand->u.operand_byte = __builtin_va_arg(args,int);
                ca->code_length++;
                break;
            case 's':
                operand->tag = CODE_OPERAND_SHORT;
                operand->u.operand_short = __builtin_va_arg(args,int);
                ca->code_length += 2;
        }
    }
    __builtin_va_end(args);
    return operator;
}

variable_types: struct CodeAttribute { unsigned short max_stack; unsigned short max_locals; unsigned int code_length; struct Code_tag *code; unsigned short exception_table_length; struct Exception_tag { unsigned short start_pc; unsigned short end_pc; unsigned short handler_pc; unsigned short catch_type; struct Exception_tag *prev; struct Exception_tag *next; } *exception_table; unsigned short attributes_count; struct AttributeInfo_tag { enum AttributeTag { ATTRIBUTE_ConstantValue=1, ATTRIBUTE_Code=2, ATTRIBUTE_Exceptions=3, ATTRIBUTE_InnerClasses=4, ATTRIBUTE_Synthetic=5, ATTRIBUTE_SourceFile=6, ATTRIBUTE_LineNumberTable=7, ATTRIBUTE_LocalVariableTable=8, ATTRIBUTE_Deprecated=9 } tag; unsigned short attribute_name_index; unsigned int attribute_length; union { unsigned short cp_index; struct CodeAttribute code_attribute; struct ExceptionsAttribute { unsigned short number_of_exceptions; struct ExceptionIndex_tag { unsigned short exception_index; struct ExceptionIndex_tag *prev; struct ExceptionIndex_tag *next; } *exception_index_table; } exceptions_attribute; struct InnerClassesAttribute { unsigned short number_of_classes; struct InnerClass_tag { unsigned short inner_class_info_index; unsigned short outer_class_info_index; unsigned short inner_name_index; unsigned short inner_class_access_flags; } *classes; } inner_classes_attribute; unsigned char dummy; struct LineNumberTableAttribute { unsigned short line_number_table_length; struct LineNumber_tag { unsigned short start_pc; unsigned short line_number; struct LineNumber_tag *prev; struct LineNumber_tag *next; } *line_number_table; } line_number_table_attribute; struct LocalVariableTableAttribute { unsigned short local_variable_table_length; struct LocalVariable_tag { unsigned short start_pc; unsigned short length; unsigned short name_index; unsigned short descriptor_index; unsigned short index; struct LocalVariable_tag *prev; struct LocalVariable_tag *next; } *local_variable_table; } local_variable_table_attribute; } u; struct AttributeInfo_tag *prev; struct AttributeInfo_tag *next; } *attributes; unsigned short this_class_index; char *parameter_name; } *

variable_types: enum Opcode { ICONST_M1=1, ICONST_0=2, ICONST_1=3, ICONST_2=4, ICONST_3=5, ICONST_4=6, ICONST_5=7, BIPUSH=8, SIPUSH=9, LDC=10, LDC_W=11, ILOAD=12, ILOAD_0=13, ILOAD_1=14, ILOAD_2=15, ILOAD_3=16, ALOAD_0=17, AALOAD=18, ISTORE=19, ISTORE_0=20, ISTORE_1=21, ISTORE_2=22, ISTORE_3=23, POP=24, POP2=25, DUP=26, DUP_X1=27, DUP_X2=28, DUP2=29, DUP2_X1=30, DUP2_X2=31, SWAP=32, IADD=33, ISUB=34, IMUL=35, IDIV=36, IREM=37, INEG=38, IINC=39, IFEQ=40, IFNE=41, IFLT=42, IFGE=43, IFGT=44, IFLE=45, IF_ICOMPEQ=46, IF_ICOMPNE=47, IF_ICOMPLT=48, IF_ICOMPGE=49, IF_ICOMPGT=50, IF_ICOMPLE=51, GOTO=52, IRETURN=53, RETURN=54, GETSTATIC=55, PUTSTATIC=56, INVOKEVIRTUAL=57, INVOKESPECIAL=58, INVOKESTATIC=59 }

variable_types: struct Code_tag { enum CodeTag { CODE_OPERATOR=0, CODE_OPERAND_BYTE=1, CODE_OPERAND_SHORT=2 } tag; union { struct OpcodeInfo { unsigned char byte; char *mnemonic; unsigned char operand_count; char *operands_type; unsigned short max_stack; unsigned short max_locals; } *opcode; unsigned char operand_byte; unsigned short operand_short; } u; struct Code_tag *prev; struct Code_tag *next; } *


decompiled_code:
__int64 __fastcall generate_main_prefix_code(__int64 a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9)
{
double v9; // xmm4_8
double v10; // xmm5_8
double v11; // xmm4_8
double v12; // xmm5_8
unsigned __int16 v13; // ax
double v14; // xmm4_8
double v15; // xmm5_8
double v16; // xmm4_8
double v17; // xmm5_8

add_code(a1, 0x11u, a2, a3, a4, a5, a6, a7, a8, a9);
add_code(a1, 2u, a2, a3, a4, a5, v9, v10, a8, a9);
add_code(a1, 0x12u, a2, a3, a4, a5, v11, v12, a8, a9);
v13 = add_constant_method_info("java/lang/Integer", "parseInt", "(Ljava/lang/String;)I");
add_code(a1, 0x3Bu, a2, a3, a4, a5, v14, v15, a8, a9, v13);
return add_code(a1, 0x14u, a2, a3, a4, a5, v16, v17, a8, a9);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9)
{
double v9; // xmm4_8
double v10; // xmm5_8
double v11; // xmm4_8
double v12; // xmm5_8
unsigned __int16 v13; // ax
double v14; // xmm4_8
double v15; // xmm5_8
double v16; // xmm4_8
double v17; // xmm5_8

func1(a1, 0x11u, a2, a3, a4, a5, a6, a7, a8, a9);
func1(a1, 2u, a2, a3, a4, a5, v9, v10, a8, a9);
func1(a1, 0x12u, a2, a3, a4, a5, v11, v12, a8, a9);
v13 = add_constant_method_info("java/lang/Integer", "parseInt", "(Ljava/lang/String;)I");
func1(a1, 0x3Bu, a2, a3, a4, a5, v14, v15, a8, a9, v13);
return func1(a1, 0x14u, a2, a3, a4, a5, v16, v17, a8, a9);
}

original_code:
static void generate_main_prefix_code(CodeAttribute *ca){
    add_code(ca, ALOAD_0);
    add_code(ca, ICONST_0);
    add_code(ca, AALOAD);
    add_code(ca, INVOKESTATIC, add_constant_method_info("java/lang/Integer", "parseInt", "(Ljava/lang/String;)I"));
    add_code(ca, ISTORE_0);
}

canonical_original_code:
static void generate_main_prefix_code(struct CodeAttribute *ca){
    add_code(ca, ALOAD_0);
    add_code(ca, ICONST_0);
    add_code(ca, AALOAD);
    add_code(ca, INVOKESTATIC, add_constant_method_info("java/lang/Integer", "parseInt", "(Ljava/lang/String;)I"));
    add_code(ca, ISTORE_0);
}

variable_types: struct CodeAttribute { unsigned short max_stack; unsigned short max_locals; unsigned int code_length; struct Code_tag { enum CodeTag { CODE_OPERATOR=0, CODE_OPERAND_BYTE=1, CODE_OPERAND_SHORT=2 } tag; union { struct OpcodeInfo { unsigned char byte; char *mnemonic; unsigned char operand_count; char *operands_type; unsigned short max_stack; unsigned short max_locals; } *opcode; unsigned char operand_byte; unsigned short operand_short; } u; struct Code_tag *prev; struct Code_tag *next; } *code; unsigned short exception_table_length; struct Exception_tag { unsigned short start_pc; unsigned short end_pc; unsigned short handler_pc; unsigned short catch_type; struct Exception_tag *prev; struct Exception_tag *next; } *exception_table; unsigned short attributes_count; struct AttributeInfo_tag { enum AttributeTag { ATTRIBUTE_ConstantValue=1, ATTRIBUTE_Code=2, ATTRIBUTE_Exceptions=3, ATTRIBUTE_InnerClasses=4, ATTRIBUTE_Synthetic=5, ATTRIBUTE_SourceFile=6, ATTRIBUTE_LineNumberTable=7, ATTRIBUTE_LocalVariableTable=8, ATTRIBUTE_Deprecated=9 } tag; unsigned short attribute_name_index; unsigned int attribute_length; union { unsigned short cp_index; struct CodeAttribute code_attribute; struct ExceptionsAttribute { unsigned short number_of_exceptions; struct ExceptionIndex_tag { unsigned short exception_index; struct ExceptionIndex_tag *prev; struct ExceptionIndex_tag *next; } *exception_index_table; } exceptions_attribute; struct InnerClassesAttribute { unsigned short number_of_classes; struct InnerClass_tag { unsigned short inner_class_info_index; unsigned short outer_class_info_index; unsigned short inner_name_index; unsigned short inner_class_access_flags; } *classes; } inner_classes_attribute; unsigned char dummy; struct LineNumberTableAttribute { unsigned short line_number_table_length; struct LineNumber_tag { unsigned short start_pc; unsigned short line_number; struct LineNumber_tag *prev; struct LineNumber_tag *next; } *line_number_table; } line_number_table_attribute; struct LocalVariableTableAttribute { unsigned short local_variable_table_length; struct LocalVariable_tag { unsigned short start_pc; unsigned short length; unsigned short name_index; unsigned short descriptor_index; unsigned short index; struct LocalVariable_tag *prev; struct LocalVariable_tag *next; } *local_variable_table; } local_variable_table_attribute; } u; struct AttributeInfo_tag *prev; struct AttributeInfo_tag *next; } *attributes; unsigned short this_class_index; char *parameter_name; } *


decompiled_code:
__int64 __fastcall generate_int_expression(__int64 a1, unsigned int a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10)
{
__int64 result; // rax

switch ( a2 )
{
case 0u:
result = add_code(a1, 2u, a3, a4, a5, a6, a7, a8, a9, a10);
break;
case 1u:
result = add_code(a1, 3u, a3, a4, a5, a6, a7, a8, a9, a10);
break;
case 2u:
result = add_code(a1, 4u, a3, a4, a5, a6, a7, a8, a9, a10);
break;
case 3u:
result = add_code(a1, 5u, a3, a4, a5, a6, a7, a8, a9, a10);
break;
case 4u:
result = add_code(a1, 6u, a3, a4, a5, a6, a7, a8, a9, a10);
break;
case 5u:
result = add_code(a1, 7u, a3, a4, a5, a6, a7, a8, a9, a10);
break;
default:
if ( a2 + 128 <= 0xFF )
{
result = add_code(a1, 8u, a3, a4, a5, a6, a7, a8, a9, a10, a2);
}
else
{
result = a2 + 0x8000;
if ( (unsigned int)result <= 0xFFFF )
result = add_code(a1, 9u, a3, a4, a5, a6, a7, a8, a9, a10, a2);
}
break;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, unsigned int a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10)
{
__int64 result; // rax

switch ( a2 )
{
case 0u:
result = func1(a1, 2u, a3, a4, a5, a6, a7, a8, a9, a10);
break;
case 1u:
result = func1(a1, 3u, a3, a4, a5, a6, a7, a8, a9, a10);
break;
case 2u:
result = func1(a1, 4u, a3, a4, a5, a6, a7, a8, a9, a10);
break;
case 3u:
result = func1(a1, 5u, a3, a4, a5, a6, a7, a8, a9, a10);
break;
case 4u:
result = func1(a1, 6u, a3, a4, a5, a6, a7, a8, a9, a10);
break;
case 5u:
result = func1(a1, 7u, a3, a4, a5, a6, a7, a8, a9, a10);
break;
default:
if ( a2 + 128 <= 0xFF )
{
result = func1(a1, 8u, a3, a4, a5, a6, a7, a8, a9, a10, a2);
}
else
{
result = a2 + 0x8000;
if ( (unsigned int)result <= 0xFFFF )
result = func1(a1, 9u, a3, a4, a5, a6, a7, a8, a9, a10, a2);
}
break;
}
return result;
}

original_code:
static void generate_int_expression(CodeAttribute *ca, int value){
    switch(value){
        case 0:
            add_code(ca, ICONST_0);
            return;
            break;
        case 1:
            add_code(ca, ICONST_1);
            return;
            break;
        case 2:
            add_code(ca, ICONST_2);
            return;
            break;
        case 3:
            add_code(ca, ICONST_3);
            return;
            break;
        case 4:
            add_code(ca, ICONST_4);
            return;
            break;
        case 5:
            add_code(ca, ICONST_5);
            return;
            break;
    }
    if(-128 <= value && value < 128)
        add_code(ca, BIPUSH, value);
    else if(-32768 <= value && value < 32768)
        add_code(ca, SIPUSH, value);
    else{
    }
}

canonical_original_code:
static void generate_int_expression(struct CodeAttribute *ca, int value){
    switch(value){
        case 0:
            add_code(ca, ICONST_0);
            return;
            break;
        case 1:
            add_code(ca, ICONST_1);
            return;
            break;
        case 2:
            add_code(ca, ICONST_2);
            return;
            break;
        case 3:
            add_code(ca, ICONST_3);
            return;
            break;
        case 4:
            add_code(ca, ICONST_4);
            return;
            break;
        case 5:
            add_code(ca, ICONST_5);
            return;
            break;
    }
    if(-128 <= value && value < 128)
        add_code(ca, BIPUSH, value);
    else if(-32768 <= value && value < 32768)
        add_code(ca, SIPUSH, value);
    else{
    }
}

variable_types: value int

user_defined_types: struct Exception_tag { unsigned short start_pc; unsigned short end_pc; unsigned short handler_pc; unsigned short catch_type; struct Exception_tag *prev; struct Exception_tag *next; }

user_defined_types: enum CodeTag { CODE_OPERATOR=0, CODE_OPERAND_BYTE=1, CODE_OPERAND_SHORT=2 }

user_defined_types: enum AttributeTag { ATTRIBUTE_ConstantValue=1, ATTRIBUTE_Code=2, ATTRIBUTE_Exceptions=3, ATTRIBUTE_InnerClasses=4, ATTRIBUTE_Synthetic=5, ATTRIBUTE_SourceFile=6, ATTRIBUTE_LineNumberTable=7, ATTRIBUTE_LocalVariableTable=8, ATTRIBUTE_Deprecated=9 }

user_defined_types: struct OpcodeInfo { unsigned char byte; char *mnemonic; unsigned char operand_count; char *operands_type; unsigned short max_stack; unsigned short max_locals; }

user_defined_types: struct ExceptionIndex_tag { unsigned short exception_index; struct ExceptionIndex_tag *prev; struct ExceptionIndex_tag *next; }

user_defined_types: struct InnerClass_tag { unsigned short inner_class_info_index; unsigned short outer_class_info_index; unsigned short inner_name_index; unsigned short inner_class_access_flags; }

user_defined_types: struct LineNumber_tag { unsigned short start_pc; unsigned short line_number; struct LineNumber_tag *prev; struct LineNumber_tag *next; }

user_defined_types: struct LocalVariable_tag { unsigned short start_pc; unsigned short length; unsigned short name_index; unsigned short descriptor_index; unsigned short index; struct LocalVariable_tag *prev; struct LocalVariable_tag *next; }


decompiled_code:
__int64 __fastcall generate_constructor_code(__int64 a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9)
{
unsigned __int16 v9; // ax
double v10; // xmm4_8
double v11; // xmm5_8
double v12; // xmm4_8
double v13; // xmm5_8

add_code(a1, 0x11u, a2, a3, a4, a5, a6, a7, a8, a9);
v9 = add_constant_method_info("java/lang/Object", "<init>", "()V");
add_code(a1, 0x3Au, a2, a3, a4, a5, v10, v11, a8, a9, v9);
return add_code(a1, 0x36u, a2, a3, a4, a5, v12, v13, a8, a9);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, double a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9)
{
unsigned __int16 v9; // ax
double v10; // xmm4_8
double v11; // xmm5_8
double v12; // xmm4_8
double v13; // xmm5_8

func1(a1, 0x11u, a2, a3, a4, a5, a6, a7, a8, a9);
v9 = add_constant_method_info("java/lang/Object", "<init>", "()V");
func1(a1, 0x3Au, a2, a3, a4, a5, v10, v11, a8, a9, v9);
return func1(a1, 0x36u, a2, a3, a4, a5, v12, v13, a8, a9);
}

original_code:
static void generate_constructor_code(CodeAttribute *ca){
    add_code(ca, ALOAD_0);
    add_code(ca, INVOKESPECIAL, add_constant_method_info("java/lang/Object", "<init>", "()V"));
    add_code(ca, RETURN);
}

canonical_original_code:
static void generate_constructor_code(struct CodeAttribute *ca){
    add_code(ca, ALOAD_0);
    add_code(ca, INVOKESPECIAL, add_constant_method_info("java/lang/Object", "<init>", "()V"));
    add_code(ca, RETURN);
}


decompiled_code:
__int64 __fastcall generate_expression_code(__int64 a1, unsigned int *a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10)
{
__int64 result; // rax

result = *a2;
switch ( *a2 )
{
case 0u:
result = generate_int_expression(a1, a2[2], a3, a4, a5, a6, a7, a8, a9, a10);
break;
case 1u:
result = generate_identifier_expression_isra_0(
a1,
a2[1],
*((const char **)a2 + 1),
a3,
a4,
a5,
a6,
a7,
a8,
a9,
a10);
break;
case 2u:
result = generate_binary_expression_isra_0(
a1,
a2[2],
*((_QWORD *)a2 + 2),
*((_QWORD *)a2 + 3),
a3,
a4,
a5,
a6,
a7,
a8,
a9,
a10);
break;
case 3u:
result = generate_minus_expression(a1, *((_QWORD *)a2 + 1));
break;
case 4u:
result = generate_call_expression(a1, a2 + 2);
break;
default:
return result;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, unsigned int *a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10)
{
__int64 result; // rax

result = *a2;
switch ( *a2 )
{
case 0u:
result = func3(a1, a2[2], a3, a4, a5, a6, a7, a8, a9, a10);
break;
case 1u:
result = func5(
a1,
a2[1],
*((const char **)a2 + 1),
a3,
a4,
a5,
a6,
a7,
a8,
a9,
a10);
break;
case 2u:
result = func6(
a1,
a2[2],
*((_QWORD *)a2 + 2),
*((_QWORD *)a2 + 3),
a3,
a4,
a5,
a6,
a7,
a8,
a9,
a10);
break;
case 3u:
result = func8(a1, *((_QWORD *)a2 + 1));
break;
case 4u:
result = func9(a1, a2 + 2);
break;
default:
return result;
}
return result;
}

original_code:
static void generate_expression_code(CodeAttribute *ca, Expression *ex){
    switch(ex->kind){
        case INT_EXPRESSION:
            generate_int_expression(ca, ex->u.int_value);
            break;
        case IDENTIFIER_EXPRESSION:
            generate_identifier_expression(ca, ex);
            break;
        case BINARY_EXPRESSION:
            generate_binary_expression(ca, ex->u.binary_expression);
            break;
        case MINUS_EXPRESSION:
            generate_minus_expression(ca, ex->u.minus_expression);
            break;
        case CALL_EXPRESSION:
            generate_call_expression(ca, &(ex->u.call_expression));
    }
}

canonical_original_code:
static void generate_expression_code(struct CodeAttribute *ca, struct Expression_tag *ex){
    switch(ex->kind){
        case INT_EXPRESSION:
            generate_int_expression(ca, ex->u.int_value);
            break;
        case IDENTIFIER_EXPRESSION:
            generate_identifier_expression(ca, ex);
            break;
        case BINARY_EXPRESSION:
            generate_binary_expression(ca, ex->u.binary_expression);
            break;
        case MINUS_EXPRESSION:
            generate_minus_expression(ca, ex->u.minus_expression);
            break;
        case CALL_EXPRESSION:
            generate_call_expression(ca, &(ex->u.call_expression));
    }
}

variable_types: struct Expression_tag { enum ExpressionKind { INT_EXPRESSION=0, IDENTIFIER_EXPRESSION=1, BINARY_EXPRESSION=2, MINUS_EXPRESSION=3, CALL_EXPRESSION=4 } kind; int line_number; union { int int_value; char *identifier; struct BinaryExpression { enum OperatorKind { ADD_OPERATOR=0, SUB_OPERATOR=1, MUL_OPERATOR=2, DIV_OPERATOR=3, MOD_OPERATOR=4 } kind; struct Expression_tag *left; struct Expression_tag *right; } binary_expression; struct Expression_tag *minus_expression; struct CallExpression { char *identifier; struct Expression_tag *parameter_expression; } call_expression; } u; } *

user_defined_types: struct Expression_tag { enum ExpressionKind kind; int line_number; union { int int_value; char *identifier; struct BinaryExpression binary_expression; struct Expression_tag *minus_expression; struct CallExpression call_expression; } u; }

user_defined_types: struct BinaryExpression { enum OperatorKind kind; struct Expression_tag *left; struct Expression_tag *right; }


decompiled_code:
__int64 __fastcall generate_minus_expression(__int64 a1, unsigned int *a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10)
{
double v10; // xmm4_8
double v11; // xmm5_8

generate_expression_code(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
return add_code(a1, 0x26u, a3, a4, a5, a6, v10, v11, a9, a10);
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, unsigned int *a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10)
{
double v10; // xmm4_8
double v11; // xmm5_8

func7(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
return func1(a1, 0x26u, a3, a4, a5, a6, v10, v11, a9, a10);
}

original_code:
static void generate_minus_expression(CodeAttribute *ca, Expression *me){
    generate_expression_code(ca, me);
    add_code(ca, INEG);
}

canonical_original_code:
static void generate_minus_expression(struct CodeAttribute *ca, struct Expression_tag *me){
    generate_expression_code(ca, me);
    add_code(ca, INEG);
}

user_defined_types: enum ExpressionKind { INT_EXPRESSION=0, IDENTIFIER_EXPRESSION=1, BINARY_EXPRESSION=2, MINUS_EXPRESSION=3, CALL_EXPRESSION=4 }

user_defined_types: struct AttributeInfo_tag { enum AttributeTag tag; unsigned short attribute_name_index; unsigned int attribute_length; union { unsigned short cp_index; struct CodeAttribute code_attribute; struct ExceptionsAttribute exceptions_attribute; struct InnerClassesAttribute inner_classes_attribute; unsigned char dummy; struct LineNumberTableAttribute line_number_table_attribute; struct LocalVariableTableAttribute local_variable_table_attribute; } u; struct AttributeInfo_tag *prev; struct AttributeInfo_tag *next; }

user_defined_types: struct CallExpression { char *identifier; struct Expression_tag *parameter_expression; }

user_defined_types: enum OperatorKind { ADD_OPERATOR=0, SUB_OPERATOR=1, MUL_OPERATOR=2, DIV_OPERATOR=3, MOD_OPERATOR=4 }


decompiled_code:
__int64 __fastcall generate_call_expression(__int64 a1, _QWORD *a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10)
{
unsigned int *v12; // rsi
__int64 v13; // rdi
const char *v14; // rdx
unsigned __int16 v15; // ax
double v16; // xmm4_8
double v17; // xmm5_8

v12 = (unsigned int *)a2[1];
if ( v12 )
{
generate_expression_code(a1, v12, a3, a4, a5, a6, a7, a8, a9, a10);
v13 = *(unsigned __int16 *)(a1 + 48);
v14 = "(I)I";
}
else
{
v13 = *(unsigned __int16 *)(a1 + 48);
v14 = "()I";
}
v15 = add_constant_method_info_with_class(v13, *a2, v14);
return add_code(a1, 0x3Bu, a3, a4, a5, a6, v16, v17, a9, a10, v15);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, _QWORD *a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10)
{
unsigned int *v12; // rsi
__int64 v13; // rdi
const char *v14; // rdx
unsigned __int16 v15; // ax
double v16; // xmm4_8
double v17; // xmm5_8

v12 = (unsigned int *)a2[1];
if ( v12 )
{
func7(a1, v12, a3, a4, a5, a6, a7, a8, a9, a10);
v13 = *(unsigned __int16 *)(a1 + 48);
v14 = "(I)I";
}
else
{
v13 = *(unsigned __int16 *)(a1 + 48);
v14 = "()I";
}
v15 = add_constant_method_info_with_class(v13, *a2, v14);
return func1(a1, 0x3Bu, a3, a4, a5, a6, v16, v17, a9, a10, v15);
}

original_code:
static void generate_call_expression(CodeAttribute *ca, CallExpression *ce){
    if(ce->parameter_expression){
        generate_expression_code(ca, ce->parameter_expression);
        add_code(ca, INVOKESTATIC, add_constant_method_info_with_class(ca->this_class_index, ce->identifier, "(I)I"));
    } else{
        add_code(ca, INVOKESTATIC, add_constant_method_info_with_class(ca->this_class_index, ce->identifier, "()I"));
    }
}

canonical_original_code:
static void generate_call_expression(struct CodeAttribute *ca, struct CallExpression *ce){
    if(ce->parameter_expression){
        generate_expression_code(ca, ce->parameter_expression);
        add_code(ca, INVOKESTATIC, add_constant_method_info_with_class(ca->this_class_index, ce->identifier, "(I)I"));
    } else{
        add_code(ca, INVOKESTATIC, add_constant_method_info_with_class(ca->this_class_index, ce->identifier, "()I"));
    }
}

variable_types: struct CallExpression { char *identifier; struct Expression_tag { enum ExpressionKind { INT_EXPRESSION=0, IDENTIFIER_EXPRESSION=1, BINARY_EXPRESSION=2, MINUS_EXPRESSION=3, CALL_EXPRESSION=4 } kind; int line_number; union { int int_value; char *identifier; struct BinaryExpression { enum OperatorKind { ADD_OPERATOR=0, SUB_OPERATOR=1, MUL_OPERATOR=2, DIV_OPERATOR=3, MOD_OPERATOR=4 } kind; struct Expression_tag *left; struct Expression_tag *right; } binary_expression; struct Expression_tag *minus_expression; struct CallExpression call_expression; } u; } *parameter_expression; } *

user_defined_types: struct CodeAttribute { unsigned short max_stack; unsigned short max_locals; unsigned int code_length; struct Code_tag *code; unsigned short exception_table_length; struct Exception_tag *exception_table; unsigned short attributes_count; struct AttributeInfo_tag *attributes; unsigned short this_class_index; char *parameter_name; }

user_defined_types: struct ExceptionsAttribute { unsigned short number_of_exceptions; struct ExceptionIndex_tag *exception_index_table; }

user_defined_types: struct InnerClassesAttribute { unsigned short number_of_classes; struct InnerClass_tag *classes; }

user_defined_types: struct LineNumberTableAttribute { unsigned short line_number_table_length; struct LineNumber_tag *line_number_table; }


decompiled_code:
__int64 __fastcall generate_function_pattern_code(__int64 a1, __int64 a2, double a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10)
{
double v11; // xmm4_8
double v12; // xmm5_8
unsigned int v13; // esi
int v14; // er13
double v15; // xmm4_8
double v16; // xmm5_8
__int64 v17; // r12
double v18; // xmm4_8
double v19; // xmm5_8
double v20; // xmm4_8
double v21; // xmm5_8
__int64 result; // rax

add_code(a1, 0xDu, a3, a4, a5, a6, a7, a8, a9, a10);
v13 = *(_DWORD *)a2;
if ( v13 )
{
generate_int_expression(a1, v13, a3, a4, a5, a6, v11, v12, a9, a10);
v14 = *(unsigned __int16 *)(a1 + 4);
v17 = add_code(a1, 0x2Fu, a3, a4, a5, a6, v15, v16, a9, a10, 0LL);
}
else
{
v14 = *(unsigned __int16 *)(a1 + 4);
v17 = add_code(a1, 0x29u, a3, a4, a5, a6, v11, v12, a9, a10, 0LL);
}
generate_expression_code(a1, *(unsigned int **)(*(_QWORD *)(a2 + 8) + 8LL), a3, a4, a5, a6, v18, v19, a9, a10);
add_code(a1, 0x35u, a3, a4, a5, a6, v20, v21, a9, a10);
result = (unsigned int)(*(_DWORD *)(a1 + 4) - v14);
*(_WORD *)(*(_QWORD *)(v17 + 24) + 8LL) = *(_WORD *)(a1 + 4) - v14;
return result;
}

original_code:
static void generate_function_pattern_code(CodeAttribute *ca, FunctionPattern *fp){
    Code *jump_operator;
    u2 start_pc;
    add_code(ca, ILOAD_0);
    if(fp->pattern){
        generate_int_expression(ca, fp->pattern);
        start_pc = ca->code_length;
        jump_operator = add_code(ca, IF_ICOMPNE, 0);
    }
    else{
        start_pc = ca->code_length;
        jump_operator = add_code(ca, IFNE, 0);
    }
    generate_expression_code(ca, fp->statement->expression);
    add_code(ca, IRETURN);
    jump_operator->next->u.operand_short = ca->code_length - start_pc;
}

canonical_original_code:
static void generate_function_pattern_code(struct CodeAttribute *ca, struct FunctionPattern_tag *fp){
    struct Code_tag *jump_operator;
    unsigned short start_pc;
    add_code(ca, ILOAD_0);
    if(fp->pattern){
        generate_int_expression(ca, fp->pattern);
        start_pc = ca->code_length;
        jump_operator = add_code(ca, IF_ICOMPNE, 0);
    }
    else{
        start_pc = ca->code_length;
        jump_operator = add_code(ca, IFNE, 0);
    }
    generate_expression_code(ca, fp->statement->expression);
    add_code(ca, IRETURN);
    jump_operator->next->u.operand_short = ca->code_length - start_pc;
}

variable_types: struct FunctionPattern_tag { int pattern; struct Statement { enum StatementType { NONE_TYPE_STATEMENT=0, MAIN_STATEMENT=1, CONSTRUCTOR_STATEMENT=2, FUNCTION_STATEMENT=3, FUNCTION_PATTERN_STATEMENT=4 } type; int line_number; struct Expression_tag { enum ExpressionKind { INT_EXPRESSION=0, IDENTIFIER_EXPRESSION=1, BINARY_EXPRESSION=2, MINUS_EXPRESSION=3, CALL_EXPRESSION=4 } kind; int line_number; union { int int_value; char *identifier; struct BinaryExpression { enum OperatorKind { ADD_OPERATOR=0, SUB_OPERATOR=1, MUL_OPERATOR=2, DIV_OPERATOR=3, MOD_OPERATOR=4 } kind; struct Expression_tag *left; struct Expression_tag *right; } binary_expression; struct Expression_tag *minus_expression; struct CallExpression { char *identifier; struct Expression_tag *parameter_expression; } call_expression; } u; } *expression; } *statement; struct FunctionPattern_tag *prev; struct FunctionPattern_tag *next; } *

user_defined_types: struct FunctionPattern_tag { int pattern; struct Statement *statement; struct FunctionPattern_tag *prev; struct FunctionPattern_tag *next; }

user_defined_types: struct Code_tag { enum CodeTag tag; union { struct OpcodeInfo *opcode; unsigned char operand_byte; unsigned short operand_short; } u; struct Code_tag *prev; struct Code_tag *next; }

user_defined_types: enum CodeTag { CODE_OPERATOR=0, CODE_OPERAND_BYTE=1, CODE_OPERAND_SHORT=2 }

user_defined_types: struct Exception_tag { unsigned short start_pc; unsigned short end_pc; unsigned short handler_pc; unsigned short catch_type; struct Exception_tag *prev; struct Exception_tag *next; }

user_defined_types: struct Statement { enum StatementType type; int line_number; struct Expression_tag *expression; }

user_defined_types: struct LocalVariableTableAttribute { unsigned short local_variable_table_length; struct LocalVariable_tag *local_variable_table; }


decompiled_code:
__int64 __fastcall create_attribute_code(__int64 a1, unsigned int **a2, __int64 a3, double a4, double a5, double a6, double a7, double a8, double a9, double a10, double a11)
{
bool v12; // zf
int v13; // eax
__int64 result; // rax
unsigned __int16 v15; // ax
double v16; // xmm4_8
double v17; // xmm5_8
double v18; // xmm4_8
double v19; // xmm5_8
double v20; // xmm4_8
double v21; // xmm5_8
unsigned __int16 v22; // ax
double v23; // xmm4_8
double v24; // xmm5_8

*(_QWORD *)a1 = 0x10000LL;
v12 = *(_DWORD *)a2 == 1;
*(_WORD *)(a1 + 16) = 0;
*(_QWORD *)(a1 + 24) = 0LL;
if ( v12 )
{
v22 = add_constant_field_info("java/lang/System", "out", "Ljava/io/PrintStream;");
add_code(a1, 0x37u, a4, a5, a6, a7, v23, v24, a10, a11, v22);
if ( *(_QWORD *)(a1 + 56) )
generate_main_prefix_code(a1, a4, a5, a6, a7, a8, a9, a10, a11);
}
while ( a3 )
{
generate_function_pattern_code(a1, a3, a4, a5, a6, a7, a8, a9, a10, a11);
a3 = *(_QWORD *)(a3 + 24);
}
v13 = *(_DWORD *)a2;
if ( *(_DWORD *)a2 == 2 )
{
generate_constructor_code(a1, a4, a5, a6, a7, a8, a9, a10, a11);
result = (unsigned int)(*(_DWORD *)(a1 + 4) + 12);
}
else if ( v13 == 3 )
{
generate_expression_code(a1, a2[1], a4, a5, a6, a7, a8, a9, a10, a11);
add_code(a1, 0x35u, a4, a5, a6, a7, v20, v21, a10, a11);
result = (unsigned int)(*(_DWORD *)(a1 + 4) + 12);
}
else
{
if ( v13 == 1 )
{
generate_expression_code(a1, a2[1], a4, a5, a6, a7, a8, a9, a10, a11);
v15 = add_constant_method_info("java/io/PrintStream", "println", "(I)V");
add_code(a1, 0x39u, a4, a5, a6, a7, v16, v17, a10, a11, v15);
add_code(a1, 0x36u, a4, a5, a6, a7, v18, v19, a10, a11);
}
result = (unsigned int)(*(_DWORD *)(a1 + 4) + 12);
}
return result;
}

original_code:
static u4 create_attribute_code(CodeAttribute *ca, Statement *statement, FunctionPattern *pattern_list){
    ca->max_stack = 0;
    ca->max_locals = 1;
    ca->code_length = 0;
    ca->exception_table_length = 0;
    ca->exception_table = ((void *)0);
    if(statement->type == MAIN_STATEMENT){
        add_code(ca, GETSTATIC, add_constant_field_info("java/lang/System", "out", "Ljava/io/PrintStream;"));
        if(ca->parameter_name)
            generate_main_prefix_code(ca);
    }
    while(pattern_list){
        generate_function_pattern_code(ca, pattern_list);
        pattern_list = pattern_list->next;
    }
    switch(statement->type){
        case CONSTRUCTOR_STATEMENT:
            generate_constructor_code(ca);
            break;
        case MAIN_STATEMENT:
            generate_expression_code(ca, statement->expression);
            add_code(ca, INVOKEVIRTUAL, add_constant_method_info("java/io/PrintStream", "println", "(I)V"));
            add_code(ca, RETURN);
            break;
        case FUNCTION_STATEMENT:
            generate_expression_code(ca, statement->expression);
            add_code(ca, IRETURN);
            break;
        default:
            break;
    }
    return 12 + ca->code_length;
}

canonical_original_code:
static unsigned int create_attribute_code(struct CodeAttribute *ca, struct Statement *statement, struct FunctionPattern_tag *pattern_list){
    ca->max_stack = 0;
    ca->max_locals = 1;
    ca->code_length = 0;
    ca->exception_table_length = 0;
    ca->exception_table = ((void *)0);
    if(statement->type == MAIN_STATEMENT){
        add_code(ca, GETSTATIC, add_constant_field_info("java/lang/System", "out", "Ljava/io/PrintStream;"));
        if(ca->parameter_name)
            generate_main_prefix_code(ca);
    }
    while(pattern_list){
        generate_function_pattern_code(ca, pattern_list);
        pattern_list = pattern_list->next;
    }
    switch(statement->type){
        case CONSTRUCTOR_STATEMENT:
            generate_constructor_code(ca);
            break;
        case MAIN_STATEMENT:
            generate_expression_code(ca, statement->expression);
            add_code(ca, INVOKEVIRTUAL, add_constant_method_info("java/io/PrintStream", "println", "(I)V"));
            add_code(ca, RETURN);
            break;
        case FUNCTION_STATEMENT:
            generate_expression_code(ca, statement->expression);
            add_code(ca, IRETURN);
            break;
        default:
            break;
    }
    return 12 + ca->code_length;
}

variable_types: struct Statement { enum StatementType { NONE_TYPE_STATEMENT=0, MAIN_STATEMENT=1, CONSTRUCTOR_STATEMENT=2, FUNCTION_STATEMENT=3, FUNCTION_PATTERN_STATEMENT=4 } type; int line_number; struct Expression_tag { enum ExpressionKind { INT_EXPRESSION=0, IDENTIFIER_EXPRESSION=1, BINARY_EXPRESSION=2, MINUS_EXPRESSION=3, CALL_EXPRESSION=4 } kind; int line_number; union { int int_value; char *identifier; struct BinaryExpression { enum OperatorKind { ADD_OPERATOR=0, SUB_OPERATOR=1, MUL_OPERATOR=2, DIV_OPERATOR=3, MOD_OPERATOR=4 } kind; struct Expression_tag *left; struct Expression_tag *right; } binary_expression; struct Expression_tag *minus_expression; struct CallExpression { char *identifier; struct Expression_tag *parameter_expression; } call_expression; } u; } *expression; } *

variable_types: struct FunctionPattern_tag { int pattern; struct Statement *statement; struct FunctionPattern_tag *prev; struct FunctionPattern_tag *next; } *

return_type: unsigned int

user_defined_types: enum AttributeTag { ATTRIBUTE_ConstantValue=1, ATTRIBUTE_Code=2, ATTRIBUTE_Exceptions=3, ATTRIBUTE_InnerClasses=4, ATTRIBUTE_Synthetic=5, ATTRIBUTE_SourceFile=6, ATTRIBUTE_LineNumberTable=7, ATTRIBUTE_LocalVariableTable=8, ATTRIBUTE_Deprecated=9 }

user_defined_types: struct OpcodeInfo { unsigned char byte; char *mnemonic; unsigned char operand_count; char *operands_type; unsigned short max_stack; unsigned short max_locals; }

user_defined_types: struct ExceptionIndex_tag { unsigned short exception_index; struct ExceptionIndex_tag *prev; struct ExceptionIndex_tag *next; }

user_defined_types: struct InnerClass_tag { unsigned short inner_class_info_index; unsigned short outer_class_info_index; unsigned short inner_name_index; unsigned short inner_class_access_flags; }

user_defined_types: struct LineNumber_tag { unsigned short start_pc; unsigned short line_number; struct LineNumber_tag *prev; struct LineNumber_tag *next; }

user_defined_types: struct LocalVariable_tag { unsigned short start_pc; unsigned short length; unsigned short name_index; unsigned short descriptor_index; unsigned short index; struct LocalVariable_tag *prev; struct LocalVariable_tag *next; }


decompiled_code:
__int64 __fastcall add_attribute_source_file_info(__int64 *a1, _WORD *a2, __int64 a3)
{
__int64 v4; // rax
__int64 v5; // rbx
__int64 result; // rax

v4 = add_attribute_info(a1, a2, 6u);
*(_DWORD *)(v4 + 8) = 2;
v5 = v4;
result = add_constant_utf8_info(a3);
*(_WORD *)(v5 + 16) = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 *a1, _WORD *a2, __int64 a3)
{
__int64 v4; // rax
__int64 v5; // rbx
__int64 result; // rax

v4 = func0(a1, a2, 6u);
*(_DWORD *)(v4 + 8) = 2;
v5 = v4;
result = add_constant_utf8_info(a3);
*(_WORD *)(v5 + 16) = result;
return result;
}

original_code:
void add_attribute_source_file_info(AttributeInfo **ai_list, u2 *list_length, char *source_file){
    AttributeInfo *ai;
    ai = add_attribute_info(ai_list, list_length, ATTRIBUTE_SourceFile);
    ai->attribute_length = 2;
    ai->u.cp_index = add_constant_utf8_info(source_file);
}

canonical_original_code:
void add_attribute_source_file_info(struct AttributeInfo_tag **ai_list, unsigned short *list_length, char *source_file){
    struct AttributeInfo_tag *ai;
    ai = add_attribute_info(ai_list, list_length, ATTRIBUTE_SourceFile);
    ai->attribute_length = 2;
    ai->u.cp_index = add_constant_utf8_info(source_file);
}

variable_types: struct AttributeInfo_tag { enum AttributeTag { ATTRIBUTE_ConstantValue=1, ATTRIBUTE_Code=2, ATTRIBUTE_Exceptions=3, ATTRIBUTE_InnerClasses=4, ATTRIBUTE_Synthetic=5, ATTRIBUTE_SourceFile=6, ATTRIBUTE_LineNumberTable=7, ATTRIBUTE_LocalVariableTable=8, ATTRIBUTE_Deprecated=9 } tag; unsigned short attribute_name_index; unsigned int attribute_length; union { unsigned short cp_index; struct CodeAttribute { unsigned short max_stack; unsigned short max_locals; unsigned int code_length; struct Code_tag { enum CodeTag { CODE_OPERATOR=0, CODE_OPERAND_BYTE=1, CODE_OPERAND_SHORT=2 } tag; union { struct OpcodeInfo { unsigned char byte; char *mnemonic; unsigned char operand_count; char *operands_type; unsigned short max_stack; unsigned short max_locals; } *opcode; unsigned char operand_byte; unsigned short operand_short; } u; struct Code_tag *prev; struct Code_tag *next; } *code; unsigned short exception_table_length; struct Exception_tag { unsigned short start_pc; unsigned short end_pc; unsigned short handler_pc; unsigned short catch_type; struct Exception_tag *prev; struct Exception_tag *next; } *exception_table; unsigned short attributes_count; struct AttributeInfo_tag *attributes; unsigned short this_class_index; char *parameter_name; } code_attribute; struct ExceptionsAttribute { unsigned short number_of_exceptions; struct ExceptionIndex_tag { unsigned short exception_index; struct ExceptionIndex_tag *prev; struct ExceptionIndex_tag *next; } *exception_index_table; } exceptions_attribute; struct InnerClassesAttribute { unsigned short number_of_classes; struct InnerClass_tag { unsigned short inner_class_info_index; unsigned short outer_class_info_index; unsigned short inner_name_index; unsigned short inner_class_access_flags; } *classes; } inner_classes_attribute; unsigned char dummy; struct LineNumberTableAttribute { unsigned short line_number_table_length; struct LineNumber_tag { unsigned short start_pc; unsigned short line_number; struct LineNumber_tag *prev; struct LineNumber_tag *next; } *line_number_table; } line_number_table_attribute; struct LocalVariableTableAttribute { unsigned short local_variable_table_length; struct LocalVariable_tag { unsigned short start_pc; unsigned short length; unsigned short name_index; unsigned short descriptor_index; unsigned short index; struct LocalVariable_tag *prev; struct LocalVariable_tag *next; } *local_variable_table; } local_variable_table_attribute; } u; struct AttributeInfo_tag *prev; struct AttributeInfo_tag *next; } **

user_defined_types: struct AttributeInfo_tag { enum AttributeTag tag; unsigned short attribute_name_index; unsigned int attribute_length; union { unsigned short cp_index; struct CodeAttribute code_attribute; struct ExceptionsAttribute exceptions_attribute; struct InnerClassesAttribute inner_classes_attribute; unsigned char dummy; struct LineNumberTableAttribute line_number_table_attribute; struct LocalVariableTableAttribute local_variable_table_attribute; } u; struct AttributeInfo_tag *prev; struct AttributeInfo_tag *next; }


decompiled_code:
__int64 __fastcall add_attribute_code(__int64 *a1, _WORD *a2, _QWORD *a3, __int16 a4, double a5, double a6, double a7, double a8, double a9, double a10, double a11, double a12)
{
__int64 v14; // rax
__int64 v15; // rdx
unsigned int **v16; // rsi
__int64 v17; // rbx
double v18; // xmm4_8
double v19; // xmm5_8
__int64 result; // rax

v14 = add_attribute_info(a1, a2, 2u);
v15 = a3[4];
v16 = (unsigned int **)a3[3];
v17 = v14;
*(_WORD *)(v14 + 64) = a4;
*(_QWORD *)(v14 + 72) = a3[2];
result = create_attribute_code(v14 + 16, v16, v15, a5, a6, a7, a8, v18, v19, a11, a12);
*(_DWORD *)(v17 + 8) = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 *a1, _WORD *a2, _QWORD *a3, __int16 a4, double a5, double a6, double a7, double a8, double a9, double a10, double a11, double a12)
{
__int64 v14; // rax
__int64 v15; // rdx
unsigned int **v16; // rsi
__int64 v17; // rbx
double v18; // xmm4_8
double v19; // xmm5_8
__int64 result; // rax

v14 = func0(a1, a2, 2u);
v15 = a3[4];
v16 = (unsigned int **)a3[3];
v17 = v14;
*(_WORD *)(v14 + 64) = a4;
*(_QWORD *)(v14 + 72) = a3[2];
result = func11(v14 + 16, v16, v15, a5, a6, a7, a8, v18, v19, a11, a12);
*(_DWORD *)(v17 + 8) = result;
return result;
}

original_code:
void add_attribute_code(AttributeInfo **ai_list, u2 *list_length, FunctionDefinition *fd, u2 this_class_index){
    AttributeInfo *ai;
    ai = add_attribute_info(ai_list, list_length, ATTRIBUTE_Code);
    ai->u.code_attribute.this_class_index = this_class_index;
    ai->u.code_attribute.parameter_name = fd->parameter_name;
    ai->attribute_length = create_attribute_code(&(ai->u.code_attribute), fd->statement, fd->pattern_list);
}

canonical_original_code:
void add_attribute_code(struct AttributeInfo_tag **ai_list, unsigned short *list_length, struct FunctionDefinition_tag *fd, unsigned short this_class_index){
    struct AttributeInfo_tag *ai;
    ai = add_attribute_info(ai_list, list_length, ATTRIBUTE_Code);
    ai->u.code_attribute.this_class_index = this_class_index;
    ai->u.code_attribute.parameter_name = fd->parameter_name;
    ai->attribute_length = create_attribute_code(&(ai->u.code_attribute), fd->statement, fd->pattern_list);
}

variable_types: struct FunctionDefinition_tag { char *name; char *descriptor; char *parameter_name; struct Statement { enum StatementType { NONE_TYPE_STATEMENT=0, MAIN_STATEMENT=1, CONSTRUCTOR_STATEMENT=2, FUNCTION_STATEMENT=3, FUNCTION_PATTERN_STATEMENT=4 } type; int line_number; struct Expression_tag { enum ExpressionKind { INT_EXPRESSION=0, IDENTIFIER_EXPRESSION=1, BINARY_EXPRESSION=2, MINUS_EXPRESSION=3, CALL_EXPRESSION=4 } kind; int line_number; union { int int_value; char *identifier; struct BinaryExpression { enum OperatorKind { ADD_OPERATOR=0, SUB_OPERATOR=1, MUL_OPERATOR=2, DIV_OPERATOR=3, MOD_OPERATOR=4 } kind; struct Expression_tag *left; struct Expression_tag *right; } binary_expression; struct Expression_tag *minus_expression; struct CallExpression { char *identifier; struct Expression_tag *parameter_expression; } call_expression; } u; } *expression; } *statement; struct FunctionPattern_tag { int pattern; struct Statement *statement; struct FunctionPattern_tag *prev; struct FunctionPattern_tag *next; } *pattern_list; struct FunctionDefinition_tag *prev; struct FunctionDefinition_tag *next; } *

user_defined_types: struct FunctionDefinition_tag { char *name; char *descriptor; char *parameter_name; struct Statement *statement; struct FunctionPattern_tag *pattern_list; struct FunctionDefinition_tag *prev; struct FunctionDefinition_tag *next; }

user_defined_types: struct CodeAttribute { unsigned short max_stack; unsigned short max_locals; unsigned int code_length; struct Code_tag *code; unsigned short exception_table_length; struct Exception_tag *exception_table; unsigned short attributes_count; struct AttributeInfo_tag *attributes; unsigned short this_class_index; char *parameter_name; }

user_defined_types: struct Expression_tag { enum ExpressionKind kind; int line_number; union { int int_value; char *identifier; struct BinaryExpression binary_expression; struct Expression_tag *minus_expression; struct CallExpression call_expression; } u; }

user_defined_types: struct BinaryExpression { enum OperatorKind kind; struct Expression_tag *left; struct Expression_tag *right; }


decompiled_code:
__int64 __fastcall format_name(const char *a1)
{
const char *v1; // rbx
char v2; // al
bool v3; // zf
char v4; // al
unsigned int v5; // er12

v1 = a1;
v2 = *a1;
if ( *a1 )
{
do
{
++a1;
v3 = v2 == 47;
v2 = *a1;
if ( v3 )
v1 = a1;
}
while ( v2 );
v4 = *v1;
if ( (unsigned __int8)(*v1 - 65) <= 0x19u )
goto LABEL_6;
}
compile_error(3LL);
v4 = *v1;
if ( *v1 )
{
LABEL_6:
v5 = 0;
while ( v4 != 46 )
{
v4 = *++v1;
++v5;
if ( !v4 )
goto LABEL_12;
}
if ( strcmp(v1, ".desk") )
{
compile_error(4LL);
return v5;
}
}
else
{
LABEL_12:
v5 = -1;
compile_error(4LL);
}
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func0(const char *a1)
{
const char *v1; // rbx
char v2; // al
bool v3; // zf
char v4; // al
unsigned int v5; // er12

v1 = a1;
v2 = *a1;
if ( *a1 )
{
do
{
++a1;
v3 = v2 == 47;
v2 = *a1;
if ( v3 )
v1 = a1;
}
while ( v2 );
v4 = *v1;
if ( (unsigned __int8)(*v1 - 65) <= 0x19u )
goto LABEL_6;
}
compile_error(3LL);
v4 = *v1;
if ( *v1 )
{
LABEL_6:
v5 = 0;
while ( v4 != 46 )
{
v4 = *++v1;
++v5;
if ( !v4 )
goto LABEL_12;
}
if ( strcmp(v1, ".desk") )
{
compile_error(4LL);
return v5;
}
}
else
{
LABEL_12:
v5 = -1;
compile_error(4LL);
}
return v5;
}

original_code:
static int format_name(char *file_name){
    int classc = 0;
    char *i;
    for(i = file_name; *i; i++){
        if(*i == '/')
            file_name = i + 1;
    }
    if(*file_name < 'A' || 'Z' < *file_name)
        compile_error(ERROR_UNSUPPORTED_FILE_NAME);
    for(i = file_name; *i; i++){
        if(*i == '.'){
            if(strcmp(i, ".desk"))
                compile_error(ERROR_UNSUPPORTED_FILE_EXTENSION);
            return classc;
        }
        classc++;
    }
    compile_error(ERROR_UNSUPPORTED_FILE_EXTENSION);
    return -1;
}

variable_types: classc int

variable_types:
i
char *