decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax
__int64 v4; // r12
__int64 v5; // r13
double *v6; // r14
double *v7; // r15
unsigned int v8; // er8
double v9; // xmm4_8
double *v10; // rbp
__int64 v11; // rbx
double v12; // xmm2_8
double v13; // xmm1_8
double v14; // xmm0_8
double v15; // xmm0_8
unsigned int nmemba; // [rsp+0h] [rbp-78h]
double *nmemb; // [rsp+0h] [rbp-78h]
unsigned int v18; // [rsp+Ch] [rbp-6Ch]
unsigned int v19; // [rsp+Ch] [rbp-6Ch]
double v20; // [rsp+18h] [rbp-60h]

if ( argc == 3 )
{
v4 = read_wave_file(argv[1], argv, envp);
nmemba = str2int(argv[2]);
print_wave_header(v4);
v5 = nmemba;
v18 = nmemba;
v6 = (double *)calloc(nmemba, 8uLL);
v7 = (double *)calloc(nmemba, 8uLL);
nmemb = (double *)calloc(nmemba, 0x10uLL);
if ( v7 == 0LL || v6 == 0LL || !nmemb )
{
fwrite(&unk_100, 1uLL, 0x1FuLL, stderr);
result = 1;
}
else
{
auto_dft(v6, v7, *(_QWORD *)(v4 + 48), 0LL);
v8 = v18;
v9 = (double)*(int *)(v4 + 24) / (double)(int)v5;
if ( v18 )
{
v10 = nmemb;
v11 = 0LL;
v12 = 0.0;
do
{
v13 = v7[v11] * v7[v11];
*v10 = (double)(int)v11 * v9;
v14 = v6[v11] * v6[v11] + v13;
if ( v14 < 0.0 )
{
v19 = v8;
v20 = v9;
v15 = sqrt(v14);
v9 = v20;
v8 = v19;
}
else
{
v15 = sqrt(v14);
}
v10[1] = v15;
++v11;
v10 += 2;
v12 = fmax(v15, v12);
}
while ( v5 != v11 );
}
if ( (unsigned int)show_gplot(nmemb, v8) == -1 )
{
fwrite(&unk_120, 1uLL, 0x20uLL, stderr);
fwrite(&unk_148, 1uLL, 0x3FuLL, stderr);
}
free(v6);
free(v7);
free(nmemb);
free_wave_data(v4);
result = 0;
}
}
else
{
fwrite("bad argument!\n", 1uLL, 0xEuLL, stderr);
result = 1;
}
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax
__int64 v4; // r12
__int64 v5; // r13
double *v6; // r14
double *v7; // r15
unsigned int v8; // er8
double v9; // xmm4_8
double *v10; // rbp
__int64 v11; // rbx
double v12; // xmm2_8
double v13; // xmm1_8
double v14; // xmm0_8
double v15; // xmm0_8
unsigned int nmemba; // [rsp+0h] [rbp-78h]
double *nmemb; // [rsp+0h] [rbp-78h]
unsigned int v18; // [rsp+Ch] [rbp-6Ch]
unsigned int v19; // [rsp+Ch] [rbp-6Ch]
double v20; // [rsp+18h] [rbp-60h]

if ( argc == 3 )
{
v4 = read_wave_file(argv[1], argv, envp);
nmemba = func0(argv[2]);
print_wave_header(v4);
v5 = nmemba;
v18 = nmemba;
v6 = (double *)calloc(nmemba, 8uLL);
v7 = (double *)calloc(nmemba, 8uLL);
nmemb = (double *)calloc(nmemba, 0x10uLL);
if ( v7 == 0LL || v6 == 0LL || !nmemb )
{
fwrite(&unk_100, 1uLL, 0x1FuLL, stderr);
result = 1;
}
else
{
auto_dft(v6, v7, *(_QWORD *)(v4 + 48), 0LL);
v8 = v18;
v9 = (double)*(int *)(v4 + 24) / (double)(int)v5;
if ( v18 )
{
v10 = nmemb;
v11 = 0LL;
v12 = 0.0;
do
{
v13 = v7[v11] * v7[v11];
*v10 = (double)(int)v11 * v9;
v14 = v6[v11] * v6[v11] + v13;
if ( v14 < 0.0 )
{
v19 = v8;
v20 = v9;
v15 = sqrt(v14);
v9 = v20;
v8 = v19;
}
else
{
v15 = sqrt(v14);
}
v10[1] = v15;
++v11;
v10 += 2;
v12 = fmax(v15, v12);
}
while ( v5 != v11 );
}
if ( (unsigned int)show_gplot(nmemb, v8) == -1 )
{
fwrite(&unk_120, 1uLL, 0x20uLL, stderr);
fwrite(&unk_148, 1uLL, 0x3FuLL, stderr);
}
free(v6);
free(v7);
free(nmemb);
free_wave_data(v4);
result = 0;
}
}
else
{
fwrite("bad argument!\n", 1uLL, 0xEuLL, stderr);
result = 1;
}
return result;
}

original_code:
int main(int argc, char *argv[]) {
  unsigned int N;
  unsigned int k;
  double frq_rate;
  double *restrict f_real;
  double *restrict f_imag;
  WAVE_DATA *restrict wd;
  POINT *restrict points;
  RANGE range = {{0.0, 0.0}, {0.0, 0.0}};
  if (argc != 3) {
    fprintf(stderr, "bad argument!\n");
    return 1;
  }
  wd = read_wave_file(argv[1]);
  N = str2int(argv[2]);
  print_wave_header(wd);
  f_real = ((double *)calloc((N), sizeof(double)));
  f_imag = ((double *)calloc((N), sizeof(double)));
  points = ((POINT *)calloc((N), sizeof(POINT)));
  if (f_real == ((void *)0) || f_imag == ((void *)0) || points == ((void *)0)) {
    fputs("メモリ確保エラーです\n", stderr);
    return 1;
  }
  auto_dft(f_real, f_imag, wd->s_data1, ((void *)0), N);
  frq_rate = (double)wd->samples_per_sec / N;
  for (k = 0; k < N; k++) {
    points[k].x = frq_rate * k;
    points[k].y = sqrt(((f_real[k]) * (f_real[k])) + ((f_imag[k]) * (f_imag[k])));
    if (range.max.y < points[k].y) range.max.y = points[k].y;
  }
  range.max.x = (double)wd->samples_per_sec / 2;
  range.max.y = (range.max.y == 0.0 ? 1.0 : range.max.y * 1.2);
  if (show_gplot(points, N, range) == -1) {
    fputs("gnuplotを起動できません\n", stderr);
    fputs("gnuplotにPATHが通っているか、確認してください\n", stderr);
  }
  (free(*(&f_real)), *(&f_real) = ((void *)0));
  (free(*(&f_imag)), *(&f_imag) = ((void *)0));
  (free(*(&points)), *(&points) = ((void *)0));
  free_wave_data(wd);
  return 0;
}

canonical_original_code:
int main(int argc, char *argv[]) {
  unsigned int N;
  unsigned int k;
  double frq_rate;
  double *f_real;
  double *f_imag;
  struct WAVE_DATA *wd;
  struct POINT *points;
  struct RANGE range = {{0.0, 0.0}, {0.0, 0.0}};
  if (argc != 3) {
    fprintf(stderr, "bad argument!\n");
    return 1;
  }
  wd = read_wave_file(argv[1]);
  N = str2int(argv[2]);
  print_wave_header(wd);
  f_real = ((double *)calloc((N), sizeof(double)));
  f_imag = ((double *)calloc((N), sizeof(double)));
  points = ((struct POINT *)calloc((N), sizeof(POINT)));
  if (f_real == ((void *)0) || f_imag == ((void *)0) || points == ((void *)0)) {
    fputs("メモリ確保エラーです\n", stderr);
    return 1;
  }
  auto_dft(f_real, f_imag, wd->s_data1, ((void *)0), N);
  frq_rate = (double)wd->samples_per_sec / N;
  for (k = 0; k < N; k++) {
    points[k].x = frq_rate * k;
    points[k].y = sqrt(((f_real[k]) * (f_real[k])) + ((f_imag[k]) * (f_imag[k])));
    if (range.max.y < points[k].y) range.max.y = points[k].y;
  }
  range.max.x = (double)wd->samples_per_sec / 2;
  range.max.y = (range.max.y == 0.0 ? 1.0 : range.max.y * 1.2);
  if (show_gplot(points, N, range) == -1) {
    fputs("gnuplotを起動できません\n", stderr);
    fputs("gnuplotにPATHが通っているか、確認してください\n", stderr);
  }
  (free(*(&f_real)), *(&f_real) = ((void *)0));
  (free(*(&f_imag)), *(&f_imag) = ((void *)0));
  (free(*(&points)), *(&points) = ((void *)0));
  free_wave_data(wd);
  return 0;
}

variable_types: argc int

variable_types:
N
unsigned int

variable_types:
k
unsigned int

variable_types: struct WAVE_DATA { char riff_chunk_id[4]; unsigned int riff_chunk_size; char file_format_type[4]; char fmt_chunk_id[4]; unsigned int fmt_chunk_size; unsigned short wave_format_type; unsigned short channel; unsigned int samples_per_sec; unsigned int bytes_per_sec; unsigned short block_size; unsigned short bits_per_sample; char data_chunk_id[4]; unsigned int data_chunk_size; double *s_data1; double *s_data2; unsigned int length; } *

variable_types:
points
struct POINT { double x; double y; } *

variable_types: struct RANGE { struct POINT { double x; double y; } min; struct POINT max; }

user_defined_types: struct RANGE { struct POINT min; struct POINT max; }


repo: koturn/WaveAnalyzer

decompiled_code:
void __fastcall free_wave_data(void *ptr)
{
free(*((void **)ptr + 6));
free(*((void **)ptr + 7));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func11(void *ptr)
{
free(*((void **)ptr + 6));
free(*((void **)ptr + 7));
free(ptr);
}

original_code:
void free_wave_data(WAVE_DATA *restrict wd) {
  (free(*(&wd->s_data1)), *(&wd->s_data1) = ((void *)0));
  (free(*(&wd->s_data2)), *(&wd->s_data2) = ((void *)0));
  (free(*(&wd)), *(&wd) = ((void *)0));
}

canonical_original_code:
void free_wave_data(struct WAVE_DATA *wd) {
  (free(*(&wd->s_data1)), *(&wd->s_data1) = ((void *)0));
  (free(*(&wd->s_data2)), *(&wd->s_data2) = ((void *)0));
  (free(*(&wd)), *(&wd) = ((void *)0));
}

return_type: void

user_defined_types: struct WAVE_DATA { char riff_chunk_id[4]; unsigned int riff_chunk_size; char file_format_type[4]; char fmt_chunk_id[4]; unsigned int fmt_chunk_size; unsigned short wave_format_type; unsigned short channel; unsigned int samples_per_sec; unsigned int bytes_per_sec; unsigned short block_size; unsigned short bits_per_sample; char data_chunk_id[4]; unsigned int data_chunk_size; double *s_data1; double *s_data2; unsigned int length; }


decompiled_code:
int __fastcall print_wave_header(__int64 a1)
{
__int64 v1; // rsi
const char *v2; // rdx
__int64 v3; // rsi
const char *v4; // rdx

printf("riff_chunk_id (4byte):%12.4s (%s)\n", (const char *)a1, "constant");
printf("riff_chunk_size (4byte):%12u (%s)\n", *(unsigned int *)(a1 + 4), "36 + data_chunk_size");
printf("file_format_type (4byte):%12.4s (%s)\n", (const char *)(a1 + 8), "constant");
printf("fmt_chunk_id (4byte):%12.4s (%s)\n", (const char *)(a1 + 12), "constant");
printf("fmt_chunk_size (4byte):%12u (%s)\n", *(unsigned int *)(a1 + 16), "constant");
v1 = *(unsigned __int16 *)(a1 + 20);
v2 = "PCM";
if ( (_WORD)v1 != 1 )
v2 = "UNKNOWN";
printf("wave_format_type (2byte):%12u (%s)\n", v1, v2);
v3 = *(unsigned __int16 *)(a1 + 22);
v4 = "MONAURAL";
if ( (_WORD)v3 != 1 )
v4 = "STEREO";
printf("channel (2byte):%12u (%s)\n", v3, v4);
printf("samples_per_sec (4byte):%12u\n", *(unsigned int *)(a1 + 24));
printf("bytes_per_sec (4byte):%12u (%s)\n", *(unsigned int *)(a1 + 28), "block_size * samples_per_sec");
printf("block_size (2byte):%12u (%s)\n", *(unsigned __int16 *)(a1 + 32), "bits_per_sample * channel / 8");
printf("bits_per_sample (2byte):%12u\n", *(unsigned __int16 *)(a1 + 34));
printf("data_chunk_id (4byte):%12.4s (%s)\n", (const char *)(a1 + 36), "constant");
return printf("data_chunk_size (4byte):%12u\n", *(unsigned int *)(a1 + 40));
}

canonical_decompiled_code:
int __fastcall func12(__int64 a1)
{
__int64 v1; // rsi
const char *v2; // rdx
__int64 v3; // rsi
const char *v4; // rdx

printf("riff_chunk_id (4byte):%12.4s (%s)\n", (const char *)a1, "constant");
printf("riff_chunk_size (4byte):%12u (%s)\n", *(unsigned int *)(a1 + 4), "36 + data_chunk_size");
printf("file_format_type (4byte):%12.4s (%s)\n", (const char *)(a1 + 8), "constant");
printf("fmt_chunk_id (4byte):%12.4s (%s)\n", (const char *)(a1 + 12), "constant");
printf("fmt_chunk_size (4byte):%12u (%s)\n", *(unsigned int *)(a1 + 16), "constant");
v1 = *(unsigned __int16 *)(a1 + 20);
v2 = "PCM";
if ( (_WORD)v1 != 1 )
v2 = "UNKNOWN";
printf("wave_format_type (2byte):%12u (%s)\n", v1, v2);
v3 = *(unsigned __int16 *)(a1 + 22);
v4 = "MONAURAL";
if ( (_WORD)v3 != 1 )
v4 = "STEREO";
printf("channel (2byte):%12u (%s)\n", v3, v4);
printf("samples_per_sec (4byte):%12u\n", *(unsigned int *)(a1 + 24));
printf("bytes_per_sec (4byte):%12u (%s)\n", *(unsigned int *)(a1 + 28), "block_size * samples_per_sec");
printf("block_size (2byte):%12u (%s)\n", *(unsigned __int16 *)(a1 + 32), "bits_per_sample * channel / 8");
printf("bits_per_sample (2byte):%12u\n", *(unsigned __int16 *)(a1 + 34));
printf("data_chunk_id (4byte):%12.4s (%s)\n", (const char *)(a1 + 36), "constant");
return printf("data_chunk_size (4byte):%12u\n", *(unsigned int *)(a1 + 40));
}

original_code:
void print_wave_header(const WAVE_DATA *restrict wd) {
  printf("riff_chunk_id    (4byte):%12.4s (%s)\n", wd->riff_chunk_id, "constant");
  printf("riff_chunk_size  (4byte):%12u (%s)\n", wd->riff_chunk_size, "36 + data_chunk_size");
  printf("file_format_type (4byte):%12.4s (%s)\n", wd->file_format_type, "constant");
  printf("fmt_chunk_id     (4byte):%12.4s (%s)\n", wd->fmt_chunk_id, "constant");
  printf("fmt_chunk_size   (4byte):%12u (%s)\n", wd->fmt_chunk_size, "constant");
  printf("wave_format_type (2byte):%12u (%s)\n", wd->wave_format_type, wd->wave_format_type == 1 ? "PCM" : "UNKNOWN");
  printf("channel          (2byte):%12u (%s)\n", wd->channel, wd->channel == 1 ? "MONAURAL" : "STEREO");
  printf("samples_per_sec  (4byte):%12u\n", wd->samples_per_sec);
  printf("bytes_per_sec    (4byte):%12u (%s)\n", wd->bytes_per_sec, "block_size * samples_per_sec");
  printf("block_size       (2byte):%12u (%s)\n", wd->block_size, "bits_per_sample * channel / 8");
  printf("bits_per_sample  (2byte):%12u\n", wd->bits_per_sample);
  printf("data_chunk_id    (4byte):%12.4s (%s)\n", wd->data_chunk_id, "constant");
  printf("data_chunk_size  (4byte):%12u\n", wd->data_chunk_size);
}

canonical_original_code:
void print_wave_header(struct WAVE_DATA *wd) {
  printf("riff_chunk_id    (4byte):%12.4s (%s)\n", wd->riff_chunk_id, "constant");
  printf("riff_chunk_size  (4byte):%12u (%s)\n", wd->riff_chunk_size, "36 + data_chunk_size");
  printf("file_format_type (4byte):%12.4s (%s)\n", wd->file_format_type, "constant");
  printf("fmt_chunk_id     (4byte):%12.4s (%s)\n", wd->fmt_chunk_id, "constant");
  printf("fmt_chunk_size   (4byte):%12u (%s)\n", wd->fmt_chunk_size, "constant");
  printf("wave_format_type (2byte):%12u (%s)\n", wd->wave_format_type, wd->wave_format_type == 1 ? "PCM" : "UNKNOWN");
  printf("channel          (2byte):%12u (%s)\n", wd->channel, wd->channel == 1 ? "MONAURAL" : "STEREO");
  printf("samples_per_sec  (4byte):%12u\n", wd->samples_per_sec);
  printf("bytes_per_sec    (4byte):%12u (%s)\n", wd->bytes_per_sec, "block_size * samples_per_sec");
  printf("block_size       (2byte):%12u (%s)\n", wd->block_size, "bits_per_sample * channel / 8");
  printf("bits_per_sample  (2byte):%12u\n", wd->bits_per_sample);
  printf("data_chunk_id    (4byte):%12.4s (%s)\n", wd->data_chunk_id, "constant");
  printf("data_chunk_size  (4byte):%12u\n", wd->data_chunk_size);
}


decompiled_code:
_DWORD *make_skelton_wave_data()
{
_DWORD *result; // rax

result = calloc(1uLL, 0x48uLL);
*result = 1179011410;
result[2] = 1163280727;
result[3] = 544501094;
result[4] = 16;
*((_WORD *)result + 10) = 1;
result[9] = 1635017060;
return result;
}

original_code:
WAVE_DATA *make_skelton_wave_data(void) {
  WAVE_DATA *wd = ((WAVE_DATA *)calloc((1), sizeof(WAVE_DATA)));
  strncpy(wd->riff_chunk_id, "RIFF", sizeof(char) * 4);
  strncpy(wd->file_format_type, "WAVE", sizeof(char) * 4);
  strncpy(wd->fmt_chunk_id, "fmt ", sizeof(char) * 4);
  wd->fmt_chunk_size = 16;
  wd->wave_format_type = 1;
  strncpy(wd->data_chunk_id, "data", sizeof(char) * 4);
  return wd;
}

canonical_original_code:
struct WAVE_DATA *make_skelton_wave_data() {
  struct WAVE_DATA *wd = ((WAVE_DATA *)calloc((1), sizeof(WAVE_DATA)));
  strncpy(wd->riff_chunk_id, "RIFF", sizeof(char) * 4);
  strncpy(wd->file_format_type, "WAVE", sizeof(char) * 4);
  strncpy(wd->fmt_chunk_id, "fmt ", sizeof(char) * 4);
  wd->fmt_chunk_size = 16;
  wd->wave_format_type = 1;
  strncpy(wd->data_chunk_id, "data", sizeof(char) * 4);
  return wd;
}

return_type: struct WAVE_DATA { char riff_chunk_id[4]; unsigned int riff_chunk_size; char file_format_type[4]; char fmt_chunk_id[4]; unsigned int fmt_chunk_size; unsigned short wave_format_type; unsigned short channel; unsigned int samples_per_sec; unsigned int bytes_per_sec; unsigned short block_size; unsigned short bits_per_sample; char data_chunk_id[4]; unsigned int data_chunk_size; double *s_data1; double *s_data2; unsigned int length; } *


original_code:
int set_wave_data(
    WAVE_DATA *restrict wd,
    const double *restrict s_data1,
    const double *restrict s_data2,
    unsigned int N,
    unsigned int samples_per_sec,
    unsigned short channel,
    unsigned short bits_per_sample)
{
  wd->samples_per_sec = samples_per_sec;
  wd->channel = channel;
  wd->bits_per_sample = bits_per_sample;
  wd->data_chunk_size = N * channel * (bits_per_sample / 8);
  wd->riff_chunk_size = 36 + wd->data_chunk_size;
  wd->block_size = wd->bits_per_sample * wd->channel / 8;
  wd->bytes_per_sec = wd->block_size * wd->samples_per_sec;
  if (s_data1 != ((void *)0)) {
    if ((wd->s_data1 = ((double *)calloc((N), sizeof(double)))) == ((void *)0)) {
      return -1;
    }
    memcpy(wd->s_data1, s_data1, N);
  }
  if (s_data2 != ((void *)0)) {
    if ((wd->s_data2 = ((double *)calloc((N), sizeof(double)))) == ((void *)0)) {
      return -1;
    }
    memcpy(wd->s_data2, s_data2, N);
  }
  return 0;
}

canonical_original_code:
int set_wave_data(struct WAVE_DATA *wd, double *s_data1, double *s_data2, unsigned int N, unsigned int samples_per_sec, unsigned short channel, unsigned short bits_per_sample)
{
  wd->samples_per_sec = samples_per_sec;
  wd->channel = channel;
  wd->bits_per_sample = bits_per_sample;
  wd->data_chunk_size = N * channel * (bits_per_sample / 8);
  wd->riff_chunk_size = 36 + wd->data_chunk_size;
  wd->block_size = wd->bits_per_sample * wd->channel / 8;
  wd->bytes_per_sec = wd->block_size * wd->samples_per_sec;
  if (s_data1 != ((void *)0)) {
    if ((wd->s_data1 = ((double *)calloc((N), sizeof(double)))) == ((void *)0)) {
      return -1;
    }
    memcpy(wd->s_data1, s_data1, N);
  }
  if (s_data2 != ((void *)0)) {
    if ((wd->s_data2 = ((double *)calloc((N), sizeof(double)))) == ((void *)0)) {
      return -1;
    }
    memcpy(wd->s_data2, s_data2, N);
  }
  return 0;
}

variable_types:
channel
unsigned short

return_type: int


repo: koturn/example

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

if ( a1 != a2 || (result = 1LL, a2 != a3) )
{
if ( a1 < a2 && a1 > 0 && a2 < a3 )
{
result = 2LL;
}
else if ( a2 <= a3 || a3 <= 0 || (result = 3LL, a1 <= a2) )
{
result = 0LL;
}
}
return result;
}

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

if ( a1 != a2 || (result = 1LL, a2 != a3) )
{
if ( a1 < a2 && a1 > 0 && a2 < a3 )
{
result = 2LL;
}
else if ( a2 <= a3 || a3 <= 0 || (result = 3LL, a1 <= a2) )
{
result = 0LL;
}
}
return result;
}

original_code:
int func2(int a, int b, int c)
{
  if (a == b && b == c) {
    return 1;
  } else if (0 < a && a < b && b < c) {
    return 2;
  } else if (0 < c && c < b && b < a) {
    return 3;
  } else {
    return 0;
  }
}

variable_types: a int

variable_types: b int

variable_types: c int


prtAnswer

decompiled_code:
int __fastcall prtAnswer(__int64 a1)
{
unsigned int *v1; // r13
__int64 i; // rbp
__int64 v3; // rsi
int result; // eax
unsigned int *v5; // rbx
int v6; // er12
__int64 v7; // rax
__int64 v8; // rdx
__int64 v9; // rcx
int v10; // [rsp-10h] [rbp-38h]

v1 = (unsigned int *)(unsigned int)((_DWORD)&Case + 7200);
for ( i = 1LL; i != 4; ++i )
{
v3 = *(_QWORD *)(a1 + 8 * i);
if ( NC[i] )
{
v5 = v1;
v6 = 0;
printf(aS, v3);
result = puts("(x, y, z) -> (a, b, c)");
if ( NC[i] > 0 )
{
do
{
v7 = v5[5];
v8 = v5[1];
v9 = v5[2];
++v6;
v5 += 6;
printf("(%d, %d, %d) -> (%d, %d, %d)\n", *(v5 - 6), v8, v9, *(v5 - 3), *(v5 - 2), v7);
result = v10;
}
while ( NC[i] > v6 );
}
}
else
{
result = printf(format, v3);
}
v1 += 1800;
}
return result;
}

original_code:
void prtAnswer(char *str[])
{
  int i, j;
  for (i = 1; i < 4; i++) {
    if (NC[i] == 0) {
     printf("%s となる場合は存在しない．\n", str[i]);
    } else {
     printf("%s となるのは以下の%d通りである．\n", str[i], NC[i]);
     printf("(x, y, z) -> (a, b, c)\n");
     for (j = 0; j < NC[i]; j++) {
       printf("(%d, %d, %d) -> (%d, %d, %d)\n",
           Case[i][j].x, Case[i][j].y, Case[i][j].z,
           Case[i][j].a, Case[i][j].b, Case[i][j].c
       );
     }
    }
  }
}

canonical_original_code:
void prtAnswer(char *str[])
{
  int i; int j;
  for (i = 1; i < 4; i++) {
    if (NC[i] == 0) {
     printf("%s となる場合は存在しない．\n", str[i]);
    } else {
     printf("%s となるのは以下の%d通りである．\n", str[i], NC[i]);
     printf("(x, y, z) -> (a, b, c)\n");
     for (j = 0; j < NC[i]; j++) {
       printf("(%d, %d, %d) -> (%d, %d, %d)\n",
           Case[i][j].x, Case[i][j].y, Case[i][j].z,
           Case[i][j].a, Case[i][j].b, Case[i][j].c
       );
     }
    }
  }
}

variable_types:
str
char *[]

variable_types: i int

variable_types: j int


original_code:
void func1(int x, int y, int z)
{
  int a, b, c, nn;
  a = (x - y) * (y - z) * (z - x);
  b = x * y - y * z;
  c = (x - y + z) * (x + y - z);
  nn = func2(a, b, c);
  if (nn == 1 || nn == 2 || nn == 3) {
    Case[nn][NC[nn]].x = x;
    Case[nn][NC[nn]].y = y;
    Case[nn][NC[nn]].z = z;
    Case[nn][NC[nn]].a = a;
    Case[nn][NC[nn]].b = b;
    Case[nn][NC[nn]].c = c;
    NC[nn]++;
  }
}

canonical_original_code:
void func1(int x, int y, int z)
{
  int a; int b; int c; int nn;
  a = (x - y) * (y - z) * (z - x);
  b = x * y - y * z;
  c = (x - y + z) * (x + y - z);
  nn = func2(a, b, c);
  if (nn == 1 || nn == 2 || nn == 3) {
    Case[nn][NC[nn]].x = x;
    Case[nn][NC[nn]].y = y;
    Case[nn][NC[nn]].z = z;
    Case[nn][NC[nn]].a = a;
    Case[nn][NC[nn]].b = b;
    Case[nn][NC[nn]].c = c;
    NC[nn]++;
  }
}

variable_types: x int

variable_types: y int

variable_types: z int

variable_types: nn int


main

canonical_name: main


getTriangle

canonical_original_code:
void getTriangle(int n, struct Triangle t[])
{
  int i; int j;
  for (i = 0; i < n; i++) {
    for (j = 0; j < 3; j++) {
      t[i].p[j].x = (double)(rand() % 201 - 100) / 10;
      t[i].p[j].y = (double)(rand() % 201 - 100) / 10;
    }
  }
}

variable_types: n int

variable_types: struct Triangle { struct Point { double x; } p[3]; double area; } []

user_defined_types: struct Triangle { struct Point p[3]; double area; }


calcArea

variable_types: a double

variable_types: b double

variable_types: c double

variable_types: s double


prtTriangle

decompiled_code:
int __fastcall prtTriangle(int a1, __int64 a2)
{
int result; // eax
double *v3; // rbp
double *v4; // rbx
double v5; // xmm1_8
double v6; // xmm0_8
double v7; // xmm0_8

result = puts("( V1 ) ( V2 ) ( V3 ) Area");
if ( a1 > 0 )
{
v3 = (double *)(a2 + 48);
do
{
v4 = v3 - 6;
do
{
v5 = v4[1];
v6 = *v4;
v4 += 2;
printf("(%5.1f, %5.1f) ", v6, v5);
}
while ( v4 != v3 );
v7 = *v3;
v3 += 7;
result = printf("%5.1f\n", v7);
}
while ( v3 != (double *)(a2 + 56LL * (unsigned int)(a1 - 1) + 104) );
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(int a1, __int64 a2)
{
int result; // eax
double *v3; // rbp
double *v4; // rbx
double v5; // xmm1_8
double v6; // xmm0_8
double v7; // xmm0_8

result = puts("( V1 ) ( V2 ) ( V3 ) Area");
if ( a1 > 0 )
{
v3 = (double *)(a2 + 48);
do
{
v4 = v3 - 6;
do
{
v5 = v4[1];
v6 = *v4;
v4 += 2;
printf("(%5.1f, %5.1f) ", v6, v5);
}
while ( v4 != v3 );
v7 = *v3;
v3 += 7;
result = printf("%5.1f\n", v7);
}
while ( v3 != (double *)(a2 + 56LL * (unsigned int)(a1 - 1) + 104) );
}
return result;
}

original_code:
void prtTriangle(int n, Triangle t[])
{
  int i, j;
  printf("(     V1     ) (     V2     ) (     V3     )  Area\n");
  for (i = 0; i < n; i++) {
    for (j = 0; j < 3; j++) {
      printf("(%5.1f, %5.1f) ", t[i].p[j].x, t[i].p[j].y);
    }
    printf("%5.1f\n", t[i].area);
  }
}

canonical_original_code:
void prtTriangle(int n, struct Triangle t[])
{
  int i; int j;
  printf("(     V1     ) (     V2     ) (     V3     )  Area\n");
  for (i = 0; i < n; i++) {
    for (j = 0; j < 3; j++) {
      printf("(%5.1f, %5.1f) ", t[i].p[j].x, t[i].p[j].y);
    }
    printf("%5.1f\n", t[i].area);
  }
}


sortTriangle

original_code:
void sortTriangle(int n, Triangle t[])
{
  int i;
  for (i = 0; i < n - 1; i++) {
    int j;
    for (j = i + 1; j < n; j++) {
      if (t[i].area < t[j].area) {
        Triangle tmp = t[i];
        t[i] = t[j];
        t[j] = tmp;
      }
    }
  }
}

canonical_original_code:
void sortTriangle(int n, struct Triangle t[])
{
  int i;
  for (i = 0; i < n - 1; i++) {
    int j;
    for (j = i + 1; j < n; j++) {
      if (t[i].area < t[j].area) {
        struct Triangle tmp = t[i];
        t[i] = t[j];
        t[j] = tmp;
      }
    }
  }
}

variable_types: struct Triangle { struct Point { double x; } p[3]; double area; }


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int seed; // [rsp+8h] [rbp-15F0h] BYREF
int v5; // [rsp+Ch] [rbp-15ECh] BYREF
double v6[701]; // [rsp+10h] [rbp-15E8h] BYREF

printf(&byte_46A, argv, envp);
_isoc99_scanf(&unk_479, &seed);
srand(seed);
printf(a3);
_isoc99_scanf(&unk_479, &v5);
getTriangle(v5, (__int64)v6);
calcArea(v5, v6);
sortTriangle(v5, v6);
prtTriangle(v5, (__int64)v6);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int seed; // [rsp+8h] [rbp-15F0h] BYREF
int v5; // [rsp+Ch] [rbp-15ECh] BYREF
double v6[701]; // [rsp+10h] [rbp-15E8h] BYREF

printf(&byte_46A, argv, envp);
_isoc99_scanf(&unk_479, &seed);
srand(seed);
printf(a3);
_isoc99_scanf(&unk_479, &v5);
func0(v5, (__int64)v6);
func1(v5, v6);
func3(v5, v6);
func2(v5, (__int64)v6);
return 0;
}

original_code:
int main(void)
{
  int seed, n;
  Triangle tri[100];
  printf("乱数 seed : ");
  scanf("%d", &seed);
  srand(seed);
  printf("3角形の個数 : ");
  scanf("%d", &n);
  getTriangle(n, tri);
  calcArea(n, tri);
  sortTriangle(n, tri);
  prtTriangle(n, tri);
  return 0;
}

canonical_original_code:
int main()
{
  int seed; int n;
  struct Triangle tri[100];
  printf("乱数 seed : ");
  scanf("%d", &seed);
  srand(seed);
  printf("3角形の個数 : ");
  scanf("%d", &n);
  getTriangle(n, tri);
  calcArea(n, tri);
  sortTriangle(n, tri);
  prtTriangle(n, tri);
  return 0;
}

variable_types: seed int

variable_types: struct Triangle { struct Point { double x; } p[3]; double area; } [100]


prtMoney

decompiled_code:
int __fastcall prtMoney(__int64 a1)
{
__int64 v1; // rbx
int result; // eax

v1 = a1;
do
{
if ( *(int *)(v1 + 12) > 0 )
result = printf(format, *(_QWORD *)v1);
v1 += 16LL;
}
while ( v1 != a1 + 144 );
return result;
}

canonical_decompiled_code:
int __fastcall func1(__int64 a1)
{
__int64 v1; // rbx
int result; // eax

v1 = a1;
do
{
if ( *(int *)(v1 + 12) > 0 )
result = printf(format, *(_QWORD *)v1);
v1 += 16LL;
}
while ( v1 != a1 + 144 );
return result;
}

original_code:
void prtMoney(Money mon[])
{
  int i;
  for (i = 0; i < 9; i++) {
    if (mon[i].num > 0) {
      printf("%s = %d 枚\n", mon[i].name, mon[i].num);
    }
  }
}

canonical_original_code:
void prtMoney(struct Money mon[])
{
  int i;
  for (i = 0; i < 9; i++) {
    if (mon[i].num > 0) {
      printf("%s = %d 枚\n", mon[i].name, mon[i].num);
    }
  }
}

variable_types: struct Money { char *name; int value; int num; } []


original_code:
int func1(int kingaku, Money mon[])
{
  int i;
  int val = (int)(kingaku * 1.05);
  for (i = 0; i < 9; i++) {
    while (val - mon[i].value >= 0) {
      val -= mon[i].value;
      mon[i].num++;
    }
  }
  return (int)(kingaku * 1.05);
}

canonical_original_code:
int func1(int kingaku, struct Money mon[])
{
  int i;
  int val = (int)(kingaku * 1.05);
  for (i = 0; i < 9; i++) {
    while (val - mon[i].value >= 0) {
      val -= mon[i].value;
      mon[i].num++;
    }
  }
  return (int)(kingaku * 1.05);
}

variable_types: kingaku int

variable_types: val int

user_defined_types: struct Money { char *name; int value; int num; }


main

original_code:
int main(void)
{
  int kingaku, zeikomi;
  Money mon[] = {
    {"一万円", 10000, 0},
    {"五千円", 5000, 0},
    {"  千円", 1000, 0},
    {"五百円", 500, 0},
    {"  百円", 100, 0},
    {"五十円", 50, 0},
    {"  十円", 10, 0},
    {"  五円", 5, 0},
    {"  一円", 1, 0}
  };
  printf("金額 = "); scanf("%d", &kingaku);
  zeikomi = func1(kingaku, mon);
  printf("税込み金額は%d円です．\n", zeikomi);
  prtMoney(mon);
  return 0;
}

canonical_original_code:
int main()
{
  int kingaku; int zeikomi;
  struct Money mon[] = {
    {"一万円", 10000, 0},
    {"五千円", 5000, 0},
    {"  千円", 1000, 0},
    {"五百円", 500, 0},
    {"  百円", 100, 0},
    {"五十円", 50, 0},
    {"  十円", 10, 0},
    {"  五円", 5, 0},
    {"  一円", 1, 0}
  };
  printf("金額 = "); scanf("%d", &kingaku);
  zeikomi = func1(kingaku, mon);
  printf("税込み金額は%d円です．\n", zeikomi);
  prtMoney(mon);
  return 0;
}

variable_types: zeikomi int


calcSeiseki

original_code:
void calcSeiseki(int n, int m, Person p[])
{
  int i;
  double p_ave = 0.0;
  double s = 0.0;
  for (i = 0; i < n; i++) {
    int j;
    int sum = 0.0;
    for (j = 0; j < m; j++) {
      sum += p[i].points[j];
    }
    p[i].ave = sum / m;
    p_ave += p[i].ave;
    if (p[i].ave < 60) {
      p[i].judge = 'F';
    }
  }
  p_ave /= n;
  for (i = 0; i < n; i++) {
    double tmp = p[i].ave - p_ave;
    s += tmp * tmp;
  }
  s = sqrt(s / n);
  for (i = 0; i < n; i++) {
    p[i].s = 10 * (p[i].ave - p_ave) / s + 50;
  }
}

canonical_original_code:
void calcSeiseki(int n, int m, struct Person p[])
{
  int i;
  double p_ave = 0.0;
  double s = 0.0;
  for (i = 0; i < n; i++) {
    int j;
    int sum = 0.0;
    for (j = 0; j < m; j++) {
      sum += p[i].points[j];
    }
    p[i].ave = sum / m;
    p_ave += p[i].ave;
    if (p[i].ave < 60) {
      p[i].judge = 'F';
    }
  }
  p_ave /= n;
  for (i = 0; i < n; i++) {
    double tmp = p[i].ave - p_ave;
    s += tmp * tmp;
  }
  s = sqrt(s / n);
  for (i = 0; i < n; i++) {
    p[i].s = 10 * (p[i].ave - p_ave) / s + 50;
  }
}

variable_types: m int

variable_types: struct Person { char judge; char *name; int points[4]; int ave; double s; } []

variable_types: i int

variable_types: j int

variable_types: sum int

variable_types: tmp double


prtSeiseki

decompiled_code:
int __fastcall prtSeiseki(int a1, __int64 a2)
{
__int64 v2; // rbx
int result; // eax
__int64 v4; // rcx
const char *v5; // rdx

v2 = a2;
result = puts(s);
if ( a1 > 0 )
{
do
{
v4 = *(unsigned int *)(v2 + 32);
v5 = *(const char **)(v2 + 8);
v2 += 48LL;
result = printf("%c %-10s %4d %6.1f\n", (unsigned int)*(char *)(v2 - 48), v5, v4, *(double *)(v2 - 8));
}
while ( v2 != a2 + 48LL * (unsigned int)(a1 - 1) + 48 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(int a1, __int64 a2)
{
__int64 v2; // rbx
int result; // eax
__int64 v4; // rcx
const char *v5; // rdx

v2 = a2;
result = puts(s);
if ( a1 > 0 )
{
do
{
v4 = *(unsigned int *)(v2 + 32);
v5 = *(const char **)(v2 + 8);
v2 += 48LL;
result = printf("%c %-10s %4d %6.1f\n", (unsigned int)*(char *)(v2 - 48), v5, v4, *(double *)(v2 - 8));
}
while ( v2 != a2 + 48LL * (unsigned int)(a1 - 1) + 48 );
}
return result;
}

original_code:
void prtSeiseki(int n, Person p[])
{
  int i;
  printf("  名前        成績 偏差値\n");
  for (i = 0; i < n; i++) {
    printf("%c %-10s %4d %6.1f\n", p[i].judge, p[i].name, p[i].ave, p[i].s);
  }
}

canonical_original_code:
void prtSeiseki(int n, struct Person p[])
{
  int i;
  printf("  名前        成績 偏差値\n");
  for (i = 0; i < n; i++) {
    printf("%c %-10s %4d %6.1f\n", p[i].judge, p[i].name, p[i].ave, p[i].s);
  }
}

variable_types: n int

user_defined_types: struct Person { char judge; char *name; int points[4]; int ave; double s; }


sort

original_code:
void sort(int n, Person p[])
{
  int i;
  for (i = 0; i < n - 1; i++) {
    int j;
    for (j = i + 1; j < n; j++) {
      if (p[i].ave < p[j].ave) {
        Person tmp = p[i];
        p[i] = p[j];
        p[j] = tmp;
      }
    }
  }
}

canonical_original_code:
void sort(int n, struct Person p[])
{
  int i;
  for (i = 0; i < n - 1; i++) {
    int j;
    for (j = i + 1; j < n; j++) {
      if (p[i].ave < p[j].ave) {
        struct Person tmp = p[i];
        p[i] = p[j];
        p[j] = tmp;
      }
    }
  }
}

variable_types: struct Person { char judge; char *name; int points[4]; int ave; double s; }


prtMat

decompiled_code:
int __fastcall prtMat(__int64 a1, int a2)
{
__int64 v2; // rax
__int64 v3; // rbp
__int64 v4; // r13
double *v5; // rbx
double v6; // xmm0_8
int result; // eax

if ( a2 > 0 )
{
v2 = (unsigned int)(a2 - 1);
v3 = a1 + 8 * v2 + 8;
v4 = a1 + 88 * v2 + 88;
do
{
v5 = (double *)(-8LL * (unsigned int)a2 + v3);
do
{
v6 = *v5++;
printf(" %3.1f", v6);
}
while ( v5 != (double *)v3 );
v3 += 80LL;
result = putchar(10);
}
while ( v3 != v4 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1, int a2)
{
__int64 v2; // rax
__int64 v3; // rbp
__int64 v4; // r13
double *v5; // rbx
double v6; // xmm0_8
int result; // eax

if ( a2 > 0 )
{
v2 = (unsigned int)(a2 - 1);
v3 = a1 + 8 * v2 + 8;
v4 = a1 + 88 * v2 + 88;
do
{
v5 = (double *)(-8LL * (unsigned int)a2 + v3);
do
{
v6 = *v5++;
printf(" %3.1f", v6);
}
while ( v5 != (double *)v3 );
v3 += 80LL;
result = putchar(10);
}
while ( v3 != v4 );
}
return result;
}

original_code:
void prtMat(double a[10][10], int n)
{
  int i, j;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      printf(" %3.1f", a[i][j]);
    }
    printf("\n");
  }
}

canonical_original_code:
void prtMat(double a[10][10], int n)
{
  int i; int j;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      printf(" %3.1f", a[i][j]);
    }
    printf("\n");
  }
}


copyMat

canonical_original_code:
void copyMat(double a[10][10], double b[10][10], int n)
{
  int i; int j;
  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      b[i][j] = a[i][j];
    }
  }
}


aPow

decompiled_code:
void __fastcall aPow(int a1, double *a2, double *a3, int a4)
{
int v6; // ebx
double v7[105]; // [rsp+0h] [rbp-348h] BYREF

if ( a1 < 0 )
{
puts("aPow: Error!");
}
else if ( a1 )
{
v6 = a1;
copyMat((__int64)a2, (__int64)a3, a4);
if ( a1 != 1 )
{
do
{
prod(a2, a3, v7, a4);
--v6;
copyMat((__int64)v7, (__int64)a3, a4);
}
while ( v6 != 1 );
}
}
else
{
unitMat((__int64)a3, a4);
}
}

original_code:
void aPow(int p, double a[10][10], double x[10][10], int n)
{
  double b[10][10];
  if (p < 0) {
    printf("aPow: Error!\n");
  } else if (p == 0) {
    unitMat(x, n);
  } else {
    copyMat(a, x, n);
    while (p > 1) {
      prod(a, x, b, n);
      copyMat(b, x, n);
      p--;
    }
  }
}

variable_types: p int


getCircle

variable_types: struct Circle { double r; double x0; double y0; double area; } []


prtCircle

decompiled_code:
int __fastcall prtCircle(int a1, double *a2)
{
int result; // eax
unsigned int i; // ebp
double v5; // xmm3_8
double v6; // xmm0_8

result = puts(s);
if ( a1 > 0 )
{
for ( i = 0; i != a1; result = printf("%3d:%5.1f (%5.1f, %5.1f) %6.1f\n", i, v6, *(a2 - 3), *(a2 - 2), v5) )
{
v5 = a2[3];
v6 = *a2;
++i;
a2 += 4;
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func1(int a1, double *a2)
{
int result; // eax
unsigned int i; // ebp
double v5; // xmm3_8
double v6; // xmm0_8

result = puts(s);
if ( a1 > 0 )
{
for ( i = 0; i != a1; result = printf("%3d:%5.1f (%5.1f, %5.1f) %6.1f\n", i, v6, *(a2 - 3), *(a2 - 2), v5) )
{
v5 = a2[3];
v6 = *a2;
++i;
a2 += 4;
}
}
return result;
}

canonical_original_code:
void prtCircle(int n, struct Circle c[])
{
  int i;
  printf(" no:    r (   x0,    y0)   面積\n");
  for (i = 0; i < n; i++) {
    printf("%3d:%5.1f (%5.1f, %5.1f) %6.1f\n", i + 1, c[i].r, c[i].x0, c[i].y0, c[i].area);
  }
}

user_defined_types: struct Circle { double r; double x0; double y0; double area; }


sort

original_code:
void sort(int n, Circle c[])
{
  int i, j;
  Circle tmp;
  for (i = 0; i < n - 1; i++) {
    for (j = i + 1; j < n; j++) {
      if (c[i].area < c[j].area) {
        tmp = c[j];
        c[j] = c[i];
        c[i] = tmp;
      }
    }
  }
}

canonical_original_code:
void sort(int n, struct Circle c[])
{
  int i; int j;
  struct Circle tmp;
  for (i = 0; i < n - 1; i++) {
    for (j = i + 1; j < n; j++) {
      if (c[i].area < c[j].area) {
        tmp = c[j];
        c[j] = c[i];
        c[i] = tmp;
      }
    }
  }
}

variable_types: struct Circle { double r; double x0; double y0; double area; }


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int seed; // [rsp+8h] [rbp-C90h] BYREF
int v5; // [rsp+Ch] [rbp-C8Ch] BYREF
double v6[401]; // [rsp+10h] [rbp-C88h] BYREF

printf(&byte_210, argv, envp);
_isoc99_scanf(&unk_21E, &seed);
srand(seed);
printf(&byte_221);
_isoc99_scanf(&unk_21E, &v5);
getCircle(v5, (__int64)v6);
sort(v5, (__int64)v6);
prtCircle(v5, v6);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int seed; // [rsp+8h] [rbp-C90h] BYREF
int v5; // [rsp+Ch] [rbp-C8Ch] BYREF
double v6[401]; // [rsp+10h] [rbp-C88h] BYREF

printf(&byte_210, argv, envp);
_isoc99_scanf(&unk_21E, &seed);
srand(seed);
printf(&byte_221);
_isoc99_scanf(&unk_21E, &v5);
func0(v5, (__int64)v6);
func2(v5, (__int64)v6);
func1(v5, v6);
return 0;
}

original_code:
int main(void)
{
  int seed, n;
  Circle c[100];
  printf("乱数seed : ");
  scanf("%d", &seed);
  srand(seed);
  printf("円の個数 : ");
  scanf("%d", &n);
  getCircle(n, c);
  sort(n, c);
  prtCircle(n, c);
  return 0;
}

canonical_original_code:
int main()
{
  int seed; int n;
  struct Circle c[100];
  printf("乱数seed : ");
  scanf("%d", &seed);
  srand(seed);
  printf("円の個数 : ");
  scanf("%d", &n);
  getCircle(n, c);
  sort(n, c);
  prtCircle(n, c);
  return 0;
}

variable_types: seed int

variable_types: struct Circle { double r; double x0; double y0; double area; } [100]


decompiled_code:
__int64 __fastcall f1(int a1, int a2)
{
int v2; // esi
int i; // edx

v2 = a2 - 1;
if ( v2 > 0 )
{
for ( i = 0; i != v2; ++i )
a1 /= 10;
}
return (unsigned int)(a1 % 10);
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, int a2)
{
int v2; // esi
int i; // edx

v2 = a2 - 1;
if ( v2 > 0 )
{
for ( i = 0; i != v2; ++i )
a1 /= 10;
}
return (unsigned int)(a1 % 10);
}

original_code:
int f1(int n, int m)
{
  int i;
  for (i = 0; i < m - 1; i++) {
    n /= 10;
  }
  return n % 10;
}


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int i; // er12
unsigned int v4; // ebx
unsigned int v5; // ebp
unsigned int v6; // eax
unsigned int v7; // er14
unsigned int v8; // er13

for ( i = 10; i != 100; ++i )
{
v4 = 10;
do
{
while ( 1 )
{
v5 = 10 * i * f1(v4, 2);
if ( (unsigned int)f1(v5, 3) == 4 )
{
v6 = i * f1(v4, 1);
v7 = v6 + v5;
v8 = v6;
if ( (unsigned int)f1(v6 + v5, 3) == 3 )
break;
}
if ( ++v4 == 100 )
goto LABEL_7;
}
printf(" %d\n", i);
printf(" x%d\n", v4++);
puts(" ---");
printf(" %d\n", v8);
printf("%d\n", v5);
puts("----");
printf("%d\n", v7);
}
while ( v4 != 100 );
LABEL_7:
;
}
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int i; // er12
unsigned int v4; // ebx
unsigned int v5; // ebp
unsigned int v6; // eax
unsigned int v7; // er14
unsigned int v8; // er13

for ( i = 10; i != 100; ++i )
{
v4 = 10;
do
{
while ( 1 )
{
v5 = 10 * i * func0(v4, 2);
if ( (unsigned int)func0(v5, 3) == 4 )
{
v6 = i * func0(v4, 1);
v7 = v6 + v5;
v8 = v6;
if ( (unsigned int)func0(v6 + v5, 3) == 3 )
break;
}
if ( ++v4 == 100 )
goto LABEL_7;
}
printf(" %d\n", i);
printf(" x%d\n", v4++);
puts(" ---");
printf(" %d\n", v8);
printf("%d\n", v5);
puts("----");
printf("%d\n", v7);
}
while ( v4 != 100 );
LABEL_7:
;
}
return 0;
}

variable_types: a int

variable_types: b int

variable_types: c int

variable_types: d int

variable_types: e int


inputlength

original_code:
Triangle inputlength(Triangle t) {
  Triangle ret_t;
  ret_t.line1 = distance(t.p1, t.p2);
  ret_t.line2 = distance(t.p2, t.p3);
  ret_t.line3 = distance(t.p3, t.p1);
  return ret_t;
}

canonical_original_code:
struct Triangle inputlength(struct Triangle t) {
  struct Triangle ret_t;
  ret_t.line1 = distance(t.p1, t.p2);
  ret_t.line2 = distance(t.p2, t.p3);
  ret_t.line3 = distance(t.p3, t.p1);
  return ret_t;
}

variable_types:
t
struct Triangle

variable_types: struct Triangle { double p1[2]; double line1; }


main

original_code:
int main(void)
{
  Triangle tri;
  printf("3点を入力してください\n");
  printf("点1(x, y) "); scanf("%lf,%lf", &tri.p1[0], &tri.p1[1]);
  printf("点2(x, y) "); scanf("%lf,%lf", &tri.p2[0], &tri.p2[1]);
  printf("点3(x, y) "); scanf("%lf,%lf", &tri.p3[0], &tri.p3[1]);
  tri = inputlength(tri);
  printf("辺の長さは%.2f, %.2f, %.2f です\n", tri.line1, tri.line2, tri.line3);
  return 0;
}

canonical_original_code:
int main()
{
  struct Triangle tri;
  printf("3点を入力してください\n");
  printf("点1(x, y) "); scanf("%lf,%lf", &tri.p1[0], &tri.p1[1]);
  printf("点2(x, y) "); scanf("%lf,%lf", &tri.p2[0], &tri.p2[1]);
  printf("点3(x, y) "); scanf("%lf,%lf", &tri.p3[0], &tri.p3[1]);
  tri = inputlength(tri);
  printf("辺の長さは%.2f, %.2f, %.2f です\n", tri.line1, tri.line2, tri.line3);
  return 0;
}

user_defined_types: struct Triangle { double p1[2]; double line1; }


sindata

decompiled_code:
void __fastcall sindata(int a1, __int64 a2, float a3, float a4, float a5)
{
__int64 v5; // r12
float v6; // xmm0_4
double v7; // [rsp+0h] [rbp-30h]

if ( a1 > 0 )
{
v5 = 0LL;
v7 = a3 * 6.2831853;
do
{
v6 = sin((double)(int)v5 * v7 * a4) * a5;
*(float *)(a2 + 4 * v5++) = v6;
}
while ( a1 != v5 );
}
}

original_code:
void sindata(int len, float freq, float tdel, float amp, float *x)
{
  int i;
  for (i = 0; i < len; i++) {
    x[i] = amp * sin(2 * 3.14159265 * freq * i * tdel);
  }
}

variable_types: len int

variable_types: freq float

variable_types: tdel float

variable_types: amp float

variable_types:
x
float *

variable_types: i int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbx
float v5[5002]; // [rsp+0h] [rbp-4E28h] BYREF

v3 = 0LL;
sindata(1000, (__int64)v5, 100.0, 0.000049999999, 5.0);
do
{
printf("x[%4d] = %f\n", (unsigned int)v3, v5[v3]);
++v3;
}
while ( v3 != 1000 );
return 0;
}

original_code:
int main(void)
{
  float x[5000], tdel = 5e-5, freq = 100, amp = 5;
  int len = 1000;
  int i;
  sindata(len, freq, tdel, amp, x);
  for (i = 0; i < len; i++) {
    printf("x[%4d] = %f\n", i, x[i]);
  }
  return 0;
}

canonical_original_code:
int main()
{
  float x[5000]; float tdel = 5e-5; float freq = 100; float amp = 5;
  int len = 1000;
  int i;
  sindata(len, freq, tdel, amp, x);
  for (i = 0; i < len; i++) {
    printf("x[%4d] = %f\n", i, x[i]);
  }
  return 0;
}

variable_types:
x
float [5000]


change

decompiled_code:
__int64 __fastcall change(char a1, int a2)
{
__int64 result; // rax

if ( a2 <= 0 )
goto LABEL_6;
result = (unsigned int)(a2 + 1988);
if ( a1 == 72 )
return result;
if ( a1 == 83 && a2 <= 64 )
result = (unsigned int)(a2 + 1925);
else
LABEL_6:
result = 0xFFFFFFFFLL;
return result;
}

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

if ( a2 <= 0 )
goto LABEL_6;
result = (unsigned int)(a2 + 1988);
if ( a1 == 72 )
return result;
if ( a1 == 83 && a2 <= 64 )
result = (unsigned int)(a2 + 1925);
else
LABEL_6:
result = 0xFFFFFFFFLL;
return result;
}

original_code:
int change(char g, int y)
{
  int year = -1;
  if (y >= 1) {
    switch (g) {
      case 'H':
        year = 1989 + y - 1;
        break;
      case 'S':
        if (y <= 64) {
          year = 1926 + y - 1;
        }
        break;
    }
  }
  return year;
}

variable_types: g char

variable_types: y int

variable_types: year int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
__int64 v4; // rdx
unsigned int v5; // er8
char v7; // [rsp+Bh] [rbp-Dh] BYREF
int v8; // [rsp+Ch] [rbp-Ch] BYREF

printf("Input the era name (H/S) and year: ");
_isoc99_scanf("%c%d", &v7, &v8);
v3 = change(v7, v8);
if ( v3 == -1 )
puts("Out of Range");
else
printf("%c %d = %d\n", v5, v4, v3);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
__int64 v4; // rdx
unsigned int v5; // er8
char v7; // [rsp+Bh] [rbp-Dh] BYREF
int v8; // [rsp+Ch] [rbp-Ch] BYREF

printf("Input the era name (H/S) and year: ");
_isoc99_scanf("%c%d", &v7, &v8);
v3 = func0(v7, v8);
if ( v3 == -1 )
puts("Out of Range");
else
printf("%c %d = %d\n", v5, v4, v3);
return 0;
}

original_code:
int main(void)
{
  char g;
  int y1, y2;
  printf("Input the era name (H/S) and year: ");
  scanf("%c%d", &g, &y1);
  y2 = change(g, y1);
  if (y2 != -1) {
    printf("%c %d = %d\n", g, y1, y2);
  } else {
    printf("Out of Range\n");
  }
  return 0;
}

canonical_original_code:
int main()
{
  char g;
  int y1; int y2;
  printf("Input the era name (H/S) and year: ");
  scanf("%c%d", &g, &y1);
  y2 = change(g, y1);
  if (y2 != -1) {
    printf("%c %d = %d\n", g, y1, y2);
  } else {
    printf("Out of Range\n");
  }
  return 0;
}


calc

original_code:
void calc(int m, int n, int p, unsigned char Im[5][10], FEATURE *f)
{
  int i, x, y, a;
  double cx, cy;
  for (i = 1; i <= p; i++) {
    cx = 0, cy = 0, a = 0;
    for (y = 0; y < n; y++) {
      for (x = 0; x < m; x++) {
        if (i == Im[x][y]) {
          a++;
          cx += x;
          cy += y;
        }
      }
    }
    f[i].area = a;
    if (a != 0) {
      f[i].cx = cx / a;
      f[i].cy = cy / a;
    }
  }
}

canonical_original_code:
void calc(int m, int n, int p, unsigned char Im[5][10], struct FEATURE *f)
{
  int i; int x; int y; int a;
  double cx; double cy;
  for (i = 1; i <= p; i++) {
    cx = 0, cy = 0, a = 0;
    for (y = 0; y < n; y++) {
      for (x = 0; x < m; x++) {
        if (i == Im[x][y]) {
          a++;
          cx += x;
          cy += y;
        }
      }
    }
    f[i].area = a;
    if (a != 0) {
      f[i].cx = cx / a;
      f[i].cy = cy / a;
    }
  }
}

variable_types: m int

variable_types: n int

variable_types: p int

variable_types:
Im
unsigned char [5][10]

variable_types: struct FEATURE { int area; double cx; } *

variable_types: x int

variable_types: a int

variable_types: cx double

variable_types: cy double


prtFeature

decompiled_code:
int __fastcall prtFeature(int a1, __int64 a2)
{
int v2; // ebp
double *v3; // rbx
__int64 v4; // rdx
double v5; // xmm0_8
double v6; // xmm1_8
__int64 v7; // rsi
int result; // eax

if ( a1 > 0 )
{
v2 = 1;
v3 = (double *)(a2 + 24);
do
{
while ( 1 )
{
v4 = *(unsigned int *)v3;
if ( (_DWORD)v4 )
break;
++v2;
v3 += 3;
if ( a1 < v2 )
return result;
}
v5 = v3[2];
v6 = v3[1];
v7 = (unsigned int)v2++;
v3 += 3;
result = printf("%2d: %2d : (%.1f, %.1f)\n", v7, v4, v5, v6);
}
while ( a1 >= v2 );
}
return result;
}

canonical_decompiled_code:
int __fastcall func1(int a1, __int64 a2)
{
int v2; // ebp
double *v3; // rbx
__int64 v4; // rdx
double v5; // xmm0_8
double v6; // xmm1_8
__int64 v7; // rsi
int result; // eax

if ( a1 > 0 )
{
v2 = 1;
v3 = (double *)(a2 + 24);
do
{
while ( 1 )
{
v4 = *(unsigned int *)v3;
if ( (_DWORD)v4 )
break;
++v2;
v3 += 3;
if ( a1 < v2 )
return result;
}
v5 = v3[2];
v6 = v3[1];
v7 = (unsigned int)v2++;
v3 += 3;
result = printf("%2d: %2d : (%.1f, %.1f)\n", v7, v4, v5, v6);
}
while ( a1 >= v2 );
}
return result;
}

original_code:
void prtFeature(int n, FEATURE *f)
{
  int i;
  for (i = 1; i <= n; i++) {
    if (f[i].area != 0) {
      printf("%2d:  %2d : (%.1f, %.1f)\n", i, f[i].area, f[i].cy, f[i].cx);
    }
  }
}

canonical_original_code:
void prtFeature(int n, struct FEATURE *f)
{
  int i;
  for (i = 1; i <= n; i++) {
    if (f[i].area != 0) {
      printf("%2d:  %2d : (%.1f, %.1f)\n", i, f[i].area, f[i].cy, f[i].cx);
    }
  }
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_BYTE v4[248]; // [rsp+0h] [rbp-F8h] BYREF

calc(5, 10, 4, (__int64)&Im, (__int64)v4);
prtFeature(4, (__int64)v4);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_BYTE v4[248]; // [rsp+0h] [rbp-F8h] BYREF

func0(5, 10, 4, (__int64)&Im, (__int64)v4);
func1(4, (__int64)v4);
return 0;
}

original_code:
int main(void)
{
  FEATURE fea[10];
  calc(5, 10, 4, Im, fea);
  prtFeature(4, fea);
  return 0;
}

canonical_original_code:
int main()
{
  struct FEATURE fea[10];
  calc(5, 10, 4, Im, fea);
  prtFeature(4, fea);
  return 0;
}

variable_types: struct FEATURE { int area; double cx; } [10]


original_code:
int median_value(int d[], int num)
{
  int i, j, tmp;
  for (i = 0; i < num - 1; i++) {
    for (j = i + 1; j < num; j++) {
      if (d[i] > d[j]) {
        tmp = d[i];
        d[i] = d[j];
        d[j] = tmp;
      }
    }
  }
  return d[num / 2];
}

canonical_original_code:
int median_value(int d[], int num)
{
  int i; int j; int tmp;
  for (i = 0; i < num - 1; i++) {
    for (j = i + 1; j < num; j++) {
      if (d[i] > d[j]) {
        tmp = d[i];
        d[i] = d[j];
        d[j] = tmp;
      }
    }
  }
  return d[num / 2];
}

variable_types:
d
int []

variable_types: num int

variable_types: j int

variable_types: tmp int


median

variable_types: i int


prtData

decompiled_code:
int __fastcall prtData(__int64 a1)
{
unsigned int *v1; // rbp
unsigned int *v2; // rbx
__int64 v3; // rsi
int result; // eax

v1 = (unsigned int *)(a1 + 48);
do
{
v2 = v1 - 12;
do
{
v3 = *v2++;
printf(" %2d", v3);
}
while ( v2 != v1 );
v1 = v2 + 12;
result = puts(&s);
}
while ( v2 + 12 != (unsigned int *)(a1 + 336) );
return result;
}

canonical_decompiled_code:
int __fastcall func3(__int64 a1)
{
unsigned int *v1; // rbp
unsigned int *v2; // rbx
__int64 v3; // rsi
int result; // eax

v1 = (unsigned int *)(a1 + 48);
do
{
v2 = v1 - 12;
do
{
v3 = *v2++;
printf(" %2d", v3);
}
while ( v2 != v1 );
v1 = v2 + 12;
result = puts(&s);
}
while ( v2 + 12 != (unsigned int *)(a1 + 336) );
return result;
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er12
char *v4; // rdx
double v5; // xmm0_8
int v6; // eax
int v7; // er13
char *i; // rbp
int v10[12]; // [rsp+10h] [rbp-258h] BYREF
char v11; // [rsp+40h] [rbp-228h] BYREF
char v12; // [rsp+130h] [rbp-138h] BYREF

makeData((__int64)v10);
puts(&byte_32E);
prtData((__int64)v10);
v3 = v10[0];
v4 = &v11;
v5 = 0.0;
v6 = v10[0];
v7 = v10[0];
while ( 1 )
{
for ( i = v4 - 44; ; i += 4 )
{
if ( v3 > v6 )
v3 = v6;
if ( v7 < v6 )
v7 = v6;
v5 = v5 + (double)v6;
if ( i == v4 )
break;
v6 = *(_DWORD *)i;
}
if ( v4 == &v12 )
break;
v6 = *(_DWORD *)v4;
v4 += 48;
}
puts(asc_33E);
printf("%4d|%4d|%4.1f\n", (unsigned int)v3, (unsigned int)v7, v5 / 72.0);
median((__int64)v10, (__int64)i, 5);
printf(aDxD, 5LL, 5LL);
prtData((__int64)i);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er12
char *v4; // rdx
double v5; // xmm0_8
int v6; // eax
int v7; // er13
char *i; // rbp
int v10[12]; // [rsp+10h] [rbp-258h] BYREF
char v11; // [rsp+40h] [rbp-228h] BYREF
char v12; // [rsp+130h] [rbp-138h] BYREF

func2((__int64)v10);
puts(&byte_32E);
func3((__int64)v10);
v3 = v10[0];
v4 = &v11;
v5 = 0.0;
v6 = v10[0];
v7 = v10[0];
while ( 1 )
{
for ( i = v4 - 44; ; i += 4 )
{
if ( v3 > v6 )
v3 = v6;
if ( v7 < v6 )
v7 = v6;
v5 = v5 + (double)v6;
if ( i == v4 )
break;
v6 = *(_DWORD *)i;
}
if ( v4 == &v12 )
break;
v6 = *(_DWORD *)v4;
v4 += 48;
}
puts(asc_33E);
printf("%4d|%4d|%4.1f\n", (unsigned int)v3, (unsigned int)v7, v5 / 72.0);
func1((__int64)v10, (__int64)i, 5);
printf(aDxD, 5LL, 5LL);
func3((__int64)i);
return 0;
}

original_code:
int main(void)
{
  int in[6][12], out[6][12];
  int m = 5, min, max, i, j;
  double ave;
  makeData(in);
  printf("入力データ\n");
  prtData(in);
  min = max = in[0][0];
  ave = 0;
  for (i = 0; i < 6; i++) {
    for (j = 0; j < 12; j++) {
      ave += in[i][j];
      if (min > in[i][j]) min = in[i][j];
      if (max < in[i][j]) max = in[i][j];
    }
  }
  printf("\n最小|最大|平均\n");
  printf("%4d|%4d|%4.1f\n", min, max, ave / (6 * 12));
  median(in, out, m);
  printf("\n%dx%dメディアンフィルタ\n", m, m);
  prtData(out);
  return 0;
}

canonical_original_code:
int main()
{
  int in[6][12]; int out[6][12];
  int m = 5; int min; int max; int i; int j;
  double ave;
  makeData(in);
  printf("入力データ\n");
  prtData(in);
  min = max = in[0][0];
  ave = 0;
  for (i = 0; i < 6; i++) {
    for (j = 0; j < 12; j++) {
      ave += in[i][j];
      if (min > in[i][j]) min = in[i][j];
      if (max < in[i][j]) max = in[i][j];
    }
  }
  printf("\n最小|最大|平均\n");
  printf("%4d|%4d|%4.1f\n", min, max, ave / (6 * 12));
  median(in, out, m);
  printf("\n%dx%dメディアンフィルタ\n", m, m);
  prtData(out);
  return 0;
}

variable_types: min int

variable_types: max int

variable_types: ave double


inputData

decompiled_code:
__int64 __fastcall inputData(__int64 a1)
{
__int64 result; // rax
int v3; // ebx
__int64 v4; // rsi
unsigned int v5[7]; // [rsp+Ch] [rbp-1Ch] BYREF

printf(&format);
_isoc99_scanf(&unk_1DA, v5);
result = v5[0];
if ( (int)v5[0] > 0 )
{
v3 = 0;
do
{
v4 = (unsigned int)v3++;
printf(&byte_1DD, v4);
_isoc99_scanf(&unk_1EE, a1);
result = v5[0];
a1 += 8LL;
}
while ( (int)v5[0] > v3 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
__int64 result; // rax
int v3; // ebx
__int64 v4; // rsi
unsigned int v5[7]; // [rsp+Ch] [rbp-1Ch] BYREF

printf(&format);
_isoc99_scanf(&unk_1DA, v5);
result = v5[0];
if ( (int)v5[0] > 0 )
{
v3 = 0;
do
{
v4 = (unsigned int)v3++;
printf(&byte_1DD, v4);
_isoc99_scanf(&unk_1EE, a1);
result = v5[0];
a1 += 8LL;
}
while ( (int)v5[0] > v3 );
}
return result;
}

original_code:
int inputData(double x[])
{
  int i, n;
  printf("データ数: ");
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    printf("データ数%d: ", i);
    scanf("%lf", &x[i]);
  }
  return n;
}

canonical_original_code:
int inputData(double x[])
{
  int i; int n;
  printf("データ数: ");
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    printf("データ数%d: ", i);
    scanf("%lf", &x[i]);
  }
  return n;
}

variable_types:
x
double []

variable_types: n int


dft

variable_types: struct Complex { double rl; double im; } []

variable_types: k int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
__int64 v4; // rbp
__int64 i; // rbx
__int64 v6; // rax
__int64 v7; // rsi
_BYTE v9[800]; // [rsp+0h] [rbp-978h] BYREF
__int64 v10[203]; // [rsp+320h] [rbp-658h] BYREF

v3 = inputData((__int64)v9);
v4 = v3;
dft(v3, (__int64)v9, (double *)v10);
puts("| k| f.rl| f.im|");
if ( (int)v4 > 0 )
{
for ( i = 0LL; i != v4; ++i )
{
v6 = i;
v7 = (unsigned int)i;
printf("|%2d|%5.1f|%5.1f|\n", v7, *(double *)&v10[2 * v6], *(double *)&v10[2 * v6 + 1]);
}
}
return 0;
}

original_code:
int main(void)
{
  int k, n;
  double x[100];
  Complex f[100];
  n = inputData(x);
  dft(n, x, f);
  printf("| k| f.rl| f.im|\n");
  for (k = 0; k < n; k++) {
    printf("|%2d|%5.1f|%5.1f|\n", k, f[k].rl, f[k].im);
  }
  return 0;
}

canonical_original_code:
int main()
{
  int k; int n;
  double x[100];
  struct Complex f[100];
  n = inputData(x);
  dft(n, x, f);
  printf("| k| f.rl| f.im|\n");
  for (k = 0; k < n; k++) {
    printf("|%2d|%5.1f|%5.1f|\n", k, f[k].rl, f[k].im);
  }
  return 0;
}

variable_types:
x
double [100]

variable_types: struct Complex { double rl; double im; } [100]


capital

decompiled_code:
int __fastcall capital(char *a1)
{
__int64 v1; // rbx
char *v2; // rbp
int v3; // er12
int v4; // edi

v1 = *a1;
if ( (_BYTE)v1 )
{
v2 = a1;
v3 = 1;
do
{
if ( (_BYTE)v1 == 32 )
{
v4 = 32;
v3 = 1;
}
else
{
v4 = (char)v1;
if ( v3 )
{
v3 = 0;
v4 = (*_ctype_toupper_loc())[v1];
}
}
putchar(v4);
v1 = *++v2;
}
while ( (_BYTE)v1 );
}
return putchar(10);
}

canonical_decompiled_code:
int __fastcall func0(char *a1)
{
__int64 v1; // rbx
char *v2; // rbp
int v3; // er12
int v4; // edi

v1 = *a1;
if ( (_BYTE)v1 )
{
v2 = a1;
v3 = 1;
do
{
if ( (_BYTE)v1 == 32 )
{
v4 = 32;
v3 = 1;
}
else
{
v4 = (char)v1;
if ( v3 )
{
v3 = 0;
v4 = (*_ctype_toupper_loc())[v1];
}
}
putchar(v4);
v1 = *++v2;
}
while ( (_BYTE)v1 );
}
return putchar(10);
}

original_code:
void capital(char *st)
{
  int is_top = 1;
  int ch;
  for (; *st != '\0'; st++) {
    if (*st == ' ') {
      ch = ' ';
      is_top = 1;
    } else if (is_top) {
      ch = toupper(*st);
      is_top = 0;
    } else {
      ch = *st;
      is_top = 0;
    }
    putchar(ch);
  }
  putchar('\n');
}

variable_types:
st
char *

variable_types: ch int


main

original_code:
int main(void) {
    char str[2][30] = {
      "doshisha university",
      "kyotanabe, 610-0321 japan"
    };
    int i;
    for (i = 0; i < 2; i++) {
      capital(str[i]);
    }
    return 0;
}

canonical_original_code:
int main() {
    char str[2][30] = {
      "doshisha university",
      "kyotanabe, 610-0321 japan"
    };
    int i;
    for (i = 0; i < 2; i++) {
      capital(str[i]);
    }
    return 0;
}

variable_types:
str
char [2][30]


inputData

decompiled_code:
__int64 __fastcall inputData(__int64 a1)
{
FILE *v1; // rax
FILE *v2; // rbp
__int64 i; // rbx
unsigned int v4; // er13
int v6; // [rsp+Ch] [rbp-2Ch] BYREF

v1 = fopen("input.txt", "r");
if ( !v1 )
return (unsigned int)-1;
v2 = v1;
for ( i = 0LL; ; ++i )
{
v4 = i;
if ( (unsigned int)_isoc99_fscanf(v2, "%d", &v6) == -1 )
break;
*(_DWORD *)(a1 + 4 * i) = v6;
}
fclose(v2);
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
FILE *v1; // rax
FILE *v2; // rbp
__int64 i; // rbx
unsigned int v4; // er13
int v6; // [rsp+Ch] [rbp-2Ch] BYREF

v1 = fopen("input.txt", "r");
if ( !v1 )
return (unsigned int)-1;
v2 = v1;
for ( i = 0LL; ; ++i )
{
v4 = i;
if ( (unsigned int)_isoc99_fscanf(v2, "%d", &v6) == -1 )
break;
*(_DWORD *)(a1 + 4 * i) = v6;
}
fclose(v2);
return v4;
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbp

v3 = (unsigned int)inputData((__int64)data);
printf(&byte_1120, v3);
sort(v3, (__int64)data);
outputData(v3, data);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbp

v3 = (unsigned int)func0((__int64)data);
printf(&byte_1120, v3);
func1(v3, (__int64)data);
func2(v3, data);
return 0;
}

user_defined_types: struct Complex { double rl; double im; }


decompiled_code:
__int64 __fastcall func1(int a1, __int64 a2, _DWORD *a3, _DWORD *a4, double *a5)
{
__int64 result; // rax
double v9; // xmm0_8

sort(a1, a2);
*a3 = *(_DWORD *)(a2 + 36);
result = *(unsigned int *)(a2 + 40LL * a1 - 4);
*a4 = result;
v9 = (double)*(int *)(a2 + 36);
if ( a1 > 1 )
{
result = a2 + 76;
do
{
result += 40LL;
v9 = v9 + (double)*(int *)(result - 40);
}
while ( result != a2 + 40LL * (unsigned int)(a1 - 2) + 116 );
}
*a5 = v9 / (double)a1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, __int64 a2, _DWORD *a3, _DWORD *a4, double *a5)
{
__int64 result; // rax
double v9; // xmm0_8

sort(a1, a2);
*a3 = *(_DWORD *)(a2 + 36);
result = *(unsigned int *)(a2 + 40LL * a1 - 4);
*a4 = result;
v9 = (double)*(int *)(a2 + 36);
if ( a1 > 1 )
{
result = a2 + 76;
do
{
result += 40LL;
v9 = v9 + (double)*(int *)(result - 40);
}
while ( result != a2 + 40LL * (unsigned int)(a1 - 2) + 116 );
}
*a5 = v9 / (double)a1;
return result;
}

original_code:
void func1(int n, Seiseki a[], int *max, int *min, double *ave)
{
  int i;
  double t;
  sort(n, a);
  *max = a[0].ten;
  *min = a[n - 1].ten;
  t = a[0].ten;
  for (i = 1; i < n; i++) {
    t += a[i].ten;
  }
  *ave = t / n;
}

canonical_original_code:
void func1(int n, struct Seiseki a[], int *max, int *min, double *ave)
{
  int i;
  double t;
  sort(n, a);
  *max = a[0].ten;
  *min = a[n - 1].ten;
  t = a[0].ten;
  for (i = 1; i < n; i++) {
    t += a[i].ten;
  }
  *ave = t / n;
}

variable_types: struct Seiseki { int no; char name[30]; int ten; } []

variable_types:
max
int *

variable_types:
min
int *

variable_types:
ave
double *

variable_types: t double


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v4; // [rsp+0h] [rbp-18h] BYREF
unsigned int v5; // [rsp+4h] [rbp-14h] BYREF
double v6[2]; // [rsp+8h] [rbp-10h] BYREF

func1(4, (__int64)&s_0, &v4, &v5, v6);
printf(&format, v4, (unsigned int)s_0, &unk_164);
printf(&byte_220, v5, v6[0]);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v4; // [rsp+0h] [rbp-18h] BYREF
unsigned int v5; // [rsp+4h] [rbp-14h] BYREF
double v6[2]; // [rsp+8h] [rbp-10h] BYREF

func0(4, (__int64)&s_0, &v4, &v5, v6);
printf(&format, v4, (unsigned int)s_0, &unk_164);
printf(&byte_220, v5, v6[0]);
return 0;
}

original_code:
int main(void)
{
  static Seiseki s[] = {
    {1, "あいうえお", 77},
    {2, "かきくけこ", 57},
    {3, "さしすせそ", 100},
    {4, "たちつてと", 85},
  };
  int n = 4, max, min;
  double ave;
  func1(n, s, &max, &min, &ave);
  printf("最高点 = %d (%d番 : %s)\n", max, s[0].no, s[0].name);
  printf("最低点 = %d  平均点 = %5.1f\n", min, ave);
  return 0;
}

canonical_original_code:
int main()
{
  static struct Seiseki s[] = {
    {1, "あいうえお", 77},
    {2, "かきくけこ", 57},
    {3, "さしすせそ", 100},
    {4, "たちつてと", 85},
  };
  int n = 4; int max; int min;
  double ave;
  func1(n, s, &max, &min, &ave);
  printf("最高点 = %d (%d番 : %s)\n", max, s[0].no, s[0].name);
  printf("最低点 = %d  平均点 = %5.1f\n", min, ave);
  return 0;
}

variable_types: min int

user_defined_types: struct Seiseki { int no; char name[30]; int ten; }


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rax
_BYTE v5[264]; // [rsp+0h] [rbp-108h] BYREF

v3 = read(0LL, v5, 256LL);
write(1LL, v5, v3);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rax
_BYTE v5[264]; // [rsp+0h] [rbp-108h] BYREF

v3 = func1(0LL, v5, 256LL);
func0(1LL, v5, v3);
return 0;
}

original_code:
int main(int argc, char* argv[])
{
 long len;
 char buf[256];
 len = read(0, buf, 256);
 write(1, buf, len);
 return 0;
}

canonical_original_code:
int main(int argc, char *argv[])
{
 long len;
 char buf[256];
 len = read(0, buf, 256);
 write(1, buf, len);
 return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: len long

variable_types:
buf
char [256]


exit

decompiled_code:
void __fastcall __noreturn exit(int status)
{
__asm { int 80h; LINUX - sys_exit }
}

canonical_decompiled_code:
void __fastcall __noreturn func2(int status)
{
__asm { int 80h; LINUX - sys_exit }
}

original_code:
void exit(int status)
{
 asm ( "movl %0, %%ebx	\n\t"
   "movq $1, %%rax		\n\t"
   "int $0x80			\n\t"
   :
   :"r"(status)
   :);
}

variable_types: status int


repo: koukaipan/xen-examples

decompiled_code:
void __fastcall __noreturn start_kernel(__int64 a1)
{
HYPERVISOR_update_va_mapping_constprop_0_isra_0(4096LL, *(_QWORD *)(a1 + 40) | 7LL);
edata = 4096LL;
init_events();
console_init(a1);
console_write("Hello world!\r\n");
while ( 1 )
HYPERVISOR_sched_op_constprop_0_isra_0();
}

canonical_decompiled_code:
void __fastcall __noreturn func2(__int64 a1)
{
func1(4096LL, *(_QWORD *)(a1 + 40) | 7LL);
edata = 4096LL;
func16();
func5(a1);
func6("Hello world!\r\n");
while ( 1 )
func0();
}

original_code:
void start_kernel(start_info_t * start_info)
{
 HYPERVISOR_update_va_mapping((unsigned long) &shared_info,
   ((pte_t) { (start_info->shared_info | 7) } ),
   (2UL<<0));
 HYPERVISOR_shared_info = &shared_info;
 init_events();
 console_init(start_info);
 console_write("Hello world!\r\n");
 while(1)
 {
  HYPERVISOR_sched_op(1,0);
 }
}

canonical_original_code:
void start_kernel(struct start_info *start_info)
{
 HYPERVISOR_update_va_mapping((unsigned long) &shared_info,
   ((struct pte_t) { (start_info->shared_info | 7) } ),
   (2UL<<0));
 HYPERVISOR_shared_info = &shared_info;
 init_events();
 console_init(start_info);
 console_write("Hello world!\r\n");
 while(1)
 {
  HYPERVISOR_sched_op(1,0);
 }
}

variable_types: struct start_info { char magic[32]; unsigned long nr_pages; unsigned long shared_info; unsigned int flags; unsigned long store_mfn; unsigned int store_evtchn; union { struct { unsigned long mfn; unsigned int evtchn; } domU; struct { unsigned int info_off; unsigned int info_size; } dom0; } console; unsigned long pt_base; unsigned long nr_pt_frames; unsigned long mfn_list; unsigned long mod_start; unsigned long mod_len; char cmd_line[1024]; unsigned long first_p2m_pfn; unsigned long nr_p2m_frames; } *


decompiled_code:
__int64 __fastcall console_write(_BYTE *a1)
{
bool v1; // zf
int *v2; // r8
_BYTE *v3; // rcx
unsigned int v4; // edx
unsigned int v5; // er10
__int64 result; // rax
unsigned int v7; // er10
int v8; // [rsp+Ch] [rbp-4h] BYREF

v1 = *a1 == 0;
v8 = console_evt;
if ( v1 )
{
HYPERVISOR_event_channel_op_constprop_0_isra_0((__int64)&v8);
result = v7;
}
else
{
v2 = &v8;
do
{
do
{
HYPERVISOR_event_channel_op_constprop_0_isra_0((__int64)v2);
_mm_mfence();
}
while ( v4 > 0x7FF );
*(_BYTE *)(console + ((*(_DWORD *)(console + 3084))++ & 0x7FF) + 1024) = *v3;
}
while ( v3[1] );
HYPERVISOR_event_channel_op_constprop_0_isra_0((__int64)v2);
result = v5;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(_BYTE *a1)
{
bool v1; // zf
int *v2; // r8
_BYTE *v3; // rcx
unsigned int v4; // edx
unsigned int v5; // er10
__int64 result; // rax
unsigned int v7; // er10
int v8; // [rsp+Ch] [rbp-4h] BYREF

v1 = *a1 == 0;
v8 = console_evt;
if ( v1 )
{
func4((__int64)&v8);
result = v7;
}
else
{
v2 = &v8;
do
{
do
{
func4((__int64)v2);
_mm_mfence();
}
while ( v4 > 0x7FF );
*(_BYTE *)(console + ((*(_DWORD *)(console + 3084))++ & 0x7FF) + 1024) = *v3;
}
while ( v3[1] );
func4((__int64)v2);
result = v5;
}
return result;
}

original_code:
int console_write(char * message)
{
 struct evtchn_send event;
 event.port = console_evt;
 int length = 0;
 while(*message != '\0')
 {
  XENCONS_RING_IDX data;
  do
  {
   data = console->out_prod - console->out_cons;
   HYPERVISOR_event_channel_op(4, &event);
   __asm__ __volatile__ ( "mfence" : : : "memory");
  } while (data >= sizeof(console->out));
  int ring_index = ((console->out_prod) & (sizeof(console->out)-1));
  console->out[ring_index] = *message;
  __asm__ __volatile__ ( "" : : : "memory");
  console->out_prod++;
  length++;
  message++;
 }
 HYPERVISOR_event_channel_op(4, &event);
 return length;
}

canonical_original_code:
int console_write(char *message)
{
 struct evtchn_send event;
 event.port = console_evt;
 int length = 0;
 while(*message != '\0')
 {
  unsigned int data;
  do
  {
   data = console->out_prod - console->out_cons;
   HYPERVISOR_event_channel_op(4, &event);
   __asm__ __volatile__ ( "mfence" : : : "memory");
  } while (data >= sizeof(console->out));
  int ring_index = ((console->out_prod) & (sizeof(console->out)-1));
  console->out[ring_index] = *message;
  __asm__ __volatile__ ( "" : : : "memory");
  console->out_prod++;
  length++;
  message++;
 }
 HYPERVISOR_event_channel_op(4, &event);
 return length;
}

variable_types:
message
char *

variable_types: struct evtchn_send { unsigned int port; }

variable_types: length int

variable_types:
data
unsigned int


decompiled_code:
__int64 handle_input()
{
__int64 result; // rax
char v1[10]; // [rsp+0h] [rbp-Ah] BYREF

result = console;
if ( *(_DWORD *)(console + 3076) - *(_DWORD *)(console + 3072) > 0 )
{
console_read(v1, *(_DWORD *)(console + 3076) - *(_DWORD *)(console + 3072) + 1);
result = console_write(v1);
}
return result;
}

canonical_decompiled_code:
__int64 func8()
{
__int64 result; // rax
char v1[10]; // [rsp+0h] [rbp-Ah] BYREF

result = console;
if ( *(_DWORD *)(console + 3076) - *(_DWORD *)(console + 3072) > 0 )
{
func7(v1, *(_DWORD *)(console + 3076) - *(_DWORD *)(console + 3072) + 1);
result = func6(v1);
}
return result;
}

original_code:
void handle_input(evtchn_port_t port, struct pt_regs * regs)
{
 XENCONS_RING_IDX cons = console->in_cons;
 XENCONS_RING_IDX prod = console->in_prod;
 int length = prod - cons;
 if(length > 0)
 {
  char buffer[10];
  console_read(buffer, ++length);
  console_write(buffer);
 }
}

canonical_original_code:
void handle_input(unsigned int port, struct pt_regs *regs)
{
 unsigned int cons = console->in_cons;
 unsigned int prod = console->in_prod;
 int length = prod - cons;
 if(length > 0)
 {
  char buffer[10];
  console_read(buffer, ++length);
  console_write(buffer);
 }
}

variable_types:
port
unsigned int

variable_types: struct pt_regs { long ebx; long ecx; long edx; long esi; long edi; long ebp; long eax; int xds; int xes; long orig_eax; long eip; int xcs; long eflags; long esp; int xss; } *

variable_types:
cons
unsigned int

variable_types:
prod
unsigned int

variable_types:
buffer
char [10]


atoc

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

result = a1 + 48;
if ( a1 >= 0xA )
result = 120LL;
return result;
}

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

result = a1 + 48;
if ( a1 >= 0xA )
result = 120LL;
return result;
}

original_code:
char atoc(int n)
{
 switch(n)
 {
  case 0: return '0';
  case 1: return '1';
  case 2: return '2';
  case 3: return '3';
  case 4: return '4';
  case 5: return '5';
  case 6: return '6';
  case 7: return '7';
  case 8: return '8';
  case 9: return '9';
  default: return 'x';
 }
}

variable_types: n int

return_type: char


decompiled_code:
void EVT_IGN()
{
;
}

canonical_decompiled_code:
void func12()
{
;
}

original_code: void EVT_IGN(evtchn_port_t port, struct pt_regs * regs) {}

canonical_original_code: void EVT_IGN(unsigned int port, struct pt_regs *regs) {}

user_defined_types: struct pt_regs { long ebx; long ecx; long edx; long esi; long edi; long ebp; long eax; int xds; int xes; long orig_eax; long eip; int xcs; long eflags; long esp; int xss; }


decompiled_code:
__int64 __fastcall first_bit(unsigned __int64 a1)
{
__int64 result; // rax

_BitScanForward64((unsigned __int64 *)&result, a1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func13(unsigned __int64 a1)
{
__int64 result; // rax

_BitScanForward64((unsigned __int64 *)&result, a1);
return result;
}

original_code:
static inline unsigned long int first_bit(unsigned long int word)
{
 __asm__("bsfq %1,%0"
  :"=r" (word)
  :"rm" (word));
 return word;
}

canonical_original_code:
static inline unsigned long first_bit(unsigned long word)
{
 __asm__("bsfq %1,%0"
  :"=r" (word)
  :"rm" (word));
 return word;
}

variable_types:
word
unsigned long

return_type: unsigned long


decompiled_code:
// write access to const memory has been detected, the output may be wrong!
__int64 init_events()
{
__int64 result; // rax

HYPERVISOR_set_callbacks_constprop_0_isra_0(12396LL, 12796LL);
for ( result = 0LL; result != 1024; ++result )
{
handlers[result] = 14144LL;
_interlockedbittestandset(&dword_1A00, result);
}
BYTE1(shared_info) = 0;
return result;
}

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

func15(12396LL, 12796LL);
for ( result = 0LL; result != 1024; ++result )
{
handlers[result] = 14144LL;
_interlockedbittestandset(&dword_1A00, result);
}
BYTE1(shared_info) = 0;
return result;
}

original_code:
void init_events(void)
{
 HYPERVISOR_set_callbacks(
  (unsigned long)hypervisor_callback,
  (unsigned long)failsafe_callback, 0);
 for(unsigned int i=0 ; i<(1024) ; i++)
 {
  handlers[i] = EVT_IGN;
  __asm__ __volatile__ ("lock btsl %1,%0":"=m"(shared_info.evtchn_mask[0]):"Ir"(i):"memory" );;
 }
 shared_info.vcpu_info[0].evtchn_upcall_mask = 0;
}

canonical_original_code:
void init_events()
{
 HYPERVISOR_set_callbacks(
  (unsigned long)hypervisor_callback,
  (unsigned long)failsafe_callback, 0);
 for(unsigned int i = 0; i<(1024) ; i++)
 {
  handlers[i] = EVT_IGN;
  __asm__ __volatile__ ("lock btsl %1,%0":"=m"(shared_info.evtchn_mask[0]):"Ir"(i):"memory" );;
 }
 shared_info.vcpu_info[0].evtchn_upcall_mask = 0;
}

variable_types:
i
unsigned int


decompiled_code:
__int64 __fastcall register_event(unsigned int a1, __int64 a2)
{
__int64 result; // rax

result = a1;
handlers[a1] = a2;
_interlockedbittestandreset(&dword_1A00, a1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func17(unsigned int a1, __int64 a2)
{
__int64 result; // rax

result = a1;
handlers[a1] = a2;
_interlockedbittestandreset(&dword_1A00, a1);
return result;
}

original_code:
void register_event(evtchn_port_t port, evtchn_handler_t handler)
{
 handlers[port] = handler;
 __asm__ __volatile__ ("lock btrl %1,%0":"=m" ((shared_info.evtchn_mask)):"Ir"((port)):"memory");
}

canonical_original_code:
void register_event(unsigned int port, void (*handler)(unsigned int, struct pt_regs *))
{
 handlers[port] = handler;
 __asm__ __volatile__ ("lock btrl %1,%0":"=m" ((shared_info.evtchn_mask)):"Ir"((port)):"memory");
}

variable_types: void (*)(unsigned int, struct pt_regs { long ebx; long ecx; long edx; long esi; long edi; long ebp; long eax; int xds; int xes; long orig_eax; long eip; int xcs; long eflags; long esp; int xss; } *)


decompiled_code:
void do_divide_error()
{
;
}

canonical_decompiled_code:
void func20()
{
;
}

original_code: void do_divide_error(void) {}

canonical_original_code: void do_divide_error() {}


decompiled_code:
void do_debug()
{
;
}

canonical_decompiled_code:
void func21()
{
;
}

original_code: void do_debug(void) {}

canonical_original_code: void do_debug() {}


decompiled_code:
void do_int3()
{
;
}

canonical_decompiled_code:
void func22()
{
;
}

original_code: void do_int3(void) {}

canonical_original_code: void do_int3() {}


decompiled_code:
void do_overflow()
{
;
}

canonical_decompiled_code:
void func23()
{
;
}

original_code: void do_overflow(void) {}

canonical_original_code: void do_overflow() {}


decompiled_code:
void do_bounds()
{
;
}

canonical_decompiled_code:
void func24()
{
;
}

original_code: void do_bounds(void) {}

canonical_original_code: void do_bounds() {}


decompiled_code:
void do_invalid_op()
{
;
}

canonical_decompiled_code:
void func25()
{
;
}

original_code: void do_invalid_op(void) {}

canonical_original_code: void do_invalid_op() {}


decompiled_code:
void do_device_not_available()
{
;
}

canonical_decompiled_code:
void func26()
{
;
}

original_code: void do_device_not_available(void) {}

canonical_original_code: void do_device_not_available() {}


decompiled_code:
void do_coprocessor_segment_overrun()
{
;
}

canonical_decompiled_code:
void func27()
{
;
}


decompiled_code:
void do_invalid_TSS()
{
;
}

canonical_decompiled_code:
void func28()
{
;
}

original_code: void do_invalid_TSS(void) {}

canonical_original_code: void do_invalid_TSS() {}


decompiled_code:
void do_segment_not_present()
{
;
}

canonical_decompiled_code:
void func29()
{
;
}

original_code: void do_segment_not_present(void) {}

canonical_original_code: void do_segment_not_present() {}


decompiled_code:
void do_stack_segment()
{
;
}

canonical_decompiled_code:
void func30()
{
;
}

original_code: void do_stack_segment(void) {}

canonical_original_code: void do_stack_segment() {}


decompiled_code:
void do_general_protection()
{
;
}

canonical_decompiled_code:
void func31()
{
;
}

original_code: void do_general_protection(void) {}

canonical_original_code: void do_general_protection() {}


decompiled_code:
void do_page_fault()
{
;
}

canonical_decompiled_code:
void func32()
{
;
}

original_code: void do_page_fault(void) {}

canonical_original_code: void do_page_fault() {}


decompiled_code:
void do_coprocessor_error()
{
;
}

canonical_decompiled_code:
void func33()
{
;
}

original_code: void do_coprocessor_error(void) {}

canonical_original_code: void do_coprocessor_error() {}


decompiled_code:
void do_simd_coprocessor_error()
{
;
}

canonical_decompiled_code:
void func34()
{
;
}

original_code: void do_simd_coprocessor_error(void) {}

canonical_original_code: void do_simd_coprocessor_error() {}


decompiled_code:
void do_alignment_check()
{
;
}

canonical_decompiled_code:
void func35()
{
;
}

original_code: void do_alignment_check(void) {}

canonical_original_code: void do_alignment_check() {}


decompiled_code:
void do_spurious_interrupt_bug()
{
;
}

canonical_decompiled_code:
void func36()
{
;
}

original_code: void do_spurious_interrupt_bug(void) {}

canonical_original_code: void do_spurious_interrupt_bug() {}


decompiled_code:
void do_machine_check()
{
;
}

canonical_decompiled_code:
void func37()
{
;
}

original_code: void do_machine_check(void) {}

canonical_original_code: void do_machine_check() {}


decompiled_code:
// attributes: thunk
__int64 trap_init()
{
return HYPERVISOR_set_trap_table_constprop_0_isra_0();
}

canonical_decompiled_code:
__int64 func38()
{
return func19();
}

original_code:
void trap_init(void)
{
    HYPERVISOR_set_trap_table(trap_table);
}

canonical_original_code:
void trap_init()
{
    HYPERVISOR_set_trap_table(trap_table);
}


decompiled_code:
__int64 __fastcall pcap__connect(__int64 a1)
{
if ( !a1 )
_assert_fail("d", "analysis/pcap.c", 0x2Eu, "pcap__connect");
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
if ( !a1 )
_assert_fail("d", "analysis/pcap.c", 0x2Eu, "pcap__connect");
return 0LL;
}

canonical_original_code:
enum err_t pcap__connect(void *d)
{
    ((void) sizeof ((d) ? 1 : 0), __extension__ ({ if (d) ; else __assert_fail ("d", "analysis/pcap.c", 46, __extension__ __PRETTY_FUNCTION__); }));
    return ERR_NONE;
}

variable_types:
d
void *

return_type: enum err_t { ERR_NONE=0, ERR_SEND_FAILED=1, ERR_RECV_FAILED=2, ERR_CONNECTION_FAILED=3, ERR_CONNECTION_CLOSED=4, ERR_TIMEOUT=5, ERR_READ_FAILURE=6, ERR_WRITE_FAILURE=7, ERR_NO_SUCH_VALUE=8, ERR_NOT_SUPPORTED=9, ERR_UNKNOWN=10 }


decompiled_code:
void __fastcall pcap__disconnect(__int64 a1)
{
if ( !a1 )
_assert_fail("d", "analysis/pcap.c", 0x34u, "pcap__disconnect");
}

canonical_decompiled_code:
void __fastcall func1(__int64 a1)
{
if ( !a1 )
_assert_fail("d", "analysis/pcap.c", 0x34u, "pcap__disconnect");
}

original_code:
void pcap__disconnect(void *d)
{
    ((void) sizeof ((d) ? 1 : 0), __extension__ ({ if (d) ; else __assert_fail ("d", "analysis/pcap.c", 52, __extension__ __PRETTY_FUNCTION__); }));
}


decompiled_code:
__int64 __fastcall ppkt_prefix_header(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // rdx

if ( !a2 )
_assert_fail("p", "lib/ppkt.c", 0x3Cu, "ppkt_prefix_header");
if ( !a1 )
_assert_fail("hdr", "lib/ppkt.c", 0x3Du, "ppkt_prefix_header");
if ( a2 == a1 )
_assert_fail("p != hdr", "lib/ppkt.c", 0x3Eu, "ppkt_prefix_header");
v2 = a1;
do
{
v3 = v2;
v2 = *(_QWORD *)(v2 + 24);
}
while ( v2 );
*(_QWORD *)(v3 + 24) = a2;
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // rdx

if ( !a2 )
_assert_fail("p", "lib/ppkt.c", 0x3Cu, "ppkt_prefix_header");
if ( !a1 )
_assert_fail("hdr", "lib/ppkt.c", 0x3Du, "ppkt_prefix_header");
if ( a2 == a1 )
_assert_fail("p != hdr", "lib/ppkt.c", 0x3Eu, "ppkt_prefix_header");
v2 = a1;
do
{
v3 = v2;
v2 = *(_QWORD *)(v2 + 24);
}
while ( v2 );
*(_QWORD *)(v3 + 24) = a2;
return a1;
}

original_code:
struct ppkt_t *ppkt_prefix_header(struct ppkt_t *hdr, struct ppkt_t *p)
{
    ((void) sizeof ((p) ? 1 : 0), __extension__ ({ if (p) ; else __assert_fail ("p", "lib/ppkt.c", 60, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((hdr) ? 1 : 0), __extension__ ({ if (hdr) ; else __assert_fail ("hdr", "lib/ppkt.c", 61, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((p != hdr) ? 1 : 0), __extension__ ({ if (p != hdr) ; else __assert_fail ("p != hdr", "lib/ppkt.c", 62, __extension__ __PRETTY_FUNCTION__); }));
    struct ppkt_t *it = hdr;
    while (it->next) it = it->next;
    it->next = p;
    return hdr;
}

variable_types:
hdr
struct ppkt_t *

variable_types:
p
struct ppkt_t *

variable_types: struct ppkt_t { unsigned char *payload; unsigned long size; unsigned long offset; struct ppkt_t *next; unsigned char flags; } *


decompiled_code:
__int64 __fastcall ppkt_append_footer(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // rdx

if ( !a1 )
_assert_fail("footer", "lib/ppkt.c", 0x49u, "ppkt_append_footer");
if ( !a2 )
return a1;
v2 = a2;
do
{
v3 = v2;
v2 = *(_QWORD *)(v2 + 24);
}
while ( v2 );
if ( v3 == a1 )
_assert_fail("it != footer", "lib/ppkt.c", 0x51u, "ppkt_append_footer");
*(_QWORD *)(v3 + 24) = a1;
return a2;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2)
{
__int64 v2; // rax
__int64 v3; // rdx

if ( !a1 )
_assert_fail("footer", "lib/ppkt.c", 0x49u, "ppkt_append_footer");
if ( !a2 )
return a1;
v2 = a2;
do
{
v3 = v2;
v2 = *(_QWORD *)(v2 + 24);
}
while ( v2 );
if ( v3 == a1 )
_assert_fail("it != footer", "lib/ppkt.c", 0x51u, "ppkt_append_footer");
*(_QWORD *)(v3 + 24) = a1;
return a2;
}

original_code:
struct ppkt_t *ppkt_append_footer(struct ppkt_t *footer, struct ppkt_t *p)
{
    ((void) sizeof ((footer) ? 1 : 0), __extension__ ({ if (footer) ; else __assert_fail ("footer", "lib/ppkt.c", 73, __extension__ __PRETTY_FUNCTION__); }));
    if (! p)
        return footer;
    struct ppkt_t *it = p;
    while (it->next) it = it->next;
    ((void) sizeof ((it != footer) ? 1 : 0), __extension__ ({ if (it != footer) ; else __assert_fail ("it != footer", "lib/ppkt.c", 81, __extension__ __PRETTY_FUNCTION__); }));
    it->next = footer;
    return p;
}

variable_types:
footer
struct ppkt_t *

return_type: struct ppkt_t { unsigned char *payload; unsigned long size; unsigned long offset; struct ppkt_t *next; unsigned char flags; } *


decompiled_code:
__int64 __fastcall ppkt_payload(_QWORD *a1)
{
if ( !a1 )
_assert_fail("p", "lib/ppkt.c", 0xAFu, "ppkt_payload");
return *a1 + a1[2];
}

canonical_decompiled_code:
__int64 __fastcall func4(_QWORD *a1)
{
if ( !a1 )
_assert_fail("p", "lib/ppkt.c", 0xAFu, "ppkt_payload");
return *a1 + a1[2];
}

original_code:
uint8_t* ppkt_payload(struct ppkt_t *p)
{
    ((void) sizeof ((p) ? 1 : 0), __extension__ ({ if (p) ; else __assert_fail ("p", "lib/ppkt.c", 175, __extension__ __PRETTY_FUNCTION__); }));
    return p->payload + p->offset;
}

canonical_original_code:
unsigned char *ppkt_payload(struct ppkt_t *p)
{
    ((void) sizeof ((p) ? 1 : 0), __extension__ ({ if (p) ; else __assert_fail ("p", "lib/ppkt.c", 175, __extension__ __PRETTY_FUNCTION__); }));
    return p->payload + p->offset;
}

return_type: unsigned char *

user_defined_types: struct ppkt_t { unsigned char *payload; unsigned long size; unsigned long offset; struct ppkt_t *next; unsigned char flags; }


decompiled_code:
__int64 __fastcall ppkt_size(__int64 a1)
{
if ( !a1 )
_assert_fail("p", "lib/ppkt.c", 0xBCu, "ppkt_size");
return *(_QWORD *)(a1 + 8) - *(_QWORD *)(a1 + 16);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
if ( !a1 )
_assert_fail("p", "lib/ppkt.c", 0xBCu, "ppkt_size");
return *(_QWORD *)(a1 + 8) - *(_QWORD *)(a1 + 16);
}

original_code:
size_t ppkt_size(struct ppkt_t *p)
{
    ((void) sizeof ((p) ? 1 : 0), __extension__ ({ if (p) ; else __assert_fail ("p", "lib/ppkt.c", 188, __extension__ __PRETTY_FUNCTION__); }));
    return p->size - p->offset;
}

canonical_original_code:
unsigned long ppkt_size(struct ppkt_t *p)
{
    ((void) sizeof ((p) ? 1 : 0), __extension__ ({ if (p) ; else __assert_fail ("p", "lib/ppkt.c", 188, __extension__ __PRETTY_FUNCTION__); }));
    return p->size - p->offset;
}


decompiled_code:
__int64 __fastcall ppkt_payload_sized(_QWORD *a1, unsigned __int64 a2)
{
if ( !a1 )
_assert_fail("p", "lib/ppkt.c", 0xB5u, "ppkt_payload_sized");
if ( ppkt_size((__int64)a1) < a2 )
_assert_fail("ppkt_size(p) >= size", "lib/ppkt.c", 0xB6u, "ppkt_payload_sized");
return ppkt_payload(a1);
}

canonical_decompiled_code:
__int64 __fastcall func6(_QWORD *a1, unsigned __int64 a2)
{
if ( !a1 )
_assert_fail("p", "lib/ppkt.c", 0xB5u, "ppkt_payload_sized");
if ( func5((__int64)a1) < a2 )
_assert_fail("ppkt_size(p) >= size", "lib/ppkt.c", 0xB6u, "ppkt_payload_sized");
return func4(a1);
}

original_code:
uint8_t* ppkt_payload_sized(struct ppkt_t *p, size_t size)
{
    ((void) sizeof ((p) ? 1 : 0), __extension__ ({ if (p) ; else __assert_fail ("p", "lib/ppkt.c", 181, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((ppkt_size(p) >= size) ? 1 : 0), __extension__ ({ if (ppkt_size(p) >= size) ; else __assert_fail ("ppkt_size(p) >= size", "lib/ppkt.c", 182, __extension__ __PRETTY_FUNCTION__); }));
    return ppkt_payload(p);
}

canonical_original_code:
unsigned char *ppkt_payload_sized(struct ppkt_t *p, unsigned long size)
{
    ((void) sizeof ((p) ? 1 : 0), __extension__ ({ if (p) ; else __assert_fail ("p", "lib/ppkt.c", 181, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((ppkt_size(p) >= size) ? 1 : 0), __extension__ ({ if (ppkt_size(p) >= size) ; else __assert_fail ("ppkt_size(p) >= size", "lib/ppkt.c", 182, __extension__ __PRETTY_FUNCTION__); }));
    return ppkt_payload(p);
}

variable_types:
size
unsigned long


decompiled_code:
__int64 __fastcall ppkt_chain_size(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // r12
__int64 v3; // rax

if ( !a1 )
return 0LL;
v1 = a1;
v2 = 0LL;
do
{
v3 = ppkt_size(v1);
v1 = *(_QWORD *)(v1 + 24);
v2 += v3;
}
while ( v1 );
return v2;
}

original_code:
size_t ppkt_chain_size(struct ppkt_t *p)
{
    size_t length = 0;
    while (p)
    {
        length += ppkt_size(p);
        p = p->next;
    }
    return length;
}

canonical_original_code:
unsigned long ppkt_chain_size(struct ppkt_t *p)
{
    unsigned long length = 0;
    while (p)
    {
        length += ppkt_size(p);
        p = p->next;
    }
    return length;
}

variable_types:
length
unsigned long


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

if ( !a1 )
_assert_fail("p", "lib/ppkt.c", 0xCFu, "ppkt_chain_count");
result = 0LL;
do
{
a1 = *(_QWORD *)(a1 + 24);
++result;
}
while ( a1 );
return result;
}

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

if ( !a1 )
_assert_fail("p", "lib/ppkt.c", 0xCFu, "ppkt_chain_count");
result = 0LL;
do
{
a1 = *(_QWORD *)(a1 + 24);
++result;
}
while ( a1 );
return result;
}

original_code:
size_t ppkt_chain_count(struct ppkt_t *p)
{
    ((void) sizeof ((p) ? 1 : 0), __extension__ ({ if (p) ; else __assert_fail ("p", "lib/ppkt.c", 207, __extension__ __PRETTY_FUNCTION__); }));
    size_t length = 0;
    while (p)
    {
        length++;
        p = p->next;
    }
    return length;
}

canonical_original_code:
unsigned long ppkt_chain_count(struct ppkt_t *p)
{
    ((void) sizeof ((p) ? 1 : 0), __extension__ ({ if (p) ; else __assert_fail ("p", "lib/ppkt.c", 207, __extension__ __PRETTY_FUNCTION__); }));
    unsigned long length = 0;
    while (p)
    {
        length++;
        p = p->next;
    }
    return length;
}


decompiled_code:
__int64 __fastcall ppkt_next(__int64 a1)
{
if ( !a1 )
_assert_fail("p", "lib/ppkt.c", 0xDDu, "ppkt_next");
return *(_QWORD *)(a1 + 24);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
if ( !a1 )
_assert_fail("p", "lib/ppkt.c", 0xDDu, "ppkt_next");
return *(_QWORD *)(a1 + 24);
}

original_code:
struct ppkt_t* ppkt_next(struct ppkt_t *p)
{
    ((void) sizeof ((p) ? 1 : 0), __extension__ ({ if (p) ; else __assert_fail ("p", "lib/ppkt.c", 221, __extension__ __PRETTY_FUNCTION__); }));
    return p->next;
}

canonical_original_code:
struct ppkt_t *ppkt_next(struct ppkt_t *p)
{
    ((void) sizeof ((p) ? 1 : 0), __extension__ ({ if (p) ; else __assert_fail ("p", "lib/ppkt.c", 221, __extension__ __PRETTY_FUNCTION__); }));
    return p->next;
}


decompiled_code:
unsigned __int64 __fastcall ppkt_pull(__int64 a1, unsigned __int64 a2)
{
unsigned __int64 result; // rax

if ( !a1 )
_assert_fail("p", "lib/ppkt.c", 0xE3u, "ppkt_pull");
result = ppkt_size(a1);
if ( result < a2 )
_assert_fail("size <= ppkt_size(p)", "lib/ppkt.c", 0xE4u, "ppkt_pull");
*(_QWORD *)(a1 + 16) += a2;
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func10(__int64 a1, unsigned __int64 a2)
{
unsigned __int64 result; // rax

if ( !a1 )
_assert_fail("p", "lib/ppkt.c", 0xE3u, "ppkt_pull");
result = func5(a1);
if ( result < a2 )
_assert_fail("size <= ppkt_size(p)", "lib/ppkt.c", 0xE4u, "ppkt_pull");
*(_QWORD *)(a1 + 16) += a2;
return result;
}

original_code:
void ppkt_pull(struct ppkt_t *p, size_t size)
{
    ((void) sizeof ((p) ? 1 : 0), __extension__ ({ if (p) ; else __assert_fail ("p", "lib/ppkt.c", 227, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((size <= ppkt_size(p)) ? 1 : 0), __extension__ ({ if (size <= ppkt_size(p)) ; else __assert_fail ("size <= ppkt_size(p)", "lib/ppkt.c", 228, __extension__ __PRETTY_FUNCTION__); }));
    p->offset += size;
}

canonical_original_code:
void ppkt_pull(struct ppkt_t *p, unsigned long size)
{
    ((void) sizeof ((p) ? 1 : 0), __extension__ ({ if (p) ; else __assert_fail ("p", "lib/ppkt.c", 227, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((size <= ppkt_size(p)) ? 1 : 0), __extension__ ({ if (size <= ppkt_size(p)) ; else __assert_fail ("size <= ppkt_size(p)", "lib/ppkt.c", 228, __extension__ __PRETTY_FUNCTION__); }));
    p->offset += size;
}


decompiled_code:
unsigned __int64 __fastcall ppkt_cut(__int64 a1, unsigned __int64 a2)
{
unsigned __int64 result; // rax

if ( !a1 )
_assert_fail("p", "lib/ppkt.c", 0xEBu, "ppkt_cut");
result = ppkt_size(a1);
if ( result < a2 )
_assert_fail("size <= ppkt_size(p)", "lib/ppkt.c", 0xECu, "ppkt_cut");
*(_QWORD *)(a1 + 8) -= a2;
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func11(__int64 a1, unsigned __int64 a2)
{
unsigned __int64 result; // rax

if ( !a1 )
_assert_fail("p", "lib/ppkt.c", 0xEBu, "ppkt_cut");
result = func5(a1);
if ( result < a2 )
_assert_fail("size <= ppkt_size(p)", "lib/ppkt.c", 0xECu, "ppkt_cut");
*(_QWORD *)(a1 + 8) -= a2;
return result;
}

original_code:
void ppkt_cut(struct ppkt_t *p, size_t size)
{
    ((void) sizeof ((p) ? 1 : 0), __extension__ ({ if (p) ; else __assert_fail ("p", "lib/ppkt.c", 235, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((size <= ppkt_size(p)) ? 1 : 0), __extension__ ({ if (size <= ppkt_size(p)) ; else __assert_fail ("size <= ppkt_size(p)", "lib/ppkt.c", 236, __extension__ __PRETTY_FUNCTION__); }));
    p->size -= size;
}

canonical_original_code:
void ppkt_cut(struct ppkt_t *p, unsigned long size)
{
    ((void) sizeof ((p) ? 1 : 0), __extension__ ({ if (p) ; else __assert_fail ("p", "lib/ppkt.c", 235, __extension__ __PRETTY_FUNCTION__); }));
    ((void) sizeof ((size <= ppkt_size(p)) ? 1 : 0), __extension__ ({ if (size <= ppkt_size(p)) ; else __assert_fail ("size <= ppkt_size(p)", "lib/ppkt.c", 236, __extension__ __PRETTY_FUNCTION__); }));
    p->size -= size;
}


decompiled_code:
const char *__fastcall s7comm_area_to_string(int a1)
{
const char *result; // rax

switch ( a1 )
{
case 0:
result = "Raw memory S5";
break;
case 3:
result = "SysInfo";
break;
case 5:
result = "SysFlags";
break;
case 6:
result = "Analog in";
break;
case 7:
result = "Analog out";
break;
case 28:
result = "Counter";
break;
case 29:
result = "Timer";
break;
case 30:
result = "Counter (200 family)";
break;
case 31:
result = "Timer (200 family)";
break;
case 128:
result = "Direct peripheral access";
break;
case 129:
result = "Inputs";
break;
case 130:
result = "Outputs";
break;
case 131:
result = "Flags";
break;
case 132:
result = "Data blocks";
break;
case 133:
result = "Instance data blocks";
break;
case 134:
result = "System data S5";
break;
case 135:
result = "V";
break;
default:
result = "unknown";
break;
}
return result;
}

canonical_decompiled_code:
const char *__fastcall func0(int a1)
{
const char *result; // rax

switch ( a1 )
{
case 0:
result = "Raw memory S5";
break;
case 3:
result = "SysInfo";
break;
case 5:
result = "SysFlags";
break;
case 6:
result = "Analog in";
break;
case 7:
result = "Analog out";
break;
case 28:
result = "Counter";
break;
case 29:
result = "Timer";
break;
case 30:
result = "Counter (200 family)";
break;
case 31:
result = "Timer (200 family)";
break;
case 128:
result = "Direct peripheral access";
break;
case 129:
result = "Inputs";
break;
case 130:
result = "Outputs";
break;
case 131:
result = "Flags";
break;
case 132:
result = "Data blocks";
break;
case 133:
result = "Instance data blocks";
break;
case 134:
result = "System data S5";
break;
case 135:
result = "V";
break;
default:
result = "unknown";
break;
}
return result;
}

original_code:
const char* s7comm_area_to_string(const enum s7comm_area_t area)
{
    switch (area)
    {
        case s7comm_area_SysInfo:
            return "SysInfo";
        case s7comm_area_SysFlags:
            return "SysFlags";
        case s7comm_area_AnaIn:
            return "Analog in";
        case s7comm_area_AnaOut:
            return "Analog out";
        case s7comm_area_P:
            return "Direct peripheral access";
        case s7comm_area_Inputs:
            return "Inputs";
        case s7comm_area_Outputs:
            return "Outputs";
        case s7comm_area_Flags:
            return "Flags";
        case s7comm_area_DB:
            return "Data blocks";
        case s7comm_area_DI:
            return "Instance data blocks";
        case s7comm_area_SysDataS5:
            return "System data S5";
        case s7comm_area_V:
            return "V";
        case s7comm_area_Counter:
            return "Counter";
        case s7comm_area_Timer:
            return "Timer";
        case s7comm_area_Counter200:
            return "Counter (200 family)";
        case s7comm_area_Timer200:
            return "Timer (200 family)";
        case s7comm_area_RawMemoryS5:
            return "Raw memory S5";
    }
    return "unknown";
}

canonical_original_code:
char *s7comm_area_to_string(enum s7comm_area_t area)
{
    switch (area)
    {
        case s7comm_area_SysInfo:
            return "SysInfo";
        case s7comm_area_SysFlags:
            return "SysFlags";
        case s7comm_area_AnaIn:
            return "Analog in";
        case s7comm_area_AnaOut:
            return "Analog out";
        case s7comm_area_P:
            return "Direct peripheral access";
        case s7comm_area_Inputs:
            return "Inputs";
        case s7comm_area_Outputs:
            return "Outputs";
        case s7comm_area_Flags:
            return "Flags";
        case s7comm_area_DB:
            return "Data blocks";
        case s7comm_area_DI:
            return "Instance data blocks";
        case s7comm_area_SysDataS5:
            return "System data S5";
        case s7comm_area_V:
            return "V";
        case s7comm_area_Counter:
            return "Counter";
        case s7comm_area_Timer:
            return "Timer";
        case s7comm_area_Counter200:
            return "Counter (200 family)";
        case s7comm_area_Timer200:
            return "Timer (200 family)";
        case s7comm_area_RawMemoryS5:
            return "Raw memory S5";
    }
    return "unknown";
}

variable_types: enum s7comm_area_t { s7comm_area_SysInfo=3, s7comm_area_SysFlags=5, s7comm_area_AnaIn=6, s7comm_area_AnaOut=7, s7comm_area_P=128, s7comm_area_Inputs=129, s7comm_area_Outputs=130, s7comm_area_Flags=131, s7comm_area_DB=132, s7comm_area_DI=133, s7comm_area_SysDataS5=134, s7comm_area_V=135, s7comm_area_Counter=28, s7comm_area_Timer=29, s7comm_area_Counter200=30, s7comm_area_Timer200=31, s7comm_area_RawMemoryS5=0 }

return_type: char *


decompiled_code:
int __fastcall dump_bytes(unsigned __int8 *a1, __int64 a2)
{
__int64 v2; // rbx
__int64 v3; // rax

if ( !a2 )
goto LABEL_9;
v2 = 0LL;
printf("%02x ", *a1);
LABEL_3:
v3 = v2 & 0xF;
if ( v3 == 15 )
{
while ( 1 )
{
++v2;
LODWORD(v3) = putchar(10);
if ( a2 == v2 )
break;
LABEL_5:
printf("%02x ", a1[v2]);
if ( (v2 & 7) != 7 )
goto LABEL_3;
printf(" ");
v3 = v2 & 0xF;
if ( v3 != 15 )
goto LABEL_4;
}
}
else
{
LABEL_4:
if ( a2 != ++v2 )
goto LABEL_5;
}
if ( (a2 & 0xF) != 15 )
LABEL_9:
LODWORD(v3) = putchar(10);
return v3;
}

canonical_decompiled_code:
int __fastcall func1(unsigned __int8 *a1, __int64 a2)
{
__int64 v2; // rbx
__int64 v3; // rax

if ( !a2 )
goto LABEL_9;
v2 = 0LL;
printf("%02x ", *a1);
LABEL_3:
v3 = v2 & 0xF;
if ( v3 == 15 )
{
while ( 1 )
{
++v2;
LODWORD(v3) = putchar(10);
if ( a2 == v2 )
break;
LABEL_5:
printf("%02x ", a1[v2]);
if ( (v2 & 7) != 7 )
goto LABEL_3;
printf(" ");
v3 = v2 & 0xF;
if ( v3 != 15 )
goto LABEL_4;
}
}
else
{
LABEL_4:
if ( a2 != ++v2 )
goto LABEL_5;
}
if ( (a2 & 0xF) != 15 )
LABEL_9:
LODWORD(v3) = putchar(10);
return v3;
}

original_code:
void dump_bytes(const uint8_t *bytes, size_t size)
{
    size_t i;
    for (i = 0; i < size; i++)
    {
        printf("%02x ", bytes[i]);
        if (i % 8 == 7)
            printf("  ");
        if (i % 16 == 15)
            printf("\n");
    }
    if (i % 16 != 15)
        printf("\n");
}

canonical_original_code:
void dump_bytes(unsigned char *bytes, unsigned long size)
{
    unsigned long i;
    for (i = 0; i < size; i++)
    {
        printf("%02x ", bytes[i]);
        if (i % 8 == 7)
            printf("  ");
        if (i % 16 == 15)
            printf("\n");
    }
    if (i % 16 != 15)
        printf("\n");
}

variable_types:
bytes
unsigned char *

variable_types:
i
unsigned long


help

decompiled_code:
void __fastcall __noreturn help(const char *a1)
{
printf("Usage: %s [-l] -a <ip> -t [mda] -d <db> -n <number>\n", a1);
puts(" -l: Target is a Logo device.");
puts(" -t:");
puts(" m: Merker (bit)");
puts(" d: Data word");
puts(" a: Output");
puts(" i: Input");
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func7(const char *a1)
{
printf("Usage: %s [-l] -a <ip> -t [mda] -d <db> -n <number>\n", a1);
puts(" -l: Target is a Logo device.");
puts(" -t:");
puts(" m: Merker (bit)");
puts(" d: Data word");
puts(" a: Output");
puts(" i: Input");
exit(1);
}

original_code:
static void help(const char *name)
{
    printf("Usage: %s [-l] -a <ip> -t [mda] -d <db> -n <number>\n", name);
    printf(" -l: Target is a Logo device.\n");
    printf(" -t:\n");
    printf("       m: Merker (bit)\n");
    printf("       d: Data word\n");
    printf("       a: Output\n");
    printf("       i: Input\n");
    exit(1);
}

canonical_original_code:
static void help(char *name)
{
    printf("Usage: %s [-l] -a <ip> -t [mda] -d <db> -n <number>\n", name);
    printf(" -l: Target is a Logo device.\n");
    printf(" -t:\n");
    printf("       m: Merker (bit)\n");
    printf("       d: Data word\n");
    printf("       a: Output\n");
    printf("       i: Input\n");
    exit(1);
}

variable_types:
name
char *