decompiled_code:
void __fastcall aubio_filter_do_filtfilt(__int64 a1, __int64 a2, __int64 a3)
{
int v4; // ebx
unsigned int v5; // ebx
unsigned int v6; // eax
__int64 v7; // rdx
__int64 v8; // rax

v4 = *(_DWORD *)a2;
aubio_filter_do(a1, a2);
if ( v4 )
{
v5 = v4 - 1;
v6 = v5;
v7 = 0LL;
do
{
*(_DWORD *)(**(_QWORD **)(a3 + 8) + 4LL * v6) = *(_DWORD *)(**(_QWORD **)(a2 + 8) + v7);
v7 += 4LL;
--v6;
}
while ( v6 != -1 );
aubio_filter_do(a1, a3);
v8 = 0LL;
do
{
*(_DWORD *)(**(_QWORD **)(a2 + 8) + v8) = *(_DWORD *)(**(_QWORD **)(a3 + 8) + 4LL * v5--);
v8 += 4LL;
}
while ( v5 != -1 );
}
else
{
aubio_filter_do(a1, a3);
}
}

original_code:
void aubio_filter_do_filtfilt(aubio_filter_t * f, fvec_t * in, fvec_t * tmp) {
  uint_t j,i=0;
  uint_t length = in->length;
  aubio_filter_do(f,in);
  for (j = 0; j < length; j++)
    tmp->data[i][length-j-1] = in->data[i][j];
  aubio_filter_do(f,tmp);
  for (j = 0; j < length; j++)
    in->data[i][j] = tmp->data[i][length-j-1];
}

canonical_original_code:
void aubio_filter_do_filtfilt(struct _aubio_filter_t *f, struct _fvec_t *in, struct _fvec_t *tmp) {
  unsigned int j; unsigned int i = 0;
  unsigned int length = in->length;
  aubio_filter_do(f,in);
  for (j = 0; j < length; j++)
    tmp->data[i][length-j-1] = in->data[i][j];
  aubio_filter_do(f,tmp);
  for (j = 0; j < length; j++)
    in->data[i][j] = tmp->data[i][length-j-1];
}

variable_types:
tmp
struct _fvec_t *

variable_types:
j
unsigned int

variable_types:
length
unsigned int


decompiled_code:
void __fastcall del_aubio_filter(void *ptr)
{
free(*((void **)ptr + 1));
free(*((void **)ptr + 2));
free(*((void **)ptr + 4));
free(*((void **)ptr + 3));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func3(void *ptr)
{
free(*((void **)ptr + 1));
free(*((void **)ptr + 2));
free(*((void **)ptr + 4));
free(*((void **)ptr + 3));
free(ptr);
}

original_code:
void del_aubio_filter(aubio_filter_t * f) {
  free(f->a);
  free(f->b);
  free(f->x);
  free(f->y);
  free(f);
  return;
}

canonical_original_code:
void del_aubio_filter(struct _aubio_filter_t *f) {
  free(f->a);
  free(f->b);
  free(f->x);
  free(f->y);
  free(f);
  return;
}

variable_types: struct _aubio_filter_t { unsigned int order; double *a; double *b; double *y; double *x; } *

return_type: void


decompiled_code:
__int64 __fastcall common_init(int a1, __int64 a2)
{
__int64 v2; // rax
__int64 result; // rax

if ( a1 == 1 )
{
puts("filename pitch_algo(0:mcomb 1:yinfft 2:yin 3:schmitt 4:fcomb)");
exit(1);
}
input_filename = *(_QWORD *)(a2 + 8);
if ( a1 > 2 )
{
switch ( atoi(*(const char **)(a2 + 16)) )
{
case 0:
type_pitch = 1;
break;
case 1:
type_pitch = 4;
break;
case 2:
type_pitch = 0;
break;
case 3:
type_pitch = 2;
break;
case 4:
type_pitch = 3;
break;
default:
break;
}
}
if ( verbose )
fwrite("Opening files ...\n", 1uLL, 0x12uLL, stderr);
v2 = new_aubio_sndfile_ro(input_filename);
file = v2;
if ( !v2 )
{
fprintf(stdout, "Could not open input file %s.\n", (const char *)input_filename);
exit(1);
}
if ( verbose )
aubio_sndfile_info(v2);
channels = aubio_sndfile_channels(file);
samplerate = aubio_sndfile_samplerate(file);
ibuf = new_fvec((unsigned int)overlap_size, (unsigned int)channels);
obuf = new_fvec((unsigned int)overlap_size, (unsigned int)channels);
fftgrain = new_cvec((unsigned int)buffer_size, (unsigned int)channels);
pitchdet = new_aubio_pitchdetection(
(unsigned int)(4 * buffer_size),
(unsigned int)overlap_size,
(unsigned int)channels,
(unsigned int)samplerate,
(unsigned int)type_pitch,
(unsigned int)mode_pitch);
aubio_pitchdetection_set_yinthresh(pitchdet, 0.69999999);
note_buffer = new_fvec((unsigned int)median, 1LL);
note_buffer2 = new_fvec((unsigned int)median, 1LL);
pv = new_aubio_pvoc((unsigned int)buffer_size, (unsigned int)overlap_size, (unsigned int)channels);
parms = new_aubio_peakpicker(*(float *)&threshold);
o = new_aubio_onsetdetection((unsigned int)type_onset, (unsigned int)buffer_size, (unsigned int)channels);
result = new_fvec(1LL, (unsigned int)channels);
onset = result;
if ( usedoubled )
{
o2 = new_aubio_onsetdetection((unsigned int)type_onset2, (unsigned int)buffer_size, (unsigned int)channels);
result = new_fvec(1LL, (unsigned int)channels);
onset2 = result;
}
return result;
}

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

if ( a1 == 1 )
{
puts("filename pitch_algo(0:mcomb 1:yinfft 2:yin 3:schmitt 4:fcomb)");
exit(1);
}
input_filename = *(_QWORD *)(a2 + 8);
if ( a1 > 2 )
{
switch ( atoi(*(const char **)(a2 + 16)) )
{
case 0:
type_pitch = 1;
break;
case 1:
type_pitch = 4;
break;
case 2:
type_pitch = 0;
break;
case 3:
type_pitch = 2;
break;
case 4:
type_pitch = 3;
break;
default:
break;
}
}
if ( verbose )
fwrite("Opening files ...\n", 1uLL, 0x12uLL, stderr);
v2 = new_aubio_sndfile_ro(input_filename);
file = v2;
if ( !v2 )
{
fprintf(stdout, "Could not open input file %s.\n", (const char *)input_filename);
exit(1);
}
if ( verbose )
aubio_sndfile_info(v2);
channels = aubio_sndfile_channels(file);
samplerate = aubio_sndfile_samplerate(file);
ibuf = new_fvec((unsigned int)overlap_size, (unsigned int)channels);
obuf = new_fvec((unsigned int)overlap_size, (unsigned int)channels);
fftgrain = new_cvec((unsigned int)buffer_size, (unsigned int)channels);
pitchdet = new_aubio_pitchdetection(
(unsigned int)(4 * buffer_size),
(unsigned int)overlap_size,
(unsigned int)channels,
(unsigned int)samplerate,
(unsigned int)type_pitch,
(unsigned int)mode_pitch);
aubio_pitchdetection_set_yinthresh(pitchdet, 0.69999999);
note_buffer = new_fvec((unsigned int)median, 1LL);
note_buffer2 = new_fvec((unsigned int)median, 1LL);
pv = new_aubio_pvoc((unsigned int)buffer_size, (unsigned int)overlap_size, (unsigned int)channels);
parms = new_aubio_peakpicker(*(float *)&threshold);
o = new_aubio_onsetdetection((unsigned int)type_onset, (unsigned int)buffer_size, (unsigned int)channels);
result = new_fvec(1LL, (unsigned int)channels);
onset = result;
if ( usedoubled )
{
o2 = new_aubio_onsetdetection((unsigned int)type_onset2, (unsigned int)buffer_size, (unsigned int)channels);
result = new_fvec(1LL, (unsigned int)channels);
onset2 = result;
}
return result;
}

original_code:
void common_init(int argc, char ** argv) {
  if (argc == 1) {
    printf("filename pitch_algo(0:mcomb 1:yinfft 2:yin 3:schmitt 4:fcomb)\n");
    exit(1);
  }
  input_filename = argv[1];
  if (argc >= 3) {
    int pitch_algo = atoi(argv[2]);
    switch (pitch_algo) {
      case 0:
        type_pitch = aubio_pitch_mcomb;
        break;
      case 1:
        type_pitch = aubio_pitch_yinfft;
        break;
      case 2:
        type_pitch = aubio_pitch_yin;
        break;
      case 3:
        type_pitch = aubio_pitch_schmitt;
        break;
      case 4:
        type_pitch = aubio_pitch_fcomb;
        break;
    }
  }
  if (verbose) fprintf (stderr, "Opening files ...\n");
  file = new_aubio_sndfile_ro (input_filename);
  if (file == ((void *)0)) {
    fprintf (stdout, "Could not open input file %s.\n", input_filename);
    exit(1);
  }
  if (verbose) aubio_sndfile_info(file);
  channels = aubio_sndfile_channels(file);
  samplerate = aubio_sndfile_samplerate(file);
  ibuf = new_fvec(overlap_size, channels);
  obuf = new_fvec(overlap_size, channels);
  fftgrain = new_cvec(buffer_size, channels);
  pitchdet = new_aubio_pitchdetection(buffer_size * 4,
      overlap_size, channels, samplerate, type_pitch, mode_pitch);
  aubio_pitchdetection_set_yinthresh(pitchdet, 0.7);
  note_buffer = new_fvec(median, 1);
  note_buffer2= new_fvec(median, 1);
  pv = new_aubio_pvoc(buffer_size, overlap_size, channels);
  parms = new_aubio_peakpicker(threshold);
  o = new_aubio_onsetdetection(type_onset,buffer_size,channels);
  onset = new_fvec(1, channels);
  if (usedoubled) {
    o2 = new_aubio_onsetdetection(type_onset2,buffer_size,channels);
    onset2 = new_fvec(1 , channels);
  }
}

canonical_original_code:
void common_init(int argc, char **argv) {
  if (argc == 1) {
    printf("filename pitch_algo(0:mcomb 1:yinfft 2:yin 3:schmitt 4:fcomb)\n");
    exit(1);
  }
  input_filename = argv[1];
  if (argc >= 3) {
    int pitch_algo = atoi(argv[2]);
    switch (pitch_algo) {
      case 0:
        type_pitch = aubio_pitch_mcomb;
        break;
      case 1:
        type_pitch = aubio_pitch_yinfft;
        break;
      case 2:
        type_pitch = aubio_pitch_yin;
        break;
      case 3:
        type_pitch = aubio_pitch_schmitt;
        break;
      case 4:
        type_pitch = aubio_pitch_fcomb;
        break;
    }
  }
  if (verbose) fprintf (stderr, "Opening files ...\n");
  file = new_aubio_sndfile_ro (input_filename);
  if (file == ((void *)0)) {
    fprintf (stdout, "Could not open input file %s.\n", input_filename);
    exit(1);
  }
  if (verbose) aubio_sndfile_info(file);
  channels = aubio_sndfile_channels(file);
  samplerate = aubio_sndfile_samplerate(file);
  ibuf = new_fvec(overlap_size, channels);
  obuf = new_fvec(overlap_size, channels);
  fftgrain = new_cvec(buffer_size, channels);
  pitchdet = new_aubio_pitchdetection(buffer_size * 4,
      overlap_size, channels, samplerate, type_pitch, mode_pitch);
  aubio_pitchdetection_set_yinthresh(pitchdet, 0.7);
  note_buffer = new_fvec(median, 1);
  note_buffer2= new_fvec(median, 1);
  pv = new_aubio_pvoc(buffer_size, overlap_size, channels);
  parms = new_aubio_peakpicker(threshold);
  o = new_aubio_onsetdetection(type_onset,buffer_size,channels);
  onset = new_fvec(1, channels);
  if (usedoubled) {
    o2 = new_aubio_onsetdetection(type_onset2,buffer_size,channels);
    onset2 = new_fvec(1 , channels);
  }
}

variable_types: argc int

variable_types:
argv
char **


decompiled_code:
__int64 common_del()
{
del_aubio_pitchdetection(pitchdet);
if ( median )
{
del_fvec(note_buffer);
del_fvec(note_buffer2);
}
if ( usedoubled )
{
del_aubio_onsetdetection(o2);
del_fvec(onset2);
}
del_aubio_onsetdetection(o);
del_aubio_peakpicker(parms);
del_aubio_pvoc(pv);
del_fvec(obuf);
del_fvec(ibuf);
del_cvec(fftgrain);
del_fvec(onset);
return aubio_cleanup();
}

canonical_decompiled_code:
__int64 func1()
{
del_aubio_pitchdetection(pitchdet);
if ( median )
{
del_fvec(note_buffer);
del_fvec(note_buffer2);
}
if ( usedoubled )
{
del_aubio_onsetdetection(o2);
del_fvec(onset2);
}
del_aubio_onsetdetection(o);
del_aubio_peakpicker(parms);
del_aubio_pvoc(pv);
del_fvec(obuf);
del_fvec(ibuf);
del_cvec(fftgrain);
del_fvec(onset);
return aubio_cleanup();
}

original_code:
void common_del(void){
  del_aubio_pitchdetection(pitchdet);
  if (median) {
    del_fvec(note_buffer);
    del_fvec(note_buffer2);
  }
  if (usedoubled) {
    del_aubio_onsetdetection(o2);
    del_fvec(onset2);
  }
  del_aubio_onsetdetection(o);
  del_aubio_peakpicker(parms);
  del_aubio_pvoc(pv);
  del_fvec(obuf);
  del_fvec(ibuf);
  del_cvec(fftgrain);
  del_fvec(onset);
  aubio_cleanup();
}

canonical_original_code:
void common_del(){
  del_aubio_pitchdetection(pitchdet);
  if (median) {
    del_fvec(note_buffer);
    del_fvec(note_buffer2);
  }
  if (usedoubled) {
    del_aubio_onsetdetection(o2);
    del_fvec(onset2);
  }
  del_aubio_onsetdetection(o);
  del_aubio_peakpicker(parms);
  del_aubio_pvoc(pv);
  del_fvec(obuf);
  del_fvec(ibuf);
  del_cvec(fftgrain);
  del_fvec(onset);
  aubio_cleanup();
}


decompiled_code:
__int64 __fastcall common_process(void (__fastcall *a1)(_QWORD, _QWORD))
{
if ( verbose )
fwrite("Processing ...\n", 1uLL, 0xFuLL, stderr);
frames = 0;
while ( (unsigned int)aubio_sndfile_read(file, (unsigned int)overlap_size, ibuf) == overlap_size )
{
isonset = 0;
a1(*(_QWORD *)(ibuf + 8), *(_QWORD *)(obuf + 8));
++frames;
}
if ( verbose )
fprintf(stderr, "Processed %d frames of %d samples.\n", (unsigned int)frames, (unsigned int)buffer_size);
return del_aubio_sndfile(file);
}

canonical_decompiled_code:
__int64 __fastcall func2(void (__fastcall *a1)(_QWORD, _QWORD))
{
if ( verbose )
fwrite("Processing ...\n", 1uLL, 0xFuLL, stderr);
frames = 0;
while ( (unsigned int)aubio_sndfile_read(file, (unsigned int)overlap_size, ibuf) == overlap_size )
{
isonset = 0;
a1(*(_QWORD *)(ibuf + 8), *(_QWORD *)(obuf + 8));
++frames;
}
if ( verbose )
fprintf(stderr, "Processed %d frames of %d samples.\n", (unsigned int)frames, (unsigned int)buffer_size);
return del_aubio_sndfile(file);
}

original_code:
void common_process(aubio_process_func_t process_func){
  if (verbose) fprintf (stderr, "Processing ...\n");
  frames = 0;
  while ((signed)overlap_size == aubio_sndfile_read(file, overlap_size, ibuf)) {
    isonset = 0;
    process_func(ibuf->data, obuf->data, overlap_size);
    frames++;
  }
  if (verbose) fprintf (stderr, "Processed %d frames of %d samples.\n", frames, buffer_size);
  del_aubio_sndfile(file);
}

canonical_original_code:
void common_process(int (*process_func)(float **input, float **output, int nframes)){
  if (verbose) fprintf (stderr, "Processing ...\n");
  frames = 0;
  while ((int)overlap_size == aubio_sndfile_read(file, overlap_size, ibuf)) {
    isonset = 0;
    process_func(ibuf->data, obuf->data, overlap_size);
    frames++;
  }
  if (verbose) fprintf (stderr, "Processed %d frames of %d samples.\n", frames, buffer_size);
  del_aubio_sndfile(file);
}

variable_types: int (*)(float **input, float **output, int nframes)


syntax

decompiled_code:
__int64 syntax()
{
return prs_error("Syntax error");
}

canonical_decompiled_code:
__int64 func1()
{
return func0("Syntax error");
}

original_code:
static void syntax()
{
    prs_error ("Syntax error");
}


checkeol

decompiled_code:
void checkeol()
{
if ( !eol_seen && (unsigned int)yylex() != 272 )
{
prs_error("Garbage deleted");
while ( !eol_seen )
yylex();
}
}

canonical_decompiled_code:
void func2()
{
if ( !eol_seen && (unsigned int)yylex() != 272 )
{
func0("Garbage deleted");
while ( !eol_seen )
yylex();
}
}

original_code:
static void checkeol()
{
    if (eol_seen) return;
    if (yylex() != 272) {
     prs_error ("Garbage deleted");
 while (!eol_seen) yylex();
    }
}


checknote

decompiled_code:
__int64 __fastcall checknote()
{
int v0; // ebx
__int64 result; // rax
__int64 v2; // rbp
char v3; // r12
int v4; // ebx
__int64 v5; // rdx
char v6; // al
const char *v7; // rdi

if ( (unsigned int)yylex() != 263 || (v0 = yylex(), (v0 & 0xFFFFFFFB) != 267) )
syntax();
if ( v0 == 271 )
{
v2 = yytext;
v3 = *yytext;
v4 = (char)*yytext;
if ( ((*_ctype_b_loc())[v3] & 0x100) != 0 )
v4 = tolower(v4);
v5 = notes_0[v4 - 97];
yyval = v5;
v6 = *(_BYTE *)(v2 + 1);
if ( v6 != 43 )
{
if ( v6 > 43 )
{
if ( (v6 & 0xDF) == 66 || v6 == 45 )
{
yyval = v5 - 1;
v7 = (const char *)(v2 + 2);
goto LABEL_16;
}
goto LABEL_15;
}
if ( v6 != 35 )
{
LABEL_15:
v7 = (const char *)(v2 + 1);
LABEL_16:
yyval += 12 * atoi(v7);
goto LABEL_4;
}
}
yyval = v5 + 1;
v7 = (const char *)(v2 + 2);
goto LABEL_16;
}
LABEL_4:
if ( yyval > 0x7FuLL )
error("Note must be between 0 and 127");
result = yyval;
data = yyval;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5()
{
int v0; // ebx
__int64 result; // rax
__int64 v2; // rbp
char v3; // r12
int v4; // ebx
__int64 v5; // rdx
char v6; // al
const char *v7; // rdi

if ( (unsigned int)yylex() != 263 || (v0 = yylex(), (v0 & 0xFFFFFFFB) != 267) )
func1();
if ( v0 == 271 )
{
v2 = yytext;
v3 = *yytext;
v4 = (char)*yytext;
if ( ((*_ctype_b_loc())[v3] & 0x100) != 0 )
v4 = tolower(v4);
v5 = notes_0[v4 - 97];
yyval = v5;
v6 = *(_BYTE *)(v2 + 1);
if ( v6 != 43 )
{
if ( v6 > 43 )
{
if ( (v6 & 0xDF) == 66 || v6 == 45 )
{
yyval = v5 - 1;
v7 = (const char *)(v2 + 2);
goto LABEL_16;
}
goto LABEL_15;
}
if ( v6 != 35 )
{
LABEL_15:
v7 = (const char *)(v2 + 1);
LABEL_16:
yyval += 12 * atoi(v7);
goto LABEL_4;
}
}
yyval = v5 + 1;
v7 = (const char *)(v2 + 2);
goto LABEL_16;
}
LABEL_4:
if ( yyval > 0x7FuLL )
func4("Note must be between 0 and 127");
result = yyval;
data = yyval;
return result;
}

original_code:
void checknote()
{
    int c;
    if (yylex() != 263 || ((c=yylex()) != 267 && c != 271))
  syntax();
    if (c == 271) {
        static int notes[] = {
     9,
     11,
     0,
     2,
     4,
     5,
     7
        };
 char *p = yytext;
        c = *p++;
        if (((*__ctype_b_loc ())[(int) ((c))] & (unsigned short int) _ISupper)) c = tolower(c);
        yyval = notes[c-'a'];
        switch (*p) {
        case '#':
        case '+':
            yyval++;
     p++;
     break;
 case 'b':
 case 'B':
 case '-':
     yyval--;
     p++;
     break;
 }
 yyval += 12 * atoi(p);
    }
    if (yyval < 0 || yyval > 127)
  error("Note must be between 0 and 127");
    data[0] = yyval;
}

canonical_original_code:
void checknote()
{
    int c;
    if (yylex() != 263 || ((c=yylex()) != 267 && c != 271))
  syntax();
    if (c == 271) {
        static int notes[] = {
     9,
     11,
     0,
     2,
     4,
     5,
     7
        };
 char *p = yytext;
        c = *p++;
        if (((*__ctype_b_loc ())[(int) ((c))] & (unsigned short) _ISupper)) c = tolower(c);
        yyval = notes[c-'a'];
        switch (*p) {
        case '#':
        case '+':
            yyval++;
     p++;
     break;
 case 'b':
 case 'B':
 case '-':
     yyval--;
     p++;
     break;
 }
 yyval += 12 * atoi(p);
    }
    if (yyval < 0 || yyval > 127)
  error("Note must be between 0 and 127");
    data[0] = yyval;
}

variable_types: c int

variable_types:
notes
int []

variable_types:
p
char *


checkcon

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

if ( (unsigned int)yylex() != 265 || (unsigned int)yylex() != 267 )
syntax();
if ( yyval > 0x7FuLL )
error("Controller must be between 0 and 127");
result = yyval;
data = yyval;
return result;
}

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

if ( (unsigned int)yylex() != 265 || (unsigned int)yylex() != 267 )
func1();
if ( yyval > 0x7FuLL )
func4("Controller must be between 0 and 127");
result = yyval;
data = yyval;
return result;
}

original_code:
static void checkcon(void)
{
    if (yylex() != 265 || yylex() != 267)
  syntax();
    if (yyval < 0 || yyval > 127)
  error ("Controller must be between 0 and 127");
    data[0] = yyval;
}

canonical_original_code:
static void checkcon()
{
    if (yylex() != 265 || yylex() != 267)
  syntax();
    if (yyval < 0 || yyval > 127)
  error ("Controller must be between 0 and 127");
    data[0] = yyval;
}


splitval

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

if ( (unsigned int)yylex() != 264 || (unsigned int)yylex() != 267 )
syntax();
if ( yyval > 0x3FFFuLL )
error("Value must be between 0 and 16383");
data = yyval % 128LL;
result = yyval / 128LL;
*(&data + 1) = yyval / 128LL;
return result;
}

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

if ( (unsigned int)yylex() != 264 || (unsigned int)yylex() != 267 )
func1();
if ( yyval > 0x3FFFuLL )
func4("Value must be between 0 and 16383");
data = yyval % 128LL;
result = yyval / 128LL;
*(&data + 1) = yyval / 128LL;
return result;
}

original_code:
void splitval(void)
{
    if (yylex() != 264 || yylex() != 267) syntax();
    if (yyval < 0 || yyval > 16383)
  error ("Value must be between 0 and 16383");
    data[0] = yyval%128;
    data[1] = yyval/128;
}

canonical_original_code:
void splitval()
{
    if (yylex() != 264 || yylex() != 267) syntax();
    if (yyval < 0 || yyval > 16383)
  error ("Value must be between 0 and 16383");
    data[0] = yyval%128;
    data[1] = yyval/128;
}


checkprog

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

if ( (unsigned int)yylex() != 266 || (unsigned int)yylex() != 267 )
syntax();
if ( yyval > 0x7FuLL )
error("Program number must be between 0 and 127");
result = yyval;
data = yyval;
return result;
}

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

if ( (unsigned int)yylex() != 266 || (unsigned int)yylex() != 267 )
func1();
if ( yyval > 0x7FuLL )
func4("Program number must be between 0 and 127");
result = yyval;
data = yyval;
return result;
}

original_code:
static void checkprog()
{
    if (yylex() != 266 || yylex() != 267) syntax();
    if (yyval < 0 || yyval > 127)
  error ("Program number must be between 0 and 127");
    data[0] = yyval;
}


checkchan

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

if ( (unsigned int)yylex() != 262 || (unsigned int)yylex() != 267 )
syntax();
if ( (unsigned __int64)(yyval - 1LL) > 0xF )
error("Chan must be between 1 and 16");
result = (unsigned int)(yyval - 1);
chan = yyval - 1;
return result;
}

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

if ( (unsigned int)yylex() != 262 || (unsigned int)yylex() != 267 )
func1();
if ( (unsigned __int64)(yyval - 1LL) > 0xF )
func4("Chan must be between 1 and 16");
result = (unsigned int)(yyval - 1);
chan = yyval - 1;
return result;
}

original_code:
static void checkchan(void)
{
    if (yylex() != 262 || yylex() != 267) syntax();
    if (yyval < 1 || yyval > 16)
  error("Chan must be between 1 and 16");
    chan = yyval-1;
}

canonical_original_code:
static void checkchan()
{
    if (yylex() != 262 || yylex() != 267) syntax();
    if (yyval < 1 || yyval > 16)
  error("Chan must be between 1 and 16");
    chan = yyval-1;
}


checkval

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

if ( (unsigned int)yylex() != 264 || (unsigned int)yylex() != 267 )
syntax();
if ( yyval > 0x7FuLL )
error("Value must be between 0 and 127");
result = yyval;
*(&data + 1) = yyval;
return result;
}

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

if ( (unsigned int)yylex() != 264 || (unsigned int)yylex() != 267 )
func1();
if ( yyval > 0x7FuLL )
func4("Value must be between 0 and 127");
result = yyval;
*(&data + 1) = yyval;
return result;
}

original_code:
void checkval()
{
    if (yylex() != 264 || yylex() != 267) syntax();
    if (yyval < 0 || yyval > 127)
 error ("Value must be between 0 and 127");
    data[1] = yyval;
}


translate

decompiled_code:
__int64 translate()
{
int v0; // ebx

if ( (unsigned int)yylex() != 256 )
{
fwrite("Missing MFile - can't continue\n", 1uLL, 0x1FuLL, stderr);
exit(1);
}
Format = getint("MFile format");
Ntrks = getint("MFile #tracks");
v0 = getint("MFile Clicks");
Clicks = v0;
if ( v0 < 0 )
Clicks = getint("MFile SMPTE division") | (unsigned __int16)((_WORD)v0 << 8);
checkeol();
return mfwrite((unsigned int)Format, (unsigned int)Ntrks, (unsigned int)Clicks, F);
}

canonical_decompiled_code:
__int64 func12()
{
int v0; // ebx

if ( (unsigned int)yylex() != 256 )
{
fwrite("Missing MFile - can't continue\n", 1uLL, 0x1FuLL, stderr);
exit(1);
}
Format = func11("MFile format");
Ntrks = func11("MFile #tracks");
v0 = func11("MFile Clicks");
Clicks = v0;
if ( v0 < 0 )
Clicks = func11("MFile SMPTE division") | (unsigned __int16)((_WORD)v0 << 8);
func2();
return mfwrite((unsigned int)Format, (unsigned int)Ntrks, (unsigned int)Clicks, F);
}

original_code:
static void translate(void)
{
    if (yylex()==256) {
        Format = getint("MFile format");
        Ntrks = getint("MFile #tracks");
        Clicks = getint("MFile Clicks");
 if (Clicks < 0)
  Clicks = (Clicks&0xff)<<8|getint("MFile SMPTE division");
  checkeol();
        mfwrite(Format, Ntrks, Clicks, F);
    } else {
        fprintf (stderr, "Missing MFile - can't continue\n");
 exit(1);
    }
}

canonical_original_code:
static void translate()
{
    if (yylex()==256) {
        Format = getint("MFile format");
        Ntrks = getint("MFile #tracks");
        Clicks = getint("MFile Clicks");
 if (Clicks < 0)
  Clicks = (Clicks&0xff)<<8|getint("MFile SMPTE division");
  checkeol();
        mfwrite(Format, Ntrks, Clicks, F);
    } else {
        fprintf (stderr, "Missing MFile - can't continue\n");
 exit(1);
    }
}


toMIDI

decompiled_code:
int __fastcall toMIDI(const char *a1, const char *a2)
{
yyin = efopen(a1, "r");
F = efopen(a2, "wb");
Mf_putc = fileputc;
Mf_wtrack = mywritetrack;
Measure = 4;
Beat = 96;
Clicks = 96;
M0 = 0;
T0 = 0LL;
translate();
fclose(F);
return fclose(yyin);
}

canonical_decompiled_code:
int __fastcall func13(const char *a1, const char *a2)
{
yyin = efopen(a1, "r");
F = efopen(a2, "wb");
Mf_putc = fileputc;
Mf_wtrack = mywritetrack;
Measure = 4;
Beat = 96;
Clicks = 96;
M0 = 0;
T0 = 0LL;
func12();
fclose(F);
return fclose(yyin);
}

original_code:
void toMIDI(const char * filein, const char * fileout) {
  yyin = efopen(filein, "r");
  F = efopen(fileout, "wb");
  Mf_putc = fileputc;
  Mf_wtrack = mywritetrack;
  TrkNr = 0;
  Measure = 4;
  Beat = 96;
  Clicks = 96;
  M0 = 0;
  T0 = 0;
  translate();
  fclose(F);
  fclose(yyin);
}

canonical_original_code:
void toMIDI(char *filein, char *fileout) {
  yyin = efopen(filein, "r");
  F = efopen(fileout, "wb");
  Mf_putc = fileputc;
  Mf_wtrack = mywritetrack;
  TrkNr = 0;
  Measure = 4;
  Beat = 96;
  Clicks = 96;
  M0 = 0;
  T0 = 0;
  translate();
  fclose(F);
  fclose(yyin);
}

variable_types:
filein
char *

variable_types:
fileout
char *


gethex

decompiled_code:
int gethex()
{
int v0; // eax
void *v1; // rax
int v2; // edx
__int64 v3; // rbx
int v4; // eax
int v5; // ebp
char v6; // al
__int64 v7; // rax
unsigned __int64 v8; // rdx
int v9; // eax
int v10; // esi
int v12; // [rsp+Ch] [rbp-1Ch] BYREF

buflen = 0;
do_hex = 1;
v0 = yylex();
v12 = v0;
if ( v0 == 268 )
{
LODWORD(v1) = yyleng - 1;
if ( yyleng - 1 > bufsiz )
{
bufsiz = yyleng - 1;
v1 = buffer ? realloc(buffer, (int)v1) : malloc((int)v1);
buffer = v1;
if ( !v1 )
LODWORD(v1) = error("Out of memory");
}
if ( yyleng > 1 )
{
v2 = 0;
v3 = 0x100002600LL;
do
{
v5 = v2 + 1;
v12 = *(char *)(yytext + v2);
if ( v12 == 92 )
{
while ( 1 )
{
v2 = v5 + 1;
v6 = *(_BYTE *)(yytext + v5);
v12 = v6;
if ( v6 == 110 )
{
v12 = 10;
goto LABEL_18;
}
if ( v6 > 110 )
break;
if ( v6 != 13 )
{
if ( v6 == 48 )
{
v12 = 0;
goto LABEL_18;
}
if ( v6 != 10 )
goto LABEL_18;
}
v7 = v5 + 2;
do
{
v5 = v7;
v8 = *(unsigned __int8 *)(yytext + v7 - 1);
v12 = (char)v8;
if ( (unsigned __int8)v8 > 0x20u )
break;
++v7;
}
while ( _bittest64(&v3, v8) );
if ( (char)v8 != 92 )
{
v2 = v5;
goto LABEL_18;
}
}
switch ( v6 )
{
case 't':
v12 = 9;
break;
case 'x':
if ( (unsigned int)_isoc99_sscanf(v2 + yytext, "%2x", &v12) != 1 )
prs_error("Illegal \\x in string");
v2 = v5 + 3;
break;
case 'r':
v12 = 13;
break;
}
}
else
{
++v2;
}
LABEL_18:
v4 = buflen++;
*((_BYTE *)buffer + v4) = v12;
LODWORD(v1) = yyleng - 1;
}
while ( yyleng - 1 > v2 );
}
}
else if ( v0 == 267 )
{
do
{
if ( buflen >= bufsiz )
{
v10 = bufsiz + 128;
bufsiz += 128;
buffer = buffer ? realloc(buffer, v10) : malloc(v10);
if ( !buffer )
error("Out of memory");
}
v9 = buflen++;
*((_BYTE *)buffer + v9) = yyval;
LODWORD(v1) = yylex();
v12 = (int)v1;
}
while ( (_DWORD)v1 == 267 );
if ( (_DWORD)v1 != 272 )
LODWORD(v1) = prs_error("Unknown hex input");
}
else
{
LODWORD(v1) = prs_error("String or hex input expected");
}
return (int)v1;
}

canonical_decompiled_code:
int func16()
{
int v0; // eax
void *v1; // rax
int v2; // edx
__int64 v3; // rbx
int v4; // eax
int v5; // ebp
char v6; // al
__int64 v7; // rax
unsigned __int64 v8; // rdx
int v9; // eax
int v10; // esi
int v12; // [rsp+Ch] [rbp-1Ch] BYREF

buflen = 0;
do_hex = 1;
v0 = yylex();
v12 = v0;
if ( v0 == 268 )
{
LODWORD(v1) = yyleng - 1;
if ( yyleng - 1 > bufsiz )
{
bufsiz = yyleng - 1;
v1 = buffer ? realloc(buffer, (int)v1) : malloc((int)v1);
buffer = v1;
if ( !v1 )
LODWORD(v1) = func4("Out of memory");
}
if ( yyleng > 1 )
{
v2 = 0;
v3 = 0x100002600LL;
do
{
v5 = v2 + 1;
v12 = *(char *)(yytext + v2);
if ( v12 == 92 )
{
while ( 1 )
{
v2 = v5 + 1;
v6 = *(_BYTE *)(yytext + v5);
v12 = v6;
if ( v6 == 110 )
{
v12 = 10;
goto LABEL_18;
}
if ( v6 > 110 )
break;
if ( v6 != 13 )
{
if ( v6 == 48 )
{
v12 = 0;
goto LABEL_18;
}
if ( v6 != 10 )
goto LABEL_18;
}
v7 = v5 + 2;
do
{
v5 = v7;
v8 = *(unsigned __int8 *)(yytext + v7 - 1);
v12 = (char)v8;
if ( (unsigned __int8)v8 > 0x20u )
break;
++v7;
}
while ( _bittest64(&v3, v8) );
if ( (char)v8 != 92 )
{
v2 = v5;
goto LABEL_18;
}
}
switch ( v6 )
{
case 't':
v12 = 9;
break;
case 'x':
if ( (unsigned int)_isoc99_sscanf(v2 + yytext, "%2x", &v12) != 1 )
func0("Illegal \\x in string");
v2 = v5 + 3;
break;
case 'r':
v12 = 13;
break;
}
}
else
{
++v2;
}
LABEL_18:
v4 = buflen++;
*((_BYTE *)buffer + v4) = v12;
LODWORD(v1) = yyleng - 1;
}
while ( yyleng - 1 > v2 );
}
}
else if ( v0 == 267 )
{
do
{
if ( buflen >= bufsiz )
{
v10 = bufsiz + 128;
bufsiz += 128;
buffer = buffer ? realloc(buffer, v10) : malloc(v10);
if ( !buffer )
func4("Out of memory");
}
v9 = buflen++;
*((_BYTE *)buffer + v9) = yyval;
LODWORD(v1) = yylex();
v12 = (int)v1;
}
while ( (_DWORD)v1 == 267 );
if ( (_DWORD)v1 != 272 )
LODWORD(v1) = func0("Unknown hex input");
}
else
{
LODWORD(v1) = func0("String or hex input expected");
}
return (int)v1;
}

original_code:
static void gethex()
{
    int c;
    buflen = 0;
    do_hex = 1;
    c = yylex();
    if (c==268) {
  int i = 0;
     if (yyleng-1 > bufsiz) {
   bufsiz = yyleng-1;
   if (buffer)
    buffer = realloc (buffer, bufsiz);
   else
    buffer = malloc (bufsiz);
     if (! buffer) error ("Out of memory");
  }
  while (i<yyleng-1) {
   c = yytext[i++];
rescan:
   if (c == '\\') {
    switch (c = yytext[i++]) {
    case '0':
     c = '\0';
     break;
    case 'n':
     c = '\n';
     break;
    case 'r':
     c = '\r';
     break;
    case 't':
     c = '\t';
     break;
    case 'x':
     if (sscanf (yytext+i, "%2x", &c) != 1)
      prs_error ("Illegal \\x in string");
     i += 2;
     break;
    case '\r':
    case '\n':
     while ((c=yytext[i++])==' '||c=='\t'||c=='\r'||c=='\n')
                           ;
     goto rescan;
    }
   }
  buffer[buflen++] = c;
  }
    }
    else if (c == 267) {
 do {
         if (buflen >= bufsiz) {
         bufsiz += 128;
         if (buffer)
          buffer = realloc (buffer, bufsiz);
         else
          buffer = malloc (bufsiz);
         if (! buffer) error ("Out of memory");
     }
     buffer[buflen++] = yyval;
     c = yylex();
 } while (c == 267);
 if (c != 272) prs_error ("Unknown hex input");
    }
    else prs_error ("String or hex input expected");
}

variable_types: i int


mywritetrack

decompiled_code:
__int64 mywritetrack()
{
int v0; // eax
int v1; // eax
__int64 v3; // rbx
int v4; // er12
__int64 v5; // rbp
__int64 v6; // rbx
__int64 i; // r12
int v8; // er14
int v9; // er13
char v10; // r15
int v11; // eax
char v12; // r12
int v13; // eax
int v14; // er12
int v15; // eax
int v16; // er12
__int64 v17; // [rsp+0h] [rbp-48h]
char v18; // [rsp+Ch] [rbp-3Ch]

v17 = 0LL;
do
v0 = yylex();
while ( v0 == 272 );
if ( v0 != 257 )
prs_error("Missing MTrk");
while ( 1 )
{
checkeol();
err_cont = 1;
setjmp(erjump);
v1 = yylex();
if ( v1 == 258 )
break;
if ( v1 > 258 )
{
if ( v1 == 267 )
{
v3 = yyval;
v4 = yylex();
if ( v4 == 47 )
{
if ( (unsigned int)yylex() != 267 )
prs_error("Illegal time value");
v6 = yyval + Measure * (v3 - M0);
if ( (unsigned int)yylex() != 47 || (unsigned int)yylex() != 267 )
prs_error("Illegal time value");
v3 = yyval + T0 + v6 * Beat;
v4 = yylex();
}
v5 = v3 - v17;
if ( v4 == 273 )
{
v15 = yylex();
v16 = v15;
if ( v15 == 267 )
{
v16 = yyval;
}
else
{
if ( v15 > 267 )
{
if ( (unsigned int)(v15 - 275) <= 6 )
{
LOBYTE(v16) = v15 - 18;
goto LABEL_80;
}
}
else if ( v15 == 258 )
{
goto LABEL_76;
}
prs_error("Illegal Meta type");
}
if ( v16 == 47 )
{
LABEL_76:
buflen = 0;
LOBYTE(v16) = 47;
goto LABEL_77;
}
LABEL_80:
gethex();
LABEL_77:
mf_w_meta_event(v5, (unsigned __int8)v16, buffer, buflen);
v17 = v3;
}
else if ( v4 > 273 )
{
if ( v4 == 362 )
{
if ( (unsigned int)yylex() != 267 || (unsigned int)yylex() != 47 )
syntax();
v8 = yyval;
v9 = getbyte("Denom");
v18 = getbyte("clocks per click");
v10 = getbyte("32nd notes per 24 clocks");
if ( v9 <= 1 )
{
v11 = 1;
v12 = 0;
}
else
{
v11 = 1;
v12 = 0;
do
{
++v12;
v11 *= 2;
}
while ( v9 > v11 );
}
if ( v9 != v11 )
error("Illegal TimeSig");
data[0] = v8;
data[1] = v12;
data[2] = v18;
data[3] = v10;
M0 += (v3 - T0) / (Measure * Beat);
T0 = v3;
Measure = v8;
Beat = 4 * Clicks / v9;
mf_w_meta_event(v5, 88LL, data, 4LL);
v17 = v3;
}
else if ( v4 <= 362 )
{
switch ( v4 )
{
case 355:
if ( (unsigned int)yylex() != 267 )
syntax();
mf_w_tempo(v5, yyval);
v17 = v3;
break;
case 358:
for ( i = 0LL; i != 5; ++i )
data[i] = getbyte("SMPTE");
mf_w_meta_event(v5, 84LL, data, 5LL);
v17 = v3;
break;
case 274:
get16val("SeqNr");
mf_w_meta_event(v5, 0LL, data, 2LL);
v17 = v3;
break;
default:
goto LABEL_37;
}
}
else if ( v4 == 363 )
{
v13 = getint("Keysig");
data[0] = v13;
if ( (unsigned int)(v13 + 7) > 0xE )
error("Key Sig must be between -7 and 7");
v14 = yylex();
if ( (unsigned int)(v14 - 260) > 1 )
syntax();
data[1] = v14 == 260;
mf_w_meta_event(v5, 89LL, data, 2LL);
v17 = v3;
}
else
{
if ( v4 != 401 )
goto LABEL_37;
gethex();
mf_w_meta_event(v5, 127LL, buffer, buflen);
v17 = v3;
}
}
else if ( v4 == 208 )
{
checkchan();
checkval();
data[0] = data[1];
mf_w_midi_event(v5, 208LL, (unsigned int)chan, data, 1LL);
v17 = v3;
}
else if ( v4 <= 208 )
{
if ( v4 == 176 )
{
checkchan();
checkcon();
checkval();
mf_w_midi_event(v5, 176LL, (unsigned int)chan, data, 2LL);
v17 = v3;
}
else if ( v4 <= 176 )
{
if ( v4 == 160 || (v4 & 0xFFFFFFEF) == 128 )
{
checkchan();
checknote();
checkval();
mf_w_midi_event(v5, (unsigned int)v4, (unsigned int)chan, data, 2LL);
v17 = v3;
}
else
{
LABEL_37:
prs_error("Unknown input");
v17 = v3;
}
}
else
{
if ( v4 != 192 )
goto LABEL_37;
checkchan();
checkprog();
mf_w_midi_event(v5, 192LL, (unsigned int)chan, data, 1LL);
v17 = v3;
}
}
else if ( v4 == 240 || v4 == 259 )
{
gethex();
mf_w_sysex_event(v5, buffer, buflen);
v17 = v3;
}
else
{
if ( v4 != 224 )
goto LABEL_37;
checkchan();
splitval();
mf_w_midi_event(v5, 224LL, (unsigned int)chan, data, 2LL);
v17 = v3;
}
}
else if ( v1 != 272 )
{
goto LABEL_85;
}
}
else
{
if ( v1 == -1 )
goto LABEL_10;
if ( v1 == 257 )
{
prs_error("Unexpected MTrk");
LABEL_10:
err_cont = 0;
error("Unexpected EOF");
return 0xFFFFFFFFLL;
}
LABEL_85:
prs_error("Unknown input");
}
}
err_cont = 0;
checkeol();
return 1LL;
}

canonical_decompiled_code:
__int64 func17()
{
int v0; // eax
int v1; // eax
__int64 v3; // rbx
int v4; // er12
__int64 v5; // rbp
__int64 v6; // rbx
__int64 i; // r12
int v8; // er14
int v9; // er13
char v10; // r15
int v11; // eax
char v12; // r12
int v13; // eax
int v14; // er12
int v15; // eax
int v16; // er12
__int64 v17; // [rsp+0h] [rbp-48h]
char v18; // [rsp+Ch] [rbp-3Ch]

v17 = 0LL;
do
v0 = yylex();
while ( v0 == 272 );
if ( v0 != 257 )
func0("Missing MTrk");
while ( 1 )
{
func2();
err_cont = 1;
setjmp(erjump);
v1 = yylex();
if ( v1 == 258 )
break;
if ( v1 > 258 )
{
if ( v1 == 267 )
{
v3 = yyval;
v4 = yylex();
if ( v4 == 47 )
{
if ( (unsigned int)yylex() != 267 )
func0("Illegal time value");
v6 = yyval + Measure * (v3 - M0);
if ( (unsigned int)yylex() != 47 || (unsigned int)yylex() != 267 )
func0("Illegal time value");
v3 = yyval + T0 + v6 * Beat;
v4 = yylex();
}
v5 = v3 - v17;
if ( v4 == 273 )
{
v15 = yylex();
v16 = v15;
if ( v15 == 267 )
{
v16 = yyval;
}
else
{
if ( v15 > 267 )
{
if ( (unsigned int)(v15 - 275) <= 6 )
{
LOBYTE(v16) = v15 - 18;
goto LABEL_80;
}
}
else if ( v15 == 258 )
{
goto LABEL_76;
}
func0("Illegal Meta type");
}
if ( v16 == 47 )
{
LABEL_76:
buflen = 0;
LOBYTE(v16) = 47;
goto LABEL_77;
}
LABEL_80:
func16();
LABEL_77:
mf_w_meta_event(v5, (unsigned __int8)v16, buffer, buflen);
v17 = v3;
}
else if ( v4 > 273 )
{
if ( v4 == 362 )
{
if ( (unsigned int)yylex() != 267 || (unsigned int)yylex() != 47 )
func1();
v8 = yyval;
v9 = func14("Denom");
v18 = func14("clocks per click");
v10 = func14("32nd notes per 24 clocks");
if ( v9 <= 1 )
{
v11 = 1;
v12 = 0;
}
else
{
v11 = 1;
v12 = 0;
do
{
++v12;
v11 *= 2;
}
while ( v9 > v11 );
}
if ( v9 != v11 )
func4("Illegal TimeSig");
data[0] = v8;
data[1] = v12;
data[2] = v18;
data[3] = v10;
M0 += (v3 - T0) / (Measure * Beat);
T0 = v3;
Measure = v8;
Beat = 4 * Clicks / v9;
mf_w_meta_event(v5, 88LL, data, 4LL);
v17 = v3;
}
else if ( v4 <= 362 )
{
switch ( v4 )
{
case 355:
if ( (unsigned int)yylex() != 267 )
func1();
mf_w_tempo(v5, yyval);
v17 = v3;
break;
case 358:
for ( i = 0LL; i != 5; ++i )
data[i] = func14("SMPTE");
mf_w_meta_event(v5, 84LL, data, 5LL);
v17 = v3;
break;
case 274:
func15("SeqNr");
mf_w_meta_event(v5, 0LL, data, 2LL);
v17 = v3;
break;
default:
goto LABEL_37;
}
}
else if ( v4 == 363 )
{
v13 = func11("Keysig");
data[0] = v13;
if ( (unsigned int)(v13 + 7) > 0xE )
func4("Key Sig must be between -7 and 7");
v14 = yylex();
if ( (unsigned int)(v14 - 260) > 1 )
func1();
data[1] = v14 == 260;
mf_w_meta_event(v5, 89LL, data, 2LL);
v17 = v3;
}
else
{
if ( v4 != 401 )
goto LABEL_37;
func16();
mf_w_meta_event(v5, 127LL, buffer, buflen);
v17 = v3;
}
}
else if ( v4 == 208 )
{
func9();
func10();
data[0] = data[1];
mf_w_midi_event(v5, 208LL, (unsigned int)chan, data, 1LL);
v17 = v3;
}
else if ( v4 <= 208 )
{
if ( v4 == 176 )
{
func9();
func6();
func10();
mf_w_midi_event(v5, 176LL, (unsigned int)chan, data, 2LL);
v17 = v3;
}
else if ( v4 <= 176 )
{
if ( v4 == 160 || (v4 & 0xFFFFFFEF) == 128 )
{
func9();
func5();
func10();
mf_w_midi_event(v5, (unsigned int)v4, (unsigned int)chan, data, 2LL);
v17 = v3;
}
else
{
LABEL_37:
func0("Unknown input");
v17 = v3;
}
}
else
{
if ( v4 != 192 )
goto LABEL_37;
func9();
func8();
mf_w_midi_event(v5, 192LL, (unsigned int)chan, data, 1LL);
v17 = v3;
}
}
else if ( v4 == 240 || v4 == 259 )
{
func16();
mf_w_sysex_event(v5, buffer, buflen);
v17 = v3;
}
else
{
if ( v4 != 224 )
goto LABEL_37;
func9();
func7();
mf_w_midi_event(v5, 224LL, (unsigned int)chan, data, 2LL);
v17 = v3;
}
}
else if ( v1 != 272 )
{
goto LABEL_85;
}
}
else
{
if ( v1 == -1 )
goto LABEL_10;
if ( v1 == 257 )
{
func0("Unexpected MTrk");
LABEL_10:
err_cont = 0;
func4("Unexpected EOF");
return 0xFFFFFFFFLL;
}
LABEL_85:
func0("Unknown input");
}
}
err_cont = 0;
func2();
return 1LL;
}

original_code:
static int mywritetrack(void)
{
    int opcode, c;
    long currtime = 0;
    long newtime, delta;
    int i, k;
    while ((opcode = yylex()) == 272) ;
    if (opcode != 257)
        prs_error("Missing MTrk");
    checkeol();
    while (1) {
  err_cont = 1;
  _setjmp (erjump);
        switch (yylex()) {
        case 257:
            prs_error("Unexpected MTrk");
  case (-1):
      err_cont = 0;
      error ("Unexpected EOF");
      return -1;
        case 258:
      err_cont = 0;
      checkeol();
            return 1;
        case 267:
            newtime = yyval;
            if ((opcode=yylex())=='/') {
                if (yylex()!=267) prs_error("Illegal time value");
                newtime = (newtime-M0)*Measure+yyval;
                if (yylex()!='/'||yylex()!=267) prs_error("Illegal time value");
                newtime = T0 + newtime*Beat + yyval;
    opcode = yylex();
            }
            delta = newtime - currtime;
            switch (opcode) {
            case 0x90:
            case 0x80:
            case 0xa0:
    checkchan();
    checknote();
    checkval();
    mf_w_midi_event(delta, opcode, chan, (unsigned char *) data, 2L);
    break;
            case 0xb0:
    checkchan();
    checkcon();
    checkval();
    mf_w_midi_event (delta, opcode, chan, (unsigned char *) data, 2L);
    break;
            case 0xe0:
    checkchan();
    splitval();
    mf_w_midi_event (delta, opcode, chan, (unsigned char *) data, 2L);
    break;
            case 0xc0:
    checkchan();
    checkprog();
    mf_w_midi_event (delta, opcode, chan, (unsigned char *) data, 1L);
    break;
      case 0xd0:
    checkchan();
    checkval();
    data[0] = data[1];
    mf_w_midi_event (delta, opcode, chan, (unsigned char *) data, 1L);
    break;
            case 0xf0:
            case 259:
       gethex();
    mf_w_sysex_event (delta, (unsigned char *) buffer, (long)buflen);
    break;
            case (273 +1+0x51):
       if (yylex() != 267) syntax();
    mf_w_tempo(delta, yyval);
    break;
            case (273 +1+0x58): {
          int nn, denom, cc, bb;
          if (yylex() != 267 || yylex() != '/') syntax();
    nn = yyval;
    denom = getbyte("Denom");
    cc = getbyte("clocks per click");
    bb = getbyte("32nd notes per 24 clocks");
    for (i=0, k=1 ; k<denom; i++, k<<=1);
    if (k!=denom) error ("Illegal TimeSig");
    data[0] = nn;
    data[1] = i;
    data[2] = cc;
    data[3] = bb;
    M0 += (newtime-T0)/(Beat*Measure);
    T0 = newtime;
    Measure = nn;
    Beat = 4 * Clicks / denom;
    mf_w_meta_event(delta, (unsigned char) 0x58, (unsigned char *) data, 4L);
    }
    break;
            case (273 +1+0x54):
    for (i=0; i<5; i++) {
        data[i] = getbyte("SMPTE");
    }
    mf_w_meta_event (delta, (unsigned char) 0x54, (unsigned char *) data, 5L);
    break;
            case (273 +1+0x59):
    data[0] = i = getint ("Keysig");
    if (i<-7 || i>7)
        error ("Key Sig must be between -7 and 7");
    if ((c=yylex()) != 260 && c != 261)
     syntax();
    data[1] = (c == 260);
    mf_w_meta_event (delta, (unsigned char) 0x59, (unsigned char *) data, 2L);
    break;
            case (273 +1+0x00):
    get16val("SeqNr");
    mf_w_meta_event (delta, (unsigned char) 0x00, (unsigned char *) data, 2L);
    break;
      case 273: {
          int type = yylex();
    switch (type) {
    case 258:
        type = 0x2f;
        break;
    case (273 +1+0x01):
    case (273 +1+0x02):
    case (273 +1+0x03):
    case (273 +1+0x04):
    case (273 +1+0x05):
    case (273 +1+0x06):
    case (273 +1+0x07):
        type -= (273 +1);
        break;
    case 267:
        type = yyval;
        break;
    default:
        prs_error ("Illegal Meta type");
    }
    if (type == 0x2f)
        buflen = 0;
    else
        gethex();
    mf_w_meta_event (delta, (unsigned char) type, (unsigned char *) buffer, (long)buflen);
    break;
       }
            case (273 +1+0x7f):
    gethex();
    mf_w_meta_event (delta, (unsigned char) 0x7f, (unsigned char *) buffer, (long)buflen);
    break;
      default:
          prs_error ("Unknown input");
    break;
      }
            currtime = newtime;
        case 272:
      break;
  default:
      prs_error ("Unknown input");
      break;
 }
 checkeol();
    }
}

canonical_original_code:
static int mywritetrack()
{
    int opcode; int c;
    long currtime = 0;
    long newtime; long delta;
    int i; int k;
    while ((opcode = yylex()) == 272) ;
    if (opcode != 257)
        prs_error("Missing MTrk");
    checkeol();
    while (1) {
  err_cont = 1;
  _setjmp (erjump);
        switch (yylex()) {
        case 257:
            prs_error("Unexpected MTrk");
  case (-1):
      err_cont = 0;
      error ("Unexpected EOF");
      return -1;
        case 258:
      err_cont = 0;
      checkeol();
            return 1;
        case 267:
            newtime = yyval;
            if ((opcode=yylex())=='/') {
                if (yylex()!=267) prs_error("Illegal time value");
                newtime = (newtime-M0)*Measure+yyval;
                if (yylex()!='/'||yylex()!=267) prs_error("Illegal time value");
                newtime = T0 + newtime*Beat + yyval;
    opcode = yylex();
            }
            delta = newtime - currtime;
            switch (opcode) {
            case 0x90:
            case 0x80:
            case 0xa0:
    checkchan();
    checknote();
    checkval();
    mf_w_midi_event(delta, opcode, chan, (unsigned char *) data, 2L);
    break;
            case 0xb0:
    checkchan();
    checkcon();
    checkval();
    mf_w_midi_event (delta, opcode, chan, (unsigned char *) data, 2L);
    break;
            case 0xe0:
    checkchan();
    splitval();
    mf_w_midi_event (delta, opcode, chan, (unsigned char *) data, 2L);
    break;
            case 0xc0:
    checkchan();
    checkprog();
    mf_w_midi_event (delta, opcode, chan, (unsigned char *) data, 1L);
    break;
      case 0xd0:
    checkchan();
    checkval();
    data[0] = data[1];
    mf_w_midi_event (delta, opcode, chan, (unsigned char *) data, 1L);
    break;
            case 0xf0:
            case 259:
       gethex();
    mf_w_sysex_event (delta, (unsigned char *) buffer, (long)buflen);
    break;
            case (273 +1+0x51):
       if (yylex() != 267) syntax();
    mf_w_tempo(delta, yyval);
    break;
            case (273 +1+0x58): {
          int nn; int denom; int cc; int bb;
          if (yylex() != 267 || yylex() != '/') syntax();
    nn = yyval;
    denom = getbyte("Denom");
    cc = getbyte("clocks per click");
    bb = getbyte("32nd notes per 24 clocks");
    for (i=0, k=1 ; k<denom; i++, k<<=1);
    if (k!=denom) error ("Illegal TimeSig");
    data[0] = nn;
    data[1] = i;
    data[2] = cc;
    data[3] = bb;
    M0 += (newtime-T0)/(Beat*Measure);
    T0 = newtime;
    Measure = nn;
    Beat = 4 * Clicks / denom;
    mf_w_meta_event(delta, (unsigned char) 0x58, (unsigned char *) data, 4L);
    }
    break;
            case (273 +1+0x54):
    for (i=0; i<5; i++) {
        data[i] = getbyte("SMPTE");
    }
    mf_w_meta_event (delta, (unsigned char) 0x54, (unsigned char *) data, 5L);
    break;
            case (273 +1+0x59):
    data[0] = i = getint ("Keysig");
    if (i<-7 || i>7)
        error ("Key Sig must be between -7 and 7");
    if ((c=yylex()) != 260 && c != 261)
     syntax();
    data[1] = (c == 260);
    mf_w_meta_event (delta, (unsigned char) 0x59, (unsigned char *) data, 2L);
    break;
            case (273 +1+0x00):
    get16val("SeqNr");
    mf_w_meta_event (delta, (unsigned char) 0x00, (unsigned char *) data, 2L);
    break;
      case 273: {
          int type = yylex();
    switch (type) {
    case 258:
        type = 0x2f;
        break;
    case (273 +1+0x01):
    case (273 +1+0x02):
    case (273 +1+0x03):
    case (273 +1+0x04):
    case (273 +1+0x05):
    case (273 +1+0x06):
    case (273 +1+0x07):
        type -= (273 +1);
        break;
    case 267:
        type = yyval;
        break;
    default:
        prs_error ("Illegal Meta type");
    }
    if (type == 0x2f)
        buflen = 0;
    else
        gethex();
    mf_w_meta_event (delta, (unsigned char) type, (unsigned char *) buffer, (long)buflen);
    break;
       }
            case (273 +1+0x7f):
    gethex();
    mf_w_meta_event (delta, (unsigned char) 0x7f, (unsigned char *) buffer, (long)buflen);
    break;
      default:
          prs_error ("Unknown input");
    break;
      }
            currtime = newtime;
        case 272:
      break;
  default:
      prs_error ("Unknown input");
      break;
 }
 checkeol();
    }
}

variable_types: opcode int

variable_types: currtime long

variable_types: newtime long

variable_types: delta long

variable_types: k int

variable_types: nn int

variable_types: denom int

variable_types: cc int

variable_types: bb int

variable_types: type int

return_type: int


decompiled_code:
void __fastcall aubio_fft_getspectrum(__int64 a1, __int64 a2, __int64 a3, unsigned int a4)
{
__int64 v6; // rbx
__int64 v7; // rbx
unsigned int v8; // [rsp+8h] [rbp-40h]
unsigned int v9; // [rsp+Ch] [rbp-3Ch]

v9 = a4 >> 1;
v8 = (a4 >> 1) + 1;
v6 = 0LL;
do
{
*(double *)(a1 + 2 * v6) = (float)(cosf(*(float *)(a3 + v6)) * *(float *)(a2 + v6));
v6 += 4LL;
}
while ( v6 != 4LL * v8 );
if ( v8 > 1 )
{
v7 = 1LL;
do
{
*(double *)(a1 + 8LL * (a4 - (unsigned int)v7)) = (float)(sinf(*(float *)(a3 + 4 * v7)) * *(float *)(a2 + 4 * v7));
++v7;
}
while ( v7 != v9 + 1 );
}
}

original_code:
void aubio_fft_getspectrum(fft_data_t * spectrum, smpl_t *norm, smpl_t * phas, uint_t size) {
  uint_t j;
  for (j=0; j<size/2+1; j++) {
    spectrum[j] = norm[j]*cosf(phas[j]);
  }
  for (j=1; j<size/2+1; j++) {
    spectrum[size-j] = norm[j]*sinf(phas[j]);
  }
}

canonical_original_code:
void aubio_fft_getspectrum(double *spectrum, float *norm, float *phas, unsigned int size) {
  unsigned int j;
  for (j=0; j<size/2+1; j++) {
    spectrum[j] = norm[j]*cosf(phas[j]);
  }
  for (j=1; j<size/2+1; j++) {
    spectrum[size-j] = norm[j]*sinf(phas[j]);
  }
}

variable_types:
spectrum
double *

variable_types:
norm
float *

variable_types:
phas
float *

variable_types:
size
unsigned int

variable_types:
j
unsigned int


decompiled_code:
void __fastcall aubio_fft_getnorm(_DWORD *a1, double *a2, unsigned int a3)
{
float v4; // xmm0_4
__int64 v5; // r14
__int64 v6; // rbx
float v7; // xmm0_4
float v8; // xmm0_4

v4 = *a2;
*a1 = LODWORD(v4) ^ LC1;
if ( (a3 >> 1) + 1 > 1 )
{
v5 = (a3 >> 1) + 1;
v6 = 1LL;
do
{
v7 = a2[v6] * a2[v6] + a2[a3 - (unsigned int)v6] * a2[a3 - (unsigned int)v6];
if ( v7 < 0.0 )
v8 = sqrtf(v7);
else
v8 = fsqrt(v7);
*(float *)&a1[v6++] = v8;
}
while ( v6 != v5 );
}
}

canonical_decompiled_code:
void __fastcall func4(_DWORD *a1, double *a2, unsigned int a3)
{
float v4; // xmm0_4
__int64 v5; // r14
__int64 v6; // rbx
float v7; // xmm0_4
float v8; // xmm0_4

v4 = *a2;
*a1 = LODWORD(v4) ^ LC1;
if ( (a3 >> 1) + 1 > 1 )
{
v5 = (a3 >> 1) + 1;
v6 = 1LL;
do
{
v7 = a2[v6] * a2[v6] + a2[a3 - (unsigned int)v6] * a2[a3 - (unsigned int)v6];
if ( v7 < 0.0 )
v8 = sqrtf(v7);
else
v8 = fsqrt(v7);
*(float *)&a1[v6++] = v8;
}
while ( v6 != v5 );
}
}

original_code:
void aubio_fft_getnorm(smpl_t * norm, fft_data_t * spectrum, uint_t size) {
 uint_t i;
  norm[0] = -spectrum[0];
 for (i=1;i<size/2+1;i++) norm[i] = sqrtf((spectrum[i]*spectrum[i]) + (spectrum[size-i]*spectrum[size-i]));
}

canonical_original_code:
void aubio_fft_getnorm(float *norm, double *spectrum, unsigned int size) {
 unsigned int i;
  norm[0] = -spectrum[0];
 for (i=1;i<size/2+1;i++) norm[i] = sqrtf((spectrum[i]*spectrum[i]) + (spectrum[size-i]*spectrum[size-i]));
}

variable_types:
i
unsigned int


original_code:
void aubio_fft_getphas(smpl_t * phas, fft_data_t * spectrum, uint_t size) {
 uint_t i;
  phas[0] = (3.1415926536);
 for (i=1;i<size/2+1;i++) phas[i] = atan2f(spectrum[size-i] , spectrum[i]);
}

canonical_original_code:
void aubio_fft_getphas(float *phas, double *spectrum, unsigned int size) {
 unsigned int i;
  phas[0] = (3.1415926536);
 for (i=1;i<size/2+1;i++) phas[i] = atan2f(spectrum[size-i] , spectrum[i]);
}


original_code:
void aubio_biquad_do(aubio_biquad_t * b, fvec_t * in) {
  uint_t i,j;
  lsmp_t i1 = b->i1;
  lsmp_t i2 = b->i2;
  lsmp_t o1 = b->o1;
  lsmp_t o2 = b->o2;
  lsmp_t a2 = b->a2;
  lsmp_t a3 = b->a3;
  lsmp_t b1 = b->b1;
  lsmp_t b2 = b->b2;
  lsmp_t b3 = b->b3;
  i=0;
  for (j = 0; j < in->length; j++) {
    lsmp_t i0 = in->data[i][j];
    lsmp_t o0 = b1 * i0 + b2 * i1 + b3 * i2
      - a2 * o1 - a3 * o2;
    in->data[i][j] = o0;
    i2 = i1;
    i1 = i0;
    o2 = o1;
    o1 = o0;
  }
  b->i2 = i2;
  b->i1 = i1;
  b->o2 = o2;
  b->o1 = o1;
}

canonical_original_code:
void aubio_biquad_do(struct _aubio_biquad_t *b, struct _fvec_t *in) {
  unsigned int i; unsigned int j;
  double i1 = b->i1;
  double i2 = b->i2;
  double o1 = b->o1;
  double o2 = b->o2;
  double a2 = b->a2;
  double a3 = b->a3;
  double b1 = b->b1;
  double b2 = b->b2;
  double b3 = b->b3;
  i=0;
  for (j = 0; j < in->length; j++) {
    double i0 = in->data[i][j];
    double o0 = b1 * i0 + b2 * i1 + b3 * i2
      - a2 * o1 - a3 * o2;
    in->data[i][j] = o0;
    i2 = i1;
    i1 = i0;
    o2 = o1;
    o1 = o0;
  }
  b->i2 = i2;
  b->i1 = i1;
  b->o2 = o2;
  b->o1 = o1;
}

variable_types: struct _aubio_biquad_t { double a2; double a3; double b1; double b2; double b3; double o1; double o2; double i1; double i2; } *

variable_types: struct _fvec_t { unsigned int length; unsigned int channels; float **data; } *


original_code:
void aubio_biquad_do_filtfilt(aubio_biquad_t * b, fvec_t * in, fvec_t * tmp) {
  uint_t j,i=0;
  uint_t length = in->length;
  lsmp_t mir;
  mir = 2*in->data[i][0];
  b->i1 = mir - in->data[i][2];
  b->i2 = mir - in->data[i][1];
  aubio_biquad_do(b,in);
  for (j = 0; j < length; j++)
    tmp->data[i][length-j-1] = in->data[i][j];
  mir = 2*tmp->data[i][0];
  b->i1 = mir - tmp->data[i][2];
  b->i2 = mir - tmp->data[i][1];
  aubio_biquad_do(b,tmp);
  for (j = 0; j < length; j++)
    in->data[i][j] = tmp->data[i][length-j-1];
}

canonical_original_code:
void aubio_biquad_do_filtfilt(struct _aubio_biquad_t *b, struct _fvec_t *in, struct _fvec_t *tmp) {
  unsigned int j; unsigned int i = 0;
  unsigned int length = in->length;
  double mir;
  mir = 2*in->data[i][0];
  b->i1 = mir - in->data[i][2];
  b->i2 = mir - in->data[i][1];
  aubio_biquad_do(b,in);
  for (j = 0; j < length; j++)
    tmp->data[i][length-j-1] = in->data[i][j];
  mir = 2*tmp->data[i][0];
  b->i1 = mir - tmp->data[i][2];
  b->i2 = mir - tmp->data[i][1];
  aubio_biquad_do(b,tmp);
  for (j = 0; j < length; j++)
    in->data[i][j] = tmp->data[i][length-j-1];
}

variable_types:
tmp
struct _fvec_t *

variable_types:
length
unsigned int

variable_types: mir double

user_defined_types: struct _aubio_biquad_t { double a2; double a3; double b1; double b2; double b3; double o1; double o2; double i1; double i2; }

user_defined_types: struct _fvec_t { unsigned int length; unsigned int channels; float **data; }


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

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

original_code:
void del_aubio_biquad(aubio_biquad_t * b) {
  free(b);
}

canonical_original_code:
void del_aubio_biquad(struct _aubio_biquad_t *b) {
  free(b);
}


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

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

original_code:
void del_aubio_scale(aubio_scale_t *s) {
 free(s);
}

canonical_original_code:
void del_aubio_scale(struct _aubio_scale_t *s) {
 free(s);
}

variable_types: struct _aubio_scale_t { float ilow; float ihig; float olow; float ohig; float scaler; float irange; } *


decompiled_code:
void __fastcall aubio_scale_set(float *a1, float a2, float a3, float a4, float a5)
{
float v5; // xmm3_4

*a1 = a2;
a1[1] = a3;
a1[2] = a4;
a1[3] = a5;
if ( (float)(a3 - a2) == 0.0 )
v5 = 0.0;
else
v5 = (float)(a5 - a4) / (float)(a3 - a2);
a1[4] = v5;
}

original_code:
void aubio_scale_set (aubio_scale_t *s, smpl_t ilow, smpl_t ihig, smpl_t olow, smpl_t ohig)
{
 smpl_t inputrange = ihig - ilow;
 smpl_t outputrange= ohig - olow;
 s->ilow = ilow;
 s->ihig = ihig;
 s->olow = olow;
 s->ohig = ohig;
 if (inputrange == 0 )
  s->scaler = 0.0f;
 else {
  s->scaler = outputrange/inputrange;
  if (inputrange < 0 )
   inputrange = inputrange * -1.0f;
 }
}

canonical_original_code:
void aubio_scale_set(struct _aubio_scale_t *s, float ilow, float ihig, float olow, float ohig)
{
 float inputrange = ihig - ilow;
 float outputrange = ohig - olow;
 s->ilow = ilow;
 s->ihig = ihig;
 s->olow = olow;
 s->ohig = ohig;
 if (inputrange == 0 )
  s->scaler = 0.0f;
 else {
  s->scaler = outputrange/inputrange;
  if (inputrange < 0 )
   inputrange = inputrange * -1.0f;
 }
}

variable_types: ilow float

variable_types: ihig float

variable_types: olow float

variable_types: ohig float

variable_types: inputrange float

variable_types: outputrange float

user_defined_types: struct _aubio_scale_t { float ilow; float ihig; float olow; float ohig; float scaler; float irange; }


decompiled_code:
float *__fastcall new_aubio_scale(float a1, float a2, float a3, float a4)
{
float *v4; // rbx

v4 = (float *)malloc(0x18uLL);
aubio_scale_set(v4, a1, a2, a3, a4);
return v4;
}

canonical_decompiled_code:
float *__fastcall func2(float a1, float a2, float a3, float a4)
{
float *v4; // rbx

v4 = (float *)malloc(0x18uLL);
func1(v4, a1, a2, a3, a4);
return v4;
}

original_code:
aubio_scale_t * new_aubio_scale (smpl_t ilow, smpl_t ihig, smpl_t olow, smpl_t ohig ){
 aubio_scale_t * s = (aubio_scale_t*)malloc(sizeof(aubio_scale_t));
 aubio_scale_set (s, ilow, ihig, olow, ohig);
 return s;
}

canonical_original_code:
struct _aubio_scale_t *new_aubio_scale(float ilow, float ihig, float olow, float ohig){
 struct _aubio_scale_t *s = (aubio_scale_t*)malloc(sizeof(aubio_scale_t));
 aubio_scale_set (s, ilow, ihig, olow, ohig);
 return s;
}

return_type: struct _aubio_scale_t { float ilow; float ihig; float olow; float ohig; float scaler; float irange; } *


decompiled_code:
void __fastcall aubio_pitchyin_diff(__int64 a1, __int64 a2)
{
unsigned int i; // er10
unsigned int j; // eax
__int64 v4; // rdx
float v5; // xmm0_4
float *v6; // rdx
unsigned int v7; // edx
unsigned int v8; // ecx
unsigned int v9; // eax

for ( i = 0; *(_DWORD *)(a1 + 4) > i; ++i )
{
v9 = 0;
if ( *(_DWORD *)a2 )
{
do
*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a2 + 8) + 8LL * i) + 4LL * v9++) = 0;
while ( *(_DWORD *)a2 > v9 );
if ( *(_DWORD *)a2 > 1u )
{
v8 = 1;
for ( j = 0; ; j = 0 )
{
do
{
v4 = *(_QWORD *)(*(_QWORD *)(a1 + 8) + 8LL * i);
v5 = *(float *)(v4 + 4LL * j) - *(float *)(v4 + 4LL * (v8 + j));
v6 = (float *)(*(_QWORD *)(*(_QWORD *)(a2 + 8) + 8LL * i) + 4LL * v8);
*v6 = (float)(v5 * v5) + *v6;
++j;
v7 = *(_DWORD *)a2;
}
while ( *(_DWORD *)a2 > j );
if ( v7 <= ++v8 || !v7 )
break;
}
}
}
}
}

original_code:
void aubio_pitchyin_diff(fvec_t * input, fvec_t * yin){
 uint_t c,j,tau;
 smpl_t tmp;
 for (c=0;c<input->channels;c++)
 {
  for (tau=0;tau<yin->length;tau++)
  {
   yin->data[c][tau] = 0.;
  }
  for (tau=1;tau<yin->length;tau++)
  {
   for (j=0;j<yin->length;j++)
   {
    tmp = input->data[c][j] - input->data[c][j+tau];
    yin->data[c][tau] += (tmp*tmp);
   }
  }
 }
}

canonical_original_code:
void aubio_pitchyin_diff(struct _fvec_t *input, struct _fvec_t *yin){
 unsigned int c; unsigned int j; unsigned int tau;
 float tmp;
 for (c=0;c<input->channels;c++)
 {
  for (tau=0;tau<yin->length;tau++)
  {
   yin->data[c][tau] = 0.;
  }
  for (tau=1;tau<yin->length;tau++)
  {
   for (j=0;j<yin->length;j++)
   {
    tmp = input->data[c][j] - input->data[c][j+tau];
    yin->data[c][tau] += (tmp*tmp);
   }
  }
 }
}

variable_types:
yin
struct _fvec_t *

variable_types:
c
unsigned int

variable_types:
tau
unsigned int

variable_types: tmp float


original_code:
void aubio_pitchyin_getcum(fvec_t * yin) {
 uint_t c,tau;
 smpl_t tmp;
 for (c=0;c<yin->channels;c++)
 {
  tmp = 0.;
  yin->data[c][0] = 1.;
  for (tau=1;tau<yin->length;tau++)
  {
   tmp += yin->data[c][tau];
   yin->data[c][tau] *= tau/tmp;
  }
 }
}

canonical_original_code:
void aubio_pitchyin_getcum(struct _fvec_t *yin) {
 unsigned int c; unsigned int tau;
 float tmp;
 for (c=0;c<yin->channels;c++)
 {
  tmp = 0.;
  yin->data[c][0] = 1.;
  for (tau=1;tau<yin->length;tau++)
  {
   tmp += yin->data[c][tau];
   yin->data[c][tau] *= tau/tmp;
  }
 }
}


decompiled_code:
__int64 __fastcall aubio_pitchyin_getpitch(__int64 a1)
{
__int64 v1; // rdx
unsigned int v2; // eax
unsigned int v3; // ecx

v1 = **(_QWORD **)(a1 + 8);
v2 = 1;
while ( *(float *)(v1 + 4LL * v2) >= 0.1 )
{
if ( *(_DWORD *)a1 <= ++v2 )
return 0;
}
do
v3 = v2++;
while ( *(float *)(v1 + 4LL * v3) > *(float *)(v1 + 4LL * v2) );
return v3;
}

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

v1 = **(_QWORD **)(a1 + 8);
v2 = 1;
while ( *(float *)(v1 + 4LL * v2) >= 0.1 )
{
if ( *(_DWORD *)a1 <= ++v2 )
return 0;
}
do
v3 = v2++;
while ( *(float *)(v1 + 4LL * v3) > *(float *)(v1 + 4LL * v2) );
return v3;
}

original_code:
uint_t aubio_pitchyin_getpitch(fvec_t * yin) {
 uint_t c=0,tau=1;
 do
 {
  if(yin->data[c][tau] < 0.1) {
   while (yin->data[c][tau+1] < yin->data[c][tau]) {
    tau++;
   }
   return tau;
  }
  tau++;
 } while (tau<yin->length);
 return 0;
}

canonical_original_code:
unsigned int aubio_pitchyin_getpitch(struct _fvec_t *yin) {
 unsigned int c = 0; unsigned int tau = 1;
 do
 {
  if(yin->data[c][tau] < 0.1) {
   while (yin->data[c][tau+1] < yin->data[c][tau]) {
    tau++;
   }
   return tau;
  }
  tau++;
 } while (tau<yin->length);
 return 0;
}

return_type: unsigned int


original_code:
smpl_t aubio_pitchyin_getpitchfast(fvec_t * input, fvec_t * yin, smpl_t tol){
 uint_t c=0,j,tau = 0;
 sint_t period;
 smpl_t tmp = 0., tmp2 = 0.;
 yin->data[c][0] = 1.;
 for (tau=1;tau<yin->length;tau++)
 {
  yin->data[c][tau] = 0.;
  for (j=0;j<yin->length;j++)
  {
   tmp = input->data[c][j] - input->data[c][j+tau];
   yin->data[c][tau] += (tmp*tmp);
  }
  tmp2 += yin->data[c][tau];
  yin->data[c][tau] *= tau/tmp2;
  period = tau-3;
  if(tau > 4 && (yin->data[c][period] < tol) &&
                                (yin->data[c][period] < yin->data[c][period+1])) {
   return vec_quadint_min(yin,period,1);
  }
        }
 return vec_quadint_min(yin,vec_min_elem(yin),1);
}

canonical_original_code:
float aubio_pitchyin_getpitchfast(struct _fvec_t *input, struct _fvec_t *yin, float tol){
 unsigned int c = 0; unsigned int j; unsigned int tau = 0;
 int period;
 float tmp = 0.; float tmp2 = 0.;
 yin->data[c][0] = 1.;
 for (tau=1;tau<yin->length;tau++)
 {
  yin->data[c][tau] = 0.;
  for (j=0;j<yin->length;j++)
  {
   tmp = input->data[c][j] - input->data[c][j+tau];
   yin->data[c][tau] += (tmp*tmp);
  }
  tmp2 += yin->data[c][tau];
  yin->data[c][tau] *= tau/tmp2;
  period = tau-3;
  if(tau > 4 && (yin->data[c][period] < tol) &&
                                (yin->data[c][period] < yin->data[c][period+1])) {
   return vec_quadint_min(yin,period,1);
  }
        }
 return vec_quadint_min(yin,vec_min_elem(yin),1);
}

variable_types: tol float

variable_types:
j
unsigned int

variable_types: period int

return_type: float


decompiled_code:
void __fastcall aubio_pvoc_swapbuffers(__int64 a1, __int64 a2, __int64 a3, int a4, unsigned int a5)
{
unsigned int v5; // ecx
__int64 i; // rax
__int64 v7; // rax
__int64 v8; // rax

v5 = a4 - a5;
if ( v5 )
{
for ( i = 0LL; i != v5; ++i )
*(_DWORD *)(a1 + 4 * i) = *(_DWORD *)(a2 + 4 * i);
if ( !a5 )
goto LABEL_8;
}
else if ( !a5 )
{
return;
}
v7 = 0LL;
do
{
*(_DWORD *)(a1 + 4LL * (v5 + (unsigned int)v7)) = *(_DWORD *)(a3 + 4 * v7);
++v7;
}
while ( a5 > (unsigned int)v7 );
if ( v5 )
{
LABEL_8:
v8 = 0LL;
do
{
*(_DWORD *)(a2 + 4 * v8) = *(_DWORD *)(a1 + 4LL * (a5 + (unsigned int)v8));
++v8;
}
while ( v5 > (unsigned int)v8 );
}
}

canonical_decompiled_code:
void __fastcall func0(__int64 a1, __int64 a2, __int64 a3, int a4, unsigned int a5)
{
unsigned int v5; // ecx
__int64 i; // rax
__int64 v7; // rax
__int64 v8; // rax

v5 = a4 - a5;
if ( v5 )
{
for ( i = 0LL; i != v5; ++i )
*(_DWORD *)(a1 + 4 * i) = *(_DWORD *)(a2 + 4 * i);
if ( !a5 )
goto LABEL_8;
}
else if ( !a5 )
{
return;
}
v7 = 0LL;
do
{
*(_DWORD *)(a1 + 4LL * (v5 + (unsigned int)v7)) = *(_DWORD *)(a3 + 4 * v7);
++v7;
}
while ( a5 > (unsigned int)v7 );
if ( v5 )
{
LABEL_8:
v8 = 0LL;
do
{
*(_DWORD *)(a2 + 4 * v8) = *(_DWORD *)(a1 + 4LL * (a5 + (unsigned int)v8));
++v8;
}
while ( v5 > (unsigned int)v8 );
}
}

original_code:
static void aubio_pvoc_swapbuffers(smpl_t * data, smpl_t * dataold,
                const smpl_t * datanew, uint_t win_s, uint_t hop_s)
{
 uint_t i;
 for (i=0;i<win_s-hop_s;i++)
  data[i] = dataold[i];
 for (i=0;i<hop_s;i++)
  data[win_s-hop_s+i] = datanew[i];
 for (i=0;i<win_s-hop_s;i++)
  dataold[i] = data[i+hop_s];
}

canonical_original_code:
static void aubio_pvoc_swapbuffers(float *data, float *dataold, float *datanew, unsigned int win_s, unsigned int hop_s)
{
 unsigned int i;
 for (i=0;i<win_s-hop_s;i++)
  data[i] = dataold[i];
 for (i=0;i<hop_s;i++)
  data[win_s-hop_s+i] = datanew[i];
 for (i=0;i<win_s-hop_s;i++)
  dataold[i] = data[i+hop_s];
}

variable_types:
data
float *

variable_types:
dataold
float *

variable_types:
datanew
float *

variable_types:
i
unsigned int


decompiled_code:
__int64 __fastcall aubio_pvoc_addsynth(__int64 a1, float *a2, __int64 a3, int a4, unsigned int a5)
{
int v5; // er10
float v6; // xmm1_4
__int64 i; // rax
int v8; // edx
__int64 v9; // rax
__int64 result; // rax

v5 = 2 * a5;
v6 = (double)(int)(2 * a5) / ((double)a4 + 0.0);
if ( a5 )
{
for ( i = 0LL; i != a5; ++i )
*(float *)(a3 + 4 * i) = (float)(v6 * *(float *)(a1 + 4 * i)) + a2[i];
}
v8 = a4 - v5;
if ( a4 != v5 )
{
v9 = 0LL;
do
{
a2[v9] = a2[a5 + (unsigned int)v9];
++v9;
}
while ( v9 != v8 );
}
result = a5 + v8;
if ( a4 > (unsigned int)result )
{
do
a2[v8++] = 0.0;
while ( v8 != (_DWORD)result );
}
if ( (_DWORD)result )
{
result = a5 + (unsigned int)result;
do
{
*a2 = (float)(v6 * *(float *)(a1 + 4LL * a5)) + *a2;
++a2;
++a5;
}
while ( a5 != (_DWORD)result );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, float *a2, __int64 a3, int a4, unsigned int a5)
{
int v5; // er10
float v6; // xmm1_4
__int64 i; // rax
int v8; // edx
__int64 v9; // rax
__int64 result; // rax

v5 = 2 * a5;
v6 = (double)(int)(2 * a5) / ((double)a4 + 0.0);
if ( a5 )
{
for ( i = 0LL; i != a5; ++i )
*(float *)(a3 + 4 * i) = (float)(v6 * *(float *)(a1 + 4 * i)) + a2[i];
}
v8 = a4 - v5;
if ( a4 != v5 )
{
v9 = 0LL;
do
{
a2[v9] = a2[a5 + (unsigned int)v9];
++v9;
}
while ( v9 != v8 );
}
result = a5 + v8;
if ( a4 > (unsigned int)result )
{
do
a2[v8++] = 0.0;
while ( v8 != (_DWORD)result );
}
if ( (_DWORD)result )
{
result = a5 + (unsigned int)result;
do
{
*a2 = (float)(v6 * *(float *)(a1 + 4LL * a5)) + *a2;
++a2;
++a5;
}
while ( a5 != (_DWORD)result );
}
return result;
}

original_code:
static void aubio_pvoc_addsynth(const smpl_t * synth, smpl_t * synthold,
                smpl_t * synthnew, uint_t win_s, uint_t hop_s)
{
 uint_t i;
 smpl_t scale = 2*hop_s/(win_s+.0);
 for (i=0;i<hop_s;i++)
  synthnew[i] = synthold[i]+synth[i]*scale;
 for (i=0;i<win_s-2*hop_s;i++)
  synthold[i] = synthold[i+hop_s];
 for (i=win_s-hop_s;i<win_s;i++)
  synthold[i-hop_s]=0.;
 for (i=0;i<win_s-hop_s;i++)
  synthold[i] += synth[i+hop_s]*scale;
}

canonical_original_code:
static void aubio_pvoc_addsynth(float *synth, float *synthold, float *synthnew, unsigned int win_s, unsigned int hop_s)
{
 unsigned int i;
 float scale = 2*hop_s/(win_s+.0);
 for (i=0;i<hop_s;i++)
  synthnew[i] = synthold[i]+synth[i]*scale;
 for (i=0;i<win_s-2*hop_s;i++)
  synthold[i] = synthold[i+hop_s];
 for (i=win_s-hop_s;i<win_s;i++)
  synthold[i-hop_s]=0.;
 for (i=0;i<win_s-hop_s;i++)
  synthold[i] += synth[i+hop_s]*scale;
}

variable_types:
synth
float *

variable_types:
synthold
float *

variable_types:
synthnew
float *

variable_types: scale float


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
unsigned int v4; // ebp
char *v5; // rbx
int v6; // er12
int v7; // eax

ext2_init(argc, argv, envp);
v3 = ext2_open("/home/barracuda/help.txt");
if ( v3 >= 0 )
{
v4 = v3;
v5 = (char *)malloc(0x400uLL);
v6 = 512;
do
{
v7 = ext2_read(v4, v5, 2LL);
if ( !v7 )
break;
v5[v7] = 0;
printf("%s", v5);
--v6;
}
while ( v6 );
free(v5);
ext2_close(v4);
ext2_fini();
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
unsigned int v4; // ebp
char *v5; // rbx
int v6; // er12
int v7; // eax

func7(argc, argv, envp);
v3 = func11("/home/barracuda/help.txt");
if ( v3 >= 0 )
{
v4 = v3;
v5 = (char *)malloc(0x400uLL);
v6 = 512;
do
{
v7 = func12(v4, v5, 2LL);
if ( !v7 )
break;
v5[v7] = 0;
printf("%s", v5);
--v6;
}
while ( v6 );
free(v5);
func14(v4);
func8();
}
return 0;
}

original_code:
int main()
{
  ext2_init();
  int i = ext2_open("/home/barracuda/help.txt", 0);
  if (i < 0)
    return 0;
  char *buf = malloc(1024);
  int j,k;
  for(j = 0; j < 512; j++)
  {
    if((k = ext2_read(i, buf, 2)) == 0)
      break;
    buf[k] = 0;
    printf("%s", buf);
  }
  free(buf);
  ext2_close(i);
  ext2_fini();
}

canonical_original_code:
int main()
{
  ext2_init();
  int i = ext2_open("/home/barracuda/help.txt", 0);
  if (i < 0)
    return 0;
  char *buf = malloc(1024);
  int j; int k;
  for(j = 0; j < 512; j++)
  {
    if((k = ext2_read(i, buf, 2)) == 0)
      break;
    buf[k] = 0;
    printf("%s", buf);
  }
  free(buf);
  ext2_close(i);
  ext2_fini();
}

variable_types: i int

variable_types:
buf
char *

variable_types: j int

variable_types: k int


decompiled_code:
int ext2_init()
{
FILE *v0; // rax
FILE *v1; // rbx
char *v2; // rbp
_BYTE *v3; // rdx
int v4; // eax
int v5; // ebx
void *v6; // rsi

v0 = fopen("disk.img", "rb");
f = v0;
if ( v0 )
{
v1 = v0;
v2 = (char *)malloc(0x1FEuLL);
fread(v2, 0x1FEuLL, 1uLL, v1);
v3 = v2 + 450;
v4 = 0;
while ( *v3 != 0x83 )
{
++v4;
v3 += 16;
if ( v4 == 4 )
{
free(v2);
LODWORD(v0) = puts("No linux partition found!");
return (int)v0;
}
}
start = *(_DWORD *)&v2[16 * v4 + 454] << 9;
v5 = start;
free(v2);
fseek(f, (unsigned int)(v5 + 1024), 0);
super = malloc(0x400uLL);
fread(super, 0x400uLL, 1uLL, f);
v6 = &unk_402020;
if ( *((_WORD *)super + 28) != 0xEF53 )
v6 = &unk_402025;
printf(&byte_402052, v6);
printf(&byte_402063, *((unsigned int *)super + 19), *((unsigned __int16 *)super + 31));
printf(&byte_40207C, (unsigned int)(1024 << *((_DWORD *)super + 6)));
printf(&byte_402098, *((unsigned __int16 *)super + 44));
printf(&byte_4020B0, *((unsigned int *)super + 8));
printf(&byte_4020E8, *((unsigned int *)super + 10));
LODWORD(v0) = printf(&byte_402120, *((unsigned int *)super + 5));
}
return (int)v0;
}

canonical_decompiled_code:
int func7()
{
FILE *v0; // rax
FILE *v1; // rbx
char *v2; // rbp
_BYTE *v3; // rdx
int v4; // eax
int v5; // ebx
void *v6; // rsi

v0 = fopen("disk.img", "rb");
f = v0;
if ( v0 )
{
v1 = v0;
v2 = (char *)malloc(0x1FEuLL);
fread(v2, 0x1FEuLL, 1uLL, v1);
v3 = v2 + 450;
v4 = 0;
while ( *v3 != 0x83 )
{
++v4;
v3 += 16;
if ( v4 == 4 )
{
free(v2);
LODWORD(v0) = puts("No linux partition found!");
return (int)v0;
}
}
start = *(_DWORD *)&v2[16 * v4 + 454] << 9;
v5 = start;
free(v2);
fseek(f, (unsigned int)(v5 + 1024), 0);
super = malloc(0x400uLL);
fread(super, 0x400uLL, 1uLL, f);
v6 = &unk_402020;
if ( *((_WORD *)super + 28) != 0xEF53 )
v6 = &unk_402025;
printf(&byte_402052, v6);
printf(&byte_402063, *((unsigned int *)super + 19), *((unsigned __int16 *)super + 31));
printf(&byte_40207C, (unsigned int)(1024 << *((_DWORD *)super + 6)));
printf(&byte_402098, *((unsigned __int16 *)super + 44));
printf(&byte_4020B0, *((unsigned int *)super + 8));
printf(&byte_4020E8, *((unsigned int *)super + 10));
LODWORD(v0) = printf(&byte_402120, *((unsigned int *)super + 5));
}
return (int)v0;
}

original_code:
void ext2_init( void )
{
  f = fopen("disk.img", "rb");
  if (!f)
    return;
  part *p = malloc(sizeof(part));
  fread(p, sizeof(part), 1, f);
  int i;
  for ( i = 0; i < 4; i++)
  {
    if ( p->parts[i].type == 0x83 )
      break;
  }
  if ( i == 4 )
  {
    free(p);
    printf("No linux partition found!\n");
    return;
  }
  start = (p->parts[i].first_sector<<9);
  free(p);
  fseek(f, start + 0x400, 0);
  super = malloc(sizeof(ext2_superblock));
  fread(super, sizeof(ext2_superblock), 1, f);
  printf("Это EXT2? %s\n", super->magic == 0xEF53 ? "Да" : "Нет");
  printf("Версия ФС %d.%d\n", super->ver_major, super->ver_minor);
  printf("Размер блока %d\n", 1024<<super->block_size);
  printf("Размер inode %d\n", super->inode_size);
  printf("Количество блоков в группе - %d\n", super->blk_in_grp);
  printf("Количество inode в группе - %d\n", super->ind_in_grp);
  printf("Номер блока, содержащего суперблок - %d\n", super->sblock_num);
}

canonical_original_code:
void ext2_init()
{
  f = fopen("disk.img", "rb");
  if (!f)
    return;
  struct part *p = malloc(sizeof(part));
  fread(p, sizeof(part), 1, f);
  int i;
  for ( i = 0; i < 4; i++)
  {
    if ( p->parts[i].type == 0x83 )
      break;
  }
  if ( i == 4 )
  {
    free(p);
    printf("No linux partition found!\n");
    return;
  }
  start = (p->parts[i].first_sector<<9);
  free(p);
  fseek(f, start + 0x400, 0);
  super = malloc(sizeof(ext2_superblock));
  fread(super, sizeof(ext2_superblock), 1, f);
  printf("Это EXT2? %s\n", super->magic == 0xEF53 ? "Да" : "Нет");
  printf("Версия ФС %d.%d\n", super->ver_major, super->ver_minor);
  printf("Размер блока %d\n", 1024<<super->block_size);
  printf("Размер inode %d\n", super->inode_size);
  printf("Количество блоков в группе - %d\n", super->blk_in_grp);
  printf("Количество inode в группе - %d\n", super->ind_in_grp);
  printf("Номер блока, содержащего суперблок - %d\n", super->sblock_num);
}

variable_types: struct part { char bootldr[446]; struct partition { unsigned char active; unsigned char s_head; unsigned short s_sector; unsigned short s_track; unsigned char type; unsigned char e_head; unsigned short e_sector; unsigned short e_track; unsigned int first_sector; unsigned int num_sectors; } parts[4]; } *

user_defined_types: struct part { char bootldr[446]; struct partition parts[4]; }


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

if ( start )
{
free(super);
result = fclose(f);
}
return result;
}

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

if ( start )
{
free(super);
result = fclose(f);
}
return result;
}

original_code:
void ext2_fini( void )
{
  if (!start)
    return;
  free(super);
  fclose(f);
}

canonical_original_code:
void ext2_fini()
{
  if (!start)
    return;
  free(super);
  fclose(f);
}


decompiled_code:
void *__fastcall ext2_read_inode(int a1)
{
_DWORD *v1; // rbx
unsigned int v2; // er13
unsigned int v3; // er12
unsigned __int16 v4; // bx
void *v5; // rbp
_DWORD *v7; // r14

v1 = super;
v2 = (unsigned int)(a1 - 1) % *((_DWORD *)super + 10);
v3 = (unsigned int)(a1 - 1) / *((_DWORD *)super + 10);
if ( !i_start[v3] )
{
v7 = malloc(0x20uLL);
fseek(f, 32LL * v3 + (unsigned int)(start + (v1[5] + 1) * (1024 << v1[6])), 0);
fread(v7, 0x20uLL, 1uLL, f);
i_start[v3] = v7[2] * (1024 << *((_DWORD *)super + 6));
free(v7);
}
v4 = *((_WORD *)super + 44);
v5 = malloc(v4);
fseek(f, start + i_start[v3] + v2 * v4, 0);
fread(v5, *((unsigned __int16 *)super + 44), 1uLL, f);
return v5;
}

canonical_decompiled_code:
void *__fastcall func9(int a1)
{
_DWORD *v1; // rbx
unsigned int v2; // er13
unsigned int v3; // er12
unsigned __int16 v4; // bx
void *v5; // rbp
_DWORD *v7; // r14

v1 = super;
v2 = (unsigned int)(a1 - 1) % *((_DWORD *)super + 10);
v3 = (unsigned int)(a1 - 1) / *((_DWORD *)super + 10);
if ( !i_start[v3] )
{
v7 = malloc(0x20uLL);
fseek(f, 32LL * v3 + (unsigned int)(start + (v1[5] + 1) * (1024 << v1[6])), 0);
fread(v7, 0x20uLL, 1uLL, f);
i_start[v3] = v7[2] * (1024 << *((_DWORD *)super + 6));
free(v7);
}
v4 = *((_WORD *)super + 44);
v5 = malloc(v4);
fseek(f, start + i_start[v3] + v2 * v4, 0);
fread(v5, *((unsigned __int16 *)super + 44), 1uLL, f);
return v5;
}

original_code:
ext2_inode *ext2_read_inode(uint32_t inode)
{
  uint32_t bg = (inode-1)/(super->ind_in_grp);
  uint32_t id = (inode-1)%(super->ind_in_grp);
  if (i_start[bg] == 0)
  {
    ext2_group_desc *desc = malloc(sizeof(ext2_group_desc));
    fseek(f,
          start + (1024<<super->block_size)*(super->sblock_num+1) +
             bg*sizeof(ext2_group_desc),
          0);
    fread(desc, sizeof(ext2_group_desc), 1, f);
    i_start[bg] = desc->inode_st*(1024<<super->block_size);
    free(desc);
  }
  ext2_inode *in = malloc(super->inode_size);
  fseek(f, i_start[bg] + start + (id*super->inode_size), 0);
  fread(in, super->inode_size, 1, f);
  return in;
}

canonical_original_code:
struct ext2_inode *ext2_read_inode(unsigned int inode)
{
  unsigned int bg = (inode-1)/(super->ind_in_grp);
  unsigned int id = (inode-1)%(super->ind_in_grp);
  if (i_start[bg] == 0)
  {
    struct ext2_group_desc *desc = malloc(sizeof(ext2_group_desc));
    fseek(f,
          start + (1024<<super->block_size)*(super->sblock_num+1) +
             bg*sizeof(ext2_group_desc),
          0);
    fread(desc, sizeof(ext2_group_desc), 1, f);
    i_start[bg] = desc->inode_st*(1024<<super->block_size);
    free(desc);
  }
  struct ext2_inode *in = malloc(super->inode_size);
  fseek(f, i_start[bg] + start + (id*super->inode_size), 0);
  fread(in, super->inode_size, 1, f);
  return in;
}

variable_types:
inode
unsigned int

variable_types:
bg
unsigned int

variable_types:
id
unsigned int

variable_types: struct ext2_group_desc { unsigned int block_bmp; unsigned int inode_bmp; unsigned int inode_st; unsigned short free_blk; unsigned short free_ino; unsigned short dir_num; unsigned char unused[14]; } *

variable_types: struct ext2_inode { unsigned short type_perm; unsigned short uid; unsigned int size_low; unsigned int acc_time; unsigned int cre_time; unsigned int mod_time; unsigned int del_time; unsigned short gid; unsigned short links; unsigned int sectors; unsigned int flags; unsigned int oss_value1; unsigned int direct[12]; unsigned int s_indirect; unsigned int d_indirect; unsigned int t_indirect; unsigned int generation; unsigned int file_acl; union { unsigned int size_hi; unsigned int dir_acl; }; unsigned int frag_addr; unsigned char frag_num; unsigned char frag_size; unsigned short rsrvd1; unsigned short uid_hi; unsigned short gid_hi; unsigned int rsrvd2; } *


decompiled_code:
char *__fastcall ext2_read_inode_data(__int64 a1)
{
int *v1; // rbp
int i; // er14
int v3; // er13
_DWORD *v4; // r15
char *ptr; // [rsp+8h] [rbp-40h]

v1 = (int *)(a1 + 40);
ptr = 0LL;
for ( i = 0; ; ++i )
{
v3 = *v1;
if ( !*v1 )
break;
v4 = super;
ptr = (char *)realloc(ptr, (i + 1) * (1024 << *((_DWORD *)super + 6)));
fseek(f, (unsigned int)(start + v3 * (1024 << v4[6])), 0);
fread(&ptr[i * (1024 << *((_DWORD *)super + 6))], 1024 << *((_DWORD *)super + 6), 1uLL, f);
++v1;
if ( i == 11 )
break;
}
return ptr;
}

original_code:
char *ext2_read_inode_data(ext2_inode *in)
{
  int sz = 0;
  char *data = 0;
  for (sz = 0; sz < 12; sz++)
  {
    if (in->direct[sz] == 0)
      break;
    data = realloc(data, (sz + 1)*(1024<<super->block_size));
    fseek(f, start + in->direct[sz]*(1024<<super->block_size), 0);
    fread(data + sz*(1024<<super->block_size), 1024<<super->block_size, 1, f);
  }
  return data;
}

canonical_original_code:
char *ext2_read_inode_data(struct ext2_inode *in)
{
  int sz = 0;
  char *data = 0;
  for (sz = 0; sz < 12; sz++)
  {
    if (in->direct[sz] == 0)
      break;
    data = realloc(data, (sz + 1)*(1024<<super->block_size));
    fseek(f, start + in->direct[sz]*(1024<<super->block_size), 0);
    fread(data + sz*(1024<<super->block_size), 1024<<super->block_size, 1, f);
  }
  return data;
}

variable_types: sz int

variable_types:
data
char *

return_type: char *

user_defined_types: struct ext2_inode { unsigned short type_perm; unsigned short uid; unsigned int size_low; unsigned int acc_time; unsigned int cre_time; unsigned int mod_time; unsigned int del_time; unsigned short gid; unsigned short links; unsigned int sectors; unsigned int flags; unsigned int oss_value1; unsigned int direct[12]; unsigned int s_indirect; unsigned int d_indirect; unsigned int t_indirect; unsigned int generation; unsigned int file_acl; union { unsigned int size_hi; unsigned int dir_acl; }; unsigned int frag_addr; unsigned char frag_num; unsigned char frag_size; unsigned short rsrvd1; unsigned short uid_hi; unsigned short gid_hi; unsigned int rsrvd2; }


original_code:
int ext2_open(const char *path, int flags)
{
  if (!start)
    return;
  printf("Попытка открыть %s\n", path);
  int i;
  for (i = 0; (i < 1024) && (open_files[i] != 0xFFFFFFFF); i++);
  if (i == 1024)
    return -2;
  int inode = 2;
  int our_inode = 0;
  while (our_inode == 0)
  {
    ext2_inode *in = ext2_read_inode(inode);
    if ((in->type_perm&EXT2_INODE_DIR) != EXT2_INODE_DIR)
    {
      free(in);
      return -4;
    }
    while (*path == '/') path++;
    int s = 0;
    while ((path[s] != '/') && (path[s] != 0)) s++;
    char *data = ext2_read_inode_data(in);
    ext2_direntry *dirent = 0;
    char *data2 = data;
    inode = 0;
    for (; (data2 - data) < in->size_low; data2 += dirent->size)
    {
      dirent = (ext2_direntry *)data2;
      if (dirent->lenght == 0)
      {
        break;
      }
      if (!strncmp(dirent->name, path, s))
      {
        if (path[s] == '/')
        {
          inode = dirent->inode;
        } else {
          our_inode = dirent->inode;
        }
        break;
      }
    }
    free(in);
    free(data);
    if ((inode == 0)&&(our_inode == 0))
      return -3;
    path += s;
  }
  open_files[i] = 0;
  file_inodes[i] = our_inode;
  return i;
}

canonical_original_code:
int ext2_open(char *path, int flags)
{
  if (!start)
    return;
  printf("Попытка открыть %s\n", path);
  int i;
  for (i = 0; (i < 1024) && (open_files[i] != 0xFFFFFFFF); i++);
  if (i == 1024)
    return -2;
  int inode = 2;
  int our_inode = 0;
  while (our_inode == 0)
  {
    struct ext2_inode *in = ext2_read_inode(inode);
    if ((in->type_perm&EXT2_INODE_DIR) != EXT2_INODE_DIR)
    {
      free(in);
      return -4;
    }
    while (*path == '/') path++;
    int s = 0;
    while ((path[s] != '/') && (path[s] != 0)) s++;
    char *data = ext2_read_inode_data(in);
    struct ext2_direntry *dirent = 0;
    char *data2 = data;
    inode = 0;
    for (; (data2 - data) < in->size_low; data2 += dirent->size)
    {
      dirent = (struct ext2_direntry *)data2;
      if (dirent->lenght == 0)
      {
        break;
      }
      if (!strncmp(dirent->name, path, s))
      {
        if (path[s] == '/')
        {
          inode = dirent->inode;
        } else {
          our_inode = dirent->inode;
        }
        break;
      }
    }
    free(in);
    free(data);
    if ((inode == 0)&&(our_inode == 0))
      return -3;
    path += s;
  }
  open_files[i] = 0;
  file_inodes[i] = our_inode;
  return i;
}

variable_types:
path
char *

variable_types: flags int

variable_types: inode int

variable_types: s int

variable_types: struct ext2_direntry { unsigned int inode; unsigned short size; unsigned char lenght; union { unsigned char lenght_hi; unsigned char type; }; char name[]; } *


decompiled_code:
__int64 __fastcall ext2_read(int a1, __int64 a2, unsigned __int64 a3)
{
unsigned __int64 v3; // rbx
__int64 result; // rax
unsigned int v5; // er12
int v6; // edi
unsigned int v7; // eax
unsigned __int64 v8; // rcx
unsigned __int64 v9; // rax
int v10; // ecx
unsigned int v11; // er13
int v12; // er14
__int64 v13; // r14
int v14; // edx
int v15; // eax
int v16; // ebp
unsigned int v17; // ecx
bool v18; // dl
_DWORD *ptr; // [rsp+8h] [rbp-50h]

if ( !start )
return -6LL;
v3 = a3;
result = 0LL;
if ( a3 )
{
if ( a1 > 1024 )
{
result = -5LL;
}
else
{
v5 = open_files[a1];
if ( v5 == -1 )
{
result = -5LL;
}
else
{
v6 = file_inodes[a1];
if ( v6 == -1 )
{
result = -5LL;
}
else if ( a2 )
{
ptr = ext2_read_inode(v6);
v7 = ptr[1];
if ( v5 >= v7 )
{
free(ptr);
result = 0LL;
}
else
{
v8 = v7;
v9 = v7 - v5;
if ( v3 + v5 > v8 )
v3 = v9;
v10 = *((_DWORD *)super + 6);
v11 = 0;
if ( v5 < 12 * (1024 << v10) )
{
v12 = v5 >> (v10 + 10);
if ( v12 <= 11 && v3 )
{
v13 = v12 + 1;
do
{
v14 = 1024 << *((_DWORD *)super + 6);
v15 = v5 & (v14 - 1);
v16 = v14 - v15;
v17 = v14;
if ( v14 > v3 )
v17 = v3;
if ( v16 > v17 )
v16 = v17;
fseek(f, (unsigned int)(ptr[v13 + 9] * v14 + start + v15), 0);
fread((void *)(a2 + v11), v16, 1uLL, f);
v11 += v16;
v5 += v16;
v18 = (int)v13 <= 11;
v3 -= v16;
++v13;
}
while ( v3 != 0 && v18 );
}
else
{
v11 = 0;
}
}
free(ptr);
open_files[a1] = v5;
result = v11;
}
}
else
{
result = -6LL;
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(int a1, __int64 a2, unsigned __int64 a3)
{
unsigned __int64 v3; // rbx
__int64 result; // rax
unsigned int v5; // er12
int v6; // edi
unsigned int v7; // eax
unsigned __int64 v8; // rcx
unsigned __int64 v9; // rax
int v10; // ecx
unsigned int v11; // er13
int v12; // er14
__int64 v13; // r14
int v14; // edx
int v15; // eax
int v16; // ebp
unsigned int v17; // ecx
bool v18; // dl
_DWORD *ptr; // [rsp+8h] [rbp-50h]

if ( !start )
return -6LL;
v3 = a3;
result = 0LL;
if ( a3 )
{
if ( a1 > 1024 )
{
result = -5LL;
}
else
{
v5 = open_files[a1];
if ( v5 == -1 )
{
result = -5LL;
}
else
{
v6 = file_inodes[a1];
if ( v6 == -1 )
{
result = -5LL;
}
else if ( a2 )
{
ptr = func9(v6);
v7 = ptr[1];
if ( v5 >= v7 )
{
free(ptr);
result = 0LL;
}
else
{
v8 = v7;
v9 = v7 - v5;
if ( v3 + v5 > v8 )
v3 = v9;
v10 = *((_DWORD *)super + 6);
v11 = 0;
if ( v5 < 12 * (1024 << v10) )
{
v12 = v5 >> (v10 + 10);
if ( v12 <= 11 && v3 )
{
v13 = v12 + 1;
do
{
v14 = 1024 << *((_DWORD *)super + 6);
v15 = v5 & (v14 - 1);
v16 = v14 - v15;
v17 = v14;
if ( v14 > v3 )
v17 = v3;
if ( v16 > v17 )
v16 = v17;
fseek(f, (unsigned int)(ptr[v13 + 9] * v14 + start + v15), 0);
fread((void *)(a2 + v11), v16, 1uLL, f);
v11 += v16;
v5 += v16;
v18 = (int)v13 <= 11;
v3 -= v16;
++v13;
}
while ( v3 != 0 && v18 );
}
else
{
v11 = 0;
}
}
free(ptr);
open_files[a1] = v5;
result = v11;
}
}
else
{
result = -6LL;
}
}
}
}
return result;
}

original_code:
ssize_t ext2_read( int fd, void *buf, size_t count )
{
  if (!start)
    return -6;
  if (count == 0)
    return 0;
  if(fd > 1024)
    return -5;
  if((open_files[fd] == 0xFFFFFFFF) ||
     (file_inodes[fd] == 0xFFFFFFFF))
    return -5;
  if(buf == ((void *)0))
    return -6;
  uint32_t pos = open_files[fd];
  ext2_inode *in = ext2_read_inode(file_inodes[fd]);
  if(pos >= in->size_low)
  {
    free(in);
    return 0;
  }
  if((pos + count) > in->size_low)
  {
    count = in->size_low - pos;
  }
  uint32_t cnt = 0;
  char *data = (char *)buf;
  if (pos < (1024<<super->block_size)*12)
  {
    int i = pos>>(10+super->block_size);
    int k;
    for(; (i < 12) && (count > 0); i++)
    {
      k = (count > (1024<<super->block_size) ? (1024<<super->block_size) : count);
      k = k > ((1024<<super->block_size) - (pos%(1024<<super->block_size))) ?
        ((1024<<super->block_size) - (pos%(1024<<super->block_size))) : k;
      fseek(f,
            start + in->direct[i]*(1024<<super->block_size) + (pos%(1024<<super->block_size)),
            0);
      fread(data + cnt,
            k,
            1,
            f);
      cnt += k;
      count -= k;
      pos += k;
    }
  }
  free(in);
  open_files[fd] = pos;
  return cnt;
}

canonical_original_code:
long ext2_read(int fd, void *buf, unsigned long count)
{
  if (!start)
    return -6;
  if (count == 0)
    return 0;
  if(fd > 1024)
    return -5;
  if((open_files[fd] == 0xFFFFFFFF) ||
     (file_inodes[fd] == 0xFFFFFFFF))
    return -5;
  if(buf == ((void *)0))
    return -6;
  unsigned int pos = open_files[fd];
  struct ext2_inode *in = ext2_read_inode(file_inodes[fd]);
  if(pos >= in->size_low)
  {
    free(in);
    return 0;
  }
  if((pos + count) > in->size_low)
  {
    count = in->size_low - pos;
  }
  unsigned int cnt = 0;
  char *data = (char *)buf;
  if (pos < (1024<<super->block_size)*12)
  {
    int i = pos>>(10+super->block_size);
    int k;
    for(; (i < 12) && (count > 0); i++)
    {
      k = (count > (1024<<super->block_size) ? (1024<<super->block_size) : count);
      k = k > ((1024<<super->block_size) - (pos%(1024<<super->block_size))) ?
        ((1024<<super->block_size) - (pos%(1024<<super->block_size))) : k;
      fseek(f,
            start + in->direct[i]*(1024<<super->block_size) + (pos%(1024<<super->block_size)),
            0);
      fread(data + cnt,
            k,
            1,
            f);
      cnt += k;
      count -= k;
      pos += k;
    }
  }
  free(in);
  open_files[fd] = pos;
  return cnt;
}

variable_types: fd int

variable_types:
buf
void *

variable_types:
count
unsigned long

variable_types:
pos
unsigned int

variable_types:
cnt
unsigned int

variable_types: i int

return_type: long


decompiled_code:
__int64 ext2_write()
{
return -6LL;
}

canonical_decompiled_code:
__int64 func13()
{
return -6LL;
}

original_code:
ssize_t ext2_write( int fd, const void *buf, size_t count )
{
  return -6;
}

canonical_original_code:
long ext2_write(int fd, void *buf, unsigned long count)
{
  return -6;
}


decompiled_code:
__int64 __fastcall ext2_close(int a1)
{
if ( !start )
return 4294967290LL;
if ( a1 > 1024 )
return 4294967291LL;
if ( open_files[a1] == -1 )
return 4294967291LL;
if ( file_inodes[a1] == -1 )
return 4294967291LL;
open_files[a1] = -1;
file_inodes[a1] = -1;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func14(int a1)
{
if ( !start )
return 4294967290LL;
if ( a1 > 1024 )
return 4294967291LL;
if ( open_files[a1] == -1 )
return 4294967291LL;
if ( file_inodes[a1] == -1 )
return 4294967291LL;
open_files[a1] = -1;
file_inodes[a1] = -1;
return 0LL;
}

original_code:
int ext2_close( int fd )
{
  if (!start)
    return -6;
  if(fd > 1024)
    return -5;
  if((open_files[fd] == 0xFFFFFFFF) ||
     (file_inodes[fd] == 0xFFFFFFFF))
    return -5;
  open_files[fd] = 0xFFFFFFFF;
  file_inodes[fd] = 0xFFFFFFFF;
  return 0;
}

canonical_original_code:
int ext2_close(int fd)
{
  if (!start)
    return -6;
  if(fd > 1024)
    return -5;
  if((open_files[fd] == 0xFFFFFFFF) ||
     (file_inodes[fd] == 0xFFFFFFFF))
    return -5;
  open_files[fd] = 0xFFFFFFFF;
  file_inodes[fd] = 0xFFFFFFFF;
  return 0;
}


decompiled_code:
__int64 __fastcall ext2_lseek(int a1, unsigned int a2, unsigned int a3)
{
unsigned int v5; // ebp
int v6; // edi
_DWORD *v7; // rax
__int64 result; // rax

if ( !start )
return -6LL;
if ( a1 > 1024 )
return -5LL;
v5 = open_files[a1];
if ( v5 == -1 )
return -5LL;
v6 = file_inodes[a1];
if ( v6 == -1 )
return -5LL;
if ( a3 > 2 )
return -6LL;
v7 = ext2_read_inode(v6);
if ( a3 )
{
if ( a3 == 1 )
{
v5 += a2;
}
else if ( a3 == 2 )
{
v5 = v7[1] + a2;
}
}
else
{
v5 = a2;
}
if ( v7[1] < v5 )
{
free(v7);
result = -6LL;
}
else
{
free(v7);
open_files[a1] = v5;
result = v5;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func15(int a1, unsigned int a2, unsigned int a3)
{
unsigned int v5; // ebp
int v6; // edi
_DWORD *v7; // rax
__int64 result; // rax

if ( !start )
return -6LL;
if ( a1 > 1024 )
return -5LL;
v5 = open_files[a1];
if ( v5 == -1 )
return -5LL;
v6 = file_inodes[a1];
if ( v6 == -1 )
return -5LL;
if ( a3 > 2 )
return -6LL;
v7 = func9(v6);
if ( a3 )
{
if ( a3 == 1 )
{
v5 += a2;
}
else if ( a3 == 2 )
{
v5 = v7[1] + a2;
}
}
else
{
v5 = a2;
}
if ( v7[1] < v5 )
{
free(v7);
result = -6LL;
}
else
{
free(v7);
open_files[a1] = v5;
result = v5;
}
return result;
}

original_code:
off_t ext2_lseek( int fd, off_t offset, int whence )
{
  if (!start)
    return -6;
  if(fd > 1024)
    return -5;
  if((open_files[fd] == 0xFFFFFFFF) ||
     (file_inodes[fd] == 0xFFFFFFFF))
    return -5;
  if( (whence != 1)
     && (whence != 0)
     && (whence != 2))
    return -6;
  uint32_t pos = open_files[fd];
  ext2_inode *in = ext2_read_inode(file_inodes[fd]);
  if (whence == 0)
    pos = offset;
  if (whence == 1)
    pos += offset;
  if (whence == 2)
    pos = offset + in->size_low;
  if ((pos > in->size_low) || (pos < 0))
  {
    free(in);
    return -6;
  }
  free(in);
  open_files[fd] = pos;
  return pos;
}

canonical_original_code:
long ext2_lseek(int fd, long offset, int whence)
{
  if (!start)
    return -6;
  if(fd > 1024)
    return -5;
  if((open_files[fd] == 0xFFFFFFFF) ||
     (file_inodes[fd] == 0xFFFFFFFF))
    return -5;
  if( (whence != 1)
     && (whence != 0)
     && (whence != 2))
    return -6;
  unsigned int pos = open_files[fd];
  struct ext2_inode *in = ext2_read_inode(file_inodes[fd]);
  if (whence == 0)
    pos = offset;
  if (whence == 1)
    pos += offset;
  if (whence == 2)
    pos = offset + in->size_low;
  if ((pos > in->size_low) || (pos < 0))
  {
    free(in);
    return -6;
  }
  free(in);
  open_files[fd] = pos;
  return pos;
}

variable_types: offset long

variable_types: whence int


decompiled_code:
__int64 __fastcall parse_factor(__int64 a1, __int64 a2)
{
return parser_exec(parser_start_factor, a1, a2, int_parse_factor, "factor");
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
return parser_exec(parser_start_factor, a1, a2, int_parse_factor, "factor");
}

original_code: void *parse_factor (unsigned long *folls, unsigned long *ex) { return parser_exec(parser_start_factor, folls, ex, int_parse_factor, parser_name_factor); }

canonical_original_code: void *parse_factor(unsigned long *folls, unsigned long *ex) { return parser_exec(parser_start_factor, folls, ex, int_parse_factor, parser_name_factor); }

variable_types:
folls
unsigned long *

variable_types:
ex
unsigned long *

return_type: void *


decompiled_code:
__int64 __fastcall int_parse_term(__int64 a1, __int64 a2)
{
void *v2; // r12
__int64 i; // rbp
unsigned int v4; // ebx
socklen_t *v5; // rdx
__int64 v6; // rax
struct sockaddr *v7; // rbx
int v8; // eax
struct sockaddr *v9; // rsi

v2 = (void *)balloc();
bits_disjunct(a1, parser_ops_mult, v2);
for ( i = parse_factor((__int64)v2, a2); ; i = mix_types(i, v6, v4) )
{
v7 = (struct sockaddr *)parser_ops_mult;
v8 = lex_get_s();
v9 = v7;
if ( !(unsigned int)bits_belong(v8, v7) )
break;
v4 = lex_get_s();
sem_l = syn_line;
sem_c = syn_c;
accept(v4, v9, v5);
v6 = parse_factor((__int64)v2, 0LL);
}
free(v2);
return i;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2)
{
void *v2; // r12
__int64 i; // rbp
unsigned int v4; // ebx
socklen_t *v5; // rdx
__int64 v6; // rax
struct sockaddr *v7; // rbx
int v8; // eax
struct sockaddr *v9; // rsi

v2 = (void *)balloc();
bits_disjunct(a1, parser_ops_mult, v2);
for ( i = func0((__int64)v2, a2); ; i = mix_types(i, v6, v4) )
{
v7 = (struct sockaddr *)parser_ops_mult;
v8 = lex_get_s();
v9 = v7;
if ( !(unsigned int)bits_belong(v8, v7) )
break;
v4 = lex_get_s();
sem_l = syn_line;
sem_c = syn_c;
accept(v4, v9, v5);
v6 = func0((__int64)v2, 0LL);
}
free(v2);
return i;
}

original_code:
void *int_parse_term (unsigned long *folls, unsigned long *ex)
{
    unsigned long *tmp = balloc();
    bits_disjunct(folls, parser_ops_mult, tmp);
    type_table_elem *tp1, *tp2;
    tp1 = parse_factor(tmp, ex);
    while (bits_belong(lex_get_s(), parser_ops_mult))
    {
        int c = lex_get_s();
        sem_l = syn_line;
        sem_c = syn_c;
        accept(c);
        tp2 = parse_factor(tmp, 0);
        tp1 = mix_types(tp1, tp2, c);
    }
    free(tmp);
    return tp1;
}

canonical_original_code:
void *int_parse_term(unsigned long *folls, unsigned long *ex)
{
    unsigned long *tmp = balloc();
    bits_disjunct(folls, parser_ops_mult, tmp);
    struct _type_table_elem *tp1; struct _type_table_elem *tp2;
    tp1 = parse_factor(tmp, ex);
    while (bits_belong(lex_get_s(), parser_ops_mult))
    {
        int c = lex_get_s();
        sem_l = syn_line;
        sem_c = syn_c;
        accept(c);
        tp2 = parse_factor(tmp, 0);
        tp1 = mix_types(tp1, tp2, c);
    }
    free(tmp);
    return tp1;
}

variable_types:
tmp
unsigned long *

variable_types: struct _type_table_elem { enum USE_TYPE { UT_SCALAR=5000, UT_LIMITED=5001, UT_ENUM=5002, UT_ARRAY=5003, UT_RECORD=5004, UT_REFERENCE=5005, UT_SET=5006, UT_FILE=5007 } utype; struct _type_table_elem *base; union { struct _list { void *value; struct _list *next; } *constants; struct _list *indexes; struct { unsigned long min; }; }; } *

variable_types: c int

user_defined_types: struct _type_table_elem { enum USE_TYPE utype; struct _type_table_elem *base; union { struct _list *constants; struct _list *indexes; struct { unsigned long min; }; }; }


decompiled_code:
__int64 __fastcall parse_term(__int64 a1, __int64 a2)
{
return parser_exec(parser_start_term, a1, a2, int_parse_term, "term");
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
return parser_exec(parser_start_term, a1, a2, int_parse_term, "term");
}

original_code: void *parse_term (unsigned long *folls, unsigned long *ex) { return parser_exec(parser_start_term, folls, ex, int_parse_term, parser_name_term); }

canonical_original_code: void *parse_term(unsigned long *folls, unsigned long *ex) { return parser_exec(parser_start_term, folls, ex, int_parse_term, parser_name_term); }


decompiled_code:
__int64 __fastcall int_parse_simple_expr(__int64 a1, struct sockaddr *a2)
{
void *v2; // r12
__int64 v3; // rbp
int v4; // eax
socklen_t *v5; // rdx
__int64 v6; // r13
__int64 v7; // rax
unsigned int v8; // ebx
socklen_t *v9; // rdx
__int64 v10; // rsi
struct sockaddr *v11; // rbx
__int64 v12; // rdi
struct sockaddr *v13; // rsi

sem_l = syn_line;
sem_c = syn_c;
if ( (unsigned int)lex_get_s() == 43 || (unsigned int)lex_get_s() == 45 )
{
v4 = lex_get_s();
accept(v4, a2, v5);
v6 = inttype;
v2 = (void *)balloc();
bits_disjunct(a1, parser_ops_add, v2);
v7 = parse_term((__int64)v2, (__int64)a2);
v3 = v7;
if ( v6 )
v3 = mix_types(v7, v6, 43LL);
}
else
{
v2 = (void *)balloc();
bits_disjunct(a1, parser_ops_add, v2);
v3 = parse_term((__int64)v2, (__int64)a2);
}
while ( 1 )
{
v11 = (struct sockaddr *)parser_ops_add;
v12 = (int)lex_get_s();
v13 = v11;
if ( !(unsigned int)bits_belong(v12, v11) )
break;
v8 = lex_get_s();
sem_l = syn_line;
sem_c = syn_c;
accept(v8, v13, v9);
v10 = parse_term((__int64)v2, 0LL);
v3 = mix_types(v3, v10, v8);
}
free(v2);
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, struct sockaddr *a2)
{
void *v2; // r12
__int64 v3; // rbp
int v4; // eax
socklen_t *v5; // rdx
__int64 v6; // r13
__int64 v7; // rax
unsigned int v8; // ebx
socklen_t *v9; // rdx
__int64 v10; // rsi
struct sockaddr *v11; // rbx
__int64 v12; // rdi
struct sockaddr *v13; // rsi

sem_l = syn_line;
sem_c = syn_c;
if ( (unsigned int)lex_get_s() == 43 || (unsigned int)lex_get_s() == 45 )
{
v4 = lex_get_s();
accept(v4, a2, v5);
v6 = inttype;
v2 = (void *)balloc();
bits_disjunct(a1, parser_ops_add, v2);
v7 = func2((__int64)v2, (__int64)a2);
v3 = v7;
if ( v6 )
v3 = mix_types(v7, v6, 43LL);
}
else
{
v2 = (void *)balloc();
bits_disjunct(a1, parser_ops_add, v2);
v3 = func2((__int64)v2, (__int64)a2);
}
while ( 1 )
{
v11 = (struct sockaddr *)parser_ops_add;
v12 = (int)lex_get_s();
v13 = v11;
if ( !(unsigned int)bits_belong(v12, v11) )
break;
v8 = lex_get_s();
sem_l = syn_line;
sem_c = syn_c;
accept(v8, v13, v9);
v10 = func2((__int64)v2, 0LL);
v3 = mix_types(v3, v10, v8);
}
free(v2);
return v3;
}

original_code:
void *int_parse_simple_expr (unsigned long *folls, unsigned long *ex)
{
    type_table_elem *tp1 = 0, *tp2 = 0;
    sem_l = syn_line;
    sem_c = syn_c;
    if ((lex_get_s() == L_PLUS) || (lex_get_s() == L_MINUS))
    {
        accept(lex_get_s());
        tp2 = inttype;
    }
    unsigned long *tmp = balloc();
    bits_disjunct(folls, parser_ops_add, tmp);
    tp1 = parse_term(tmp, ex);
    if (tp2 != 0)
        tp1 = mix_types(tp1, tp2, L_PLUS);
    while (bits_belong(lex_get_s(), parser_ops_add))
    {
        int c = lex_get_s();
        sem_l = syn_line;
        sem_c = syn_c;
        accept(c);
        tp2 = parse_term(tmp, 0);
        tp1 = mix_types(tp1, tp2, c);
    }
    free(tmp);
    return tp1;
}

canonical_original_code:
void *int_parse_simple_expr(unsigned long *folls, unsigned long *ex)
{
    struct _type_table_elem *tp1 = 0; struct _type_table_elem *tp2 = 0;
    sem_l = syn_line;
    sem_c = syn_c;
    if ((lex_get_s() == L_PLUS) || (lex_get_s() == L_MINUS))
    {
        accept(lex_get_s());
        tp2 = inttype;
    }
    unsigned long *tmp = balloc();
    bits_disjunct(folls, parser_ops_add, tmp);
    tp1 = parse_term(tmp, ex);
    if (tp2 != 0)
        tp1 = mix_types(tp1, tp2, L_PLUS);
    while (bits_belong(lex_get_s(), parser_ops_add))
    {
        int c = lex_get_s();
        sem_l = syn_line;
        sem_c = syn_c;
        accept(c);
        tp2 = parse_term(tmp, 0);
        tp1 = mix_types(tp1, tp2, c);
    }
    free(tmp);
    return tp1;
}

user_defined_types: enum USE_TYPE { UT_SCALAR=5000, UT_LIMITED=5001, UT_ENUM=5002, UT_ARRAY=5003, UT_RECORD=5004, UT_REFERENCE=5005, UT_SET=5006, UT_FILE=5007 }

user_defined_types: struct _list { void *value; struct _list *next; }


decompiled_code:
__int64 __fastcall parse_simple_expr(__int64 a1, __int64 a2)
{
return parser_exec(parser_start_simple_expr, a1, a2, int_parse_simple_expr, "simple_expr");
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
return parser_exec(parser_start_simple_expr, a1, a2, int_parse_simple_expr, "simple_expr");
}

original_code: void *parse_simple_expr (unsigned long *folls, unsigned long *ex) { return parser_exec(parser_start_simple_expr, folls, ex, int_parse_simple_expr, parser_name_simple_expr); }

canonical_original_code: void *parse_simple_expr(unsigned long *folls, unsigned long *ex) { return parser_exec(parser_start_simple_expr, folls, ex, int_parse_simple_expr, parser_name_simple_expr); }