original_code:
int update_dissolved_organic_losses(
      struct date current_date,
      double DON_production_rate,
      struct soil_c_object *cs_soil,
      struct soil_n_object *ns_soil,
      struct litter_c_object *cs_litr,
      struct litter_n_object *ns_litr,
      struct cdayflux_patch_struct *cdf,
      struct ndayflux_patch_struct *ndf)
{
 double cn_l1,cn_l2,cn_l3,cn_l4,cn_s1,cn_s2,cn_s3,cn_s4;
 int ok;
 ok=1;
 if (ns_litr->litr1n > 0.000000001) cn_l1 = cs_litr->litr1c/ns_litr->litr1n;
  else cn_l1 = 50;
 if (ns_litr->litr2n > 0.000000001) cn_l2 = cs_litr->litr2c/ns_litr->litr2n;
  else cn_l2 = 250.0;
 if (ns_litr->litr3n > 0.000000001) cn_l3 = cs_litr->litr3c/ns_litr->litr3n;
  else cn_l3 = 500.0;
 if (ns_litr->litr4n > 0.000000001) cn_l4 = cs_litr->litr4c/ns_litr->litr4n;
  else cn_l4 = 500.0;
 cn_s1 = 12.0;
 cn_s2 = 12.0;
 cn_s3 = 10.0;
 cn_s4 = 8.0;
 if (-1.0*ndf->pmnf_l1s1 > 0.000000001) {
  ndf->do_litr1n_loss = DON_production_rate * -1.0*ndf->pmnf_l1s1;
  cdf->do_litr1c_loss = ndf->do_litr1n_loss * cn_l1;
  }
 if (-1.0*ndf->pmnf_l2s2 > 0.000000001) {
  ndf->do_litr2n_loss = DON_production_rate * -1.0*ndf->pmnf_l2s2;
  cdf->do_litr2c_loss = ndf->do_litr2n_loss * cn_l2;
  }
 if (-1.0*ndf->pmnf_l4s3 > 0.000000001) {
  ndf->do_litr3n_loss = DON_production_rate * -1.0*ndf->pmnf_l3l2;
  cdf->do_litr3c_loss = ndf->do_litr3n_loss * cn_l3;
  }
 if (-1.0*ndf->pmnf_l4s3 > 0.000000001) {
  ndf->do_litr4n_loss = DON_production_rate * -1.0*ndf->pmnf_l4s3;
  cdf->do_litr4c_loss = ndf->do_litr4n_loss * cn_l4;
  }
 if (-1.0*ndf->pmnf_s1s2 > 0.000000001) {
  ndf->do_soil1n_loss = DON_production_rate * -1.0*ndf->pmnf_s1s2;
  cdf->do_soil1c_loss = ndf->do_soil1n_loss * cn_s1;
  }
 if (-1.0*ndf->pmnf_s2s3 > 0.000000001) {
  ndf->do_soil2n_loss = DON_production_rate * -1.0*ndf->pmnf_s2s3;
  cdf->do_soil2c_loss = ndf->do_soil2n_loss * cn_s2;
  }
 if (-1.0*ndf->pmnf_s3s4 > 0.000000001) {
  ndf->do_soil3n_loss = DON_production_rate * -1.0*ndf->pmnf_s3s4;
  cdf->do_soil3c_loss = ndf->do_soil3n_loss * cn_s3;
  }
 if (-1.0*ndf->soil4n_to_sminn > 0.000000001) {
  ndf->do_soil4n_loss = DON_production_rate * -1.0*ndf->soil4n_to_sminn;
  cdf->do_soil4c_loss = ndf->do_soil4n_loss * cn_s4;
  }
 cs_litr->litr1c -= cdf->do_litr1c_loss;
 cs_litr->litr3c -= cdf->do_litr3c_loss;
 cs_litr->litr2c -= cdf->do_litr2c_loss;
 cs_litr->litr4c -= cdf->do_litr4c_loss;
 cs_soil->soil1c -= cdf->do_soil1c_loss;
 cs_soil->soil2c -= cdf->do_soil2c_loss;
 cs_soil->soil3c -= cdf->do_soil3c_loss;
 cs_soil->soil4c -= cdf->do_soil4c_loss;
 ns_litr->litr1n -= ndf->do_litr1n_loss;
 ns_litr->litr2n -= ndf->do_litr2n_loss;
 ns_litr->litr3n -= ndf->do_litr3n_loss;
 ns_litr->litr4n -= ndf->do_litr4n_loss;
 ns_soil->soil1n -= ndf->do_soil1n_loss;
 ns_soil->soil2n -= ndf->do_soil2n_loss;
 ns_soil->soil3n -= ndf->do_soil3n_loss;
 ns_soil->soil4n -= ndf->do_soil4n_loss;
 cs_soil->DOC += (cdf->do_soil1c_loss + cdf->do_soil2c_loss + cdf->do_soil3c_loss + cdf->do_soil4c_loss);
 ns_soil->DON += ( ndf->do_soil1n_loss + ndf->do_soil3n_loss + ndf->do_soil2n_loss + ndf->do_soil4n_loss);
 return (!ok);
}

canonical_original_code:
int update_dissolved_organic_losses(struct date current_date, double DON_production_rate, struct soil_c_object *cs_soil, struct soil_n_object *ns_soil, struct litter_c_object *cs_litr, struct litter_n_object *ns_litr, struct cdayflux_patch_struct *cdf, struct ndayflux_patch_struct *ndf)
{
 double cn_l1; double cn_l2; double cn_l3; double cn_l4; double cn_s1; double cn_s2; double cn_s3; double cn_s4;
 int ok;
 ok=1;
 if (ns_litr->litr1n > 0.000000001) cn_l1 = cs_litr->litr1c/ns_litr->litr1n;
  else cn_l1 = 50;
 if (ns_litr->litr2n > 0.000000001) cn_l2 = cs_litr->litr2c/ns_litr->litr2n;
  else cn_l2 = 250.0;
 if (ns_litr->litr3n > 0.000000001) cn_l3 = cs_litr->litr3c/ns_litr->litr3n;
  else cn_l3 = 500.0;
 if (ns_litr->litr4n > 0.000000001) cn_l4 = cs_litr->litr4c/ns_litr->litr4n;
  else cn_l4 = 500.0;
 cn_s1 = 12.0;
 cn_s2 = 12.0;
 cn_s3 = 10.0;
 cn_s4 = 8.0;
 if (-1.0*ndf->pmnf_l1s1 > 0.000000001) {
  ndf->do_litr1n_loss = DON_production_rate * -1.0*ndf->pmnf_l1s1;
  cdf->do_litr1c_loss = ndf->do_litr1n_loss * cn_l1;
  }
 if (-1.0*ndf->pmnf_l2s2 > 0.000000001) {
  ndf->do_litr2n_loss = DON_production_rate * -1.0*ndf->pmnf_l2s2;
  cdf->do_litr2c_loss = ndf->do_litr2n_loss * cn_l2;
  }
 if (-1.0*ndf->pmnf_l4s3 > 0.000000001) {
  ndf->do_litr3n_loss = DON_production_rate * -1.0*ndf->pmnf_l3l2;
  cdf->do_litr3c_loss = ndf->do_litr3n_loss * cn_l3;
  }
 if (-1.0*ndf->pmnf_l4s3 > 0.000000001) {
  ndf->do_litr4n_loss = DON_production_rate * -1.0*ndf->pmnf_l4s3;
  cdf->do_litr4c_loss = ndf->do_litr4n_loss * cn_l4;
  }
 if (-1.0*ndf->pmnf_s1s2 > 0.000000001) {
  ndf->do_soil1n_loss = DON_production_rate * -1.0*ndf->pmnf_s1s2;
  cdf->do_soil1c_loss = ndf->do_soil1n_loss * cn_s1;
  }
 if (-1.0*ndf->pmnf_s2s3 > 0.000000001) {
  ndf->do_soil2n_loss = DON_production_rate * -1.0*ndf->pmnf_s2s3;
  cdf->do_soil2c_loss = ndf->do_soil2n_loss * cn_s2;
  }
 if (-1.0*ndf->pmnf_s3s4 > 0.000000001) {
  ndf->do_soil3n_loss = DON_production_rate * -1.0*ndf->pmnf_s3s4;
  cdf->do_soil3c_loss = ndf->do_soil3n_loss * cn_s3;
  }
 if (-1.0*ndf->soil4n_to_sminn > 0.000000001) {
  ndf->do_soil4n_loss = DON_production_rate * -1.0*ndf->soil4n_to_sminn;
  cdf->do_soil4c_loss = ndf->do_soil4n_loss * cn_s4;
  }
 cs_litr->litr1c -= cdf->do_litr1c_loss;
 cs_litr->litr3c -= cdf->do_litr3c_loss;
 cs_litr->litr2c -= cdf->do_litr2c_loss;
 cs_litr->litr4c -= cdf->do_litr4c_loss;
 cs_soil->soil1c -= cdf->do_soil1c_loss;
 cs_soil->soil2c -= cdf->do_soil2c_loss;
 cs_soil->soil3c -= cdf->do_soil3c_loss;
 cs_soil->soil4c -= cdf->do_soil4c_loss;
 ns_litr->litr1n -= ndf->do_litr1n_loss;
 ns_litr->litr2n -= ndf->do_litr2n_loss;
 ns_litr->litr3n -= ndf->do_litr3n_loss;
 ns_litr->litr4n -= ndf->do_litr4n_loss;
 ns_soil->soil1n -= ndf->do_soil1n_loss;
 ns_soil->soil2n -= ndf->do_soil2n_loss;
 ns_soil->soil3n -= ndf->do_soil3n_loss;
 ns_soil->soil4n -= ndf->do_soil4n_loss;
 cs_soil->DOC += (cdf->do_soil1c_loss + cdf->do_soil2c_loss + cdf->do_soil3c_loss + cdf->do_soil4c_loss);
 ns_soil->DON += ( ndf->do_soil1n_loss + ndf->do_soil3n_loss + ndf->do_soil2n_loss + ndf->do_soil4n_loss);
 return (!ok);
}

variable_types: struct date { long year; long month; long day; long hour; }

user_defined_types: struct soil_c_object { double frootc; double DOC; double DOC_Qin; double DOC_Qout; double DOC_Qin_total; double DOC_Qout_total; double totalc; double soil_cpool; double soil1c; double soil2c; double soil3c; double soil4c; double soil1c_hr_snk; double soil2c_hr_snk; double soil3c_hr_snk; double soil4c_hr_snk; }

user_defined_types: struct soil_n_object { double nlimit; double fract_potential_immob; double fract_potential_uptake; double totaln; double soil_npool; double DON; double DON_Qin; double DON_Qout; double DON_Qin_total; double DON_Qout_total; double soil1n; double soil2n; double soil3n; double soil4n; double sminn; double nitrate; double NO3_Qin_total; double NO3_Qout_total; double NO3_Qin; double NO3_Qout; double NH4_Qin; double NH4_Qout; double NH4_Qin_total; double NH4_Qout_total; double leach; double nfix_src; double ndep_src; double nleached_snk; double nvolatilized_snk; }

user_defined_types: struct litter_c_object { double totalc; double litr1c; double litr2c; double litr3c; double litr4c; double litr1c_hr_snk; double litr2c_hr_snk; double litr4c_hr_snk; double fire_snk; double t_scalar; double w_scalar; }

user_defined_types: struct litter_n_object { double totaln; double litr1n; double litr2n; double litr3n; double litr4n; double fire_snk; }

user_defined_types: struct cdayflux_patch_struct { double do_litr1c_loss; double do_litr2c_loss; double do_litr3c_loss; double do_litr4c_loss; double do_soil1c_loss; double do_soil2c_loss; double do_soil3c_loss; double do_soil4c_loss; double total_DOC_loss; double DOC_to_gw; double plitr1c_loss; double plitr2c_loss; double plitr3c_loss; double plitr4c_loss; double psoil1c_loss; double psoil2c_loss; double psoil3c_loss; double psoil4c_loss; double kl4; double decomp_w_scalar; double decomp_t_scalar; double leafc_to_litr1c; double leafc_to_litr2c; double leafc_to_litr3c; double leafc_to_litr4c; double frootc_to_litr1c; double frootc_to_litr2c; double frootc_to_litr3c; double frootc_to_litr4c; double litr1c_to_soil1c; double litr2c_to_soil2c; double litr3c_to_litr2c; double litr4c_to_soil3c; double soil1c_to_soil2c; double soil2c_to_soil3c; double soil3c_to_soil4c; double cwdc_to_litr2c; double cwdc_to_litr3c; double cwdc_to_litr4c; double litr1c_hr; double litr2c_hr; double litr3c_hr; double litr4c_hr; double soil1c_hr; double soil2c_hr; double soil3c_hr; double soil4c_hr; double m_leafc_to_litr1c; double m_leafc_to_litr2c; double m_leafc_to_litr3c; double m_leafc_to_litr4c; double m_frootc_to_litr1c; double m_frootc_to_litr2c; double m_frootc_to_litr3c; double m_frootc_to_litr4c; double m_leafc_store_to_litr1c; double m_frootc_store_to_litr1c; double m_livestemc_store_to_litr1c; double m_deadstemc_store_to_litr1c; double m_livecrootc_store_to_litr1c; double m_deadcrootc_store_to_litr1c; double m_leafc_transfer_to_litr1c; double m_frootc_transfer_to_litr1c; double m_livestemc_transfer_to_litr1c; double m_deadstemc_transfer_to_litr1c; double m_livecrootc_transfer_to_litr1c; double m_deadcrootc_transfer_to_litr1c; double m_gresp_store_to_litr1c; double m_gresp_transfer_to_litr1c; double m_litr1c_to_atmos; double m_litr2c_to_atmos; double m_litr3c_to_atmos; double m_litr4c_to_atmos; double m_soil1c_to_atmos; double m_soil2c_to_atmos; double m_soil3c_to_atmos; double m_soil4c_to_atmos; }

user_defined_types: struct ndayflux_patch_struct { double do_litr1n_loss; double do_litr2n_loss; double do_litr3n_loss; double do_litr4n_loss; double do_soil1n_loss; double do_soil2n_loss; double do_soil3n_loss; double do_soil4n_loss; double total_DON_loss; double DON_to_gw; double mineralized; double potential_immob; double net_mineralized; double pmnf_l1s1; double pmnf_l2s2; double pmnf_l3l2; double pmnf_l4s3; double pmnf_s1s2; double pmnf_s2s3; double pmnf_s3s4; double pmnf_s4; double leafn_to_litr1n; double leafn_to_litr2n; double leafn_to_litr3n; double leafn_to_litr4n; double frootn_to_litr1n; double frootn_to_litr2n; double frootn_to_litr3n; double frootn_to_litr4n; double litr1n_to_soil1n; double litr2n_to_soil2n; double litr4n_to_soil3n; double litr3n_to_litr2n; double soil1n_to_soil2n; double soil2n_to_soil3n; double soil3n_to_soil4n; double cwdn_to_litr2n; double cwdn_to_litr3n; double cwdn_to_litr4n; double plant_potential_ndemand; double plant_avail_uptake; double sminn_to_soil1n_l1; double sminn_to_soil2n_l2; double sminn_to_soil2n_l3; double sminn_to_soil3n_l4; double sminn_to_soil2n_s1; double sminn_to_soil3n_s2; double sminn_to_soil4n_s3; double sminn_to_npool; double soil4n_to_sminn; double sminn_to_nitrate; double m_leafn_to_litr1n; double m_leafn_to_litr2n; double m_leafn_to_litr3n; double m_leafn_to_litr4n; double m_frootn_to_litr1n; double m_frootn_to_litr2n; double m_frootn_to_litr3n; double m_frootn_to_litr4n; double m_livestemn_to_litr1n; double m_livecrootn_to_litr1n; double m_leafn_store_to_litr1n; double m_frootn_store_to_litr1n; double m_livestemn_store_to_litr1n; double m_deadstemn_store_to_litr1n; double m_livecrootn_store_to_litr1n; double m_deadcrootn_store_to_litr1n; double m_leafn_transfer_to_litr1n; double m_frootn_transfer_to_litr1n; double m_livestemn_transfer_to_litr1n; double m_deadstemn_transfer_to_litr1n; double m_livecrootn_transfer_to_litr1n; double m_deadcrootn_transfer_to_litr1n; double m_retransn_to_litr1n; double sminn_to_nvol; double denitrif; double ndep_to_sminn; double nfix_to_sminn; double N_to_gw; double m_litr1n_to_atmos; double m_litr2n_to_atmos; double m_litr3n_to_atmos; double m_litr4n_to_atmos; double m_soil1n_to_atmos; double m_soil2n_to_atmos; double m_soil3n_to_atmos; double m_soil4n_to_atmos; }


repo: RHESSys/RHESSys

original_code:
char *get_iso_date(struct date const * const d) {
 char *iso_date = malloc(17);
 long hour = d->hour;
 if (hour > 24) hour = 24;
 snprintf(iso_date, 17, "%ld-%02ld-%02ldT%02ld:%02d",
   d->year, d->month, d->day, hour, 0);
 return iso_date;
}

canonical_original_code:
char *get_iso_date(struct date *d) {
 char *iso_date = malloc(17);
 long hour = d->hour;
 if (hour > 24) hour = 24;
 snprintf(iso_date, 17, "%ld-%02ld-%02ldT%02ld:%02d",
   d->year, d->month, d->day, hour, 0);
 return iso_date;
}

variable_types: struct date { long year; long month; long day; long hour; } *

variable_types: hour long

return_type: char *


decompiled_code:
void __fastcall destroy_basin_defaults(int a1, int a2, void **a3)
{
void **v4; // rbx
__int64 v5; // r12
void *v6; // rdi

if ( a2 && a1 > 0 )
{
v4 = a3 + 2;
v5 = (__int64)&a3[3 * (unsigned int)(a1 - 1) + 5];
do
{
v6 = *v4;
v4 += 3;
free(v6);
}
while ( v4 != (void **)v5 );
}
free(a3);
}

original_code:
void destroy_basin_defaults(int num_default_files,
       int grow_flag,
       struct basin_default *default_object_list )
{
 int i;
 if ( grow_flag ){
  for ( i=0 ; i<num_default_files; i++ )
   free( default_object_list[i].grow_defaults );
 }
 free( default_object_list );
 return;
}

canonical_original_code:
void destroy_basin_defaults(int num_default_files, int grow_flag, struct basin_default *default_object_list)
{
 int i;
 if ( grow_flag ){
  for ( i=0 ; i<num_default_files; i++ )
   free( default_object_list[i].grow_defaults );
 }
 free( default_object_list );
 return;
}

variable_types: struct basin_default { int ID; int n_routing_timesteps; int wyday_start; struct basin_grow_default { int temp; } *grow_defaults; } *

variable_types: i int

return_type: void

user_defined_types: struct basin_default { int ID; int n_routing_timesteps; int wyday_start; struct basin_grow_default *grow_defaults; }


decompiled_code:
__int64 __fastcall compute_potential_decomp(double *a1, double *a2, double *a3, double *a4, double *a5, double *a6, double a7, double a8, double a9, double a10, double a11, __m128d a12, double a13, double a14)
{
__m128d v19; // xmm0
__int64 v20; // xmm1_8
double v21; // xmm5_8
char *v22; // r14
double v23; // xmm2_8
double v24; // xmm4_8
double v25; // xmm0_8
double v26; // xmm2_8
double v27; // xmm0_8
double v28; // xmm4_8
__m128d v29; // xmm1
double v30; // xmm0_8
double v31; // xmm4_8
double v32; // xmm14_8
double v33; // xmm1_8
double v34; // xmm6_8
double v35; // xmm9_8
double v36; // xmm2_8
double v37; // xmm12_8
double v38; // xmm8_8
double v39; // xmm1_8
double v40; // xmm11_8
double v41; // xmm10_8
double v42; // xmm7_8
double v43; // xmm15_8
double v44; // xmm6_8
double v45; // xmm9_8
double v46; // xmm13_8
double v47; // xmm2_8
double v48; // xmm13_8
double v49; // xmm1_8
double v50; // xmm0_8
double v51; // xmm12_8
double v52; // rdi
double v53; // xmm0_8
double v54; // xmm11_8
double v55; // rdx
double v56; // xmm10_8
double v57; // xmm10_8
double v58; // rsi
double v59; // xmm0_8
double v60; // xmm5_8
double v61; // rcx
double v62; // xmm8_8
double v63; // xmm0_8
__int64 result; // rax
double v65; // xmm0_8
double v66; // [rsp+8h] [rbp-F0h]
double v67; // [rsp+8h] [rbp-F0h]
double v68; // [rsp+8h] [rbp-F0h]
unsigned __int64 v69; // [rsp+8h] [rbp-F0h]
double v70; // [rsp+10h] [rbp-E8h]
double v71; // [rsp+18h] [rbp-E0h]
double v72; // [rsp+20h] [rbp-D8h]
double v74; // [rsp+30h] [rbp-C8h]
double v75; // [rsp+50h] [rbp-A8h]
double v76; // [rsp+50h] [rbp-A8h]
double v78; // [rsp+68h] [rbp-90h]
__int64 v79[9]; // [rsp+78h] [rbp-80h] BYREF
char v80; // [rsp+C0h] [rbp-38h] BYREF

v72 = a10;
v79[1] = LC10;
v79[2] = LC11;
v79[0] = 0LL;
v79[3] = LC12;
v79[4] = LC13;
v79[5] = LC14;
v75 = 0.0;
v79[6] = LC15;
v79[7] = LC16;
v79[8] = LC17;
if ( a7 >= -10.0 )
{
v69 = *(_QWORD *)&a12.m128d_f64[0];
v65 = exp((0.0140805406927626 - 1.0 / (a7 + 273.15 - 227.13)) * 308.56);
*(_QWORD *)&a12.m128d_f64[0] = v69;
v75 = v65;
}
*(_QWORD *)&v19.m128d_f64[0] = LC23;
v19.m128d_f64[0] = _mm_cmpge_sd(v19, a12).m128d_f64[0];
v20 = *(_QWORD *)&v75 & *(_QWORD *)&v19.m128d_f64[0];
*(_QWORD *)&v19.m128d_f64[0] = ~*(_QWORD *)&v19.m128d_f64[0] & *(_QWORD *)&a12.m128d_f64[0];
v21 = *(double *)&LC6;
*(_QWORD *)&v76 = *(_QWORD *)&v19.m128d_f64[0] | v20;
if ( a11 <= 0.000000001 )
{
if ( a10 > 0.000000001 )
{
if ( a10 <= 1.0 )
{
v74 = *(double *)&LC24;
if ( a10 <= 0.0012 )
{
v24 = *(double *)&LC5;
LABEL_79:
v28 = sqrt(v24);
goto LABEL_16;
}
v78 = *(double *)&LC25;
v27 = a10 - 2.5;
}
else
{
v27 = *(double *)&LC1;
v74 = *(double *)&LC24;
v72 = *(double *)&LC2;
v78 = *(double *)&LC25;
}
}
else
{
v27 = *(double *)&LC1;
v74 = *(double *)&LC24;
v72 = *(double *)&LC2;
v78 = *(double *)&LC25;
}
v67 = pow(v27 / (a14 - v78), (v78 - a14) * 2.84 / (a14 - v74));
v24 = v67 * pow((v72 - v74) / (a14 - v74), 2.84);
v21 = *(double *)&LC6;
}
else
{
v22 = (char *)v79;
v23 = 0.0;
v24 = 0.0;
while ( 1 )
{
v26 = v23 * a11 + a10;
if ( v26 > 1.0 )
{
v25 = *(double *)&LC1;
v26 = *(double *)&LC2;
}
else if ( v26 >= 0.1 )
{
v25 = v26 - 2.5;
}
else
{
v25 = *(double *)&LC3;
v26 = *(double *)&LC4;
}
v71 = v24;
v66 = pow(v25 / (a14 - 2.5), (2.5 - a14) * 2.84 / (a14 - 0.0012));
v24 = v71 + pow((v26 - 0.0012) / (a14 - 0.0012), 2.84) * v66 / 10.0;
v21 = *(double *)&LC6;
if ( &v80 == v22 )
break;
v23 = *(double *)v22;
v22 += 8;
}
}
if ( v24 > v21 )
{
if ( v24 < 0.0 )
{
v28 = sqrt(v24);
v21 = *(double *)&LC6;
goto LABEL_16;
}
goto LABEL_79;
}
v28 = v21;
LABEL_16:
*(_QWORD *)&v29.m128d_f64[0] = LC23;
v30 = a3[1];
v29.m128d_f64[0] = _mm_cmpge_sd(v29, (__m128d)*(unsigned __int64 *)&a13).m128d_f64[0];
*(_QWORD *)&v31 = *(_QWORD *)&v28 & *(_QWORD *)&v29.m128d_f64[0] | ~*(_QWORD *)&v29.m128d_f64[0] & *(_QWORD *)&a13;
a3[9] = v76;
v32 = v76 * v31;
a3[10] = v31;
if ( v30 > v21 && (v33 = a4[1], v33 > v21) )
v34 = v30 / v33;
else
v34 = *(double *)&LC7;
v35 = a3[2];
v36 = a4[2];
if ( v35 > v21 && v36 > v21 )
v37 = v35 / v36;
else
v37 = *(double *)&LC8;
v38 = a3[4];
v39 = a4[4];
if ( v38 > v21 && v39 > v21 )
v40 = v38 / v39;
else
v40 = *(double *)&LC9;
v41 = 0.07000000000000001 * v32;
v68 = 0.014 * v32;
if ( v30 > v21 && a4[1] > v21 )
{
v43 = 0.7 * v32 * v30;
v42 = (0.61 - 12.0 / v34) * v43 / 12.0;
}
else
{
v42 = 0.0;
v43 = 0.0;
}
if ( v36 > v21 && v35 > v21 )
{
v45 = v35 * v41;
v44 = (0.45 - 12.0 / v37) * v45 / 12.0;
}
else
{
v44 = 0.0;
v45 = 0.0;
}
if ( a4[3] > v21 && (v46 = a3[3], v46 > v21) )
{
v48 = v46 * v68;
v47 = (0.71 - v37 / v37) * v48 / v37;
}
else
{
v47 = 0.0;
v48 = 0.0;
}
if ( v39 > v21 && v38 > v21 )
{
v70 = v38 * v68;
v49 = (0.71 - 10.0 / v40) * (v38 * v68) / 10.0;
}
else
{
v49 = 0.0;
v70 = 0.0;
}
if ( a2[10] > v21 && (v50 = a1[8], v50 > v21) )
{
v52 = v50 * v41;
v51 = v50 * v41 * -0.28 / 12.0;
}
else
{
v51 = 0.0;
v52 = 0.0;
}
if ( a2[11] > v21 && (v53 = a1[9], v53 > v21) )
{
v55 = v53 * v68;
v54 = v53 * v68 * -0.2933333333333333 / 10.0;
}
else
{
v54 = 0.0;
v55 = 0.0;
}
if ( a2[12] > v21 && (v56 = a1[10], v56 > v21) )
{
v58 = 0.0014 * v32 * v56;
v57 = v58 * -0.3500000000000001 * 0.125;
}
else
{
v57 = 0.0;
v58 = 0.0;
}
if ( a2[13] > v21 && (v59 = a1[11], v59 > v21) )
{
v61 = 0.0001 * v32 * v59;
v60 = COERCE_DOUBLE(COERCE_UNSIGNED_INT64(0.0001 * v32 * v59) ^ LC41) * 0.125;
if ( v42 > 0.0 )
{
LABEL_49:
v62 = 0.0;
v63 = v42 + 0.0;
if ( v44 > 0.0 )
goto LABEL_50;
goto LABEL_61;
}
}
else
{
v60 = 0.0;
v61 = 0.0;
if ( v42 > 0.0 )
goto LABEL_49;
}
v63 = 0.0;
v62 = 0.0 - v42;
if ( v44 > 0.0 )
{
LABEL_50:
v63 = v63 + v44;
if ( v47 > 0.0 )
goto LABEL_51;
goto LABEL_62;
}
LABEL_61:
v62 = v62 - v44;
if ( v47 > 0.0 )
{
LABEL_51:
v63 = v63 + v47;
if ( v49 > 0.0 )
goto LABEL_52;
goto LABEL_63;
}
LABEL_62:
v62 = v62 - v47;
if ( v49 > 0.0 )
{
LABEL_52:
v63 = v63 + v49;
if ( v51 > 0.0 )
goto LABEL_53;
goto LABEL_64;
}
LABEL_63:
v62 = v62 - v49;
if ( v51 > 0.0 )
{
LABEL_53:
v63 = v63 + v51;
if ( v54 > 0.0 )
goto LABEL_54;
LABEL_65:
v62 = v62 - v54;
if ( v57 > 0.0 )
goto LABEL_55;
LABEL_66:
v62 = v62 - v57;
goto LABEL_56;
}
LABEL_64:
v62 = v62 - v51;
if ( v54 <= 0.0 )
goto LABEL_65;
LABEL_54:
v63 = v63 + v54;
if ( v57 <= 0.0 )
goto LABEL_66;
LABEL_55:
v63 = v63 + v57;
LABEL_56:
a6[11] = v63;
result = 0LL;
a6[10] = v62 - v60;
a5[10] = v43;
a6[13] = v42;
a5[11] = v45;
a6[14] = v44;
a5[12] = v48;
a6[15] = v47;
a5[13] = v70;
a6[16] = v49;
a5[14] = v52;
a6[17] = v51;
a5[15] = v55;
a6[18] = v54;
a5[16] = v58;
a6[19] = v57;
a5[17] = v61;
a6[20] = v60;
a5[18] = v68;
a5[19] = v31;
a5[20] = v76;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(double *a1, double *a2, double *a3, double *a4, double *a5, double *a6, double a7, double a8, double a9, double a10, double a11, __m128d a12, double a13, double a14)
{
__m128d v19; // xmm0
__int64 v20; // xmm1_8
double v21; // xmm5_8
char *v22; // r14
double v23; // xmm2_8
double v24; // xmm4_8
double v25; // xmm0_8
double v26; // xmm2_8
double v27; // xmm0_8
double v28; // xmm4_8
__m128d v29; // xmm1
double v30; // xmm0_8
double v31; // xmm4_8
double v32; // xmm14_8
double v33; // xmm1_8
double v34; // xmm6_8
double v35; // xmm9_8
double v36; // xmm2_8
double v37; // xmm12_8
double v38; // xmm8_8
double v39; // xmm1_8
double v40; // xmm11_8
double v41; // xmm10_8
double v42; // xmm7_8
double v43; // xmm15_8
double v44; // xmm6_8
double v45; // xmm9_8
double v46; // xmm13_8
double v47; // xmm2_8
double v48; // xmm13_8
double v49; // xmm1_8
double v50; // xmm0_8
double v51; // xmm12_8
double v52; // rdi
double v53; // xmm0_8
double v54; // xmm11_8
double v55; // rdx
double v56; // xmm10_8
double v57; // xmm10_8
double v58; // rsi
double v59; // xmm0_8
double v60; // xmm5_8
double v61; // rcx
double v62; // xmm8_8
double v63; // xmm0_8
__int64 result; // rax
double v65; // xmm0_8
double v66; // [rsp+8h] [rbp-F0h]
double v67; // [rsp+8h] [rbp-F0h]
double v68; // [rsp+8h] [rbp-F0h]
unsigned __int64 v69; // [rsp+8h] [rbp-F0h]
double v70; // [rsp+10h] [rbp-E8h]
double v71; // [rsp+18h] [rbp-E0h]
double v72; // [rsp+20h] [rbp-D8h]
double v74; // [rsp+30h] [rbp-C8h]
double v75; // [rsp+50h] [rbp-A8h]
double v76; // [rsp+50h] [rbp-A8h]
double v78; // [rsp+68h] [rbp-90h]
__int64 v79[9]; // [rsp+78h] [rbp-80h] BYREF
char v80; // [rsp+C0h] [rbp-38h] BYREF

v72 = a10;
v79[1] = LC10;
v79[2] = LC11;
v79[0] = 0LL;
v79[3] = LC12;
v79[4] = LC13;
v79[5] = LC14;
v75 = 0.0;
v79[6] = LC15;
v79[7] = LC16;
v79[8] = LC17;
if ( a7 >= -10.0 )
{
v69 = *(_QWORD *)&a12.m128d_f64[0];
v65 = exp((0.0140805406927626 - 1.0 / (a7 + 273.15 - 227.13)) * 308.56);
*(_QWORD *)&a12.m128d_f64[0] = v69;
v75 = v65;
}
*(_QWORD *)&v19.m128d_f64[0] = LC23;
v19.m128d_f64[0] = _mm_cmpge_sd(v19, a12).m128d_f64[0];
v20 = *(_QWORD *)&v75 & *(_QWORD *)&v19.m128d_f64[0];
*(_QWORD *)&v19.m128d_f64[0] = ~*(_QWORD *)&v19.m128d_f64[0] & *(_QWORD *)&a12.m128d_f64[0];
v21 = *(double *)&LC6;
*(_QWORD *)&v76 = *(_QWORD *)&v19.m128d_f64[0] | v20;
if ( a11 <= 0.000000001 )
{
if ( a10 > 0.000000001 )
{
if ( a10 <= 1.0 )
{
v74 = *(double *)&LC24;
if ( a10 <= 0.0012 )
{
v24 = *(double *)&LC5;
LABEL_79:
v28 = sqrt(v24);
goto LABEL_16;
}
v78 = *(double *)&LC25;
v27 = a10 - 2.5;
}
else
{
v27 = *(double *)&LC1;
v74 = *(double *)&LC24;
v72 = *(double *)&LC2;
v78 = *(double *)&LC25;
}
}
else
{
v27 = *(double *)&LC1;
v74 = *(double *)&LC24;
v72 = *(double *)&LC2;
v78 = *(double *)&LC25;
}
v67 = pow(v27 / (a14 - v78), (v78 - a14) * 2.84 / (a14 - v74));
v24 = v67 * pow((v72 - v74) / (a14 - v74), 2.84);
v21 = *(double *)&LC6;
}
else
{
v22 = (char *)v79;
v23 = 0.0;
v24 = 0.0;
while ( 1 )
{
v26 = v23 * a11 + a10;
if ( v26 > 1.0 )
{
v25 = *(double *)&LC1;
v26 = *(double *)&LC2;
}
else if ( v26 >= 0.1 )
{
v25 = v26 - 2.5;
}
else
{
v25 = *(double *)&LC3;
v26 = *(double *)&LC4;
}
v71 = v24;
v66 = pow(v25 / (a14 - 2.5), (2.5 - a14) * 2.84 / (a14 - 0.0012));
v24 = v71 + pow((v26 - 0.0012) / (a14 - 0.0012), 2.84) * v66 / 10.0;
v21 = *(double *)&LC6;
if ( &v80 == v22 )
break;
v23 = *(double *)v22;
v22 += 8;
}
}
if ( v24 > v21 )
{
if ( v24 < 0.0 )
{
v28 = sqrt(v24);
v21 = *(double *)&LC6;
goto LABEL_16;
}
goto LABEL_79;
}
v28 = v21;
LABEL_16:
*(_QWORD *)&v29.m128d_f64[0] = LC23;
v30 = a3[1];
v29.m128d_f64[0] = _mm_cmpge_sd(v29, (__m128d)*(unsigned __int64 *)&a13).m128d_f64[0];
*(_QWORD *)&v31 = *(_QWORD *)&v28 & *(_QWORD *)&v29.m128d_f64[0] | ~*(_QWORD *)&v29.m128d_f64[0] & *(_QWORD *)&a13;
a3[9] = v76;
v32 = v76 * v31;
a3[10] = v31;
if ( v30 > v21 && (v33 = a4[1], v33 > v21) )
v34 = v30 / v33;
else
v34 = *(double *)&LC7;
v35 = a3[2];
v36 = a4[2];
if ( v35 > v21 && v36 > v21 )
v37 = v35 / v36;
else
v37 = *(double *)&LC8;
v38 = a3[4];
v39 = a4[4];
if ( v38 > v21 && v39 > v21 )
v40 = v38 / v39;
else
v40 = *(double *)&LC9;
v41 = 0.07000000000000001 * v32;
v68 = 0.014 * v32;
if ( v30 > v21 && a4[1] > v21 )
{
v43 = 0.7 * v32 * v30;
v42 = (0.61 - 12.0 / v34) * v43 / 12.0;
}
else
{
v42 = 0.0;
v43 = 0.0;
}
if ( v36 > v21 && v35 > v21 )
{
v45 = v35 * v41;
v44 = (0.45 - 12.0 / v37) * v45 / 12.0;
}
else
{
v44 = 0.0;
v45 = 0.0;
}
if ( a4[3] > v21 && (v46 = a3[3], v46 > v21) )
{
v48 = v46 * v68;
v47 = (0.71 - v37 / v37) * v48 / v37;
}
else
{
v47 = 0.0;
v48 = 0.0;
}
if ( v39 > v21 && v38 > v21 )
{
v70 = v38 * v68;
v49 = (0.71 - 10.0 / v40) * (v38 * v68) / 10.0;
}
else
{
v49 = 0.0;
v70 = 0.0;
}
if ( a2[10] > v21 && (v50 = a1[8], v50 > v21) )
{
v52 = v50 * v41;
v51 = v50 * v41 * -0.28 / 12.0;
}
else
{
v51 = 0.0;
v52 = 0.0;
}
if ( a2[11] > v21 && (v53 = a1[9], v53 > v21) )
{
v55 = v53 * v68;
v54 = v53 * v68 * -0.2933333333333333 / 10.0;
}
else
{
v54 = 0.0;
v55 = 0.0;
}
if ( a2[12] > v21 && (v56 = a1[10], v56 > v21) )
{
v58 = 0.0014 * v32 * v56;
v57 = v58 * -0.3500000000000001 * 0.125;
}
else
{
v57 = 0.0;
v58 = 0.0;
}
if ( a2[13] > v21 && (v59 = a1[11], v59 > v21) )
{
v61 = 0.0001 * v32 * v59;
v60 = COERCE_DOUBLE(COERCE_UNSIGNED_INT64(0.0001 * v32 * v59) ^ LC41) * 0.125;
if ( v42 > 0.0 )
{
LABEL_49:
v62 = 0.0;
v63 = v42 + 0.0;
if ( v44 > 0.0 )
goto LABEL_50;
goto LABEL_61;
}
}
else
{
v60 = 0.0;
v61 = 0.0;
if ( v42 > 0.0 )
goto LABEL_49;
}
v63 = 0.0;
v62 = 0.0 - v42;
if ( v44 > 0.0 )
{
LABEL_50:
v63 = v63 + v44;
if ( v47 > 0.0 )
goto LABEL_51;
goto LABEL_62;
}
LABEL_61:
v62 = v62 - v44;
if ( v47 > 0.0 )
{
LABEL_51:
v63 = v63 + v47;
if ( v49 > 0.0 )
goto LABEL_52;
goto LABEL_63;
}
LABEL_62:
v62 = v62 - v47;
if ( v49 > 0.0 )
{
LABEL_52:
v63 = v63 + v49;
if ( v51 > 0.0 )
goto LABEL_53;
goto LABEL_64;
}
LABEL_63:
v62 = v62 - v49;
if ( v51 > 0.0 )
{
LABEL_53:
v63 = v63 + v51;
if ( v54 > 0.0 )
goto LABEL_54;
LABEL_65:
v62 = v62 - v54;
if ( v57 > 0.0 )
goto LABEL_55;
LABEL_66:
v62 = v62 - v57;
goto LABEL_56;
}
LABEL_64:
v62 = v62 - v51;
if ( v54 <= 0.0 )
goto LABEL_65;
LABEL_54:
v63 = v63 + v54;
if ( v57 <= 0.0 )
goto LABEL_66;
LABEL_55:
v63 = v63 + v57;
LABEL_56:
a6[11] = v63;
result = 0LL;
a6[10] = v62 - v60;
a5[10] = v43;
a6[13] = v42;
a5[11] = v45;
a6[14] = v44;
a5[12] = v48;
a6[15] = v47;
a5[13] = v70;
a6[16] = v49;
a5[14] = v52;
a6[17] = v51;
a5[15] = v55;
a6[18] = v54;
a5[16] = v58;
a6[19] = v57;
a5[17] = v61;
a6[20] = v60;
a5[18] = v68;
a5[19] = v31;
a5[20] = v76;
return result;
}

original_code:
int compute_potential_decomp(double tsoil, double maxpsi,
        double minpsi,
        double theta,
        double std,
        double fixed_t_mult,
        double fixed_w_mult,
        double nitrif_parm_smax,
        struct soil_c_object *cs_soil,
        struct soil_n_object *ns_soil,
        struct litter_c_object *cs_litr,
        struct litter_n_object *ns_litr,
        struct cdayflux_patch_struct *cdf,
        struct ndayflux_patch_struct *ndf)
{
 int ok;
 double rate_scalar, t_scalar, w_scalar;
 double a,b,c,d;
 double tk, thetai;
 double rfl1s1, rfl2s2,rfl4s3,rfs1s2,rfs2s3,rfs3s4;
 double kl1_base,kl2_base,kl4_base,ks1_base,ks2_base,ks3_base,ks4_base;
 double kl1,kl2,kl4,ks1,ks2,ks3,ks4;
 double cn_l1,cn_l2,cn_l4,cn_s1,cn_s2,cn_s3,cn_s4;
 double plitr1c_loss, plitr3c_loss, plitr2c_loss, plitr4c_loss;
 double psoil1c_loss, psoil2c_loss, psoil3c_loss, psoil4c_loss;
 double pmnf_l1s1,pmnf_l2s2,pmnf_l3l2, pmnf_l4s3,pmnf_s1s2,pmnf_s2s3,pmnf_s3s4,pmnf_s4;
 double potential_immob,mineralized;
 double weight1, weight2, theta1, theta2;
 int nlimit, i;
 double NORMAL[10]= {0,0,0.253,0.524,0.842,1.283,-0.253,-0.524,-0.842,-1.283};
 ok = 0;
 if (tsoil < -10.0){
  t_scalar = 0.0;
 }
 else{
  tk = tsoil + 273.15;
  t_scalar = exp(308.56*((1.0/71.02)-(1.0/(tk-227.13))));
 }
 if (fixed_t_mult > -999)
  t_scalar = fixed_t_mult;
 a = nitrif_parm_smax;
 b=2.5; c=0.0012; d=2.84;
 w_scalar = 0.0;
 if (std > 0.000000001) {
  for (i=0; i<10; i++) {
   thetai = theta + NORMAL[i]*std;
   thetai = ((1.0) < (thetai) ? (1.0) : (thetai));
   thetai = ((0.1) > (thetai) ? (0.1) : (thetai));
   w_scalar += (pow( ((thetai -b) / (a-b)), d*(b-a)/(a-c))
     * pow( ((thetai-c)/ (a-c)), d)) * 1.0/10;
   }
 }
 else {
  if ((theta <= 0.000000001) || (theta > 1.0))
   theta = 1.0;
  if (theta > c) {
   w_scalar = pow( ((theta -b) / (a-b)), d*(b-a)/(a-c))
   * pow( ((theta-c)/ (a-c)), d);
    }
  else
   w_scalar = 0.000001;
 }
 if (w_scalar > 0.000000001)
  w_scalar = sqrt(w_scalar);
 else
  w_scalar = 0.000000001;
 if (fixed_w_mult > -999)
  w_scalar = fixed_w_mult;
 rate_scalar = w_scalar * t_scalar;
 cs_litr->t_scalar = t_scalar;
 cs_litr->w_scalar = w_scalar;
 if ((cs_litr->litr1c > 0.000000001) && (ns_litr->litr1n > 0.000000001 )) cn_l1 = cs_litr->litr1c/ns_litr->litr1n;
  else cn_l1 = 50;
 if ((cs_litr->litr2c > 0.000000001) && (ns_litr->litr2n > 0.000000001)) cn_l2 = cs_litr->litr2c/ns_litr->litr2n;
  else cn_l2 = 250.0;
 if ((cs_litr->litr4c > 0.000000001) && (ns_litr->litr4n > 0.000000001)) cn_l4 = cs_litr->litr4c/ns_litr->litr4n;
  else cn_l4 = 500.0;
 cn_s1 = 12.0;
 cn_s2 = 12.0;
 cn_s3 = 10.0;
 cn_s4 = 8.0;
 rfl1s1 = 0.39;
 rfl2s2 = 0.55;
 rfl4s3 = 0.29;
 rfs1s2 = 0.28;
 rfs2s3 = 0.46;
 rfs3s4 = 0.55;
 kl1_base = 0.7;
 kl2_base = 0.07;
 kl4_base = 0.014;
 ks1_base = 0.07;
 ks2_base = 0.014;
 ks3_base = 0.0014;
 ks4_base = 0.0001;
 kl1 = kl1_base * rate_scalar;
 kl2 = kl2_base * rate_scalar;
 kl4 = kl4_base * rate_scalar;
 ks1 = ks1_base * rate_scalar;
 ks2 = ks2_base * rate_scalar;
 ks3 = ks3_base * rate_scalar;
 ks4 = ks4_base * rate_scalar;
 plitr1c_loss = plitr2c_loss = plitr3c_loss = plitr4c_loss = 0.0;
 psoil1c_loss = psoil2c_loss = psoil3c_loss = psoil4c_loss = 0.0;
 pmnf_l1s1 = pmnf_l2s2 = pmnf_l3l2 = pmnf_l4s3 = 0.0;
 pmnf_s1s2 = pmnf_s2s3 = pmnf_s3s4 = pmnf_s4 = 0.0;
 if ((cs_litr->litr1c > 0.000000001) && (ns_litr->litr1n > 0.000000001)) {
  plitr1c_loss = kl1 * cs_litr->litr1c;
  pmnf_l1s1 = (plitr1c_loss * (1.0 - rfl1s1 - (cn_s1/cn_l1)))/cn_s1;
 }
 if ((ns_litr->litr2n > 0.000000001) && (cs_litr->litr2c > 0.000000001)) {
  plitr2c_loss = kl2 * cs_litr->litr2c;
  pmnf_l2s2 = (plitr2c_loss * (1.0 - rfl2s2 - (cn_s2/cn_l2)))/cn_s2;
 }
 if ((ns_litr->litr3n > 0.000000001) && (cs_litr->litr3c > 0.000000001)) {
  plitr3c_loss = kl4 * cs_litr->litr3c;
  pmnf_l3l2 = (plitr3c_loss * (1.0 - rfl4s3 - (cn_l2/cn_l2)))/cn_l2;
 }
 if ((ns_litr->litr4n > 0.000000001) && (cs_litr->litr4c > 0.000000001)) {
  plitr4c_loss = kl4 * cs_litr->litr4c;
  pmnf_l4s3 = (plitr4c_loss * (1.0 - rfl4s3 - (cn_s3/cn_l4)))/cn_s3;
 }
 if ((ns_soil->soil1n > 0.000000001) && (cs_soil->soil1c > 0.000000001)) {
  psoil1c_loss = ks1 * cs_soil->soil1c;
  pmnf_s1s2 = (psoil1c_loss * (1.0 - rfs1s2 - (cn_s2/cn_s1)))/cn_s2;
 }
 if ((ns_soil->soil2n > 0.000000001) && (cs_soil->soil2c > 0.000000001)) {
  psoil2c_loss = ks2 * cs_soil->soil2c;
  pmnf_s2s3 = (psoil2c_loss * (1.0 - rfs2s3 - (cn_s3/cn_s2)))/cn_s3;
 }
 if ((ns_soil->soil3n > 0.000000001) && (cs_soil->soil3c > 0.000000001)) {
  psoil3c_loss = ks3 * cs_soil->soil3c;
  pmnf_s3s4 = (psoil3c_loss * (1.0 - rfs3s4 - (cn_s4/cn_s3)))/cn_s4;
 }
 if ((ns_soil->soil4n > 0.000000001) && (cs_soil->soil4c > 0.000000001)) {
  psoil4c_loss = ks4 * cs_soil->soil4c;
  pmnf_s4 = -psoil4c_loss/cn_s4;
 }
 nlimit = 0;
 potential_immob = 0.0;
 mineralized = 0.0;
 if (pmnf_l1s1 > 0.0) potential_immob += pmnf_l1s1;
 else mineralized += -pmnf_l1s1;
 if (pmnf_l2s2 > 0.0) potential_immob += pmnf_l2s2;
 else mineralized += -pmnf_l2s2;
 if (pmnf_l3l2 > 0.0) potential_immob += pmnf_l3l2;
 else mineralized += -pmnf_l3l2;
 if (pmnf_l4s3 > 0.0) potential_immob += pmnf_l4s3;
 else mineralized += -pmnf_l4s3;
 if (pmnf_s1s2 > 0.0) potential_immob += pmnf_s1s2;
 else mineralized += -pmnf_s1s2;
 if (pmnf_s2s3 > 0.0) potential_immob += pmnf_s2s3;
 else mineralized += -pmnf_s2s3;
 if (pmnf_s3s4 > 0.0) potential_immob += pmnf_s3s4;
 else mineralized += -pmnf_s3s4;
 mineralized += -pmnf_s4;
 ndf->mineralized = mineralized;
 ndf->potential_immob = potential_immob;
 cdf->plitr1c_loss = plitr1c_loss;
 ndf->pmnf_l1s1 = pmnf_l1s1;
 cdf->plitr2c_loss = plitr2c_loss;
 ndf->pmnf_l2s2 = pmnf_l2s2;
 cdf->plitr3c_loss = plitr3c_loss;
 ndf->pmnf_l3l2 = pmnf_l3l2;
 cdf->plitr4c_loss = plitr4c_loss;
 ndf->pmnf_l4s3 = pmnf_l4s3;
 cdf->psoil1c_loss = psoil1c_loss;
 ndf->pmnf_s1s2 = pmnf_s1s2;
 cdf->psoil2c_loss = psoil2c_loss;
 ndf->pmnf_s2s3 = pmnf_s2s3;
 cdf->psoil3c_loss = psoil3c_loss;
 ndf->pmnf_s3s4 = pmnf_s3s4;
 cdf->psoil4c_loss = psoil4c_loss;
 ndf->pmnf_s4 = pmnf_s4;
 cdf->kl4 = kl4;
 cdf->decomp_w_scalar = w_scalar;
 cdf->decomp_t_scalar = t_scalar;
 return(ok);
}

canonical_original_code:
int compute_potential_decomp(double tsoil, double maxpsi, double minpsi, double theta, double std, double fixed_t_mult, double fixed_w_mult, double nitrif_parm_smax, struct soil_c_object *cs_soil, struct soil_n_object *ns_soil, struct litter_c_object *cs_litr, struct litter_n_object *ns_litr, struct cdayflux_patch_struct *cdf, struct ndayflux_patch_struct *ndf)
{
 int ok;
 double rate_scalar; double t_scalar; double w_scalar;
 double a; double b; double c; double d;
 double tk; double thetai;
 double rfl1s1; double rfl2s2; double rfl4s3; double rfs1s2; double rfs2s3; double rfs3s4;
 double kl1_base; double kl2_base; double kl4_base; double ks1_base; double ks2_base; double ks3_base; double ks4_base;
 double kl1; double kl2; double kl4; double ks1; double ks2; double ks3; double ks4;
 double cn_l1; double cn_l2; double cn_l4; double cn_s1; double cn_s2; double cn_s3; double cn_s4;
 double plitr1c_loss; double plitr3c_loss; double plitr2c_loss; double plitr4c_loss;
 double psoil1c_loss; double psoil2c_loss; double psoil3c_loss; double psoil4c_loss;
 double pmnf_l1s1; double pmnf_l2s2; double pmnf_l3l2; double pmnf_l4s3; double pmnf_s1s2; double pmnf_s2s3; double pmnf_s3s4; double pmnf_s4;
 double potential_immob; double mineralized;
 double weight1; double weight2; double theta1; double theta2;
 int nlimit; int i;
 double NORMAL[10] = {0,0,0.253,0.524,0.842,1.283,-0.253,-0.524,-0.842,-1.283};
 ok = 0;
 if (tsoil < -10.0){
  t_scalar = 0.0;
 }
 else{
  tk = tsoil + 273.15;
  t_scalar = exp(308.56*((1.0/71.02)-(1.0/(tk-227.13))));
 }
 if (fixed_t_mult > -999)
  t_scalar = fixed_t_mult;
 a = nitrif_parm_smax;
 b=2.5; c=0.0012; d=2.84;
 w_scalar = 0.0;
 if (std > 0.000000001) {
  for (i=0; i<10; i++) {
   thetai = theta + NORMAL[i]*std;
   thetai = ((1.0) < (thetai) ? (1.0) : (thetai));
   thetai = ((0.1) > (thetai) ? (0.1) : (thetai));
   w_scalar += (pow( ((thetai -b) / (a-b)), d*(b-a)/(a-c))
     * pow( ((thetai-c)/ (a-c)), d)) * 1.0/10;
   }
 }
 else {
  if ((theta <= 0.000000001) || (theta > 1.0))
   theta = 1.0;
  if (theta > c) {
   w_scalar = pow( ((theta -b) / (a-b)), d*(b-a)/(a-c))
   * pow( ((theta-c)/ (a-c)), d);
    }
  else
   w_scalar = 0.000001;
 }
 if (w_scalar > 0.000000001)
  w_scalar = sqrt(w_scalar);
 else
  w_scalar = 0.000000001;
 if (fixed_w_mult > -999)
  w_scalar = fixed_w_mult;
 rate_scalar = w_scalar * t_scalar;
 cs_litr->t_scalar = t_scalar;
 cs_litr->w_scalar = w_scalar;
 if ((cs_litr->litr1c > 0.000000001) && (ns_litr->litr1n > 0.000000001 )) cn_l1 = cs_litr->litr1c/ns_litr->litr1n;
  else cn_l1 = 50;
 if ((cs_litr->litr2c > 0.000000001) && (ns_litr->litr2n > 0.000000001)) cn_l2 = cs_litr->litr2c/ns_litr->litr2n;
  else cn_l2 = 250.0;
 if ((cs_litr->litr4c > 0.000000001) && (ns_litr->litr4n > 0.000000001)) cn_l4 = cs_litr->litr4c/ns_litr->litr4n;
  else cn_l4 = 500.0;
 cn_s1 = 12.0;
 cn_s2 = 12.0;
 cn_s3 = 10.0;
 cn_s4 = 8.0;
 rfl1s1 = 0.39;
 rfl2s2 = 0.55;
 rfl4s3 = 0.29;
 rfs1s2 = 0.28;
 rfs2s3 = 0.46;
 rfs3s4 = 0.55;
 kl1_base = 0.7;
 kl2_base = 0.07;
 kl4_base = 0.014;
 ks1_base = 0.07;
 ks2_base = 0.014;
 ks3_base = 0.0014;
 ks4_base = 0.0001;
 kl1 = kl1_base * rate_scalar;
 kl2 = kl2_base * rate_scalar;
 kl4 = kl4_base * rate_scalar;
 ks1 = ks1_base * rate_scalar;
 ks2 = ks2_base * rate_scalar;
 ks3 = ks3_base * rate_scalar;
 ks4 = ks4_base * rate_scalar;
 plitr1c_loss = plitr2c_loss = plitr3c_loss = plitr4c_loss = 0.0;
 psoil1c_loss = psoil2c_loss = psoil3c_loss = psoil4c_loss = 0.0;
 pmnf_l1s1 = pmnf_l2s2 = pmnf_l3l2 = pmnf_l4s3 = 0.0;
 pmnf_s1s2 = pmnf_s2s3 = pmnf_s3s4 = pmnf_s4 = 0.0;
 if ((cs_litr->litr1c > 0.000000001) && (ns_litr->litr1n > 0.000000001)) {
  plitr1c_loss = kl1 * cs_litr->litr1c;
  pmnf_l1s1 = (plitr1c_loss * (1.0 - rfl1s1 - (cn_s1/cn_l1)))/cn_s1;
 }
 if ((ns_litr->litr2n > 0.000000001) && (cs_litr->litr2c > 0.000000001)) {
  plitr2c_loss = kl2 * cs_litr->litr2c;
  pmnf_l2s2 = (plitr2c_loss * (1.0 - rfl2s2 - (cn_s2/cn_l2)))/cn_s2;
 }
 if ((ns_litr->litr3n > 0.000000001) && (cs_litr->litr3c > 0.000000001)) {
  plitr3c_loss = kl4 * cs_litr->litr3c;
  pmnf_l3l2 = (plitr3c_loss * (1.0 - rfl4s3 - (cn_l2/cn_l2)))/cn_l2;
 }
 if ((ns_litr->litr4n > 0.000000001) && (cs_litr->litr4c > 0.000000001)) {
  plitr4c_loss = kl4 * cs_litr->litr4c;
  pmnf_l4s3 = (plitr4c_loss * (1.0 - rfl4s3 - (cn_s3/cn_l4)))/cn_s3;
 }
 if ((ns_soil->soil1n > 0.000000001) && (cs_soil->soil1c > 0.000000001)) {
  psoil1c_loss = ks1 * cs_soil->soil1c;
  pmnf_s1s2 = (psoil1c_loss * (1.0 - rfs1s2 - (cn_s2/cn_s1)))/cn_s2;
 }
 if ((ns_soil->soil2n > 0.000000001) && (cs_soil->soil2c > 0.000000001)) {
  psoil2c_loss = ks2 * cs_soil->soil2c;
  pmnf_s2s3 = (psoil2c_loss * (1.0 - rfs2s3 - (cn_s3/cn_s2)))/cn_s3;
 }
 if ((ns_soil->soil3n > 0.000000001) && (cs_soil->soil3c > 0.000000001)) {
  psoil3c_loss = ks3 * cs_soil->soil3c;
  pmnf_s3s4 = (psoil3c_loss * (1.0 - rfs3s4 - (cn_s4/cn_s3)))/cn_s4;
 }
 if ((ns_soil->soil4n > 0.000000001) && (cs_soil->soil4c > 0.000000001)) {
  psoil4c_loss = ks4 * cs_soil->soil4c;
  pmnf_s4 = -psoil4c_loss/cn_s4;
 }
 nlimit = 0;
 potential_immob = 0.0;
 mineralized = 0.0;
 if (pmnf_l1s1 > 0.0) potential_immob += pmnf_l1s1;
 else mineralized += -pmnf_l1s1;
 if (pmnf_l2s2 > 0.0) potential_immob += pmnf_l2s2;
 else mineralized += -pmnf_l2s2;
 if (pmnf_l3l2 > 0.0) potential_immob += pmnf_l3l2;
 else mineralized += -pmnf_l3l2;
 if (pmnf_l4s3 > 0.0) potential_immob += pmnf_l4s3;
 else mineralized += -pmnf_l4s3;
 if (pmnf_s1s2 > 0.0) potential_immob += pmnf_s1s2;
 else mineralized += -pmnf_s1s2;
 if (pmnf_s2s3 > 0.0) potential_immob += pmnf_s2s3;
 else mineralized += -pmnf_s2s3;
 if (pmnf_s3s4 > 0.0) potential_immob += pmnf_s3s4;
 else mineralized += -pmnf_s3s4;
 mineralized += -pmnf_s4;
 ndf->mineralized = mineralized;
 ndf->potential_immob = potential_immob;
 cdf->plitr1c_loss = plitr1c_loss;
 ndf->pmnf_l1s1 = pmnf_l1s1;
 cdf->plitr2c_loss = plitr2c_loss;
 ndf->pmnf_l2s2 = pmnf_l2s2;
 cdf->plitr3c_loss = plitr3c_loss;
 ndf->pmnf_l3l2 = pmnf_l3l2;
 cdf->plitr4c_loss = plitr4c_loss;
 ndf->pmnf_l4s3 = pmnf_l4s3;
 cdf->psoil1c_loss = psoil1c_loss;
 ndf->pmnf_s1s2 = pmnf_s1s2;
 cdf->psoil2c_loss = psoil2c_loss;
 ndf->pmnf_s2s3 = pmnf_s2s3;
 cdf->psoil3c_loss = psoil3c_loss;
 ndf->pmnf_s3s4 = pmnf_s3s4;
 cdf->psoil4c_loss = psoil4c_loss;
 ndf->pmnf_s4 = pmnf_s4;
 cdf->kl4 = kl4;
 cdf->decomp_w_scalar = w_scalar;
 cdf->decomp_t_scalar = t_scalar;
 return(ok);
}

variable_types: tsoil double

variable_types: maxpsi double

variable_types: minpsi double

variable_types: theta double

variable_types: std double

variable_types: struct soil_c_object { double frootc; double DOC; double DOC_Qin; double DOC_Qout; double DOC_Qin_total; double DOC_Qout_total; double totalc; double soil_cpool; double soil1c; double soil2c; double soil3c; double soil4c; double soil1c_hr_snk; double soil2c_hr_snk; double soil3c_hr_snk; double soil4c_hr_snk; } *

variable_types: struct soil_n_object { double nlimit; double fract_potential_immob; double fract_potential_uptake; double totaln; double soil_npool; double DON; double DON_Qin; double DON_Qout; double DON_Qin_total; double DON_Qout_total; double soil1n; double soil2n; double soil3n; double soil4n; double sminn; double nitrate; double NO3_Qin_total; double NO3_Qout_total; double NO3_Qin; double NO3_Qout; double NH4_Qin; double NH4_Qout; double NH4_Qin_total; double NH4_Qout_total; double leach; double nfix_src; double ndep_src; double nleached_snk; double nvolatilized_snk; } *

variable_types: struct litter_c_object { double totalc; double litr1c; double litr2c; double litr3c; double litr4c; double litr1c_hr_snk; double litr2c_hr_snk; double litr4c_hr_snk; double fire_snk; double t_scalar; double w_scalar; } *

variable_types: struct litter_n_object { double totaln; double litr1n; double litr2n; double litr3n; double litr4n; double fire_snk; } *

variable_types: struct cdayflux_patch_struct { double do_litr1c_loss; double do_litr2c_loss; double do_litr3c_loss; double do_litr4c_loss; double do_soil1c_loss; double do_soil2c_loss; double do_soil3c_loss; double do_soil4c_loss; double total_DOC_loss; double DOC_to_gw; double plitr1c_loss; double plitr2c_loss; double plitr3c_loss; double plitr4c_loss; double psoil1c_loss; double psoil2c_loss; double psoil3c_loss; double psoil4c_loss; double kl4; double decomp_w_scalar; double decomp_t_scalar; double leafc_to_litr1c; double leafc_to_litr2c; double leafc_to_litr3c; double leafc_to_litr4c; double frootc_to_litr1c; double frootc_to_litr2c; double frootc_to_litr3c; double frootc_to_litr4c; double litr1c_to_soil1c; double litr2c_to_soil2c; double litr3c_to_litr2c; double litr4c_to_soil3c; double soil1c_to_soil2c; double soil2c_to_soil3c; double soil3c_to_soil4c; double cwdc_to_litr2c; double cwdc_to_litr3c; double cwdc_to_litr4c; double litr1c_hr; double litr2c_hr; double litr3c_hr; double litr4c_hr; double soil1c_hr; double soil2c_hr; double soil3c_hr; double soil4c_hr; double m_leafc_to_litr1c; double m_leafc_to_litr2c; double m_leafc_to_litr3c; double m_leafc_to_litr4c; double m_frootc_to_litr1c; double m_frootc_to_litr2c; double m_frootc_to_litr3c; double m_frootc_to_litr4c; double m_leafc_store_to_litr1c; double m_frootc_store_to_litr1c; double m_livestemc_store_to_litr1c; double m_deadstemc_store_to_litr1c; double m_livecrootc_store_to_litr1c; double m_deadcrootc_store_to_litr1c; double m_leafc_transfer_to_litr1c; double m_frootc_transfer_to_litr1c; double m_livestemc_transfer_to_litr1c; double m_deadstemc_transfer_to_litr1c; double m_livecrootc_transfer_to_litr1c; double m_deadcrootc_transfer_to_litr1c; double m_gresp_store_to_litr1c; double m_gresp_transfer_to_litr1c; double m_litr1c_to_atmos; double m_litr2c_to_atmos; double m_litr3c_to_atmos; double m_litr4c_to_atmos; double m_soil1c_to_atmos; double m_soil2c_to_atmos; double m_soil3c_to_atmos; double m_soil4c_to_atmos; } *

variable_types: struct ndayflux_patch_struct { double do_litr1n_loss; double do_litr2n_loss; double do_litr3n_loss; double do_litr4n_loss; double do_soil1n_loss; double do_soil2n_loss; double do_soil3n_loss; double do_soil4n_loss; double total_DON_loss; double DON_to_gw; double mineralized; double potential_immob; double net_mineralized; double pmnf_l1s1; double pmnf_l2s2; double pmnf_l3l2; double pmnf_l4s3; double pmnf_s1s2; double pmnf_s2s3; double pmnf_s3s4; double pmnf_s4; double leafn_to_litr1n; double leafn_to_litr2n; double leafn_to_litr3n; double leafn_to_litr4n; double frootn_to_litr1n; double frootn_to_litr2n; double frootn_to_litr3n; double frootn_to_litr4n; double litr1n_to_soil1n; double litr2n_to_soil2n; double litr4n_to_soil3n; double litr3n_to_litr2n; double soil1n_to_soil2n; double soil2n_to_soil3n; double soil3n_to_soil4n; double cwdn_to_litr2n; double cwdn_to_litr3n; double cwdn_to_litr4n; double plant_potential_ndemand; double plant_avail_uptake; double sminn_to_soil1n_l1; double sminn_to_soil2n_l2; double sminn_to_soil2n_l3; double sminn_to_soil3n_l4; double sminn_to_soil2n_s1; double sminn_to_soil3n_s2; double sminn_to_soil4n_s3; double sminn_to_npool; double soil4n_to_sminn; double sminn_to_nitrate; double m_leafn_to_litr1n; double m_leafn_to_litr2n; double m_leafn_to_litr3n; double m_leafn_to_litr4n; double m_frootn_to_litr1n; double m_frootn_to_litr2n; double m_frootn_to_litr3n; double m_frootn_to_litr4n; double m_livestemn_to_litr1n; double m_livecrootn_to_litr1n; double m_leafn_store_to_litr1n; double m_frootn_store_to_litr1n; double m_livestemn_store_to_litr1n; double m_deadstemn_store_to_litr1n; double m_livecrootn_store_to_litr1n; double m_deadcrootn_store_to_litr1n; double m_leafn_transfer_to_litr1n; double m_frootn_transfer_to_litr1n; double m_livestemn_transfer_to_litr1n; double m_deadstemn_transfer_to_litr1n; double m_livecrootn_transfer_to_litr1n; double m_deadcrootn_transfer_to_litr1n; double m_retransn_to_litr1n; double sminn_to_nvol; double denitrif; double ndep_to_sminn; double nfix_to_sminn; double N_to_gw; double m_litr1n_to_atmos; double m_litr2n_to_atmos; double m_litr3n_to_atmos; double m_litr4n_to_atmos; double m_soil1n_to_atmos; double m_soil2n_to_atmos; double m_soil3n_to_atmos; double m_soil4n_to_atmos; } *

variable_types: ok int

variable_types: a double

variable_types: b double

variable_types: c double

variable_types: d double

variable_types: tk double

variable_types: thetai double

variable_types: mineralized double

variable_types: nlimit int

variable_types:
NORMAL
double [10]

return_type: int


decompiled_code:
__int64 __fastcall find_stream(__int64 a1, int a2, _DWORD *a3)
{
__int64 v4; // rbx
__int64 result; // rax
__int64 v6; // rbp
int v7; // er12
bool v8; // dl

v4 = a1 + 160LL * a2;
result = *(unsigned int *)(v4 + 20);
if ( (_DWORD)result == 1 )
{
*a3 = a2;
}
else if ( *(int *)(v4 + 96) <= 0 )
{
result = 0LL;
}
else
{
v6 = *(_QWORD *)(v4 + 128);
v7 = 1;
if ( *(_DWORD *)(v6 + 16) == 1 )
goto LABEL_7;
LABEL_4:
result = find_stream(a1, *(unsigned int *)(v6 + 12), a3);
v8 = (_DWORD)result == 0;
if ( *(_DWORD *)(v4 + 96) >= ++v7 )
{
do
{
if ( !v8 )
break;
v6 = *(_QWORD *)(v6 + 48);
if ( *(_DWORD *)(v6 + 16) != 1 )
goto LABEL_4;
LABEL_7:
v8 = 1;
result = 0LL;
++v7;
}
while ( *(_DWORD *)(v4 + 96) >= v7 );
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int a2, _DWORD *a3)
{
__int64 v4; // rbx
__int64 result; // rax
__int64 v6; // rbp
int v7; // er12
bool v8; // dl

v4 = a1 + 160LL * a2;
result = *(unsigned int *)(v4 + 20);
if ( (_DWORD)result == 1 )
{
*a3 = a2;
}
else if ( *(int *)(v4 + 96) <= 0 )
{
result = 0LL;
}
else
{
v6 = *(_QWORD *)(v4 + 128);
v7 = 1;
if ( *(_DWORD *)(v6 + 16) == 1 )
goto LABEL_7;
LABEL_4:
result = func0(a1, *(unsigned int *)(v6 + 12), a3);
v8 = (_DWORD)result == 0;
if ( *(_DWORD *)(v4 + 96) >= ++v7 )
{
do
{
if ( !v8 )
break;
v6 = *(_QWORD *)(v6 + 48);
if ( *(_DWORD *)(v6 + 16) != 1 )
goto LABEL_4;
LABEL_7:
v8 = 1;
result = 0LL;
++v7;
}
while ( *(_DWORD *)(v4 + 96) >= v7 );
}
}
return result;
}

original_code:
int find_stream(struct flow_struct *flow_table, int curr, int *str_inx) {
 struct adj_struct *aptr;
 int i, inx, fnd;
 fnd = 0;
 aptr = flow_table[curr].adj_list;
 if (flow_table[curr].land != 1) {
  i = 1;
  while ((i <= flow_table[curr].num_adjacent) && (fnd == 0)) {
   inx = aptr->inx;
   if (aptr->landtype != 1)
    fnd = (int) find_stream(flow_table, inx, str_inx);
   aptr = aptr->next;
   i += 1;
  }
 }
 else {
  fnd = 1;
  *str_inx = curr;
 }
 return (fnd);
}

canonical_original_code:
int find_stream(struct flow_struct *flow_table, int curr, int *str_inx) {
 struct adj_struct *aptr;
 int i; int inx; int fnd;
 fnd = 0;
 aptr = flow_table[curr].adj_list;
 if (flow_table[curr].land != 1) {
  i = 1;
  while ((i <= flow_table[curr].num_adjacent) && (fnd == 0)) {
   inx = aptr->inx;
   if (aptr->landtype != 1)
    fnd = (int) find_stream(flow_table, inx, str_inx);
   aptr = aptr->next;
   i += 1;
  }
 }
 else {
  fnd = 1;
  *str_inx = curr;
 }
 return (fnd);
}

variable_types: struct flow_struct { int patchID; int hillID; int zoneID; int ID_order; int area; int land; int sewer; float x; float y; float z; float flna; float acc_area; float total_str_gamma; float total_gamma; float gamma_neigh; float total_perimeter; float road_dist; float slope; float internal_slope; float max_slope; double path_length; int num_str; int inflow_cnt; int num_adjacent; int num_dsa; int stream_inx; float stream_gamma; struct ID_struct { int patch; int hill; int zone; } stream_ID; struct adj_struct { int patchID; int hillID; int zoneID; int inx; int landtype; int sewertype; double perimeter; float slope; float gamma; float z; struct adj_struct *next; } *adj_list; struct adj_struct *adj_ptr; struct adj_struct *adj_str_ptr; struct adj_struct *adj_str_list; } *

variable_types: curr int

variable_types: i int

variable_types: inx int

variable_types: fnd int

user_defined_types: struct flow_struct { int patchID; int hillID; int zoneID; int ID_order; int area; int land; int sewer; float x; float y; float z; float flna; float acc_area; float total_str_gamma; float total_gamma; float gamma_neigh; float total_perimeter; float road_dist; float slope; float internal_slope; float max_slope; double path_length; int num_str; int inflow_cnt; int num_adjacent; int num_dsa; int stream_inx; float stream_gamma; struct ID_struct stream_ID; struct adj_struct *adj_list; struct adj_struct *adj_ptr; struct adj_struct *adj_str_ptr; struct adj_struct *adj_str_list; }


decompiled_code:
double __fastcall compute_radiative_fluxes(int a1, double *a2, double *a3, double a4, double a5, double a6)
{
double v7; // xmm6_8
double v8; // xmm0_8
double v9; // xmm2_8
double v10; // xmm3_8
double result; // xmm0_8
double v12; // xmm0_8
double v13; // xmm2_8
double v14; // xmm3_8

v7 = *a2;
if ( a1 > 2 )
{
printf("%8.1f %8.1f %8.1f %8.1f ", v7, a4, a5, a6);
*a3 = a5 * *a2;
v12 = exp(COERCE_DOUBLE(*(_QWORD *)&a4 ^ LC0));
v13 = a6 * *a2 * (1.0 - v12);
v14 = *a2 - *a3 - v13;
*a2 = v14;
printf("%8.1f %8.1f %8.1f %8.1f ", v12, *a3, v13, v14);
result = v13;
}
else
{
*a3 = a5 * v7;
v8 = exp(COERCE_DOUBLE(*(_QWORD *)&a4 ^ LC0));
v9 = a6 * *a2 * (1.0 - v8);
v10 = *a2 - *a3 - v9;
*a2 = v10;
if ( a1 == -5 )
printf("\nRADFLUX: trans=%lf fluxrefl=%1f fluxabs=%lf fluxtrans=%lf ", v8, *a3, v9, v10);
result = v9;
}
return result;
}

canonical_decompiled_code:
double __fastcall func0(int a1, double *a2, double *a3, double a4, double a5, double a6)
{
double v7; // xmm6_8
double v8; // xmm0_8
double v9; // xmm2_8
double v10; // xmm3_8
double result; // xmm0_8
double v12; // xmm0_8
double v13; // xmm2_8
double v14; // xmm3_8

v7 = *a2;
if ( a1 > 2 )
{
printf("%8.1f %8.1f %8.1f %8.1f ", v7, a4, a5, a6);
*a3 = a5 * *a2;
v12 = exp(COERCE_DOUBLE(*(_QWORD *)&a4 ^ LC0));
v13 = a6 * *a2 * (1.0 - v12);
v14 = *a2 - *a3 - v13;
*a2 = v14;
printf("%8.1f %8.1f %8.1f %8.1f ", v12, *a3, v13, v14);
result = v13;
}
else
{
*a3 = a5 * v7;
v8 = exp(COERCE_DOUBLE(*(_QWORD *)&a4 ^ LC0));
v9 = a6 * *a2 * (1.0 - v8);
v10 = *a2 - *a3 - v9;
*a2 = v10;
if ( a1 == -5 )
printf("\nRADFLUX: trans=%lf fluxrefl=%1f fluxabs=%lf fluxtrans=%lf ", v8, *a3, v9, v10);
result = v9;
}
return result;
}

original_code:
double compute_radiative_fluxes(int verbose_flag,
         double *flux_down_ptr,
         double *flux_up_ptr,
         double total_extinction,
         double reflectance,
         double absorptance)
{
 double flux_reflected;
 double flux_transmitted;
 double flux_absorbed;
 double opaque_transmittance;
 if( verbose_flag > 2)
  printf("%8.1f %8.1f %8.1f %8.1f ", *flux_down_ptr, total_extinction,
  reflectance, absorptance);
 *flux_up_ptr = *flux_down_ptr * reflectance ;
 opaque_transmittance = exp(-1.0 * total_extinction);
 flux_absorbed = *flux_down_ptr * absorptance * (1.0 - opaque_transmittance );
 flux_transmitted = *flux_down_ptr - *flux_up_ptr - flux_absorbed ;
 *flux_down_ptr = flux_transmitted;
 if( verbose_flag > 2)
  printf("%8.1f %8.1f %8.1f %8.1f ", opaque_transmittance, *flux_up_ptr,
  flux_absorbed,flux_transmitted);
 if ( verbose_flag == -5 ){
  printf("\nRADFLUX: trans=%lf fluxrefl=%1f fluxabs=%lf fluxtrans=%lf ", opaque_transmittance, *flux_up_ptr,
     flux_absorbed,flux_transmitted);
 }
 return( flux_absorbed );
}

variable_types: reflectance double

variable_types: absorptance double

return_type: double


original_code:
int update_denitrif(
     struct soil_c_object *cs_soil,
     struct soil_n_object *ns_soil,
     struct cdayflux_patch_struct *cdf,
     struct ndayflux_patch_struct *ndf,
     struct soil_class soil_type,
     double theta,
     double std)
{
 int ok,i;
 double denitrify;
 double a, b, c, d;
 double water_scalar, thetai, water_scalari;
 double fnitrate, fCO2;
 double hr, nitrate_ratio;
 double NORMAL[10]= {0,0,0.253,0.524,0.842,1.283,-0.253,-0.524,-0.842,-1.283};
 ok = 1;
 if ((theta <= 0.000000001) || (theta > 1.0)) theta = 1.0;
 if ((ns_soil->nitrate > 0.000000001)) {
  if (soil_type.sand > 0.5) {
   a = 1.56; b=12.0; c=16.0; d=2.01;
  }
  else if (soil_type.clay > 0.5) {
   a = 60.0; b=18.0; c=22.0; d=1.06;
  }
  else {
   a=4.82; b=14.0; c=16.0; d=1.39;
  }
  water_scalar = 0.0;
  if (std > 0) {
   for (i =1; i< 10; i++) {
    thetai = theta + std*NORMAL[i];
    thetai = ((1.0) < (thetai) ? (1.0) : (thetai));
    thetai = ((0.0) > (thetai) ? (0.0) : (thetai));
    if (thetai > 0.000000001)
    water_scalari = ((1.0) < (a / pow(b, (c / pow(b, (d*thetai) )) )) ? (1.0) : (a / pow(b, (c / pow(b, (d*thetai) )) )));
    water_scalar += 1.0/10 * water_scalari;
    }
   }
  else
    water_scalar = ((1.0) < (a / pow(b, (c / pow(b, (d*theta) )) )) ? (1.0) : (a / pow(b, (c / pow(b, (d*theta) )) )));
  nitrate_ratio = (ns_soil->nitrate)
   / (cs_soil->totalc + ns_soil->totaln) * 1e6;
  fnitrate = atan(3.14159265359*0.002*(nitrate_ratio - 180)) * 0.004 / 3.14159265359 + 0.0011;
  hr = (cdf->soil1c_hr + cdf->soil2c_hr + cdf->soil3c_hr + cdf->soil4c_hr);
  if (hr > 0.000000001)
   fCO2 = 0.0024 / (1+ 200.0/exp(0.35*hr*10000.0)) - 0.00001;
  else
   fCO2 = 0.0;
  denitrify = ((fCO2) < (fnitrate) ? (fCO2) : (fnitrate)) * water_scalar;
 }
 else
  denitrify = 0.0;
 denitrify = ((denitrify) < (ns_soil->nitrate) ? (denitrify) : (ns_soil->nitrate));
 denitrify = ((0.0) > (denitrify) ? (0.0) : (denitrify));
 ns_soil->nvolatilized_snk += denitrify;
 ndf->sminn_to_nvol = denitrify;
 ns_soil->nitrate -= denitrify;
 ndf->denitrif = denitrify;
 ok = 0;
 return(ok);
}

canonical_original_code:
int update_denitrif(struct soil_c_object *cs_soil, struct soil_n_object *ns_soil, struct cdayflux_patch_struct *cdf, struct ndayflux_patch_struct *ndf, struct soil_class soil_type, double theta, double std)
{
 int ok; int i;
 double denitrify;
 double a; double b; double c; double d;
 double water_scalar; double thetai; double water_scalari;
 double fnitrate; double fCO2;
 double hr; double nitrate_ratio;
 double NORMAL[10] = {0,0,0.253,0.524,0.842,1.283,-0.253,-0.524,-0.842,-1.283};
 ok = 1;
 if ((theta <= 0.000000001) || (theta > 1.0)) theta = 1.0;
 if ((ns_soil->nitrate > 0.000000001)) {
  if (soil_type.sand > 0.5) {
   a = 1.56; b=12.0; c=16.0; d=2.01;
  }
  else if (soil_type.clay > 0.5) {
   a = 60.0; b=18.0; c=22.0; d=1.06;
  }
  else {
   a=4.82; b=14.0; c=16.0; d=1.39;
  }
  water_scalar = 0.0;
  if (std > 0) {
   for (i =1; i< 10; i++) {
    thetai = theta + std*NORMAL[i];
    thetai = ((1.0) < (thetai) ? (1.0) : (thetai));
    thetai = ((0.0) > (thetai) ? (0.0) : (thetai));
    if (thetai > 0.000000001)
    water_scalari = ((1.0) < (a / pow(b, (c / pow(b, (d*thetai) )) )) ? (1.0) : (a / pow(b, (c / pow(b, (d*thetai) )) )));
    water_scalar += 1.0/10 * water_scalari;
    }
   }
  else
    water_scalar = ((1.0) < (a / pow(b, (c / pow(b, (d*theta) )) )) ? (1.0) : (a / pow(b, (c / pow(b, (d*theta) )) )));
  nitrate_ratio = (ns_soil->nitrate)
   / (cs_soil->totalc + ns_soil->totaln) * 1e6;
  fnitrate = atan(3.14159265359*0.002*(nitrate_ratio - 180)) * 0.004 / 3.14159265359 + 0.0011;
  hr = (cdf->soil1c_hr + cdf->soil2c_hr + cdf->soil3c_hr + cdf->soil4c_hr);
  if (hr > 0.000000001)
   fCO2 = 0.0024 / (1+ 200.0/exp(0.35*hr*10000.0)) - 0.00001;
  else
   fCO2 = 0.0;
  denitrify = ((fCO2) < (fnitrate) ? (fCO2) : (fnitrate)) * water_scalar;
 }
 else
  denitrify = 0.0;
 denitrify = ((denitrify) < (ns_soil->nitrate) ? (denitrify) : (ns_soil->nitrate));
 denitrify = ((0.0) > (denitrify) ? (0.0) : (denitrify));
 ns_soil->nvolatilized_snk += denitrify;
 ndf->sminn_to_nvol = denitrify;
 ns_soil->nitrate -= denitrify;
 ndf->denitrif = denitrify;
 ok = 0;
 return(ok);
}

variable_types: struct soil_c_object { double frootc; double DOC; double DOC_Qin; double DOC_Qout; double DOC_Qin_total; double DOC_Qout_total; double totalc; double soil_cpool; double soil1c; double soil2c; double soil3c; double soil4c; double soil1c_hr_snk; double soil2c_hr_snk; double soil3c_hr_snk; double soil4c_hr_snk; } *

variable_types: struct soil_n_object { double nlimit; double fract_potential_immob; double fract_potential_uptake; double totaln; double soil_npool; double DON; double DON_Qin; double DON_Qout; double DON_Qin_total; double DON_Qout_total; double soil1n; double soil2n; double soil3n; double soil4n; double sminn; double nitrate; double NO3_Qin_total; double NO3_Qout_total; double NO3_Qin; double NO3_Qout; double NH4_Qin; double NH4_Qout; double NH4_Qin_total; double NH4_Qout_total; double leach; double nfix_src; double ndep_src; double nleached_snk; double nvolatilized_snk; } *

variable_types: struct cdayflux_patch_struct { double do_litr1c_loss; double do_litr2c_loss; double do_litr3c_loss; double do_litr4c_loss; double do_soil1c_loss; double do_soil2c_loss; double do_soil3c_loss; double do_soil4c_loss; double total_DOC_loss; double DOC_to_gw; double plitr1c_loss; double plitr2c_loss; double plitr3c_loss; double plitr4c_loss; double psoil1c_loss; double psoil2c_loss; double psoil3c_loss; double psoil4c_loss; double kl4; double decomp_w_scalar; double decomp_t_scalar; double leafc_to_litr1c; double leafc_to_litr2c; double leafc_to_litr3c; double leafc_to_litr4c; double frootc_to_litr1c; double frootc_to_litr2c; double frootc_to_litr3c; double frootc_to_litr4c; double litr1c_to_soil1c; double litr2c_to_soil2c; double litr3c_to_litr2c; double litr4c_to_soil3c; double soil1c_to_soil2c; double soil2c_to_soil3c; double soil3c_to_soil4c; double cwdc_to_litr2c; double cwdc_to_litr3c; double cwdc_to_litr4c; double litr1c_hr; double litr2c_hr; double litr3c_hr; double litr4c_hr; double soil1c_hr; double soil2c_hr; double soil3c_hr; double soil4c_hr; double m_leafc_to_litr1c; double m_leafc_to_litr2c; double m_leafc_to_litr3c; double m_leafc_to_litr4c; double m_frootc_to_litr1c; double m_frootc_to_litr2c; double m_frootc_to_litr3c; double m_frootc_to_litr4c; double m_leafc_store_to_litr1c; double m_frootc_store_to_litr1c; double m_livestemc_store_to_litr1c; double m_deadstemc_store_to_litr1c; double m_livecrootc_store_to_litr1c; double m_deadcrootc_store_to_litr1c; double m_leafc_transfer_to_litr1c; double m_frootc_transfer_to_litr1c; double m_livestemc_transfer_to_litr1c; double m_deadstemc_transfer_to_litr1c; double m_livecrootc_transfer_to_litr1c; double m_deadcrootc_transfer_to_litr1c; double m_gresp_store_to_litr1c; double m_gresp_transfer_to_litr1c; double m_litr1c_to_atmos; double m_litr2c_to_atmos; double m_litr3c_to_atmos; double m_litr4c_to_atmos; double m_soil1c_to_atmos; double m_soil2c_to_atmos; double m_soil3c_to_atmos; double m_soil4c_to_atmos; } *

variable_types: struct ndayflux_patch_struct { double do_litr1n_loss; double do_litr2n_loss; double do_litr3n_loss; double do_litr4n_loss; double do_soil1n_loss; double do_soil2n_loss; double do_soil3n_loss; double do_soil4n_loss; double total_DON_loss; double DON_to_gw; double mineralized; double potential_immob; double net_mineralized; double pmnf_l1s1; double pmnf_l2s2; double pmnf_l3l2; double pmnf_l4s3; double pmnf_s1s2; double pmnf_s2s3; double pmnf_s3s4; double pmnf_s4; double leafn_to_litr1n; double leafn_to_litr2n; double leafn_to_litr3n; double leafn_to_litr4n; double frootn_to_litr1n; double frootn_to_litr2n; double frootn_to_litr3n; double frootn_to_litr4n; double litr1n_to_soil1n; double litr2n_to_soil2n; double litr4n_to_soil3n; double litr3n_to_litr2n; double soil1n_to_soil2n; double soil2n_to_soil3n; double soil3n_to_soil4n; double cwdn_to_litr2n; double cwdn_to_litr3n; double cwdn_to_litr4n; double plant_potential_ndemand; double plant_avail_uptake; double sminn_to_soil1n_l1; double sminn_to_soil2n_l2; double sminn_to_soil2n_l3; double sminn_to_soil3n_l4; double sminn_to_soil2n_s1; double sminn_to_soil3n_s2; double sminn_to_soil4n_s3; double sminn_to_npool; double soil4n_to_sminn; double sminn_to_nitrate; double m_leafn_to_litr1n; double m_leafn_to_litr2n; double m_leafn_to_litr3n; double m_leafn_to_litr4n; double m_frootn_to_litr1n; double m_frootn_to_litr2n; double m_frootn_to_litr3n; double m_frootn_to_litr4n; double m_livestemn_to_litr1n; double m_livecrootn_to_litr1n; double m_leafn_store_to_litr1n; double m_frootn_store_to_litr1n; double m_livestemn_store_to_litr1n; double m_deadstemn_store_to_litr1n; double m_livecrootn_store_to_litr1n; double m_deadcrootn_store_to_litr1n; double m_leafn_transfer_to_litr1n; double m_frootn_transfer_to_litr1n; double m_livestemn_transfer_to_litr1n; double m_deadstemn_transfer_to_litr1n; double m_livecrootn_transfer_to_litr1n; double m_deadcrootn_transfer_to_litr1n; double m_retransn_to_litr1n; double sminn_to_nvol; double denitrif; double ndep_to_sminn; double nfix_to_sminn; double N_to_gw; double m_litr1n_to_atmos; double m_litr2n_to_atmos; double m_litr3n_to_atmos; double m_litr4n_to_atmos; double m_soil1n_to_atmos; double m_soil2n_to_atmos; double m_soil3n_to_atmos; double m_soil4n_to_atmos; } *

variable_types: struct soil_class { double sand; double silt; double clay; }

variable_types: theta double

variable_types: std double

variable_types: ok int

variable_types: denitrify double

variable_types: fnitrate double

variable_types: hr double


decompiled_code:
double __fastcall compute_delta_water(double a1, double a2, double a3, double a4, double a5)
{
double v6; // xmm7_8
double v7; // xmm3_8
double v8; // xmm4_8
double v10; // [rsp+8h] [rbp-28h]

v6 = fmin(a4, 0.0);
if ( a5 < 0.0 )
v6 = v6 - a5;
v7 = fmax(a4, 0.0);
v8 = fmin(fmax(a5, 0.0), a3);
if ( a2 == 0.0 || a2 >= 999.0 )
return (v7 - v8) * a1 + v6;
v10 = exp(COERCE_DOUBLE(*(_QWORD *)&v8 ^ LC2) / a2);
return (v10 - exp(COERCE_DOUBLE(*(_QWORD *)&v7 ^ LC2) / a2)) * (a2 * a1) + v6;
}

canonical_decompiled_code:
double __fastcall func0(double a1, double a2, double a3, double a4, double a5)
{
double v6; // xmm7_8
double v7; // xmm3_8
double v8; // xmm4_8
double v10; // [rsp+8h] [rbp-28h]

v6 = fmin(a4, 0.0);
if ( a5 < 0.0 )
v6 = v6 - a5;
v7 = fmax(a4, 0.0);
v8 = fmin(fmax(a5, 0.0), a3);
if ( a2 == 0.0 || a2 >= 999.0 )
return (v7 - v8) * a1 + v6;
v10 = exp(COERCE_DOUBLE(*(_QWORD *)&v8 ^ LC2) / a2);
return (v10 - exp(COERCE_DOUBLE(*(_QWORD *)&v7 ^ LC2) / a2)) * (a2 * a1) + v6;
}

original_code:
double compute_delta_water(
       int verbose_flag,
       double n_0,
       double p,
       double soil_depth,
       double z_initial,
       double z_final)
{
 double delta_water;
 delta_water = ((z_initial) < (0) ? (z_initial) : (0)) - ((z_final) < (0) ? (z_final) : (0));
 z_final = ((((z_final) > (0) ? (z_final) : (0))) < (soil_depth) ? (((z_final) > (0) ? (z_final) : (0))) : (soil_depth));
 z_initial = ((z_initial) > (0) ? (z_initial) : (0));
 if ( ( p != 0 ) && (p < 999.0) ){
  delta_water += n_0 * p *
   (exp(-z_final/p) - exp(-z_initial/p));
 }
 else{
  delta_water += n_0 * (z_initial - z_final );
 }
 return(delta_water);
}

canonical_original_code:
double compute_delta_water(int verbose_flag, double n_0, double p, double soil_depth, double z_initial, double z_final)
{
 double delta_water;
 delta_water = ((z_initial) < (0) ? (z_initial) : (0)) - ((z_final) < (0) ? (z_final) : (0));
 z_final = ((((z_final) > (0) ? (z_final) : (0))) < (soil_depth) ? (((z_final) > (0) ? (z_final) : (0))) : (soil_depth));
 z_initial = ((z_initial) > (0) ? (z_initial) : (0));
 if ( ( p != 0 ) && (p < 999.0) ){
  delta_water += n_0 * p *
   (exp(-z_final/p) - exp(-z_initial/p));
 }
 else{
  delta_water += n_0 * (z_initial - z_final );
 }
 return(delta_water);
}

variable_types: p double


variable_types: cn double

variable_types:
u
double *

variable_types:
ga
double *

variable_types: ra double


decompiled_code:
void __fastcall destroy_zone_defaults(int a1, int a2, void **a3)
{
void **v4; // rbx
__int64 v5; // r12
void *v6; // rdi

if ( a2 && a1 > 0 )
{
v4 = a3 + 35;
v5 = (__int64)&a3[40 * (unsigned int)(a1 - 1) + 75];
do
{
v6 = *v4;
v4 += 40;
free(v6);
}
while ( v4 != (void **)v5 );
}
free(a3);
}

original_code:
void destroy_zone_defaults(int num_default_files,
         int grow_flag,
         struct zone_default *default_object_list )
{
 int i;
 if ( grow_flag ){
  for ( i=0 ; i<num_default_files; i++ )
   free( default_object_list[i].grow_defaults );
 }
 free( default_object_list );
 return;
}

canonical_original_code:
void destroy_zone_defaults(int num_default_files, int grow_flag, struct zone_default *default_object_list)
{
 int i;
 if ( grow_flag ){
  for ( i=0 ; i<num_default_files; i++ )
   free( default_object_list[i].grow_defaults );
 }
 free( default_object_list );
 return;
}

variable_types: struct zone_default { int ID; double atm_trans_lapse_rate; double dewpoint_lapse_rate; double lapse_rate; double wet_lapse_rate; double lapse_rate_precip_default; double lapse_rate_tmin; double lapse_rate_tmax; double lapse_rate_tavg; double max_effective_lai; double pptmin; double sea_level_clear_sky_trans; double temcf; double trans_coeff1; double trans_coeff2; double trans_coeff1_sum; double trans_coeff2_sum; int trans_startmonth_sum; double trans_coeff1_win; double trans_coeff2_win; int trans_startmonth_win; double wind; double wind_direction; double max_snow_temp; double min_rain_temp; double ndep_NO3; double atm_CO2; double psen[7]; double ravg_days; struct zone_grow_default { int temp; } *grow_defaults; double search_x; double search_y; double res_patch; int grid_interpolation; } *

variable_types: i int

user_defined_types: struct zone_default { int ID; double atm_trans_lapse_rate; double dewpoint_lapse_rate; double lapse_rate; double wet_lapse_rate; double lapse_rate_precip_default; double lapse_rate_tmin; double lapse_rate_tmax; double lapse_rate_tavg; double max_effective_lai; double pptmin; double sea_level_clear_sky_trans; double temcf; double trans_coeff1; double trans_coeff2; double trans_coeff1_sum; double trans_coeff2_sum; int trans_startmonth_sum; double trans_coeff1_win; double trans_coeff2_win; int trans_startmonth_win; double wind; double wind_direction; double max_snow_temp; double min_rain_temp; double ndep_NO3; double atm_CO2; double psen[7]; double ravg_days; struct zone_grow_default *grow_defaults; double search_x; double search_y; double res_patch; int grid_interpolation; }


decompiled_code:
__int64 __fastcall find_sewer(__int64 a1, int a2, _DWORD *a3)
{
__int64 v4; // rbx
__int64 result; // rax
__int64 v6; // rbp
int v7; // er12
bool v8; // dl

v4 = a1 + 160LL * a2;
result = *(unsigned int *)(v4 + 20);
if ( (_DWORD)result == 1 )
{
*a3 = a2;
}
else if ( *(int *)(v4 + 96) <= 0 )
{
result = 0LL;
}
else
{
v6 = *(_QWORD *)(v4 + 128);
v7 = 1;
if ( *(_DWORD *)(v6 + 20) == 1 )
goto LABEL_7;
LABEL_4:
result = find_sewer(a1, *(unsigned int *)(v6 + 12), a3);
v8 = (_DWORD)result == 0;
if ( *(_DWORD *)(v4 + 96) >= ++v7 )
{
do
{
if ( !v8 )
break;
v6 = *(_QWORD *)(v6 + 48);
if ( *(_DWORD *)(v6 + 20) != 1 )
goto LABEL_4;
LABEL_7:
v8 = 1;
result = 0LL;
++v7;
}
while ( *(_DWORD *)(v4 + 96) >= v7 );
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int a2, _DWORD *a3)
{
__int64 v4; // rbx
__int64 result; // rax
__int64 v6; // rbp
int v7; // er12
bool v8; // dl

v4 = a1 + 160LL * a2;
result = *(unsigned int *)(v4 + 20);
if ( (_DWORD)result == 1 )
{
*a3 = a2;
}
else if ( *(int *)(v4 + 96) <= 0 )
{
result = 0LL;
}
else
{
v6 = *(_QWORD *)(v4 + 128);
v7 = 1;
if ( *(_DWORD *)(v6 + 20) == 1 )
goto LABEL_7;
LABEL_4:
result = func0(a1, *(unsigned int *)(v6 + 12), a3);
v8 = (_DWORD)result == 0;
if ( *(_DWORD *)(v4 + 96) >= ++v7 )
{
do
{
if ( !v8 )
break;
v6 = *(_QWORD *)(v6 + 48);
if ( *(_DWORD *)(v6 + 20) != 1 )
goto LABEL_4;
LABEL_7:
v8 = 1;
result = 0LL;
++v7;
}
while ( *(_DWORD *)(v4 + 96) >= v7 );
}
}
return result;
}

original_code:
int find_sewer(struct flow_struct *flow_table, int curr, int *str_inx) {
 struct adj_struct *aptr;
 int i, inx, fnd;
 fnd = 0;
 aptr = flow_table[curr].adj_list;
 if (flow_table[curr].land != 1) {
  i = 1;
  while ((i <= flow_table[curr].num_adjacent) && (fnd == 0)) {
   inx = aptr->inx;
   if (aptr->sewertype != 1)
    fnd = (int) find_sewer(flow_table, inx, str_inx);
   aptr = aptr->next;
   i += 1;
  }
 }
 else {
  fnd = 1;
  *str_inx = curr;
 }
 return (fnd);
}

canonical_original_code:
int find_sewer(struct flow_struct *flow_table, int curr, int *str_inx) {
 struct adj_struct *aptr;
 int i; int inx; int fnd;
 fnd = 0;
 aptr = flow_table[curr].adj_list;
 if (flow_table[curr].land != 1) {
  i = 1;
  while ((i <= flow_table[curr].num_adjacent) && (fnd == 0)) {
   inx = aptr->inx;
   if (aptr->sewertype != 1)
    fnd = (int) find_sewer(flow_table, inx, str_inx);
   aptr = aptr->next;
   i += 1;
  }
 }
 else {
  fnd = 1;
  *str_inx = curr;
 }
 return (fnd);
}

variable_types: struct flow_struct { int patchID; int hillID; int zoneID; int ID_order; int area; int land; int sewer; float x; float y; float z; float flna; float acc_area; float total_str_gamma; float total_gamma; float gamma_neigh; float total_perimeter; float road_dist; float slope; float internal_slope; float max_slope; double path_length; int num_str; int inflow_cnt; int num_adjacent; int num_dsa; int stream_inx; float stream_gamma; struct ID_struct { int patch; int hill; int zone; } stream_ID; struct adj_struct { int patchID; int hillID; int zoneID; int inx; int landtype; int sewertype; double perimeter; float slope; float gamma; float z; struct adj_struct *next; } *adj_list; struct adj_struct *adj_ptr; struct adj_struct *adj_str_ptr; struct adj_struct *adj_str_list; } *

variable_types: curr int

variable_types: inx int

variable_types: fnd int


keysAreEqual

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

result = 0LL;
if ( (_DWORD)a3 == (_DWORD)a1 && a2 == a4 )
result = HIDWORD(a1) == HIDWORD(a3);
return result;
}

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

result = 0LL;
if ( (_DWORD)a3 == (_DWORD)a1 && a2 == a4 )
result = HIDWORD(a1) == HIDWORD(a3);
return result;
}

original_code:
static bool keysAreEqual(char *key1, char *key2) {
 return strcmp(key1, key2) == 0;
}

canonical_original_code:
static short keysAreEqual(char *key1, char *key2) {
 return strcmp(key1, key2) == 0;
}

return_type: short


keyIsEmpty

decompiled_code:
_BOOL8 __fastcall keyIsEmpty(__int64 a1, int a2)
{
return (HIDWORD(a1) & (unsigned int)a1 & a2) == -1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(__int64 a1, int a2)
{
return (HIDWORD(a1) & (unsigned int)a1 & a2) == -1;
}

original_code:
static bool keyIsEmpty(char *key) {
 return key == ((void *)0);
}

canonical_original_code:
static short keyIsEmpty(char *key) {
 return key == ((void *)0);
}

variable_types:
key
char *


freePatchHashTable

decompiled_code:
void __fastcall freePatchHashTable(void *ptr)
{
unsigned __int64 v2; // rbp
_QWORD *i; // rdi
_QWORD *v4; // rbx
void *v5; // rdi

if ( !ptr )
_assert_fail("table != NULL", "src/patch_hash_table.c", 0x45u, "freePatchHashTable");
v2 = 0LL;
for ( i = (_QWORD *)*((_QWORD *)ptr + 2); *(_QWORD *)ptr > v2; ++v2 )
{
v4 = (_QWORD *)i[3 * v2 + 2];
if ( v4 )
{
do
{
v5 = v4;
v4 = (_QWORD *)v4[2];
free(v5);
}
while ( v4 );
i = (_QWORD *)*((_QWORD *)ptr + 2);
}
}
free(i);
free(ptr);
}

canonical_decompiled_code:
void __fastcall func3(void *ptr)
{
unsigned __int64 v2; // rbp
_QWORD *i; // rdi
_QWORD *v4; // rbx
void *v5; // rdi

if ( !ptr )
_assert_fail("table != NULL", "src/patch_hash_table.c", 0x45u, "freePatchHashTable");
v2 = 0LL;
for ( i = (_QWORD *)*((_QWORD *)ptr + 2); *(_QWORD *)ptr > v2; ++v2 )
{
v4 = (_QWORD *)i[3 * v2 + 2];
if ( v4 )
{
do
{
v5 = v4;
v4 = (_QWORD *)v4[2];
free(v5);
}
while ( v4 );
i = (_QWORD *)*((_QWORD *)ptr + 2);
}
}
free(i);
free(ptr);
}

original_code:
void freePatchHashTable(PatchTable_t *table) {
 ((table != ((void *)0)) ? (void) (0) : __assert_fail ("table != NULL", "src/patch_hash_table.c", 69, __extension__ __PRETTY_FUNCTION__));
 PatchTableEntry_t *entry;
 PatchTableEntry_t *tmpEntry;
 size_t size = sizeof(PatchTableEntry_t);
 for (size_t i = 0; i < table->tableSize; i++) {
  entry = table->entries + i;
  tmpEntry = entry->next;
  while (tmpEntry != ((void *)0) ) {
   entry = tmpEntry;
   tmpEntry = entry->next;
   free(entry);
  }
 }
 free(table->entries);
 free(table);
}

canonical_original_code:
void freePatchHashTable(struct table_s *table) {
 ((table != ((void *)0)) ? (void) (0) : __assert_fail ("table != NULL", "src/patch_hash_table.c", 69, __extension__ __PRETTY_FUNCTION__));
 struct table_entry_s *entry;
 struct table_entry_s *tmpEntry;
 unsigned long size = sizeof(PatchTableEntry_t);
 for (unsigned long i = 0; i < table->tableSize; i++) {
  entry = table->entries + i;
  tmpEntry = entry->next;
  while (tmpEntry != ((void *)0) ) {
   entry = tmpEntry;
   tmpEntry = entry->next;
   free(entry);
  }
 }
 free(table->entries);
 free(table);
}

variable_types: struct table_s { unsigned long tableSize; unsigned long numEntries; struct table_entry_s { struct key_s { int patchID; int zoneID; int hillID; } originKey; int value; struct table_entry_s *next; } *entries; } *

variable_types:
size
unsigned long

variable_types:
i
unsigned long

user_defined_types: struct table_s { unsigned long tableSize; unsigned long numEntries; struct table_entry_s *entries; }

user_defined_types: struct table_entry_s { struct key_s originKey; int value; struct table_entry_s *next; }


patchHashTableGet

decompiled_code:
__int64 __fastcall patchHashTableGet(unsigned __int64 *a1, __int64 a2, int a3)
{
unsigned __int64 v3; // rax
__int64 v4; // r9
__int64 v5; // r8
__int64 v6; // r8
int v7; // ecx
__int64 v8; // r8

if ( !a1 )
_assert_fail("table != NULL", "src/patch_hash_table.c", 0x88u, "patchHashTableGet");
v3 = hash(a2, a3, *a1);
v6 = *(_QWORD *)(v5 + 16) + 24 * v3;
if ( !v6 )
return 0xFFFFFFFFLL;
v7 = a3;
while ( !keysAreEqual(*(_QWORD *)v6, *(_DWORD *)(v6 + 8), v4, v7) )
{
v6 = *(_QWORD *)(v8 + 16);
if ( !v6 )
return 0xFFFFFFFFLL;
}
return *(unsigned int *)(v8 + 12);
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned __int64 *a1, __int64 a2, int a3)
{
unsigned __int64 v3; // rax
__int64 v4; // r9
__int64 v5; // r8
__int64 v6; // r8
int v7; // ecx
__int64 v8; // r8

if ( !a1 )
_assert_fail("table != NULL", "src/patch_hash_table.c", 0x88u, "patchHashTableGet");
v3 = func0(a2, a3, *a1);
v6 = *(_QWORD *)(v5 + 16) + 24 * v3;
if ( !v6 )
return 0xFFFFFFFFLL;
v7 = a3;
while ( !func1(*(_QWORD *)v6, *(_DWORD *)(v6 + 8), v4, v7) )
{
v6 = *(_QWORD *)(v8 + 16);
if ( !v6 )
return 0xFFFFFFFFLL;
}
return *(unsigned int *)(v8 + 12);
}

original_code:
PatchTableValue_t patchHashTableGet(PatchTable_t *table, PatchKey_t key) {
 ((table != ((void *)0)) ? (void) (0) : __assert_fail ("table != NULL", "src/patch_hash_table.c", 136, __extension__ __PRETTY_FUNCTION__));
 PatchTableKey_t hash = _hash(key, table->tableSize);
 PatchTableEntry_t *entry = table->entries + hash;
 while (entry) {
  if (_keysAreEqual(entry->originKey, key)) {
   return entry->value;
  }
  entry = entry->next;
 }
 return -1;
}

canonical_original_code:
int patchHashTableGet(struct table_s *table, struct key_s key) {
 ((table != ((void *)0)) ? (void) (0) : __assert_fail ("table != NULL", "src/patch_hash_table.c", 136, __extension__ __PRETTY_FUNCTION__));
 unsigned long hash = _hash(key, table->tableSize);
 struct table_entry_s *entry = table->entries + hash;
 while (entry) {
  if (_keysAreEqual(entry->originKey, key)) {
   return entry->value;
  }
  entry = entry->next;
 }
 return -1;
}

variable_types:
key
struct key_s

variable_types:
hash
unsigned long

variable_types: struct table_entry_s { struct key_s { int patchID; int zoneID; int hillID; } originKey; int value; struct table_entry_s *next; } *


printPatchHashTable

decompiled_code:
__int64 __fastcall printPatchHashTable(unsigned __int64 *a1)
{
unsigned __int64 v1; // rbp
unsigned int *v2; // rbx
__int64 result; // rax
__int64 v4; // [rsp-28h] [rbp-28h]

if ( *a1 )
{
v1 = 0LL;
do
{
v2 = (unsigned int *)(a1[2] + 24 * v1);
fprintf(
stderr,
"Entry %d: originKey: %d, %d, %d; value: %d; next: %p\n",
v1,
*v2,
v2[2],
v2[1],
v2[3],
*((_QWORD *)v2 + 2));
while ( 1 )
{
v2 = (unsigned int *)*((_QWORD *)v2 + 2);
result = v4;
if ( !v2 )
break;
fprintf(
stderr,
"\tEntry %d: originKey: %d, %d, %d; value: %d; next: %p\n",
v1,
*v2,
v2[2],
v2[1],
v2[3],
*((_QWORD *)v2 + 2));
}
++v1;
}
while ( *a1 > v1 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned __int64 *a1)
{
unsigned __int64 v1; // rbp
unsigned int *v2; // rbx
__int64 result; // rax
__int64 v4; // [rsp-28h] [rbp-28h]

if ( *a1 )
{
v1 = 0LL;
do
{
v2 = (unsigned int *)(a1[2] + 24 * v1);
fprintf(
stderr,
"Entry %d: originKey: %d, %d, %d; value: %d; next: %p\n",
v1,
*v2,
v2[2],
v2[1],
v2[3],
*((_QWORD *)v2 + 2));
while ( 1 )
{
v2 = (unsigned int *)*((_QWORD *)v2 + 2);
result = v4;
if ( !v2 )
break;
fprintf(
stderr,
"\tEntry %d: originKey: %d, %d, %d; value: %d; next: %p\n",
v1,
*v2,
v2[2],
v2[1],
v2[3],
*((_QWORD *)v2 + 2));
}
++v1;
}
while ( *a1 > v1 );
}
return result;
}

original_code:
void printPatchHashTable(PatchTable_t *table) {
 PatchTableEntry_t *entry;
 PatchTableEntry_t *tmpEntry;
 size_t size = sizeof(PatchTableEntry_t);
 for (size_t i = 0; i < table->tableSize; i++) {
  entry = table->entries + i;
  fprintf(stderr, "Entry %d: originKey: %d, %d, %d; value: %d; next: %p\n", i,
    entry->originKey.patchID, entry->originKey.hillID,
    entry->originKey.zoneID, entry->value, entry->next);
  tmpEntry = entry->next;
  while (tmpEntry != ((void *)0) ) {
   entry = tmpEntry;
   fprintf(stderr, "\tEntry %d: originKey: %d, %d, %d; value: %d; next: %p\n", i,
     entry->originKey.patchID, entry->originKey.hillID,
     entry->originKey.zoneID, entry->value, entry->next);
   tmpEntry = entry->next;
  }
 }
}

canonical_original_code:
void printPatchHashTable(struct table_s *table) {
 struct table_entry_s *entry;
 struct table_entry_s *tmpEntry;
 unsigned long size = sizeof(PatchTableEntry_t);
 for (unsigned long i = 0; i < table->tableSize; i++) {
  entry = table->entries + i;
  fprintf(stderr, "Entry %d: originKey: %d, %d, %d; value: %d; next: %p\n", i,
    entry->originKey.patchID, entry->originKey.hillID,
    entry->originKey.zoneID, entry->value, entry->next);
  tmpEntry = entry->next;
  while (tmpEntry != ((void *)0) ) {
   entry = tmpEntry;
   fprintf(stderr, "\tEntry %d: originKey: %d, %d, %d; value: %d; next: %p\n", i,
     entry->originKey.patchID, entry->originKey.hillID,
     entry->originKey.zoneID, entry->value, entry->next);
   tmpEntry = entry->next;
  }
 }
}

user_defined_types: struct key_s { int patchID; int zoneID; int hillID; }


decompiled_code:
__int64 __fastcall verify_num_adjacent_for_patch(__int64 a1, int a2)
{
__int64 v2; // rdx
__int64 v3; // rdi
__int64 i; // rax
__int64 v5; // rcx
__int64 result; // rax

if ( a1 )
{
if ( a2 < 0 )
{
fprintf(stderr, "ERROR: Patch index, %d, is less than zero.\n", (unsigned int)a2);
result = 0LL;
}
else
{
v2 = 0LL;
v3 = 160LL * a2 + a1;
for ( i = *(_QWORD *)(v3 + 128); i; v2 = (unsigned int)(v2 + 1) )
i = *(_QWORD *)(i + 48);
v5 = *(unsigned int *)(v3 + 96);
result = 1LL;
if ( (_DWORD)v5 != (_DWORD)v2 )
{
fprintf(
stderr,
"ERROR: The number of adjacencies in the list, %d, does not match the patches num_adjacent field, %d.\n",
v2,
v5);
result = 0LL;
}
}
}
else
{
fwrite("ERROR: Flow table pointer is NULL.\n", 1uLL, 0x23uLL, stderr);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int a2)
{
__int64 v2; // rdx
__int64 v3; // rdi
__int64 i; // rax
__int64 v5; // rcx
__int64 result; // rax

if ( a1 )
{
if ( a2 < 0 )
{
fprintf(stderr, "ERROR: Patch index, %d, is less than zero.\n", (unsigned int)a2);
result = 0LL;
}
else
{
v2 = 0LL;
v3 = 160LL * a2 + a1;
for ( i = *(_QWORD *)(v3 + 128); i; v2 = (unsigned int)(v2 + 1) )
i = *(_QWORD *)(i + 48);
v5 = *(unsigned int *)(v3 + 96);
result = 1LL;
if ( (_DWORD)v5 != (_DWORD)v2 )
{
fprintf(
stderr,
"ERROR: The number of adjacencies in the list, %d, does not match the patches num_adjacent field, %d.\n",
v2,
v5);
result = 0LL;
}
}
}
else
{
fwrite("ERROR: Flow table pointer is NULL.\n", 1uLL, 0x23uLL, stderr);
result = 0LL;
}
return result;
}

original_code:
bool verify_num_adjacent_for_patch(
    struct flow_struct* _flow_table,
    int _patch)
{
    bool result = true;
    if(_flow_table == 0) {
        fprintf(stderr, "ERROR: Flow table pointer is NULL.\n");
        result = false;
    }
    else if(_patch < 0) {
        fprintf(stderr, "ERROR: Patch index, %d, is less than zero.\n", _patch);
        result = false;
    } else {
        int num_adjacent = 0;
        for(struct adj_struct* adjacency = _flow_table[_patch].adj_list; result && adjacency; adjacency = adjacency->next) {
            ++num_adjacent;
        }
        if(num_adjacent != _flow_table[_patch].num_adjacent) {
            fprintf(stderr, "ERROR: The number of adjacencies in the list, %d, does not match the patches num_adjacent field, %d.\n",
                    num_adjacent, _flow_table[_patch].num_adjacent);
            result = false;
        }
    }
    return result;
}

canonical_original_code:
short verify_num_adjacent_for_patch(struct flow_struct *_flow_table, int _patch)
{
    short result = true;
    if(_flow_table == 0) {
        fprintf(stderr, "ERROR: Flow table pointer is NULL.\n");
        result = false;
    }
    else if(_patch < 0) {
        fprintf(stderr, "ERROR: Patch index, %d, is less than zero.\n", _patch);
        result = false;
    } else {
        int num_adjacent = 0;
        for(struct adj_struct *adjacency = _flow_table[_patch].adj_list; result && adjacency; adjacency = adjacency->next) {
            ++num_adjacent;
        }
        if(num_adjacent != _flow_table[_patch].num_adjacent) {
            fprintf(stderr, "ERROR: The number of adjacencies in the list, %d, does not match the patches num_adjacent field, %d.\n",
                    num_adjacent, _flow_table[_patch].num_adjacent);
            result = false;
        }
    }
    return result;
}

variable_types: result short

variable_types: struct adj_struct { int patchID; int hillID; int zoneID; int inx; int landtype; int sewertype; double perimeter; float slope; float gamma; float z; struct adj_struct *next; } *

user_defined_types: struct ID_struct { int patch; int hill; int zone; }


decompiled_code:
__int64 __fastcall verify_num_adjacent(__int64 a1, int a2)
{
unsigned int v2; // er13
unsigned int v3; // er12
__int64 result; // rax

if ( a1 )
{
if ( a2 < 0 )
{
fprintf(stderr, "ERROR: Number of patches, %d, is less than zero.\n", (unsigned int)a2);
result = 0LL;
}
else
{
v2 = 0;
if ( a2 )
{
while ( 1 )
{
v3 = verify_num_adjacent_for_patch(a1, v2);
if ( !(_WORD)v3 )
break;
if ( a2 == ++v2 )
goto LABEL_11;
}
fprintf(stderr, "ERROR: Patch, %d, has adjacency and num_adjacent mismatch.\n", v2);
}
else
{
LABEL_11:
v3 = 1;
}
result = v3;
}
}
else
{
fwrite("ERROR: Flow table pointer is NULL.\n", 1uLL, 0x23uLL, stderr);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, int a2)
{
unsigned int v2; // er13
unsigned int v3; // er12
__int64 result; // rax

if ( a1 )
{
if ( a2 < 0 )
{
fprintf(stderr, "ERROR: Number of patches, %d, is less than zero.\n", (unsigned int)a2);
result = 0LL;
}
else
{
v2 = 0;
if ( a2 )
{
while ( 1 )
{
v3 = func0(a1, v2);
if ( !(_WORD)v3 )
break;
if ( a2 == ++v2 )
goto LABEL_11;
}
fprintf(stderr, "ERROR: Patch, %d, has adjacency and num_adjacent mismatch.\n", v2);
}
else
{
LABEL_11:
v3 = 1;
}
result = v3;
}
}
else
{
fwrite("ERROR: Flow table pointer is NULL.\n", 1uLL, 0x23uLL, stderr);
result = 0LL;
}
return result;
}

original_code:
bool verify_num_adjacent(
    struct flow_struct* _flow_table,
    int _num_patches)
{
    bool result = true;
    if(_flow_table == 0) {
        fprintf(stderr, "ERROR: Flow table pointer is NULL.\n");
        result = false;
    }
    else if(_num_patches < 0) {
        fprintf(stderr, "ERROR: Number of patches, %d, is less than zero.\n", _num_patches);
        result = false;
    } else {
        for(int index = 0; result && index < _num_patches; ++index) {
            if(!verify_num_adjacent_for_patch(_flow_table, index)) {
                fprintf(stderr, "ERROR: Patch, %d, has adjacency and num_adjacent mismatch.\n", index);
                result = false;
            }
        }
    }
    return result;
}

canonical_original_code:
short verify_num_adjacent(struct flow_struct *_flow_table, int _num_patches)
{
    short result = true;
    if(_flow_table == 0) {
        fprintf(stderr, "ERROR: Flow table pointer is NULL.\n");
        result = false;
    }
    else if(_num_patches < 0) {
        fprintf(stderr, "ERROR: Number of patches, %d, is less than zero.\n", _num_patches);
        result = false;
    } else {
        for(int index = 0; result && index < _num_patches; ++index) {
            if(!verify_num_adjacent_for_patch(_flow_table, index)) {
                fprintf(stderr, "ERROR: Patch, %d, has adjacency and num_adjacent mismatch.\n", index);
                result = false;
            }
        }
    }
    return result;
}

variable_types: index int

user_defined_types: struct adj_struct { int patchID; int hillID; int zoneID; int inx; int landtype; int sewertype; double perimeter; float slope; float gamma; float z; struct adj_struct *next; }


original_code:
void zero_flow_table(struct flow_struct *flow_table, int maxr, int maxc) {
 int r, c;
 int inx;
 for (r = 0; r < maxr; r++) {
  for (c = 0; c < maxc; c++) {
   inx = r * maxc + c;
   flow_table[inx].patchID = -99999;
   flow_table[inx].zoneID = -99999;
   flow_table[inx].hillID = -99999;
   flow_table[inx].ID_order = -99999;
   flow_table[inx].area = 0;
   flow_table[inx].x = 0.0;
   flow_table[inx].y = 0.0;
   flow_table[inx].z = 0.0;
   flow_table[inx].land = 0;
   flow_table[inx].flna = 0.0;
   flow_table[inx].total_gamma = 0.0;
   flow_table[inx].acc_area = 0.0;
   flow_table[inx].path_length = 0.0;
   flow_table[inx].num_adjacent = 0;
  }
 }
 return;
}

canonical_original_code:
void zero_flow_table(struct flow_struct *flow_table, int maxr, int maxc) {
 int r; int c;
 int inx;
 for (r = 0; r < maxr; r++) {
  for (c = 0; c < maxc; c++) {
   inx = r * maxc + c;
   flow_table[inx].patchID = -99999;
   flow_table[inx].zoneID = -99999;
   flow_table[inx].hillID = -99999;
   flow_table[inx].ID_order = -99999;
   flow_table[inx].area = 0;
   flow_table[inx].x = 0.0;
   flow_table[inx].y = 0.0;
   flow_table[inx].z = 0.0;
   flow_table[inx].land = 0;
   flow_table[inx].flna = 0.0;
   flow_table[inx].total_gamma = 0.0;
   flow_table[inx].acc_area = 0.0;
   flow_table[inx].path_length = 0.0;
   flow_table[inx].num_adjacent = 0;
  }
 }
 return;
}

variable_types: maxr int

variable_types: maxc int

variable_types: r int

variable_types: c int


original_code:
int zero_stratum_daily_flux(
       struct cdayflux_struct *cdf,
       struct ndayflux_struct *ndf)
{
 int ok=1;
 cdf->psn_to_cpool = 0.0;
 cdf->leafc_transfer_to_leafc = 0.0;
 cdf->frootc_transfer_to_frootc = 0.0;
 cdf->livestemc_transfer_to_livestemc = 0.0;
 cdf->deadstemc_transfer_to_deadstemc = 0.0;
 cdf->livecrootc_transfer_to_livecrootc = 0.0;
 cdf->deadcrootc_transfer_to_deadcrootc = 0.0;
 cdf->livestemc_to_deadstemc = 0.0;
 cdf->livecrootc_to_deadcrootc = 0.0;
 cdf->added_carbon = 0.0;
 cdf->cpool_to_leafc = 0.0;
 cdf->cpool_to_leafc_store = 0.0;
 cdf->cpool_to_frootc = 0.0;
 cdf->cpool_to_frootc_store = 0.0;
 cdf->cpool_to_livestemc = 0.0;
 cdf->cpool_to_livestemc_store = 0.0;
 cdf->cpool_to_deadstemc = 0.0;
 cdf->cpool_to_deadstemc_store = 0.0;
 cdf->cpool_to_livecrootc = 0.0;
 cdf->cpool_to_livecrootc_store = 0.0;
 cdf->cpool_to_deadcrootc = 0.0;
 cdf->cpool_to_deadcrootc_store = 0.0;
 cdf->cpool_to_gresp_store = 0.0;
 cdf->leafc_store_to_leafc_transfer = 0.0;
 cdf->frootc_store_to_frootc_transfer = 0.0;
 cdf->livestemc_store_to_livestemc_transfer = 0.0;
 cdf->deadstemc_store_to_deadstemc_transfer = 0.0;
 cdf->livecrootc_store_to_livecrootc_transfer = 0.0;
 cdf->deadcrootc_store_to_deadcrootc_transfer = 0.0;
 cdf->gresp_store_to_gresp_transfer = 0.0;
 cdf->storage_transfer_prop = 0.0;
 cdf->carbohydrate_transfer = 0.0;
 cdf->leaf_day_mr = 0.0;
 cdf->leaf_night_mr = 0.0;
 cdf->froot_mr = 0.0;
 cdf->livestem_mr = 0.0;
 cdf->livecroot_mr = 0.0;
  cdf->total_mr = 0.0;
 cdf->transfer_leaf_gr = 0.0;
 cdf->cpool_froot_gr = 0.0;
 cdf->transfer_froot_gr = 0.0;
 cdf->cpool_livestem_gr = 0.0;
 cdf->transfer_livestem_gr = 0.0;
 cdf->cpool_deadstem_gr = 0.0;
 cdf->transfer_deadstem_gr = 0.0;
 cdf->cpool_livecroot_gr = 0.0;
 cdf->transfer_livecroot_gr = 0.0;
 cdf->cpool_deadcroot_gr = 0.0;
 cdf->transfer_deadcroot_gr = 0.0;
 ndf->leafn_transfer_to_leafn = 0.0;
 ndf->frootn_transfer_to_frootn = 0.0;
 ndf->livestemn_transfer_to_livestemn = 0.0;
 ndf->deadstemn_transfer_to_deadstemn = 0.0;
 ndf->livecrootn_transfer_to_livecrootn = 0.0;
 ndf->deadcrootn_transfer_to_deadcrootn = 0.0;
 ndf->livestemn_to_deadstemn = 0.0;
 ndf->livestemn_to_retransn = 0.0;
 ndf->livecrootn_to_deadcrootn = 0.0;
 ndf->livecrootn_to_retransn = 0.0;
 ndf->potential_N_uptake = 0.0;
 ndf->sminn_to_npool = 0.0;
 ndf->retransn_to_npool = 0.0;
 ndf->npool_to_leafn = 0.0;
 ndf->npool_to_leafn_store = 0.0;
 ndf->npool_to_frootn = 0.0;
 ndf->npool_to_frootn_store = 0.0;
 ndf->npool_to_livestemn = 0.0;
 ndf->npool_to_livestemn_store = 0.0;
 ndf->npool_to_deadstemn = 0.0;
 ndf->npool_to_deadstemn_store = 0.0;
 ndf->npool_to_livecrootn = 0.0;
 ndf->npool_to_livecrootn_store = 0.0;
 ndf->npool_to_deadcrootn = 0.0;
 ndf->npool_to_deadcrootn_store = 0.0;
 ndf->leafn_store_to_leafn_transfer = 0.0;
 ndf->frootn_store_to_frootn_transfer = 0.0;
 ndf->livestemn_store_to_livestemn_transfer = 0.0;
 ndf->deadstemn_store_to_deadstemn_transfer = 0.0;
 ndf->livecrootn_store_to_livecrootn_transfer = 0.0;
 ndf->deadcrootn_store_to_deadcrootn_transfer = 0.0;
 ndf->carbohydrate_transfer = 0.0;
 return (!ok);
}

canonical_original_code:
int zero_stratum_daily_flux(struct cdayflux_struct *cdf, struct ndayflux_struct *ndf)
{
 int ok = 1;
 cdf->psn_to_cpool = 0.0;
 cdf->leafc_transfer_to_leafc = 0.0;
 cdf->frootc_transfer_to_frootc = 0.0;
 cdf->livestemc_transfer_to_livestemc = 0.0;
 cdf->deadstemc_transfer_to_deadstemc = 0.0;
 cdf->livecrootc_transfer_to_livecrootc = 0.0;
 cdf->deadcrootc_transfer_to_deadcrootc = 0.0;
 cdf->livestemc_to_deadstemc = 0.0;
 cdf->livecrootc_to_deadcrootc = 0.0;
 cdf->added_carbon = 0.0;
 cdf->cpool_to_leafc = 0.0;
 cdf->cpool_to_leafc_store = 0.0;
 cdf->cpool_to_frootc = 0.0;
 cdf->cpool_to_frootc_store = 0.0;
 cdf->cpool_to_livestemc = 0.0;
 cdf->cpool_to_livestemc_store = 0.0;
 cdf->cpool_to_deadstemc = 0.0;
 cdf->cpool_to_deadstemc_store = 0.0;
 cdf->cpool_to_livecrootc = 0.0;
 cdf->cpool_to_livecrootc_store = 0.0;
 cdf->cpool_to_deadcrootc = 0.0;
 cdf->cpool_to_deadcrootc_store = 0.0;
 cdf->cpool_to_gresp_store = 0.0;
 cdf->leafc_store_to_leafc_transfer = 0.0;
 cdf->frootc_store_to_frootc_transfer = 0.0;
 cdf->livestemc_store_to_livestemc_transfer = 0.0;
 cdf->deadstemc_store_to_deadstemc_transfer = 0.0;
 cdf->livecrootc_store_to_livecrootc_transfer = 0.0;
 cdf->deadcrootc_store_to_deadcrootc_transfer = 0.0;
 cdf->gresp_store_to_gresp_transfer = 0.0;
 cdf->storage_transfer_prop = 0.0;
 cdf->carbohydrate_transfer = 0.0;
 cdf->leaf_day_mr = 0.0;
 cdf->leaf_night_mr = 0.0;
 cdf->froot_mr = 0.0;
 cdf->livestem_mr = 0.0;
 cdf->livecroot_mr = 0.0;
  cdf->total_mr = 0.0;
 cdf->transfer_leaf_gr = 0.0;
 cdf->cpool_froot_gr = 0.0;
 cdf->transfer_froot_gr = 0.0;
 cdf->cpool_livestem_gr = 0.0;
 cdf->transfer_livestem_gr = 0.0;
 cdf->cpool_deadstem_gr = 0.0;
 cdf->transfer_deadstem_gr = 0.0;
 cdf->cpool_livecroot_gr = 0.0;
 cdf->transfer_livecroot_gr = 0.0;
 cdf->cpool_deadcroot_gr = 0.0;
 cdf->transfer_deadcroot_gr = 0.0;
 ndf->leafn_transfer_to_leafn = 0.0;
 ndf->frootn_transfer_to_frootn = 0.0;
 ndf->livestemn_transfer_to_livestemn = 0.0;
 ndf->deadstemn_transfer_to_deadstemn = 0.0;
 ndf->livecrootn_transfer_to_livecrootn = 0.0;
 ndf->deadcrootn_transfer_to_deadcrootn = 0.0;
 ndf->livestemn_to_deadstemn = 0.0;
 ndf->livestemn_to_retransn = 0.0;
 ndf->livecrootn_to_deadcrootn = 0.0;
 ndf->livecrootn_to_retransn = 0.0;
 ndf->potential_N_uptake = 0.0;
 ndf->sminn_to_npool = 0.0;
 ndf->retransn_to_npool = 0.0;
 ndf->npool_to_leafn = 0.0;
 ndf->npool_to_leafn_store = 0.0;
 ndf->npool_to_frootn = 0.0;
 ndf->npool_to_frootn_store = 0.0;
 ndf->npool_to_livestemn = 0.0;
 ndf->npool_to_livestemn_store = 0.0;
 ndf->npool_to_deadstemn = 0.0;
 ndf->npool_to_deadstemn_store = 0.0;
 ndf->npool_to_livecrootn = 0.0;
 ndf->npool_to_livecrootn_store = 0.0;
 ndf->npool_to_deadcrootn = 0.0;
 ndf->npool_to_deadcrootn_store = 0.0;
 ndf->leafn_store_to_leafn_transfer = 0.0;
 ndf->frootn_store_to_frootn_transfer = 0.0;
 ndf->livestemn_store_to_livestemn_transfer = 0.0;
 ndf->deadstemn_store_to_deadstemn_transfer = 0.0;
 ndf->livecrootn_store_to_livecrootn_transfer = 0.0;
 ndf->deadcrootn_store_to_deadcrootn_transfer = 0.0;
 ndf->carbohydrate_transfer = 0.0;
 return (!ok);
}

variable_types: struct cdayflux_struct { double fcroot; double fleaf; double froot; double fwood; double added_carbon; double assim_sunlit; double assim_shade; double psn_to_cpool; double potential_psn_to_cpool; double DOC_to_gw; double trans_sunlit; double trans_shade; double leafc_to_deadleafc; double leafc_store_to_leafc; double frootc_store_to_frootc; double leafc_transfer_to_leafc; double frootc_transfer_to_frootc; double livestemc_transfer_to_livestemc; double deadstemc_transfer_to_deadstemc; double livecrootc_transfer_to_livecrootc; double deadcrootc_transfer_to_deadcrootc; double cpool_to_leafc; double cpool_to_leafc_store; double cpool_to_frootc; double cpool_to_frootc_store; double cpool_to_livestemc; double cpool_to_livestemc_store; double cpool_to_deadstemc; double cpool_to_deadstemc_store; double cpool_to_livecrootc; double cpool_to_livecrootc_store; double cpool_to_deadcrootc; double cpool_to_deadcrootc_store; double cpool_to_gresp_store; double actual_C_growth; double leafc_store_to_leafc_transfer; double frootc_store_to_frootc_transfer; double livestemc_store_to_livestemc_transfer; double deadstemc_store_to_deadstemc_transfer; double livecrootc_store_to_livecrootc_transfer; double deadcrootc_store_to_deadcrootc_transfer; double gresp_store_to_gresp_transfer; double carbohydrate_transfer; double storage_transfer_prop; double livestemc_to_deadstemc; double livecrootc_to_deadcrootc; double leaf_day_mr; double leaf_night_mr; double froot_mr; double livestem_mr; double livecroot_mr; double total_mr; double cpool_leaf_gr; double transfer_leaf_gr; double cpool_froot_gr; double transfer_froot_gr; double cpool_livestem_gr; double transfer_livestem_gr; double cpool_deadstem_gr; double transfer_deadstem_gr; double cpool_livecroot_gr; double transfer_livecroot_gr; double cpool_deadcroot_gr; double transfer_deadcroot_gr; double transfer_gr; double total_gr; } *

variable_types: struct ndayflux_struct { double sminn_to_npool; double leafn_to_deadleafn; double leafn_store_to_leafn; double frootn_store_to_frootn; double leafn_transfer_to_leafn; double frootn_transfer_to_frootn; double livestemn_transfer_to_livestemn; double deadstemn_transfer_to_deadstemn; double livecrootn_transfer_to_livecrootn; double deadcrootn_transfer_to_deadcrootn; double potential_N_uptake; double actual_N_uptake; double retransn_to_npool; double npool_to_leafn; double npool_to_leafn_store; double npool_to_frootn; double npool_to_frootn_store; double npool_to_livestemn; double npool_to_livestemn_store; double npool_to_deadstemn; double npool_to_deadstemn_store; double npool_to_livecrootn; double npool_to_livecrootn_store; double npool_to_deadcrootn; double npool_to_deadcrootn_store; double leafn_store_to_leafn_transfer; double frootn_store_to_frootn_transfer; double livestemn_store_to_livestemn_transfer; double deadstemn_store_to_deadstemn_transfer; double livecrootn_store_to_livecrootn_transfer; double deadcrootn_store_to_deadcrootn_transfer; double carbohydrate_transfer; double livestemn_to_deadstemn; double livestemn_to_retransn; double livecrootn_to_deadcrootn; double livecrootn_to_retransn; } *

variable_types: ok int


decompiled_code:
__int64 __fastcall key_compare(__int64 a1, __int64 a2)
{
double v2; // xmm0_8
double v3; // xmm1_8
__int64 result; // rax

v2 = *(double *)(a1 + 16);
v3 = *(double *)(a2 + 16);
result = 0xFFFFFFFFLL;
if ( v2 <= v3 )
result = v3 > v2;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, __int64 a2)
{
double v2; // xmm0_8
double v3; // xmm1_8
__int64 result; // rax

v2 = *(double *)(a1 + 16);
v3 = *(double *)(a2 + 16);
result = 0xFFFFFFFFLL;
if ( v2 <= v3 )
result = v3 > v2;
return result;
}

original_code:
int key_compare( void * e1, void *e2 )
{
 double v1,v2;
  v1 = ((struct layer_object *)e1)->height;
  v2 = ((struct layer_object *)e2)->height;
 return (v1>v2) ? -1 : (v1<v2) ? 1: 0;
}

canonical_original_code:
int key_compare(void *e1, void *e2)
{
 double v1; double v2;
  v1 = ((struct layer_object *)e1)->height;
  v2 = ((struct layer_object *)e2)->height;
 return (v1>v2) ? -1 : (v1<v2) ? 1: 0;
}

user_defined_types: struct layer_object { int count; long *strata; double height; double base; double null_cover; }