getDoubleWorldfile

decompiled_code:
int __fastcall getDoubleWorldfile(int *a1, __int64 *a2, const char *a3, const char *a4, int a5)
{
int result; // eax
__int64 v8; // rbx
__int64 v10; // r14
__int64 v11; // [rsp+0h] [rbp-40h] BYREF

result = *a1;
v8 = *a2;
if ( *a1 <= 0 )
{
LABEL_7:
if ( !a5 )
result = printf("\nNo parameter value found for %s and 'useDefault' flag set to false\n", a3);
}
else
{
v10 = v8 + 1072LL * (unsigned int)(result - 1) + 1072;
while ( 1 )
{
result = strcmp((const char *)v8, a3);
if ( !result )
break;
v8 += 1072LL;
if ( v8 == v10 )
goto LABEL_7;
}
_isoc99_sscanf(v8 + 32, a4, &v11);
*(_DWORD *)(v8 + 1064) = 1;
result = (unsigned int)strcpy((char *)(v8 + 1056), a4);
}
return result;
}

canonical_decompiled_code:
int __fastcall func10(int *a1, __int64 *a2, const char *a3, const char *a4, int a5)
{
int result; // eax
__int64 v8; // rbx
__int64 v10; // r14
__int64 v11; // [rsp+0h] [rbp-40h] BYREF

result = *a1;
v8 = *a2;
if ( *a1 <= 0 )
{
LABEL_7:
if ( !a5 )
result = printf("\nNo parameter value found for %s and 'useDefault' flag set to false\n", a3);
}
else
{
v10 = v8 + 1072LL * (unsigned int)(result - 1) + 1072;
while ( 1 )
{
result = strcmp((const char *)v8, a3);
if ( !result )
break;
v8 += 1072LL;
if ( v8 == v10 )
goto LABEL_7;
}
_isoc99_sscanf(v8 + 32, a4, &v11);
*(_DWORD *)(v8 + 1064) = 1;
result = (unsigned int)strcpy((char *)(v8 + 1056), a4);
}
return result;
}

original_code:
double getDoubleWorldfile(int *paramCnt, param **paramPtr, char *paramName, char *readFormat, double defaultVal, int useDefaultVal) {
    int iParam;
    int paramInd;
    int sLen;
    double doubleVal;
    int found = 0;
    param *params;
    params = *paramPtr;
    for (iParam = 0; iParam < *paramCnt; iParam++) {
        if (strcmp(params[iParam].name, paramName) == 0) {
            found = 1;
            sscanf(params[iParam].strVal, readFormat, &doubleVal);
            params[iParam].accessed = 1;
            strcpy(params[iParam].format, readFormat);
            break;
        }
    }
    if (found) {
        return doubleVal;
    } else if (useDefaultVal) {
        return defaultVal;
    } else {
        printf("\nNo parameter value found for %s and 'useDefault' flag set to false\n", paramName);
    }
}

canonical_original_code:
double getDoubleWorldfile(int *paramCnt, struct param **paramPtr, char *paramName, char *readFormat, double defaultVal, int useDefaultVal) {
    int iParam;
    int paramInd;
    int sLen;
    double doubleVal;
    int found = 0;
    struct param *params;
    params = *paramPtr;
    for (iParam = 0; iParam < *paramCnt; iParam++) {
        if (strcmp(params[iParam].name, paramName) == 0) {
            found = 1;
            sscanf(params[iParam].strVal, readFormat, &doubleVal);
            params[iParam].accessed = 1;
            strcpy(params[iParam].format, readFormat);
            break;
        }
    }
    if (found) {
        return doubleVal;
    } else if (useDefaultVal) {
        return defaultVal;
    } else {
        printf("\nNo parameter value found for %s and 'useDefault' flag set to false\n", paramName);
    }
}

variable_types: defaultVal double

variable_types: doubleVal double

variable_types: struct param { char name[32]; char strVal[1024]; char format[8]; int accessed; int defaultValUsed; } *


repo: RHESSys/RHESSys

decompiled_code:
double __fastcall compute_z_final(double a1, double a2, double a3, double a4, double a5)
{
double v5; // xmm1_8
double v6; // xmm6_8
double v7; // xmm0_8
double result; // xmm0_8
double v9; // xmm3_8
double v10; // xmm3_8
double v11; // xmm0_8

v5 = fmax(a2, 0.00000001);
v6 = fmax(a1, 0.00000001);
if ( a4 <= 0.0 )
{
if ( a5 < 0.0 )
{
v9 = a4 - a5;
result = v9;
if ( v9 > 0.0 )
{
*(_QWORD *)&v10 = *(_QWORD *)&v9 ^ LC2;
if ( v5 < 999.9 )
result = log(v10 / (v6 * v5) + 1.0) * COERCE_DOUBLE(*(_QWORD *)&v5 ^ LC2);
else
result = 0.0 - v10 / v6;
}
}
else
{
result = a4 - a5;
}
}
else
{
v7 = compute_delta_water(v6, v5, a3, a4, 0.0);
if ( v7 > a5 )
{
v11 = a5 / (v6 * v5) + exp(COERCE_DOUBLE(*(_QWORD *)&a4 ^ LC2) / v5);
if ( v11 > 0.0 )
result = log(v11) * COERCE_DOUBLE(*(_QWORD *)&v5 ^ LC2);
else
result = a3;
}
else
{
result = v7 - a5;
}
}
return result;
}

canonical_decompiled_code:
double __fastcall func0(double a1, double a2, double a3, double a4, double a5)
{
double v5; // xmm1_8
double v6; // xmm6_8
double v7; // xmm0_8
double result; // xmm0_8
double v9; // xmm3_8
double v10; // xmm3_8
double v11; // xmm0_8

v5 = fmax(a2, 0.00000001);
v6 = fmax(a1, 0.00000001);
if ( a4 <= 0.0 )
{
if ( a5 < 0.0 )
{
v9 = a4 - a5;
result = v9;
if ( v9 > 0.0 )
{
*(_QWORD *)&v10 = *(_QWORD *)&v9 ^ LC2;
if ( v5 < 999.9 )
result = log(v10 / (v6 * v5) + 1.0) * COERCE_DOUBLE(*(_QWORD *)&v5 ^ LC2);
else
result = 0.0 - v10 / v6;
}
}
else
{
result = a4 - a5;
}
}
else
{
v7 = compute_delta_water(v6, v5, a3, a4, 0.0);
if ( v7 > a5 )
{
v11 = a5 / (v6 * v5) + exp(COERCE_DOUBLE(*(_QWORD *)&a4 ^ LC2) / v5);
if ( v11 > 0.0 )
result = log(v11) * COERCE_DOUBLE(*(_QWORD *)&v5 ^ LC2);
else
result = a3;
}
else
{
result = v7 - a5;
}
}
return result;
}

original_code:
double compute_z_final(
      int verbose_flag,
      double p_0,
      double p,
      double soil_depth,
      double z_initial,
      double delta_water)
{
 double compute_delta_water(
  int,
  double,
  double,
  double,
  double,
  double);
 double arguement;
 double delta_water_surf;
 double z_final;
 p = ((p) > (0.00000001) ? (p) : (0.00000001));
 p_0 = ((p_0) > (0.00000001) ? (p_0) : (0.00000001));
 if ( (z_initial<=0) && (delta_water>=0) ){
  z_final = z_initial - delta_water;
 }
 else if ( (z_initial<=0) && (delta_water<0) ){
  z_final = z_initial - delta_water;
  if ( z_final > 0 ){
   delta_water = -1 * z_final;
   if (p < 999.9) {
     z_final = -1 * p *
      log( 1 + delta_water / ( p * p_0) );
   }
   else
     z_final = (0 - delta_water/p_0);
  }
 }
 else{
  delta_water_surf =
   compute_delta_water(
   verbose_flag,
   p_0,
   p,
   soil_depth,
   z_initial,
   0);
  if ( delta_water < delta_water_surf ){
   arguement = ( exp( -1 * z_initial/p) + delta_water / (p*p_0));
   if ( arguement > 0 ){
    z_final = -1 * p * log(arguement);
   }
   else{
    z_final = soil_depth;
   }
  }
  else{
   z_final = delta_water_surf - delta_water;
  }
 }
 return(z_final);
}

canonical_original_code:
double compute_z_final(int verbose_flag, double p_0, double p, double soil_depth, double z_initial, double delta_water)
{
 double compute_delta_water(int, double, double, double, double, double);
 double arguement;
 double delta_water_surf;
 double z_final;
 p = ((p) > (0.00000001) ? (p) : (0.00000001));
 p_0 = ((p_0) > (0.00000001) ? (p_0) : (0.00000001));
 if ( (z_initial<=0) && (delta_water>=0) ){
  z_final = z_initial - delta_water;
 }
 else if ( (z_initial<=0) && (delta_water<0) ){
  z_final = z_initial - delta_water;
  if ( z_final > 0 ){
   delta_water = -1 * z_final;
   if (p < 999.9) {
     z_final = -1 * p *
      log( 1 + delta_water / ( p * p_0) );
   }
   else
     z_final = (0 - delta_water/p_0);
  }
 }
 else{
  delta_water_surf =
   compute_delta_water(
   verbose_flag,
   p_0,
   p,
   soil_depth,
   z_initial,
   0);
  if ( delta_water < delta_water_surf ){
   arguement = ( exp( -1 * z_initial/p) + delta_water / (p*p_0));
   if ( arguement > 0 ){
    z_final = -1 * p * log(arguement);
   }
   else{
    z_final = soil_depth;
   }
  }
  else{
   z_final = delta_water_surf - delta_water;
  }
 }
 return(z_final);
}

variable_types: p double

variable_types: double (int, double, double, double, double, double)

variable_types: arguement double

return_type: double


decompiled_code:
__int64 __fastcall impervious_make_context(int a1, int a2, __int64 a3, __int64 a4, _QWORD *a5)
{
_DWORD *v8; // rax
__int64 result; // rax

if ( a5 )
{
v8 = calloc(1uLL, 0x18uLL);
if ( v8 )
{
*v8 = a1;
v8[1] = a2;
*((_QWORD *)v8 + 1) = a3;
*((_QWORD *)v8 + 2) = a4;
*a5 = v8;
result = 1LL;
}
else
{
fwrite("ERROR: Failed to allocate memory for the impervious search context.\n", 1uLL, 0x44uLL, stderr);
result = 0LL;
}
}
else
{
fwrite("ERROR: Return impervious context pointer is NULL.\n", 1uLL, 0x32uLL, stderr);
result = 0LL;
}
return result;
}

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

if ( a5 )
{
v8 = calloc(1uLL, 0x18uLL);
if ( v8 )
{
*v8 = a1;
v8[1] = a2;
*((_QWORD *)v8 + 1) = a3;
*((_QWORD *)v8 + 2) = a4;
*a5 = v8;
result = 1LL;
}
else
{
fwrite("ERROR: Failed to allocate memory for the impervious search context.\n", 1uLL, 0x44uLL, stderr);
result = 0LL;
}
}
else
{
fwrite("ERROR: Return impervious context pointer is NULL.\n", 1uLL, 0x32uLL, stderr);
result = 0LL;
}
return result;
}

original_code:
bool impervious_make_context(
    int _maxr,
    int _maxc,
    const double* _roofs,
    const int* _impervious,
    void** _rtn_ctx)
{
    bool result = true;
    if(_rtn_ctx == 0) {
 fprintf(stderr, "ERROR: Return impervious context pointer is NULL.\n");
 result = false;
    } else {
 impervious_context_t* context = (impervious_context_t*)calloc(1, sizeof(impervious_context_t));
 if(context == 0) {
     fprintf(stderr, "ERROR: Failed to allocate memory for the impervious search context.\n");
     result = false;
 } else {
     context->maxr_ = _maxr;
     context->maxc_ = _maxc;
     context->roofs_ = _roofs;
     context->impervious_ = _impervious;
     *_rtn_ctx = (void*)context;
 }
    }
    return result;
}

canonical_original_code:
short impervious_make_context(int _maxr, int _maxc, double *_roofs, int *_impervious, void **_rtn_ctx)
{
    short result = true;
    if(_rtn_ctx == 0) {
 fprintf(stderr, "ERROR: Return impervious context pointer is NULL.\n");
 result = false;
    } else {
 struct impervious_context_s *context = (impervious_context_t*)calloc(1, sizeof(impervious_context_t));
 if(context == 0) {
     fprintf(stderr, "ERROR: Failed to allocate memory for the impervious search context.\n");
     result = false;
 } else {
     context->maxr_ = _maxr;
     context->maxc_ = _maxc;
     context->roofs_ = _roofs;
     context->impervious_ = _impervious;
     *_rtn_ctx = (void *)context;
 }
    }
    return result;
}

variable_types: result short

variable_types: struct impervious_context_s { int maxr_; int maxc_; double *roofs_; int *impervious_; } *

return_type: short


decompiled_code:
__int64 __fastcall impervious_search_predicate(__int64 a1, __int64 a2, unsigned int a3, unsigned int a4, unsigned int *a5, _DWORD *a6)
{
__int64 result; // rax
int v9[7]; // [rsp+Ch] [rbp-1Ch] BYREF

if ( a5 )
{
result = row_col_to_index(a3, a4, *a5, a5[1], v9);
if ( (_WORD)result )
{
if ( *(_DWORD *)(*((_QWORD *)a5 + 2) + 4LL * v9[0]) != 1
|| (unsigned __int16)is_roof(*(double *)(*((_QWORD *)a5 + 1) + 8LL * v9[0])) )
{
*a6 = 0;
result = 1LL;
}
else
{
*a6 = 1;
result = 1LL;
}
}
}
else
{
fwrite("ERROR: Search context pointer is NULL.\n", 1uLL, 0x27uLL, stderr);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, unsigned int a3, unsigned int a4, unsigned int *a5, _DWORD *a6)
{
__int64 result; // rax
int v9[7]; // [rsp+Ch] [rbp-1Ch] BYREF

if ( a5 )
{
result = row_col_to_index(a3, a4, *a5, a5[1], v9);
if ( (_WORD)result )
{
if ( *(_DWORD *)(*((_QWORD *)a5 + 2) + 4LL * v9[0]) != 1
|| (unsigned __int16)is_roof(*(double *)(*((_QWORD *)a5 + 1) + 8LL * v9[0])) )
{
*a6 = 0;
result = 1LL;
}
else
{
*a6 = 1;
result = 1LL;
}
}
}
else
{
fwrite("ERROR: Search context pointer is NULL.\n", 1uLL, 0x27uLL, stderr);
result = 0LL;
}
return result;
}

original_code:
bool impervious_search_predicate(
 int _subjectRow,
 int _subjectCol,
    int _row,
    int _col,
    void* _context,
    int* _rtn_vote)
{
    bool result = true;
    if(_context == 0) {
 fprintf(stderr, "ERROR: Search context pointer is NULL.\n");
 result = false;
    } else {
 impervious_context_t* context = (impervious_context_t*)_context;
 int index;
 if(!row_col_to_index(_row, _col, context->maxr_, context->maxc_, &index)) {
     result = false;
 } else {
     if(context->impervious_[index] == 1 && !is_roof(context->roofs_[index])) {
  *_rtn_vote = 1;
     } else {
  *_rtn_vote = 0;
     }
 }
    }
    return result;
}

canonical_original_code:
short impervious_search_predicate(int _subjectRow, int _subjectCol, int _row, int _col, void *_context, int *_rtn_vote)
{
    short result = true;
    if(_context == 0) {
 fprintf(stderr, "ERROR: Search context pointer is NULL.\n");
 result = false;
    } else {
 struct impervious_context_s *context = (impervious_context_t*)_context;
 int index;
 if(!row_col_to_index(_row, _col, context->maxr_, context->maxc_, &index)) {
     result = false;
 } else {
     if(context->impervious_[index] == 1 && !is_roof(context->roofs_[index])) {
  *_rtn_vote = 1;
     } else {
  *_rtn_vote = 0;
     }
 }
    }
    return result;
}

variable_types: index int

user_defined_types: struct impervious_context_s { int maxr_; int maxc_; double *roofs_; int *impervious_; }


decompiled_code:
__int64 __fastcall impervious_search_tiebreaker(int a1, int a2, __int64 a3, __int64 a4, __int64 a5, _DWORD *a6, _DWORD *a7)
{
*a6 = a1;
*a7 = a2;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, int a2, __int64 a3, __int64 a4, __int64 a5, _DWORD *a6, _DWORD *a7)
{
*a6 = a1;
*a7 = a2;
return 1LL;
}

original_code:
bool impervious_search_tiebreaker(
 int _rowA,
 int _colA,
 int _rowB,
 int _colB,
 void* _context,
 int* _winnerRow,
 int* _winnerCol) {
 *_winnerRow = _rowA;
 *_winnerCol = _colA;
 return true;
}

canonical_original_code:
short impervious_search_tiebreaker(int _rowA, int _colA, int _rowB, int _colB, void *_context, int *_winnerRow, int *_winnerCol) {
 *_winnerRow = _rowA;
 *_winnerCol = _colA;
 return true;
}


original_code:
double compute_diffuse_radiative_PAR_fluxes( int verbose_flag,
            double *flux_down_ptr,
            double direct_flux,
            double extinction_coef,
            double gap_fraction,
            double lai,
            double theta_noon,
            double reflectance_canopy)
{
 double flux_reflected;
 double flux_transmitted;
 double flux_absorbed;
 double S;
 flux_reflected = *flux_down_ptr * reflectance_canopy;
 if ( *flux_down_ptr != 0 ){
  S = 0.07 * ( direct_flux / *flux_down_ptr ) *
   ((0) > (1.1- 0.1 * lai * (1- gap_fraction)) ? (0) : (1.1- 0.1 * lai * (1- gap_fraction))) * exp( -1 * cos(theta_noon));
 }
 else{
  S = 0;
 }
 flux_absorbed = ( *flux_down_ptr - flux_reflected)
  * ( 1 - exp(-0.5 * pow(lai*(1-gap_fraction),0.7)) + S);
 flux_transmitted = *flux_down_ptr - flux_reflected - flux_absorbed ;
 *flux_down_ptr = flux_transmitted;
 if( verbose_flag > 2)
  printf("%8.1f %8.1f %8.1f ",
  flux_reflected,flux_absorbed,flux_transmitted);
 return( flux_absorbed );
}

canonical_original_code:
double compute_diffuse_radiative_PAR_fluxes(int verbose_flag, double *flux_down_ptr, double direct_flux, double extinction_coef, double gap_fraction, double lai, double theta_noon, double reflectance_canopy)
{
 double flux_reflected;
 double flux_transmitted;
 double flux_absorbed;
 double S;
 flux_reflected = *flux_down_ptr * reflectance_canopy;
 if ( *flux_down_ptr != 0 ){
  S = 0.07 * ( direct_flux / *flux_down_ptr ) *
   ((0) > (1.1- 0.1 * lai * (1- gap_fraction)) ? (0) : (1.1- 0.1 * lai * (1- gap_fraction))) * exp( -1 * cos(theta_noon));
 }
 else{
  S = 0;
 }
 flux_absorbed = ( *flux_down_ptr - flux_reflected)
  * ( 1 - exp(-0.5 * pow(lai*(1-gap_fraction),0.7)) + S);
 flux_transmitted = *flux_down_ptr - flux_reflected - flux_absorbed ;
 *flux_down_ptr = flux_transmitted;
 if( verbose_flag > 2)
  printf("%8.1f %8.1f %8.1f ",
  flux_reflected,flux_absorbed,flux_transmitted);
 return( flux_absorbed );
}

variable_types: lai double

variable_types: S double


decompiled_code:
double __fastcall compute_N_absorbed(double a1, double a2, double a3, double a4, double a5)
{
return fmax((1.0 - a5) * 2.65 * 1000.0 * ((a2 - a1) * a5 * a3), 0.0);
}

canonical_decompiled_code:
double __fastcall func0(double a1, double a2, double a3, double a4, double a5)
{
return fmax((1.0 - a5) * 2.65 * 1000.0 * ((a2 - a1) * a5 * a3), 0.0);
}

original_code:
double compute_N_absorbed(int verbose_flag,
   double z1,
   double z2,
   double N_absorption_rate,
   double p,
   double n_0)
 {
 double nabsorbed;
 double bulk_density;
 bulk_density = 2.65 * (1.0 - n_0) * 1000;
 nabsorbed=n_0*(z2-z1)*N_absorption_rate*bulk_density;
 nabsorbed=((nabsorbed) > (0.0) ? (nabsorbed) : (0.0));
 return(nabsorbed);
}

variable_types: nabsorbed double


decompiled_code:
double __fastcall compute_nonvascular_stratum_conductance(double a1, double a2, double a3, double a4, double a5)
{
double v5; // xmm7_8
double result; // xmm0_8

v5 = fmax(0.0, a1 - 0.001);
if ( a2 < 1.0e-14 )
result = fmax(a4 * 0.0 + a5, 0.0);
else
result = fmax(a4 * fmax(0.0, (v5 + a1) * 0.5 / a2) + a5, 0.0);
return result;
}

canonical_decompiled_code:
double __fastcall func0(double a1, double a2, double a3, double a4, double a5)
{
double v5; // xmm7_8
double result; // xmm0_8

v5 = fmax(0.0, a1 - 0.001);
if ( a2 < 1.0e-14 )
result = fmax(a4 * 0.0 + a5, 0.0);
else
result = fmax(a4 * fmax(0.0, (v5 + a1) * 0.5 / a2) + a5, 0.0);
return result;
}

original_code:
double compute_nonvascular_stratum_conductance(
            int verbose_flag,
            double rain_stored,
            double rain_capacity,
            double gl_c,
            double gsurf_slope,
            double gsurf_intercept)
{
 double approx_day_end_storage;
 double adjusted_storage;
 double stratum_conductance;
 approx_day_end_storage = ((0) > (rain_stored - 0.001) ? (0) : (rain_stored - 0.001));
 if (rain_capacity < 0.00000000000001)
  adjusted_storage = 0.0;
 else
  adjusted_storage = ((0) > (((rain_stored + approx_day_end_storage )/2.0) / ( rain_capacity)) ? (0) : (((rain_stored + approx_day_end_storage )/2.0) / ( rain_capacity)));
 stratum_conductance = ((gsurf_slope*adjusted_storage + gsurf_intercept) > (0) ? (gsurf_slope*adjusted_storage + gsurf_intercept) : (0));
 return(stratum_conductance);
}

canonical_original_code:
double compute_nonvascular_stratum_conductance(int verbose_flag, double rain_stored, double rain_capacity, double gl_c, double gsurf_slope, double gsurf_intercept)
{
 double approx_day_end_storage;
 double adjusted_storage;
 double stratum_conductance;
 approx_day_end_storage = ((0) > (rain_stored - 0.001) ? (0) : (rain_stored - 0.001));
 if (rain_capacity < 0.00000000000001)
  adjusted_storage = 0.0;
 else
  adjusted_storage = ((0) > (((rain_stored + approx_day_end_storage )/2.0) / ( rain_capacity)) ? (0) : (((rain_stored + approx_day_end_storage )/2.0) / ( rain_capacity)));
 stratum_conductance = ((gsurf_slope*adjusted_storage + gsurf_intercept) > (0) ? (gsurf_slope*adjusted_storage + gsurf_intercept) : (0));
 return(stratum_conductance);
}


decompiled_code:
void __fastcall grid_dist(int a1, int a2, int a3, int a4)
{
double v4; // xmm0_8

v4 = (double)((a3 - a4) * (a3 - a4) + (a1 - a2) * (a1 - a2));
if ( v4 < 0.0 )
sqrt(v4);
}

canonical_decompiled_code:
void __fastcall func0(int a1, int a2, int a3, int a4)
{
double v4; // xmm0_8

v4 = (double)((a3 - a4) * (a3 - a4) + (a1 - a2) * (a1 - a2));
if ( v4 < 0.0 )
sqrt(v4);
}

original_code:
static double grid_dist(int _row1, int _row2, int _col1, int _col2) {
 int squaredDist = 0;
 squaredDist = (_row1 - _row2) * (_row1 - _row2)
   + (_col1 - _col2) * (_col1 - _col2);
 return sqrt( (double)squaredDist );
}

variable_types: squaredDist int


decompiled_code:
__int64 __fastcall grid_search(int a1, unsigned int a2, unsigned int a3, signed int a4, int a5, unsigned __int16 (__fastcall *a6)(_QWORD, _QWORD, _QWORD, _QWORD, __int64, int *), double a7, unsigned __int16 (__fastcall *a8)(_QWORD, _QWORD, _QWORD, _QWORD, __int64, unsigned int *, unsigned int *), __int64 a9, unsigned int *a10, unsigned int *a11, __int16 *a12)
{
unsigned int v14; // edx
signed int v15; // ebx
unsigned int v16; // eax
int v17; // esi
signed int v18; // ecx
char v19; // al
unsigned int v20; // ebp
unsigned int v21; // ebx
__int16 v22; // r11
char v23; // al
char v24; // al
signed int i; // ebx
int v26; // eax
unsigned int v27; // ebp
double v28; // xmm1_8
double v29; // xmm1_8
char v30; // al
unsigned int v31; // er10
double v32; // xmm1_8
double v33; // xmm1_8
unsigned __int16 v34; // ax
unsigned __int16 v35; // ax
unsigned __int16 v38; // [rsp+Ch] [rbp-8Ch]
int v39; // [rsp+Ch] [rbp-8Ch]
int v40; // [rsp+Ch] [rbp-8Ch]
unsigned int v41; // [rsp+14h] [rbp-84h]
char v42; // [rsp+1Ah] [rbp-7Eh]
unsigned int v43; // [rsp+1Ch] [rbp-7Ch]
double v44; // [rsp+20h] [rbp-78h]
unsigned int v45; // [rsp+28h] [rbp-70h]
int v46; // [rsp+28h] [rbp-70h]
int v47; // [rsp+28h] [rbp-70h]
int v48; // [rsp+2Ch] [rbp-6Ch]
int v49; // [rsp+30h] [rbp-68h]
__int16 v50; // [rsp+34h] [rbp-64h]
bool v51; // [rsp+37h] [rbp-61h]
int v52; // [rsp+38h] [rbp-60h]
__int16 v53; // [rsp+3Ch] [rbp-5Ch]
unsigned int v56; // [rsp+4Ch] [rbp-4Ch]
unsigned int v57; // [rsp+54h] [rbp-44h] BYREF
unsigned int v58; // [rsp+58h] [rbp-40h] BYREF
int v59[15]; // [rsp+5Ch] [rbp-3Ch] BYREF

if ( !a6 )
{
fwrite("ERROR: Predicate function pointer is NULL.\n", 1uLL, 0x2BuLL, stderr);
return 0;
}
if ( !a9 )
{
fwrite("ERROR: Predicate context pointer is NULL.\n", 1uLL, 0x2AuLL, stderr);
return 0;
}
if ( !a10 )
{
fwrite("ERROR: Return row pointer is NULL.\n", 1uLL, 0x23uLL, stderr);
return 0;
}
if ( !a11 )
{
fwrite("ERROR: Return column pointer is NULL.\n", 1uLL, 0x26uLL, stderr);
return 0;
}
if ( !a12 )
{
fwrite("ERROR: Return found pointer is NULL.\n", 1uLL, 0x25uLL, stderr);
return 0;
}
v57 = 0;
v58 = 0;
if ( a1 <= 1 )
{
v31 = 1;
v50 = 0;
goto LABEL_76;
}
v48 = a3 - 1;
v49 = a3 + 1;
v52 = 2;
v50 = 0;
v42 = 1;
v56 = a2 - a3;
v38 = 1;
v44 = *(double *)&LC1;
while ( 1 )
{
v14 = 0;
v15 = 0;
if ( (int)(v56 + v48) >= 0 )
v14 = v56 + v48;
if ( v48 >= 0 )
v15 = v48;
v16 = v56 + v49;
v45 = v14;
v43 = v15;
if ( (int)(v56 + v49) > a4 )
v16 = a4;
v17 = a5;
v18 = v16;
v41 = v16;
if ( v49 <= a5 )
v17 = v49;
v19 = v38 & 1;
v51 = v18 > (int)(v14 + 1);
if ( v17 >= v15 && v19 )
{
v20 = v15;
v21 = v14;
while ( 1 )
{
v59[0] = 0;
if ( !a6(a2, a3, v21, v20, a9, v59) )
{
LABEL_26:
++v20;
v42 = 0;
v22 = 1;
v23 = 1;
if ( v17 < (int)v20 )
{
LABEL_27:
v38 = v22;
v24 = v51 & v23;
goto LABEL_28;
}
goto LABEL_24;
}
if ( v59[0] )
{
v39 = v59[0];
grid_dist(a2, v21, a3, v20);
v28 = a7;
a7 = (double)v39 * a7;
if ( v44 <= a7 )
{
if ( a7 == v44 )
{
if ( v50 )
{
v50 = 1;
if ( !a8(v57, v58, v21, v20, a9, &v57, &v58) )
{
v38 = 0;
fwrite("ERROR: Error determining tiebreaker.\n", 1uLL, 0x25uLL, stderr);
v59[0] = 0;
v34 = a6(a2, a3, v41, v20, a9, v59);
v22 = 0;
v42 = v34;
if ( !v34 )
goto LABEL_63;
v42 = 0;
goto LABEL_22;
}
}
}
}
else
{
v57 = v21;
v58 = v20;
v50 = 1;
v44 = (double)v39 * v28;
}
}
v59[0] = 0;
if ( !a6(a2, a3, v41, v20, a9, v59) )
goto LABEL_26;
v22 = 1;
LABEL_22:
if ( v59[0] )
{
v53 = v22;
v40 = v59[0];
grid_dist(a2, v41, a3, v20);
v33 = a7;
v22 = v53;
a7 = (double)v40 * a7;
if ( v44 <= a7 )
{
if ( a7 == v44 && v50 )
{
v35 = a8(v57, v58, v41, v20, a9, &v57, &v58);
v22 = v53;
if ( !v35 )
{
fwrite("ERROR: Error determining tiebreaker.\n", 1uLL, 0x25uLL, stderr);
v42 = 0;
v38 = 0;
v30 = 0;
v50 = 1;
goto LABEL_51;
}
v50 = 1;
}
}
else
{
v58 = v20;
v50 = 1;
v57 = v41;
v44 = (double)v40 * v33;
}
}
++v20;
v23 = v22 & 1;
if ( v17 < (int)v20 )
goto LABEL_27;
LABEL_24:
if ( !v23 )
goto LABEL_27;
}
}
v24 = v51 & v19;
LABEL_28:
if ( v24 )
break;
LABEL_63:
v30 = v42 & (v52 < a1);
LABEL_51:
--v48;
++v49;
++v52;
if ( !v30 )
{
LABEL_52:
v31 = v38;
if ( v50 )
goto LABEL_75;
goto LABEL_76;
}
}
for ( i = v45 + 2; ; ++i )
{
v27 = i - 1;
v59[0] = 0;
if ( !a6(a2, a3, (unsigned int)(i - 1), v43, a9, v59) )
{
LABEL_37:
if ( i >= (int)v41 || (v38 & 1) == 0 )
goto LABEL_52;
v42 = 0;
goto LABEL_35;
}
if ( v59[0] )
{
v46 = v59[0];
grid_dist(a2, v27, a3, v43);
v29 = a7;
a7 = (double)v46 * a7;
if ( v44 <= a7 )
{
if ( a7 == v44 )
{
if ( v50 )
{
v50 = 1;
if ( !a8(v57, v58, v27, v43, a9, &v57, &v58) )
{
fwrite("ERROR: Error determining tiebreaker.\n", 1uLL, 0x25uLL, stderr);
v59[0] = 0;
if ( !a6(a2, a3, v27, (unsigned int)v17, a9, v59) )
goto LABEL_74;
v26 = v59[0];
if ( !v59[0] )
{
v38 = 0;
v42 = 0;
LABEL_50:
v30 = v42 & (a1 > v52);
goto LABEL_51;
}
v38 = 0;
v42 = 0;
goto LABEL_55;
}
}
}
}
else
{
v57 = i - 1;
v50 = 1;
v58 = v43;
v44 = (double)v46 * v29;
}
}
v59[0] = 0;
if ( !a6(a2, a3, v27, (unsigned int)v17, a9, v59) )
goto LABEL_37;
v26 = v59[0];
if ( !v59[0] )
goto LABEL_33;
LABEL_55:
v47 = v26;
grid_dist(a2, v27, a3, v17);
v32 = a7;
a7 = (double)v47 * a7;
if ( v44 > a7 )
{
v57 = i - 1;
v50 = 1;
v58 = v17;
v44 = (double)v47 * v32;
goto LABEL_33;
}
if ( a7 == v44 && v50 )
break;
LABEL_33:
if ( (int)v41 <= i || (v38 & 1) == 0 )
goto LABEL_50;
LABEL_35:
v38 = 1;
}
if ( a8(v57, v58, v27, (unsigned int)v17, a9, &v57, &v58) )
{
v50 = 1;
goto LABEL_33;
}
fwrite("ERROR: Error determining tiebreaker.\n", 1uLL, 0x25uLL, stderr);
LABEL_74:
v31 = 0;
LABEL_75:
v50 = 1;
*a10 = v57;
*a11 = v58;
LABEL_76:
*a12 = v50;
return v31;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, unsigned int a2, unsigned int a3, signed int a4, int a5, unsigned __int16 (__fastcall *a6)(_QWORD, _QWORD, _QWORD, _QWORD, __int64, int *), double a7, unsigned __int16 (__fastcall *a8)(_QWORD, _QWORD, _QWORD, _QWORD, __int64, unsigned int *, unsigned int *), __int64 a9, unsigned int *a10, unsigned int *a11, __int16 *a12)
{
unsigned int v14; // edx
signed int v15; // ebx
unsigned int v16; // eax
int v17; // esi
signed int v18; // ecx
char v19; // al
unsigned int v20; // ebp
unsigned int v21; // ebx
__int16 v22; // r11
char v23; // al
char v24; // al
signed int i; // ebx
int v26; // eax
unsigned int v27; // ebp
double v28; // xmm1_8
double v29; // xmm1_8
char v30; // al
unsigned int v31; // er10
double v32; // xmm1_8
double v33; // xmm1_8
unsigned __int16 v34; // ax
unsigned __int16 v35; // ax
unsigned __int16 v38; // [rsp+Ch] [rbp-8Ch]
int v39; // [rsp+Ch] [rbp-8Ch]
int v40; // [rsp+Ch] [rbp-8Ch]
unsigned int v41; // [rsp+14h] [rbp-84h]
char v42; // [rsp+1Ah] [rbp-7Eh]
unsigned int v43; // [rsp+1Ch] [rbp-7Ch]
double v44; // [rsp+20h] [rbp-78h]
unsigned int v45; // [rsp+28h] [rbp-70h]
int v46; // [rsp+28h] [rbp-70h]
int v47; // [rsp+28h] [rbp-70h]
int v48; // [rsp+2Ch] [rbp-6Ch]
int v49; // [rsp+30h] [rbp-68h]
__int16 v50; // [rsp+34h] [rbp-64h]
bool v51; // [rsp+37h] [rbp-61h]
int v52; // [rsp+38h] [rbp-60h]
__int16 v53; // [rsp+3Ch] [rbp-5Ch]
unsigned int v56; // [rsp+4Ch] [rbp-4Ch]
unsigned int v57; // [rsp+54h] [rbp-44h] BYREF
unsigned int v58; // [rsp+58h] [rbp-40h] BYREF
int v59[15]; // [rsp+5Ch] [rbp-3Ch] BYREF

if ( !a6 )
{
fwrite("ERROR: Predicate function pointer is NULL.\n", 1uLL, 0x2BuLL, stderr);
return 0;
}
if ( !a9 )
{
fwrite("ERROR: Predicate context pointer is NULL.\n", 1uLL, 0x2AuLL, stderr);
return 0;
}
if ( !a10 )
{
fwrite("ERROR: Return row pointer is NULL.\n", 1uLL, 0x23uLL, stderr);
return 0;
}
if ( !a11 )
{
fwrite("ERROR: Return column pointer is NULL.\n", 1uLL, 0x26uLL, stderr);
return 0;
}
if ( !a12 )
{
fwrite("ERROR: Return found pointer is NULL.\n", 1uLL, 0x25uLL, stderr);
return 0;
}
v57 = 0;
v58 = 0;
if ( a1 <= 1 )
{
v31 = 1;
v50 = 0;
goto LABEL_76;
}
v48 = a3 - 1;
v49 = a3 + 1;
v52 = 2;
v50 = 0;
v42 = 1;
v56 = a2 - a3;
v38 = 1;
v44 = *(double *)&LC1;
while ( 1 )
{
v14 = 0;
v15 = 0;
if ( (int)(v56 + v48) >= 0 )
v14 = v56 + v48;
if ( v48 >= 0 )
v15 = v48;
v16 = v56 + v49;
v45 = v14;
v43 = v15;
if ( (int)(v56 + v49) > a4 )
v16 = a4;
v17 = a5;
v18 = v16;
v41 = v16;
if ( v49 <= a5 )
v17 = v49;
v19 = v38 & 1;
v51 = v18 > (int)(v14 + 1);
if ( v17 >= v15 && v19 )
{
v20 = v15;
v21 = v14;
while ( 1 )
{
v59[0] = 0;
if ( !a6(a2, a3, v21, v20, a9, v59) )
{
LABEL_26:
++v20;
v42 = 0;
v22 = 1;
v23 = 1;
if ( v17 < (int)v20 )
{
LABEL_27:
v38 = v22;
v24 = v51 & v23;
goto LABEL_28;
}
goto LABEL_24;
}
if ( v59[0] )
{
v39 = v59[0];
func0(a2, v21, a3, v20);
v28 = a7;
a7 = (double)v39 * a7;
if ( v44 <= a7 )
{
if ( a7 == v44 )
{
if ( v50 )
{
v50 = 1;
if ( !a8(v57, v58, v21, v20, a9, &v57, &v58) )
{
v38 = 0;
fwrite("ERROR: Error determining tiebreaker.\n", 1uLL, 0x25uLL, stderr);
v59[0] = 0;
v34 = a6(a2, a3, v41, v20, a9, v59);
v22 = 0;
v42 = v34;
if ( !v34 )
goto LABEL_63;
v42 = 0;
goto LABEL_22;
}
}
}
}
else
{
v57 = v21;
v58 = v20;
v50 = 1;
v44 = (double)v39 * v28;
}
}
v59[0] = 0;
if ( !a6(a2, a3, v41, v20, a9, v59) )
goto LABEL_26;
v22 = 1;
LABEL_22:
if ( v59[0] )
{
v53 = v22;
v40 = v59[0];
func0(a2, v41, a3, v20);
v33 = a7;
v22 = v53;
a7 = (double)v40 * a7;
if ( v44 <= a7 )
{
if ( a7 == v44 && v50 )
{
v35 = a8(v57, v58, v41, v20, a9, &v57, &v58);
v22 = v53;
if ( !v35 )
{
fwrite("ERROR: Error determining tiebreaker.\n", 1uLL, 0x25uLL, stderr);
v42 = 0;
v38 = 0;
v30 = 0;
v50 = 1;
goto LABEL_51;
}
v50 = 1;
}
}
else
{
v58 = v20;
v50 = 1;
v57 = v41;
v44 = (double)v40 * v33;
}
}
++v20;
v23 = v22 & 1;
if ( v17 < (int)v20 )
goto LABEL_27;
LABEL_24:
if ( !v23 )
goto LABEL_27;
}
}
v24 = v51 & v19;
LABEL_28:
if ( v24 )
break;
LABEL_63:
v30 = v42 & (v52 < a1);
LABEL_51:
--v48;
++v49;
++v52;
if ( !v30 )
{
LABEL_52:
v31 = v38;
if ( v50 )
goto LABEL_75;
goto LABEL_76;
}
}
for ( i = v45 + 2; ; ++i )
{
v27 = i - 1;
v59[0] = 0;
if ( !a6(a2, a3, (unsigned int)(i - 1), v43, a9, v59) )
{
LABEL_37:
if ( i >= (int)v41 || (v38 & 1) == 0 )
goto LABEL_52;
v42 = 0;
goto LABEL_35;
}
if ( v59[0] )
{
v46 = v59[0];
func0(a2, v27, a3, v43);
v29 = a7;
a7 = (double)v46 * a7;
if ( v44 <= a7 )
{
if ( a7 == v44 )
{
if ( v50 )
{
v50 = 1;
if ( !a8(v57, v58, v27, v43, a9, &v57, &v58) )
{
fwrite("ERROR: Error determining tiebreaker.\n", 1uLL, 0x25uLL, stderr);
v59[0] = 0;
if ( !a6(a2, a3, v27, (unsigned int)v17, a9, v59) )
goto LABEL_74;
v26 = v59[0];
if ( !v59[0] )
{
v38 = 0;
v42 = 0;
LABEL_50:
v30 = v42 & (a1 > v52);
goto LABEL_51;
}
v38 = 0;
v42 = 0;
goto LABEL_55;
}
}
}
}
else
{
v57 = i - 1;
v50 = 1;
v58 = v43;
v44 = (double)v46 * v29;
}
}
v59[0] = 0;
if ( !a6(a2, a3, v27, (unsigned int)v17, a9, v59) )
goto LABEL_37;
v26 = v59[0];
if ( !v59[0] )
goto LABEL_33;
LABEL_55:
v47 = v26;
func0(a2, v27, a3, v17);
v32 = a7;
a7 = (double)v47 * a7;
if ( v44 > a7 )
{
v57 = i - 1;
v50 = 1;
v58 = v17;
v44 = (double)v47 * v32;
goto LABEL_33;
}
if ( a7 == v44 && v50 )
break;
LABEL_33:
if ( (int)v41 <= i || (v38 & 1) == 0 )
goto LABEL_50;
LABEL_35:
v38 = 1;
}
if ( a8(v57, v58, v27, (unsigned int)v17, a9, &v57, &v58) )
{
v50 = 1;
goto LABEL_33;
}
fwrite("ERROR: Error determining tiebreaker.\n", 1uLL, 0x25uLL, stderr);
LABEL_74:
v31 = 0;
LABEL_75:
v50 = 1;
*a10 = v57;
*a11 = v58;
LABEL_76:
*a12 = v50;
return v31;
}

original_code:
bool grid_search(int _max_dist, int _start_row, int _start_col, int _max_row, int _max_col,
  search_predicate_t _predicate, search_predicate_tiebreaker_t _tiebreaker, void* _context, int* _rtn_row,
  int* _rtn_col, bool* _rtn_found) {
 bool keepSearching = true;
 bool result = true;
 if (_predicate == 0) {
  fprintf(stderr, "ERROR: Predicate function pointer is NULL.\n");
  result = false;
  keepSearching = false;
 } else if (_context == 0) {
  fprintf(stderr, "ERROR: Predicate context pointer is NULL.\n");
  result = false;
  keepSearching = false;
 } else if (_rtn_row == 0) {
  fprintf(stderr, "ERROR: Return row pointer is NULL.\n");
  result = false;
  keepSearching = false;
 } else if (_rtn_col == 0) {
  fprintf(stderr, "ERROR: Return column pointer is NULL.\n");
  result = false;
  keepSearching = false;
 } else if (_rtn_found == 0) {
  fprintf(stderr, "ERROR: Return found pointer is NULL.\n");
  result = false;
  keepSearching = false;
 } else {
  bool found = false;
  int found_row = 0;
  int found_col = 0;
  double min_dist = (double)0x7fffffff;
  for (int offset = 1; keepSearching && offset < _max_dist; ++offset) {
   int min_row = _start_row - offset;
   if (min_row < 0) min_row = 0;
   int min_col = _start_col - offset;
   if (min_col < 0) min_col = 0;
   int max_row = _start_row + offset;
   if (max_row > _max_row) max_row = _max_row;
   int max_col = _start_col + offset;
   if (max_col > _max_col) max_col = _max_col;
   for (int col = min_col; result && col <= max_col; ++col) {
    int vote = 0;
    if (!_predicate(_start_row, _start_col, min_row, col, _context, &vote)) {
     keepSearching = false;
    } else {
     if (vote) {
      double dist = vote * grid_dist(_start_row, min_row,
        _start_col, col);
      if (dist < min_dist) {
       found_row = min_row;
       found_col = col;
       min_dist = dist;
       found = true;
      } else if (dist == min_dist && found) {
       if ( !_tiebreaker(found_row, found_col, min_row, col, _context, &found_row, &found_col) ) {
        fprintf(stderr, "ERROR: Error determining tiebreaker.\n");
        result = false;
        keepSearching = false;
       }
      }
     }
     vote = 0;
     if (!_predicate(_start_row, _start_col, max_row, col, _context, &vote)) {
      keepSearching = false;
     } else {
      if (vote) {
       double dist = vote * grid_dist(_start_row, max_row,
         _start_col, col);
       if (dist < min_dist) {
        found_row = max_row;
        found_col = col;
        min_dist = dist;
        found = true;
       } else if (dist == min_dist && found) {
        if ( !_tiebreaker(found_row, found_col, max_row, col, _context, &found_row, &found_col) ) {
         fprintf(stderr, "ERROR: Error determining tiebreaker.\n");
         result = false;
         keepSearching = false;
        }
       }
      }
     }
    }
   }
   for (int row = min_row + 1; result && row <= max_row - 1; ++row) {
    int vote = 0;
    if (!_predicate(_start_row, _start_col, row, min_col, _context, &vote)) {
     keepSearching = false;
    } else {
     if (vote) {
      double dist = vote * grid_dist(_start_row, row, _start_col,
        min_col);
      if (dist < min_dist) {
       found_row = row;
       found_col = min_col;
       min_dist = dist;
       found = true;
      } else if (dist == min_dist && found) {
       if ( !_tiebreaker(found_row, found_col, row, min_col, _context, &found_row, &found_col) ) {
        fprintf(stderr, "ERROR: Error determining tiebreaker.\n");
        result = false;
        keepSearching = false;
       }
      }
     }
     vote = 0;
     if (!_predicate(_start_row, _start_col, row, max_col, _context, &vote)) {
      keepSearching = false;
     } else {
      if (vote) {
       double dist = vote * grid_dist(_start_row, row, _start_col,
         max_col);
       if (dist < min_dist) {
        found_row = row;
        found_col = max_col;
        min_dist = dist;
        found = true;
       } else if (dist == min_dist && found) {
        if ( !_tiebreaker(found_row, found_col, row, max_col, _context, &found_row, &found_col) ) {
         fprintf(stderr, "ERROR: Error determining tiebreaker.\n");
         result = false;
         keepSearching = false;
        }
       }
      }
     }
    }
   }
  }
  if (found) {
   *_rtn_row = found_row;
   *_rtn_col = found_col;
  }
  *_rtn_found = found;
 }
 return result;
}

canonical_original_code:
short grid_search(int _max_dist, int _start_row, int _start_col, int _max_row, int _max_col, short (*_predicate)(int, int, int, int, void *, int *), short (*_tiebreaker)(int, int, int, int, void *, int *, int *), void *_context, int *_rtn_row, int *_rtn_col, short *_rtn_found) {
 short keepSearching = true;
 short result = true;
 if (_predicate == 0) {
  fprintf(stderr, "ERROR: Predicate function pointer is NULL.\n");
  result = false;
  keepSearching = false;
 } else if (_context == 0) {
  fprintf(stderr, "ERROR: Predicate context pointer is NULL.\n");
  result = false;
  keepSearching = false;
 } else if (_rtn_row == 0) {
  fprintf(stderr, "ERROR: Return row pointer is NULL.\n");
  result = false;
  keepSearching = false;
 } else if (_rtn_col == 0) {
  fprintf(stderr, "ERROR: Return column pointer is NULL.\n");
  result = false;
  keepSearching = false;
 } else if (_rtn_found == 0) {
  fprintf(stderr, "ERROR: Return found pointer is NULL.\n");
  result = false;
  keepSearching = false;
 } else {
  short found = false;
  int found_row = 0;
  int found_col = 0;
  double min_dist = (double)0x7fffffff;
  for (int offset = 1; keepSearching && offset < _max_dist; ++offset) {
   int min_row = _start_row - offset;
   if (min_row < 0) min_row = 0;
   int min_col = _start_col - offset;
   if (min_col < 0) min_col = 0;
   int max_row = _start_row + offset;
   if (max_row > _max_row) max_row = _max_row;
   int max_col = _start_col + offset;
   if (max_col > _max_col) max_col = _max_col;
   for (int col = min_col; result && col <= max_col; ++col) {
    int vote = 0;
    if (!_predicate(_start_row, _start_col, min_row, col, _context, &vote)) {
     keepSearching = false;
    } else {
     if (vote) {
      double dist = vote * grid_dist(_start_row, min_row,
        _start_col, col);
      if (dist < min_dist) {
       found_row = min_row;
       found_col = col;
       min_dist = dist;
       found = true;
      } else if (dist == min_dist && found) {
       if ( !_tiebreaker(found_row, found_col, min_row, col, _context, &found_row, &found_col) ) {
        fprintf(stderr, "ERROR: Error determining tiebreaker.\n");
        result = false;
        keepSearching = false;
       }
      }
     }
     vote = 0;
     if (!_predicate(_start_row, _start_col, max_row, col, _context, &vote)) {
      keepSearching = false;
     } else {
      if (vote) {
       double dist = vote * grid_dist(_start_row, max_row,
         _start_col, col);
       if (dist < min_dist) {
        found_row = max_row;
        found_col = col;
        min_dist = dist;
        found = true;
       } else if (dist == min_dist && found) {
        if ( !_tiebreaker(found_row, found_col, max_row, col, _context, &found_row, &found_col) ) {
         fprintf(stderr, "ERROR: Error determining tiebreaker.\n");
         result = false;
         keepSearching = false;
        }
       }
      }
     }
    }
   }
   for (int row = min_row + 1; result && row <= max_row - 1; ++row) {
    int vote = 0;
    if (!_predicate(_start_row, _start_col, row, min_col, _context, &vote)) {
     keepSearching = false;
    } else {
     if (vote) {
      double dist = vote * grid_dist(_start_row, row, _start_col,
        min_col);
      if (dist < min_dist) {
       found_row = row;
       found_col = min_col;
       min_dist = dist;
       found = true;
      } else if (dist == min_dist && found) {
       if ( !_tiebreaker(found_row, found_col, row, min_col, _context, &found_row, &found_col) ) {
        fprintf(stderr, "ERROR: Error determining tiebreaker.\n");
        result = false;
        keepSearching = false;
       }
      }
     }
     vote = 0;
     if (!_predicate(_start_row, _start_col, row, max_col, _context, &vote)) {
      keepSearching = false;
     } else {
      if (vote) {
       double dist = vote * grid_dist(_start_row, row, _start_col,
         max_col);
       if (dist < min_dist) {
        found_row = row;
        found_col = max_col;
        min_dist = dist;
        found = true;
       } else if (dist == min_dist && found) {
        if ( !_tiebreaker(found_row, found_col, row, max_col, _context, &found_row, &found_col) ) {
         fprintf(stderr, "ERROR: Error determining tiebreaker.\n");
         result = false;
         keepSearching = false;
        }
       }
      }
     }
    }
   }
  }
  if (found) {
   *_rtn_row = found_row;
   *_rtn_col = found_col;
  }
  *_rtn_found = found;
 }
 return result;
}

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

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

variable_types: keepSearching short

variable_types: found short

variable_types: offset int

variable_types: col int

variable_types: vote int

variable_types: dist double

variable_types: row int


original_code:
double compute_N_leached(int verbose_flag,
   double total_nitrate,
   double Qout,
   double s1,
   double s2,
   double m,
   double gamma,
   double n_0,
   double p,
   double N_decay_rate,
   double z2_N,
   double z2_water,
   double N_absorption_rate,
   double *transmissivity)
 {
     double compute_delta_water(
                int,
                double,
                double,
                double,
                double,
                double);
 double compute_z_final(
  int,
  double,
  double,
  double,
  double,
  double);
 double compute_N_absorbed(
  int,
  double,
  double,
  double,
  double,
  double);
 int didx_bot, didx_top;
 double navail, nleached,nabsorbed;
 double theta, sat_deficit;
 double Q, Qtotal;
 double z1, z2;
 double available_water,septic_depth;
 nleached = 0.0;
 Qtotal = 0.0;
 nabsorbed = 0.0;
 navail = 0.0;
 if (Qout > 0.000000001) {
 if (s1 < 0.0) s1 = 0.0;
 if (s2 < s1) s2 = s1;
 if ((s1 == 0.0) && (s2 == 0.0)) {
  z2 = -1.0 * p * log (1 - (Qout) / (p * n_0));
  if (z2 > z2_N)
   z2 = z2_N;
  z1 = 0.0;
  if (N_decay_rate > 0.000000001) {
   navail = total_nitrate
    / (1.0 - exp(-1.0 * N_decay_rate * z2_N) )
    * (exp(-1.0 * N_decay_rate * z1)
    - exp(-1.0 * N_decay_rate * (z2)));
  }
  else {
   navail = total_nitrate * (z2-z1)/z2_N;
  }
  if (navail > total_nitrate) navail=total_nitrate;
  nabsorbed=compute_N_absorbed(verbose_flag,
      z1,
      z2,
      N_absorption_rate,
      p,
      n_0);
  if (nabsorbed > navail) {
   navail=0;
   }
  else
    nleached = navail-nabsorbed;
  if (nleached > navail) nleached=navail;
 }
 else {
 z2 = compute_z_final(
   verbose_flag,
   n_0,
   p,
   z2_water,
   0.0,
   -s2);
 z1 = compute_z_final(
   verbose_flag,
   n_0,
   p,
   z2_water,
   0.0,
   -s1);
 if (N_decay_rate > 0.0) {
  navail = total_nitrate
   / (1.0 - exp(-1.0 * N_decay_rate * z2_N) )
   * (exp(-1.0 * N_decay_rate * z1)
   - exp(-1.0 * N_decay_rate * (z2)));
  }
 else {
   septic_depth = -1.0*N_decay_rate;
   if (z1 > septic_depth)
    navail = 0.0;
   else
    navail = total_nitrate * (z2-z1)/(z2_N - septic_depth);
  }
  if (navail > total_nitrate) navail=total_nitrate;
  available_water = compute_delta_water(
   verbose_flag,
   n_0,p,z2_water,
   z2,
   z1);
  nabsorbed=compute_N_absorbed(verbose_flag,
   z1,
   z2,
   N_absorption_rate,
   p,
   n_0);
  if (nabsorbed > navail) {
    navail=0;
  }
  else navail = navail-nabsorbed;
  if (available_water > 0.000000001) {
   nleached = navail * Qout/available_water;
  }
  else nleached = 0.0;
     }
 }
 if (nleached > navail) nleached=navail;
 nleached = ((nleached) > (0.0) ? (nleached) : (0.0));
 return(nleached);
}

canonical_original_code:
double compute_N_leached(int verbose_flag, double total_nitrate, double Qout, double s1, double s2, double m, double gamma, double n_0, double p, double N_decay_rate, double z2_N, double z2_water, double N_absorption_rate, double *transmissivity)
 {
     double compute_delta_water(int, double, double, double, double, double);
 double compute_z_final(int, double, double, double, double, double);
 double compute_N_absorbed(int, double, double, double, double, double);
 int didx_bot; int didx_top;
 double navail; double nleached; double nabsorbed;
 double theta; double sat_deficit;
 double Q; double Qtotal;
 double z1; double z2;
 double available_water; double septic_depth;
 nleached = 0.0;
 Qtotal = 0.0;
 nabsorbed = 0.0;
 navail = 0.0;
 if (Qout > 0.000000001) {
 if (s1 < 0.0) s1 = 0.0;
 if (s2 < s1) s2 = s1;
 if ((s1 == 0.0) && (s2 == 0.0)) {
  z2 = -1.0 * p * log (1 - (Qout) / (p * n_0));
  if (z2 > z2_N)
   z2 = z2_N;
  z1 = 0.0;
  if (N_decay_rate > 0.000000001) {
   navail = total_nitrate
    / (1.0 - exp(-1.0 * N_decay_rate * z2_N) )
    * (exp(-1.0 * N_decay_rate * z1)
    - exp(-1.0 * N_decay_rate * (z2)));
  }
  else {
   navail = total_nitrate * (z2-z1)/z2_N;
  }
  if (navail > total_nitrate) navail=total_nitrate;
  nabsorbed=compute_N_absorbed(verbose_flag,
      z1,
      z2,
      N_absorption_rate,
      p,
      n_0);
  if (nabsorbed > navail) {
   navail=0;
   }
  else
    nleached = navail-nabsorbed;
  if (nleached > navail) nleached=navail;
 }
 else {
 z2 = compute_z_final(
   verbose_flag,
   n_0,
   p,
   z2_water,
   0.0,
   -s2);
 z1 = compute_z_final(
   verbose_flag,
   n_0,
   p,
   z2_water,
   0.0,
   -s1);
 if (N_decay_rate > 0.0) {
  navail = total_nitrate
   / (1.0 - exp(-1.0 * N_decay_rate * z2_N) )
   * (exp(-1.0 * N_decay_rate * z1)
   - exp(-1.0 * N_decay_rate * (z2)));
  }
 else {
   septic_depth = -1.0*N_decay_rate;
   if (z1 > septic_depth)
    navail = 0.0;
   else
    navail = total_nitrate * (z2-z1)/(z2_N - septic_depth);
  }
  if (navail > total_nitrate) navail=total_nitrate;
  available_water = compute_delta_water(
   verbose_flag,
   n_0,p,z2_water,
   z2,
   z1);
  nabsorbed=compute_N_absorbed(verbose_flag,
   z1,
   z2,
   N_absorption_rate,
   p,
   n_0);
  if (nabsorbed > navail) {
    navail=0;
  }
  else navail = navail-nabsorbed;
  if (available_water > 0.000000001) {
   nleached = navail * Qout/available_water;
  }
  else nleached = 0.0;
     }
 }
 if (nleached > navail) nleached=navail;
 nleached = ((nleached) > (0.0) ? (nleached) : (0.0));
 return(nleached);
}

variable_types: Qout double

variable_types: m double

variable_types: gamma double

variable_types: p double

variable_types:
transmissivity
double *

variable_types: double (int, double, double, double, double, double)

variable_types: navail double

variable_types: nleached double

variable_types: theta double

variable_types: Q double

variable_types: Qtotal double


decompiled_code:
__int64 __fastcall find_patch(__int64 a1, unsigned int a2, unsigned int a3, unsigned int a4)
{
return patchHashTableGet(a1, __PAIR64__(a3, a2), a4);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, unsigned int a2, unsigned int a3, unsigned int a4)
{
return patchHashTableGet(a1, __PAIR64__(a3, a2), a4);
}

original_code:
int find_patch(PatchTable_t *patchTable, int patchID, int zoneID, int hillID) {
 PatchKey_t k = { patchID, zoneID, hillID };
 return (int)patchHashTableGet(patchTable, k);
}

canonical_original_code:
int find_patch(struct table_s *patchTable, int patchID, int zoneID, int hillID) {
 struct key_s k = { patchID, zoneID, hillID };
 return (int)patchHashTableGet(patchTable, k);
}

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: patchID int

variable_types: zoneID int

variable_types: hillID int

return_type: int

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; }


keyIsEmpty

decompiled_code:
_BOOL8 __fastcall keyIsEmpty(__int64 a1)
{
return a1 == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(__int64 a1)
{
return a1 == 0;
}

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 *


keysAreEqual

decompiled_code:
_BOOL8 __fastcall keysAreEqual(const char *a1, const char *a2)
{
return strcmp(a1, a2) == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(const char *a1, const char *a2)
{
return strcmp(a1, a2) == 0;
}

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;
}


addToKeyList

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

result = stringListAppend(*(_QWORD *)(a1 + 16));
if ( !*(_QWORD *)(a1 + 16) )
*(_QWORD *)(a1 + 16) = result;
return result;
}

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

result = stringListAppend(*(_QWORD *)(a1 + 16));
if ( !*(_QWORD *)(a1 + 16) )
*(_QWORD *)(a1 + 16) = result;
return result;
}

original_code:
static StringList_t *addToKeyList(Dictionary_t *table, char *key) {
 StringList_t *elem = stringListAppend(table->keys, key);
 if (table->keys == ((void *)0)) {
  table->keys = elem;
 }
 return elem;
}

canonical_original_code:
static struct string_list_s *addToKeyList(struct dict_s *table, char *key) {
 struct string_list_s *elem = stringListAppend(table->keys, key);
 if (table->keys == ((void *)0)) {
  table->keys = elem;
 }
 return elem;
}

variable_types: struct dict_s { unsigned long size; unsigned long numEntries; struct string_list_s *keys; struct dict_entry_s { char *key; struct dict_value_s { enum DataType { DATA_TYPE_UNDEFINED=0, DATA_TYPE_BOOL=1, DATA_TYPE_CHAR=2, DATA_TYPE_STRING=3, DATA_TYPE_INT=4, DATA_TYPE_LONG=5, DATA_TYPE_LONG_ARRAY=6, DATA_TYPE_FLOAT=7, DATA_TYPE_DOUBLE=8, DATA_TYPE_DOUBLE_ARRAY=9, DATA_TYPE_FILE_PTR=10, DATA_TYPE_STRUCT=11, DATA_TYPE_STRUCT_PTR=12, DATA_TYPE_STRUCT_PTR_ARRAY=13 } data_type; unsigned long offset; struct dict_s *sub_struct_index; } *value; struct dict_entry_s *next; } *entries; } *

variable_types: struct string_list_s { char *str; struct string_list_s *next; } *

user_defined_types: struct dict_s { unsigned long size; unsigned long numEntries; struct string_list_s *keys; struct dict_entry_s *entries; }

user_defined_types: struct dict_entry_s { char *key; struct dict_value_s *value; struct dict_entry_s *next; }

user_defined_types: struct dict_value_s { enum DataType data_type; unsigned long offset; struct dict_s *sub_struct_index; }


freeDictionary

decompiled_code:
void __fastcall freeDictionary(void *ptr)
{
_QWORD *v2; // rdi
unsigned __int64 v3; // r12
_QWORD *v4; // rbx
_QWORD *v5; // rbp
void *v6; // rdi

if ( ptr )
{
freeStringList(*((_QWORD *)ptr + 2));
v2 = (_QWORD *)*((_QWORD *)ptr + 3);
if ( *(_QWORD *)ptr )
{
v3 = 0LL;
do
{
v4 = (_QWORD *)v2[3 * v3 + 2];
if ( v4 )
{
do
{
v5 = v4;
v4 = (_QWORD *)v4[2];
v6 = (void *)v5[1];
if ( v6 )
free(v6);
free(v5);
}
while ( v4 );
v2 = (_QWORD *)*((_QWORD *)ptr + 3);
}
++v3;
}
while ( *(_QWORD *)ptr > v3 );
}
free(v2);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func4(void *ptr)
{
_QWORD *v2; // rdi
unsigned __int64 v3; // r12
_QWORD *v4; // rbx
_QWORD *v5; // rbp
void *v6; // rdi

if ( ptr )
{
freeStringList(*((_QWORD *)ptr + 2));
v2 = (_QWORD *)*((_QWORD *)ptr + 3);
if ( *(_QWORD *)ptr )
{
v3 = 0LL;
do
{
v4 = (_QWORD *)v2[3 * v3 + 2];
if ( v4 )
{
do
{
v5 = v4;
v4 = (_QWORD *)v4[2];
v6 = (void *)v5[1];
if ( v6 )
free(v6);
free(v5);
}
while ( v4 );
v2 = (_QWORD *)*((_QWORD *)ptr + 3);
}
++v3;
}
while ( *(_QWORD *)ptr > v3 );
}
free(v2);
free(ptr);
}
}

original_code:
void freeDictionary(Dictionary_t *table) {
 if (table == ((void *)0)) return;
 freeStringList(table->keys);
 DictionaryEntry_t *entry;
 DictionaryEntry_t *tmpEntry;
 for (size_t i = 0; i < table->size; i++) {
  entry = table->entries + i;
  tmpEntry = entry->next;
  while (tmpEntry != ((void *)0)) {
   entry = tmpEntry;
   tmpEntry = entry->next;
   if (entry->value) free(entry->value);
   free(entry);
  }
 }
 free(table->entries);
 free(table);
}

canonical_original_code:
void freeDictionary(struct dict_s *table) {
 if (table == ((void *)0)) return;
 freeStringList(table->keys);
 struct dict_entry_s *entry;
 struct dict_entry_s *tmpEntry;
 for (unsigned long i = 0; i < table->size; i++) {
  entry = table->entries + i;
  tmpEntry = entry->next;
  while (tmpEntry != ((void *)0)) {
   entry = tmpEntry;
   tmpEntry = entry->next;
   if (entry->value) free(entry->value);
   free(entry);
  }
 }
 free(table->entries);
 free(table);
}

variable_types: struct dict_s { unsigned long size; unsigned long numEntries; struct string_list_s { char *str; struct string_list_s *next; } *keys; struct dict_entry_s { char *key; struct dict_value_s { enum DataType { DATA_TYPE_UNDEFINED=0, DATA_TYPE_BOOL=1, DATA_TYPE_CHAR=2, DATA_TYPE_STRING=3, DATA_TYPE_INT=4, DATA_TYPE_LONG=5, DATA_TYPE_LONG_ARRAY=6, DATA_TYPE_FLOAT=7, DATA_TYPE_DOUBLE=8, DATA_TYPE_DOUBLE_ARRAY=9, DATA_TYPE_FILE_PTR=10, DATA_TYPE_STRUCT=11, DATA_TYPE_STRUCT_PTR=12, DATA_TYPE_STRUCT_PTR_ARRAY=13 } data_type; unsigned long offset; struct dict_s *sub_struct_index; } *value; struct dict_entry_s *next; } *entries; } *

variable_types: struct dict_entry_s { char *key; struct dict_value_s { enum DataType { DATA_TYPE_UNDEFINED=0, DATA_TYPE_BOOL=1, DATA_TYPE_CHAR=2, DATA_TYPE_STRING=3, DATA_TYPE_INT=4, DATA_TYPE_LONG=5, DATA_TYPE_LONG_ARRAY=6, DATA_TYPE_FLOAT=7, DATA_TYPE_DOUBLE=8, DATA_TYPE_DOUBLE_ARRAY=9, DATA_TYPE_FILE_PTR=10, DATA_TYPE_STRUCT=11, DATA_TYPE_STRUCT_PTR=12, DATA_TYPE_STRUCT_PTR_ARRAY=13 } data_type; unsigned long offset; struct dict_s { unsigned long size; unsigned long numEntries; struct string_list_s { char *str; struct string_list_s *next; } *keys; struct dict_entry_s *entries; } *sub_struct_index; } *value; struct dict_entry_s *next; } *

variable_types:
i
unsigned long

return_type: void


dictionaryValueEquals

decompiled_code:
_BOOL8 __fastcall dictionaryValueEquals(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, __int64 a8, int a9, int a10, __int64 a11)
{
_BOOL8 result; // rax

result = 0LL;
if ( a7 == a10 )
result = a8 == a11;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(__int64 a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5, __int64 a6, int a7, __int64 a8, int a9, int a10, __int64 a11)
{
_BOOL8 result; // rax

result = 0LL;
if ( a7 == a10 )
result = a8 == a11;
return result;
}

original_code:
bool dictionaryValueEquals(DictionaryValue_t first, DictionaryValue_t second) {
 if (first.data_type != second.data_type) return false;
 if (first.offset != second.offset) return false;
 return true;
}

canonical_original_code:
short dictionaryValueEquals(struct dict_value_s first, struct dict_value_s second) {
 if (first.data_type != second.data_type) return false;
 if (first.offset != second.offset) return false;
 return true;
}

variable_types: struct dict_value_s { enum DataType { DATA_TYPE_UNDEFINED=0, DATA_TYPE_BOOL=1, DATA_TYPE_CHAR=2, DATA_TYPE_STRING=3, DATA_TYPE_INT=4, DATA_TYPE_LONG=5, DATA_TYPE_LONG_ARRAY=6, DATA_TYPE_FLOAT=7, DATA_TYPE_DOUBLE=8, DATA_TYPE_DOUBLE_ARRAY=9, DATA_TYPE_FILE_PTR=10, DATA_TYPE_STRUCT=11, DATA_TYPE_STRUCT_PTR=12, DATA_TYPE_STRUCT_PTR_ARRAY=13 } data_type; unsigned long offset; struct dict_s { unsigned long size; unsigned long numEntries; struct string_list_s { char *str; struct string_list_s *next; } *keys; struct dict_entry_s { char *key; struct dict_value_s *value; struct dict_entry_s *next; } *entries; } *sub_struct_index; }

variable_types:
second
struct dict_value_s


dictionaryGet

decompiled_code:
__int64 __fastcall dictionaryGet(unsigned __int64 *a1, char *a2)
{
unsigned __int64 v2; // rax
__int64 v3; // r9
__int64 v4; // r12

if ( !a1 )
_assert_fail("table != NULL", "util/dictionary.c", 0x85u, "dictionaryGet");
v2 = hash(a2, *a1);
v4 = *(_QWORD *)(v3 + 24) + 24 * v2;
if ( !v4 )
return v4;
while ( !*(_QWORD *)v4 || !keysAreEqual(*(const char **)v4, a2) )
{
v4 = *(_QWORD *)(v4 + 16);
if ( !v4 )
return v4;
}
return *(_QWORD *)(v4 + 8);
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned __int64 *a1, char *a2)
{
unsigned __int64 v2; // rax
__int64 v3; // r9
__int64 v4; // r12

if ( !a1 )
_assert_fail("table != NULL", "util/dictionary.c", 0x85u, "dictionaryGet");
v2 = func0(a2, *a1);
v4 = *(_QWORD *)(v3 + 24) + 24 * v2;
if ( !v4 )
return v4;
while ( !*(_QWORD *)v4 || !func2(*(const char **)v4, a2) )
{
v4 = *(_QWORD *)(v4 + 16);
if ( !v4 )
return v4;
}
return *(_QWORD *)(v4 + 8);
}

original_code:
DictionaryValue_t *dictionaryGet(Dictionary_t *table, char *key) {
 ((table != ((void *)0)) ? (void) (0) : __assert_fail ("table != NULL", "util/dictionary.c", 133, __extension__ __PRETTY_FUNCTION__));
 DictionaryTableKey_t hash = _hash(key, table->size);
 DictionaryEntry_t *e = table->entries + hash;
 while (e) {
  if (e->key != ((void *)0) && keysAreEqual(e->key, key)) {
   return e->value;
  }
  e = e->next;
 }
 return ((void *)0);
}

canonical_original_code:
struct dict_value_s *dictionaryGet(struct dict_s *table, char *key) {
 ((table != ((void *)0)) ? (void) (0) : __assert_fail ("table != NULL", "util/dictionary.c", 133, __extension__ __PRETTY_FUNCTION__));
 unsigned long hash = _hash(key, table->size);
 struct dict_entry_s *e = table->entries + hash;
 while (e) {
  if (e->key != ((void *)0) && keysAreEqual(e->key, key)) {
   return e->value;
  }
  e = e->next;
 }
 return ((void *)0);
}

variable_types:
table
struct dict_s *

variable_types:
hash
unsigned long

return_type: struct dict_value_s { enum DataType { DATA_TYPE_UNDEFINED=0, DATA_TYPE_BOOL=1, DATA_TYPE_CHAR=2, DATA_TYPE_STRING=3, DATA_TYPE_INT=4, DATA_TYPE_LONG=5, DATA_TYPE_LONG_ARRAY=6, DATA_TYPE_FLOAT=7, DATA_TYPE_DOUBLE=8, DATA_TYPE_DOUBLE_ARRAY=9, DATA_TYPE_FILE_PTR=10, DATA_TYPE_STRUCT=11, DATA_TYPE_STRUCT_PTR=12, DATA_TYPE_STRUCT_PTR_ARRAY=13 } data_type; unsigned long offset; struct dict_s { unsigned long size; unsigned long numEntries; struct string_list_s { char *str; struct string_list_s *next; } *keys; struct dict_entry_s { char *key; struct dict_value_s *value; struct dict_entry_s *next; } *entries; } *sub_struct_index; } *


printDictionary

decompiled_code:
size_t __fastcall printDictionary(unsigned __int64 *a1)
{
unsigned __int64 v1; // rbp
__int64 v2; // rbx
const char *v3; // rdx
unsigned int *v4; // rax
__int64 v5; // r8
__int64 i; // rcx
unsigned int *v7; // rax

v1 = 0LL;
fprintf(stderr, "Dictionary@%p {\n", a1);
if ( *a1 )
{
do
{
while ( 1 )
{
v2 = a1[3] + 24 * v1;
v3 = *(const char **)v2;
if ( *(_QWORD *)v2 )
break;
if ( *a1 <= ++v1 )
return fwrite("}\n", 1uLL, 2uLL, stderr);
}
v4 = *(unsigned int **)(v2 + 8);
v5 = *((_QWORD *)v4 + 1);
for ( i = *v4; ; i = *v7 )
{
fprintf(stderr, "\t'%s': {data_type: %d, offset: %zu},\n", v3, i, v5);
v2 = *(_QWORD *)(v2 + 16);
if ( !v2 )
break;
v7 = *(unsigned int **)(v2 + 8);
v3 = *(const char **)v2;
v5 = *((_QWORD *)v7 + 1);
}
++v1;
}
while ( *a1 > v1 );
}
return fwrite("}\n", 1uLL, 2uLL, stderr);
}

canonical_decompiled_code:
size_t __fastcall func7(unsigned __int64 *a1)
{
unsigned __int64 v1; // rbp
__int64 v2; // rbx
const char *v3; // rdx
unsigned int *v4; // rax
__int64 v5; // r8
__int64 i; // rcx
unsigned int *v7; // rax

v1 = 0LL;
fprintf(stderr, "Dictionary@%p {\n", a1);
if ( *a1 )
{
do
{
while ( 1 )
{
v2 = a1[3] + 24 * v1;
v3 = *(const char **)v2;
if ( *(_QWORD *)v2 )
break;
if ( *a1 <= ++v1 )
return fwrite("}\n", 1uLL, 2uLL, stderr);
}
v4 = *(unsigned int **)(v2 + 8);
v5 = *((_QWORD *)v4 + 1);
for ( i = *v4; ; i = *v7 )
{
fprintf(stderr, "\t'%s': {data_type: %d, offset: %zu},\n", v3, i, v5);
v2 = *(_QWORD *)(v2 + 16);
if ( !v2 )
break;
v7 = *(unsigned int **)(v2 + 8);
v3 = *(const char **)v2;
v5 = *((_QWORD *)v7 + 1);
}
++v1;
}
while ( *a1 > v1 );
}
return fwrite("}\n", 1uLL, 2uLL, stderr);
}

original_code:
void printDictionary(Dictionary_t *table) {
 DictionaryEntry_t *entry;
 DictionaryEntry_t *tmpEntry;
 fprintf(stderr, "Dictionary@%p {\n", (void *)table);
 for (size_t i = 0; i < table->size; i++) {
  entry = table->entries + i;
  if (entry->key != ((void *)0)) {
   fprintf(stderr, "\t'%s': {data_type: %d, offset: %zu},\n",
     entry->key, entry->value->data_type, entry->value->offset);
   tmpEntry = entry->next;
   while (tmpEntry != ((void *)0)) {
    entry = tmpEntry;
    fprintf(stderr, "\t'%s': {data_type: %d, offset: %zu},\n",
      entry->key, entry->value->data_type, entry->value->offset);
    tmpEntry = entry->next;
   }
  }
 }
 fprintf(stderr, "}\n");
}

canonical_original_code:
void printDictionary(struct dict_s *table) {
 struct dict_entry_s *entry;
 struct dict_entry_s *tmpEntry;
 fprintf(stderr, "Dictionary@%p {\n", (void *)table);
 for (unsigned long i = 0; i < table->size; i++) {
  entry = table->entries + i;
  if (entry->key != ((void *)0)) {
   fprintf(stderr, "\t'%s': {data_type: %d, offset: %zu},\n",
     entry->key, entry->value->data_type, entry->value->offset);
   tmpEntry = entry->next;
   while (tmpEntry != ((void *)0)) {
    entry = tmpEntry;
    fprintf(stderr, "\t'%s': {data_type: %d, offset: %zu},\n",
      entry->key, entry->value->data_type, entry->value->offset);
    tmpEntry = entry->next;
   }
  }
 }
 fprintf(stderr, "}\n");
}

user_defined_types: struct string_list_s { char *str; struct string_list_s *next; }

user_defined_types: enum DataType { DATA_TYPE_UNDEFINED=0, DATA_TYPE_BOOL=1, DATA_TYPE_CHAR=2, DATA_TYPE_STRING=3, DATA_TYPE_INT=4, DATA_TYPE_LONG=5, DATA_TYPE_LONG_ARRAY=6, DATA_TYPE_FLOAT=7, DATA_TYPE_DOUBLE=8, DATA_TYPE_DOUBLE_ARRAY=9, DATA_TYPE_FILE_PTR=10, DATA_TYPE_STRUCT=11, DATA_TYPE_STRUCT_PTR=12, DATA_TYPE_STRUCT_PTR_ARRAY=13 }


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

if ( a5 )
{
if ( a1 < 0 || a1 > a3 || a2 < 0 || a2 > a4 )
{
result = 0LL;
}
else
{
result = 1LL;
*a5 = a2 + a4 * a1;
}
}
else
{
fwrite("ERROR: Index pointer is NULL.\n", 1uLL, 0x1EuLL, stderr);
result = 0LL;
}
return result;
}

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

if ( a5 )
{
if ( a1 < 0 || a1 > a3 || a2 < 0 || a2 > a4 )
{
result = 0LL;
}
else
{
result = 1LL;
*a5 = a2 + a4 * a1;
}
}
else
{
fwrite("ERROR: Index pointer is NULL.\n", 1uLL, 0x1EuLL, stderr);
result = 0LL;
}
return result;
}

original_code:
bool row_col_to_index(
    int _row,
    int _col,
    int _maxr,
    int _maxc,
    int* _rtn_index)
{
    bool result = true;
    if(_rtn_index != 0) {
        if(_row < 0 || _row > _maxr || _col < 0 || _col > _maxc) {
            result = false;
        } else {
            *_rtn_index = _row * _maxc + _col;
        }
    } else {
        fprintf(stderr, "ERROR: Index pointer is NULL.\n");
        result = false;
    }
    return result;
}

canonical_original_code:
short row_col_to_index(int _row, int _col, int _maxr, int _maxc, int *_rtn_index)
{
    short result = true;
    if(_rtn_index != 0) {
        if(_row < 0 || _row > _maxr || _col < 0 || _col > _maxc) {
            result = false;
        } else {
            *_rtn_index = _row * _maxc + _col;
        }
    } else {
        fprintf(stderr, "ERROR: Index pointer is NULL.\n");
        result = false;
    }
    return result;
}

variable_types: result short


decompiled_code:
__int64 __fastcall index_to_row_col(int a1, int a2, int a3, int *a4, int *a5)
{
__int64 result; // rax

if ( a4 && a5 )
{
if ( a1 >= 0 && a3 * a2 >= a1 )
{
*a4 = a1 / a3;
result = 1LL;
*a5 = a1 % a3;
}
else
{
result = 0LL;
}
}
else
{
fwrite("ERROR: Row and/or column pointers are NULL.\n", 1uLL, 0x2CuLL, stderr);
result = 0LL;
}
return result;
}

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

if ( a4 && a5 )
{
if ( a1 >= 0 && a3 * a2 >= a1 )
{
*a4 = a1 / a3;
result = 1LL;
*a5 = a1 % a3;
}
else
{
result = 0LL;
}
}
else
{
fwrite("ERROR: Row and/or column pointers are NULL.\n", 1uLL, 0x2CuLL, stderr);
result = 0LL;
}
return result;
}

original_code:
bool index_to_row_col(
    int _index,
    int _maxr,
    int _maxc,
    int* _rtn_row,
    int* _rtn_col)
{
    bool result = true;
    if(_rtn_row != 0 && _rtn_col != 0) {
        if(_index < 0 || _index > _maxr * _maxc) {
            result = false;
        } else {
            *_rtn_row = _index / _maxc;
            *_rtn_col = _index % _maxc;
        }
    } else {
        fprintf(stderr, "ERROR: Row and/or column pointers are NULL.\n");
        result = false;
    }
    return result;
}

canonical_original_code:
short index_to_row_col(int _index, int _maxr, int _maxc, int *_rtn_row, int *_rtn_col)
{
    short result = true;
    if(_rtn_row != 0 && _rtn_col != 0) {
        if(_index < 0 || _index > _maxr * _maxc) {
            result = false;
        } else {
            *_rtn_row = _index / _maxc;
            *_rtn_col = _index % _maxc;
        }
    } else {
        fprintf(stderr, "ERROR: Row and/or column pointers are NULL.\n");
        result = false;
    }
    return result;
}


decompiled_code:
_BOOL8 __fastcall is_roof(double a1)
{
return a1 >= 0.0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func2(double a1)
{
return a1 >= 0.0;
}

original_code:
bool is_roof(
    double _roof_value)
{
    return _roof_value >= 0;
}

canonical_original_code:
short is_roof(double _roof_value)
{
    return _roof_value >= 0;
}


original_code:
double compute_diffuse_radiative_fluxes( int verbose_flag,
           double *flux_down_ptr,
           double *flux_up_ptr,
           double direct_flux,
           double extinction_coef,
           double gap_fraction,
           double pai,
           double theta_noon,
           double reflectance_canopy)
{
 double flux_reflected;
 double flux_transmitted;
 double flux_absorbed;
 double S;
 *flux_up_ptr = *flux_down_ptr * reflectance_canopy;
 if ( *flux_down_ptr != 0 ){
  S = 0.07 * ( direct_flux / *flux_down_ptr ) *
   ((0) > (1.1-0.1*pai*(1-gap_fraction)) ? (0) : (1.1-0.1*pai*(1-gap_fraction)))*exp( -1 * cos(theta_noon));
 }
 else{
  S = 0;
 }
 flux_absorbed = ( *flux_down_ptr - *flux_up_ptr)
  * ( 1 - exp(-1*pow(pai*(1-gap_fraction),0.7))+S);
 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 %10.8f ",
  *flux_up_ptr,flux_absorbed,flux_transmitted, S);
 if ( verbose_flag == -5 ){
  printf("\n          DIFRADFLUX: extcoef=%lf thetanoon=%lf S=%lf fluxrefl=%lf fluxabs=%lf fluxtrans=%lf",
      extinction_coef, theta_noon, S, *flux_up_ptr, flux_absorbed, flux_transmitted);
 }
 return( flux_absorbed );
}

canonical_original_code:
double compute_diffuse_radiative_fluxes(int verbose_flag, double *flux_down_ptr, double *flux_up_ptr, double direct_flux, double extinction_coef, double gap_fraction, double pai, double theta_noon, double reflectance_canopy)
{
 double flux_reflected;
 double flux_transmitted;
 double flux_absorbed;
 double S;
 *flux_up_ptr = *flux_down_ptr * reflectance_canopy;
 if ( *flux_down_ptr != 0 ){
  S = 0.07 * ( direct_flux / *flux_down_ptr ) *
   ((0) > (1.1-0.1*pai*(1-gap_fraction)) ? (0) : (1.1-0.1*pai*(1-gap_fraction)))*exp( -1 * cos(theta_noon));
 }
 else{
  S = 0;
 }
 flux_absorbed = ( *flux_down_ptr - *flux_up_ptr)
  * ( 1 - exp(-1*pow(pai*(1-gap_fraction),0.7))+S);
 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 %10.8f ",
  *flux_up_ptr,flux_absorbed,flux_transmitted, S);
 if ( verbose_flag == -5 ){
  printf("\n          DIFRADFLUX: extcoef=%lf thetanoon=%lf S=%lf fluxrefl=%lf fluxabs=%lf fluxtrans=%lf",
      extinction_coef, theta_noon, S, *flux_up_ptr, flux_absorbed, flux_transmitted);
 }
 return( flux_absorbed );
}

variable_types: pai double

variable_types: S double


decompiled_code:
double __fastcall compute_vapor_pressure_deficit(double a1, double a2)
{
return fmax(a1 - a2, 0.0);
}

canonical_decompiled_code:
double __fastcall func0(double a1, double a2)
{
return fmax(a1 - a2, 0.0);
}

original_code:
double compute_vapor_pressure_deficit(double saturation_vapor_pressure,
  double dewpoint_vapor_pressure) {
 return ((saturation_vapor_pressure - dewpoint_vapor_pressure) > (0.0) ? (saturation_vapor_pressure - dewpoint_vapor_pressure) : (0.0));
}


decompiled_code:
void __fastcall destroy_stratum_defaults(__int64 a1, __int64 a2, void *a3)
{
free(a3);
}

canonical_decompiled_code:
void __fastcall func0(__int64 a1, __int64 a2, void *a3)
{
free(a3);
}

original_code:
void destroy_stratum_defaults(int num_default_files,
         int grow_flag,
         struct stratum_default *default_object_list )
{
 free( default_object_list );
 return;
}

canonical_original_code:
void destroy_stratum_defaults(int num_default_files, int grow_flag, struct stratum_default *default_object_list)
{
 free( default_object_list );
 return;
}

variable_types: struct stratum_default { int ID; int lai_end_day; int lai_start_day; int lai_seasonal_flag; double albedo; double APAR_coef; double gsurf_slope; double gsurf_intercept; double K_absorptance; double K_reflectance; double K_transmittance; double lai_stomatal_fraction; double min_heat_capacity; double max_heat_capacity; double PAR_absorptance; double PAR_reflectance; double PAR_transmittance; double specific_rain_capacity; double specific_snow_capacity; double wind_attenuation_coeff; double ustar_overu; struct epconst_struct { double max_lai; double max_storage_percent; double min_percent_leafg; double proj_sla; double shade_sla_mult; double proj_swa; double lai_ratio; double int_coef; double ext_coef; double netpabs; double netpabs_age_mult; double netpabs_shade; double netpabs_sunlit; double flnr_age_mult; double flnr; double flnr_shade; double flnr_sunlit; double ppfd_coef; double topt; double tmax; double tcoef; double psi_open; double psi_close; double psi_threshold; double psi_slp; double psi_intercpt; double vpd_open; double vpd_close; double gl_smax; double gl_smax_sunlit; double gl_smax_shade; double gl_c; double gl_bl; double gs_tmin; double gs_tmax; double gs_trange; double gs_vpd_min; double gs_vpd_max; double gs_vpd_range; double gs_dayl_min; double gs_dayl_max; double gs_dayl_range; double gs_psi_min; double gs_psi_max; double gs_psi_range; double gs_ravg_days; double gsi_thresh; double cpool_mort_fract; int gs_npp_on; double gs_npp_slp; double gs_npp_intercpt; double coef_CO2; int day_leafon; int day_leafoff; int ndays_expand; int ndays_litfall; int phenology_flag; int allocation_flag; int veg_type; int phenology_type; int nfix; int psi_curve; int edible; int Tacclim; int zero_turnover_sprouts; int alternative_ra_surface; double gr_perc; double leaf_turnover; double livewood_turnover; double deadleaf_turnover; double froot_turnover; double kfrag_base; double storage_transfer_prop; double branch_turnover; double min_daily_mortality; double max_daily_mortality; double daily_mortality_threshold; double daily_fire_turnover; double froot_cn; double leaf_cn; double livewood_cn; double leaflitr_cn; double leaflitr_flab; double leaflitr_fucel; double leaflitr_fscel; double leaflitr_flig; double litter_gsurf_intercept; double litter_gsurf_slope; double litter_moist_coef; double litter_density; double frootlitr_flab; double frootlitr_fucel; double frootlitr_fscel; double frootlitr_flig; double deadwood_fucel; double deadwood_fscel; double deadwood_flig; double deadwood_cn; double alloc_frootc_crootc; double alloc_frootc_leafc; double alloc_crootc_stemc; double alloc_stemc_leafc; double alloc_livewoodc_woodc; double height_to_stem_coef; double height_to_stem_exp; double phloemcsa_per_alllai; double alloc_cpool_fhold; double alloc_npool_fhold; double alloc_maxlgf; double alloc_prop_day_growth; int dynamic_alloc_prop_day_growth; double min_leaf_carbon; double resprout_leaf_carbon; double root_growth_direction; double root_distrib_parm; double max_stem_density; double resprout_stem_density; double max_root_depth; double crown_ratio; int max_years_resprout; double waring_pa; double waring_pb; double dickenson_pa; double Tacclim_days; double Tacclim_slp; double Tacclim_intercpt; double gxylem_min_gs; double gxylem_csat; double gxylem_bsat; double gxylem_max; double LWP_gxylem_min; double gxylem_recovery_rate; } epc; struct mrconst_struct { double q10; double per_N; double sapw_max; } mrc; double understory_mort; double consumption; double overstory_mort_k1; double overstory_mort_k2; } *

user_defined_types: struct stratum_default { int ID; int lai_end_day; int lai_start_day; int lai_seasonal_flag; double albedo; double APAR_coef; double gsurf_slope; double gsurf_intercept; double K_absorptance; double K_reflectance; double K_transmittance; double lai_stomatal_fraction; double min_heat_capacity; double max_heat_capacity; double PAR_absorptance; double PAR_reflectance; double PAR_transmittance; double specific_rain_capacity; double specific_snow_capacity; double wind_attenuation_coeff; double ustar_overu; struct epconst_struct epc; struct mrconst_struct mrc; double understory_mort; double consumption; double overstory_mort_k1; double overstory_mort_k2; }


original_code:
void update_litter_soil_mortality(
       struct cdayflux_patch_struct *cdf_patch,
       struct ndayflux_patch_struct *ndf_patch,
       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 fire_litter_soil_loss_struct fire_loss)
{
 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;
 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;
 m_litr1c_to_atmos = fire_loss.loss_litr1c * cs_litr->litr1c;
 m_litr2c_to_atmos = fire_loss.loss_litr2c * cs_litr->litr2c;
 m_litr3c_to_atmos = fire_loss.loss_litr3c * cs_litr->litr3c;
 m_litr4c_to_atmos = fire_loss.loss_litr4c * cs_litr->litr4c;
 m_soil1c_to_atmos = fire_loss.loss_soil1c * cs_soil->soil1c;
 m_soil2c_to_atmos = fire_loss.loss_soil2c * cs_soil->soil2c;
 m_soil3c_to_atmos = fire_loss.loss_soil3c * cs_soil->soil3c;
 m_soil4c_to_atmos = fire_loss.loss_soil4c * cs_soil->soil4c;
 m_litr1n_to_atmos = fire_loss.loss_litr1n * ns_litr->litr1n;
 m_litr2n_to_atmos = fire_loss.loss_litr2n * ns_litr->litr2n;
 m_litr3n_to_atmos = fire_loss.loss_litr3n * ns_litr->litr3n;
 m_litr4n_to_atmos = fire_loss.loss_litr4n * ns_litr->litr4n;
 m_soil1n_to_atmos = fire_loss.loss_soil1n * ns_soil->soil1n;
 m_soil2n_to_atmos = fire_loss.loss_soil2n * ns_soil->soil2n;
 m_soil3n_to_atmos = fire_loss.loss_soil3n * ns_soil->soil3n;
 m_soil4n_to_atmos = fire_loss.loss_soil4n * ns_soil->soil4n;
 cs_litr->litr1c -= m_litr1c_to_atmos;
 cs_litr->litr2c -= m_litr2c_to_atmos;
 cs_litr->litr3c -= m_litr3c_to_atmos;
 cs_litr->litr4c -= m_litr4c_to_atmos;
 cs_soil->soil1c -= m_soil1c_to_atmos;
 cs_soil->soil2c -= m_soil2c_to_atmos;
 cs_soil->soil3c -= m_soil3c_to_atmos;
 cs_soil->soil4c -= m_soil4c_to_atmos;
 ns_litr->litr1n -= m_litr1n_to_atmos;
 ns_litr->litr2n -= m_litr2n_to_atmos;
 ns_litr->litr3n -= m_litr3n_to_atmos;
 ns_litr->litr4n -= m_litr4n_to_atmos;
 ns_soil->soil1n -= m_soil1n_to_atmos;
 ns_soil->soil2n -= m_soil2n_to_atmos;
 ns_soil->soil3n -= m_soil3n_to_atmos;
 ns_soil->soil4n -= m_soil4n_to_atmos;
 return;
}

canonical_original_code:
void update_litter_soil_mortality(struct cdayflux_patch_struct *cdf_patch, struct ndayflux_patch_struct *ndf_patch, 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 fire_litter_soil_loss_struct fire_loss)
{
 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;
 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;
 m_litr1c_to_atmos = fire_loss.loss_litr1c * cs_litr->litr1c;
 m_litr2c_to_atmos = fire_loss.loss_litr2c * cs_litr->litr2c;
 m_litr3c_to_atmos = fire_loss.loss_litr3c * cs_litr->litr3c;
 m_litr4c_to_atmos = fire_loss.loss_litr4c * cs_litr->litr4c;
 m_soil1c_to_atmos = fire_loss.loss_soil1c * cs_soil->soil1c;
 m_soil2c_to_atmos = fire_loss.loss_soil2c * cs_soil->soil2c;
 m_soil3c_to_atmos = fire_loss.loss_soil3c * cs_soil->soil3c;
 m_soil4c_to_atmos = fire_loss.loss_soil4c * cs_soil->soil4c;
 m_litr1n_to_atmos = fire_loss.loss_litr1n * ns_litr->litr1n;
 m_litr2n_to_atmos = fire_loss.loss_litr2n * ns_litr->litr2n;
 m_litr3n_to_atmos = fire_loss.loss_litr3n * ns_litr->litr3n;
 m_litr4n_to_atmos = fire_loss.loss_litr4n * ns_litr->litr4n;
 m_soil1n_to_atmos = fire_loss.loss_soil1n * ns_soil->soil1n;
 m_soil2n_to_atmos = fire_loss.loss_soil2n * ns_soil->soil2n;
 m_soil3n_to_atmos = fire_loss.loss_soil3n * ns_soil->soil3n;
 m_soil4n_to_atmos = fire_loss.loss_soil4n * ns_soil->soil4n;
 cs_litr->litr1c -= m_litr1c_to_atmos;
 cs_litr->litr2c -= m_litr2c_to_atmos;
 cs_litr->litr3c -= m_litr3c_to_atmos;
 cs_litr->litr4c -= m_litr4c_to_atmos;
 cs_soil->soil1c -= m_soil1c_to_atmos;
 cs_soil->soil2c -= m_soil2c_to_atmos;
 cs_soil->soil3c -= m_soil3c_to_atmos;
 cs_soil->soil4c -= m_soil4c_to_atmos;
 ns_litr->litr1n -= m_litr1n_to_atmos;
 ns_litr->litr2n -= m_litr2n_to_atmos;
 ns_litr->litr3n -= m_litr3n_to_atmos;
 ns_litr->litr4n -= m_litr4n_to_atmos;
 ns_soil->soil1n -= m_soil1n_to_atmos;
 ns_soil->soil2n -= m_soil2n_to_atmos;
 ns_soil->soil3n -= m_soil3n_to_atmos;
 ns_soil->soil4n -= m_soil4n_to_atmos;
 return;
}

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_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 fire_litter_soil_loss_struct { double loss_litr1c; double loss_litr2c; double loss_litr3c; double loss_litr4c; double loss_soil1c; double loss_soil2c; double loss_soil3c; double loss_soil4c; double loss_litr1n; double loss_litr2n; double loss_litr3n; double loss_litr4n; double loss_soil1n; double loss_soil2n; double loss_soil3n; double loss_soil4n; }


original_code:
double compute_direct_radiative_PAR_fluxes( int verbose_flag,
      double *flux_down_ptr,
      double extinction_coef,
      double gap_fraction,
      double proj_pai,
      double proj_lai,
      double all_lai,
      double theta_noon,
      double reflectance_canopy,
      double reflectance_bkgd)
{
 double flux_reflected;
 double flux_transmitted;
 double flux_absorbed;
 double unreflected_fraction;
 double noon_extinction;
 double noon_transmission;
 flux_reflected = *flux_down_ptr * reflectance_canopy;
 unreflected_fraction = ( 1- reflectance_canopy);
 noon_extinction = extinction_coef*(1-gap_fraction)*proj_pai/cos(theta_noon);
 if (( noon_extinction == 0 ) || (all_lai < 0.000000001)) {
  noon_transmission = 1;
  flux_absorbed = 0;
 }
 else if ( noon_extinction < -0.3 ){
  noon_transmission = exp(noon_extinction);
  flux_absorbed = *flux_down_ptr * (unreflected_fraction-noon_transmission);
 }
 else{
  noon_extinction = ( noon_extinction *1.1 );
  noon_transmission = exp(noon_extinction);
    flux_absorbed = *flux_down_ptr * (unreflected_fraction-noon_transmission);
 }
 if ( flux_absorbed < 0 ) flux_absorbed = 0;
  flux_transmitted = *flux_down_ptr - flux_reflected - flux_absorbed;
 *flux_down_ptr = flux_transmitted;
 if( verbose_flag > 2)
  printf("%8.1f %8.1f %8.1f ",
  flux_reflected,flux_absorbed,flux_transmitted);
 return( flux_absorbed );
}

canonical_original_code:
double compute_direct_radiative_PAR_fluxes(int verbose_flag, double *flux_down_ptr, double extinction_coef, double gap_fraction, double proj_pai, double proj_lai, double all_lai, double theta_noon, double reflectance_canopy, double reflectance_bkgd)
{
 double flux_reflected;
 double flux_transmitted;
 double flux_absorbed;
 double unreflected_fraction;
 double noon_extinction;
 double noon_transmission;
 flux_reflected = *flux_down_ptr * reflectance_canopy;
 unreflected_fraction = ( 1- reflectance_canopy);
 noon_extinction = extinction_coef*(1-gap_fraction)*proj_pai/cos(theta_noon);
 if (( noon_extinction == 0 ) || (all_lai < 0.000000001)) {
  noon_transmission = 1;
  flux_absorbed = 0;
 }
 else if ( noon_extinction < -0.3 ){
  noon_transmission = exp(noon_extinction);
  flux_absorbed = *flux_down_ptr * (unreflected_fraction-noon_transmission);
 }
 else{
  noon_extinction = ( noon_extinction *1.1 );
  noon_transmission = exp(noon_extinction);
    flux_absorbed = *flux_down_ptr * (unreflected_fraction-noon_transmission);
 }
 if ( flux_absorbed < 0 ) flux_absorbed = 0;
  flux_transmitted = *flux_down_ptr - flux_reflected - flux_absorbed;
 *flux_down_ptr = flux_transmitted;
 if( verbose_flag > 2)
  printf("%8.1f %8.1f %8.1f ",
  flux_reflected,flux_absorbed,flux_transmitted);
 return( flux_absorbed );
}


decompiled_code:
__int64 __fastcall update_rooting_depth(__int64 a1, double a2, double a3, double a4, double a5, double a6, double a7)
{
double v7; // xmm0_8
double v8; // xmm0_8
__int64 result; // rax

v7 = a2 + a2;
if ( a7 <= 0.000000001 )
v8 = pow(v7, a3);
else
v8 = pow(v7 / a7, a3);
result = 0LL;
*(double *)(a1 + 32) = fmax(fmin(fmin(v8 * 3.0 / a4, a5), a6 - 0.0001), 0.0);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, double a2, double a3, double a4, double a5, double a6, double a7)
{
double v7; // xmm0_8
double v8; // xmm0_8
__int64 result; // rax

v7 = a2 + a2;
if ( a7 <= 0.000000001 )
v8 = pow(v7, a3);
else
v8 = pow(v7 / a7, a3);
result = 0LL;
*(double *)(a1 + 32) = fmax(fmin(fmin(v8 * 3.0 / a4, a5), a6 - 0.0001), 0.0);
return result;
}

original_code:
int update_rooting_depth( struct rooting_zone_object *rootzone,
         double rootc,
         double root_growth_direction,
         double root_distrib_parm,
         double max_root_depth,
         double soil_depth,
         double stem_density)
{
 int ok=1;
 double biomass_carbon_ratio;
 biomass_carbon_ratio = 2.0;
 if (stem_density > 0.000000001) {
 rootzone->depth = 3.0 * pow((biomass_carbon_ratio*rootc/stem_density), root_growth_direction)
    / root_distrib_parm;
 }
 else {
 rootzone->depth = 3.0 * pow((biomass_carbon_ratio*rootc), root_growth_direction)
    / root_distrib_parm;
 }
 rootzone->depth = ((rootzone->depth) < (max_root_depth) ? (rootzone->depth) : (max_root_depth));
 rootzone->depth = ((rootzone->depth) < (soil_depth-0.0001) ? (rootzone->depth) : (soil_depth-0.0001));
 rootzone->depth = ((rootzone->depth) > (0.0) ? (rootzone->depth) : (0.0));
 return (!ok);
}

canonical_original_code:
int update_rooting_depth(struct rooting_zone_object *rootzone, double rootc, double root_growth_direction, double root_distrib_parm, double max_root_depth, double soil_depth, double stem_density)
{
 int ok = 1;
 double biomass_carbon_ratio;
 biomass_carbon_ratio = 2.0;
 if (stem_density > 0.000000001) {
 rootzone->depth = 3.0 * pow((biomass_carbon_ratio*rootc/stem_density), root_growth_direction)
    / root_distrib_parm;
 }
 else {
 rootzone->depth = 3.0 * pow((biomass_carbon_ratio*rootc), root_growth_direction)
    / root_distrib_parm;
 }
 rootzone->depth = ((rootzone->depth) < (max_root_depth) ? (rootzone->depth) : (max_root_depth));
 rootzone->depth = ((rootzone->depth) < (soil_depth-0.0001) ? (rootzone->depth) : (soil_depth-0.0001));
 rootzone->depth = ((rootzone->depth) > (0.0) ? (rootzone->depth) : (0.0));
 return (!ok);
}

variable_types: struct rooting_zone_object { double field_capacity; double potential_sat; double sat; double unsat; double depth; double preday_depth; double S; double T; } *

variable_types: rootc double

variable_types: ok int


decompiled_code:
double __fastcall leaf_conductance_APAR_curve(double a1, double a2)
{
double result; // xmm0_8

if ( a2 <= 0.000000001 )
result = *(double *)&LC0;
else
result = a1 * a2 / (a1 * a2 + 1.0);
return result;
}

canonical_decompiled_code:
double __fastcall func0(double a1, double a2)
{
double result; // xmm0_8

if ( a2 <= 0.000000001 )
result = *(double *)&LC0;
else
result = a1 * a2 / (a1 * a2 + 1.0);
return result;
}

original_code:
double leaf_conductance_APAR_curve( double APAR,
         double APAR_coef)
{
 double m_APAR;
 if (APAR_coef > 0.000000001)
  m_APAR = ( APAR * APAR_coef ) / ( 1.0 + APAR * APAR_coef );
 else
  m_APAR = 1.0;
 return(m_APAR);
}

canonical_original_code:
double leaf_conductance_APAR_curve(double APAR, double APAR_coef)
{
 double m_APAR;
 if (APAR_coef > 0.000000001)
  m_APAR = ( APAR * APAR_coef ) / ( 1.0 + APAR * APAR_coef );
 else
  m_APAR = 1.0;
 return(m_APAR);
}

variable_types: APAR double


decompiled_code:
__int64 __fastcall stream_make_context(int a1, int a2, __int64 a3, _QWORD *a4)
{
_DWORD *v6; // rax
__int64 result; // rax

if ( a4 )
{
v6 = calloc(1uLL, 0x10uLL);
if ( v6 )
{
*v6 = a1;
v6[1] = a2;
*((_QWORD *)v6 + 1) = a3;
*a4 = v6;
result = 1LL;
}
else
{
fwrite("ERROR: Failed to allocate memory for the stream search context.\n", 1uLL, 0x40uLL, stderr);
result = 0LL;
}
}
else
{
fwrite("ERROR: Return stream context pointer is NULL.\n", 1uLL, 0x2EuLL, stderr);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, int a2, __int64 a3, _QWORD *a4)
{
_DWORD *v6; // rax
__int64 result; // rax

if ( a4 )
{
v6 = calloc(1uLL, 0x10uLL);
if ( v6 )
{
*v6 = a1;
v6[1] = a2;
*((_QWORD *)v6 + 1) = a3;
*a4 = v6;
result = 1LL;
}
else
{
fwrite("ERROR: Failed to allocate memory for the stream search context.\n", 1uLL, 0x40uLL, stderr);
result = 0LL;
}
}
else
{
fwrite("ERROR: Return stream context pointer is NULL.\n", 1uLL, 0x2EuLL, stderr);
result = 0LL;
}
return result;
}

original_code:
bool stream_make_context(
  int _maxr,
  int _maxc,
  const int* _stream,
  void** _rtn_ctx)
{
 bool result = true;
 if(_rtn_ctx == 0) {
  fprintf(stderr, "ERROR: Return stream context pointer is NULL.\n");
  result = false;
 } else {
  stream_context_t* context = (stream_context_t*)calloc(1, sizeof(stream_context_t));
  if(context == 0) {
   fprintf(stderr, "ERROR: Failed to allocate memory for the stream search context.\n");
   result = false;
  } else {
   context->maxr_ = _maxr;
   context->maxc_ = _maxc;
   context->stream_ = _stream;
   *_rtn_ctx = (void*)context;
  }
 }
 return result;
}

canonical_original_code:
short stream_make_context(int _maxr, int _maxc, int *_stream, void **_rtn_ctx)
{
 short result = true;
 if(_rtn_ctx == 0) {
  fprintf(stderr, "ERROR: Return stream context pointer is NULL.\n");
  result = false;
 } else {
  struct stream_context_s *context = (stream_context_t*)calloc(1, sizeof(stream_context_t));
  if(context == 0) {
   fprintf(stderr, "ERROR: Failed to allocate memory for the stream search context.\n");
   result = false;
  } else {
   context->maxr_ = _maxr;
   context->maxc_ = _maxc;
   context->stream_ = _stream;
   *_rtn_ctx = (void *)context;
  }
 }
 return result;
}

variable_types: struct stream_context_s { int maxr_; int maxc_; int *stream_; } *


decompiled_code:
__int64 __fastcall stream_search_predicate(__int64 a1, __int64 a2, unsigned int a3, unsigned int a4, unsigned int *a5, _DWORD *a6)
{
__int64 result; // rax
int v9[7]; // [rsp+Ch] [rbp-1Ch] BYREF

if ( a5 )
{
result = row_col_to_index(a3, a4, *a5, a5[1], v9);
if ( (_WORD)result )
{
if ( *(_DWORD *)(*((_QWORD *)a5 + 1) + 4LL * v9[0]) == 1 )
{
*a6 = 1;
result = 1LL;
}
else
{
*a6 = 0;
result = 1LL;
}
}
}
else
{
fwrite("ERROR: Search context pointer is NULL.\n", 1uLL, 0x27uLL, stderr);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, unsigned int a3, unsigned int a4, unsigned int *a5, _DWORD *a6)
{
__int64 result; // rax
int v9[7]; // [rsp+Ch] [rbp-1Ch] BYREF

if ( a5 )
{
result = row_col_to_index(a3, a4, *a5, a5[1], v9);
if ( (_WORD)result )
{
if ( *(_DWORD *)(*((_QWORD *)a5 + 1) + 4LL * v9[0]) == 1 )
{
*a6 = 1;
result = 1LL;
}
else
{
*a6 = 0;
result = 1LL;
}
}
}
else
{
fwrite("ERROR: Search context pointer is NULL.\n", 1uLL, 0x27uLL, stderr);
result = 0LL;
}
return result;
}

original_code:
bool stream_search_predicate(
  int _subjectRow,
  int _subjectCol,
  int _row,
  int _col,
  void* _context,
  int* _rtn_vote)
{
 bool result = true;
 if(_context == 0) {
  fprintf(stderr, "ERROR: Search context pointer is NULL.\n");
  result = false;
 } else {
  stream_context_t* context = (stream_context_t*)_context;
  int index;
  if(!row_col_to_index(_row, _col, context->maxr_, context->maxc_, &index)) {
   result = false;
  } else {
   if(context->stream_[index] == 1) {
    *_rtn_vote = 1;
   } else {
    *_rtn_vote = 0;
   }
  }
 }
 return result;
}

canonical_original_code:
short stream_search_predicate(int _subjectRow, int _subjectCol, int _row, int _col, void *_context, int *_rtn_vote)
{
 short result = true;
 if(_context == 0) {
  fprintf(stderr, "ERROR: Search context pointer is NULL.\n");
  result = false;
 } else {
  struct stream_context_s *context = (stream_context_t*)_context;
  int index;
  if(!row_col_to_index(_row, _col, context->maxr_, context->maxc_, &index)) {
   result = false;
  } else {
   if(context->stream_[index] == 1) {
    *_rtn_vote = 1;
   } else {
    *_rtn_vote = 0;
   }
  }
 }
 return result;
}

variable_types: index int

user_defined_types: struct stream_context_s { int maxr_; int maxc_; int *stream_; }


decompiled_code:
__int64 __fastcall stream_search_tiebreaker(int a1, int a2, __int64 a3, __int64 a4, __int64 a5, _DWORD *a6, _DWORD *a7)
{
*a6 = a1;
*a7 = a2;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1, int a2, __int64 a3, __int64 a4, __int64 a5, _DWORD *a6, _DWORD *a7)
{
*a6 = a1;
*a7 = a2;
return 1LL;
}

original_code:
bool stream_search_tiebreaker(
 int _rowA,
 int _colA,
 int _rowB,
 int _colB,
 void* _context,
 int* _winnerRow,
 int* _winnerCol) {
 *_winnerRow = _rowA;
 *_winnerCol = _colA;
 return true;
}

canonical_original_code:
short stream_search_tiebreaker(int _rowA, int _colA, int _rowB, int _colB, void *_context, int *_winnerRow, int *_winnerCol) {
 *_winnerRow = _rowA;
 *_winnerCol = _colA;
 return true;
}


decompiled_code:
__int64 __fastcall parse_dyn_flag(void *ptr)
{
bool v2; // zf
unsigned int v3; // er12

v2 = memcmp(ptr, "STATIC", 6uLL) == 0;
v3 = !v2;
if ( !v2 )
{
v2 = memcmp(ptr, "static", 6uLL) == 0;
v3 = !v2;
if ( !v2 )
{
if ( !memcmp(ptr, "DYNAMIC", 7uLL) || !memcmp(ptr, "dynamic", 7uLL) )
{
v3 = 2;
}
else
{
v2 = memcmp(ptr, "CONSTANT", 8uLL) == 0;
v3 = !v2;
if ( !v2 )
{
v2 = memcmp(ptr, "constant", 8uLL) == 0;
v3 = !v2;
if ( !v2 )
{
if ( strcmp((const char *)ptr, "DROUGHT") && strcmp((const char *)ptr, "drought") )
{
fwrite("\n FATAL ERROR - parse_dyn_flag", 1uLL, 0x1EuLL, stderr);
fprintf(stderr, "\n Flag must be stati or dynamic and is %s", (const char *)ptr);
exit(1);
}
v3 = 1;
}
}
}
}
}
free(ptr);
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func0(void *ptr)
{
bool v2; // zf
unsigned int v3; // er12

v2 = memcmp(ptr, "STATIC", 6uLL) == 0;
v3 = !v2;
if ( !v2 )
{
v2 = memcmp(ptr, "static", 6uLL) == 0;
v3 = !v2;
if ( !v2 )
{
if ( !memcmp(ptr, "DYNAMIC", 7uLL) || !memcmp(ptr, "dynamic", 7uLL) )
{
v3 = 2;
}
else
{
v2 = memcmp(ptr, "CONSTANT", 8uLL) == 0;
v3 = !v2;
if ( !v2 )
{
v2 = memcmp(ptr, "constant", 8uLL) == 0;
v3 = !v2;
if ( !v2 )
{
if ( strcmp((const char *)ptr, "DROUGHT") && strcmp((const char *)ptr, "drought") )
{
fwrite("\n FATAL ERROR - parse_dyn_flag", 1uLL, 0x1EuLL, stderr);
fprintf(stderr, "\n Flag must be stati or dynamic and is %s", (const char *)ptr);
exit(1);
}
v3 = 1;
}
}
}
}
}
free(ptr);
return v3;
}

original_code:
int parse_dyn_flag( char *input_string)
{
 int dyn_flag;
 if ((strncmp(input_string,"STATIC",6) == 0) ||
  (strncmp(input_string, "static",6) == 0) )
  dyn_flag = 0;
 else if ((strncmp(input_string,"DYNAMIC",7) == 0) ||
  (strncmp(input_string, "dynamic",7) == 0) )
  dyn_flag = 2;
 else if ((strncmp(input_string,"CONSTANT",8) == 0) ||
  (strncmp(input_string, "constant",8) == 0) )
  dyn_flag = 0;
 else if ((strncmp(input_string,"DROUGHT",9) == 0) ||
  (strncmp(input_string, "drought",9) == 0) )
  dyn_flag = 1;
 else {
  fprintf(stderr,"\n FATAL ERROR - parse_dyn_flag");
  fprintf(stderr,"\n Flag must be stati or dynamic and is %s" , input_string);
  exit(1);
 }
 free(input_string);
 return(dyn_flag);
}

canonical_original_code:
int parse_dyn_flag(char *input_string)
{
 int dyn_flag;
 if ((strncmp(input_string,"STATIC",6) == 0) ||
  (strncmp(input_string, "static",6) == 0) )
  dyn_flag = 0;
 else if ((strncmp(input_string,"DYNAMIC",7) == 0) ||
  (strncmp(input_string, "dynamic",7) == 0) )
  dyn_flag = 2;
 else if ((strncmp(input_string,"CONSTANT",8) == 0) ||
  (strncmp(input_string, "constant",8) == 0) )
  dyn_flag = 0;
 else if ((strncmp(input_string,"DROUGHT",9) == 0) ||
  (strncmp(input_string, "drought",9) == 0) )
  dyn_flag = 1;
 else {
  fprintf(stderr,"\n FATAL ERROR - parse_dyn_flag");
  fprintf(stderr,"\n Flag must be stati or dynamic and is %s" , input_string);
  exit(1);
 }
 free(input_string);
 return(dyn_flag);
}


decompiled_code:
void __fastcall destroy_fire_defaults(__int64 a1, __int64 a2, void *a3)
{
free(a3);
}

original_code:
void destroy_fire_defaults(int num_default_files,
       int grow_flag,
       struct fire_default *default_object_list )
{
 free( default_object_list );
 return;
}

canonical_original_code:
void destroy_fire_defaults(int num_default_files, int grow_flag, struct fire_default *default_object_list)
{
 free( default_object_list );
 return;
}

variable_types: struct fire_default { int ID; double ndays_average; double load_k1; double moisture_k1; double load_k2; double moisture_k2; double winddir_k1; double winddir_k2; double windmax; double slope_k1; double slope_k2; double ignition_tmin; double ignition_col; double ignition_row; int fire_write; int fire_verbose; int n_rows; int n_cols; int fire_in_buffer; int spread_calc_type; double mean_log_wind; double sd_log_wind; double mean1_rvm; double mean2_rvm; double kappa1_rvm; double kappa2_rvm; double p_rvm; double ign_def_mod; double veg_k1; double veg_k2; double mean_ign; long ran_seed; double moisture_ign_k1; double moisture_ign_k2; double load_ign_k1; double load_ign_k2; int calc_fire_effects; int include_wui; int fire_size_name; double wind_shift; } *