decompiled_code:
int __fastcall process_arguments(__int64 a1, int a2, __int64 a3)
{
int v4; // ebx
const char *v5; // r15
FILE *v6; // rax
__int64 v7; // r8
char v8; // dl
int v9; // er14
int result; // eax

if ( !a1 )
_assert_fail("job", "gocr.c", 0x7Eu, "process_arguments");
v4 = 1;
if ( a2 <= 1 )
{
out_version(1);
exit(0);
}
do
{
v7 = 8LL * v4;
v6 = *(FILE **)(a3 + v7);
if ( !strcmp((const char *)v6, "--help") )
help();
if ( LOBYTE(v6->_flags) == 45 && (v8 = BYTE1(v6->_flags)) != 0 )
{
v9 = v4 + 1;
if ( v4 + 1 >= a2 )
{
switch ( v8 )
{
case 'C':
v5 = &nptr;
LABEL_42:
*(_QWORD *)(a1 + 37216) = v5;
++v4;
break;
case 'a':
v5 = &nptr;
LABEL_58:
LODWORD(v6) = atoi(v5);
*(_DWORD *)(a1 + 37224) = (_DWORD)v6;
++v4;
break;
case 'c':
v5 = &nptr;
LABEL_40:
*(_QWORD *)(a1 + 37200) = v5;
++v4;
break;
case 'd':
v5 = &nptr;
LABEL_44:
LODWORD(v6) = atoi(v5);
*(_DWORD *)(a1 + 37180) = (_DWORD)v6;
++v4;
break;
case 'e':
v5 = &nptr;
LABEL_11:
v6 = freopen(v5, "w", stderr);
++v4;
if ( !v6 )
LODWORD(v6) = fprintf(stderr, "stderr redirection to %s failed\n", v5);
break;
case 'f':
v5 = &nptr;
LABEL_23:
LODWORD(v6) = strcmp(v5, "ISO8859_1");
if ( (_DWORD)v6 )
{
LODWORD(v6) = strcmp(v5, "TeX");
if ( (_DWORD)v6 )
{
LODWORD(v6) = strcmp(v5, "HTML");
if ( (_DWORD)v6 )
{
LODWORD(v6) = strcmp(v5, "XML");
if ( (_DWORD)v6 )
{
LODWORD(v6) = strcmp(v5, "SGML");
if ( (_DWORD)v6 )
{
LODWORD(v6) = strcmp(v5, "UTF8");
if ( (_DWORD)v6 )
{
LODWORD(v6) = strcmp(v5, "ASCII");
if ( (_DWORD)v6 )
LODWORD(v6) = fprintf(stderr, "Warning: unknown format (-f %s)\n", v5);
else
*(_DWORD *)(a1 + 37192) = 6;
++v4;
}
else
{
*(_DWORD *)(a1 + 37192) = 5;
++v4;
}
}
else
{
*(_DWORD *)(a1 + 37192) = 4;
++v4;
}
}
else
{
*(_DWORD *)(a1 + 37192) = 3;
++v4;
}
}
else
{
*(_DWORD *)(a1 + 37192) = 2;
++v4;
}
}
else
{
*(_DWORD *)(a1 + 37192) = 1;
++v4;
}
}
else
{
*(_DWORD *)(a1 + 37192) = 0;
++v4;
}
break;
case 'h':
LABEL_6:
help();
return result;
case 'i':
v5 = &nptr;
LABEL_8:
*(_QWORD *)a1 = v5;
++v4;
break;
case 'l':
v5 = &nptr;
LABEL_46:
LODWORD(v6) = atoi(v5);
*(_DWORD *)(a1 + 37168) = (_DWORD)v6;
++v4;
break;
case 'm':
v5 = &nptr;
LABEL_52:
LODWORD(v6) = atoi(v5);
*(_DWORD *)(a1 + 37176) |= (unsigned int)v6;
++v4;
break;
case 'n':
v5 = &nptr;
LABEL_54:
LODWORD(v6) = atoi(v5);
*(_DWORD *)(a1 + 37184) = (_DWORD)v6;
++v4;
break;
case 'o':
v5 = &nptr;
LABEL_18:
if ( *v5 != 45 || (++v4, v5[1]) )
{
v6 = freopen(v5, "w", stdout);
v4 = v9;
if ( !v6 )
LODWORD(v6) = fprintf(stderr, "stdout redirection to %s failed\n", v5);
}
break;
case 'p':
v5 = &nptr;
LABEL_16:
*(_QWORD *)(a1 + 37208) = v5;
++v4;
break;
case 's':
v5 = &nptr;
LABEL_48:
LODWORD(v6) = atoi(v5);
*(_DWORD *)(a1 + 37172) = (_DWORD)v6;
++v4;
break;
case 'u':
v5 = &nptr;
LABEL_60:
*(_QWORD *)(a1 + 37232) = v5;
++v4;
break;
case 'v':
v5 = &nptr;
LABEL_50:
LODWORD(v6) = atoi(v5);
*(_DWORD *)(a1 + 37188) |= (unsigned int)v6;
++v4;
break;
case 'x':
v5 = &nptr;
LABEL_56:
LODWORD(v6) = ini_progress(v5);
++v4;
break;
default:
LABEL_61:
LODWORD(v6) = fwrite("# unknown option use -h for help\n", 1uLL, 0x21uLL, stderr);
break;
}
}
else
{
v5 = *(const char **)(a3 + v7 + 8);
switch ( v8 )
{
case 'C':
goto LABEL_42;
case 'a':
goto LABEL_58;
case 'c':
goto LABEL_40;
case 'd':
goto LABEL_44;
case 'e':
if ( *v5 != 45 || v5[1] )
goto LABEL_11;
LODWORD(v6) = dup2(1, 2);
++v4;
break;
case 'f':
goto LABEL_23;
case 'h':
goto LABEL_6;
case 'i':
goto LABEL_8;
case 'l':
goto LABEL_46;
case 'm':
goto LABEL_52;
case 'n':
goto LABEL_54;
case 'o':
goto LABEL_18;
case 'p':
goto LABEL_16;
case 's':
goto LABEL_48;
case 'u':
goto LABEL_60;
case 'v':
goto LABEL_50;
case 'x':
goto LABEL_56;
default:
goto LABEL_61;
}
}
}
else
{
*(_QWORD *)a1 = v6;
}
++v4;
}
while ( a2 > v4 );
return (int)v6;
}

canonical_decompiled_code:
int __fastcall func3(__int64 a1, int a2, __int64 a3)
{
int v4; // ebx
const char *v5; // r15
FILE *v6; // rax
__int64 v7; // r8
char v8; // dl
int v9; // er14
int result; // eax

if ( !a1 )
_assert_fail("job", "gocr.c", 0x7Eu, "process_arguments");
v4 = 1;
if ( a2 <= 1 )
{
func1(1);
exit(0);
}
do
{
v7 = 8LL * v4;
v6 = *(FILE **)(a3 + v7);
if ( !strcmp((const char *)v6, "--help") )
func2();
if ( LOBYTE(v6->_flags) == 45 && (v8 = BYTE1(v6->_flags)) != 0 )
{
v9 = v4 + 1;
if ( v4 + 1 >= a2 )
{
switch ( v8 )
{
case 'C':
v5 = &nptr;
LABEL_42:
*(_QWORD *)(a1 + 37216) = v5;
++v4;
break;
case 'a':
v5 = &nptr;
LABEL_58:
LODWORD(v6) = atoi(v5);
*(_DWORD *)(a1 + 37224) = (_DWORD)v6;
++v4;
break;
case 'c':
v5 = &nptr;
LABEL_40:
*(_QWORD *)(a1 + 37200) = v5;
++v4;
break;
case 'd':
v5 = &nptr;
LABEL_44:
LODWORD(v6) = atoi(v5);
*(_DWORD *)(a1 + 37180) = (_DWORD)v6;
++v4;
break;
case 'e':
v5 = &nptr;
LABEL_11:
v6 = freopen(v5, "w", stderr);
++v4;
if ( !v6 )
LODWORD(v6) = fprintf(stderr, "stderr redirection to %s failed\n", v5);
break;
case 'f':
v5 = &nptr;
LABEL_23:
LODWORD(v6) = strcmp(v5, "ISO8859_1");
if ( (_DWORD)v6 )
{
LODWORD(v6) = strcmp(v5, "TeX");
if ( (_DWORD)v6 )
{
LODWORD(v6) = strcmp(v5, "HTML");
if ( (_DWORD)v6 )
{
LODWORD(v6) = strcmp(v5, "XML");
if ( (_DWORD)v6 )
{
LODWORD(v6) = strcmp(v5, "SGML");
if ( (_DWORD)v6 )
{
LODWORD(v6) = strcmp(v5, "UTF8");
if ( (_DWORD)v6 )
{
LODWORD(v6) = strcmp(v5, "ASCII");
if ( (_DWORD)v6 )
LODWORD(v6) = fprintf(stderr, "Warning: unknown format (-f %s)\n", v5);
else
*(_DWORD *)(a1 + 37192) = 6;
++v4;
}
else
{
*(_DWORD *)(a1 + 37192) = 5;
++v4;
}
}
else
{
*(_DWORD *)(a1 + 37192) = 4;
++v4;
}
}
else
{
*(_DWORD *)(a1 + 37192) = 3;
++v4;
}
}
else
{
*(_DWORD *)(a1 + 37192) = 2;
++v4;
}
}
else
{
*(_DWORD *)(a1 + 37192) = 1;
++v4;
}
}
else
{
*(_DWORD *)(a1 + 37192) = 0;
++v4;
}
break;
case 'h':
LABEL_6:
func2();
return result;
case 'i':
v5 = &nptr;
LABEL_8:
*(_QWORD *)a1 = v5;
++v4;
break;
case 'l':
v5 = &nptr;
LABEL_46:
LODWORD(v6) = atoi(v5);
*(_DWORD *)(a1 + 37168) = (_DWORD)v6;
++v4;
break;
case 'm':
v5 = &nptr;
LABEL_52:
LODWORD(v6) = atoi(v5);
*(_DWORD *)(a1 + 37176) |= (unsigned int)v6;
++v4;
break;
case 'n':
v5 = &nptr;
LABEL_54:
LODWORD(v6) = atoi(v5);
*(_DWORD *)(a1 + 37184) = (_DWORD)v6;
++v4;
break;
case 'o':
v5 = &nptr;
LABEL_18:
if ( *v5 != 45 || (++v4, v5[1]) )
{
v6 = freopen(v5, "w", stdout);
v4 = v9;
if ( !v6 )
LODWORD(v6) = fprintf(stderr, "stdout redirection to %s failed\n", v5);
}
break;
case 'p':
v5 = &nptr;
LABEL_16:
*(_QWORD *)(a1 + 37208) = v5;
++v4;
break;
case 's':
v5 = &nptr;
LABEL_48:
LODWORD(v6) = atoi(v5);
*(_DWORD *)(a1 + 37172) = (_DWORD)v6;
++v4;
break;
case 'u':
v5 = &nptr;
LABEL_60:
*(_QWORD *)(a1 + 37232) = v5;
++v4;
break;
case 'v':
v5 = &nptr;
LABEL_50:
LODWORD(v6) = atoi(v5);
*(_DWORD *)(a1 + 37188) |= (unsigned int)v6;
++v4;
break;
case 'x':
v5 = &nptr;
LABEL_56:
LODWORD(v6) = ini_progress(v5);
++v4;
break;
default:
LABEL_61:
LODWORD(v6) = fwrite("# unknown option use -h for help\n", 1uLL, 0x21uLL, stderr);
break;
}
}
else
{
v5 = *(const char **)(a3 + v7 + 8);
switch ( v8 )
{
case 'C':
goto LABEL_42;
case 'a':
goto LABEL_58;
case 'c':
goto LABEL_40;
case 'd':
goto LABEL_44;
case 'e':
if ( *v5 != 45 || v5[1] )
goto LABEL_11;
LODWORD(v6) = dup2(1, 2);
++v4;
break;
case 'f':
goto LABEL_23;
case 'h':
goto LABEL_6;
case 'i':
goto LABEL_8;
case 'l':
goto LABEL_46;
case 'm':
goto LABEL_52;
case 'n':
goto LABEL_54;
case 'o':
goto LABEL_18;
case 'p':
goto LABEL_16;
case 's':
goto LABEL_48;
case 'u':
goto LABEL_60;
case 'v':
goto LABEL_50;
case 'x':
goto LABEL_56;
default:
goto LABEL_61;
}
}
}
else
{
*(_QWORD *)a1 = v6;
}
++v4;
}
while ( a2 > v4 );
return (int)v6;
}

original_code:
static void process_arguments(job_t *job, int argn, char *argv[])
{
  int i;
  char *s1;
  ((void) sizeof ((job) ? 1 : 0), __extension__ ({ if (job) ; else __assert_fail ("job", "gocr.c", 126, __extension__ __PRETTY_FUNCTION__); }));
  if (argn <= 1) {
    out_version(1);
    exit(0);
  }
  for (i = 1; i < argn; i++) {
    if (strcmp(argv[i], "--help") == 0)
      help();
    if (argv[i][0] == '-' && argv[i][1] != 0) {
      s1 = "";
      if (i + 1 < argn)
 s1 = argv[i + 1];
      switch (argv[i][1]) {
      case 'h':
 help();
 break;
      case 'i':
 job->src.fname = s1;
 i++;
 break;
      case 'e':
 if (s1[0] == '-' && s1[1] == '\0') {
          dup2(1, 2);
 }
 else if (!freopen(s1, "w", stderr)) {
   fprintf(stderr, "stderr redirection to %s failed\n", s1);
 }
 i++;
 break;
      case 'p':
 job->cfg.db_path=s1;
 i++;
 break;
      case 'o':
 if (s1[0] == '-' && s1[1] == '\0') {
 }
 else if (!freopen(s1, "w", stdout)) {
   fprintf(stderr, "stdout redirection to %s failed\n", s1);
 };
 i++;
 break;
      case 'f':
        if (strcmp(s1, "ISO8859_1") == 0) job->cfg.out_format=ISO8859_1; else
        if (strcmp(s1, "TeX") == 0) job->cfg.out_format=TeX; else
        if (strcmp(s1, "HTML") == 0) job->cfg.out_format=HTML; else
        if (strcmp(s1, "XML") == 0) job->cfg.out_format=XML; else
        if (strcmp(s1, "SGML") == 0) job->cfg.out_format=SGML; else
        if (strcmp(s1, "UTF8") == 0) job->cfg.out_format=UTF8; else
        if (strcmp(s1, "ASCII") == 0) job->cfg.out_format=ASCII; else
        fprintf(stderr,"Warning: unknown format (-f %s)\n",s1);
        i++;
        break;
      case 'c':
 job->cfg.lc = s1;
 i++;
 break;
      case 'C':
 job->cfg.cfilter = s1;
 i++;
 break;
      case 'd':
 job->cfg.dust_size = atoi(s1);
 i++;
 break;
      case 'l':
 job->cfg.cs = atoi(s1);
 i++;
 break;
      case 's':
 job->cfg.spc = atoi(s1);
 i++;
 break;
      case 'v':
 job->cfg.verbose |= atoi(s1);
 i++;
 break;
      case 'm':
 job->cfg.mode |= atoi(s1);
 i++;
 break;
      case 'n':
 job->cfg.only_numbers = atoi(s1);
 i++;
 break;
      case 'x':
 ini_progress(s1);
 i++;
 break;
      case 'a':
 job->cfg.certainty = atoi(s1);;
 i++;
 break;
      case 'u':
        job->cfg.unrec_marker = s1;
        i++;
        break;
      default:
 fprintf(stderr, "# unknown option use -h for help\n");
      }
      continue;
    }
    else if (argv[i][0] != '-'
         || argv[i][1] == '\0' ) {
      job->src.fname = argv[i];
    }
  }
}

canonical_original_code:
static void process_arguments(struct job_s *job, int argn, char *argv[])
{
  int i;
  char *s1;
  ((void) sizeof ((job) ? 1 : 0), __extension__ ({ if (job) ; else __assert_fail ("job", "gocr.c", 126, __extension__ __PRETTY_FUNCTION__); }));
  if (argn <= 1) {
    out_version(1);
    exit(0);
  }
  for (i = 1; i < argn; i++) {
    if (strcmp(argv[i], "--help") == 0)
      help();
    if (argv[i][0] == '-' && argv[i][1] != 0) {
      s1 = "";
      if (i + 1 < argn)
 s1 = argv[i + 1];
      switch (argv[i][1]) {
      case 'h':
 help();
 break;
      case 'i':
 job->src.fname = s1;
 i++;
 break;
      case 'e':
 if (s1[0] == '-' && s1[1] == '\0') {
          dup2(1, 2);
 }
 else if (!freopen(s1, "w", stderr)) {
   fprintf(stderr, "stderr redirection to %s failed\n", s1);
 }
 i++;
 break;
      case 'p':
 job->cfg.db_path=s1;
 i++;
 break;
      case 'o':
 if (s1[0] == '-' && s1[1] == '\0') {
 }
 else if (!freopen(s1, "w", stdout)) {
   fprintf(stderr, "stdout redirection to %s failed\n", s1);
 };
 i++;
 break;
      case 'f':
        if (strcmp(s1, "ISO8859_1") == 0) job->cfg.out_format=ISO8859_1; else
        if (strcmp(s1, "TeX") == 0) job->cfg.out_format=TeX; else
        if (strcmp(s1, "HTML") == 0) job->cfg.out_format=HTML; else
        if (strcmp(s1, "XML") == 0) job->cfg.out_format=XML; else
        if (strcmp(s1, "SGML") == 0) job->cfg.out_format=SGML; else
        if (strcmp(s1, "UTF8") == 0) job->cfg.out_format=UTF8; else
        if (strcmp(s1, "ASCII") == 0) job->cfg.out_format=ASCII; else
        fprintf(stderr,"Warning: unknown format (-f %s)\n",s1);
        i++;
        break;
      case 'c':
 job->cfg.lc = s1;
 i++;
 break;
      case 'C':
 job->cfg.cfilter = s1;
 i++;
 break;
      case 'd':
 job->cfg.dust_size = atoi(s1);
 i++;
 break;
      case 'l':
 job->cfg.cs = atoi(s1);
 i++;
 break;
      case 's':
 job->cfg.spc = atoi(s1);
 i++;
 break;
      case 'v':
 job->cfg.verbose |= atoi(s1);
 i++;
 break;
      case 'm':
 job->cfg.mode |= atoi(s1);
 i++;
 break;
      case 'n':
 job->cfg.only_numbers = atoi(s1);
 i++;
 break;
      case 'x':
 ini_progress(s1);
 i++;
 break;
      case 'a':
 job->cfg.certainty = atoi(s1);;
 i++;
 break;
      case 'u':
        job->cfg.unrec_marker = s1;
        i++;
        break;
      default:
 fprintf(stderr, "# unknown option use -h for help\n");
      }
      continue;
    }
    else if (argv[i][0] != '-'
         || argv[i][1] == '\0' ) {
      job->src.fname = argv[i];
    }
  }
}

variable_types: struct job_s { struct { char *fname; struct pixmap { unsigned char *p; int x; int y; int bpp; } p; } src; struct { struct timeval { long tv_sec; long tv_usec; } init_time; struct pixmap ppo; int n_run; struct ocr_object_list { struct ocr_element { struct ocr_element *next; void *data; } start; struct ocr_element stop; struct ocr_element **current; int n; int level; } dblist; } tmp; struct { struct ocr_object_list boxlist; struct ocr_object_list linelist; struct tlines { int num; int dx; int m1[1024]; int x0[1024]; int wt[1024]; int pitch[1024]; int mono[1024]; } lines; int avX; int sumX; } res; struct { int cs; int spc; int mode; int dust_size; int only_numbers; int verbose; enum format { ISO8859_1=0, TeX=1, HTML=2, XML=3, SGML=4, UTF8=5, ASCII=6 } out_format; char *lc; char *db_path; char *cfilter; int certainty; char *unrec_marker; } cfg; } *

variable_types: argn int

variable_types:
argv
char *[]

user_defined_types: struct job_s { struct { char *fname; struct pixmap p; } src; struct { struct timeval init_time; struct pixmap ppo; int n_run; struct ocr_object_list dblist; } tmp; struct { struct ocr_object_list boxlist; struct ocr_object_list linelist; struct tlines lines; int avX; int sumX; } res; struct { int cs; int spc; int mode; int dust_size; int only_numbers; int verbose; enum format out_format; char *lc; char *db_path; char *cfilter; int certainty; char *unrec_marker; } cfg; }

user_defined_types: struct ocr_object_list { struct ocr_element start; struct ocr_element stop; struct ocr_element **current; int n; int level; }


repo: metamolecular/gocr-patched

decompiled_code:
int __fastcall mark_start(__int64 a1)
{
int result; // eax

if ( !a1 )
_assert_fail("job", "gocr.c", 0xF6u, "mark_start");
if ( *(_DWORD *)(a1 + 37188) )
{
out_version(0);
fwrite("# compiled: May 23 2025", 1uLL, 0x17uLL, stderr);
fprintf(stderr, " GNUC-%d", 10LL);
fprintf(stderr, ".%d", 3LL);
fwrite(" linux", 1uLL, 6uLL, stderr);
fwrite(" version 10.3.0", 1uLL, 0xFuLL, stderr);
fputc(10, stderr);
fprintf(
stderr,
"# options are: -l %d -s %d -v %d -c %s -m %d -d %d -n %d -a %d -C \"%s\"\n",
*(unsigned int *)(a1 + 37168),
*(unsigned int *)(a1 + 37172),
*(unsigned int *)(a1 + 37188),
*(const char **)(a1 + 37200),
*(unsigned int *)(a1 + 37176),
*(unsigned int *)(a1 + 37180),
*(unsigned int *)(a1 + 37184),
*(unsigned int *)(a1 + 37224),
*(const char **)(a1 + 37216));
fprintf(stderr, "# file: %s\n", *(const char **)a1);
fwrite("# using unicode\n", 1uLL, 0x10uLL, stderr);
result = gettimeofday((struct timeval *)(a1 + 32), 0LL);
}
return result;
}

canonical_decompiled_code:
int __fastcall func4(__int64 a1)
{
int result; // eax

if ( !a1 )
_assert_fail("job", "gocr.c", 0xF6u, "mark_start");
if ( *(_DWORD *)(a1 + 37188) )
{
func1(0);
fwrite("# compiled: May 23 2025", 1uLL, 0x17uLL, stderr);
fprintf(stderr, " GNUC-%d", 10LL);
fprintf(stderr, ".%d", 3LL);
fwrite(" linux", 1uLL, 6uLL, stderr);
fwrite(" version 10.3.0", 1uLL, 0xFuLL, stderr);
fputc(10, stderr);
fprintf(
stderr,
"# options are: -l %d -s %d -v %d -c %s -m %d -d %d -n %d -a %d -C \"%s\"\n",
*(unsigned int *)(a1 + 37168),
*(unsigned int *)(a1 + 37172),
*(unsigned int *)(a1 + 37188),
*(const char **)(a1 + 37200),
*(unsigned int *)(a1 + 37176),
*(unsigned int *)(a1 + 37180),
*(unsigned int *)(a1 + 37184),
*(unsigned int *)(a1 + 37224),
*(const char **)(a1 + 37216));
fprintf(stderr, "# file: %s\n", *(const char **)a1);
fwrite("# using unicode\n", 1uLL, 0x10uLL, stderr);
result = gettimeofday((struct timeval *)(a1 + 32), 0LL);
}
return result;
}

original_code:
static void mark_start(job_t *job) {
  ((void) sizeof ((job) ? 1 : 0), __extension__ ({ if (job) ; else __assert_fail ("job", "gocr.c", 246, __extension__ __PRETTY_FUNCTION__); }));
  if (job->cfg.verbose) {
    out_version(0);
    fprintf(stderr, "# compiled: " "Apr 20 2024" );
    fprintf(stderr, " GNUC-%d", 10 );
    fprintf(stderr, ".%d", 3 );
    fprintf(stderr, " linux");
    fprintf(stderr, " version " "10.3.0" );
    fprintf(stderr, "\n");
    fprintf(stderr,
      "# options are: -l %d -s %d -v %d -c %s -m %d -d %d -n %d -a %d -C \"%s\"\n",
      job->cfg.cs, job->cfg.spc, job->cfg.verbose, job->cfg.lc, job->cfg.mode,
      job->cfg.dust_size, job->cfg.only_numbers, job->cfg.certainty,
      job->cfg.cfilter);
    fprintf(stderr, "# file: %s\n", job->src.fname);
    fprintf(stderr,"# using unicode\n");
    gettimeofday(&job->tmp.init_time, ((void *)0));
  }
}

canonical_original_code:
static void mark_start(struct job_s *job) {
  ((void) sizeof ((job) ? 1 : 0), __extension__ ({ if (job) ; else __assert_fail ("job", "gocr.c", 246, __extension__ __PRETTY_FUNCTION__); }));
  if (job->cfg.verbose) {
    out_version(0);
    fprintf(stderr, "# compiled: " "Apr 20 2024" );
    fprintf(stderr, " GNUC-%d", 10 );
    fprintf(stderr, ".%d", 3 );
    fprintf(stderr, " linux");
    fprintf(stderr, " version " "10.3.0" );
    fprintf(stderr, "\n");
    fprintf(stderr,
      "# options are: -l %d -s %d -v %d -c %s -m %d -d %d -n %d -a %d -C \"%s\"\n",
      job->cfg.cs, job->cfg.spc, job->cfg.verbose, job->cfg.lc, job->cfg.mode,
      job->cfg.dust_size, job->cfg.only_numbers, job->cfg.certainty,
      job->cfg.cfilter);
    fprintf(stderr, "# file: %s\n", job->src.fname);
    fprintf(stderr,"# using unicode\n");
    gettimeofday(&job->tmp.init_time, ((void *)0));
  }
}

return_type: void

user_defined_types: struct pixmap { unsigned char *p; int x; int y; int bpp; }

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

user_defined_types: struct tlines { int num; int dx; int m1[1024]; int x0[1024]; int wt[1024]; int pitch[1024]; int mono[1024]; }

user_defined_types: enum format { ISO8859_1=0, TeX=1, HTML=2, XML=3, SGML=4, UTF8=5, ASCII=6 }

user_defined_types: struct ocr_element { struct ocr_element *next; void *data; }


decompiled_code:
int __fastcall mark_end(__int64 a1)
{
int result; // eax
struct timeval v2; // [rsp+0h] [rbp-28h] BYREF
__int64 v3; // [rsp+10h] [rbp-18h] BYREF
__int64 v4; // [rsp+18h] [rbp-10h]

if ( !a1 )
_assert_fail("job", "gocr.c", 0x121u, "mark_end");
if ( *(_DWORD *)(a1 + 37188) )
{
gettimeofday(&v2, 0LL);
timeval_subtract(&v3, &v2, (_QWORD *)(a1 + 32));
result = fprintf(
stderr,
"Elapsed time: %d:%02d:%3.3f.\n",
(unsigned int)((int)v3 / 60),
(unsigned int)((int)v3 % 60),
(float)((float)(int)v4 / 1000.0));
}
return result;
}

canonical_decompiled_code:
int __fastcall func5(__int64 a1)
{
int result; // eax
struct timeval v2; // [rsp+0h] [rbp-28h] BYREF
__int64 v3; // [rsp+10h] [rbp-18h] BYREF
__int64 v4; // [rsp+18h] [rbp-10h]

if ( !a1 )
_assert_fail("job", "gocr.c", 0x121u, "mark_end");
if ( *(_DWORD *)(a1 + 37188) )
{
gettimeofday(&v2, 0LL);
func0(&v3, &v2, (_QWORD *)(a1 + 32));
result = fprintf(
stderr,
"Elapsed time: %d:%02d:%3.3f.\n",
(unsigned int)((int)v3 / 60),
(unsigned int)((int)v3 % 60),
(float)((float)(int)v4 / 1000.0));
}
return result;
}

original_code:
static void mark_end(job_t *job) {
  ((void) sizeof ((job) ? 1 : 0), __extension__ ({ if (job) ; else __assert_fail ("job", "gocr.c", 289, __extension__ __PRETTY_FUNCTION__); }));
  if (job->cfg.verbose) {
    struct timeval end, result;
    gettimeofday(&end, ((void *)0));
    timeval_subtract(&result, &end, &job->tmp.init_time);
    fprintf(stderr,"Elapsed time: %d:%02d:%3.3f.\n", (int)result.tv_sec/60,
 (int)result.tv_sec%60, (float)result.tv_usec/1000);
  }
}

canonical_original_code:
static void mark_end(struct job_s *job) {
  ((void) sizeof ((job) ? 1 : 0), __extension__ ({ if (job) ; else __assert_fail ("job", "gocr.c", 289, __extension__ __PRETTY_FUNCTION__); }));
  if (job->cfg.verbose) {
    struct timeval end; struct timeval result;
    gettimeofday(&end, ((void *)0));
    timeval_subtract(&result, &end, &job->tmp.init_time);
    fprintf(stderr,"Elapsed time: %d:%02d:%3.3f.\n", (int)result.tv_sec/60,
 (int)result.tv_sec%60, (float)result.tv_usec/1000);
  }
}

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


decompiled_code:
__int64 __fastcall read_picture(__int64 a1)
{
const char *v1; // rbp

if ( !a1 )
_assert_fail("job", "gocr.c", 0x131u, "read_picture");
v1 = *(const char **)a1;
if ( !strstr(*(const char **)a1, ".pcx") )
return readpgm(v1, a1 + 8, *(unsigned int *)(a1 + 37188));
readpcx(v1, a1 + 8, *(unsigned int *)(a1 + 37188));
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
const char *v1; // rbp

if ( !a1 )
_assert_fail("job", "gocr.c", 0x131u, "read_picture");
v1 = *(const char **)a1;
if ( !strstr(*(const char **)a1, ".pcx") )
return readpgm(v1, a1 + 8, *(unsigned int *)(a1 + 37188));
readpcx(v1, a1 + 8, *(unsigned int *)(a1 + 37188));
return 0LL;
}

original_code:
static int read_picture(job_t *job) {
  int rc=0;
  ((void) sizeof ((job) ? 1 : 0), __extension__ ({ if (job) ; else __assert_fail ("job", "gocr.c", 305, __extension__ __PRETTY_FUNCTION__); }));
  if (strstr(job->src.fname, ".pcx"))
    readpcx(job->src.fname, &job->src.p, job->cfg.verbose);
  else
    rc=readpgm(job->src.fname, &job->src.p, job->cfg.verbose);
  return rc;
}

canonical_original_code:
static int read_picture(struct job_s *job) {
  int rc = 0;
  ((void) sizeof ((job) ? 1 : 0), __extension__ ({ if (job) ; else __assert_fail ("job", "gocr.c", 305, __extension__ __PRETTY_FUNCTION__); }));
  if (strstr(job->src.fname, ".pcx"))
    readpcx(job->src.fname, &job->src.p, job->cfg.verbose);
  else
    rc=readpgm(job->src.fname, &job->src.p, job->cfg.verbose);
  return rc;
}

variable_types: rc int

return_type: int


decompiled_code:
__int64 __fastcall print_output(__int64 a1)
{
__int64 v2; // r12
const char *v3; // rdi
unsigned int i; // ebx

if ( !a1 )
_assert_fail("job", "gocr.c", 0x13Fu, "print_output");
v2 = a1 + 208;
v3 = (const char *)getTextLine(a1 + 208, 0LL);
if ( v3 )
{
for ( i = 1; ; ++i )
{
fputs(v3, stdout);
if ( *(_DWORD *)(a1 + 37192) == 2 )
fwrite("<br />", 1uLL, 6uLL, stdout);
if ( *(_DWORD *)(a1 + 37192) != 3 )
fputc(10, stdout);
v3 = (const char *)getTextLine(v2, i);
if ( !v3 )
break;
}
}
return free_textlines(v2);
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
__int64 v2; // r12
const char *v3; // rdi
unsigned int i; // ebx

if ( !a1 )
_assert_fail("job", "gocr.c", 0x13Fu, "print_output");
v2 = a1 + 208;
v3 = (const char *)getTextLine(a1 + 208, 0LL);
if ( v3 )
{
for ( i = 1; ; ++i )
{
fputs(v3, stdout);
if ( *(_DWORD *)(a1 + 37192) == 2 )
fwrite("<br />", 1uLL, 6uLL, stdout);
if ( *(_DWORD *)(a1 + 37192) != 3 )
fputc(10, stdout);
v3 = (const char *)getTextLine(v2, i);
if ( !v3 )
break;
}
}
return free_textlines(v2);
}

original_code:
void print_output(job_t *job) {
  int linecounter = 0;
  const char *line;
  ((void) sizeof ((job) ? 1 : 0), __extension__ ({ if (job) ; else __assert_fail ("job", "gocr.c", 319, __extension__ __PRETTY_FUNCTION__); }));
  linecounter = 0;
  line = getTextLine(&(job->res.linelist), linecounter++);
  while (line) {
    fputs(line, stdout);
    if (job->cfg.out_format==HTML) fputs("<br />",stdout);
    if (job->cfg.out_format!=XML) fputc('\n', stdout);
    line = getTextLine(&(job->res.linelist), linecounter++);
  }
  free_textlines(&(job->res.linelist));
}

canonical_original_code:
void print_output(struct job_s *job) {
  int linecounter = 0;
  char *line;
  ((void) sizeof ((job) ? 1 : 0), __extension__ ({ if (job) ; else __assert_fail ("job", "gocr.c", 319, __extension__ __PRETTY_FUNCTION__); }));
  linecounter = 0;
  line = getTextLine(&(job->res.linelist), linecounter++);
  while (line) {
    fputs(line, stdout);
    if (job->cfg.out_format==HTML) fputs("<br />",stdout);
    if (job->cfg.out_format!=XML) fputc('\n', stdout);
    line = getTextLine(&(job->res.linelist), linecounter++);
  }
  free_textlines(&(job->res.linelist));
}

variable_types: linecounter int

variable_types:
line
char *


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
int result; // eax
_BYTE v5[37272]; // [rsp+0h] [rbp-9198h] BYREF

OCR_JOB = (__int64)v5;
setvbuf(stdout, 0LL, 2, 0LL);
job_init(v5);
process_arguments((__int64)v5, argc, (__int64)argv);
if ( (v5[37176] & 2) != 0 )
load_db(v5);
do
{
job_init_image(v5);
mark_start((__int64)v5);
v3 = read_picture((__int64)v5);
if ( v3 < 0 )
break;
pgm2asc(v5);
mark_end((__int64)v5);
print_output((__int64)v5);
job_free_image(v5);
}
while ( v3 == 1 );
result = 0;
if ( v3 <= 0 )
result = v3;
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
int result; // eax
_BYTE v5[37272]; // [rsp+0h] [rbp-9198h] BYREF

OCR_JOB = (__int64)v5;
setvbuf(stdout, 0LL, 2, 0LL);
job_init(v5);
func3((__int64)v5, argc, (__int64)argv);
if ( (v5[37176] & 2) != 0 )
load_db(v5);
do
{
job_init_image(v5);
func4((__int64)v5);
v3 = func6((__int64)v5);
if ( v3 < 0 )
break;
pgm2asc(v5);
func5((__int64)v5);
func7((__int64)v5);
job_free_image(v5);
}
while ( v3 == 1 );
result = 0;
if ( v3 <= 0 )
result = v3;
return result;
}

original_code:
int main(int argn, char *argv[]) {
  int multipnm=1;
  job_t job1, *job;
  job=OCR_JOB=&job1;
  setvbuf(stdout, (char *) ((void *)0), 2, 0);
  job_init(job);
  process_arguments(job, argn, argv);
  if ( job->cfg.mode & 2 )
    load_db(job);
  while (multipnm==1) {
    job_init_image(job);
    mark_start(job);
    multipnm = read_picture(job);
    if (multipnm<0) break;
    pgm2asc(job);
    mark_end(job);
    print_output(job);
    job_free_image(job);
  }
  return ((multipnm<0)?multipnm:0);
}

canonical_original_code:
int main(int argn, char *argv[]) {
  int multipnm = 1;
  struct job_s job1; struct job_s *job;
  job=OCR_JOB=&job1;
  setvbuf(stdout, (char *) ((void *)0), 2, 0);
  job_init(job);
  process_arguments(job, argn, argv);
  if ( job->cfg.mode & 2 )
    load_db(job);
  while (multipnm==1) {
    job_init_image(job);
    mark_start(job);
    multipnm = read_picture(job);
    if (multipnm<0) break;
    pgm2asc(job);
    mark_end(job);
    print_output(job);
    job_free_image(job);
  }
  return ((multipnm<0)?multipnm:0);
}

variable_types: multipnm int

variable_types: struct job_s { struct { char *fname; struct pixmap { unsigned char *p; int x; int y; int bpp; } p; } src; struct { struct timeval { long tv_sec; long tv_usec; } init_time; struct pixmap ppo; int n_run; struct ocr_object_list { struct ocr_element { struct ocr_element *next; void *data; } start; struct ocr_element stop; struct ocr_element **current; int n; int level; } dblist; } tmp; struct { struct ocr_object_list boxlist; struct ocr_object_list linelist; struct tlines { int num; int dx; int m1[1024]; int x0[1024]; int wt[1024]; int pitch[1024]; int mono[1024]; } lines; int avX; int sumX; } res; struct { int cs; int spc; int mode; int dust_size; int only_numbers; int verbose; enum format { ISO8859_1=0, TeX=1, HTML=2, XML=3, SGML=4, UTF8=5, ASCII=6 } out_format; char *lc; char *db_path; char *cfilter; int certainty; char *unrec_marker; } cfg; }


marked

canonical_original_code:
int marked(struct pixmap *p, int x, int y) {
  if (x < 0 || y < 0 || x >= p->x || y >= p->y)
    return 0;
  return ((p)->p[(x)+((y)*((p)->x))] & 7);
}

variable_types: struct pixmap { unsigned char *p; int x; int y; int bpp; } *

variable_types: x int

variable_types: y int


variable_types:
tree
char [1024]

variable_types: n int

variable_types: f int

variable_types:
filter
char *


variable_types: r int


getpixel

decompiled_code:
__int64 __fastcall getpixel(__int64 a1, int a2, int a3)
{
int v3; // ecx
__int64 result; // rax

if ( a2 < 0 || a3 < 0 )
return 248LL;
v3 = *(_DWORD *)(a1 + 8);
result = 248LL;
if ( v3 > a2 && *(_DWORD *)(a1 + 12) > a3 )
{
if ( *(int *)(OCR_JOB + 72LL) > 0 )
result = pixel_filter_by_tree((__int64 *)a1, a2, a3);
else
result = *(_BYTE *)(*(_QWORD *)a1 + a2 + v3 * a3) & 0xF8;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, int a2, int a3)
{
int v3; // ecx
__int64 result; // rax

if ( a2 < 0 || a3 < 0 )
return 248LL;
v3 = *(_DWORD *)(a1 + 8);
result = 248LL;
if ( v3 > a2 && *(_DWORD *)(a1 + 12) > a3 )
{
if ( *(int *)(OCR_JOB + 72LL) > 0 )
result = func2((__int64 *)a1, a2, a3);
else
result = *(_BYTE *)(*(_QWORD *)a1 + a2 + v3 * a3) & 0xF8;
}
return result;
}

original_code:
int getpixel(pix *p, int x, int y){
  job_t *job=OCR_JOB;
  if ( x < 0 || y < 0 || x >= p->x || y >= p->y )
    return 255 & ~7;
  if (job->tmp.n_run > 0) {
    int pix = pixel_filter_by_tree(p, x, y);
    return pix;
  }
  return ((p)->p[(x)+((y)*((p)->x))] & ~7);
}

canonical_original_code:
int getpixel(struct pixmap *p, int x, int y){
  struct job_s *job = OCR_JOB;
  if ( x < 0 || y < 0 || x >= p->x || y >= p->y )
    return 255 & ~7;
  if (job->tmp.n_run > 0) {
    int pix = pixel_filter_by_tree(p, x, y);
    return pix;
  }
  return ((p)->p[(x)+((y)*((p)->x))] & ~7);
}

variable_types: struct job_s { struct { char *fname; struct pixmap { unsigned char *p; int x; int y; int bpp; } p; } src; struct { struct timeval { long tv_sec; long tv_usec; } init_time; struct pixmap ppo; int n_run; struct ocr_object_list { struct ocr_element { struct ocr_element *next; void *data; } start; struct ocr_element stop; struct ocr_element **current; int n; int level; } dblist; } tmp; struct { struct ocr_object_list boxlist; struct ocr_object_list linelist; struct tlines { int num; int dx; int m1[1024]; int x0[1024]; int wt[1024]; int pitch[1024]; int mono[1024]; } lines; int avX; int sumX; } res; struct { int cs; int spc; int mode; int dust_size; int only_numbers; int verbose; enum format { ISO8859_1=0, TeX=1, HTML=2, XML=3, SGML=4, UTF8=5, ASCII=6 } out_format; char *lc; char *db_path; char *cfilter; int certainty; char *unrec_marker; } cfg; } *

variable_types: pix int


original_code:
void list_init( List *l ) {
  if ( !l )
     return;
  l->start.next = &l->stop;
  l->stop.previous = &l->start;
  l->start.previous = l->stop.next = ((void *)0);
  l->start.data = l->stop.data = ((void *)0);
  l->current = ((void *)0);
  l->level = -1;
  l->n = 0;
}

canonical_original_code:
void list_init(struct ocr_object_list *l) {
  if ( !l )
     return;
  l->start.next = &l->stop;
  l->stop.previous = &l->start;
  l->start.previous = l->stop.next = ((void *)0);
  l->start.data = l->stop.data = ((void *)0);
  l->current = ((void *)0);
  l->level = -1;
  l->n = 0;
}

variable_types: struct ocr_object_list { struct ocr_element { struct ocr_element *next; void *data; } start; struct ocr_element stop; struct ocr_element **current; int n; int level; } *


decompiled_code:
__int64 __fastcall list_app(__int64 a1, __int64 a2)
{
__int64 result; // rax
_QWORD *v3; // rax
_QWORD *v4; // rdx

if ( !a1 )
return 1LL;
result = 1LL;
if ( a2 )
{
v3 = malloc(0x18uLL);
if ( v3 )
{
v3[2] = a2;
v4 = *(_QWORD **)(a1 + 32);
v3[1] = v4;
*v3 = *v4;
*v4 = v3;
*(_QWORD *)(a1 + 32) = v3;
++*(_DWORD *)(a1 + 56);
result = 0LL;
}
else
{
result = 1LL;
}
}
return result;
}

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

if ( !a1 )
return 1LL;
result = 1LL;
if ( a2 )
{
v3 = malloc(0x18uLL);
if ( v3 )
{
v3[2] = a2;
v4 = *(_QWORD **)(a1 + 32);
v3[1] = v4;
*v3 = *v4;
*v4 = v3;
*(_QWORD *)(a1 + 32) = v3;
++*(_DWORD *)(a1 + 56);
result = 0LL;
}
else
{
result = 1LL;
}
}
return result;
}

original_code:
int list_app( List *l, void *data ) {
  Element *e;
  if ( !l || !data )
     return 1;
  if ( !(e = (Element *)malloc(sizeof(Element))) )
    return 1;
  e->data = data;
  e->previous = l->stop.previous;
  e->next = l->stop.previous->next;
  l->stop.previous->next = e;
  l->stop.previous = e;
  l->n++;
  return 0;
}

canonical_original_code:
int list_app(struct ocr_object_list *l, void *data) {
  struct ocr_element *e;
  if ( !l || !data )
     return 1;
  if ( !(e = (struct ocr_element *)malloc(sizeof(Element))) )
    return 1;
  e->data = data;
  e->previous = l->stop.previous;
  e->next = l->stop.previous->next;
  l->stop.previous->next = e;
  l->stop.previous = e;
  l->n++;
  return 0;
}

variable_types:
data
void *

variable_types: struct ocr_element { struct ocr_element *next; void *data; } *


decompiled_code:
__int64 __fastcall list_ins(_DWORD *a1, __int64 a2, __int64 a3)
{
__int64 result; // rax
_QWORD *v5; // r12
_QWORD *v6; // rax
_QWORD *v7; // rdx

if ( !a1 )
return 1LL;
if ( !a3 )
return 1LL;
if ( !a2 || !a1[14] )
return list_app((__int64)a1, a3);
v5 = list_element_from_data(a1, a2);
result = 1LL;
if ( v5 )
{
v6 = malloc(0x18uLL);
if ( v6 )
{
v6[2] = a3;
*v6 = v5;
v7 = (_QWORD *)v5[1];
v6[1] = v7;
*v7 = v6;
v5[1] = v6;
++a1[14];
result = 0LL;
}
else
{
result = 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(_DWORD *a1, __int64 a2, __int64 a3)
{
__int64 result; // rax
_QWORD *v5; // r12
_QWORD *v6; // rax
_QWORD *v7; // rdx

if ( !a1 )
return 1LL;
if ( !a3 )
return 1LL;
if ( !a2 || !a1[14] )
return func1((__int64)a1, a3);
v5 = list_element_from_data(a1, a2);
result = 1LL;
if ( v5 )
{
v6 = malloc(0x18uLL);
if ( v6 )
{
v6[2] = a3;
*v6 = v5;
v7 = (_QWORD *)v5[1];
v6[1] = v7;
*v7 = v6;
v5[1] = v6;
++a1[14];
result = 0LL;
}
else
{
result = 1LL;
}
}
return result;
}

original_code:
int list_ins( List *l, void *data_after, void *data) {
  Element *e, *after_element;
  if ( !l || !data )
    return 1;
  if ( !data_after || !l->n )
    return list_app(l, data);
  if ( !(after_element = list_element_from_data(l, data_after)) )
    return 1;
  if( !(e = (Element *)malloc(sizeof(Element))) )
    return 1;
  e->data = data;
  e->next = after_element;
  e->previous = after_element->previous;
  after_element->previous->next = e;
  after_element->previous = e;
  l->n++;
  return 0;
}

canonical_original_code:
int list_ins(struct ocr_object_list *l, void *data_after, void *data) {
  struct ocr_element *e; struct ocr_element *after_element;
  if ( !l || !data )
    return 1;
  if ( !data_after || !l->n )
    return list_app(l, data);
  if ( !(after_element = list_element_from_data(l, data_after)) )
    return 1;
  if( !(e = (struct ocr_element *)malloc(sizeof(Element))) )
    return 1;
  e->data = data;
  e->next = after_element;
  e->previous = after_element->previous;
  after_element->previous->next = e;
  after_element->previous = e;
  l->n++;
  return 0;
}


original_code:
int list_del( List *l, void *data ) {
  Element *temp;
  int i;
  if (!data) return 1;
  if ( !(temp = list_element_from_data(l, data)) )
    return 1;
  for ( i = l->level; i >= 0; i-- ) {
    if ( l->current[i] == temp ) {
      l->current[i] = temp->previous;
    }
  }
  temp->previous->next = temp->next;
  temp->next->previous = temp->previous;
  temp->previous = temp->next = ((void *)0);
  free(temp);
  l->n--;
  return 0;
}

canonical_original_code:
int list_del(struct ocr_object_list *l, void *data) {
  struct ocr_element *temp;
  int i;
  if (!data) return 1;
  if ( !(temp = list_element_from_data(l, data)) )
    return 1;
  for ( i = l->level; i >= 0; i-- ) {
    if ( l->current[i] == temp ) {
      l->current[i] = temp->previous;
    }
  }
  temp->previous->next = temp->next;
  temp->next->previous = temp->previous;
  temp->previous = temp->next = ((void *)0);
  free(temp);
  l->n--;
  return 0;
}

variable_types: i int


original_code:
void list_free( List *l ) {
  Element *temp, *temp2;
  if ( !l || !l->n )
    return;
  if ( l->current ) {
    free(l->current);
  }
  l->current = ((void *)0);
  temp = l->start.next;
  while ( temp && temp!=&l->stop) {
    temp2 = temp->next;
    free(temp);
    temp = temp2;
  }
  l->start.next = &l->stop;
  l->stop.previous = &l->start;
}

canonical_original_code:
void list_free(struct ocr_object_list *l) {
  struct ocr_element *temp; struct ocr_element *temp2;
  if ( !l || !l->n )
    return;
  if ( l->current ) {
    free(l->current);
  }
  l->current = ((void *)0);
  temp = l->start.next;
  while ( temp && temp!=&l->stop) {
    temp2 = temp->next;
    free(temp);
    temp = temp2;
  }
  l->start.next = &l->stop;
  l->stop.previous = &l->start;
}


decompiled_code:
__int64 __fastcall list_higher_level(__int64 a1)
{
__int64 result; // rax
_QWORD *v2; // rax
_QWORD *v3; // rdx
int v4; // eax

result = 1LL;
if ( a1 )
{
v2 = realloc(*(void **)(a1 + 48), 8LL * (*(_DWORD *)(a1 + 60) + 2));
v3 = v2;
if ( v2 )
{
*(_QWORD *)(a1 + 48) = v2;
v4 = *(_DWORD *)(a1 + 60) + 1;
*(_DWORD *)(a1 + 60) = v4;
v3[v4] = *(_QWORD *)a1;
result = 0LL;
}
else
{
fwrite(" realloc failed! abort\n", 1uLL, 0x17uLL, stderr);
result = 1LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
__int64 result; // rax
_QWORD *v2; // rax
_QWORD *v3; // rdx
int v4; // eax

result = 1LL;
if ( a1 )
{
v2 = realloc(*(void **)(a1 + 48), 8LL * (*(_DWORD *)(a1 + 60) + 2));
v3 = v2;
if ( v2 )
{
*(_QWORD *)(a1 + 48) = v2;
v4 = *(_DWORD *)(a1 + 60) + 1;
*(_DWORD *)(a1 + 60) = v4;
v3[v4] = *(_QWORD *)a1;
result = 0LL;
}
else
{
fwrite(" realloc failed! abort\n", 1uLL, 0x17uLL, stderr);
result = 1LL;
}
}
return result;
}

original_code:
int list_higher_level( List *l ) {
  Element **newcur;
  if ( !l ) return(1);
  newcur = (Element **)realloc(l->current, (l->level+2)*sizeof(Element *));
  if (newcur) {
    l->current = newcur;
    l->level++;
    l->current[l->level] = l->start.next;
  }

  if ( !newcur ) {
    fprintf(stderr, " realloc failed! abort\n"); return(1);
  }
  return 0;
}

canonical_original_code:
int list_higher_level(struct ocr_object_list *l) {
  struct ocr_element **newcur;
  if ( !l ) return(1);
  newcur = (struct ocr_element **)realloc(l->current, (l->level+2)*sizeof(struct ocr_element *));
  if (newcur) {
    l->current = newcur;
    l->level++;
    l->current[l->level] = l->start.next;
  }

  if ( !newcur ) {
    fprintf(stderr, " realloc failed! abort\n"); return(1);
  }
  return 0;
}

variable_types: struct ocr_element { struct ocr_element *next; void *data; } **


original_code:
void list_lower_level( List *l ) {
  if ( !l )
    return;
  if (!l->level) {
    free(l->current);
    l->current = ((void *)0);
  } else {
    l->current = (Element **)realloc(l->current, l->level*sizeof(Element *));
  }
  l->level--;

}

canonical_original_code:
void list_lower_level(struct ocr_object_list *l) {
  if ( !l )
    return;
  if (!l->level) {
    free(l->current);
    l->current = ((void *)0);
  } else {
    l->current = (struct ocr_element **)realloc(l->current, l->level*sizeof(struct ocr_element *));
  }
  l->level--;

}


original_code:
void list_sort( List *l, int (*compare)(const void *, const void *) ) {
  Element *temp, *prev;
  int i, sorted;
  progress_counter_t *pc = ((void *)0);
  if ( !l )
    return;
  pc = open_progress(l->n,"list_sort");
  for (i = 0; i < l->n; i++ ) {
    sorted = 1;
    for ( temp = l->start.next->next;
          temp != ((void *)0) && temp != &l->stop; temp = temp->next ) {
      if ( temp->previous == &l->start ) continue;
      if ( compare((const void *)temp->previous->data,
                   (const void *)temp->data) > 0 ) {
        sorted = 0;
 prev = temp->previous;
   prev->previous->next = temp;
        temp->next->previous = prev;
 temp->previous = prev->previous;
 prev->next = temp->next;
 prev->previous = temp;
 temp->next = prev;
 temp = prev;
      }
    }
    if (sorted) break;
    progress(i,pc);
  }
  close_progress(pc);

}

canonical_original_code:
void list_sort(struct ocr_object_list *l, int (*compare)(void *, void *)) {
  struct ocr_element *temp; struct ocr_element *prev;
  int i; int sorted;
  struct progress_counter *pc = ((void *)0);
  if ( !l )
    return;
  pc = open_progress(l->n,"list_sort");
  for (i = 0; i < l->n; i++ ) {
    sorted = 1;
    for ( temp = l->start.next->next;
          temp != ((void *)0) && temp != &l->stop; temp = temp->next ) {
      if ( temp->previous == &l->start ) continue;
      if ( compare((void *)temp->previous->data,
                   (void *)temp->data) > 0 ) {
        sorted = 0;
 prev = temp->previous;
   prev->previous->next = temp;
        temp->next->previous = prev;
 temp->previous = prev->previous;
 prev->next = temp->next;
 prev->previous = temp;
 temp->next = prev;
 temp = prev;
      }
    }
    if (sorted) break;
    progress(i,pc);
  }
  close_progress(pc);

}

variable_types:
compare
int (*)(void *, void *)

variable_types: sorted int

variable_types: struct progress_counter { char *name; int lastprintcount; int maxcount; int numskip; long starttime; long lastprinttime; } *


decompiled_code:
__int64 __fastcall list_and_data_free(__int64 a1, void (*a2)(void))
{
__int64 result; // rax
__int64 i; // rax
_QWORD **v4; // rax

if ( !a1 )
return 0LL;
result = 1LL;
if ( a2 )
{
if ( !(unsigned int)list_higher_level(a1) )
{
for ( i = *(_QWORD *)(*(_QWORD *)(a1 + 48) + 8LL * *(int *)(a1 + 60));
i;
i = *(_QWORD *)(*(_QWORD *)(a1 + 48) + 8LL * *(int *)(a1 + 60)) )
{
if ( i == a1 + 24 )
break;
if ( *(_QWORD *)(i + 16) )
a2();
v4 = (_QWORD **)(*(_QWORD *)(a1 + 48) + 8LL * *(int *)(a1 + 60));
*v4 = (_QWORD *)**v4;
}
list_lower_level(a1);
}
list_free(a1);
result = 0LL;
}
return result;
}

original_code:
int list_and_data_free( List *l, void (*free_data)(void *data)) {
  void *data;
  if ( !l ) return 0;
  if ( !free_data ) return 1;
  if (list_higher_level(l) == 0) { for ( ; (l)->current[(l)->level] && (l)->current[(l)->level]!=&(l)->stop; (l)->current[(l)->level] = (l)->current[(l)->level]->next ) { {
    if ((data = ((l)->current[(l)->level]->data)))
      free_data(data);
  } } list_lower_level(l); };
  list_free(l);

  return 0;
}

canonical_original_code:
int list_and_data_free(struct ocr_object_list *l, void (*free_data)(void *data)) {
  void *data;
  if ( !l ) return 0;
  if ( !free_data ) return 1;
  if (list_higher_level(l) == 0) { for ( ; (l)->current[(l)->level] && (l)->current[(l)->level]!=&(l)->stop; (l)->current[(l)->level] = (l)->current[(l)->level]->next ) { {
    if ((data = ((l)->current[(l)->level]->data)))
      free_data(data);
  } } list_lower_level(l); };
  list_free(l);

  return 0;
}


decompiled_code:
__int64 __fastcall ini_progress(char *filename)
{
__int64 result; // rax
char v3; // bp
int v4; // edi
__int64 v5; // rax

if ( fp )
{
fclose(fp);
fp = 0LL;
}
result = 0LL;
if ( filename )
{
v3 = *filename;
if ( *filename )
{
v4 = atoi(filename);
if ( v4 > 255 )
goto LABEL_25;
v5 = 3LL;
if ( v4 <= 99 )
v5 = (v4 > 9) + 1LL;
if ( filename[v5] )
{
LABEL_25:
if ( v3 == 45 && !filename[1] )
goto LABEL_22;
}
else
{
if ( v3 == 45 && !filename[1] )
{
LABEL_22:
fp = stdout;
LABEL_12:
if ( fp )
return 0LL;
fprintf(stderr, "could not open %s for progress output\n", filename);
return 0xFFFFFFFFLL;
}
if ( v4 > 0 )
{
fp = fdopen(v4, "w");
goto LABEL_12;
}
}
fp = fopen(filename, "w");
result = 0LL;
if ( fp )
return result;
fp = fopen(filename, "a");
goto LABEL_12;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(char *filename)
{
__int64 result; // rax
char v3; // bp
int v4; // edi
__int64 v5; // rax

if ( fp )
{
fclose(fp);
fp = 0LL;
}
result = 0LL;
if ( filename )
{
v3 = *filename;
if ( *filename )
{
v4 = atoi(filename);
if ( v4 > 255 )
goto LABEL_25;
v5 = 3LL;
if ( v4 <= 99 )
v5 = (v4 > 9) + 1LL;
if ( filename[v5] )
{
LABEL_25:
if ( v3 == 45 && !filename[1] )
goto LABEL_22;
}
else
{
if ( v3 == 45 && !filename[1] )
{
LABEL_22:
fp = stdout;
LABEL_12:
if ( fp )
return 0LL;
fprintf(stderr, "could not open %s for progress output\n", filename);
return 0xFFFFFFFFLL;
}
if ( v4 > 0 )
{
fp = fdopen(v4, "w");
goto LABEL_12;
}
}
fp = fopen(filename, "w");
result = 0LL;
if ( fp )
return result;
fp = fopen(filename, "a");
goto LABEL_12;
}
}
return result;
}

original_code:
int ini_progress(char *fname){
  int fd;
  if (fp) { fclose(fp); fp=((void *)0); }
  if (fname) if (fname[0]) {
    fd=atoi(fname);
    if(fd>255 || fname[((fd>99)?3:((fd>9)?2:1))]) fd=-1;
    if (fname[0]=='-' && fname[1]==0) { fp=stdout; }
    else if (fd>0) { fp=fdopen(fd,"w"); }
    else { fp=fopen(fname,"w");if(!fp)fp=fopen(fname,"a"); }
    if (!fp) {
      fprintf(stderr,"could not open %s for progress output\n",fname);
      return -1;
    }
  }
  return 0;
}

variable_types:
fname
char *

variable_types: fd int


decompiled_code:
__int64 __fastcall close_progress(void *a1)
{
if ( a1 )
free(a1);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(void *a1)
{
if ( a1 )
free(a1);
return 0LL;
}

original_code:
int close_progress(progress_counter_t *counter){
  if (counter) free(counter);
  return 0;
}

canonical_original_code:
int close_progress(struct progress_counter *counter){
  if (counter) free(counter);
  return 0;
}

user_defined_types: struct progress_counter { char *name; int lastprintcount; int maxcount; int numskip; long starttime; long lastprinttime; }


progress

original_code:
int progress(int counter, progress_counter_t *pc){
  if ((!fp) || counter - pc->lastprintcount <= pc->numskip) return 0;
  {
    char cr='\n';
    time_t now = time(((void *)0));
    if (5*(now - pc->lastprinttime) < 2*printinterval
     && counter - pc->lastprintcount >= pc->numskip) {
      if (pc->numskip < 1024) pc->numskip += pc->numskip+1;
    }
    if (3*(now - pc->lastprinttime) < 2*printinterval ) {
      return 0;
    }
    if (2*(now - pc->lastprinttime) > 3*printinterval ) {
      pc->numskip >>= 1;
    }
    if (fileno(fp)<3) cr='\r';
    if (counter)
    fprintf(fp," progress %s %5d / %d  time[s] %5d / %5d  (skip=%d)%c",
            pc->name,counter,pc->maxcount,
            (int)(now - pc->starttime),
            (int)(now - pc->starttime)*pc->maxcount/(counter),
            pc->numskip, cr);
    fflush(fp);
    pc->lastprintcount=counter;
    pc->lastprinttime=now;
  }
  return 0;
}

canonical_original_code:
int progress(int counter, struct progress_counter *pc){
  if ((!fp) || counter - pc->lastprintcount <= pc->numskip) return 0;
  {
    char cr = '\n';
    long now = time(((void *)0));
    if (5*(now - pc->lastprinttime) < 2*printinterval
     && counter - pc->lastprintcount >= pc->numskip) {
      if (pc->numskip < 1024) pc->numskip += pc->numskip+1;
    }
    if (3*(now - pc->lastprinttime) < 2*printinterval ) {
      return 0;
    }
    if (2*(now - pc->lastprinttime) > 3*printinterval ) {
      pc->numskip >>= 1;
    }
    if (fileno(fp)<3) cr='\r';
    if (counter)
    fprintf(fp," progress %s %5d / %d  time[s] %5d / %5d  (skip=%d)%c",
            pc->name,counter,pc->maxcount,
            (int)(now - pc->starttime),
            (int)(now - pc->starttime)*pc->maxcount/(counter),
            pc->numskip, cr);
    fflush(fp);
    pc->lastprintcount=counter;
    pc->lastprinttime=now;
  }
  return 0;
}

variable_types: counter int

variable_types: cr char

variable_types: now long


original_code:
void job_init(job_t *job) {
  job->src.fname = "-";
  list_init( &job->tmp.dblist );
  job->cfg.cs = 0;
  job->cfg.spc = 0;
  job->cfg.mode = 0;
  job->cfg.dust_size = -1;
  job->cfg.only_numbers = 0;
  job->cfg.verbose = 0;
  job->cfg.out_format = UTF8;
  job->cfg.lc = "_";
  job->cfg.db_path = (char*)((void *)0);
  job->cfg.cfilter = (char*)((void *)0);
  job->cfg.certainty = 95;
  job->cfg.unrec_marker = "_";
}

canonical_original_code:
void job_init(struct job_s *job) {
  job->src.fname = "-";
  list_init( &job->tmp.dblist );
  job->cfg.cs = 0;
  job->cfg.spc = 0;
  job->cfg.mode = 0;
  job->cfg.dust_size = -1;
  job->cfg.only_numbers = 0;
  job->cfg.verbose = 0;
  job->cfg.out_format = UTF8;
  job->cfg.lc = "_";
  job->cfg.db_path = (char *)((void *)0);
  job->cfg.cfilter = (char *)((void *)0);
  job->cfg.certainty = 95;
  job->cfg.unrec_marker = "_";
}


original_code:
void job_init_image(job_t *job) {
  job->src.p.p = ((void *)0);
  list_init( &job->res.boxlist );
  list_init( &job->res.linelist );
  job->res.avX = 5;
  job->res.avY = 8;
  job->res.sumX = 0;
  job->res.sumY = 0;
  job->res.numC = 0;
  job->res.lines.dy=0;
  job->res.lines.num=0;
  job->tmp.n_run = 0;
  job->tmp.ppo.p = ((void *)0);
  job->tmp.ppo.x = 0;
  job->tmp.ppo.y = 0;
}

canonical_original_code:
void job_init_image(struct job_s *job) {
  job->src.p.p = ((void *)0);
  list_init( &job->res.boxlist );
  list_init( &job->res.linelist );
  job->res.avX = 5;
  job->res.avY = 8;
  job->res.sumX = 0;
  job->res.sumY = 0;
  job->res.numC = 0;
  job->res.lines.dy=0;
  job->res.lines.num=0;
  job->tmp.n_run = 0;
  job->tmp.ppo.p = ((void *)0);
  job->tmp.ppo.x = 0;
  job->tmp.ppo.y = 0;
}


original_code:
void job_free_image(job_t *job) {
  if (job->tmp.ppo.p==job->src.p.p) job->tmp.ppo.p=((void *)0);
  list_and_data_free(&(job->res.boxlist), (void (*)(void *))free_box);
  if (job->src.p.p) { free(job->src.p.p); job->src.p.p=((void *)0); }
  if (job->tmp.ppo.p) { free(job->tmp.ppo.p); job->tmp.ppo.p=((void *)0); }
}

canonical_original_code:
void job_free_image(struct job_s *job) {
  if (job->tmp.ppo.p==job->src.p.p) job->tmp.ppo.p=((void *)0);
  list_and_data_free(&(job->res.boxlist), (void (*)(void *))free_box);
  if (job->src.p.p) { free(job->src.p.p); job->src.p.p=((void *)0); }
  if (job->tmp.ppo.p) { free(job->tmp.ppo.p); job->tmp.ppo.p=((void *)0); }
}


variable_types: struct pixmap { unsigned char *p; int x; int y; int bpp; } *

variable_types: cs int

variable_types: l int

variable_types: j int

variable_types:
xa
int [10]

variable_types:
ya
int [10]

variable_types:
xb
int [10]

variable_types:
yb
int [10]

variable_types:
ll
int [10]


stringToInt

repo: metthal/IFJ-Projekt

decompiled_code:
__int64 __fastcall stringToInt(__int64 a1)
{
const char *v1; // rbx
const unsigned __int16 *v2; // rcx
unsigned int v3; // edx

v1 = *(const char **)(a1 + 8);
v2 = *_ctype_b_loc();
while ( (v2[*v1] & 0x2000) != 0 )
++v1;
v3 = 0;
if ( ((*v1 - 43) & 0xFD) != 0 )
v3 = strtol(v1, 0LL, 10);
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1)
{
const char *v1; // rbx
const unsigned __int16 *v2; // rcx
unsigned int v3; // edx

v1 = *(const char **)(a1 + 8);
v2 = *_ctype_b_loc();
while ( (v2[*v1] & 0x2000) != 0 )
++v1;
v3 = 0;
if ( ((*v1 - 43) & 0xFD) != 0 )
v3 = strtol(v1, 0LL, 10);
return v3;
}

original_code:
int stringToInt(const String *str)
{
    const char *directStr = str->data;
    while (((*__ctype_b_loc ())[(int) ((*directStr))] & (unsigned short int) _ISspace))
        directStr++;
    if (*directStr == '-' || *directStr == '+')
        return 0;
    return strtol(directStr, ((void *)0), 10);
}

canonical_original_code:
int stringToInt(struct String *str)
{
    char *directStr = str->data;
    while (((*__ctype_b_loc ())[(int) ((*directStr))] & (unsigned short) _ISspace))
        directStr++;
    if (*directStr == '-' || *directStr == '+')
        return 0;
    return strtol(directStr, ((void *)0), 10);
}

variable_types: struct String { unsigned int size; unsigned int length; char *data; } *

variable_types:
directStr
char *


stringToDouble

decompiled_code:
double __fastcall stringToDouble(__int64 a1)
{
int v1; // eax
const char *v2; // r14
const char *v3; // rbx
__int64 v4; // r13
char v5; // r12
double result; // xmm0_8
char v7; // bp

v1 = *(_DWORD *)(a1 + 4);
if ( !v1 )
return 0.0;
v2 = *(const char **)(a1 + 8);
v3 = v2;
v4 = (__int64)&v2[v1 - 1 + 1];
v5 = 0;
while ( 2 )
{
v7 = *v3;
switch ( v5 )
{
case 0:
if ( ((*_ctype_b_loc())[v7] & 0x2000) != 0 )
goto LABEL_14;
if ( (unsigned __int8)(v7 - 48) <= 9u )
{
v5 = 1;
goto LABEL_14;
}
return 0.0;
case 1:
if ( (unsigned __int8)(v7 - 48) <= 9u )
goto LABEL_14;
if ( v7 == 46 )
{
v5 = 2;
}
else
{
if ( (v7 & 0xDF) != 69 )
return strtod(v2, 0LL);
v5 = 4;
}
goto LABEL_14;
case 2:
if ( (unsigned __int8)(v7 - 48) > 9u )
{
setErrorExp(6, 82, (__int64)"convert.c", (__int64)"stringToDouble");
return 0.0;
}
v5 = 3;
goto LABEL_14;
case 3:
if ( (unsigned __int8)(v7 - 48) <= 9u )
goto LABEL_14;
if ( (v7 & 0xDF) != 69 )
return strtod(v2, 0LL);
v5 = 4;
LABEL_14:
if ( (const char *)v4 != ++v3 )
continue;
result = 0.0;
break;
case 4:
if ( (unsigned __int8)(v7 - 48) <= 9u )
return strtod(v2, 0LL);
if ( ((v7 - 43) & 0xFD) != 0 )
{
setErrorExp(6, 103, (__int64)"convert.c", (__int64)"stringToDouble");
return 0.0;
}
v5 = 5;
goto LABEL_14;
case 5:
if ( (unsigned __int8)(v7 - 48) <= 9u )
return strtod(v2, 0LL);
setErrorExp(6, 113, (__int64)"convert.c", (__int64)"stringToDouble");
return 0.0;
default:
goto LABEL_14;
}
return result;
}
}

canonical_decompiled_code:
double __fastcall func2(__int64 a1)
{
int v1; // eax
const char *v2; // r14
const char *v3; // rbx
__int64 v4; // r13
char v5; // r12
double result; // xmm0_8
char v7; // bp

v1 = *(_DWORD *)(a1 + 4);
if ( !v1 )
return 0.0;
v2 = *(const char **)(a1 + 8);
v3 = v2;
v4 = (__int64)&v2[v1 - 1 + 1];
v5 = 0;
while ( 2 )
{
v7 = *v3;
switch ( v5 )
{
case 0:
if ( ((*_ctype_b_loc())[v7] & 0x2000) != 0 )
goto LABEL_14;
if ( (unsigned __int8)(v7 - 48) <= 9u )
{
v5 = 1;
goto LABEL_14;
}
return 0.0;
case 1:
if ( (unsigned __int8)(v7 - 48) <= 9u )
goto LABEL_14;
if ( v7 == 46 )
{
v5 = 2;
}
else
{
if ( (v7 & 0xDF) != 69 )
return strtod(v2, 0LL);
v5 = 4;
}
goto LABEL_14;
case 2:
if ( (unsigned __int8)(v7 - 48) > 9u )
{
func0(6, 82, (__int64)"convert.c", (__int64)"stringToDouble");
return 0.0;
}
v5 = 3;
goto LABEL_14;
case 3:
if ( (unsigned __int8)(v7 - 48) <= 9u )
goto LABEL_14;
if ( (v7 & 0xDF) != 69 )
return strtod(v2, 0LL);
v5 = 4;
LABEL_14:
if ( (const char *)v4 != ++v3 )
continue;
result = 0.0;
break;
case 4:
if ( (unsigned __int8)(v7 - 48) <= 9u )
return strtod(v2, 0LL);
if ( ((v7 - 43) & 0xFD) != 0 )
{
func0(6, 103, (__int64)"convert.c", (__int64)"stringToDouble");
return 0.0;
}
v5 = 5;
goto LABEL_14;
case 5:
if ( (unsigned __int8)(v7 - 48) <= 9u )
return strtod(v2, 0LL);
func0(6, 113, (__int64)"convert.c", (__int64)"stringToDouble");
return 0.0;
default:
goto LABEL_14;
}
return result;
}
}

original_code:
double stringToDouble(const String *str)
{
    uint32_t charPos = 0;
    uint8_t state = CS_Start;
    while (charPos < str->length) {
        char currentChar = str->data[charPos++];
        switch (state) {
            case CS_Start:
                if (((*__ctype_b_loc ())[(int) ((currentChar))] & (unsigned short int) _ISspace))
                    ;
                else if ('0' <= currentChar && currentChar <= '9')
                    state = CS_Number;
                else
                    return 0.0;
                break;
            case CS_Number:
                if ('0' <= currentChar && currentChar <= '9')
                    ;
                else if (currentChar == '.')
                    state = CS_DecimalPoint;
                else if (currentChar == 'e' || currentChar == 'E')
                    state = CS_Exponent;
                else
                    return strtod(str->data, ((void *)0));
                break;
            case CS_DecimalPoint:
                if ('0' <= currentChar && currentChar <= '9')
                    state = CS_Decimal;
                else {
                    setErrorExp(ERR_Convert, 82, "convert.c", __func__);
                    return 0.0;
                }
                break;
            case CS_Decimal:
                if ('0' <= currentChar && currentChar <= '9')
                    ;
                else if (currentChar == 'e' || currentChar == 'E')
                    state = CS_Exponent;
                else
                    return strtod(str->data, ((void *)0));
                break;
            case CS_Exponent:
                if ('0' <= currentChar && currentChar <= '9')
                    return strtod(str->data, ((void *)0));
                else if (currentChar == '+' || currentChar == '-')
                    state = CS_ExponentSign;
                else {
                    setErrorExp(ERR_Convert, 103, "convert.c", __func__);
                    return 0.0;
                }
                break;
            case CS_ExponentSign:
                if ('0' <= currentChar && currentChar <= '9')
                    return strtod(str->data, ((void *)0));
                else {
                    setErrorExp(ERR_Convert, 113, "convert.c", __func__);
                    return 0.0;
                }
                break;
        }
    }
    return 0.0;
}

canonical_original_code:
double stringToDouble(struct String *str)
{
    unsigned int charPos = 0;
    unsigned char state = CS_Start;
    while (charPos < str->length) {
        char currentChar = str->data[charPos++];
        switch (state) {
            case CS_Start:
                if (((*__ctype_b_loc ())[(int) ((currentChar))] & (unsigned short) _ISspace))
                    ;
                else if ('0' <= currentChar && currentChar <= '9')
                    state = CS_Number;
                else
                    return 0.0;
                break;
            case CS_Number:
                if ('0' <= currentChar && currentChar <= '9')
                    ;
                else if (currentChar == '.')
                    state = CS_DecimalPoint;
                else if (currentChar == 'e' || currentChar == 'E')
                    state = CS_Exponent;
                else
                    return strtod(str->data, ((void *)0));
                break;
            case CS_DecimalPoint:
                if ('0' <= currentChar && currentChar <= '9')
                    state = CS_Decimal;
                else {
                    setErrorExp(ERR_Convert, 82, "convert.c", __func__);
                    return 0.0;
                }
                break;
            case CS_Decimal:
                if ('0' <= currentChar && currentChar <= '9')
                    ;
                else if (currentChar == 'e' || currentChar == 'E')
                    state = CS_Exponent;
                else
                    return strtod(str->data, ((void *)0));
                break;
            case CS_Exponent:
                if ('0' <= currentChar && currentChar <= '9')
                    return strtod(str->data, ((void *)0));
                else if (currentChar == '+' || currentChar == '-')
                    state = CS_ExponentSign;
                else {
                    setErrorExp(ERR_Convert, 103, "convert.c", __func__);
                    return 0.0;
                }
                break;
            case CS_ExponentSign:
                if ('0' <= currentChar && currentChar <= '9')
                    return strtod(str->data, ((void *)0));
                else {
                    setErrorExp(ERR_Convert, 113, "convert.c", __func__);
                    return 0.0;
                }
                break;
        }
    }
    return 0.0;
}

variable_types:
charPos
unsigned int

variable_types:
state
unsigned char

variable_types: currentChar char

return_type: double

user_defined_types: struct String { unsigned int size; unsigned int length; char *data; }


intToString

decompiled_code:
__int64 __fastcall intToString(unsigned int a1)
{
int v1; // eax
__int64 result; // rax
char v3[40]; // [rsp+0h] [rbp-28h] BYREF

v1 = sprintf(v3, "%d", a1);
if ( v1 <= 0 )
result = newString();
else
result = newStringS(v3, (unsigned int)v1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1)
{
int v1; // eax
__int64 result; // rax
char v3[40]; // [rsp+0h] [rbp-28h] BYREF

v1 = sprintf(v3, "%d", a1);
if ( v1 <= 0 )
result = newString();
else
result = newStringS(v3, (unsigned int)v1);
return result;
}

original_code:
String* intToString(int num)
{
    String *tmp = ((void *)0);
    char buffer[21];
    int written = sprintf(buffer, "%d", num);
    if (written > 0)
        tmp = newStringS(buffer, written);
    else
        tmp = newString();
    return tmp;
}

canonical_original_code:
struct String *intToString(int num)
{
    struct String *tmp = ((void *)0);
    char buffer[21];
    int written = sprintf(buffer, "%d", num);
    if (written > 0)
        tmp = newStringS(buffer, written);
    else
        tmp = newString();
    return tmp;
}

variable_types: num int

variable_types:
buffer
char [21]

variable_types: written int

return_type: struct String { unsigned int size; unsigned int length; char *data; } *


intToStringE

decompiled_code:
__int64 __fastcall intToStringE(unsigned int a1, __int64 a2)
{
int v2; // eax
unsigned int v3; // ebx
char v5[56]; // [rsp+0h] [rbp-38h] BYREF

v2 = sprintf(v5, "%d", a1);
v3 = v2;
if ( a2 )
{
if ( v2 <= 0 )
initString(a2);
else
initStringS(a2, v5, (unsigned int)v2);
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int a1, __int64 a2)
{
int v2; // eax
unsigned int v3; // ebx
char v5[56]; // [rsp+0h] [rbp-38h] BYREF

v2 = sprintf(v5, "%d", a1);
v3 = v2;
if ( a2 )
{
if ( v2 <= 0 )
initString(a2);
else
initStringS(a2, v5, (unsigned int)v2);
}
return v3;
}

original_code:
int intToStringE(int num, String *str)
{
    char buffer[21];
    int written = sprintf(buffer, "%d", num);
    if (str != ((void *)0)) {
        if (written > 0)
            initStringS(str, buffer, written);
        else
            initString(str);
    }
    return written;
}

canonical_original_code:
int intToStringE(int num, struct String *str)
{
    char buffer[21];
    int written = sprintf(buffer, "%d", num);
    if (str != ((void *)0)) {
        if (written > 0)
            initStringS(str, buffer, written);
        else
            initString(str);
    }
    return written;
}


doubleToString

decompiled_code:
__int64 __fastcall doubleToString(double a1)
{
int v1; // eax
__int64 result; // rax
char v3[40]; // [rsp+0h] [rbp-28h] BYREF

v1 = sprintf(v3, "%g", a1);
if ( v1 <= 0 )
result = newString();
else
result = newStringS(v3, (unsigned int)v1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(double a1)
{
int v1; // eax
__int64 result; // rax
char v3[40]; // [rsp+0h] [rbp-28h] BYREF

v1 = sprintf(v3, "%g", a1);
if ( v1 <= 0 )
result = newString();
else
result = newStringS(v3, (unsigned int)v1);
return result;
}

original_code:
String* doubleToString(double num)
{
    String *tmp = ((void *)0);
    char buffer[26];
    int written = sprintf(buffer, "%g", num);
    if (written > 0)
        tmp = newStringS(buffer, written);
    else
        tmp = newString();
    return tmp;
}

canonical_original_code:
struct String *doubleToString(double num)
{
    struct String *tmp = ((void *)0);
    char buffer[26];
    int written = sprintf(buffer, "%g", num);
    if (written > 0)
        tmp = newStringS(buffer, written);
    else
        tmp = newString();
    return tmp;
}

variable_types: num double

variable_types:
buffer
char [26]


doubleToStringE

decompiled_code:
__int64 __fastcall doubleToStringE(__int64 a1, double a2)
{
int v2; // eax
unsigned int v3; // ebx
char v5[56]; // [rsp+0h] [rbp-38h] BYREF

v2 = sprintf(v5, "%g", a2);
v3 = v2;
if ( a1 )
{
if ( v2 <= 0 )
initString(a1);
else
initStringS(a1, v5, (unsigned int)v2);
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, double a2)
{
int v2; // eax
unsigned int v3; // ebx
char v5[56]; // [rsp+0h] [rbp-38h] BYREF

v2 = sprintf(v5, "%g", a2);
v3 = v2;
if ( a1 )
{
if ( v2 <= 0 )
initString(a1);
else
initStringS(a1, v5, (unsigned int)v2);
}
return v3;
}

original_code:
int doubleToStringE(double num, String *str)
{
    char buffer[26];
    int written = sprintf(buffer, "%g", num);
    if (str != ((void *)0)) {
        if (written > 0)
            initStringS(str, buffer, written);
        else
            initString(str);
    }
    return written;
}

canonical_original_code:
int doubleToStringE(double num, struct String *str)
{
    char buffer[26];
    int written = sprintf(buffer, "%g", num);
    if (str != ((void *)0)) {
        if (written > 0)
            initStringS(str, buffer, written);
        else
            initString(str);
    }
    return written;
}


getError

decompiled_code:
__int64 getError()
{
return niErr;
}

canonical_decompiled_code:
__int64 func0()
{
return niErr;
}

original_code:
static inline NiErrorType getError()
{
    return niErr.type;
}

canonical_original_code:
static inline enum NiErrorType getError()
{
    return niErr.type;
}

return_type: enum NiErrorType { ERR_None=0, ERR_Unknown=1, ERR_LexFile=2, ERR_Allocation=3, ERR_Range=4, ERR_Internal=5, ERR_Convert=6, ERR_Syntax=7, ERR_UndefFunction=8, ERR_RedefFunction=9, ERR_UndefVariable=10, ERR_RedefParameter=11, ERR_BadParamCount=12, ERR_DefArgOrder=13, ERR_BadDefArg=14, ERR_ISTGenerator=15, ERR_CycleControl=16, ERR_Substr=17, ERR_OperandTypes=18, ERR_DivideByZero=19 }


newInstruction

decompiled_code:
_QWORD *newInstruction()
{
_QWORD *result; // rax

result = malloc(0x14uLL);
*result = 0LL;
result[1] = 0LL;
*((_DWORD *)result + 4) = 0;
return result;
}

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

result = malloc(0x14uLL);
*result = 0LL;
result[1] = 0LL;
*((_DWORD *)result + 4) = 0;
return result;
}

original_code:
Instruction* newInstruction()
{
    Instruction *tmp = malloc(sizeof(Instruction));
    memset(tmp, 0, sizeof(Instruction));
    return tmp;
}

canonical_original_code:
struct Instruction *newInstruction()
{
    struct Instruction *tmp = malloc(sizeof(Instruction));
    memset(tmp, 0, sizeof(Instruction));
    return tmp;
}

variable_types: struct Instruction { enum InstructionCode { IST_Noop=0, IST_Mov=1, IST_MovC=2, IST_Jmp=3, IST_Jmpz=4, IST_Jmpnz=5, IST_Push=6, IST_PushC=7, IST_PushRef=8, IST_Reserve=9, IST_Pop=10, IST_ClearExpr=11, IST_Call=12, IST_Return=13, IST_Nullify=14, IST_BoolVal=15, IST_DoubleVal=16, IST_FindString=17, IST_GetString=18, IST_GetSubstring=19, IST_IntVal=20, IST_PutString=21, IST_SortString=22, IST_StrLen=23, IST_StrVal=24, IST_Break=25, IST_Continue=26, IST_Add=27, IST_Subtract=28, IST_Multiply=29, IST_Divide=30, IST_Concat=31, IST_Equal=32, IST_NotEqual=33, IST_Less=34, IST_LessEq=35, IST_Greater=36, IST_GreaterEq=37, IST_And=38, IST_Or=39, IST_Not=40 } code; enum InstructionMode { ISM_NoConst=0, ISM_FirstConst=1, ISM_SecondConst=2, ISM_AllConst=3 } mode; int a; int b; int res; } *

user_defined_types: struct Instruction { enum InstructionCode code; enum InstructionMode mode; int a; int b; int res; }


initInstruction

decompiled_code:
void __fastcall initInstruction(__int64 a1)
{
*(_QWORD *)a1 = 0LL;
*(_QWORD *)(a1 + 8) = 0LL;
*(_DWORD *)(a1 + 16) = 0;
}

original_code:
void initInstruction(Instruction *pt)
{
    memset(pt, 0, sizeof(Instruction));
}

canonical_original_code:
void initInstruction(struct Instruction *pt)
{
    memset(pt, 0, sizeof(Instruction));
}

user_defined_types: enum InstructionCode { IST_Noop=0, IST_Mov=1, IST_MovC=2, IST_Jmp=3, IST_Jmpz=4, IST_Jmpnz=5, IST_Push=6, IST_PushC=7, IST_PushRef=8, IST_Reserve=9, IST_Pop=10, IST_ClearExpr=11, IST_Call=12, IST_Return=13, IST_Nullify=14, IST_BoolVal=15, IST_DoubleVal=16, IST_FindString=17, IST_GetString=18, IST_GetSubstring=19, IST_IntVal=20, IST_PutString=21, IST_SortString=22, IST_StrLen=23, IST_StrVal=24, IST_Break=25, IST_Continue=26, IST_Add=27, IST_Subtract=28, IST_Multiply=29, IST_Divide=30, IST_Concat=31, IST_Equal=32, IST_NotEqual=33, IST_Less=34, IST_LessEq=35, IST_Greater=36, IST_GreaterEq=37, IST_And=38, IST_Or=39, IST_Not=40 }

user_defined_types: enum InstructionMode { ISM_NoConst=0, ISM_FirstConst=1, ISM_SecondConst=2, ISM_AllConst=3 }


deleteInstruction

decompiled_code:
void deleteInstruction()
{
;
}

canonical_decompiled_code:
void func6()
{
;
}

original_code:
void deleteInstruction(Instruction *pt)
{
    if (pt != ((void *)0)) {
    }
}

canonical_original_code:
void deleteInstruction(struct Instruction *pt)
{
    if (pt != ((void *)0)) {
    }
}


freeInstruction

decompiled_code:
void __fastcall freeInstruction(void **a1)
{
if ( a1 )
{
free(*a1);
*a1 = 0LL;
}
}

canonical_decompiled_code:
void __fastcall func7(void **a1)
{
if ( a1 )
{
free(*a1);
*a1 = 0LL;
}
}

original_code:
void freeInstruction(Instruction **ppt)
{
    if (ppt != ((void *)0)) {
        if (*ppt != ((void *)0)) {
        }
        free(*ppt);
        *ppt = ((void *)0);
    }
}

canonical_original_code:
void freeInstruction(struct Instruction **ppt)
{
    if (ppt != ((void *)0)) {
        if (*ppt != ((void *)0)) {
        }
        free(*ppt);
        *ppt = ((void *)0);
    }
}

variable_types: struct Instruction { enum InstructionCode { IST_Noop=0, IST_Mov=1, IST_MovC=2, IST_Jmp=3, IST_Jmpz=4, IST_Jmpnz=5, IST_Push=6, IST_PushC=7, IST_PushRef=8, IST_Reserve=9, IST_Pop=10, IST_ClearExpr=11, IST_Call=12, IST_Return=13, IST_Nullify=14, IST_BoolVal=15, IST_DoubleVal=16, IST_FindString=17, IST_GetString=18, IST_GetSubstring=19, IST_IntVal=20, IST_PutString=21, IST_SortString=22, IST_StrLen=23, IST_StrVal=24, IST_Break=25, IST_Continue=26, IST_Add=27, IST_Subtract=28, IST_Multiply=29, IST_Divide=30, IST_Concat=31, IST_Equal=32, IST_NotEqual=33, IST_Less=34, IST_LessEq=35, IST_Greater=36, IST_GreaterEq=37, IST_And=38, IST_Or=39, IST_Not=40 } code; enum InstructionMode { ISM_NoConst=0, ISM_FirstConst=1, ISM_SecondConst=2, ISM_AllConst=3 } mode; int a; int b; int res; } **


vectorPushInstruction

decompiled_code:
__int64 __fastcall vectorPushInstruction(__int64 a1, _DWORD *a2)
{
int v3; // esi
__int64 result; // rax

v3 = *(_DWORD *)(a1 + 4);
if ( *(_DWORD *)a1 != v3
|| (v3 ? vectorReserve(a1, (unsigned int)(2 * v3)) : vectorReserve(a1, 16LL), result = getError(), !(_DWORD)result) )
{
copyInstruction(a2, *(_DWORD **)(a1 + 24));
++*(_DWORD *)a1;
result = *(_QWORD *)(a1 + 8);
*(_QWORD *)(a1 + 24) += result;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, _DWORD *a2)
{
int v3; // esi
__int64 result; // rax

v3 = *(_DWORD *)(a1 + 4);
if ( *(_DWORD *)a1 != v3
|| (v3 ? vectorReserve(a1, (unsigned int)(2 * v3)) : vectorReserve(a1, 16LL), result = func0(), !(_DWORD)result) )
{
func8(a2, *(_DWORD **)(a1 + 24));
++*(_DWORD *)a1;
result = *(_QWORD *)(a1 + 8);
*(_QWORD *)(a1 + 24) += result;
}
return result;
}

original_code:
static void vectorPushInstruction(Vector *vec, const Instruction* item)
{
    if (vec->size == vec->capacity) {
        if (vec->capacity == 0)
            vectorReserve(vec, VectorDefaultCapacity);
        else
            vectorReserve(vec, vec->capacity * VectorResizeIncRate);
        if (getError())
            return;
    }
    copyInstruction((item), (InstructionVectorIterator)(vec->end));
    vec->size++;
    vec->end += vec->itemSize;
}

canonical_original_code:
static void vectorPushInstruction(struct Vector *vec, struct Instruction *item)
{
    if (vec->size == vec->capacity) {
        if (vec->capacity == 0)
            vectorReserve(vec, VectorDefaultCapacity);
        else
            vectorReserve(vec, vec->capacity * VectorResizeIncRate);
        if (getError())
            return;
    }
    copyInstruction((item), (InstructionVectorIterator)(vec->end));
    vec->size++;
    vec->end += vec->itemSize;
}

variable_types: struct Vector { unsigned int size; unsigned int capacity; unsigned long itemSize; unsigned char *data; unsigned char *end; } *


builtinToInstruction

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

switch ( a1 )
{
case 0:
result = 12LL;
break;
case 1:
result = 15LL;
break;
case 2:
result = 16LL;
break;
case 3:
result = 17LL;
break;
case 4:
result = 18LL;
break;
case 5:
result = 19LL;
break;
case 6:
result = 20LL;
break;
case 7:
result = 21LL;
break;
case 8:
result = 22LL;
break;
case 9:
result = 23LL;
break;
case 10:
result = 24LL;
break;
default:
result = 0LL;
break;
}
return result;
}

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

switch ( a1 )
{
case 0:
result = 12LL;
break;
case 1:
result = 15LL;
break;
case 2:
result = 16LL;
break;
case 3:
result = 17LL;
break;
case 4:
result = 18LL;
break;
case 5:
result = 19LL;
break;
case 6:
result = 20LL;
break;
case 7:
result = 21LL;
break;
case 8:
result = 22LL;
break;
case 9:
result = 23LL;
break;
case 10:
result = 24LL;
break;
default:
result = 0LL;
break;
}
return result;
}

original_code:
InstructionCode builtinToInstruction(BuiltinCode builtinCode)
{
    switch (builtinCode) {
        case BTI_None:
            return IST_Call;
        case BTI_BoolVal:
            return IST_BoolVal;
        case BTI_DoubleVal:
            return IST_DoubleVal;
        case BTI_FindString:
            return IST_FindString;
        case BTI_GetString:
            return IST_GetString;
        case BTI_GetSubstring:
            return IST_GetSubstring;
        case BTI_IntVal:
            return IST_IntVal;
        case BTI_SortString:
            return IST_SortString;
        case BTI_StrLen:
            return IST_StrLen;
        case BTI_StrVal:
            return IST_StrVal;
        case BTI_PutString:
            return IST_PutString;
    }
    return IST_Noop;
}

canonical_original_code:
enum InstructionCode builtinToInstruction(enum BuiltinCode builtinCode)
{
    switch (builtinCode) {
        case BTI_None:
            return IST_Call;
        case BTI_BoolVal:
            return IST_BoolVal;
        case BTI_DoubleVal:
            return IST_DoubleVal;
        case BTI_FindString:
            return IST_FindString;
        case BTI_GetString:
            return IST_GetString;
        case BTI_GetSubstring:
            return IST_GetSubstring;
        case BTI_IntVal:
            return IST_IntVal;
        case BTI_SortString:
            return IST_SortString;
        case BTI_StrLen:
            return IST_StrLen;
        case BTI_StrVal:
            return IST_StrVal;
        case BTI_PutString:
            return IST_PutString;
    }
    return IST_Noop;
}

variable_types: enum BuiltinCode { BTI_None=0, BTI_BoolVal=1, BTI_DoubleVal=2, BTI_FindString=3, BTI_GetString=4, BTI_GetSubstring=5, BTI_IntVal=6, BTI_PutString=7, BTI_SortString=8, BTI_StrLen=9, BTI_StrVal=10 }

return_type: enum InstructionCode { IST_Noop=0, IST_Mov=1, IST_MovC=2, IST_Jmp=3, IST_Jmpz=4, IST_Jmpnz=5, IST_Push=6, IST_PushC=7, IST_PushRef=8, IST_Reserve=9, IST_Pop=10, IST_ClearExpr=11, IST_Call=12, IST_Return=13, IST_Nullify=14, IST_BoolVal=15, IST_DoubleVal=16, IST_FindString=17, IST_GetString=18, IST_GetSubstring=19, IST_IntVal=20, IST_PutString=21, IST_SortString=22, IST_StrLen=23, IST_StrVal=24, IST_Break=25, IST_Continue=26, IST_Add=27, IST_Subtract=28, IST_Multiply=29, IST_Divide=30, IST_Concat=31, IST_Equal=32, IST_NotEqual=33, IST_Less=34, IST_LessEq=35, IST_Greater=36, IST_GreaterEq=37, IST_And=38, IST_Or=39, IST_Not=40 }


generateInstruction

decompiled_code:
void __fastcall generateInstruction(int a1, int a2, int a3, int a4, int a5)
{
int v5[10]; // [rsp+0h] [rbp-28h] BYREF

if ( a1 == 12 )
{
setErrorExp(15, 165, (__int64)"instruction.c", (__int64)"generateInstruction");
}
else
{
v5[0] = a1;
v5[1] = a2;
v5[4] = a3;
v5[2] = a4;
v5[3] = a5;
vectorPushInstruction(instructions, v5);
}
}

canonical_decompiled_code:
void __fastcall func11(int a1, int a2, int a3, int a4, int a5)
{
int v5[10]; // [rsp+0h] [rbp-28h] BYREF

if ( a1 == 12 )
{
func1(15, 165, (__int64)"instruction.c", (__int64)"generateInstruction");
}
else
{
v5[0] = a1;
v5[1] = a2;
v5[4] = a3;
v5[2] = a4;
v5[3] = a5;
func9(instructions, v5);
}
}

original_code:
void generateInstruction(InstructionCode code, InstructionMode mode, int32_t res, int32_t a, int32_t b)
{
    if (code == IST_Call) {
        setErrorExp(ERR_ISTGenerator, 165, "instruction.c", __func__);
        return;
    }
    Instruction inst;
    inst.code = code;
    inst.mode = mode;
    inst.res = res;
    inst.a = a;
    inst.b = b;
    vectorPushInstruction(instructions, &inst);
}

canonical_original_code:
void generateInstruction(enum InstructionCode code, enum InstructionMode mode, int res, int a, int b)
{
    if (code == IST_Call) {
        setErrorExp(ERR_ISTGenerator, 165, "instruction.c", __func__);
        return;
    }
    struct Instruction inst;
    inst.code = code;
    inst.mode = mode;
    inst.res = res;
    inst.a = a;
    inst.b = b;
    vectorPushInstruction(instructions, &inst);
}

variable_types: res int

variable_types: a int

variable_types: b int

variable_types: struct Instruction { enum InstructionCode { IST_Noop=0, IST_Mov=1, IST_MovC=2, IST_Jmp=3, IST_Jmpz=4, IST_Jmpnz=5, IST_Push=6, IST_PushC=7, IST_PushRef=8, IST_Reserve=9, IST_Pop=10, IST_ClearExpr=11, IST_Call=12, IST_Return=13, IST_Nullify=14, IST_BoolVal=15, IST_DoubleVal=16, IST_FindString=17, IST_GetString=18, IST_GetSubstring=19, IST_IntVal=20, IST_PutString=21, IST_SortString=22, IST_StrLen=23, IST_StrVal=24, IST_Break=25, IST_Continue=26, IST_Add=27, IST_Subtract=28, IST_Multiply=29, IST_Divide=30, IST_Concat=31, IST_Equal=32, IST_NotEqual=33, IST_Less=34, IST_LessEq=35, IST_Greater=36, IST_GreaterEq=37, IST_And=38, IST_Or=39, IST_Not=40 } code; enum InstructionMode { ISM_NoConst=0, ISM_FirstConst=1, ISM_SecondConst=2, ISM_AllConst=3 } mode; int a; int b; int res; }


generateCall

decompiled_code:
__int64 __fastcall generateCall(int **a1, unsigned int a2, unsigned int a3)
{
unsigned int v4; // [rsp+Ch] [rbp-3Ch] BYREF
int v5; // [rsp+10h] [rbp-38h] BYREF
unsigned int v6; // [rsp+18h] [rbp-30h]

v4 = a3;
initInstruction((__int64)&v5);
if ( !a2 )
{
processDefaultArg((__int64)(*a1 + 2), &v4);
if ( *((unsigned __int16 *)*a1 + 12) != v4 )
goto LABEL_6;
v6 = **a1;
LABEL_9:
v5 = builtinToInstruction(a2);
vectorPushInstruction(instructions, &v5);
return v4;
}
if ( a2 == 7 )
{
v6 = v4;
goto LABEL_9;
}
if ( v4 == getBuiltinParamCount(a2) )
goto LABEL_9;
LABEL_6:
setErrorExp(12, 153, (__int64)"instruction.c", (__int64)"generateCall");
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func13(int **a1, unsigned int a2, unsigned int a3)
{
unsigned int v4; // [rsp+Ch] [rbp-3Ch] BYREF
int v5; // [rsp+10h] [rbp-38h] BYREF
unsigned int v6; // [rsp+18h] [rbp-30h]

v4 = a3;
func4((__int64)&v5);
if ( !a2 )
{
func12((__int64)(*a1 + 2), &v4);
if ( *((unsigned __int16 *)*a1 + 12) != v4 )
goto LABEL_6;
v6 = **a1;
LABEL_9:
v5 = func10(a2);
func9(instructions, &v5);
return v4;
}
if ( a2 == 7 )
{
v6 = v4;
goto LABEL_9;
}
if ( v4 == getBuiltinParamCount(a2) )
goto LABEL_9;
LABEL_6:
func1(12, 153, (__int64)"instruction.c", (__int64)"generateCall");
return v4;
}

original_code:
uint32_t generateCall(const Symbol *symbol, BuiltinCode builtinCode, uint32_t paramCount)
{
    Instruction inst;
    initInstruction(&inst);
    uint8_t undef = 1, badParamCount = 0;
    switch(builtinCode) {
        case BTI_None:
            processDefaultArg(&(symbol->data->func.context), &paramCount);
            if (symbol->data->func.context.argumentCount == paramCount)
                inst.a = symbol->data->func.functionAddressIndex;
            else
                badParamCount = 1;
            undef = 0;
            break;
        case BTI_PutString:
            inst.a = paramCount;
            undef = 0;
            break;
        default:
            if (paramCount != getBuiltinParamCount(builtinCode))
                badParamCount = 1;
            undef = 0;
            break;
    }
    if (undef)
        setErrorExp(ERR_UndefFunction, 151, "instruction.c", __func__);
    else if (badParamCount)
        setErrorExp(ERR_BadParamCount, 153, "instruction.c", __func__);
    else {
        inst.code = builtinToInstruction(builtinCode);
        vectorPushInstruction(instructions, &inst);
    }
    return paramCount;
}

canonical_original_code:
unsigned int generateCall(struct Symbol *symbol, enum BuiltinCode builtinCode, unsigned int paramCount)
{
    struct Instruction inst;
    initInstruction(&inst);
    unsigned char undef = 1; unsigned char badParamCount = 0;
    switch(builtinCode) {
        case BTI_None:
            processDefaultArg(&(symbol->data->func.context), &paramCount);
            if (symbol->data->func.context.argumentCount == paramCount)
                inst.a = symbol->data->func.functionAddressIndex;
            else
                badParamCount = 1;
            undef = 0;
            break;
        case BTI_PutString:
            inst.a = paramCount;
            undef = 0;
            break;
        default:
            if (paramCount != getBuiltinParamCount(builtinCode))
                badParamCount = 1;
            undef = 0;
            break;
    }
    if (undef)
        setErrorExp(ERR_UndefFunction, 151, "instruction.c", __func__);
    else if (badParamCount)
        setErrorExp(ERR_BadParamCount, 153, "instruction.c", __func__);
    else {
        inst.code = builtinToInstruction(builtinCode);
        vectorPushInstruction(instructions, &inst);
    }
    return paramCount;
}

variable_types: struct Symbol { union SymbolData { struct Variable { int relativeIndex; } var; struct Function { unsigned int functionAddressIndex; struct Context { struct SymbolTable { unsigned int *table; struct Vector { unsigned int size; unsigned int capacity; unsigned long itemSize; unsigned char *data; unsigned char *end; } *vec; unsigned int size; unsigned int count; } *localTable; unsigned int defaultStart; unsigned int exprStart; unsigned short argumentCount; unsigned short localVariableCount; unsigned short defaultCount; } context; } func; } *data; enum SymbolType { ST_Function=0, ST_Variable=1 } type; struct String { unsigned int size; unsigned int length; char *data; } *key; } *

variable_types:
paramCount
unsigned int

variable_types:
undef
unsigned char

variable_types:
badParamCount
unsigned char

return_type: unsigned int

user_defined_types: enum BuiltinCode { BTI_None=0, BTI_BoolVal=1, BTI_DoubleVal=2, BTI_FindString=3, BTI_GetString=4, BTI_GetSubstring=5, BTI_IntVal=6, BTI_PutString=7, BTI_SortString=8, BTI_StrLen=9, BTI_StrVal=10 }

user_defined_types: struct Symbol { union SymbolData *data; enum SymbolType type; struct String *key; }

user_defined_types: union SymbolData { struct Variable var; struct Function func; }

user_defined_types: struct Function { unsigned int functionAddressIndex; struct Context context; }

user_defined_types: struct Context { struct SymbolTable *localTable; unsigned int defaultStart; unsigned int exprStart; unsigned short argumentCount; unsigned short localVariableCount; unsigned short defaultCount; }

user_defined_types: struct SymbolTable { unsigned int *table; struct Vector *vec; unsigned int size; unsigned int count; }


generateEmptyInstruction

decompiled_code:
__int64 generateEmptyInstruction()
{
__int64 v0; // rbp
unsigned int v1; // ebx

v0 = instructions;
v1 = vectorSize(instructions);
vectorPushDefaultInstruction(v0);
return v1;
}

canonical_decompiled_code:
__int64 func14()
{
__int64 v0; // rbp
unsigned int v1; // ebx

v0 = instructions;
v1 = func2(instructions);
func5(v0);
return v1;
}

original_code:
uint32_t generateEmptyInstruction()
{
    uint32_t ret = vectorSize(instructions);
    vectorPushDefaultInstruction(instructions);
    return ret;
}

canonical_original_code:
unsigned int generateEmptyInstruction()
{
    unsigned int ret = vectorSize(instructions);
    vectorPushDefaultInstruction(instructions);
    return ret;
}

variable_types:
ret
unsigned int


fillInstruction

decompiled_code:
void __fastcall fillInstruction(unsigned int a1, int a2, int a3, int a4, int a5)
{
_DWORD *v8; // rax

if ( a2 == 12 )
{
setErrorExp(15, 188, (__int64)"instruction.c", (__int64)"fillInstruction");
}
else
{
v8 = (_DWORD *)vectorAt(instructions, a1);
if ( (unsigned int)(*v8 - 25) <= 1 || !*v8 )
{
*v8 = a2;
v8[4] = a3;
v8[2] = a4;
v8[3] = a5;
}
}
}

canonical_decompiled_code:
void __fastcall func15(unsigned int a1, int a2, int a3, int a4, int a5)
{
_DWORD *v8; // rax

if ( a2 == 12 )
{
func1(15, 188, (__int64)"instruction.c", (__int64)"fillInstruction");
}
else
{
v8 = (_DWORD *)vectorAt(instructions, a1);
if ( (unsigned int)(*v8 - 25) <= 1 || !*v8 )
{
*v8 = a2;
v8[4] = a3;
v8[2] = a4;
v8[3] = a5;
}
}
}

original_code:
void fillInstruction(uint32_t index, InstructionCode code, int32_t res, int32_t a, int32_t b)
{
    if (code == IST_Call) {
        setErrorExp(ERR_ISTGenerator, 188, "instruction.c", __func__);
        return;
    }
    Instruction *pt = vectorAt(instructions, index);
    if (pt->code == IST_Noop || pt->code == IST_Break || pt->code == IST_Continue) {
        pt->code = code;
        pt->res = res;
        pt->a = a;
        pt->b = b;
    }
}

canonical_original_code:
void fillInstruction(unsigned int index, enum InstructionCode code, int res, int a, int b)
{
    if (code == IST_Call) {
        setErrorExp(ERR_ISTGenerator, 188, "instruction.c", __func__);
        return;
    }
    struct Instruction *pt = vectorAt(instructions, index);
    if (pt->code == IST_Noop || pt->code == IST_Break || pt->code == IST_Continue) {
        pt->code = code;
        pt->res = res;
        pt->a = a;
        pt->b = b;
    }
}

variable_types:
index
unsigned int

variable_types: enum InstructionCode { IST_Noop=0, IST_Mov=1, IST_MovC=2, IST_Jmp=3, IST_Jmpz=4, IST_Jmpnz=5, IST_Push=6, IST_PushC=7, IST_PushRef=8, IST_Reserve=9, IST_Pop=10, IST_ClearExpr=11, IST_Call=12, IST_Return=13, IST_Nullify=14, IST_BoolVal=15, IST_DoubleVal=16, IST_FindString=17, IST_GetString=18, IST_GetSubstring=19, IST_IntVal=20, IST_PutString=21, IST_SortString=22, IST_StrLen=23, IST_StrVal=24, IST_Break=25, IST_Continue=26, IST_Add=27, IST_Subtract=28, IST_Multiply=29, IST_Divide=30, IST_Concat=31, IST_Equal=32, IST_NotEqual=33, IST_Less=34, IST_LessEq=35, IST_Greater=36, IST_GreaterEq=37, IST_And=38, IST_Or=39, IST_Not=40 }


fillInstFuncInfo

decompiled_code:
__int64 __fastcall fillInstFuncInfo(__int64 a1, unsigned int *a2, _QWORD *a3)
{
unsigned int v4; // eax
__int64 v5; // rax
__int64 v6; // rbx

v4 = getBuiltinCode(a1 + 8);
*a2 = v4;
if ( v4 )
{
*a3 = getBuiltinParamCount(v4);
v6 = 0LL;
}
else
{
v5 = symbolTableFind(globalSymbolTable, a1 + 8);
v6 = v5;
if ( v5 )
*a3 = *(unsigned __int16 *)(*(_QWORD *)v5 + 24LL);
else
setErrorExp(8, 209, (__int64)"instruction.c", (__int64)"fillInstFuncInfo");
}
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func16(__int64 a1, unsigned int *a2, _QWORD *a3)
{
unsigned int v4; // eax
__int64 v5; // rax
__int64 v6; // rbx

v4 = getBuiltinCode(a1 + 8);
*a2 = v4;
if ( v4 )
{
*a3 = getBuiltinParamCount(v4);
v6 = 0LL;
}
else
{
v5 = symbolTableFind(globalSymbolTable, a1 + 8);
v6 = v5;
if ( v5 )
*a3 = *(unsigned __int16 *)(*(_QWORD *)v5 + 24LL);
else
func1(8, 209, (__int64)"instruction.c", (__int64)"fillInstFuncInfo");
}
return v6;
}

original_code:
Symbol* fillInstFuncInfo(const Token *funcToken, BuiltinCode *builtinCode, int64_t *paramCount)
{
    Symbol *symbol = ((void *)0);
    *builtinCode = getBuiltinCode(&(funcToken->str));
    if (*builtinCode == BTI_None) {
        symbol = symbolTableFind(globalSymbolTable, &funcToken->str);
        if (symbol == ((void *)0)) {
            setErrorExp(ERR_UndefFunction, 209, "instruction.c", __func__);
            return ((void *)0);
        }
        *paramCount = symbol->data->func.context.argumentCount;
    }
    else
        *paramCount = getBuiltinParamCount(*builtinCode);
    return symbol;
}

canonical_original_code:
struct Symbol *fillInstFuncInfo(struct Token *funcToken, enum BuiltinCode *builtinCode, long *paramCount)
{
    struct Symbol *symbol = ((void *)0);
    *builtinCode = getBuiltinCode(&(funcToken->str));
    if (*builtinCode == BTI_None) {
        symbol = symbolTableFind(globalSymbolTable, &funcToken->str);
        if (symbol == ((void *)0)) {
            setErrorExp(ERR_UndefFunction, 209, "instruction.c", __func__);
            return ((void *)0);
        }
        *paramCount = symbol->data->func.context.argumentCount;
    }
    else
        *paramCount = getBuiltinParamCount(*builtinCode);
    return symbol;
}

variable_types: struct Token { enum ScannerTokenType { STT_Plus=0, STT_Minus=1, STT_Multiply=2, STT_Divide=3, STT_Dot=4, STT_Less=5, STT_Greater=6, STT_LessEqual=7, STT_GreaterEqual=8, STT_Equal=9, STT_NotEqual=10, STT_And=11, STT_Or=12, STT_AndLow=13, STT_OrLow=14, STT_Not=15, STT_LeftBracket=16, STT_RightBracket=17, STT_Identifier=18, STT_Comma=19, STT_EOF=20, STT_Variable=21, STT_Number=22, STT_Double=23, STT_Bool=24, STT_Null=25, STT_String=26, STT_Semicolon=27, STT_LeftCurlyBracket=28, STT_RightCurlyBracket=29, STT_Empty=30, STT_Keyword=31, STT_Assignment=32, STT_Php=33 } type; union { double d; int n; enum KeywordTokenType { KTT_None=0, KTT_If=1, KTT_Else=2, KTT_Elseif=3, KTT_Continue=4, KTT_Break=5, KTT_While=6, KTT_For=7, KTT_Return=8, KTT_Function=9, KTT_And=10, KTT_Or=11, KTT_True=12, KTT_False=13, KTT_Null=14 } keywordType; struct String str; }; } *

variable_types: enum BuiltinCode { BTI_None=0, BTI_BoolVal=1, BTI_DoubleVal=2, BTI_FindString=3, BTI_GetString=4, BTI_GetSubstring=5, BTI_IntVal=6, BTI_PutString=7, BTI_SortString=8, BTI_StrLen=9, BTI_StrVal=10 } *

variable_types:
paramCount
long *

return_type: struct Symbol { union SymbolData { struct Variable { int relativeIndex; } var; struct Function { unsigned int functionAddressIndex; struct Context { struct SymbolTable { unsigned int *table; struct Vector { unsigned int size; unsigned int capacity; unsigned long itemSize; unsigned char *data; unsigned char *end; } *vec; unsigned int size; unsigned int count; } *localTable; unsigned int defaultStart; unsigned int exprStart; unsigned short argumentCount; unsigned short localVariableCount; unsigned short defaultCount; } context; } func; } *data; enum SymbolType { ST_Function=0, ST_Variable=1 } type; struct String { unsigned int size; unsigned int length; char *data; } *key; } *

user_defined_types: struct Token { enum ScannerTokenType type; union { double d; int n; enum KeywordTokenType keywordType; struct String str; }; }


getError

user_defined_types: enum NiErrorType { ERR_None=0, ERR_Unknown=1, ERR_LexFile=2, ERR_Allocation=3, ERR_Range=4, ERR_Internal=5, ERR_Convert=6, ERR_Syntax=7, ERR_UndefFunction=8, ERR_RedefFunction=9, ERR_UndefVariable=10, ERR_RedefParameter=11, ERR_BadParamCount=12, ERR_DefArgOrder=13, ERR_BadDefArg=14, ERR_ISTGenerator=15, ERR_CycleControl=16, ERR_Substr=17, ERR_OperandTypes=18, ERR_DivideByZero=19 }


getRcFromError

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

result = niErr;
switch ( niErr )
{
case 0:
return result;
case 2:
result = 1LL;
break;
case 3:
result = 99LL;
break;
case 6:
result = 11LL;
break;
case 7:
case 0xE:
case 0x10:
result = 2LL;
break;
case 8:
case 9:
result = 3LL;
break;
case 0xA:
result = 5LL;
break;
case 0xB:
case 0x11:
result = 13LL;
break;
case 0xC:
case 0xD:
result = 4LL;
break;
case 0x12:
result = 12LL;
break;
case 0x13:
result = 10LL;
break;
default:
result = 99LL;
break;
}
return result;
}

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

result = niErr;
switch ( niErr )
{
case 0:
return result;
case 2:
result = 1LL;
break;
case 3:
result = 99LL;
break;
case 6:
result = 11LL;
break;
case 7:
case 0xE:
case 0x10:
result = 2LL;
break;
case 8:
case 9:
result = 3LL;
break;
case 0xA:
result = 5LL;
break;
case 0xB:
case 0x11:
result = 13LL;
break;
case 0xC:
case 0xD:
result = 4LL;
break;
case 0x12:
result = 12LL;
break;
case 0x13:
result = 10LL;
break;
default:
result = 99LL;
break;
}
return result;
}

original_code:
static inline ResultCode getRcFromError()
{
    switch (niErr.type) {
        case ERR_None:
            return RC_Ok;
        case ERR_LexFile:
            return RC_LexError;
        case ERR_Syntax:
        case ERR_CycleControl:
        case ERR_BadDefArg:
            return RC_SynError;
        case ERR_Allocation:
            return RC_FatalError;
        case ERR_Convert:
            return RC_NumCastError;
        case ERR_UndefFunction:
        case ERR_RedefFunction:
            return RC_FuncDefError;
        case ERR_UndefVariable:
            return RC_VarError;
        case ERR_BadParamCount:
        case ERR_DefArgOrder:
            return RC_FuncParamError;
        case ERR_RedefParameter:
        case ERR_Substr:
            return RC_UnkError;
        case ERR_OperandTypes:
            return RC_ArithmError;
        case ERR_DivideByZero:
            return RC_DivByZero;
        default:
            return RC_FatalError;
    }
}

canonical_original_code:
static inline enum ResultCode getRcFromError()
{
    switch (niErr.type) {
        case ERR_None:
            return RC_Ok;
        case ERR_LexFile:
            return RC_LexError;
        case ERR_Syntax:
        case ERR_CycleControl:
        case ERR_BadDefArg:
            return RC_SynError;
        case ERR_Allocation:
            return RC_FatalError;
        case ERR_Convert:
            return RC_NumCastError;
        case ERR_UndefFunction:
        case ERR_RedefFunction:
            return RC_FuncDefError;
        case ERR_UndefVariable:
            return RC_VarError;
        case ERR_BadParamCount:
        case ERR_DefArgOrder:
            return RC_FuncParamError;
        case ERR_RedefParameter:
        case ERR_Substr:
            return RC_UnkError;
        case ERR_OperandTypes:
            return RC_ArithmError;
        case ERR_DivideByZero:
            return RC_DivByZero;
        default:
            return RC_FatalError;
    }
}

return_type: enum ResultCode { RC_Ok=0, RC_LexError=1, RC_SynError=2, RC_FuncDefError=3, RC_FuncParamError=4, RC_VarError=5, RC_DivByZero=10, RC_NumCastError=11, RC_ArithmError=12, RC_UnkError=13, RC_FatalError=99 }


processParams

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

if ( a1 == 2 )
{
*a3 = scannerScanFile(*(_QWORD *)(a2 + 8));
result = 0LL;
}
else
{
*a3 = 0LL;
result = 1LL;
}
return result;
}

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

if ( a1 == 2 )
{
*a3 = scannerScanFile(*(_QWORD *)(a2 + 8));
result = 0LL;
}
else
{
*a3 = 0LL;
result = 1LL;
}
return result;
}

original_code:
uint8_t processParams(int32_t argc, char **argv, Vector** tokenVector)
{
    if (argc != 2) {
        *tokenVector = ((void *)0);
        return 1;
    }
    *tokenVector = scannerScanFile(argv[1]);
    return 0;
}

canonical_original_code:
unsigned char processParams(int argc, char **argv, struct Vector **tokenVector)
{
    if (argc != 2) {
        *tokenVector = ((void *)0);
        return 1;
    }
    *tokenVector = scannerScanFile(argv[1]);
    return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: struct Vector { unsigned int size; unsigned int capacity; unsigned long itemSize; unsigned char *data; unsigned char *end; } **

return_type: unsigned char


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char v3; // dl
int result; // eax
__int64 v5[4]; // [rsp+8h] [rbp-20h] BYREF

setErrorExp(0, 40, (__int64)"main.c", (__int64)"main");
v5[0] = 0LL;
v3 = processParams(argc, (__int64)argv, v5);
result = 99;
if ( !v3 )
{
if ( (unsigned int)getError() )
{
result = getRcFromError();
}
else
{
parse(v5[0], 0LL);
result = getRcFromError();
}
}
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
char v3; // dl
int result; // eax
__int64 v5[4]; // [rsp+8h] [rbp-20h] BYREF

func1(0, 40, (__int64)"main.c", (__int64)"main");
v5[0] = 0LL;
v3 = func3(argc, (__int64)argv, v5);
result = 99;
if ( !v3 )
{
if ( (unsigned int)func0() )
{
result = func2();
}
else
{
parse(v5[0], 0LL);
result = func2();
}
}
return result;
}

original_code:
int main(int argc, char **argv)
{
    setErrorExp(ERR_None, 40, "main.c", __func__);
    Vector* tokenVector = ((void *)0);
    if (processParams(argc, argv, &tokenVector))
        return RC_FatalError;
    if(getError())
        return getRcFromError();
    parse(tokenVector, 0);
    return getRcFromError();
}

canonical_original_code:
int main(int argc, char **argv)
{
    setErrorExp(ERR_None, 40, "main.c", __func__);
    struct Vector *tokenVector = ((void *)0);
    if (processParams(argc, argv, &tokenVector))
        return RC_FatalError;
    if(getError())
        return getRcFromError();
    parse(tokenVector, 0);
    return getRcFromError();
}

variable_types: struct Vector { unsigned int size; unsigned int capacity; unsigned long itemSize; unsigned char *data; unsigned char *end; } *


deleteString

original_code:
static inline void deleteString(String *ps)
{
    if (ps != ((void *)0)) {
        free(ps->data);
        ps->data = ((void *)0);
        ps->size = 0;
        ps->length = 0;
    }
}

canonical_original_code:
static inline void deleteString(struct String *ps)
{
    if (ps != ((void *)0)) {
        free(ps->data);
        ps->data = ((void *)0);
        ps->size = 0;
        ps->length = 0;
    }
}

variable_types: struct String { unsigned int size; unsigned int length; char *data; } *


newToken

decompiled_code:
_QWORD *newToken()
{
_QWORD *result; // rax

result = malloc(0x18uLL);
*result = 0LL;
result[1] = 0LL;
result[2] = 0LL;
*(_DWORD *)result = 30;
return result;
}

canonical_decompiled_code:
_QWORD *func1()
{
_QWORD *result; // rax

result = malloc(0x18uLL);
*result = 0LL;
result[1] = 0LL;
result[2] = 0LL;
*(_DWORD *)result = 30;
return result;
}

original_code:
Token* newToken()
{
    Token* tmp = malloc(sizeof(Token));
    memset(tmp, 0, sizeof(Token));
    tmp->type = STT_Empty;
    return tmp;
}

canonical_original_code:
struct Token *newToken()
{
    struct Token *tmp = malloc(sizeof(Token));
    memset(tmp, 0, sizeof(Token));
    tmp->type = STT_Empty;
    return tmp;
}

variable_types: struct Token { enum ScannerTokenType { STT_Plus=0, STT_Minus=1, STT_Multiply=2, STT_Divide=3, STT_Dot=4, STT_Less=5, STT_Greater=6, STT_LessEqual=7, STT_GreaterEqual=8, STT_Equal=9, STT_NotEqual=10, STT_And=11, STT_Or=12, STT_AndLow=13, STT_OrLow=14, STT_Not=15, STT_LeftBracket=16, STT_RightBracket=17, STT_Identifier=18, STT_Comma=19, STT_EOF=20, STT_Variable=21, STT_Number=22, STT_Double=23, STT_Bool=24, STT_Null=25, STT_String=26, STT_Semicolon=27, STT_LeftCurlyBracket=28, STT_RightCurlyBracket=29, STT_Empty=30, STT_Keyword=31, STT_Assignment=32, STT_Php=33 } type; union { double d; int n; enum KeywordTokenType { KTT_None=0, KTT_If=1, KTT_Else=2, KTT_Elseif=3, KTT_Continue=4, KTT_Break=5, KTT_While=6, KTT_For=7, KTT_Return=8, KTT_Function=9, KTT_And=10, KTT_Or=11, KTT_True=12, KTT_False=13, KTT_Null=14 } keywordType; struct String { unsigned int size; unsigned int length; char *data; } str; }; } *