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

if ( a1 )
{
*(_QWORD *)a1 = 0LL;
*(_QWORD *)(a1 + 3232) = 0LL;
result = 0LL;
memset(
(void *)((a1 + 8) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)a1 - (((_DWORD)a1 + 8) & 0xFFFFFFF8) + 3240) >> 3));
*(_DWORD *)(a1 + 2768) = 1;
}
return result;
}

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

if ( a1 )
{
*(_QWORD *)a1 = 0LL;
*(_QWORD *)(a1 + 3232) = 0LL;
result = 0LL;
memset(
(void *)((a1 + 8) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)a1 - (((_DWORD)a1 + 8) & 0xFFFFFFF8) + 3240) >> 3));
*(_DWORD *)(a1 + 2768) = 1;
}
return result;
}

original_code:
void
qdpack_simulation_init(qdpack_simulation_t *sp)
{
    if (sp)
    {
        memset((void *)sp, 0, sizeof(qdpack_simulation_t));
        sp->cont_basis_transform = 0;
        sp->option_me_eb = 0;
        sp->option_adaptive = 1;
        sp->H0 = ((void *)0);
        sp->H1 = ((void *)0);
        sp->H_t = ((void *)0);
        sp->H0_func = ((void *)0);
        sp->H1_func = ((void *)0);
        sp->Ht_func = ((void *)0);
        sp->h_td_A = 0.0;
        sp->h_td_w = 0.0;
    }
    return;
}

canonical_original_code:
void qdpack_simulation_init(struct _qdpack_simulation *sp)
{
    if (sp)
    {
        memset((void *)sp, 0, sizeof(qdpack_simulation_t));
        sp->cont_basis_transform = 0;
        sp->option_me_eb = 0;
        sp->option_adaptive = 1;
        sp->H0 = ((void *)0);
        sp->H1 = ((void *)0);
        sp->H_t = ((void *)0);
        sp->H0_func = ((void *)0);
        sp->H1_func = ((void *)0);
        sp->Ht_func = ((void *)0);
        sp->h_td_A = 0.0;
        sp->h_td_w = 0.0;
    }
    return;
}

variable_types: struct _qdpack_simulation { struct qdpack_hilbert_space_t { int nsubsys; int *nstates; } *qs; double Ti; double Tf; double dT; char simsig[1024]; double T_w; struct _qdpack_operator_t { int n; struct qdpack_hilbert_space_t *qs; struct _qdpack_matrix { int n; struct gsl_matrix_complex { unsigned long size1; unsigned long size2; unsigned long tda; double *data; struct gsl_block_complex_struct { unsigned long size; double *data; } *block; int owner; } *data; } *data; } *H0; struct _qdpack_operator_t *H1; struct _qdpack_operator_t *H_t; struct _qdpack_operator_t *H_a; struct _qdpack_operator_t *H_b; struct _qdpack_operator_t *do_a[20]; struct _qdpack_operator_t *do_ad[20]; struct _qdpack_operator_t *do_aad[20]; struct _qdpack_operator_t *do_ada[20]; struct _qdpack_operator_t *do_a_eb[20]; struct _qdpack_operator_t *do_ad_eb[20]; struct _qdpack_operator_t *do_aad_eb[20]; struct _qdpack_operator_t *do_ada_eb[20]; struct _qdpack_operator_t *ws1; struct _qdpack_operator_t *ws2; struct _qdpack_operator_t *op_tmp; double do_g1[20]; double do_g2[20]; int do_n; void *parameters; struct _qdpack_operator_t *dSSt; double (*ho_w_func)(double, void *); int cont_basis_transform; int option_me_eb; int option_adaptive; double g0; struct _qdpack_operator_t *N_op[10]; struct _qdpack_operator_t *a; struct _qdpack_operator_t *n_op; struct _qdpack_state { int n; struct qdpack_hilbert_space_t *qs; struct _qdpack_matrix *data; } *psi_f; double h_td_A; double h_td_w; int (*H0_func)(struct _qdpack_simulation *, struct qdpack_hilbert_space_t *, struct _qdpack_operator_t *); int (*H1_func)(struct _qdpack_simulation *, struct qdpack_hilbert_space_t *, struct _qdpack_operator_t *); int (*Ht_func)(struct _qdpack_simulation *, struct _qdpack_operator_t *, struct _qdpack_operator_t *, struct _qdpack_operator_t *, double); struct _qdpack_operator_t *evec; struct _qdpack_matrix *eval; struct _qdpack_operator_t *floquet_states_t; struct _qdpack_operator_t *floquet_modes; struct _qdpack_matrix *floquet_quasienergies; struct _qdpack_operator_t **floquet_X; struct _qdpack_matrix *floquet_Gamma; struct _qdpack_matrix *floquet_ss_prob; int floquet_k_max; } *


repo: jrjohansson/qdpack

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

if ( a1 )
{
if ( *(_QWORD *)(a1 + 1064) )
result = qdpack_operator_free();
if ( *(_QWORD *)(a1 + 1072) )
result = qdpack_operator_free();
}
return result;
}

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

if ( a1 )
{
if ( *(_QWORD *)(a1 + 1064) )
result = qdpack_operator_free();
if ( *(_QWORD *)(a1 + 1072) )
result = qdpack_operator_free();
}
return result;
}

original_code:
void
qdpack_simulation_free(qdpack_simulation_t *sp)
{
    if (sp)
    {
        if (sp->H0) qdpack_operator_free(sp->H0);
        if (sp->H1) qdpack_operator_free(sp->H1);
    }
    return;
}

canonical_original_code:
void qdpack_simulation_free(struct _qdpack_simulation *sp)
{
    if (sp)
    {
        if (sp->H0) qdpack_operator_free(sp->H0);
        if (sp->H1) qdpack_operator_free(sp->H1);
    }
    return;
}

return_type: void

user_defined_types: struct _qdpack_simulation { struct qdpack_hilbert_space_t *qs; double Ti; double Tf; double dT; char simsig[1024]; double T_w; struct _qdpack_operator_t *H0; struct _qdpack_operator_t *H1; struct _qdpack_operator_t *H_t; struct _qdpack_operator_t *H_a; struct _qdpack_operator_t *H_b; struct _qdpack_operator_t *do_a[20]; struct _qdpack_operator_t *do_ad[20]; struct _qdpack_operator_t *do_aad[20]; struct _qdpack_operator_t *do_ada[20]; struct _qdpack_operator_t *do_a_eb[20]; struct _qdpack_operator_t *do_ad_eb[20]; struct _qdpack_operator_t *do_aad_eb[20]; struct _qdpack_operator_t *do_ada_eb[20]; struct _qdpack_operator_t *ws1; struct _qdpack_operator_t *ws2; struct _qdpack_operator_t *op_tmp; double do_g1[20]; double do_g2[20]; int do_n; void *parameters; struct _qdpack_operator_t *dSSt; double (*ho_w_func)(double, void *); int cont_basis_transform; int option_me_eb; int option_adaptive; double g0; struct _qdpack_operator_t *N_op[10]; struct _qdpack_operator_t *a; struct _qdpack_operator_t *n_op; struct _qdpack_state *psi_f; double h_td_A; double h_td_w; int (*H0_func)(struct _qdpack_simulation *, struct qdpack_hilbert_space_t *, struct _qdpack_operator_t *); int (*H1_func)(struct _qdpack_simulation *, struct qdpack_hilbert_space_t *, struct _qdpack_operator_t *); int (*Ht_func)(struct _qdpack_simulation *, struct _qdpack_operator_t *, struct _qdpack_operator_t *, struct _qdpack_operator_t *, double); struct _qdpack_operator_t *evec; struct _qdpack_matrix *eval; struct _qdpack_operator_t *floquet_states_t; struct _qdpack_operator_t *floquet_modes; struct _qdpack_matrix *floquet_quasienergies; struct _qdpack_operator_t **floquet_X; struct _qdpack_matrix *floquet_Gamma; struct _qdpack_matrix *floquet_ss_prob; int floquet_k_max; }

user_defined_types: struct qdpack_hilbert_space_t { int nsubsys; int *nstates; }

user_defined_types: struct _qdpack_operator_t { int n; struct qdpack_hilbert_space_t *qs; struct _qdpack_matrix *data; }

user_defined_types: struct _qdpack_state { int n; struct qdpack_hilbert_space_t *qs; struct _qdpack_matrix *data; }

user_defined_types: struct _qdpack_matrix { int n; struct gsl_matrix_complex *data; }

user_defined_types: struct gsl_matrix_complex { unsigned long size1; unsigned long size2; unsigned long tda; double *data; struct gsl_block_complex_struct *block; int owner; }

user_defined_types: struct gsl_block_complex_struct { unsigned long size; double *data; }


decompiled_code:
double __fastcall sup_norm(_QWORD *a1, double a2, double a3)
{
unsigned int v3; // er15
__int64 i; // r14
unsigned int j; // er12
double v7; // rbp
double v8; // [rsp+8h] [rbp-40h]

v8 = 0.0;
v3 = 0;
for ( i = 0LL; (unsigned __int64)v3 < *a1; i = v3 )
{
for ( j = 0; (unsigned __int64)j < a1[1]; ++j )
{
v7 = gsl_matrix_complex_get(a1, i);
if ( ((double (*)(void))gsl_complex_abs)() > v8 )
v8 = gsl_complex_abs(v7, a3);
}
++v3;
}
return v8;
}

canonical_decompiled_code:
double __fastcall func0(_QWORD *a1, double a2, double a3)
{
unsigned int v3; // er15
__int64 i; // r14
unsigned int j; // er12
double v7; // rbp
double v8; // [rsp+8h] [rbp-40h]

v8 = 0.0;
v3 = 0;
for ( i = 0LL; (unsigned __int64)v3 < *a1; i = v3 )
{
for ( j = 0; (unsigned __int64)j < a1[1]; ++j )
{
v7 = gsl_matrix_complex_get(a1, i);
if ( ((double (*)(void))gsl_complex_abs)() > v8 )
v8 = gsl_complex_abs(v7, a3);
}
++v3;
}
return v8;
}

original_code:
inline
static double
sup_norm(const gsl_matrix_complex * A)
{
    unsigned int i, j;
      double max = 0.0;
    for (i = 0; i < A->size1; i++)
    {
        for (j = 0; j < A->size2; j++)
        {
            gsl_complex z = gsl_matrix_complex_get(A, i, j);
            if (gsl_complex_abs(z) > max)
                max = gsl_complex_abs(z);
        }
    }
      return max;
}

canonical_original_code:
inline static double sup_norm(struct gsl_matrix_complex *A)
{
    unsigned int i; unsigned int j;
      double max = 0.0;
    for (i = 0; i < A->size1; i++)
    {
        for (j = 0; j < A->size2; j++)
        {
            struct gsl_complex z = gsl_matrix_complex_get(A, i, j);
            if (gsl_complex_abs(z) > max)
                max = gsl_complex_abs(z);
        }
    }
      return max;
}

variable_types: struct gsl_matrix_complex { unsigned long size1; unsigned long size2; unsigned long tda; double *data; struct gsl_block_complex_struct { unsigned long size; double *data; } *block; int owner; } *

variable_types:
i
unsigned int

variable_types:
j
unsigned int

variable_types: max double

variable_types:
z
struct gsl_complex { double dat[2]; }

return_type: double


original_code:
static
mvl_suggestion_t
obtain_suggestion(const gsl_matrix_complex * A, gsl_mode_t mode)
{
  const unsigned int mode_prec = ((mode) & (unsigned int)7);
  const double norm_A = sup_norm(A);
  if(norm_A < 0.01) return mvl_tab[mode_prec][0];
  else if(norm_A < 0.1) return mvl_tab[mode_prec][1];
  else if(norm_A < 1.0) return mvl_tab[mode_prec][2];
  else if(norm_A < 10.0) return mvl_tab[mode_prec][3];
  else if(norm_A < 100.0) return mvl_tab[mode_prec][4];
  else if(norm_A < 1000.0) return mvl_tab[mode_prec][5];
  else
  {
    const double extra = log(1.01*norm_A/1000.0) / 0.69314718055994530942;
    const int extra_i = (unsigned int) ceil(extra);
    mvl_suggestion_t s = mvl_tab[mode][5];
    s.j += extra_i;
    return s;
  }
}

canonical_original_code:
static struct moler_vanloan_optimal_suggestion obtain_suggestion(struct gsl_matrix_complex *A, unsigned int mode)
{
  unsigned int mode_prec = ((mode) & (unsigned int)7);
  double norm_A = sup_norm(A);
  if(norm_A < 0.01) return mvl_tab[mode_prec][0];
  else if(norm_A < 0.1) return mvl_tab[mode_prec][1];
  else if(norm_A < 1.0) return mvl_tab[mode_prec][2];
  else if(norm_A < 10.0) return mvl_tab[mode_prec][3];
  else if(norm_A < 100.0) return mvl_tab[mode_prec][4];
  else if(norm_A < 1000.0) return mvl_tab[mode_prec][5];
  else
  {
    double extra = log(1.01*norm_A/1000.0) / 0.69314718055994530942;
    int extra_i = (unsigned int) ceil(extra);
    struct moler_vanloan_optimal_suggestion s = mvl_tab[mode][5];
    s.j += extra_i;
    return s;
  }
}

variable_types:
mode
unsigned int

variable_types: extra double

variable_types: struct moler_vanloan_optimal_suggestion { int k; int j; }


decompiled_code:
__int64 __fastcall matrix_complex_exp_series(_QWORD *a1, __int64 a2, int a3)
{
__int64 v4; // rbp
int v5; // ebx

v4 = gsl_matrix_complex_calloc(*a1, a1[1]);
gsl_matrix_complex_memcpy(a2, a1);
gsl_matrix_complex_scale(a2, 1.0 / (double)a3, 0.0);
gsl_matrix_complex_add_diagonal(a2, 1.0, 0.0);
v5 = a3 - 1;
if ( v5 > 0 )
{
do
{
gsl_blas_zgemm(111LL, 111LL, a1, a2, v4, 1.0, 0.0, 0.0, 0.0);
gsl_matrix_complex_scale(v4, 1.0 / (double)v5, 0.0);
gsl_matrix_complex_add_diagonal(v4, 1.0, 0.0);
gsl_matrix_complex_memcpy(a2, v4);
--v5;
}
while ( v5 );
}
return gsl_matrix_complex_free(v4);
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD *a1, __int64 a2, int a3)
{
__int64 v4; // rbp
int v5; // ebx

v4 = gsl_matrix_complex_calloc(*a1, a1[1]);
gsl_matrix_complex_memcpy(a2, a1);
gsl_matrix_complex_scale(a2, 1.0 / (double)a3, 0.0);
gsl_matrix_complex_add_diagonal(a2, 1.0, 0.0);
v5 = a3 - 1;
if ( v5 > 0 )
{
do
{
gsl_blas_zgemm(111LL, 111LL, a1, a2, v4, 1.0, 0.0, 0.0, 0.0);
gsl_matrix_complex_scale(v4, 1.0 / (double)v5, 0.0);
gsl_matrix_complex_add_diagonal(v4, 1.0, 0.0);
gsl_matrix_complex_memcpy(a2, v4);
--v5;
}
while ( v5 );
}
return gsl_matrix_complex_free(v4);
}

original_code:
static void
matrix_complex_exp_series(
  const gsl_matrix_complex * B,
  gsl_matrix_complex * eB,
  int number_of_terms
  )
{
  int count;
  gsl_matrix_complex *temp = gsl_matrix_complex_calloc(B->size1, B->size2);
  gsl_complex z;
  gsl_complex alpha, beta;
  do {(&alpha)->dat[0]=(1.0); (&alpha)->dat[1]=(0.0);} while(0);
  do {(&beta)->dat[0]=(0.0); (&beta)->dat[1]=(0.0);} while(0);
  gsl_matrix_complex_memcpy(eB, B);
  do {(&z)->dat[0]=(1.0/number_of_terms); (&z)->dat[1]=(0.0);} while(0);
  gsl_matrix_complex_scale(eB, z);
  do {(&z)->dat[0]=(1.0); (&z)->dat[1]=(0.0);} while(0);
  gsl_matrix_complex_add_diagonal(eB, z);
  for(count = number_of_terms-1; count >= 1; --count)
  {
    gsl_blas_zgemm(CblasNoTrans, CblasNoTrans, alpha, B, eB, beta, temp);
    do {(&z)->dat[0]=(1.0/count); (&z)->dat[1]=(0.0);} while(0);
    gsl_matrix_complex_scale(temp, z);
    do {(&z)->dat[0]=(1.0); (&z)->dat[1]=(0.0);} while(0);
    gsl_matrix_complex_add_diagonal(temp, z);
    gsl_matrix_complex_memcpy(eB, temp);
  }
  gsl_matrix_complex_free(temp);
}

canonical_original_code:
static void matrix_complex_exp_series(struct gsl_matrix_complex *B, struct gsl_matrix_complex *eB, int number_of_terms)
{
  int count;
  struct gsl_matrix_complex *temp = gsl_matrix_complex_calloc(B->size1, B->size2);
  struct gsl_complex z;
  struct gsl_complex alpha; struct gsl_complex beta;
  do {(&alpha)->dat[0]=(1.0); (&alpha)->dat[1]=(0.0);} while(0);
  do {(&beta)->dat[0]=(0.0); (&beta)->dat[1]=(0.0);} while(0);
  gsl_matrix_complex_memcpy(eB, B);
  do {(&z)->dat[0]=(1.0/number_of_terms); (&z)->dat[1]=(0.0);} while(0);
  gsl_matrix_complex_scale(eB, z);
  do {(&z)->dat[0]=(1.0); (&z)->dat[1]=(0.0);} while(0);
  gsl_matrix_complex_add_diagonal(eB, z);
  for(count = number_of_terms-1; count >= 1; --count)
  {
    gsl_blas_zgemm(CblasNoTrans, CblasNoTrans, alpha, B, eB, beta, temp);
    do {(&z)->dat[0]=(1.0/count); (&z)->dat[1]=(0.0);} while(0);
    gsl_matrix_complex_scale(temp, z);
    do {(&z)->dat[0]=(1.0); (&z)->dat[1]=(0.0);} while(0);
    gsl_matrix_complex_add_diagonal(temp, z);
    gsl_matrix_complex_memcpy(eB, temp);
  }
  gsl_matrix_complex_free(temp);
}

variable_types:
eB
struct gsl_matrix_complex *

variable_types: count int

variable_types:
alpha
struct gsl_complex { double dat[2]; }

variable_types:
beta
struct gsl_complex { double dat[2]; }


decompiled_code:
__int64 __fastcall gsl_linalg_complex_exponential_ss(_QWORD *a1, _QWORD *a2, unsigned int a3, double a4, double a5)
{
__int64 v5; // rcx
__int64 result; // rax
_QWORD *v7; // r12
int v8; // ebp
double v9; // [rsp+18h] [rbp-50h]
unsigned __int64 v10; // [rsp+20h] [rbp-48h]

v5 = a1[1];
if ( *a1 == v5 )
{
if ( *a1 == *a2 && v5 == a2[1] )
{
v10 = obtain_suggestion(a1, a3, a4, a5);
v9 = exp((double)SHIDWORD(v10) * 0.6931471805599453);
v7 = (_QWORD *)gsl_matrix_complex_alloc(*a1, a1[1]);
gsl_matrix_complex_memcpy(v7, a1);
gsl_matrix_complex_scale(v7, 1.0 / v9, 0.0);
matrix_complex_exp_series(v7, (__int64)a2, v10);
if ( SHIDWORD(v10) > 0 )
{
v8 = 0;
do
{
gsl_blas_zgemm(111LL, 111LL, a2, a2, v7, 1.0, 0.0, 0.0, 0.0);
gsl_matrix_complex_memcpy(a2, v7);
++v8;
}
while ( HIDWORD(v10) != v8 );
}
gsl_matrix_complex_free(v7);
result = 0LL;
}
else
{
gsl_error("exponential of matrix must have same dimension as matrix", "gsl_ext_expm_complex.c", 180LL, 19LL);
result = 19LL;
}
}
else
{
gsl_error("cannot exponentiate a non-square matrix", "gsl_ext_expm_complex.c", 176LL, 20LL);
result = 20LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(_QWORD *a1, _QWORD *a2, unsigned int a3, double a4, double a5)
{
__int64 v5; // rcx
__int64 result; // rax
_QWORD *v7; // r12
int v8; // ebp
double v9; // [rsp+18h] [rbp-50h]
unsigned __int64 v10; // [rsp+20h] [rbp-48h]

v5 = a1[1];
if ( *a1 == v5 )
{
if ( *a1 == *a2 && v5 == a2[1] )
{
v10 = func1(a1, a3, a4, a5);
v9 = exp((double)SHIDWORD(v10) * 0.6931471805599453);
v7 = (_QWORD *)gsl_matrix_complex_alloc(*a1, a1[1]);
gsl_matrix_complex_memcpy(v7, a1);
gsl_matrix_complex_scale(v7, 1.0 / v9, 0.0);
func2(v7, (__int64)a2, v10);
if ( SHIDWORD(v10) > 0 )
{
v8 = 0;
do
{
gsl_blas_zgemm(111LL, 111LL, a2, a2, v7, 1.0, 0.0, 0.0, 0.0);
gsl_matrix_complex_memcpy(a2, v7);
++v8;
}
while ( HIDWORD(v10) != v8 );
}
gsl_matrix_complex_free(v7);
result = 0LL;
}
else
{
gsl_error("exponential of matrix must have same dimension as matrix", "gsl_ext_expm_complex.c", 180LL, 19LL);
result = 19LL;
}
}
else
{
gsl_error("cannot exponentiate a non-square matrix", "gsl_ext_expm_complex.c", 176LL, 20LL);
result = 20LL;
}
return result;
}

original_code:
int
gsl_linalg_complex_exponential_ss(
  const gsl_matrix_complex * A,
  gsl_matrix_complex * eA,
  gsl_mode_t mode
  )
{
  if(A->size1 != A->size2)
  {
    do { gsl_error ("cannot exponentiate a non-square matrix", "gsl_ext_expm_complex.c", 176, GSL_ENOTSQR) ; return GSL_ENOTSQR ; } while (0);
  }
  else if(A->size1 != eA->size1 || A->size2 != eA->size2)
  {
    do { gsl_error ("exponential of matrix must have same dimension as matrix", "gsl_ext_expm_complex.c", 180, GSL_EBADLEN) ; return GSL_EBADLEN ; } while (0);
  }
  else
  {
    int i;
    const mvl_suggestion_t sugg = obtain_suggestion(A, mode);
    const double divisor = exp(0.69314718055994530942 * sugg.j);
    gsl_complex z_divisor;
    gsl_complex alpha, beta;
    gsl_matrix_complex * reduced_A = gsl_matrix_complex_alloc(A->size1, A->size2);
    do {(&alpha)->dat[0]=(1.0); (&alpha)->dat[1]=(0.0);} while(0);
    do {(&beta)->dat[0]=(0.0); (&beta)->dat[1]=(0.0);} while(0);
    gsl_matrix_complex_memcpy(reduced_A, A);
    do {(&z_divisor)->dat[0]=(1.0/divisor); (&z_divisor)->dat[1]=(0.0);} while(0);
    gsl_matrix_complex_scale(reduced_A, z_divisor);
    matrix_complex_exp_series(reduced_A, eA, sugg.k);
    for(i = 0; i < sugg.j; ++i)
    {
      gsl_blas_zgemm(CblasNoTrans, CblasNoTrans, alpha, eA, eA, beta, reduced_A);
      gsl_matrix_complex_memcpy(eA, reduced_A);
    }
    gsl_matrix_complex_free(reduced_A);
    return GSL_SUCCESS;
  }
}

canonical_original_code:
int gsl_linalg_complex_exponential_ss(struct gsl_matrix_complex *A, struct gsl_matrix_complex *eA, unsigned int mode)
{
  if(A->size1 != A->size2)
  {
    do { gsl_error ("cannot exponentiate a non-square matrix", "gsl_ext_expm_complex.c", 176, GSL_ENOTSQR) ; return GSL_ENOTSQR ; } while (0);
  }
  else if(A->size1 != eA->size1 || A->size2 != eA->size2)
  {
    do { gsl_error ("exponential of matrix must have same dimension as matrix", "gsl_ext_expm_complex.c", 180, GSL_EBADLEN) ; return GSL_EBADLEN ; } while (0);
  }
  else
  {
    int i;
    struct moler_vanloan_optimal_suggestion sugg = obtain_suggestion(A, mode);
    double divisor = exp(0.69314718055994530942 * sugg.j);
    struct gsl_complex z_divisor;
    struct gsl_complex alpha; struct gsl_complex beta;
    struct gsl_matrix_complex *reduced_A = gsl_matrix_complex_alloc(A->size1, A->size2);
    do {(&alpha)->dat[0]=(1.0); (&alpha)->dat[1]=(0.0);} while(0);
    do {(&beta)->dat[0]=(0.0); (&beta)->dat[1]=(0.0);} while(0);
    gsl_matrix_complex_memcpy(reduced_A, A);
    do {(&z_divisor)->dat[0]=(1.0/divisor); (&z_divisor)->dat[1]=(0.0);} while(0);
    gsl_matrix_complex_scale(reduced_A, z_divisor);
    matrix_complex_exp_series(reduced_A, eA, sugg.k);
    for(i = 0; i < sugg.j; ++i)
    {
      gsl_blas_zgemm(CblasNoTrans, CblasNoTrans, alpha, eA, eA, beta, reduced_A);
      gsl_matrix_complex_memcpy(eA, reduced_A);
    }
    gsl_matrix_complex_free(reduced_A);
    return GSL_SUCCESS;
  }
}

variable_types:
eA
struct gsl_matrix_complex *

variable_types: i int

variable_types: divisor double

return_type: int

user_defined_types: struct moler_vanloan_optimal_suggestion { int k; int j; }


freeGraph

decompiled_code:
void __fastcall freeGraph(void *ptr)
{
free(*((void **)ptr + 3));
free(*((void **)ptr + 4));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
free(*((void **)ptr + 3));
free(*((void **)ptr + 4));
free(ptr);
}

original_code:
void freeGraph(GraphFlow *g ) {
 free( g->c );
 free( g->f );
 free( g );
}

canonical_original_code:
void freeGraph(struct GraphFlow *g) {
 free( g->c );
 free( g->f );
 free( g );
}

variable_types: struct GraphFlow { int numNodes; int source; int sink; int **e; int **c; int **f; } *


getNumNodes

decompiled_code:
__int64 __fastcall getNumNodes(unsigned int *a1)
{
return *a1;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int *a1)
{
return *a1;
}

original_code:
int getNumNodes(GraphFlow *g) {
 return g->numNodes;
}

canonical_original_code:
int getNumNodes(struct GraphFlow *g) {
 return g->numNodes;
}

user_defined_types: struct GraphFlow { int numNodes; int source; int sink; int **e; int **c; int **f; }


cleanEdges

decompiled_code:
__int64 __fastcall cleanEdges(__int64 a1)
{
__int64 result; // rax
__int64 v3; // rdi
__int64 v4; // rsi
__int64 v5; // rcx

result = getNumNodes((unsigned int *)a1);
if ( (int)result > 0 )
{
v3 = 8LL * (unsigned int)result;
v4 = 4LL * (unsigned int)result;
v5 = 0LL;
do
{
result = 0LL;
do
{
*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 16) + v5) + result) = 0;
result += 4LL;
}
while ( v4 != result );
v5 += 8LL;
}
while ( v5 != v3 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
__int64 result; // rax
__int64 v3; // rdi
__int64 v4; // rsi
__int64 v5; // rcx

result = func1((unsigned int *)a1);
if ( (int)result > 0 )
{
v3 = 8LL * (unsigned int)result;
v4 = 4LL * (unsigned int)result;
v5 = 0LL;
do
{
result = 0LL;
do
{
*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 16) + v5) + result) = 0;
result += 4LL;
}
while ( v4 != result );
v5 += 8LL;
}
while ( v5 != v3 );
}
return result;
}

original_code:
void cleanEdges(GraphFlow *g) {
 int numNodes = getNumNodes(g);
 int a = 0, b = 0;
 for(a = 0; a < numNodes; a++) {
  for(b = 0; b < numNodes; b++) {
   g->e[a][b] = !1;
  }
 }
}

canonical_original_code:
void cleanEdges(struct GraphFlow *g) {
 int numNodes = getNumNodes(g);
 int a = 0; int b = 0;
 for(a = 0; a < numNodes; a++) {
  for(b = 0; b < numNodes; b++) {
   g->e[a][b] = !1;
  }
 }
}

variable_types: numNodes int

variable_types: a int

variable_types: b int


cleanFlow

decompiled_code:
__int64 __fastcall cleanFlow(__int64 a1)
{
__int64 result; // rax
__int64 v3; // rdi
__int64 v4; // rsi
__int64 v5; // rcx

result = getNumNodes((unsigned int *)a1);
if ( (int)result > 0 )
{
v3 = 8LL * (unsigned int)result;
v4 = 4LL * (unsigned int)result;
v5 = 0LL;
do
{
result = 0LL;
do
{
*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + v5) + result) = 0;
result += 4LL;
}
while ( v4 != result );
v5 += 8LL;
}
while ( v5 != v3 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 result; // rax
__int64 v3; // rdi
__int64 v4; // rsi
__int64 v5; // rcx

result = func1((unsigned int *)a1);
if ( (int)result > 0 )
{
v3 = 8LL * (unsigned int)result;
v4 = 4LL * (unsigned int)result;
v5 = 0LL;
do
{
result = 0LL;
do
{
*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + v5) + result) = 0;
result += 4LL;
}
while ( v4 != result );
v5 += 8LL;
}
while ( v5 != v3 );
}
return result;
}

original_code:
void cleanFlow(GraphFlow *g) {
 int numNodes = getNumNodes(g);
 int a = 0, b = 0;
 for(a = 0; a < numNodes; a++) {
  for(b = 0; b < numNodes; b++) {
   g->f[a][b] = 0;
  }
 }
}

canonical_original_code:
void cleanFlow(struct GraphFlow *g) {
 int numNodes = getNumNodes(g);
 int a = 0; int b = 0;
 for(a = 0; a < numNodes; a++) {
  for(b = 0; b < numNodes; b++) {
   g->f[a][b] = 0;
  }
 }
}


getSource

decompiled_code:
__int64 __fastcall getSource(__int64 a1)
{
return *(unsigned int *)(a1 + 4);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
return *(unsigned int *)(a1 + 4);
}

original_code:
int getSource(GraphFlow *g) {
 return g->source;
}

canonical_original_code:
int getSource(struct GraphFlow *g) {
 return g->source;
}


getSink

decompiled_code:
__int64 __fastcall getSink(__int64 a1)
{
return *(unsigned int *)(a1 + 8);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
return *(unsigned int *)(a1 + 8);
}

original_code:
int getSink(GraphFlow *g) {
 return g->sink;
}

canonical_original_code:
int getSink(struct GraphFlow *g) {
 return g->sink;
}


inRange

decompiled_code:
__int64 __fastcall inRange(_DWORD *a1, int a2)
{
return (*a1 > a2) & (unsigned __int8)(a2 >= 0);
}

canonical_decompiled_code:
__int64 __fastcall func6(_DWORD *a1, int a2)
{
return (*a1 > a2) & (unsigned __int8)(a2 >= 0);
}

original_code:
int inRange(GraphFlow *g, int node) {
 return node < g->numNodes && node >= 0;
}

canonical_original_code:
int inRange(struct GraphFlow *g, int node) {
 return node < g->numNodes && node >= 0;
}

variable_types: node int


addEdge

decompiled_code:
__int64 __fastcall addEdge(__int64 a1, int a2, int a3)
{
if ( !(unsigned int)inRange((_DWORD *)a1, a2) )
return 0xFFFFFFFFLL;
if ( !(unsigned int)inRange((_DWORD *)a1, a3) )
return 0xFFFFFFFFLL;
*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL * a2) + 4LL * a3) = 1;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, int a2, int a3)
{
if ( !(unsigned int)func6((_DWORD *)a1, a2) )
return 0xFFFFFFFFLL;
if ( !(unsigned int)func6((_DWORD *)a1, a3) )
return 0xFFFFFFFFLL;
*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL * a2) + 4LL * a3) = 1;
return 0LL;
}

original_code:
int addEdge(GraphFlow *g, int node1, int node2) {
 if(inRange(g,node1) && inRange(g,node2)) {
  g->e[node1][node2] = 1;
 } else {
  return -1;
 }
 return 0;
}

canonical_original_code:
int addEdge(struct GraphFlow *g, int node1, int node2) {
 if(inRange(g,node1) && inRange(g,node2)) {
  g->e[node1][node2] = 1;
 } else {
  return -1;
 }
 return 0;
}


deletEdge

decompiled_code:
__int64 __fastcall deletEdge(__int64 a1, int a2, int a3)
{
if ( !(unsigned int)inRange((_DWORD *)a1, a2) )
return 0xFFFFFFFFLL;
if ( !(unsigned int)inRange((_DWORD *)a1, a3) )
return 0xFFFFFFFFLL;
*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL * a2) + 4LL * a3) = 0;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, int a2, int a3)
{
if ( !(unsigned int)func6((_DWORD *)a1, a2) )
return 0xFFFFFFFFLL;
if ( !(unsigned int)func6((_DWORD *)a1, a3) )
return 0xFFFFFFFFLL;
*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL * a2) + 4LL * a3) = 0;
return 0LL;
}

original_code:
int deletEdge(GraphFlow *g, int node1, int node2) {
 if(inRange(g,node1) && inRange(g,node2)) {
  g->e[node1][node2] = !1;
 } else {
  return -1;
 }
 return 0;
}

canonical_original_code:
int deletEdge(struct GraphFlow *g, int node1, int node2) {
 if(inRange(g,node1) && inRange(g,node2)) {
  g->e[node1][node2] = !1;
 } else {
  return -1;
 }
 return 0;
}


getEdge

decompiled_code:
__int64 __fastcall getEdge(__int64 a1, int a2, int a3)
{
if ( !(unsigned int)inRange((_DWORD *)a1, a2) || !(unsigned int)inRange((_DWORD *)a1, a3) )
{
puts("Error range in getEdge of GraphFlow!");
exit(-1);
}
return *(unsigned int *)(*(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL * a2) + 4LL * a3);
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, int a2, int a3)
{
if ( !(unsigned int)func6((_DWORD *)a1, a2) || !(unsigned int)func6((_DWORD *)a1, a3) )
{
puts("Error range in getEdge of GraphFlow!");
exit(-1);
}
return *(unsigned int *)(*(_QWORD *)(*(_QWORD *)(a1 + 16) + 8LL * a2) + 4LL * a3);
}

original_code:
int getEdge(GraphFlow *g, int node1, int node2) {
 if(!inRange(g,node1) || !inRange(g,node2)) {
  printf("Error range in getEdge of GraphFlow!\n");
  exit(-1);
 }
 return g->e[node1][node2];
}

canonical_original_code:
int getEdge(struct GraphFlow *g, int node1, int node2) {
 if(!inRange(g,node1) || !inRange(g,node2)) {
  printf("Error range in getEdge of GraphFlow!\n");
  exit(-1);
 }
 return g->e[node1][node2];
}


setCapacity

decompiled_code:
__int64 __fastcall setCapacity(__int64 a1, int a2, int a3, int a4)
{
if ( !(unsigned int)inRange((_DWORD *)a1, a2) )
return 0xFFFFFFFFLL;
if ( !(unsigned int)inRange((_DWORD *)a1, a3) )
return 0xFFFFFFFFLL;
*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 24) + 8LL * a2) + 4LL * a3) = a4;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1, int a2, int a3, int a4)
{
if ( !(unsigned int)func6((_DWORD *)a1, a2) )
return 0xFFFFFFFFLL;
if ( !(unsigned int)func6((_DWORD *)a1, a3) )
return 0xFFFFFFFFLL;
*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 24) + 8LL * a2) + 4LL * a3) = a4;
return 0LL;
}

original_code:
int setCapacity(GraphFlow *g, int node1, int node2, int value) {
 if(inRange(g,node1) && inRange(g,node2)) {
  g->c[node1][node2] = value;
 } else {
  return -1;
 }
 return 0;
}

canonical_original_code:
int setCapacity(struct GraphFlow *g, int node1, int node2, int value) {
 if(inRange(g,node1) && inRange(g,node2)) {
  g->c[node1][node2] = value;
 } else {
  return -1;
 }
 return 0;
}

variable_types: value int


getCapacity

decompiled_code:
__int64 __fastcall getCapacity(__int64 a1, int a2, int a3)
{
if ( !(unsigned int)inRange((_DWORD *)a1, a2) || !(unsigned int)inRange((_DWORD *)a1, a3) )
{
puts("Error range in getCapacity of GraphFlow!");
exit(-1);
}
return *(unsigned int *)(*(_QWORD *)(*(_QWORD *)(a1 + 24) + 8LL * a2) + 4LL * a3);
}

canonical_decompiled_code:
__int64 __fastcall func11(__int64 a1, int a2, int a3)
{
if ( !(unsigned int)func6((_DWORD *)a1, a2) || !(unsigned int)func6((_DWORD *)a1, a3) )
{
puts("Error range in getCapacity of GraphFlow!");
exit(-1);
}
return *(unsigned int *)(*(_QWORD *)(*(_QWORD *)(a1 + 24) + 8LL * a2) + 4LL * a3);
}

original_code:
int getCapacity(GraphFlow *g, int node1, int node2) {
 if(!inRange(g,node1) || !inRange(g,node2)) {
  printf("Error range in getCapacity of GraphFlow!\n");
  exit(-1);
 }
 return g->c[node1][node2];
}

canonical_original_code:
int getCapacity(struct GraphFlow *g, int node1, int node2) {
 if(!inRange(g,node1) || !inRange(g,node2)) {
  printf("Error range in getCapacity of GraphFlow!\n");
  exit(-1);
 }
 return g->c[node1][node2];
}


setFlow

decompiled_code:
__int64 __fastcall setFlow(__int64 a1, int a2, int a3, int a4)
{
if ( !(unsigned int)inRange((_DWORD *)a1, a2) )
return 0xFFFFFFFFLL;
if ( !(unsigned int)inRange((_DWORD *)a1, a3) )
return 0xFFFFFFFFLL;
if ( (int)getCapacity(a1, a2, a3) < a4 )
return 4294967294LL;
if ( (int)getCapacity(a1, a3, a2) < a4 )
return 4294967294LL;
*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 8LL * a2) + 4LL * a3) = a4;
*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 8LL * a3) + 4LL * a2) = -a4;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func12(__int64 a1, int a2, int a3, int a4)
{
if ( !(unsigned int)func6((_DWORD *)a1, a2) )
return 0xFFFFFFFFLL;
if ( !(unsigned int)func6((_DWORD *)a1, a3) )
return 0xFFFFFFFFLL;
if ( (int)func11(a1, a2, a3) < a4 )
return 4294967294LL;
if ( (int)func11(a1, a3, a2) < a4 )
return 4294967294LL;
*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 8LL * a2) + 4LL * a3) = a4;
*(_DWORD *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 8LL * a3) + 4LL * a2) = -a4;
return 0LL;
}

original_code:
int setFlow(GraphFlow *g, int node1, int node2, int value) {
 if(inRange(g,node1) && inRange(g,node2)) {
  if( getCapacity(g,node1,node2) >= value
      && getCapacity(g,node2,node1) >= value )
  {
   g->f[node1][node2] = value;
   g->f[node2][node1] = -value;
  } else {
   return -2;
  }
 } else {
  return -1;
 }
 return 0;
}

canonical_original_code:
int setFlow(struct GraphFlow *g, int node1, int node2, int value) {
 if(inRange(g,node1) && inRange(g,node2)) {
  if( getCapacity(g,node1,node2) >= value
      && getCapacity(g,node2,node1) >= value )
  {
   g->f[node1][node2] = value;
   g->f[node2][node1] = -value;
  } else {
   return -2;
  }
 } else {
  return -1;
 }
 return 0;
}


getFlow

decompiled_code:
__int64 __fastcall getFlow(__int64 a1, int a2, int a3)
{
if ( !(unsigned int)inRange((_DWORD *)a1, a2) || !(unsigned int)inRange((_DWORD *)a1, a3) )
{
puts("Error range in getFlow of GraphFlow!");
exit(-1);
}
return *(unsigned int *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 8LL * a2) + 4LL * a3);
}

canonical_decompiled_code:
__int64 __fastcall func13(__int64 a1, int a2, int a3)
{
if ( !(unsigned int)func6((_DWORD *)a1, a2) || !(unsigned int)func6((_DWORD *)a1, a3) )
{
puts("Error range in getFlow of GraphFlow!");
exit(-1);
}
return *(unsigned int *)(*(_QWORD *)(*(_QWORD *)(a1 + 32) + 8LL * a2) + 4LL * a3);
}

original_code:
int getFlow(GraphFlow *g, int node1, int node2) {
 if(!inRange(g,node1) || !inRange(g,node2) ) {
  printf("Error range in getFlow of GraphFlow!\n");
  exit(-1);
 }
 return g->f[node1][node2];
}

canonical_original_code:
int getFlow(struct GraphFlow *g, int node1, int node2) {
 if(!inRange(g,node1) || !inRange(g,node2) ) {
  printf("Error range in getFlow of GraphFlow!\n");
  exit(-1);
 }
 return g->f[node1][node2];
}


printGraph

decompiled_code:
__int64 __fastcall printGraph(unsigned int *a1)
{
int i; // ebp
unsigned int v2; // eax
int v3; // er12
int j; // ebp
unsigned int v5; // eax
int v6; // er12
int k; // ebp
unsigned int v8; // eax
int v9; // er12
__int64 result; // rax

puts("-- graph --");
puts("-Edges:");
for ( i = 0; (int)getNumNodes(a1) > i; i = v3 + 2 )
{
do
{
v2 = getEdge((__int64)a1, i, 0);
printf("%d ", v2);
v3 = i++;
}
while ( (int)getNumNodes(a1) > i );
putchar(10);
}
puts("-Capacity:");
for ( j = 0; (int)getNumNodes(a1) > j; j = v6 + 2 )
{
do
{
v5 = getCapacity((__int64)a1, j, 0);
printf("%d ", v5);
v6 = j++;
}
while ( (int)getNumNodes(a1) > j );
putchar(10);
}
puts("-Flow:");
for ( k = 0; ; k = v9 + 2 )
{
result = getNumNodes(a1);
if ( (int)result <= k )
break;
do
{
v8 = getFlow((__int64)a1, k, 0);
printf("%d ", v8);
v9 = k++;
}
while ( (int)getNumNodes(a1) > k );
putchar(10);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func14(unsigned int *a1)
{
int i; // ebp
unsigned int v2; // eax
int v3; // er12
int j; // ebp
unsigned int v5; // eax
int v6; // er12
int k; // ebp
unsigned int v8; // eax
int v9; // er12
__int64 result; // rax

puts("-- graph --");
puts("-Edges:");
for ( i = 0; (int)func1(a1) > i; i = v3 + 2 )
{
do
{
v2 = func9((__int64)a1, i, 0);
printf("%d ", v2);
v3 = i++;
}
while ( (int)func1(a1) > i );
putchar(10);
}
puts("-Capacity:");
for ( j = 0; (int)func1(a1) > j; j = v6 + 2 )
{
do
{
v5 = func11((__int64)a1, j, 0);
printf("%d ", v5);
v6 = j++;
}
while ( (int)func1(a1) > j );
putchar(10);
}
puts("-Flow:");
for ( k = 0; ; k = v9 + 2 )
{
result = func1(a1);
if ( (int)result <= k )
break;
do
{
v8 = func13((__int64)a1, k, 0);
printf("%d ", v8);
v9 = k++;
}
while ( (int)func1(a1) > k );
putchar(10);
}
return result;
}

original_code:
void printGraph(GraphFlow *g) {
 int i = 0;
 int j = 0;
 printf("-- graph --\n");
 printf("-Edges:\n");
 for(i=0; i < getNumNodes(g); i++) {
  for(j=0; i < getNumNodes(g); i++) {
   printf("%d ", getEdge(g,i,j));
  }
  printf("\n");
 }
 printf("-Capacity:\n");
 for(i=0; i < getNumNodes(g); i++) {
  for(j=0; i < getNumNodes(g); i++) {
   printf("%d ", getCapacity(g,i,j));
  }
  printf("\n");
 }
 printf("-Flow:\n");
 for(i=0; i < getNumNodes(g); i++) {
  for(j=0; i < getNumNodes(g); i++) {
   printf("%d ", getFlow(g,i,j));
  }
  printf("\n");
 }
}

canonical_original_code:
void printGraph(struct GraphFlow *g) {
 int i = 0;
 int j = 0;
 printf("-- graph --\n");
 printf("-Edges:\n");
 for(i=0; i < getNumNodes(g); i++) {
  for(j=0; i < getNumNodes(g); i++) {
   printf("%d ", getEdge(g,i,j));
  }
  printf("\n");
 }
 printf("-Capacity:\n");
 for(i=0; i < getNumNodes(g); i++) {
  for(j=0; i < getNumNodes(g); i++) {
   printf("%d ", getCapacity(g,i,j));
  }
  printf("\n");
 }
 printf("-Flow:\n");
 for(i=0; i < getNumNodes(g); i++) {
  for(j=0; i < getNumNodes(g); i++) {
   printf("%d ", getFlow(g,i,j));
  }
  printf("\n");
 }
}

variable_types: j int


getResidualCapacity

decompiled_code:
__int64 __fastcall getResidualCapacity(_DWORD *a1, int a2, int a3)
{
int v4; // er13

if ( !(unsigned int)inRange(a1, a2) || !(unsigned int)inRange(a1, a3) )
{
puts("Error range in getResidualCapacity of GraphFlow!");
exit(-1);
}
v4 = getCapacity((__int64)a1, a2, a3);
return v4 - (unsigned int)getFlow((__int64)a1, a2, a3);
}

canonical_decompiled_code:
__int64 __fastcall func15(_DWORD *a1, int a2, int a3)
{
int v4; // er13

if ( !(unsigned int)func6(a1, a2) || !(unsigned int)func6(a1, a3) )
{
puts("Error range in getResidualCapacity of GraphFlow!");
exit(-1);
}
v4 = func11((__int64)a1, a2, a3);
return v4 - (unsigned int)func13((__int64)a1, a2, a3);
}

original_code:
int getResidualCapacity(GraphFlow *g, int node1, int node2) {
 if(!inRange(g,node1) || !inRange(g,node2)) {
  printf("Error range in getResidualCapacity of GraphFlow!\n");
  exit(-1);
 }
 return getCapacity(g,node1,node2) - getFlow(g,node1,node2);
}

canonical_original_code:
int getResidualCapacity(struct GraphFlow *g, int node1, int node2) {
 if(!inRange(g,node1) || !inRange(g,node2)) {
  printf("Error range in getResidualCapacity of GraphFlow!\n");
  exit(-1);
 }
 return getCapacity(g,node1,node2) - getFlow(g,node1,node2);
}


flow

decompiled_code:
__int64 __fastcall flow(unsigned int *a1)
{
int v1; // ebx
unsigned int v2; // er12
int v3; // eax

v1 = 0;
v2 = 0;
while ( (int)getNumNodes(a1) > v1 )
{
v3 = getSource((__int64)a1);
v2 += getFlow((__int64)a1, v3, v1++);
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func16(unsigned int *a1)
{
int v1; // ebx
unsigned int v2; // er12
int v3; // eax

v1 = 0;
v2 = 0;
while ( (int)func1(a1) > v1 )
{
v3 = func4((__int64)a1);
v2 += func13((__int64)a1, v3, v1++);
}
return v2;
}

original_code:
int flow(GraphFlow *g) {
 int result = 0;
 int node = 0;
 for(node = 0; node < getNumNodes(g); node++) {
  result += getFlow(g,getSource(g),node);
 }
 return result;
}

canonical_original_code:
int flow(struct GraphFlow *g) {
 int result = 0;
 int node = 0;
 for(node = 0; node < getNumNodes(g); node++) {
  result += getFlow(g,getSource(g),node);
 }
 return result;
}

variable_types: result int


positiveFlowToNode

decompiled_code:
__int64 __fastcall positiveFlowToNode(unsigned int *a1, int a2)
{
unsigned int v2; // ebp
int i; // ebx
int v4; // eax

if ( !(unsigned int)inRange(a1, a2) )
{
puts("Error range in positiveFlowToNode!");
exit(-1);
}
v2 = 0;
for ( i = 0; (int)getNumNodes(a1) > i; ++i )
{
v4 = getFlow((__int64)a1, i, a2);
if ( v4 > 0 )
v2 += v4;
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func17(unsigned int *a1, int a2)
{
unsigned int v2; // ebp
int i; // ebx
int v4; // eax

if ( !(unsigned int)func6(a1, a2) )
{
puts("Error range in positiveFlowToNode!");
exit(-1);
}
v2 = 0;
for ( i = 0; (int)func1(a1) > i; ++i )
{
v4 = func13((__int64)a1, i, a2);
if ( v4 > 0 )
v2 += v4;
}
return v2;
}

original_code:
int positiveFlowToNode(GraphFlow *g, int node) {
 int i = 0;
 int result = 0;
 int flow = 0;
 if(!inRange(g,node)) {
  printf("Error range in positiveFlowToNode!\n");
  exit(-1);
 }
 for(i=0; i < getNumNodes(g); i++) {
  flow = getFlow(g,i,node);
  if(flow > 0)
   result += flow;
 }
 return result;
}

canonical_original_code:
int positiveFlowToNode(struct GraphFlow *g, int node) {
 int i = 0;
 int result = 0;
 int flow = 0;
 if(!inRange(g,node)) {
  printf("Error range in positiveFlowToNode!\n");
  exit(-1);
 }
 for(i=0; i < getNumNodes(g); i++) {
  flow = getFlow(g,i,node);
  if(flow > 0)
   result += flow;
 }
 return result;
}

variable_types: flow int


positiveFlowFromNode

decompiled_code:
__int64 __fastcall positiveFlowFromNode(unsigned int *a1, int a2)
{
unsigned int v2; // ebp
int i; // ebx
int v4; // eax

if ( !(unsigned int)inRange(a1, a2) )
{
puts("Error range in positiveFlowFromNode!");
exit(-1);
}
v2 = 0;
for ( i = 0; (int)getNumNodes(a1) > i; ++i )
{
v4 = getFlow((__int64)a1, i, a2);
if ( v4 < 0 )
v2 -= v4;
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func18(unsigned int *a1, int a2)
{
unsigned int v2; // ebp
int i; // ebx
int v4; // eax

if ( !(unsigned int)func6(a1, a2) )
{
puts("Error range in positiveFlowFromNode!");
exit(-1);
}
v2 = 0;
for ( i = 0; (int)func1(a1) > i; ++i )
{
v4 = func13((__int64)a1, i, a2);
if ( v4 < 0 )
v2 -= v4;
}
return v2;
}

original_code:
int positiveFlowFromNode(GraphFlow *g, int node) {
 int i = 0;
 int result = 0;
 int flow = 0;
 if(!inRange(g,node)) {
  printf("Error range in positiveFlowFromNode!\n");
  exit(-1);
 }
 for(i=0; i < getNumNodes(g); i++) {
  flow = getFlow(g,i,node);
  if(flow < 0)
   result += -flow;
 }
 return result;
}

canonical_original_code:
int positiveFlowFromNode(struct GraphFlow *g, int node) {
 int i = 0;
 int result = 0;
 int flow = 0;
 if(!inRange(g,node)) {
  printf("Error range in positiveFlowFromNode!\n");
  exit(-1);
 }
 for(i=0; i < getNumNodes(g); i++) {
  flow = getFlow(g,i,node);
  if(flow < 0)
   result += -flow;
 }
 return result;
}


decompiled_code:
__int64 __fastcall flowConservative1(unsigned int *a1)
{
int i; // ebx
int v2; // er12

for ( i = 0; (int)getNumNodes(a1) > i; ++i )
{
if ( (unsigned int)getSink((__int64)a1) != i && (unsigned int)getSource((__int64)a1) != i )
{
v2 = positiveFlowToNode(a1, i);
if ( v2 != (unsigned int)positiveFlowFromNode(a1, i) )
return 0LL;
}
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func19(unsigned int *a1)
{
int i; // ebx
int v2; // er12

for ( i = 0; (int)func1(a1) > i; ++i )
{
if ( (unsigned int)func5((__int64)a1) != i && (unsigned int)func4((__int64)a1) != i )
{
v2 = func17(a1, i);
if ( v2 != (unsigned int)func18(a1, i) )
return 0LL;
}
}
return 1LL;
}

original_code:
int flowConservative1(GraphFlow *g) {
 int i = 0;
 for( i =0; i < getNumNodes(g); i++) {
  if( i != getSink(g)
      && i != getSource(g)
      && positiveFlowToNode(g,i) != positiveFlowFromNode(g,i) )
  {
     return !1;
  }
 }
 return 1;
}

canonical_original_code:
int flowConservative1(struct GraphFlow *g) {
 int i = 0;
 for( i =0; i < getNumNodes(g); i++) {
  if( i != getSink(g)
      && i != getSource(g)
      && positiveFlowToNode(g,i) != positiveFlowFromNode(g,i) )
  {
     return !1;
  }
 }
 return 1;
}


decompiled_code:
__int64 __fastcall flowConservative2(unsigned int *a1)
{
int i; // er12
int v2; // er13
int j; // ebx

for ( i = 0; ; ++i )
{
if ( (int)getNumNodes(a1) <= i )
return 1LL;
if ( (unsigned int)getSource((__int64)a1) != i && (unsigned int)getSink((__int64)a1) != i )
{
v2 = 0;
for ( j = 0; (int)getNumNodes(a1) > j; ++j )
v2 += getFlow((__int64)a1, i, j);
if ( v2 )
break;
}
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func20(unsigned int *a1)
{
int i; // er12
int v2; // er13
int j; // ebx

for ( i = 0; ; ++i )
{
if ( (int)func1(a1) <= i )
return 1LL;
if ( (unsigned int)func4((__int64)a1) != i && (unsigned int)func5((__int64)a1) != i )
{
v2 = 0;
for ( j = 0; (int)func1(a1) > j; ++j )
v2 += func13((__int64)a1, i, j);
if ( v2 )
break;
}
}
return 0LL;
}

original_code:
int flowConservative2(GraphFlow *g) {
 int i = 0;
 int j = 0;
 int balance = 0;
 for( i=0; i < getNumNodes(g); i++) {
  if( i != getSource(g) && i != getSink(g) ) {
   for(j=0, balance =0; j < getNumNodes(g); j++) {
    balance += getFlow(g,i,j);
   }
   if(balance != 0)
    return !1;
  }
 }
 return 1;
}

canonical_original_code:
int flowConservative2(struct GraphFlow *g) {
 int i = 0;
 int j = 0;
 int balance = 0;
 for( i=0; i < getNumNodes(g); i++) {
  if( i != getSource(g) && i != getSink(g) ) {
   for(j=0, balance =0; j < getNumNodes(g); j++) {
    balance += getFlow(g,i,j);
   }
   if(balance != 0)
    return !1;
  }
 }
 return 1;
}

variable_types: balance int


getResidualNetwork

decompiled_code:
__int64 __fastcall getResidualNetwork(unsigned int *a1)
{
int v1; // ebp
int v2; // ebx
int v3; // eax
unsigned int *v4; // r12
int i; // ebp
int v6; // ebx
__int64 result; // rax

v1 = getSink((__int64)a1);
v2 = getSource((__int64)a1);
v3 = getNumNodes(a1);
v4 = newGraphFlow(v3, v2, v1);
for ( i = 0; ; i += 2 )
{
result = getNumNodes(v4);
if ( (int)result <= i )
break;
while ( 1 )
{
v6 = getResidualCapacity(a1, i, 0);
if ( v6 > 0 )
{
addEdge((__int64)v4, i, 0);
setCapacity((__int64)v4, i, 0, v6);
}
if ( (int)getNumNodes(v4) <= i + 1 )
break;
++i;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func21(unsigned int *a1)
{
int v1; // ebp
int v2; // ebx
int v3; // eax
unsigned int *v4; // r12
int i; // ebp
int v6; // ebx
__int64 result; // rax

v1 = func5((__int64)a1);
v2 = func4((__int64)a1);
v3 = func1(a1);
v4 = newGraphFlow(v3, v2, v1);
for ( i = 0; ; i += 2 )
{
result = func1(v4);
if ( (int)result <= i )
break;
while ( 1 )
{
v6 = func15(a1, i, 0);
if ( v6 > 0 )
{
func7((__int64)v4, i, 0);
func10((__int64)v4, i, 0, v6);
}
if ( (int)func1(v4) <= i + 1 )
break;
++i;
}
}
return result;
}

original_code:
GraphFlow *getResidualNetwork(GraphFlow *g) {
 GraphFlow *newGraph = newGraphFlow( getNumNodes(g), getSource(g), getSink(g) );
 int i = 0, j = 0;
 int capacity = 0;
 for(i=0; i < getNumNodes(newGraph); i++) {
  for(j=0; i < getNumNodes(newGraph); i++) {
   capacity = getResidualCapacity(g,i,j);
   if(capacity > 0) {
    addEdge(newGraph,i,j);
    setCapacity(newGraph,i,j,capacity);
   }
  }
 }
}

canonical_original_code:
struct GraphFlow *getResidualNetwork(struct GraphFlow *g) {
 struct GraphFlow *newGraph = newGraphFlow( getNumNodes(g), getSource(g), getSink(g) );
 int i = 0; int j = 0;
 int capacity = 0;
 for(i=0; i < getNumNodes(newGraph); i++) {
  for(j=0; i < getNumNodes(newGraph); i++) {
   capacity = getResidualCapacity(g,i,j);
   if(capacity > 0) {
    addEdge(newGraph,i,j);
    setCapacity(newGraph,i,j,capacity);
   }
  }
 }
}

variable_types:
g
struct GraphFlow *

variable_types: capacity int

return_type: struct GraphFlow { int numNodes; int source; int sink; int **e; int **c; int **f; } *


repo: jroivas/prkl

decompiled_code:
const char *db_strerror()
{
return "FIXME";
}

canonical_decompiled_code:
const char *func0()
{
return "FIXME";
}

original_code:
char *db_strerror(int error)
{
    return "FIXME";
}

variable_types: error int

return_type: char *


main

canonical_name: main

repo: jrwilson/Lily

decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
char *v3; // rbx
int *v4; // rax
char *v5; // rax
int v6; // ebp
int *v7; // rax
char *v8; // rax
int *v9; // rax
char *v10; // rax
__off_t buf; // [rsp+8h] [rbp-B0h] BYREF
struct stat v12; // [rsp+10h] [rbp-A8h] BYREF

if ( argc != 2 )
{
fprintf(stderr, "Usage: %s FILE\n", *argv);
exit(1);
}
v3 = (char *)argv[1];
if ( (unsigned int)stat(v3, &v12) )
{
v4 = __errno_location();
v5 = strerror(*v4);
fprintf(stderr, "Could not stat %s: %s\n", v3, v5);
exit(1);
}
v6 = open(v3, 2);
if ( v6 != -1 )
{
buf = v12.st_size;
if ( write(v6, &buf, 8uLL) != 8 )
{
v7 = __errno_location();
v8 = strerror(*v7);
fprintf(stderr, "Could not write to %s: %s\n", v3, v8);
exit(1);
}
close(v6);
exit(0);
}
v9 = __errno_location();
v10 = strerror(*v9);
fprintf(stderr, "Could not open %s: %s\n", v3, v10);
exit(1);
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
char *v3; // rbx
int *v4; // rax
char *v5; // rax
int v6; // ebp
int *v7; // rax
char *v8; // rax
int *v9; // rax
char *v10; // rax
__off_t buf; // [rsp+8h] [rbp-B0h] BYREF
struct stat v12; // [rsp+10h] [rbp-A8h] BYREF

if ( argc != 2 )
{
fprintf(stderr, "Usage: %s FILE\n", *argv);
exit(1);
}
v3 = (char *)argv[1];
if ( (unsigned int)func9(v3, &v12) )
{
v4 = __errno_location();
v5 = strerror(*v4);
fprintf(stderr, "Could not stat %s: %s\n", v3, v5);
exit(1);
}
v6 = open(v3, 2);
if ( v6 != -1 )
{
buf = v12.st_size;
if ( write(v6, &buf, 8uLL) != 8 )
{
v7 = __errno_location();
v8 = strerror(*v7);
fprintf(stderr, "Could not write to %s: %s\n", v3, v8);
exit(1);
}
close(v6);
exit(0);
}
v9 = __errno_location();
v10 = strerror(*v9);
fprintf(stderr, "Could not open %s: %s\n", v3, v10);
exit(1);
}

original_code:
int
main (int argc,
      char** argv)
{
  if (argc != 2) {
    fprintf (stderr, "Usage: %s FILE\n", argv[0]);
    exit (1);
  }
  const char* filename = argv[1];
  struct stat sb;
  if (stat (filename, &sb) != 0) {
    fprintf (stderr, "Could not stat %s: %s\n", filename, strerror ((*__errno_location ())));
    exit (1);
  }
  int fd = open (filename, 02);
  if (fd == -1) {
    fprintf (stderr, "Could not open %s: %s\n", filename, strerror ((*__errno_location ())));
    exit (1);
  }
  size_t size = sb.st_size;
  if (write (fd, &size, sizeof (size_t)) != sizeof (size_t)) {
    fprintf (stderr, "Could not write to %s: %s\n", filename, strerror ((*__errno_location ())));
    exit (1);
  }
  close (fd);
  exit (0);
}

canonical_original_code:
int main(int argc, char **argv)
{
  if (argc != 2) {
    fprintf (stderr, "Usage: %s FILE\n", argv[0]);
    exit (1);
  }
  char *filename = argv[1];
  struct stat sb;
  if (stat (filename, &sb) != 0) {
    fprintf (stderr, "Could not stat %s: %s\n", filename, strerror ((*__errno_location ())));
    exit (1);
  }
  int fd = open (filename, 02);
  if (fd == -1) {
    fprintf (stderr, "Could not open %s: %s\n", filename, strerror ((*__errno_location ())));
    exit (1);
  }
  unsigned long size = sb.st_size;
  if (write (fd, &size, sizeof (unsigned long)) != sizeof (unsigned long)) {
    fprintf (stderr, "Could not write to %s: %s\n", filename, strerror ((*__errno_location ())));
    exit (1);
  }
  close (fd);
  exit (0);
}

variable_types: argc int

variable_types:
argv
char **

variable_types:
filename
char *

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec { long tv_sec; long tv_nsec; } st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }

variable_types: fd int

variable_types:
size
unsigned long

user_defined_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }


repo: jsarha/ucmhal

decompiled_code:
__int64 snd_card_get_index()
{
return ah_card_find_by_name();
}

canonical_decompiled_code:
__int64 func0()
{
return ah_card_find_by_name();
}

original_code:
int snd_card_get_index(const char *name)
{
 return ah_card_find_by_name(name);
}

canonical_original_code:
int snd_card_get_index(char *name)
{
 return ah_card_find_by_name(name);
}

variable_types:
name
char *


decompiled_code:
char *__fastcall snd_strerror(int a1)
{
return strerror(a1);
}

canonical_decompiled_code:
char *__fastcall func1(int a1)
{
return strerror(a1);
}

original_code:
const char *snd_strerror(int errnum)
{
 return strerror(errnum);
}

variable_types: errnum int


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

v4 = ah_card_find_by_name(a2);
if ( v4 < 0 )
{
v5 = -19;
}
else
{
v5 = ah_control_open((unsigned int)v4, a3);
if ( v5 >= 0 )
{
v6 = calloc(1uLL, 1uLL);
*a1 = v6;
*v6 = v5;
v5 = 0;
}
}
return (unsigned int)v5;
}

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

v4 = ah_card_find_by_name(a2);
if ( v4 < 0 )
{
v5 = -19;
}
else
{
v5 = ah_control_open((unsigned int)v4, a3);
if ( v5 >= 0 )
{
v6 = calloc(1uLL, 1uLL);
*a1 = v6;
*v6 = v5;
v5 = 0;
}
}
return (unsigned int)v5;
}

original_code:
int snd_ctl_open(snd_ctl_t **ctl, const char *name, int mode)
{
 int card = ah_card_find_by_name(name);
 int fd;
 if (card < 0)
  return -19;
 fd = ah_control_open(card, mode);
 if (fd < 0)
  return fd;
 *ctl = calloc(1, 1);
 **ctl = fd;
 return 0;
}

canonical_original_code:
int snd_ctl_open(int **ctl, char *name, int mode)
{
 int card = ah_card_find_by_name(name);
 int fd;
 if (card < 0)
  return -19;
 fd = ah_control_open(card, mode);
 if (fd < 0)
  return fd;
 *ctl = calloc(1, 1);
 **ctl = fd;
 return 0;
}

variable_types:
ctl
int **

variable_types: mode int

variable_types: card int


decompiled_code:
__int64 __fastcall snd_ctl_close(unsigned int *a1)
{
return ah_control_close(*a1);
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int *a1)
{
return ah_control_close(*a1);
}

original_code:
int snd_ctl_close(snd_ctl_t *ctl)
{
 return ah_control_close(*ctl);
}

canonical_original_code:
int snd_ctl_close(int *ctl)
{
 return ah_control_close(*ctl);
}

variable_types:
ctl
int *


decompiled_code:
__int64 __fastcall snd_ctl_card_info(unsigned int *a1)
{
return ah_card_get_info(*a1);
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int *a1)
{
return ah_card_get_info(*a1);
}

original_code:
int snd_ctl_card_info(snd_ctl_t *ctl, snd_ctl_card_info_t *info)
{
 return ah_card_get_info(*ctl, info);
}

canonical_original_code:
int snd_ctl_card_info(int *ctl, struct snd_ctl_card_info *info)
{
 return ah_card_get_info(*ctl, info);
}

variable_types: struct snd_ctl_card_info { int card; int pad; unsigned char id[16]; unsigned char driver[16]; unsigned char name[32]; unsigned char longname[80]; unsigned char reserved_[16]; unsigned char mixername[80]; unsigned char components[128]; } *


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

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

original_code:
void snd_ctl_card_info_free(snd_ctl_card_info_t *obj)
{
 free(obj);
}

canonical_original_code:
void snd_ctl_card_info_free(struct snd_ctl_card_info *obj)
{
 free(obj);
}

user_defined_types: struct snd_ctl_card_info { int card; int pad; unsigned char id[16]; unsigned char driver[16]; unsigned char name[32]; unsigned char longname[80]; unsigned char reserved_[16]; unsigned char mixername[80]; unsigned char components[128]; }


decompiled_code:
__int64 __fastcall snd_ctl_card_info_malloc(void **a1)
{
*a1 = malloc(0x178uLL);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func6(void **a1)
{
*a1 = malloc(0x178uLL);
return 0LL;
}

original_code:
int snd_ctl_card_info_malloc(snd_ctl_card_info_t **ptr)
{
 *ptr = malloc(sizeof(snd_ctl_card_info_t));
 if (ptr)
  return 0;
 return 12;
}

canonical_original_code:
int snd_ctl_card_info_malloc(struct snd_ctl_card_info **ptr)
{
 *ptr = malloc(sizeof(snd_ctl_card_info_t));
 if (ptr)
  return 0;
 return 12;
}

variable_types: struct snd_ctl_card_info { int card; int pad; unsigned char id[16]; unsigned char driver[16]; unsigned char name[32]; unsigned char longname[80]; unsigned char reserved_[16]; unsigned char mixername[80]; unsigned char components[128]; } **


decompiled_code:
__int64 snd_ctl_card_info_sizeof()
{
return 376LL;
}

canonical_decompiled_code:
__int64 func7()
{
return 376LL;
}

original_code:
size_t snd_ctl_card_info_sizeof(void)
{
 return sizeof(snd_ctl_card_info_t);
}

canonical_original_code:
unsigned long snd_ctl_card_info_sizeof()
{
 return sizeof(snd_ctl_card_info_t);
}

return_type: unsigned long


decompiled_code:
__int64 __fastcall snd_ctl_elem_id_malloc(_QWORD *a1)
{
void *v1; // rax

v1 = calloc(1uLL, 0x40uLL);
if ( !v1 )
return 4294967284LL;
*a1 = v1;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(_QWORD *a1)
{
void *v1; // rax

v1 = calloc(1uLL, 0x40uLL);
if ( !v1 )
return 4294967284LL;
*a1 = v1;
return 0LL;
}

original_code:
int snd_ctl_elem_id_malloc(snd_ctl_elem_id_t **ptr)
{
 snd_ctl_elem_id_t *p = calloc(1, sizeof(snd_ctl_elem_id_t));
 if (!p)
  return -12;
 *ptr = p;
 return 0;
}

canonical_original_code:
int snd_ctl_elem_id_malloc(struct snd_ctl_elem_id **ptr)
{
 struct snd_ctl_elem_id *p = calloc(1, sizeof(snd_ctl_elem_id_t));
 if (!p)
  return -12;
 *ptr = p;
 return 0;
}

variable_types: struct snd_ctl_elem_id { unsigned int numid; int iface; unsigned int device; unsigned int subdevice; unsigned char name[44]; unsigned int index; } **


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

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

original_code:
void snd_ctl_elem_id_free(snd_ctl_elem_id_t *obj)
{
 free(obj);
}

canonical_original_code:
void snd_ctl_elem_id_free(struct snd_ctl_elem_id *obj)
{
 free(obj);
}

variable_types: struct snd_ctl_elem_id { unsigned int numid; int iface; unsigned int device; unsigned int subdevice; unsigned char name[44]; unsigned int index; } *


decompiled_code:
__int64 __fastcall snd_ctl_elem_id_get_name(__int64 a1)
{
return a1 + 16;
}

canonical_decompiled_code:
__int64 __fastcall func10(__int64 a1)
{
return a1 + 16;
}

original_code:
const char *snd_ctl_elem_id_get_name(const snd_ctl_elem_id_t *obj)
{
 return (char*)obj->name;
}

canonical_original_code:
char *snd_ctl_elem_id_get_name(struct snd_ctl_elem_id *obj)
{
 return (char *)obj->name;
}

user_defined_types: struct snd_ctl_elem_id { unsigned int numid; int iface; unsigned int device; unsigned int subdevice; unsigned char name[44]; unsigned int index; }


decompiled_code:
__int64 __fastcall snd_ctl_elem_id_get_numid(unsigned int *a1)
{
return *a1;
}

canonical_decompiled_code:
__int64 __fastcall func11(unsigned int *a1)
{
return *a1;
}

original_code:
unsigned int snd_ctl_elem_id_get_numid(const snd_ctl_elem_id_t *obj)
{
 return obj->numid;
}

canonical_original_code:
unsigned int snd_ctl_elem_id_get_numid(struct snd_ctl_elem_id *obj)
{
 return obj->numid;
}

return_type: unsigned int


decompiled_code:
__int64 snd_ctl_elem_id_sizeof()
{
return 64LL;
}

canonical_decompiled_code:
__int64 func13()
{
return 64LL;
}

original_code:
size_t snd_ctl_elem_id_sizeof(void)
{
 return sizeof(snd_ctl_elem_id_t);
}

canonical_original_code:
unsigned long snd_ctl_elem_id_sizeof()
{
 return sizeof(snd_ctl_elem_id_t);
}


decompiled_code:
int __fastcall snd_ctl_elem_read(int *a1, __int64 a2)
{
int result; // eax

result = ioctl(*a1, 0xC4C85512uLL, a2);
if ( result )
result = *_errno_location();
return result;
}

canonical_decompiled_code:
int __fastcall func14(int *a1, __int64 a2)
{
int result; // eax

result = ioctl(*a1, 0xC4C85512uLL, a2);
if ( result )
result = *_errno_location();
return result;
}

original_code:
int snd_ctl_elem_read(snd_ctl_t *ctl, snd_ctl_elem_value_t *value)
{
 int e, rv = 0;
 e = ioctl(*ctl, (((2U|1U) << (((0 +8)+8)+14)) | ((('U')) << (0 +8)) | (((0x12)) << 0) | ((((sizeof(struct snd_ctl_elem_value)))) << ((0 +8)+8))), value);
 if (e)
  rv = (*__errno_location ());
 return rv;
}

canonical_original_code:
int snd_ctl_elem_read(int *ctl, struct snd_ctl_elem_value *value)
{
 int e; int rv = 0;
 e = ioctl(*ctl, (((2U|1U) << (((0 +8)+8)+14)) | ((('U')) << (0 +8)) | (((0x12)) << 0) | ((((sizeof(struct snd_ctl_elem_value)))) << ((0 +8)+8))), value);
 if (e)
  rv = (*__errno_location ());
 return rv;
}

variable_types: struct snd_ctl_elem_value { struct snd_ctl_elem_id { unsigned int numid; int iface; unsigned int device; unsigned int subdevice; unsigned char name[44]; unsigned int index; } id; unsigned int indirect; union { union { long value[128]; long *value_ptr; } integer; union { long long value[64]; long long *value_ptr; } integer64; union { unsigned int item[128]; unsigned int *item_ptr; } enumerated; union { unsigned char data[512]; unsigned char *data_ptr; } bytes; struct snd_aes_iec958 { unsigned char status[24]; unsigned char subcode[147]; unsigned char pad; unsigned char dig_subframe[4]; } iec958; } value; struct timespec { long tv_sec; long tv_nsec; } tstamp; unsigned char reserved[-1]; } *

variable_types: e int

variable_types: rv int

user_defined_types: struct snd_ctl_elem_value { struct snd_ctl_elem_id id; unsigned int indirect; union { union { long value[128]; long *value_ptr; } integer; union { long long value[64]; long long *value_ptr; } integer64; union { unsigned int item[128]; unsigned int *item_ptr; } enumerated; union { unsigned char data[512]; unsigned char *data_ptr; } bytes; struct snd_aes_iec958 iec958; } value; struct timespec tstamp; unsigned char reserved[-1]; }


decompiled_code:
int __fastcall snd_ctl_elem_write(int *a1, __int64 a2)
{
int result; // eax

result = ioctl(*a1, 0xC4C85513uLL, a2);
if ( result )
result = *_errno_location();
return result;
}

canonical_decompiled_code:
int __fastcall func15(int *a1, __int64 a2)
{
int result; // eax

result = ioctl(*a1, 0xC4C85513uLL, a2);
if ( result )
result = *_errno_location();
return result;
}

original_code:
int snd_ctl_elem_write(snd_ctl_t *ctl, snd_ctl_elem_value_t *value)
{
 int e, rv = 0;
 e = ioctl(*ctl, (((2U|1U) << (((0 +8)+8)+14)) | ((('U')) << (0 +8)) | (((0x13)) << 0) | ((((sizeof(struct snd_ctl_elem_value)))) << ((0 +8)+8))), value);
 if (e)
  rv = (*__errno_location ());
 return rv;
}

canonical_original_code:
int snd_ctl_elem_write(int *ctl, struct snd_ctl_elem_value *value)
{
 int e; int rv = 0;
 e = ioctl(*ctl, (((2U|1U) << (((0 +8)+8)+14)) | ((('U')) << (0 +8)) | (((0x13)) << 0) | ((((sizeof(struct snd_ctl_elem_value)))) << ((0 +8)+8))), value);
 if (e)
  rv = (*__errno_location ());
 return rv;
}

user_defined_types: struct timespec { long tv_sec; long tv_nsec; }

user_defined_types: struct snd_aes_iec958 { unsigned char status[24]; unsigned char subcode[147]; unsigned char pad; unsigned char dig_subframe[4]; }


decompiled_code:
int __fastcall snd_ctl_elem_info(int *a1, __int64 a2)
{
int result; // eax

result = ioctl(*a1, 0xC1105511uLL, a2);
if ( result )
result = *_errno_location();
return result;
}

canonical_decompiled_code:
int __fastcall func16(int *a1, __int64 a2)
{
int result; // eax

result = ioctl(*a1, 0xC1105511uLL, a2);
if ( result )
result = *_errno_location();
return result;
}

original_code:
int snd_ctl_elem_info(snd_ctl_t *ctl, snd_ctl_elem_info_t *info)
{
 int e, rv = 0;
 e = ioctl(*ctl, (((2U|1U) << (((0 +8)+8)+14)) | ((('U')) << (0 +8)) | (((0x11)) << 0) | ((((sizeof(struct snd_ctl_elem_info)))) << ((0 +8)+8))), info);
 if (e)
  rv = (*__errno_location ());
 return rv;
}

canonical_original_code:
int snd_ctl_elem_info(int *ctl, struct snd_ctl_elem_info *info)
{
 int e; int rv = 0;
 e = ioctl(*ctl, (((2U|1U) << (((0 +8)+8)+14)) | ((('U')) << (0 +8)) | (((0x11)) << 0) | ((((sizeof(struct snd_ctl_elem_info)))) << ((0 +8)+8))), info);
 if (e)
  rv = (*__errno_location ());
 return rv;
}

variable_types: struct snd_ctl_elem_info { struct snd_ctl_elem_id { unsigned int numid; int iface; unsigned int device; unsigned int subdevice; unsigned char name[44]; unsigned int index; } id; int type; unsigned int access; unsigned int count; int owner; union { struct { long min; long max; long step; } integer; struct { long long min; long long max; long long step; } integer64; struct { unsigned int items; unsigned int item; char name[64]; unsigned long long names_ptr; unsigned int names_length; } enumerated; unsigned char reserved[128]; } value; union { unsigned short d[4]; unsigned short *d_ptr; } dimen; unsigned char reserved[-1]; } *

user_defined_types: struct snd_ctl_elem_info { struct snd_ctl_elem_id id; int type; unsigned int access; unsigned int count; int owner; union { struct { long min; long max; long step; } integer; struct { long long min; long long max; long long step; } integer64; struct { unsigned int items; unsigned int item; char name[64]; unsigned long long names_ptr; unsigned int names_length; } enumerated; unsigned char reserved[128]; } value; union { unsigned short d[4]; unsigned short *d_ptr; } dimen; unsigned char reserved[-1]; }


decompiled_code:
__int64 __fastcall snd_ctl_elem_info_get_count(__int64 a1)
{
return *(unsigned int *)(a1 + 72);
}

canonical_decompiled_code:
__int64 __fastcall func17(__int64 a1)
{
return *(unsigned int *)(a1 + 72);
}

original_code:
unsigned int snd_ctl_elem_info_get_count(const snd_ctl_elem_info_t *obj)
{
 return obj->count;
}

canonical_original_code:
unsigned int snd_ctl_elem_info_get_count(struct snd_ctl_elem_info *obj)
{
 return obj->count;
}


decompiled_code:
__int64 __fastcall snd_ctl_elem_info_get_type(__int64 a1)
{
return *(unsigned int *)(a1 + 64);
}

canonical_decompiled_code:
__int64 __fastcall func18(__int64 a1)
{
return *(unsigned int *)(a1 + 64);
}

original_code:
snd_ctl_elem_type_t snd_ctl_elem_info_get_type(const snd_ctl_elem_info_t *obj)
{
 return obj->type;
}

canonical_original_code:
int snd_ctl_elem_info_get_type(struct snd_ctl_elem_info *obj)
{
 return obj->type;
}


original_code:
void snd_ctl_elem_info_set_id(snd_ctl_elem_info_t *obj, const snd_ctl_elem_id_t *ptr)
{
 memcpy(&obj->id, ptr, sizeof(snd_ctl_elem_id_t));
}

canonical_original_code:
void snd_ctl_elem_info_set_id(struct snd_ctl_elem_info *obj, struct snd_ctl_elem_id *ptr)
{
 memcpy(&obj->id, ptr, sizeof(snd_ctl_elem_id_t));
}

variable_types:
ptr
struct snd_ctl_elem_id *


decompiled_code:
__int64 snd_ctl_elem_info_sizeof()
{
return 272LL;
}

canonical_decompiled_code:
__int64 func20()
{
return 272LL;
}

original_code:
size_t snd_ctl_elem_info_sizeof(void)
{
 return sizeof(snd_ctl_elem_info_t);
}

canonical_original_code:
unsigned long snd_ctl_elem_info_sizeof()
{
 return sizeof(snd_ctl_elem_info_t);
}


decompiled_code:
__int64 snd_ctl_elem_list_sizeof()
{
return 80LL;
}

canonical_decompiled_code:
__int64 func21()
{
return 80LL;
}

original_code:
size_t snd_ctl_elem_list_sizeof(void)
{
 return sizeof(snd_ctl_elem_list_t);
}

canonical_original_code:
unsigned long snd_ctl_elem_list_sizeof()
{
 return sizeof(snd_ctl_elem_list_t);
}


decompiled_code:
__int64 __fastcall snd_ctl_elem_list_alloc_space(__int64 a1, unsigned int a2)
{
void *v2; // rax

free(*(void **)(a1 + 16));
v2 = calloc(a2, 0x40uLL);
*(_QWORD *)(a1 + 16) = v2;
return v2 == 0LL ? 0xC : 0;
}

canonical_decompiled_code:
__int64 __fastcall func22(__int64 a1, unsigned int a2)
{
void *v2; // rax

free(*(void **)(a1 + 16));
v2 = calloc(a2, 0x40uLL);
*(_QWORD *)(a1 + 16) = v2;
return v2 == 0LL ? 0xC : 0;
}

original_code:
int snd_ctl_elem_list_alloc_space(snd_ctl_elem_list_t *obj, unsigned int entries)
{
 free(obj->pids);
 obj->pids = calloc(entries, sizeof(snd_ctl_elem_id_t));
 if (!obj->pids)
  return 12;
 return 0;
}

canonical_original_code:
int snd_ctl_elem_list_alloc_space(struct snd_ctl_elem_list *obj, unsigned int entries)
{
 free(obj->pids);
 obj->pids = calloc(entries, sizeof(snd_ctl_elem_id_t));
 if (!obj->pids)
  return 12;
 return 0;
}

variable_types: struct snd_ctl_elem_list { unsigned int offset; unsigned int space; unsigned int used; unsigned int count; struct snd_ctl_elem_id { unsigned int numid; int iface; unsigned int device; unsigned int subdevice; unsigned char name[44]; unsigned int index; } *pids; unsigned char reserved[50]; } *

variable_types:
entries
unsigned int

user_defined_types: struct snd_ctl_elem_list { unsigned int offset; unsigned int space; unsigned int used; unsigned int count; struct snd_ctl_elem_id *pids; unsigned char reserved[50]; }


decompiled_code:
int __fastcall snd_ctl_elem_list(int *a1, __int64 a2)
{
int result; // eax

if ( ioctl(*a1, 0xC0505510uLL, a2) )
return -*_errno_location();
if ( (unsigned int)snd_ctl_elem_list_alloc_space(a2, *(_DWORD *)(a2 + 12)) )
return -12;
*(_DWORD *)(a2 + 4) = *(_DWORD *)(a2 + 12);
result = ioctl(*a1, 0xC0505510uLL, a2);
if ( result )
result = -*_errno_location();
return result;
}

canonical_decompiled_code:
int __fastcall func23(int *a1, __int64 a2)
{
int result; // eax

if ( ioctl(*a1, 0xC0505510uLL, a2) )
return -*_errno_location();
if ( (unsigned int)func22(a2, *(_DWORD *)(a2 + 12)) )
return -12;
*(_DWORD *)(a2 + 4) = *(_DWORD *)(a2 + 12);
result = ioctl(*a1, 0xC0505510uLL, a2);
if ( result )
result = -*_errno_location();
return result;
}

original_code:
int snd_ctl_elem_list(snd_ctl_t *ctl, snd_ctl_elem_list_t *list)
{
 int e, rv = 0;
 e = ioctl(*ctl, (((2U|1U) << (((0 +8)+8)+14)) | ((('U')) << (0 +8)) | (((0x10)) << 0) | ((((sizeof(struct snd_ctl_elem_list)))) << ((0 +8)+8))), list);
 if (e) {
  rv = -(*__errno_location ());
  goto end;
 }
 if (list->count < 0) {
  rv = 0;
  goto end;
 }
 if (snd_ctl_elem_list_alloc_space(list, list->count)) {
  rv = -12;
  goto end;
 }
 list->space = list->count;
 e = ioctl(*ctl, (((2U|1U) << (((0 +8)+8)+14)) | ((('U')) << (0 +8)) | (((0x10)) << 0) | ((((sizeof(struct snd_ctl_elem_list)))) << ((0 +8)+8))), list);
 if (e) {
  rv = -(*__errno_location ());
  goto end;
 }
end:
 return rv;
}

canonical_original_code:
int snd_ctl_elem_list(int *ctl, struct snd_ctl_elem_list *list)
{
 int e; int rv = 0;
 e = ioctl(*ctl, (((2U|1U) << (((0 +8)+8)+14)) | ((('U')) << (0 +8)) | (((0x10)) << 0) | ((((sizeof(struct snd_ctl_elem_list)))) << ((0 +8)+8))), list);
 if (e) {
  rv = -(*__errno_location ());
  goto end;
 }
 if (list->count < 0) {
  rv = 0;
  goto end;
 }
 if (snd_ctl_elem_list_alloc_space(list, list->count)) {
  rv = -12;
  goto end;
 }
 list->space = list->count;
 e = ioctl(*ctl, (((2U|1U) << (((0 +8)+8)+14)) | ((('U')) << (0 +8)) | (((0x10)) << 0) | ((((sizeof(struct snd_ctl_elem_list)))) << ((0 +8)+8))), list);
 if (e) {
  rv = -(*__errno_location ());
  goto end;
 }
end:
 return rv;
}


decompiled_code:
void __fastcall snd_ctl_elem_list_free_space(__int64 a1)
{
free(*(void **)(a1 + 16));
}

canonical_decompiled_code:
void __fastcall func24(__int64 a1)
{
free(*(void **)(a1 + 16));
}

original_code:
void snd_ctl_elem_list_free_space(snd_ctl_elem_list_t *obj)
{
 free(obj->pids);
}

canonical_original_code:
void snd_ctl_elem_list_free_space(struct snd_ctl_elem_list *obj)
{
 free(obj->pids);
}


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

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

original_code:
void snd_ctl_elem_list_free(snd_ctl_elem_list_t *obj)
{
 free(obj);
}

canonical_original_code:
void snd_ctl_elem_list_free(struct snd_ctl_elem_list *obj)
{
 free(obj);
}


decompiled_code:
__int64 __fastcall snd_ctl_elem_list_get_count(__int64 a1)
{
return *(unsigned int *)(a1 + 12);
}

canonical_decompiled_code:
__int64 __fastcall func26(__int64 a1)
{
return *(unsigned int *)(a1 + 12);
}

original_code:
unsigned int snd_ctl_elem_list_get_count(const snd_ctl_elem_list_t *obj)
{
 return obj->count;
}

canonical_original_code:
unsigned int snd_ctl_elem_list_get_count(struct snd_ctl_elem_list *obj)
{
 return obj->count;
}


decompiled_code:
__int64 __fastcall snd_ctl_elem_list_malloc(_QWORD *a1)
{
void *v1; // rax

v1 = calloc(1uLL, 0x50uLL);
if ( !v1 )
return 12LL;
*a1 = v1;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func27(_QWORD *a1)
{
void *v1; // rax

v1 = calloc(1uLL, 0x50uLL);
if ( !v1 )
return 12LL;
*a1 = v1;
return 0LL;
}

original_code:
int snd_ctl_elem_list_malloc(snd_ctl_elem_list_t **ptr)
{
 snd_ctl_elem_list_t *p = calloc(1, sizeof(snd_ctl_elem_list_t));
 if (!p)
  return 12;
 *ptr = p;
 return 0;
}

canonical_original_code:
int snd_ctl_elem_list_malloc(struct snd_ctl_elem_list **ptr)
{
 struct snd_ctl_elem_list *p = calloc(1, sizeof(snd_ctl_elem_list_t));
 if (!p)
  return 12;
 *ptr = p;
 return 0;
}

variable_types: struct snd_ctl_elem_list { unsigned int offset; unsigned int space; unsigned int used; unsigned int count; struct snd_ctl_elem_id { unsigned int numid; int iface; unsigned int device; unsigned int subdevice; unsigned char name[44]; unsigned int index; } *pids; unsigned char reserved[50]; } **


decompiled_code:
__int64 snd_ctl_elem_value_sizeof()
{
return 1224LL;
}

canonical_decompiled_code:
__int64 func30()
{
return 1224LL;
}

original_code:
size_t snd_ctl_elem_value_sizeof(void)
{
 return sizeof(snd_ctl_elem_value_t);
}

canonical_original_code:
unsigned long snd_ctl_elem_value_sizeof()
{
 return sizeof(snd_ctl_elem_value_t);
}


original_code:
void snd_ctl_elem_value_set_id(snd_ctl_elem_value_t *obj, const snd_ctl_elem_id_t *ptr)
{
 memcpy(&obj->id, ptr, sizeof(snd_ctl_elem_id_t));
}

canonical_original_code:
void snd_ctl_elem_value_set_id(struct snd_ctl_elem_value *obj, struct snd_ctl_elem_id *ptr)
{
 memcpy(&obj->id, ptr, sizeof(snd_ctl_elem_id_t));
}


decompiled_code:
__int64 __fastcall snd_ctl_elem_value_get_boolean(__int64 a1, unsigned int a2)
{
return *(_QWORD *)(a1 + 8LL * a2 + 72);
}

canonical_decompiled_code:
__int64 __fastcall func32(__int64 a1, unsigned int a2)
{
return *(_QWORD *)(a1 + 8LL * a2 + 72);
}

original_code:
int snd_ctl_elem_value_get_boolean(const snd_ctl_elem_value_t *obj, unsigned int idx)
{
 return obj->value.integer.value[idx];
}

canonical_original_code:
int snd_ctl_elem_value_get_boolean(struct snd_ctl_elem_value *obj, unsigned int idx)
{
 return obj->value.integer.value[idx];
}

variable_types:
idx
unsigned int


decompiled_code:
void __fastcall snd_ctl_elem_value_set_boolean(__int64 a1, unsigned int a2, __int64 a3)
{
*(_QWORD *)(a1 + 8LL * a2 + 72) = a3;
}

canonical_decompiled_code:
void __fastcall func33(__int64 a1, unsigned int a2, __int64 a3)
{
*(_QWORD *)(a1 + 8LL * a2 + 72) = a3;
}

original_code:
void snd_ctl_elem_value_set_boolean(snd_ctl_elem_value_t *obj, unsigned int idx, long val)
{
 obj->value.integer.value[idx] = val;
}

canonical_original_code:
void snd_ctl_elem_value_set_boolean(struct snd_ctl_elem_value *obj, unsigned int idx, long val)
{
 obj->value.integer.value[idx] = val;
}

variable_types: val long


decompiled_code:
__int64 __fastcall snd_ctl_elem_value_get_byte(__int64 a1, unsigned int a2)
{
return *(unsigned __int8 *)(a2 + a1 + 72);
}

canonical_decompiled_code:
__int64 __fastcall func34(__int64 a1, unsigned int a2)
{
return *(unsigned __int8 *)(a2 + a1 + 72);
}

original_code:
unsigned char snd_ctl_elem_value_get_byte(const snd_ctl_elem_value_t *obj, unsigned int idx)
{
 return obj->value.bytes.data[idx];
}

canonical_original_code:
unsigned char snd_ctl_elem_value_get_byte(struct snd_ctl_elem_value *obj, unsigned int idx)
{
 return obj->value.bytes.data[idx];
}

return_type: unsigned char


decompiled_code:
void __fastcall snd_ctl_elem_value_set_byte(__int64 a1, unsigned int a2, char a3)
{
*(_BYTE *)(a2 + a1 + 72) = a3;
}

canonical_decompiled_code:
void __fastcall func35(__int64 a1, unsigned int a2, char a3)
{
*(_BYTE *)(a2 + a1 + 72) = a3;
}

original_code:
void snd_ctl_elem_value_set_byte(snd_ctl_elem_value_t *obj, unsigned int idx, unsigned char val)
{
 obj->value.bytes.data[idx] = val;
}

canonical_original_code:
void snd_ctl_elem_value_set_byte(struct snd_ctl_elem_value *obj, unsigned int idx, unsigned char val)
{
 obj->value.bytes.data[idx] = val;
}

variable_types:
val
unsigned char


decompiled_code:
__int64 __fastcall snd_ctl_elem_value_get_enumerated(__int64 a1, unsigned int a2)
{
return *(unsigned int *)(a1 + 4LL * a2 + 72);
}

canonical_decompiled_code:
__int64 __fastcall func36(__int64 a1, unsigned int a2)
{
return *(unsigned int *)(a1 + 4LL * a2 + 72);
}

original_code:
unsigned int snd_ctl_elem_value_get_enumerated(const snd_ctl_elem_value_t *obj, unsigned int idx)
{
 return obj->value.enumerated.item[idx];
}

canonical_original_code:
unsigned int snd_ctl_elem_value_get_enumerated(struct snd_ctl_elem_value *obj, unsigned int idx)
{
 return obj->value.enumerated.item[idx];
}


decompiled_code:
void __fastcall snd_ctl_elem_value_set_enumerated(__int64 a1, unsigned int a2, int a3)
{
*(_DWORD *)(a1 + 4LL * a2 + 72) = a3;
}

canonical_decompiled_code:
void __fastcall func37(__int64 a1, unsigned int a2, int a3)
{
*(_DWORD *)(a1 + 4LL * a2 + 72) = a3;
}

original_code:
void snd_ctl_elem_value_set_enumerated(snd_ctl_elem_value_t *obj, unsigned int idx, unsigned int val)
{
 obj->value.enumerated.item[idx] = val;
}

canonical_original_code:
void snd_ctl_elem_value_set_enumerated(struct snd_ctl_elem_value *obj, unsigned int idx, unsigned int val)
{
 obj->value.enumerated.item[idx] = val;
}

variable_types:
val
unsigned int


decompiled_code:
__int64 __fastcall snd_ctl_elem_value_get_integer(__int64 a1, unsigned int a2)
{
return *(_QWORD *)(a1 + 8LL * a2 + 72);
}

canonical_decompiled_code:
__int64 __fastcall func38(__int64 a1, unsigned int a2)
{
return *(_QWORD *)(a1 + 8LL * a2 + 72);
}

original_code:
long snd_ctl_elem_value_get_integer(const snd_ctl_elem_value_t *obj, unsigned int idx)
{
 return obj->value.integer.value[idx];
}

canonical_original_code:
long snd_ctl_elem_value_get_integer(struct snd_ctl_elem_value *obj, unsigned int idx)
{
 return obj->value.integer.value[idx];
}

return_type: long


decompiled_code:
void __fastcall snd_ctl_elem_value_set_integer(__int64 a1, unsigned int a2, __int64 a3)
{
*(_QWORD *)(a1 + 8LL * a2 + 72) = a3;
}

canonical_decompiled_code:
void __fastcall func39(__int64 a1, unsigned int a2, __int64 a3)
{
*(_QWORD *)(a1 + 8LL * a2 + 72) = a3;
}

original_code:
void snd_ctl_elem_value_set_integer(snd_ctl_elem_value_t *obj, unsigned int idx, long val)
{
 obj->value.integer.value[idx] = val;
}

canonical_original_code:
void snd_ctl_elem_value_set_integer(struct snd_ctl_elem_value *obj, unsigned int idx, long val)
{
 obj->value.integer.value[idx] = val;
}


decompiled_code:
__int64 __fastcall snd_ctl_elem_value_get_integer64(__int64 a1, unsigned int a2)
{
return *(_QWORD *)(a1 + 8LL * a2 + 72);
}

canonical_decompiled_code:
__int64 __fastcall func40(__int64 a1, unsigned int a2)
{
return *(_QWORD *)(a1 + 8LL * a2 + 72);
}

original_code:
long long snd_ctl_elem_value_get_integer64(const snd_ctl_elem_value_t *obj, unsigned int idx)
{
 return obj->value.integer64.value[idx];
}

canonical_original_code:
long long snd_ctl_elem_value_get_integer64(struct snd_ctl_elem_value *obj, unsigned int idx)
{
 return obj->value.integer64.value[idx];
}

return_type: long long


decompiled_code:
void __fastcall snd_ctl_elem_value_set_integer64(__int64 a1, unsigned int a2, __int64 a3)
{
*(_QWORD *)(a1 + 8LL * a2 + 72) = a3;
}

canonical_decompiled_code:
void __fastcall func41(__int64 a1, unsigned int a2, __int64 a3)
{
*(_QWORD *)(a1 + 8LL * a2 + 72) = a3;
}

original_code:
void snd_ctl_elem_value_set_integer64(snd_ctl_elem_value_t *obj, unsigned int idx, long long val)
{
 obj->value.integer64.value[idx] = val;
}

canonical_original_code:
void snd_ctl_elem_value_set_integer64(struct snd_ctl_elem_value *obj, unsigned int idx, long long val)
{
 obj->value.integer64.value[idx] = val;
}

variable_types:
val
long long


decompiled_code:
__int64 ah_card_max_count()
{
return 32LL;
}

canonical_decompiled_code:
__int64 func2()
{
return 32LL;
}

original_code:
int ah_card_max_count()
{
 return 32;
}

canonical_original_code:
int ah_card_max_count()
{
 return 32;
}


decompiled_code:
int __fastcall ah_card_get_info(int a1, __int64 a2)
{
int result; // eax

result = ioctl(a1, 0x81785501uLL, a2);
if ( result )
result = -*_errno_location();
return result;
}

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

result = ioctl(a1, 0x81785501uLL, a2);
if ( result )
result = -*_errno_location();
return result;
}

canonical_original_code:
int ah_card_get_info(int fd, struct snd_ctl_card_info *info)
{
        int e; int rv = 0;
        e = ioctl(fd, (((2U) << (((0 +8)+8)+14)) | ((('U')) << (0 +8)) | (((0x01)) << 0) | ((((sizeof(struct snd_ctl_card_info)))) << ((0 +8)+8))), info);
        if(e)
  rv = -(*__errno_location ());
        return rv;
}

variable_types: fd int

variable_types: struct snd_ctl_card_info { int card; int pad; unsigned char id[16]; unsigned char driver[16]; unsigned char name[32]; unsigned char longname[80]; unsigned char reserved_[16]; unsigned char mixername[80]; unsigned char components[128]; } *


decompiled_code:
int __fastcall ah_control_open(unsigned int a1, int a2)
{
char file[8]; // [rsp+0h] [rbp-58h] BYREF
__int64 v4; // [rsp+8h] [rbp-50h]
__int64 v5; // [rsp+10h] [rbp-48h]
__int64 v6; // [rsp+18h] [rbp-40h]
__int64 v7; // [rsp+20h] [rbp-38h]
__int64 v8; // [rsp+28h] [rbp-30h]
int v9; // [rsp+30h] [rbp-28h]

*(_QWORD *)file = 0LL;
v4 = 0LL;
v5 = 0LL;
v6 = 0LL;
v7 = 0LL;
v8 = 0LL;
v9 = 0;
card_control_path(a1, file, 0x34uLL);
debug_print("alsa-control.c", 0xC6u, "alsa-control API", 69, "Trying to open %s (card = %d)", file, a1);
return open(file, a2);
}

canonical_decompiled_code:
int __fastcall func5(unsigned int a1, int a2)
{
char file[8]; // [rsp+0h] [rbp-58h] BYREF
__int64 v4; // [rsp+8h] [rbp-50h]
__int64 v5; // [rsp+10h] [rbp-48h]
__int64 v6; // [rsp+18h] [rbp-40h]
__int64 v7; // [rsp+20h] [rbp-38h]
__int64 v8; // [rsp+28h] [rbp-30h]
int v9; // [rsp+30h] [rbp-28h]

*(_QWORD *)file = 0LL;
v4 = 0LL;
v5 = 0LL;
v6 = 0LL;
v7 = 0LL;
v8 = 0LL;
v9 = 0;
func0(a1, file, 0x34uLL);
func1("alsa-control.c", 0xC6u, "alsa-control API", 69, "Trying to open %s (card = %d)", file, a1);
return open(file, a2);
}

original_code:
int ah_control_open(int card, int mode)
{
 char control_fn[sizeof("/dev/snd" "/" "controlC" "%d") + 32] = "";
 int fd;
 card_control_path(card, control_fn, sizeof(control_fn));
 debug_print("alsa-control.c", 198, "alsa-control API", 'E', "Trying to open %s (card = %d)", control_fn, card);
 fd = open(control_fn, mode);
 return fd;
}

canonical_original_code:
int ah_control_open(int card, int mode)
{
 char control_fn[-1] = "";
 int fd;
 card_control_path(card, control_fn, sizeof(control_fn));
 debug_print("alsa-control.c", 198, "alsa-control API", 'E', "Trying to open %s (card = %d)", control_fn, card);
 fd = open(control_fn, mode);
 return fd;
}

variable_types: card int

variable_types: mode int


decompiled_code:
int __fastcall ah_control_close(int a1)
{
return close(a1);
}

canonical_decompiled_code:
int __fastcall func6(int a1)
{
return close(a1);
}

original_code:
int ah_control_close(int fd)
{
 return close(fd);
}


decompiled_code:
__int64 __fastcall ah_card_get_name(unsigned int a1, char *a2, size_t a3)
{
int v4; // eax
int v5; // ebp
unsigned int v6; // ebx
int *v8; // rbx
__int64 v9; // [rsp+0h] [rbp-1B8h] BYREF
char src[432]; // [rsp+8h] [rbp-1B0h] BYREF

v4 = ah_control_open(a1, 0);
if ( v4 < 0 )
{
debug_print("alsa-control.c", 0x6Du, "alsa-control API", 69, "ah_control_open() failed");
v6 = -*_errno_location();
}
else
{
v5 = v4;
v6 = ah_card_get_info(v4, (__int64)&v9);
if ( v6 )
{
v8 = _errno_location();
debug_print("alsa-control.c", 0x74u, "alsa-control API", 69, "error %d in getting card info", (unsigned int)*v8);
v6 = -*v8;
}
else
{
debug_print("alsa-control.c", 0x78u, "alsa-control API", 69, "card %d info->name = %s", a1, src);
strncpy(a2, src, a3);
}
ah_control_close(v5);
}
return v6;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned int a1, char *a2, size_t a3)
{
int v4; // eax
int v5; // ebp
unsigned int v6; // ebx
int *v8; // rbx
__int64 v9; // [rsp+0h] [rbp-1B8h] BYREF
char src[432]; // [rsp+8h] [rbp-1B0h] BYREF

v4 = func5(a1, 0);
if ( v4 < 0 )
{
func1("alsa-control.c", 0x6Du, "alsa-control API", 69, "ah_control_open() failed");
v6 = -*_errno_location();
}
else
{
v5 = v4;
v6 = func4(v4, (__int64)&v9);
if ( v6 )
{
v8 = _errno_location();
func1("alsa-control.c", 0x74u, "alsa-control API", 69, "error %d in getting card info", (unsigned int)*v8);
v6 = -*v8;
}
else
{
func1("alsa-control.c", 0x78u, "alsa-control API", 69, "card %d info->name = %s", a1, src);
strncpy(a2, src, a3);
}
func6(v5);
}
return v6;
}

original_code:
int ah_card_get_name(int card, char *str, size_t strlen)
{
 snd_ctl_card_info_t info;
 int fd, rv = 0;
 fd = ah_control_open(card, 00);
 if (fd < 0) {
  debug_print("alsa-control.c", 109, "alsa-control API", 'E', "ah_control_open() failed");
  rv = -(*__errno_location ());
  goto end;
 }
 rv = ah_card_get_info(fd, &info);
 if (rv) {
  debug_print("alsa-control.c", 116, "alsa-control API", 'E', "error %d in getting card info", (*__errno_location ()));
  rv = -(*__errno_location ());
  goto card_err;
 }
 debug_print("alsa-control.c", 120, "alsa-control API", 'E', "card %d info->name = %s", card, info.id);
 strncpy(str, (char*)info.id, strlen);
card_err:
 ah_control_close(fd);
end:
        return rv;
}

canonical_original_code:
int ah_card_get_name(int card, char *str, unsigned long strlen)
{
 struct snd_ctl_card_info info;
 int fd; int rv = 0;
 fd = ah_control_open(card, 00);
 if (fd < 0) {
  debug_print("alsa-control.c", 109, "alsa-control API", 'E', "ah_control_open() failed");
  rv = -(*__errno_location ());
  goto end;
 }
 rv = ah_card_get_info(fd, &info);
 if (rv) {
  debug_print("alsa-control.c", 116, "alsa-control API", 'E', "error %d in getting card info", (*__errno_location ()));
  rv = -(*__errno_location ());
  goto card_err;
 }
 debug_print("alsa-control.c", 120, "alsa-control API", 'E', "card %d info->name = %s", card, info.id);
 strncpy(str, (char *)info.id, strlen);
card_err:
 ah_control_close(fd);
end:
        return rv;
}

variable_types:
str
char *

variable_types:
strlen
unsigned long

variable_types: struct snd_ctl_card_info { int card; int pad; unsigned char id[16]; unsigned char driver[16]; unsigned char name[32]; unsigned char longname[80]; unsigned char reserved_[16]; unsigned char mixername[80]; unsigned char components[128]; }


original_code:
int ah_card_find_by_name(const char* name)
{
 char cur[256] = "";
 int cards = ah_card_count();
 int k;
 int match = 0;
 if (1 == sscanf(name, "hw:%d", &k) && k < cards) {
  debug_print("alsa-control.c", 143, "alsa-control API", 'D', "Name '%s' refers to card %d", name, k);
  return k;
 }
 debug_print("alsa-control.c", 147, "alsa-control API", 'D', "%s() looking for %s", __func__, name);
 for (k = 0 ; k < cards ; ++k) {
  ah_card_get_name(k, cur, sizeof(cur));
  debug_print("alsa-control.c", 150, "alsa-control API", 'D', "Comparing to '%s'", cur);
  if ( 0 == strcmp(cur, name) ) {
   match = 1;
   break;
  }
 }
 if (match)
  return k;
 return -19;
}

canonical_original_code:
int ah_card_find_by_name(char *name)
{
 char cur[256] = "";
 int cards = ah_card_count();
 int k;
 int match = 0;
 if (1 == sscanf(name, "hw:%d", &k) && k < cards) {
  debug_print("alsa-control.c", 143, "alsa-control API", 'D', "Name '%s' refers to card %d", name, k);
  return k;
 }
 debug_print("alsa-control.c", 147, "alsa-control API", 'D', "%s() looking for %s", __func__, name);
 for (k = 0 ; k < cards ; ++k) {
  ah_card_get_name(k, cur, sizeof(cur));
  debug_print("alsa-control.c", 150, "alsa-control API", 'D', "Comparing to '%s'", cur);
  if ( 0 == strcmp(cur, name) ) {
   match = 1;
   break;
  }
 }
 if (match)
  return k;
 return -19;
}

variable_types:
name
char *

variable_types:
cur
char [256]

variable_types: cards int

variable_types: k int

variable_types: match int


compare

repo: jschauma/news

decompiled_code:
__int64 __fastcall compare(const FTSENT **a1, const FTSENT **a2)
{
__time_t v2; // rcx
__time_t v3; // rdx
__int64 result; // rax

v2 = (*a1)->fts_statp->st_mtim.tv_sec;
v3 = (*a2)->fts_statp->st_mtim.tv_sec;
result = 0xFFFFFFFFLL;
if ( v2 <= v3 )
result = v2 != v3;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(const FTSENT **a1, const FTSENT **a2)
{
__time_t v2; // rcx
__time_t v3; // rdx
__int64 result; // rax

v2 = (*a1)->fts_statp->st_mtim.tv_sec;
v3 = (*a2)->fts_statp->st_mtim.tv_sec;
result = 0xFFFFFFFFLL;
if ( v2 <= v3 )
result = v2 != v3;
return result;
}

original_code:
int
compare(const FTSENT **a, const FTSENT **b)
{
 if ((*a)->fts_statp->st_mtim.tv_sec > (*b)->fts_statp->st_mtim.tv_sec)
  return -1;
 else if ((*a)->fts_statp->st_mtim.tv_sec == (*b)->fts_statp->st_mtim.tv_sec)
  return 0;
 else
  return 1;
}

canonical_original_code:
int compare(struct _ftsent **a, struct _ftsent **b)
{
 if ((*a)->fts_statp->st_mtim.tv_sec > (*b)->fts_statp->st_mtim.tv_sec)
  return -1;
 else if ((*a)->fts_statp->st_mtim.tv_sec == (*b)->fts_statp->st_mtim.tv_sec)
  return 0;
 else
  return 1;
}

variable_types: struct _ftsent { struct _ftsent *fts_cycle; struct _ftsent *fts_parent; struct _ftsent *fts_link; long fts_number; void *fts_pointer; char *fts_accpath; char *fts_path; int fts_errno; int fts_symfd; unsigned short fts_pathlen; unsigned short fts_namelen; unsigned long fts_ino; unsigned long fts_dev; unsigned long fts_nlink; short fts_level; unsigned short fts_info; unsigned short fts_flags; unsigned short fts_instr; struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec { long tv_sec; long tv_nsec; } st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; } *fts_statp; char fts_name[1]; } **

variable_types:
b
struct _ftsent **

user_defined_types: struct _ftsent { struct _ftsent *fts_cycle; struct _ftsent *fts_parent; struct _ftsent *fts_link; long fts_number; void *fts_pointer; char *fts_accpath; char *fts_path; int fts_errno; int fts_symfd; unsigned short fts_pathlen; unsigned short fts_namelen; unsigned long fts_ino; unsigned long fts_dev; unsigned long fts_nlink; short fts_level; unsigned short fts_info; unsigned short fts_flags; unsigned short fts_instr; struct stat *fts_statp; char fts_name[1]; }


usage

decompiled_code:
void __noreturn usage()
{
fwrite("usage: news [-ans] [ items ]\n", 1uLL, 0x1DuLL, stderr);
exit(1);
}

canonical_decompiled_code:
void __noreturn func8()
{
fwrite("usage: news [-ans] [ items ]\n", 1uLL, 0x1DuLL, stderr);
exit(1);
}

original_code:
void
usage()
{
 (void)fprintf(stderr, "usage: news [-ans] [ items ]\n");
 exit(1);
}


updateTimestamp

decompiled_code:
__time_t __fastcall updateTimestamp(char *file)
{
int v1; // eax
__time_t v2; // rbp
int v4; // er12
__m128i v5; // [rsp+0h] [rbp-C8h] BYREF
__m128i v6; // [rsp+10h] [rbp-B8h] BYREF
struct stat v7; // [rsp+20h] [rbp-A8h] BYREF

v1 = stat(file, &v7);
v2 = v7.st_mtim.tv_sec;
if ( v1 == -1 )
{
f_all = 1;
v4 = open(file, 705, 384LL);
if ( v4 == -1 )
{
warn("unable to create %s", file);
}
else
{
v6 = 0uLL;
v5 = _mm_loadu_si128(&v6);
if ( utimes(file, (const struct timeval *)&v5) == -1 )
warn("unable to update timestamp");
close(v4);
v2 = 0LL;
}
}
if ( !f_short && utimes(file, 0LL) == -1 )
warn("unable to update timestamp");
return v2;
}

canonical_decompiled_code:
__time_t __fastcall func9(char *file)
{
int v1; // eax
__time_t v2; // rbp
int v4; // er12
__m128i v5; // [rsp+0h] [rbp-C8h] BYREF
__m128i v6; // [rsp+10h] [rbp-B8h] BYREF
struct stat v7; // [rsp+20h] [rbp-A8h] BYREF

v1 = func15(file, &v7);
v2 = v7.st_mtim.tv_sec;
if ( v1 == -1 )
{
f_all = 1;
v4 = open(file, 705, 384LL);
if ( v4 == -1 )
{
warn("unable to create %s", file);
}
else
{
v6 = 0uLL;
v5 = _mm_loadu_si128(&v6);
if ( utimes(file, (const struct timeval *)&v5) == -1 )
warn("unable to update timestamp");
close(v4);
v2 = 0LL;
}
}
if ( !f_short && utimes(file, 0LL) == -1 )
warn("unable to update timestamp");
return v2;
}

original_code:
time_t
updateTimestamp(const char *nf)
{
 struct stat sb;
 time_t retval;
 if (stat(nf, &sb) == -1) {
  int fd;
  f_all = 1;
  if ((fd = open(nf, 0100 |0200 | 01000 | 01,
      0400 | 0200)) == -1)
   warn("unable to create %s", nf);
  else {
   struct timeval tv[2];
   struct timeval tv1;
   tv1.tv_sec = tv1.tv_usec = 0;
   tv[0] = tv[1] = tv1;
   if (utimes(nf, tv) == -1)
    warn("unable to update timestamp");
   retval = (time_t)0;
   close(fd);
  }
 } else
  retval = sb.st_mtim.tv_sec;
 if (!f_short)
  if (utimes(nf, ((void *)0)) == -1)
   warn("unable to update timestamp");
 return retval;
}

canonical_original_code:
long updateTimestamp(char *nf)
{
 struct stat sb;
 long retval;
 if (stat(nf, &sb) == -1) {
  int fd;
  f_all = 1;
  if ((fd = open(nf, 0100 |0200 | 01000 | 01,
      0400 | 0200)) == -1)
   warn("unable to create %s", nf);
  else {
   struct timeval tv[2];
   struct timeval tv1;
   tv1.tv_sec = tv1.tv_usec = 0;
   tv[0] = tv[1] = tv1;
   if (utimes(nf, tv) == -1)
    warn("unable to update timestamp");
   retval = (long)0;
   close(fd);
  }
 } else
  retval = sb.st_mtim.tv_sec;
 if (!f_short)
  if (utimes(nf, ((void *)0)) == -1)
   warn("unable to update timestamp");
 return retval;
}

variable_types:
nf
char *

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec { long tv_sec; long tv_nsec; } st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }

variable_types: retval long

variable_types: struct timeval { long tv_sec; long tv_usec; } [2]


printHead

decompiled_code:
void __fastcall printHead(char *a1)
{
struct passwd *v1; // rax
unsigned int v2; // eax
char v3[272]; // [rsp+0h] [rbp-1A8h] BYREF
struct stat v4; // [rsp+110h] [rbp-98h] BYREF

if ( (unsigned int)stat(a1, &v4) == -1 )
{
warn("unable to stat %s", a1);
}
else
{
v1 = getpwuid(v4.st_uid);
if ( v1 )
snprintf(v3, 0x102uLL, "(%s)", v1->pw_name);
else
snprintf(v3, 0x102uLL, "(%d)", v4.st_uid);
v2 = (unsigned int)ctime(&v4.st_mtim.tv_sec);
printf("%s %s %s", a1, v3, (const char *)v2);
}
}

canonical_decompiled_code:
void __fastcall func10(char *a1)
{
struct passwd *v1; // rax
unsigned int v2; // eax
char v3[272]; // [rsp+0h] [rbp-1A8h] BYREF
struct stat v4; // [rsp+110h] [rbp-98h] BYREF

if ( (unsigned int)func15(a1, &v4) == -1 )
{
warn("unable to stat %s", a1);
}
else
{
v1 = getpwuid(v4.st_uid);
if ( v1 )
snprintf(v3, 0x102uLL, "(%s)", v1->pw_name);
else
snprintf(v3, 0x102uLL, "(%d)", v4.st_uid);
v2 = (unsigned int)ctime(&v4.st_mtim.tv_sec);
printf("%s %s %s", a1, v3, (const char *)v2);
}
}

original_code:
void
printHead(const char *file)
{
 struct stat sb;
 struct passwd *pw;
 char owner[256 +2];
 if (stat(file, &sb) == -1) {
  warn("unable to stat %s", file);
  return;
 }
 if (((pw = getpwuid(sb.st_uid)) == ((void *)0)))
  (void)snprintf(owner, 256 +2, "(%d)", sb.st_uid);
 else
  (void)snprintf(owner, 256 +2, "(%s)", pw->pw_name);
 printf("%s %s %s", file, owner, ctime(&(sb.st_mtim.tv_sec)));
}

canonical_original_code:
void printHead(char *file)
{
 struct stat sb;
 struct passwd *pw;
 char owner[-1];
 if (stat(file, &sb) == -1) {
  warn("unable to stat %s", file);
  return;
 }
 if (((pw = getpwuid(sb.st_uid)) == ((void *)0)))
  (void)snprintf(owner, 256 +2, "(%d)", sb.st_uid);
 else
  (void)snprintf(owner, 256 +2, "(%s)", pw->pw_name);
 printf("%s %s %s", file, owner, ctime(&(sb.st_mtim.tv_sec)));
}

variable_types:
file
char *

variable_types: struct passwd { char *pw_name; char *pw_passwd; unsigned int pw_uid; unsigned int pw_gid; char *pw_gecos; char *pw_dir; char *pw_shell; } *

variable_types:
owner
char [-1]


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
char **v4; // r13
char *v5; // rax
const char *v6; // r12
size_t v7; // rbp
char *v8; // rax
char *v9; // rbx

f_short = 0;
f_name = 0;
f_all = 0;
while ( 1 )
{
v3 = getopt(argc, (char *const *)argv, "ans");
if ( v3 == -1 )
break;
if ( v3 == 110 )
{
f_name = 1;
f_short = 0;
}
else if ( v3 == 115 )
{
f_short = 1;
f_name = 0;
}
else
{
if ( v3 != 97 )
usage();
f_all = 1;
}
}
v4 = (char **)&argv[optind];
if ( *v4 && f_short | f_name | f_all )
errx(1, "Options are not allowed with file names.");
v5 = getenv("HOME");
v6 = v5;
if ( !v5 )
errx(1, "Unable to find HOME variable.");
v7 = (int)(strlen(v5) + 12);
v8 = (char *)malloc(v7);
v9 = v8;
if ( !v8 )
errx(1, "Unable to allocate memory.");
if ( snprintf(v8, v7, "%s/%s", v6, ".news_time") == -1 )
errx(1, "Unable to prepare path.");
nf_time = updateTimestamp(v9);
free(v9);
return printFiles(v4);
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
char **v4; // r13
char *v5; // rax
const char *v6; // r12
size_t v7; // rbp
char *v8; // rax
char *v9; // rbx

f_short = 0;
f_name = 0;
f_all = 0;
while ( 1 )
{
v3 = getopt(argc, (char *const *)argv, "ans");
if ( v3 == -1 )
break;
if ( v3 == 110 )
{
f_name = 1;
f_short = 0;
}
else if ( v3 == 115 )
{
f_short = 1;
f_name = 0;
}
else
{
if ( v3 != 97 )
func8();
f_all = 1;
}
}
v4 = (char **)&argv[optind];
if ( *v4 && f_short | f_name | f_all )
errx(1, "Options are not allowed with file names.");
v5 = getenv("HOME");
v6 = v5;
if ( !v5 )
errx(1, "Unable to find HOME variable.");
v7 = (int)(strlen(v5) + 12);
v8 = (char *)malloc(v7);
v9 = v8;
if ( !v8 )
errx(1, "Unable to allocate memory.");
if ( snprintf(v8, v7, "%s/%s", v6, ".news_time") == -1 )
errx(1, "Unable to prepare path.");
nf_time = func9(v9);
free(v9);
return func12(v4);
}

original_code:
int
main(int argc, char *argv[])
{
 int ch, len;
 char *home, *nf;
 extern int optind;
 f_all = f_name = f_short = 0;
 while ((ch = getopt(argc, argv, "ans")) != -1) {
  switch(ch) {
  case 'a':
   f_all = 1;
   break;
  case 'n':
   f_name = 1;
   f_short = 0;
   break;
  case 's':
   f_short = 1;
   f_name = 0;
   break;
  case '?':
  default:
   usage();
  }
 }
 argc -= optind;
 argv += optind;
 if (*argv && (f_all || f_name || f_short))
  errx(1, "Options are not allowed with file names.");
 if ((home = getenv("HOME")) == ((void *)0))
  errx(1, "Unable to find HOME variable.");
 len = strlen(home) + strlen(".news_time") + 2;
 if ((nf = malloc(len)) == ((void *)0))
  errx(1, "Unable to allocate memory.");
 if ((snprintf(nf, len, "%s/%s", home, ".news_time")) == -1)
  errx(1, "Unable to prepare path.");
 nf_time = updateTimestamp(nf);
 free(nf);
 return printFiles(argv);
}

canonical_original_code:
int main(int argc, char *argv[])
{
 int ch; int len;
 char *home; char *nf;
 extern int optind;
 f_all = f_name = f_short = 0;
 while ((ch = getopt(argc, argv, "ans")) != -1) {
  switch(ch) {
  case 'a':
   f_all = 1;
   break;
  case 'n':
   f_name = 1;
   f_short = 0;
   break;
  case 's':
   f_short = 1;
   f_name = 0;
   break;
  case '?':
  default:
   usage();
  }
 }
 argc -= optind;
 argv += optind;
 if (*argv && (f_all || f_name || f_short))
  errx(1, "Options are not allowed with file names.");
 if ((home = getenv("HOME")) == ((void *)0))
  errx(1, "Unable to find HOME variable.");
 len = strlen(home) + strlen(".news_time") + 2;
 if ((nf = malloc(len)) == ((void *)0))
  errx(1, "Unable to allocate memory.");
 if ((snprintf(nf, len, "%s/%s", home, ".news_time")) == -1)
  errx(1, "Unable to prepare path.");
 nf_time = updateTimestamp(nf);
 free(nf);
 return printFiles(argv);
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: ch int

variable_types: len int

variable_types:
home
char *

variable_types: optind int