decompiled_code:
int __fastcall Sgui_StartupError(char *s)
{
int v1; // kr00_4
size_t v2; // rax

v1 = LINES;
create_color();
wattr_on(stdscr, 0x200uLL, 0LL);
v2 = strlen(s);
mvprintw(v1 / 2 + 6, COLS / 2 - (v2 >> 1), s);
return wattr_on(stdscr, 0x100uLL, 0LL);
}

canonical_decompiled_code:
int __fastcall func6(char *s)
{
int v1; // kr00_4
size_t v2; // rax

v1 = LINES;
func0();
wattr_on(stdscr, 0x200uLL, 0LL);
v2 = strlen(s);
mvprintw(v1 / 2 + 6, COLS / 2 - (v2 >> 1), s);
return wattr_on(stdscr, 0x100uLL, 0LL);
}

original_code:
extern void Sgui_StartupError(char* message)
{
    int x_offset = (LINES / 2) + 6;
    create_color();
    wattr_on(stdscr, (attr_t)(((((chtype)(((2))) << ((0) + 8)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8))))), ((void *)0));
    mvprintw(x_offset, (COLS / 2) - (strlen(message) / 2), message);
    wattr_on(stdscr, (attr_t)(((((chtype)(((1))) << ((0) + 8)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8))))), ((void *)0));
}

canonical_original_code:
extern void Sgui_StartupError(char *message)
{
    int x_offset = (LINES / 2) + 6;
    create_color();
    wattr_on(stdscr, (attr_t)(((((chtype)(((2))) << ((0) + 8)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8))))), ((void *)0));
    mvprintw(x_offset, (COLS / 2) - (strlen(message) / 2), message);
    wattr_on(stdscr, (attr_t)(((((chtype)(((1))) << ((0) + 8)) & ((chtype)((((1U) << 8) - 1U)) << ((0) + 8))))), ((void *)0));
}


repo: QuentinBarrand/ENSIIE-IALP-solitaire

decompiled_code:
int Sgui_Terminer()
{
wclear(stdscr);
mvprintw(LINES / 2, COLS / 2 - 17, aMerciDAvoirJou);
wrefresh(stdscr);
sleep(3u);
return endwin();
}

canonical_decompiled_code:
int func7()
{
wclear(stdscr);
mvprintw(LINES / 2, COLS / 2 - 17, aMerciDAvoirJou);
wrefresh(stdscr);
sleep(3u);
return endwin();
}

original_code:
extern void Sgui_Terminer()
{
    wclear(stdscr);
    mvprintw(LINES / 2, COLS / 2 - 17, "Merci d'avoir joué, à bientôt !");
    wrefresh(stdscr);
    sleep(3);
    endwin();
}

return_type: void


decompiled_code:
void __fastcall Stack_Free(void *ptr)
{
free(*((void **)ptr + 1));
free(ptr);
}

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

original_code:
void Stack_Free(Stack* stack)
{
    free(stack->container);
    free(stack);
}

canonical_original_code:
void Stack_Free(struct Stack *stack)
{
    free(stack->container);
    free(stack);
}

variable_types: struct Stack { int count; int max; void **container; } *


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

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

original_code:
int Stack_Size(Stack* stack)
{
    return stack->count;
}

canonical_original_code:
int Stack_Size(struct Stack *stack)
{
    return stack->count;
}

return_type: int

user_defined_types: struct Stack { int count; int max; void **container; }


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

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

original_code:
int Stack_Max(Stack* stack)
{
    return stack->max;
}

canonical_original_code:
int Stack_Max(struct Stack *stack)
{
    return stack->max;
}


decompiled_code:
_BOOL8 __fastcall Stack_IsEmpty(_DWORD *a1)
{
return *a1 == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func3(_DWORD *a1)
{
return *a1 == 0;
}

original_code:
int Stack_IsEmpty(Stack* stack)
{
    if(stack->count == 0)
        return 1;
    return 0;
}

canonical_original_code:
int Stack_IsEmpty(struct Stack *stack)
{
    if(stack->count == 0)
        return 1;
    return 0;
}


decompiled_code:
void *__fastcall Stack_ResizeContainer(__int64 a1)
{
__int64 v1; // r12
void *v2; // rax
void *result; // rax

v1 = *(int *)(a1 + 4);
v2 = malloc(16 * v1);
result = memmove(v2, *(const void **)(a1 + 8), 8 * v1);
*(_DWORD *)(a1 + 4) = 2 * v1;
return result;
}

canonical_decompiled_code:
void *__fastcall func4(__int64 a1)
{
__int64 v1; // r12
void *v2; // rax
void *result; // rax

v1 = *(int *)(a1 + 4);
v2 = malloc(16 * v1);
result = memmove(v2, *(const void **)(a1 + 8), 8 * v1);
*(_DWORD *)(a1 + 4) = 2 * v1;
return result;
}

original_code:
void** Stack_ResizeContainer(Stack* stack)
{
    void** tmpContainer = malloc(sizeof(void**) * stack->max * 2);
    bcopy(stack->container, tmpContainer, sizeof(void**)*stack->max);
    stack->max *= 2;
    return tmpContainer;
}

canonical_original_code:
void **Stack_ResizeContainer(struct Stack *stack)
{
    void **tmpContainer = malloc(sizeof(void**) * stack->max * 2);
    bcopy(stack->container, tmpContainer, sizeof(void **)*stack->max);
    stack->max *= 2;
    return tmpContainer;
}

variable_types:
tmpContainer
void **

return_type: void **


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

LODWORD(result) = *(_DWORD *)a2 - 1;
if ( (int)result < 0 )
return 0xFFFFFFFFLL;
result = (int)result;
while ( *(_QWORD *)(*(_QWORD *)(a2 + 8) + 8 * result) != a1 )
{
if ( (int)--result < 0 )
return 0xFFFFFFFFLL;
}
return (unsigned int)result;
}

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

LODWORD(result) = *(_DWORD *)a2 - 1;
if ( (int)result < 0 )
return 0xFFFFFFFFLL;
result = (int)result;
while ( *(_QWORD *)(*(_QWORD *)(a2 + 8) + 8 * result) != a1 )
{
if ( (int)--result < 0 )
return 0xFFFFFFFFLL;
}
return (unsigned int)result;
}

original_code:
int Stack_Search(void* value, Stack* stack)
{
    int i;
    for(i = stack->count - 1; i >= 0; i--)
    {
        if(stack->container[i] == value)
            return i;
    }
    return -1;
}

canonical_original_code:
int Stack_Search(void *value, struct Stack *stack)
{
    int i;
    for(i = stack->count - 1; i >= 0; i--)
    {
        if(stack->container[i] == value)
            return i;
    }
    return -1;
}

variable_types:
value
void *

variable_types: i int


original_code:
void* Stack_Peek(Stack* stack)
{
    if (stack->count > 0)
        return stack->container[stack->count - 1];
    return ((void *)0);
}

canonical_original_code:
void *Stack_Peek(struct Stack *stack)
{
    if (stack->count > 0)
        return stack->container[stack->count - 1];
    return ((void *)0);
}

return_type: void *


decompiled_code:
__int64 __fastcall Stack_Push(__int64 a1, __int64 a2)
{
int v2; // eax
_QWORD *v3; // rdx
__int64 v4; // rcx
__int64 result; // rax
_QWORD *v6; // rax

v2 = *(_DWORD *)a2;
if ( *(_DWORD *)a2 == *(_DWORD *)(a2 + 4) )
{
v6 = Stack_ResizeContainer(a2);
*(_QWORD *)(a2 + 8) = v6;
v3 = v6;
v2 = *(_DWORD *)a2;
}
else
{
v3 = *(_QWORD **)(a2 + 8);
}
v4 = v2;
result = (unsigned int)(v2 + 1);
v3[v4] = a1;
*(_DWORD *)a2 = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2)
{
int v2; // eax
_QWORD *v3; // rdx
__int64 v4; // rcx
__int64 result; // rax
_QWORD *v6; // rax

v2 = *(_DWORD *)a2;
if ( *(_DWORD *)a2 == *(_DWORD *)(a2 + 4) )
{
v6 = func4(a2);
*(_QWORD *)(a2 + 8) = v6;
v3 = v6;
v2 = *(_DWORD *)a2;
}
else
{
v3 = *(_QWORD **)(a2 + 8);
}
v4 = v2;
result = (unsigned int)(v2 + 1);
v3[v4] = a1;
*(_DWORD *)a2 = result;
return result;
}

original_code:
void Stack_Push(void* item, Stack* stack)
{
    if (stack->count == stack->max)
        stack->container = Stack_ResizeContainer(stack);
    stack->container[stack->count] = item;
    stack->count++;
}

canonical_original_code:
void Stack_Push(void *item, struct Stack *stack)
{
    if (stack->count == stack->max)
        stack->container = Stack_ResizeContainer(stack);
    stack->container[stack->count] = item;
    stack->count++;
}

variable_types:
item
void *


original_code:
void* Stack_Pop(Stack* stack)
{
    if (stack->count > 0)
    {
        stack->count--;
        return stack->container[stack->count];
    }
    return ((void *)0);
}

canonical_original_code:
void *Stack_Pop(struct Stack *stack)
{
    if (stack->count > 0)
    {
        stack->count--;
        return stack->container[stack->count];
    }
    return ((void *)0);
}


getOrdByNumber

decompiled_code:
__int64 __fastcall getOrdByNumber(char a1)
{
unsigned __int8 v1; // di
__int64 result; // rax

v1 = a1 - 49;
if ( v1 > 8u )
result = 0xFFFFFFFFLL;
else
result = (unsigned int)(char)v1;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(char a1)
{
unsigned __int8 v1; // di
__int64 result; // rax

v1 = a1 - 49;
if ( v1 > 8u )
result = 0xFFFFFFFFLL;
else
result = (unsigned int)(char)v1;
return result;
}

original_code:
static int getOrdByNumber(char c)
{
    const int FUNC_NOT_A_NUMBER = -1;
    return (c >= '1' && c <= '9') ? c - '0' - 1 : FUNC_NOT_A_NUMBER;
}

canonical_original_code:
static int getOrdByNumber(char c)
{
    int FUNC_NOT_A_NUMBER = -1;
    return (c >= '1' && c <= '9') ? c - '0' - 1 : FUNC_NOT_A_NUMBER;
}

variable_types: c char


getOrdByTwoNumbers

decompiled_code:
__int64 __fastcall getOrdByTwoNumbers(char a1, char a2)
{
int v2; // eax
int v3; // edx
__int64 result; // rax

getOrdByNumber(a1);
v2 = getOrdByNumber(a2) + 1;
if ( v3 && v2 )
result = (unsigned int)(v2 + 10 * v3);
else
result = 0xFFFFFFFFLL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(char a1, char a2)
{
int v2; // eax
int v3; // edx
__int64 result; // rax

func0(a1);
v2 = func0(a2) + 1;
if ( v3 && v2 )
result = (unsigned int)(v2 + 10 * v3);
else
result = 0xFFFFFFFFLL;
return result;
}

original_code:
static int getOrdByTwoNumbers(char c1, char c2)
{
    const int FUNC_NOT_A_NUMBER = -1;
    int p1 = getOrdByNumber(c1) + 1;
    int p2 = getOrdByNumber(c2) + 1;
    if(p1 == 0 || p2 == 0) return FUNC_NOT_A_NUMBER;
    return 10 * p1 + p2;
}

canonical_original_code:
static int getOrdByTwoNumbers(char c1, char c2)
{
    int FUNC_NOT_A_NUMBER = -1;
    int p1 = getOrdByNumber(c1) + 1;
    int p2 = getOrdByNumber(c2) + 1;
    if(p1 == 0 || p2 == 0) return FUNC_NOT_A_NUMBER;
    return 10 * p1 + p2;
}


getAbsByLetter

decompiled_code:
__int64 __fastcall getAbsByLetter(char a1)
{
unsigned __int8 v1; // di
__int64 result; // rax

if ( (unsigned __int8)(a1 - 65) <= 0x19u )
return (unsigned int)(char)(a1 - 65);
v1 = a1 - 97;
result = (unsigned int)(char)v1;
if ( v1 >= 0x1Au )
result = 0xFFFFFFFFLL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(char a1)
{
unsigned __int8 v1; // di
__int64 result; // rax

if ( (unsigned __int8)(a1 - 65) <= 0x19u )
return (unsigned int)(char)(a1 - 65);
v1 = a1 - 97;
result = (unsigned int)(char)v1;
if ( v1 >= 0x1Au )
result = 0xFFFFFFFFLL;
return result;
}

original_code:
static int getAbsByLetter(char c)
{
    const int FUNC_NOT_A_LETTER = -1;
    if(c >= 'A' && c <= 'Z') return c - 'A';
    if(c >= 'a' && c <= 'z') return c - 'a';
    return FUNC_NOT_A_LETTER;
}

canonical_original_code:
static int getAbsByLetter(char c)
{
    int FUNC_NOT_A_LETTER = -1;
    if(c >= 'A' && c <= 'Z') return c - 'A';
    if(c >= 'a' && c <= 'z') return c - 'a';
    return FUNC_NOT_A_LETTER;
}


decompiled_code:
__int64 __fastcall coordutils_ToIntCoord(char *s, _DWORD *a2, int a3, int a4)
{
_DWORD *v5; // r13
char v6; // r12
int i; // ebx
char *v8; // rdx
int v9; // eax
__int64 result; // rax
int v11; // eax
char v12; // r8

v5 = a2;
v6 = 1;
for ( i = 0; i < (int)strlen(s); ++v5 )
{
v8 = &s[i];
if ( (v6 & 1) != 0 )
{
v9 = getAbsByLetter(*v8);
if ( v9 == -1 )
return 1LL;
}
else
{
v11 = getOrdByTwoNumbers(*v8, s[i + 1]);
if ( v11 != -1 )
{
*v5 = v11;
++i;
goto LABEL_5;
}
v9 = getOrdByNumber(v12);
if ( v9 == -1 )
return 1LL;
}
*v5 = v9;
LABEL_5:
++i;
++v6;
}
result = 2LL;
if ( *a2 < a3 && a2[1] < a4 && a2[2] < a3 )
result = 2 * (unsigned int)(a2[3] >= a4);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(char *s, _DWORD *a2, int a3, int a4)
{
_DWORD *v5; // r13
char v6; // r12
int i; // ebx
char *v8; // rdx
int v9; // eax
__int64 result; // rax
int v11; // eax
char v12; // r8

v5 = a2;
v6 = 1;
for ( i = 0; i < (int)strlen(s); ++v5 )
{
v8 = &s[i];
if ( (v6 & 1) != 0 )
{
v9 = func2(*v8);
if ( v9 == -1 )
return 1LL;
}
else
{
v11 = func1(*v8, s[i + 1]);
if ( v11 != -1 )
{
*v5 = v11;
++i;
goto LABEL_5;
}
v9 = func0(v12);
if ( v9 == -1 )
return 1LL;
}
*v5 = v9;
LABEL_5:
++i;
++v6;
}
result = 2LL;
if ( *a2 < a3 && a2[1] < a4 && a2[2] < a3 )
result = 2 * (unsigned int)(a2[3] >= a4);
return result;
}

original_code:
extern int coordutils_ToIntCoord(char* userinput, int* coord, int width,
    int length)
{
    const int FUNC_SUCCESS = 0;
    const int FUNC_INCORRECT_CHAR = 1;
    const int FUNC_OUT_OF_BOUNDS = 2;
    int i, j = 0, current;
    for(i = 0; i < (int)strlen(userinput); i++)
    {
        if(j % 2 == 0)
        {
            if((current = getAbsByLetter(userinput[i])) != -1)
            {
                coord[j] = current;
                j++;
                continue;
            }
        }
        else
        {
            if((current =
                getOrdByTwoNumbers(userinput[i], userinput[i + 1])) != -1)
            {
                coord[j] = current;
                i++;
                j++;
                continue;
            }
            if((current = getOrdByNumber(userinput[i])) != -1)
            {
                coord[j] = current;
                j++;
                continue;
            }
        }
        return FUNC_INCORRECT_CHAR;
    }
    if(coord[0] + 1 > width ||
        coord[1] + 1 > length ||
        coord[2] + 1 > width ||
        coord[3] + 1 > length)
        return FUNC_OUT_OF_BOUNDS;
    return FUNC_SUCCESS;
}

canonical_original_code:
extern int coordutils_ToIntCoord(char *userinput, int *coord, int width, int length)
{
    int FUNC_SUCCESS = 0;
    int FUNC_INCORRECT_CHAR = 1;
    int FUNC_OUT_OF_BOUNDS = 2;
    int i; int j = 0; int current;
    for(i = 0; i < (int)strlen(userinput); i++)
    {
        if(j % 2 == 0)
        {
            if((current = getAbsByLetter(userinput[i])) != -1)
            {
                coord[j] = current;
                j++;
                continue;
            }
        }
        else
        {
            if((current =
                getOrdByTwoNumbers(userinput[i], userinput[i + 1])) != -1)
            {
                coord[j] = current;
                i++;
                j++;
                continue;
            }
            if((current = getOrdByNumber(userinput[i])) != -1)
            {
                coord[j] = current;
                j++;
                continue;
            }
        }
        return FUNC_INCORRECT_CHAR;
    }
    if(coord[0] + 1 > width ||
        coord[1] + 1 > length ||
        coord[2] + 1 > width ||
        coord[3] + 1 > length)
        return FUNC_OUT_OF_BOUNDS;
    return FUNC_SUCCESS;
}

variable_types:
userinput
char *

variable_types:
coord
int *

variable_types: width int

variable_types: length int

variable_types: j int

variable_types: current int


repo: RHESSys/RHESSys

decompiled_code:
__int64 __fastcall parse_veg_type(void *ptr)
{
unsigned int v2; // er12

if ( !memcmp(ptr, "TREE", 4uLL) || !memcmp(ptr, "tree", 4uLL) )
{
v2 = 1;
}
else
{
if ( !memcmp(ptr, "GRASS", 5uLL) || !memcmp(ptr, "grass", 5uLL) )
goto LABEL_14;
if ( !memcmp(ptr, "C4GRASS", 7uLL) || !memcmp(ptr, "c4grass", 7uLL) )
{
v2 = 3;
goto LABEL_4;
}
if ( !memcmp(ptr, "C3GRASS", 7uLL) || !memcmp(ptr, "c3grass", 7uLL) )
{
LABEL_14:
v2 = 2;
}
else
{
if ( memcmp(ptr, "NON_VEG", 5uLL) && memcmp(ptr, "non_veg", 5uLL) )
{
fwrite("\n FATAL ERROR - parse_veg_type", 1uLL, 0x1EuLL, stderr);
fprintf(stderr, "\n %s Unknown veg type in stratum default file", (const char *)ptr);
fwrite("\n must be either TREE or GRASS\n", 1uLL, 0x1FuLL, stderr);
exit(1);
}
v2 = 20;
}
}
LABEL_4:
free(ptr);
return v2;
}

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

if ( !memcmp(ptr, "TREE", 4uLL) || !memcmp(ptr, "tree", 4uLL) )
{
v2 = 1;
}
else
{
if ( !memcmp(ptr, "GRASS", 5uLL) || !memcmp(ptr, "grass", 5uLL) )
goto LABEL_14;
if ( !memcmp(ptr, "C4GRASS", 7uLL) || !memcmp(ptr, "c4grass", 7uLL) )
{
v2 = 3;
goto LABEL_4;
}
if ( !memcmp(ptr, "C3GRASS", 7uLL) || !memcmp(ptr, "c3grass", 7uLL) )
{
LABEL_14:
v2 = 2;
}
else
{
if ( memcmp(ptr, "NON_VEG", 5uLL) && memcmp(ptr, "non_veg", 5uLL) )
{
fwrite("\n FATAL ERROR - parse_veg_type", 1uLL, 0x1EuLL, stderr);
fprintf(stderr, "\n %s Unknown veg type in stratum default file", (const char *)ptr);
fwrite("\n must be either TREE or GRASS\n", 1uLL, 0x1FuLL, stderr);
exit(1);
}
v2 = 20;
}
}
LABEL_4:
free(ptr);
return v2;
}

original_code:
int parse_veg_type( char *input_string)
{
 int veg_type;
 if ((strncmp(input_string,"TREE",4) == 0) ||
  (strncmp(input_string, "tree",4) == 0) )
  veg_type = 1;
 else if ((strncmp(input_string,"GRASS",5) == 0) ||
  (strncmp(input_string, "grass",5) == 0) )
  veg_type = 2;
 else if ((strncmp(input_string,"C4GRASS",7) == 0) ||
  (strncmp(input_string, "c4grass",7) == 0) )
  veg_type = 3;
 else if ((strncmp(input_string,"C3GRASS",7) == 0) ||
  (strncmp(input_string, "c3grass",7) == 0) )
  veg_type = 2;
 else if ((strncmp(input_string,"NON_VEG",5) == 0) ||
  (strncmp(input_string, "non_veg",5) == 0) )
  veg_type = 20;
 else {
  fprintf(stderr,"\n FATAL ERROR - parse_veg_type");
  fprintf(stderr,"\n %s Unknown veg type in stratum default file", input_string);
  fprintf(stderr,"\n must be either TREE or GRASS\n");
  exit(1);
 }
 free(input_string);
 return(veg_type);
}

canonical_original_code:
int parse_veg_type(char *input_string)
{
 int veg_type;
 if ((strncmp(input_string,"TREE",4) == 0) ||
  (strncmp(input_string, "tree",4) == 0) )
  veg_type = 1;
 else if ((strncmp(input_string,"GRASS",5) == 0) ||
  (strncmp(input_string, "grass",5) == 0) )
  veg_type = 2;
 else if ((strncmp(input_string,"C4GRASS",7) == 0) ||
  (strncmp(input_string, "c4grass",7) == 0) )
  veg_type = 3;
 else if ((strncmp(input_string,"C3GRASS",7) == 0) ||
  (strncmp(input_string, "c3grass",7) == 0) )
  veg_type = 2;
 else if ((strncmp(input_string,"NON_VEG",5) == 0) ||
  (strncmp(input_string, "non_veg",5) == 0) )
  veg_type = 20;
 else {
  fprintf(stderr,"\n FATAL ERROR - parse_veg_type");
  fprintf(stderr,"\n %s Unknown veg type in stratum default file", input_string);
  fprintf(stderr,"\n must be either TREE or GRASS\n");
  exit(1);
 }
 free(input_string);
 return(veg_type);
}


original_code:
int compute_farq_psn( struct psnin_struct *in,
      struct psnout_struct* out, int verbose)
{
 int ok=1;
 double t;
 double tk;
 double g;
 double O2;
 double Ca;
 double gamma;
 double Kc;
 double Ko;
 double act;
 double Rd;
 double Vmax;
 double Jmax;
 double J;
 double Av;
 double Aj;
 double A;
 double aa,bb,cc,det;
 double netpabs;
 int c3;
 static double fnr = 7.16;
 static double Kc25 = 404.0;
 static double q10Kc = 2.1;
 static double Ko25 = 248.0;
 static double q10Ko = 1.2;
 static double act25 = 3.6;
 static double q10act = 2.4;
 static double pabs = 0.85;
 Rd = in->Rd;
 t = in->t;
 tk = t + 273.15;
 g = in->g * 1e3 / (8.3143 * tk);
 Ca = in->co2 * in->pa / 1e6;
 c3 = 0;
 in->c3 = 1;
 netpabs = in->netpabs;
 if (in->c3)
        {
  c3 = 1;
        }
        else
        {
                Ca *= 10.0;
        }
 O2 = 0.21 * in->pa;
 Ko = Ko25 * pow(q10Ko, (t-25.0)/10.0);
 Ko = Ko * 100.0;
 if (t > 15.0){
  Kc = Kc25 * pow(q10Kc, (t-25.0)/10.0);
  act = act25 * pow(q10act, (t-25.0)/10.0);
 }
 else{
  Kc = Kc25 * pow(1.8*q10Kc, (t-15.0)/10.0) / q10Kc;
  act = act25 * pow(1.8*q10act, (t-15.0)/10.0) / q10act;
 }
 Kc = Kc * 0.10;
 act = act * 1e6 / 60.0;
 gamma = 0.5 * 0.21 * Kc * O2 / Ko;
 Vmax = in->lnc * in->flnr * fnr * act;
 Jmax = 2.1 * Vmax;
        aa = 0.7;
        bb = -Jmax - (in->irad*netpabs);
        cc = Jmax * in->irad*netpabs;
        J = (-bb - sqrt(bb*bb - 4.0*aa*cc))/(2.0*aa);
 aa = -1.0/g;
 bb = Ca + (Vmax - Rd)/g + Kc*(1.0 + O2/Ko);
 cc = Vmax*(gamma - Ca) + Rd*(Ca + Kc*(1.0 + O2/Ko));
 if ((det = bb*bb - 4.0*aa*cc) < 0.0){
  printf("negative root error in psn routine\n");
  return (1);
 }
 Av = (-bb + sqrt(det)) / (2.0*aa);
 aa = -4.5/g;
 bb = 4.5*Ca + 10.5*gamma + J/g - 4.5*Rd/g;
 cc = J*(gamma - Ca) + Rd*(4.5*Ca + 10.5*gamma);
 if ((det = bb*bb - 4.0*aa*cc) < 0.0){
  printf("negative root error in psn routine\n");
  return(1);
 }
 Aj = (-bb + sqrt(det)) / (2.0*aa);
 if (Av < Aj)
  A = Av;
 else
  A = Aj;
 out->A = A;
  out->g = g;
  out->Ca = Ca;
  out->Ci = Ca - A/g;
  out->dC13 = out->Ci/out->Ca*(28-4.4)+4.4;
  out->gamma = gamma;
  out->O2 = O2;
  out->Kc = Kc;
  out->Ko = Ko;
  out->act = act;
  out->Vmax = Vmax;
  out->Jmax = Jmax;
  out->J = J;
  out->Av = Av;
  out->Aj = Aj;
 return (!ok);
}

canonical_original_code:
int compute_farq_psn(struct psnin_struct *in, struct psnout_struct *out, int verbose)
{
 int ok = 1;
 double t;
 double tk;
 double g;
 double O2;
 double Ca;
 double gamma;
 double Kc;
 double Ko;
 double act;
 double Rd;
 double Vmax;
 double Jmax;
 double J;
 double Av;
 double Aj;
 double A;
 double aa; double bb; double cc; double det;
 double netpabs;
 int c3;
 static double fnr = 7.16;
 static double Kc25 = 404.0;
 static double q10Kc = 2.1;
 static double Ko25 = 248.0;
 static double q10Ko = 1.2;
 static double act25 = 3.6;
 static double q10act = 2.4;
 static double pabs = 0.85;
 Rd = in->Rd;
 t = in->t;
 tk = t + 273.15;
 g = in->g * 1e3 / (8.3143 * tk);
 Ca = in->co2 * in->pa / 1e6;
 c3 = 0;
 in->c3 = 1;
 netpabs = in->netpabs;
 if (in->c3)
        {
  c3 = 1;
        }
        else
        {
                Ca *= 10.0;
        }
 O2 = 0.21 * in->pa;
 Ko = Ko25 * pow(q10Ko, (t-25.0)/10.0);
 Ko = Ko * 100.0;
 if (t > 15.0){
  Kc = Kc25 * pow(q10Kc, (t-25.0)/10.0);
  act = act25 * pow(q10act, (t-25.0)/10.0);
 }
 else{
  Kc = Kc25 * pow(1.8*q10Kc, (t-15.0)/10.0) / q10Kc;
  act = act25 * pow(1.8*q10act, (t-15.0)/10.0) / q10act;
 }
 Kc = Kc * 0.10;
 act = act * 1e6 / 60.0;
 gamma = 0.5 * 0.21 * Kc * O2 / Ko;
 Vmax = in->lnc * in->flnr * fnr * act;
 Jmax = 2.1 * Vmax;
        aa = 0.7;
        bb = -Jmax - (in->irad*netpabs);
        cc = Jmax * in->irad*netpabs;
        J = (-bb - sqrt(bb*bb - 4.0*aa*cc))/(2.0*aa);
 aa = -1.0/g;
 bb = Ca + (Vmax - Rd)/g + Kc*(1.0 + O2/Ko);
 cc = Vmax*(gamma - Ca) + Rd*(Ca + Kc*(1.0 + O2/Ko));
 if ((det = bb*bb - 4.0*aa*cc) < 0.0){
  printf("negative root error in psn routine\n");
  return (1);
 }
 Av = (-bb + sqrt(det)) / (2.0*aa);
 aa = -4.5/g;
 bb = 4.5*Ca + 10.5*gamma + J/g - 4.5*Rd/g;
 cc = J*(gamma - Ca) + Rd*(4.5*Ca + 10.5*gamma);
 if ((det = bb*bb - 4.0*aa*cc) < 0.0){
  printf("negative root error in psn routine\n");
  return(1);
 }
 Aj = (-bb + sqrt(det)) / (2.0*aa);
 if (Av < Aj)
  A = Av;
 else
  A = Aj;
 out->A = A;
  out->g = g;
  out->Ca = Ca;
  out->Ci = Ca - A/g;
  out->dC13 = out->Ci/out->Ca*(28-4.4)+4.4;
  out->gamma = gamma;
  out->O2 = O2;
  out->Kc = Kc;
  out->Ko = Ko;
  out->act = act;
  out->Vmax = Vmax;
  out->Jmax = Jmax;
  out->J = J;
  out->Av = Av;
  out->Aj = Aj;
 return (!ok);
}

variable_types: struct psnin_struct { int c3; double pa; double co2; double t; double irad; double g; double Rd; double lnc; double flnr; double netpabs; } *

variable_types: struct psnout_struct { double g; double O2; double Ca; double Ci; double gamma; double Kc; double Ko; double act; double Vmax; double Jmax; double J; double Av; double Aj; double A; double dC13; } *

variable_types: verbose int

variable_types: ok int

variable_types: t double

variable_types: tk double

variable_types: g double

variable_types: Ca double

variable_types: gamma double

variable_types: Kc double

variable_types: Ko double

variable_types: act double

variable_types: Rd double

variable_types: Vmax double

variable_types: Jmax double

variable_types: J double

variable_types: Av double

variable_types: Aj double

variable_types: A double

variable_types: aa double

variable_types: bb double

variable_types: cc double

variable_types: det double

variable_types: netpabs double

variable_types: fnr double

variable_types: pabs double


decompiled_code:
void __fastcall destroy_hillslope_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_hillslope_defaults(int num_default_files,
        int grow_flag,
        struct hillslope_default *default_object_list )
{
 int i;
 free( default_object_list );
 return;
}

canonical_original_code:
void destroy_hillslope_defaults(int num_default_files, int grow_flag, struct hillslope_default *default_object_list)
{
 int i;
 free( default_object_list );
 return;
}

variable_types: struct hillslope_default { int ID; int n_routing_timesteps; double gw_loss_coeff; double gw_loss_fast_coeff; double gw_loss_fast_threshold; } *

variable_types: i int


freePointerSet

decompiled_code:
void __fastcall freePointerSet(void *ptr)
{
void *v1; // rbx
void *v2; // rdi

if ( ptr )
{
v1 = ptr;
do
{
v2 = v1;
v1 = (void *)*((_QWORD *)v1 + 1);
free(v2);
}
while ( v1 );
}
}

canonical_decompiled_code:
void __fastcall func0(void *ptr)
{
void *v1; // rbx
void *v2; // rdi

if ( ptr )
{
v1 = ptr;
do
{
v2 = v1;
v1 = (void *)*((_QWORD *)v1 + 1);
free(v2);
}
while ( v1 );
}
}

original_code:
void freePointerSet(PointerSet *set) {
 if (set == ((void *)0)) return;
 PointerSet *next = set->next;
 free(set);
 freePointerSet(next);
}

canonical_original_code:
void freePointerSet(struct pointer_set_s *set) {
 if (set == ((void *)0)) return;
 struct pointer_set_s *next = set->next;
 free(set);
 freePointerSet(next);
}

variable_types: struct pointer_set_s { void *ptr; struct pointer_set_s *next; } *


printPointerSet

decompiled_code:
size_t __fastcall printPointerSet(const void **a1)
{
const void **v1; // rbx

v1 = a1;
fprintf(stderr, "PointerSet@%p {\n", a1);
if ( a1 )
{
do
{
fprintf(stderr, "%p,\n", *v1);
v1 = (const void **)v1[1];
}
while ( v1 );
}
return fwrite("}\n", 1uLL, 2uLL, stderr);
}

canonical_decompiled_code:
size_t __fastcall func1(const void **a1)
{
const void **v1; // rbx

v1 = a1;
fprintf(stderr, "PointerSet@%p {\n", a1);
if ( a1 )
{
do
{
fprintf(stderr, "%p,\n", *v1);
v1 = (const void **)v1[1];
}
while ( v1 );
}
return fwrite("}\n", 1uLL, 2uLL, stderr);
}

original_code:
void printPointerSet(PointerSet *set) {
 fprintf(stderr, "PointerSet@%p {\n", (void *)set);
 PointerSet *s = set;
 while (s != ((void *)0)) {
  fprintf(stderr, "%p,\n", s->ptr);
  s = s->next;
 }
 fprintf(stderr, "}\n");
}

canonical_original_code:
void printPointerSet(struct pointer_set_s *set) {
 fprintf(stderr, "PointerSet@%p {\n", (void *)set);
 struct pointer_set_s *s = set;
 while (s != ((void *)0)) {
  fprintf(stderr, "%p,\n", s->ptr);
  s = s->next;
 }
 fprintf(stderr, "}\n");
}

user_defined_types: struct pointer_set_s { void *ptr; struct pointer_set_s *next; }


original_code:
double adjust_pit(struct flow_struct *flow_table, int curr, int edge_inx,
  double edge_elev, double cell, int slp_flag)
{
 int j;
 double total_perimeter;
 float xrun, yrun;
 float rise;
 struct adj_struct *aptr;
 if (flow_table[curr].num_adjacent > 0) {
  aptr = flow_table[curr].adj_list;
  total_perimeter = aptr->perimeter;
  for (j = 1; j < flow_table[curr].num_adjacent; j++) {
   aptr = aptr->next;
   total_perimeter += aptr->perimeter;
  }
 } else
  total_perimeter = 0.0;
 if (flow_table[curr].num_adjacent == 0) {
  if ((flow_table[curr].adj_list = (struct adj_struct *) malloc(
    sizeof(struct adj_struct))) == ((void *)0) ) {
   printf("\n Not enough memory");
   exit(1);
  }
  aptr = flow_table[curr].adj_list;
 }
 else {
  if ((aptr->next = (struct adj_struct *) malloc(
    sizeof(struct adj_struct))) == ((void *)0) ) {
   printf("\n Not enough memory");
   exit(1);
  }
  aptr = aptr->next;
 }
 aptr->patchID = flow_table[edge_inx].patchID;
 aptr->zoneID = flow_table[edge_inx].zoneID;
 aptr->hillID = flow_table[edge_inx].hillID;
 aptr->perimeter = total_perimeter;
 aptr->z = (float) edge_elev;
 aptr->inx = edge_inx;
 xrun = (flow_table[curr].x - flow_table[edge_inx].x);
 xrun = xrun * xrun;
 yrun = (flow_table[curr].y - flow_table[edge_inx].y);
 yrun = yrun * yrun;
 rise = flow_table[curr].z - flow_table[edge_inx].z;
 if ((yrun + xrun) <= 0.000000001)
  aptr->slope = rise;
 else
  aptr->slope = (float) (rise / (sqrt(xrun + yrun) * (cell)));
 aptr->gamma = 1.0;
 flow_table[curr].gamma_neigh = (float) (aptr->perimeter * aptr->slope);
 if (0 == slp_flag) {
  flow_table[curr].total_gamma = (float) (flow_table[curr].area
    * aptr->slope * cell * cell);
 }
 if (1 == slp_flag) {
  flow_table[curr].total_gamma = (float) (flow_table[curr].area
    * flow_table[curr].internal_slope * cell * cell);
 }
 if (2 == slp_flag) {
  flow_table[curr].total_gamma = (float) (flow_table[curr].area
    * flow_table[curr].max_slope * cell * cell);
 }
 flow_table[curr].z = (float) (edge_elev + 0.001);
 flow_table[curr].num_adjacent += 1;
 return (1);
}

canonical_original_code:
double adjust_pit(struct flow_struct *flow_table, int curr, int edge_inx, double edge_elev, double cell, int slp_flag)
{
 int j;
 double total_perimeter;
 float xrun; float yrun;
 float rise;
 struct adj_struct *aptr;
 if (flow_table[curr].num_adjacent > 0) {
  aptr = flow_table[curr].adj_list;
  total_perimeter = aptr->perimeter;
  for (j = 1; j < flow_table[curr].num_adjacent; j++) {
   aptr = aptr->next;
   total_perimeter += aptr->perimeter;
  }
 } else
  total_perimeter = 0.0;
 if (flow_table[curr].num_adjacent == 0) {
  if ((flow_table[curr].adj_list = (struct adj_struct *) malloc(
    sizeof(struct adj_struct))) == ((void *)0) ) {
   printf("\n Not enough memory");
   exit(1);
  }
  aptr = flow_table[curr].adj_list;
 }
 else {
  if ((aptr->next = (struct adj_struct *) malloc(
    sizeof(struct adj_struct))) == ((void *)0) ) {
   printf("\n Not enough memory");
   exit(1);
  }
  aptr = aptr->next;
 }
 aptr->patchID = flow_table[edge_inx].patchID;
 aptr->zoneID = flow_table[edge_inx].zoneID;
 aptr->hillID = flow_table[edge_inx].hillID;
 aptr->perimeter = total_perimeter;
 aptr->z = (float) edge_elev;
 aptr->inx = edge_inx;
 xrun = (flow_table[curr].x - flow_table[edge_inx].x);
 xrun = xrun * xrun;
 yrun = (flow_table[curr].y - flow_table[edge_inx].y);
 yrun = yrun * yrun;
 rise = flow_table[curr].z - flow_table[edge_inx].z;
 if ((yrun + xrun) <= 0.000000001)
  aptr->slope = rise;
 else
  aptr->slope = (float) (rise / (sqrt(xrun + yrun) * (cell)));
 aptr->gamma = 1.0;
 flow_table[curr].gamma_neigh = (float) (aptr->perimeter * aptr->slope);
 if (0 == slp_flag) {
  flow_table[curr].total_gamma = (float) (flow_table[curr].area
    * aptr->slope * cell * cell);
 }
 if (1 == slp_flag) {
  flow_table[curr].total_gamma = (float) (flow_table[curr].area
    * flow_table[curr].internal_slope * cell * cell);
 }
 if (2 == slp_flag) {
  flow_table[curr].total_gamma = (float) (flow_table[curr].area
    * flow_table[curr].max_slope * cell * cell);
 }
 flow_table[curr].z = (float) (edge_elev + 0.001);
 flow_table[curr].num_adjacent += 1;
 return (1);
}

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

variable_types: curr int

variable_types: cell double

variable_types: j int

variable_types: xrun float

variable_types: yrun float

variable_types: rise float

return_type: double

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


decompiled_code:
_QWORD *new_struct_index()
{
_QWORD *result; // rax

result = malloc(0xE8uLL);
if ( !result )
_assert_fail("i", "util/index_struct_fields.c", 0xDu, "new_struct_index");
*result = 0LL;
result[1] = 0LL;
result[2] = 0LL;
result[3] = 0LL;
result[4] = 0LL;
result[5] = 0LL;
result[6] = 0LL;
result[7] = 0LL;
result[8] = 0LL;
result[9] = 0LL;
result[10] = 0LL;
result[11] = 0LL;
result[12] = 0LL;
result[13] = 0LL;
result[14] = 0LL;
result[15] = 0LL;
result[16] = 0LL;
result[17] = 0LL;
result[18] = 0LL;
result[19] = 0LL;
result[20] = 0LL;
result[21] = 0LL;
result[22] = 0LL;
result[23] = 0LL;
return result;
}

canonical_decompiled_code:
_QWORD *func0()
{
_QWORD *result; // rax

result = malloc(0xE8uLL);
if ( !result )
_assert_fail("i", "util/index_struct_fields.c", 0xDu, "new_struct_index");
*result = 0LL;
result[1] = 0LL;
result[2] = 0LL;
result[3] = 0LL;
result[4] = 0LL;
result[5] = 0LL;
result[6] = 0LL;
result[7] = 0LL;
result[8] = 0LL;
result[9] = 0LL;
result[10] = 0LL;
result[11] = 0LL;
result[12] = 0LL;
result[13] = 0LL;
result[14] = 0LL;
result[15] = 0LL;
result[16] = 0LL;
result[17] = 0LL;
result[18] = 0LL;
result[19] = 0LL;
result[20] = 0LL;
result[21] = 0LL;
result[22] = 0LL;
result[23] = 0LL;
return result;
}

original_code:
StructIndex_t *new_struct_index() {
 StructIndex_t *i = (StructIndex_t *) malloc(sizeof(StructIndex_t));
 ((i) ? (void) (0) : __assert_fail ("i", "util/index_struct_fields.c", 13, __extension__ __PRETTY_FUNCTION__));
 i->patch_object = ((void *)0);
 i->accumulate_patch_object = ((void *)0);
 i->patch_hourly_object = ((void *)0);
 i->patch_fire_water_object = ((void *)0);
 i->rooting_zone_object = ((void *)0);
 i->snowpack_object = ((void *)0);
 i->soil_c_object = ((void *)0);
 i->soil_n_object = ((void *)0);
 i->litter_object = ((void *)0);
 i->litter_c_object = ((void *)0);
 i->litter_n_object = ((void *)0);
 i->cdayflux_patch_struct = ((void *)0);
 i->ndayflux_patch_struct = ((void *)0);
 i->canopy_strata_object = ((void *)0);
 i->accumulate_strata_object = ((void *)0);
 i->cdayflux_struct = ((void *)0);
 i->cstate_struct = ((void *)0);
 i->target_object = ((void *)0);
 i->epvar_struct = ((void *)0);
 i->nstate_struct = ((void *)0);
 i->ndayflux_struct = ((void *)0);
 i->phenology_struct = ((void *)0);
 i->fire_effects_object = ((void *)0);
 i->mult_conduct_struct = ((void *)0);
 i->hillslope_object == ((void *)0);
 i->gw_object == ((void *)0);
 i->zone_object == ((void *)0);
 i->accumulate_zone_object == ((void *)0);
 i->metvar_struct == ((void *)0);
 return i;
}

canonical_original_code:
struct struct_index_s *new_struct_index() {
 struct struct_index_s *i = (StructIndex_t *) malloc(sizeof(StructIndex_t));
 ((i) ? (void) (0) : __assert_fail ("i", "util/index_struct_fields.c", 13, __extension__ __PRETTY_FUNCTION__));
 i->patch_object = ((void *)0);
 i->accumulate_patch_object = ((void *)0);
 i->patch_hourly_object = ((void *)0);
 i->patch_fire_water_object = ((void *)0);
 i->rooting_zone_object = ((void *)0);
 i->snowpack_object = ((void *)0);
 i->soil_c_object = ((void *)0);
 i->soil_n_object = ((void *)0);
 i->litter_object = ((void *)0);
 i->litter_c_object = ((void *)0);
 i->litter_n_object = ((void *)0);
 i->cdayflux_patch_struct = ((void *)0);
 i->ndayflux_patch_struct = ((void *)0);
 i->canopy_strata_object = ((void *)0);
 i->accumulate_strata_object = ((void *)0);
 i->cdayflux_struct = ((void *)0);
 i->cstate_struct = ((void *)0);
 i->target_object = ((void *)0);
 i->epvar_struct = ((void *)0);
 i->nstate_struct = ((void *)0);
 i->ndayflux_struct = ((void *)0);
 i->phenology_struct = ((void *)0);
 i->fire_effects_object = ((void *)0);
 i->mult_conduct_struct = ((void *)0);
 i->hillslope_object == ((void *)0);
 i->gw_object == ((void *)0);
 i->zone_object == ((void *)0);
 i->accumulate_zone_object == ((void *)0);
 i->metvar_struct == ((void *)0);
 return i;
}

variable_types: struct struct_index_s { 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; } *patch_object; struct dict_s *accumulate_patch_object; struct dict_s *patch_hourly_object; struct dict_s *patch_fire_water_object; struct dict_s *rooting_zone_object; struct dict_s *snowpack_object; struct dict_s *soil_c_object; struct dict_s *soil_n_object; struct dict_s *litter_object; struct dict_s *litter_c_object; struct dict_s *litter_n_object; struct dict_s *cdayflux_patch_struct; struct dict_s *ndayflux_patch_struct; struct dict_s *canopy_strata_object; struct dict_s *accumulate_strata_object; struct dict_s *cdayflux_struct; struct dict_s *cstate_struct; struct dict_s *target_object; struct dict_s *epvar_struct; struct dict_s *nstate_struct; struct dict_s *ndayflux_struct; struct dict_s *phenology_struct; struct dict_s *fire_effects_object; struct dict_s *mult_conduct_struct; struct dict_s *hillslope_object; struct dict_s *gw_object; struct dict_s *zone_object; struct dict_s *accumulate_zone_object; struct dict_s *metvar_struct; } *

user_defined_types: struct struct_index_s { struct dict_s *patch_object; struct dict_s *accumulate_patch_object; struct dict_s *patch_hourly_object; struct dict_s *patch_fire_water_object; struct dict_s *rooting_zone_object; struct dict_s *snowpack_object; struct dict_s *soil_c_object; struct dict_s *soil_n_object; struct dict_s *litter_object; struct dict_s *litter_c_object; struct dict_s *litter_n_object; struct dict_s *cdayflux_patch_struct; struct dict_s *ndayflux_patch_struct; struct dict_s *canopy_strata_object; struct dict_s *accumulate_strata_object; struct dict_s *cdayflux_struct; struct dict_s *cstate_struct; struct dict_s *target_object; struct dict_s *epvar_struct; struct dict_s *nstate_struct; struct dict_s *ndayflux_struct; struct dict_s *phenology_struct; struct dict_s *fire_effects_object; struct dict_s *mult_conduct_struct; struct dict_s *hillslope_object; struct dict_s *gw_object; struct dict_s *zone_object; struct dict_s *accumulate_zone_object; struct dict_s *metvar_struct; }

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


decompiled_code:
void __fastcall free_struct_index(void *ptr)
{
if ( ptr )
{
if ( *(_QWORD *)ptr )
freeDictionary();
if ( *((_QWORD *)ptr + 1) )
freeDictionary();
if ( *((_QWORD *)ptr + 2) )
freeDictionary();
if ( *((_QWORD *)ptr + 3) )
freeDictionary();
if ( *((_QWORD *)ptr + 4) )
freeDictionary();
if ( *((_QWORD *)ptr + 5) )
freeDictionary();
if ( *((_QWORD *)ptr + 6) )
freeDictionary();
if ( *((_QWORD *)ptr + 7) )
freeDictionary();
if ( *((_QWORD *)ptr + 8) )
freeDictionary();
if ( *((_QWORD *)ptr + 9) )
freeDictionary();
if ( *((_QWORD *)ptr + 10) )
freeDictionary();
if ( *((_QWORD *)ptr + 11) )
freeDictionary();
if ( *((_QWORD *)ptr + 12) )
freeDictionary();
if ( *((_QWORD *)ptr + 13) )
freeDictionary();
if ( *((_QWORD *)ptr + 14) )
freeDictionary();
if ( *((_QWORD *)ptr + 15) )
freeDictionary();
if ( *((_QWORD *)ptr + 16) )
freeDictionary();
if ( *((_QWORD *)ptr + 17) )
freeDictionary();
if ( *((_QWORD *)ptr + 18) )
freeDictionary();
if ( *((_QWORD *)ptr + 19) )
freeDictionary();
if ( *((_QWORD *)ptr + 20) )
freeDictionary();
if ( *((_QWORD *)ptr + 21) )
freeDictionary();
if ( *((_QWORD *)ptr + 22) )
freeDictionary();
if ( *((_QWORD *)ptr + 23) )
freeDictionary();
if ( *((_QWORD *)ptr + 24) )
freeDictionary();
if ( *((_QWORD *)ptr + 25) )
freeDictionary();
if ( *((_QWORD *)ptr + 26) )
freeDictionary();
if ( *((_QWORD *)ptr + 27) )
freeDictionary();
if ( *((_QWORD *)ptr + 28) )
freeDictionary();
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func1(void *ptr)
{
if ( ptr )
{
if ( *(_QWORD *)ptr )
freeDictionary();
if ( *((_QWORD *)ptr + 1) )
freeDictionary();
if ( *((_QWORD *)ptr + 2) )
freeDictionary();
if ( *((_QWORD *)ptr + 3) )
freeDictionary();
if ( *((_QWORD *)ptr + 4) )
freeDictionary();
if ( *((_QWORD *)ptr + 5) )
freeDictionary();
if ( *((_QWORD *)ptr + 6) )
freeDictionary();
if ( *((_QWORD *)ptr + 7) )
freeDictionary();
if ( *((_QWORD *)ptr + 8) )
freeDictionary();
if ( *((_QWORD *)ptr + 9) )
freeDictionary();
if ( *((_QWORD *)ptr + 10) )
freeDictionary();
if ( *((_QWORD *)ptr + 11) )
freeDictionary();
if ( *((_QWORD *)ptr + 12) )
freeDictionary();
if ( *((_QWORD *)ptr + 13) )
freeDictionary();
if ( *((_QWORD *)ptr + 14) )
freeDictionary();
if ( *((_QWORD *)ptr + 15) )
freeDictionary();
if ( *((_QWORD *)ptr + 16) )
freeDictionary();
if ( *((_QWORD *)ptr + 17) )
freeDictionary();
if ( *((_QWORD *)ptr + 18) )
freeDictionary();
if ( *((_QWORD *)ptr + 19) )
freeDictionary();
if ( *((_QWORD *)ptr + 20) )
freeDictionary();
if ( *((_QWORD *)ptr + 21) )
freeDictionary();
if ( *((_QWORD *)ptr + 22) )
freeDictionary();
if ( *((_QWORD *)ptr + 23) )
freeDictionary();
if ( *((_QWORD *)ptr + 24) )
freeDictionary();
if ( *((_QWORD *)ptr + 25) )
freeDictionary();
if ( *((_QWORD *)ptr + 26) )
freeDictionary();
if ( *((_QWORD *)ptr + 27) )
freeDictionary();
if ( *((_QWORD *)ptr + 28) )
freeDictionary();
free(ptr);
}
}

original_code:
void free_struct_index(StructIndex_t *i) {
 if (i == ((void *)0)) return;
 if (i->patch_object) {
  freeDictionary(i->patch_object);
 }
 if (i->accumulate_patch_object) {
  freeDictionary(i->accumulate_patch_object);
 }
 if (i->patch_hourly_object) {
  freeDictionary(i->patch_hourly_object);
 }
 if (i->patch_fire_water_object) {
  freeDictionary(i->patch_fire_water_object);
 }
 if (i->rooting_zone_object) {
  freeDictionary(i->rooting_zone_object);
 }
 if (i->snowpack_object) {
  freeDictionary(i->snowpack_object);
 }
 if (i->soil_c_object) {
  freeDictionary(i->soil_c_object);
 }
 if (i->soil_n_object) {
  freeDictionary(i->soil_n_object);
 }
 if (i->litter_object) {
  freeDictionary(i->litter_object);
 }
 if (i->litter_c_object) {
  freeDictionary(i->litter_c_object);
 }
 if (i->litter_n_object) {
  freeDictionary(i->litter_n_object);
 }
 if (i->cdayflux_patch_struct) {
  freeDictionary(i->cdayflux_patch_struct);
 }
 if (i->ndayflux_patch_struct) {
  freeDictionary(i->ndayflux_patch_struct);
 }
 if (i->canopy_strata_object) {
  freeDictionary(i->canopy_strata_object);
 }
 if (i->accumulate_strata_object) {
  freeDictionary(i->accumulate_strata_object);
 }
 if (i->cdayflux_struct) {
  freeDictionary(i->cdayflux_struct);
 }
 if (i->cstate_struct) {
  freeDictionary(i->cstate_struct);
 }
 if (i->target_object) {
  freeDictionary(i->target_object);
 }
 if (i->epvar_struct) {
  freeDictionary(i->epvar_struct);
 }
 if (i->nstate_struct) {
  freeDictionary(i->nstate_struct);
 }
 if (i->ndayflux_struct) {
  freeDictionary(i->ndayflux_struct);
 }
 if (i->phenology_struct) {
  freeDictionary(i->phenology_struct);
 }
 if (i->fire_effects_object) {
  freeDictionary(i->fire_effects_object);
 }
 if (i->mult_conduct_struct) {
  freeDictionary(i->mult_conduct_struct);
 }
 if (i->hillslope_object) {
  freeDictionary(i->hillslope_object);
 }
 if (i->gw_object) {
  freeDictionary(i->gw_object);
 }
 if (i->zone_object) {
  freeDictionary(i->zone_object);
 }
 if (i->accumulate_zone_object) {
  freeDictionary(i->accumulate_zone_object);
 }
 if (i->metvar_struct) {
  freeDictionary(i->metvar_struct);
 }
 free(i);
}

canonical_original_code:
void free_struct_index(struct struct_index_s *i) {
 if (i == ((void *)0)) return;
 if (i->patch_object) {
  freeDictionary(i->patch_object);
 }
 if (i->accumulate_patch_object) {
  freeDictionary(i->accumulate_patch_object);
 }
 if (i->patch_hourly_object) {
  freeDictionary(i->patch_hourly_object);
 }
 if (i->patch_fire_water_object) {
  freeDictionary(i->patch_fire_water_object);
 }
 if (i->rooting_zone_object) {
  freeDictionary(i->rooting_zone_object);
 }
 if (i->snowpack_object) {
  freeDictionary(i->snowpack_object);
 }
 if (i->soil_c_object) {
  freeDictionary(i->soil_c_object);
 }
 if (i->soil_n_object) {
  freeDictionary(i->soil_n_object);
 }
 if (i->litter_object) {
  freeDictionary(i->litter_object);
 }
 if (i->litter_c_object) {
  freeDictionary(i->litter_c_object);
 }
 if (i->litter_n_object) {
  freeDictionary(i->litter_n_object);
 }
 if (i->cdayflux_patch_struct) {
  freeDictionary(i->cdayflux_patch_struct);
 }
 if (i->ndayflux_patch_struct) {
  freeDictionary(i->ndayflux_patch_struct);
 }
 if (i->canopy_strata_object) {
  freeDictionary(i->canopy_strata_object);
 }
 if (i->accumulate_strata_object) {
  freeDictionary(i->accumulate_strata_object);
 }
 if (i->cdayflux_struct) {
  freeDictionary(i->cdayflux_struct);
 }
 if (i->cstate_struct) {
  freeDictionary(i->cstate_struct);
 }
 if (i->target_object) {
  freeDictionary(i->target_object);
 }
 if (i->epvar_struct) {
  freeDictionary(i->epvar_struct);
 }
 if (i->nstate_struct) {
  freeDictionary(i->nstate_struct);
 }
 if (i->ndayflux_struct) {
  freeDictionary(i->ndayflux_struct);
 }
 if (i->phenology_struct) {
  freeDictionary(i->phenology_struct);
 }
 if (i->fire_effects_object) {
  freeDictionary(i->fire_effects_object);
 }
 if (i->mult_conduct_struct) {
  freeDictionary(i->mult_conduct_struct);
 }
 if (i->hillslope_object) {
  freeDictionary(i->hillslope_object);
 }
 if (i->gw_object) {
  freeDictionary(i->gw_object);
 }
 if (i->zone_object) {
  freeDictionary(i->zone_object);
 }
 if (i->accumulate_zone_object) {
  freeDictionary(i->accumulate_zone_object);
 }
 if (i->metvar_struct) {
  freeDictionary(i->metvar_struct);
 }
 free(i);
}

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:
double __fastcall leaf_conductance_tavg_curve(double a1, double a2, double a3, double a4)
{
double result; // xmm0_8
double v6; // xmm4_8
double v7; // xmm0_8
double v8; // xmm0_8
double x; // [rsp+0h] [rbp-30h]
double xa; // [rsp+0h] [rbp-30h]
double v11; // [rsp+18h] [rbp-18h]

result = 0.0;
if ( a1 >= 0.0 && a1 <= a3 )
{
v11 = a1;
x = (a3 - a1) / (a3 - a2);
pow(x, (a3 - a2) / (a2 + 10.0));
v6 = v11;
if ( COERCE_DOUBLE(COERCE_UNSIGNED_INT64(v11 - a2) & LC3) > 0.1 )
{
v7 = log(x);
xa = exp(v7 * (a3 - a2) * a4);
v8 = exp((v11 - a2) * a4);
v6 = v11;
result = v8 * xa;
}
else
{
result = *(double *)&LC0;
}
if ( v6 < 5.0 )
result = result * v6 / 5.0;
}
return result;
}

canonical_decompiled_code:
double __fastcall func0(double a1, double a2, double a3, double a4)
{
double result; // xmm0_8
double v6; // xmm4_8
double v7; // xmm0_8
double v8; // xmm0_8
double x; // [rsp+0h] [rbp-30h]
double xa; // [rsp+0h] [rbp-30h]
double v11; // [rsp+18h] [rbp-18h]

result = 0.0;
if ( a1 >= 0.0 && a1 <= a3 )
{
v11 = a1;
x = (a3 - a1) / (a3 - a2);
pow(x, (a3 - a2) / (a2 + 10.0));
v6 = v11;
if ( COERCE_DOUBLE(COERCE_UNSIGNED_INT64(v11 - a2) & LC3) > 0.1 )
{
v7 = log(x);
xa = exp(v7 * (a3 - a2) * a4);
v8 = exp((v11 - a2) * a4);
v6 = v11;
result = v8 * xa;
}
else
{
result = *(double *)&LC0;
}
if ( v6 < 5.0 )
result = result * v6 / 5.0;
}
return result;
}

original_code:
double leaf_conductance_tavg_curve( double Tair_mean_day,
         double topt,
         double tmax,
         double tcoef)
{
 double dt;
 double m_tavg;
 double temp;
 double pp;
 if ( Tair_mean_day < 0.0 || Tair_mean_day > tmax ){
  m_tavg = 0.0;
 }
 else{
  pp = pow(((tmax-Tair_mean_day)/(tmax - topt)),((tmax - topt)/(topt +10)));
  m_tavg = (Tair_mean_day +10 ) / (topt + 10 ) * pp;
  dt = tmax - topt;
  if (fabs(Tair_mean_day-topt) > 0.1) {
  temp = exp(log((tmax-Tair_mean_day)/dt) * dt * tcoef);
  m_tavg = temp * exp(tcoef * (Tair_mean_day - topt));
  }
  else
  { m_tavg = 1.0; }
  if ( Tair_mean_day < 5.0 ){
   m_tavg = m_tavg * Tair_mean_day / 5.0;
  }
 }
 return(m_tavg);
}

canonical_original_code:
double leaf_conductance_tavg_curve(double Tair_mean_day, double topt, double tmax, double tcoef)
{
 double dt;
 double m_tavg;
 double temp;
 double pp;
 if ( Tair_mean_day < 0.0 || Tair_mean_day > tmax ){
  m_tavg = 0.0;
 }
 else{
  pp = pow(((tmax-Tair_mean_day)/(tmax - topt)),((tmax - topt)/(topt +10)));
  m_tavg = (Tair_mean_day +10 ) / (topt + 10 ) * pp;
  dt = tmax - topt;
  if (fabs(Tair_mean_day-topt) > 0.1) {
  temp = exp(log((tmax-Tair_mean_day)/dt) * dt * tcoef);
  m_tavg = temp * exp(tcoef * (Tair_mean_day - topt));
  }
  else
  { m_tavg = 1.0; }
  if ( Tair_mean_day < 5.0 ){
   m_tavg = m_tavg * Tair_mean_day / 5.0;
  }
 }
 return(m_tavg);
}

variable_types: topt double

variable_types: tmax double

variable_types: tcoef double

variable_types: dt double

variable_types: temp double

variable_types: pp double


original_code:
double compute_return_flow(
       int verbose_flag,
       double detention_store_size,
       double sat_deficit,
       struct litter_object *litter )
{
 double return_flow;
 double excess, add_to_litter;
 excess = ((0) > (-1 * sat_deficit - detention_store_size) ? (0) : (-1 * sat_deficit - detention_store_size));
 return_flow = ((0) > (excess) ? (0) : (excess));
 add_to_litter = (((litter[0].rain_capacity - litter[0].rain_stored)) > (0.0) ? ((litter[0].rain_capacity - litter[0].rain_stored)) : (0.0));
 return_flow -= add_to_litter;
 litter[0].rain_stored += add_to_litter;
 return(return_flow);
}

canonical_original_code:
double compute_return_flow(int verbose_flag, double detention_store_size, double sat_deficit, struct litter_object *litter)
{
 double return_flow;
 double excess; double add_to_litter;
 excess = ((0) > (-1 * sat_deficit - detention_store_size) ? (0) : (-1 * sat_deficit - detention_store_size));
 return_flow = ((0) > (excess) ? (0) : (excess));
 add_to_litter = (((litter[0].rain_capacity - litter[0].rain_stored)) > (0.0) ? ((litter[0].rain_capacity - litter[0].rain_stored)) : (0.0));
 return_flow -= add_to_litter;
 litter[0].rain_stored += add_to_litter;
 return(return_flow);
}

variable_types: struct litter_object { double cover_fraction; double depth; double density; double rain_stored; double NO3_stored; double gsurf; double proj_pai; double rain_capacity; double gl_c; double gsurf_slope; double gsurf_intercept; double moist_coef; double T; } *

variable_types: excess double


decompiled_code:
__int64 __fastcall create_flow_adjacency(__int64 a1, int a2, _QWORD *a3, double a4)
{
__int64 result; // rax
_DWORD *v5; // rax
float v6; // xmm0_4
__int64 *v7; // rbx
int v8; // xmm1_4
__int64 v9; // rsi
__int64 v10; // rcx
int v11; // xmm1_4

if ( a1 )
{
if ( a3 )
{
if ( a2 < 0 )
{
fwrite("ERROR: Flow table index less than zero.\n", 1uLL, 0x28uLL, stderr);
result = 0LL;
}
else if ( a4 >= 0.0 && a4 <= 1.0 )
{
v5 = calloc(1uLL, 0x38uLL);
if ( v5 )
{
v5[3] = a2;
v6 = a4;
*((_QWORD *)v5 + 6) = 0LL;
*((_QWORD *)v5 + 3) = 0LL;
v7 = (__int64 *)(160LL * a2 + a1);
*((float *)v5 + 9) = v6;
v8 = *((_DWORD *)v7 + 17);
v9 = *v7;
v5[2] = *((_DWORD *)v7 + 2);
v10 = *(__int64 *)((char *)v7 + 20);
v5[8] = v8;
v11 = *((_DWORD *)v7 + 9);
*(_QWORD *)v5 = v9;
*((_QWORD *)v5 + 2) = v10;
*a3 = v5;
v5[10] = v11;
result = 1LL;
}
else
{
fwrite("ERROR: Failed to allocate flow table adjacency struct.\n", 1uLL, 0x37uLL, stderr);
result = 0LL;
}
}
else
{
fwrite("ERROR: Proportion is out of bounds.\n", 1uLL, 0x24uLL, stderr);
result = 0LL;
}
}
else
{
fwrite("ERROR: Return adjacency pointer is NULL.\n", 1uLL, 0x29uLL, stderr);
result = 0LL;
}
}
else
{
fwrite("ERROR: Flow table pointer is NULL.\n", 1uLL, 0x23uLL, stderr);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, int a2, _QWORD *a3, double a4)
{
__int64 result; // rax
_DWORD *v5; // rax
float v6; // xmm0_4
__int64 *v7; // rbx
int v8; // xmm1_4
__int64 v9; // rsi
__int64 v10; // rcx
int v11; // xmm1_4

if ( a1 )
{
if ( a3 )
{
if ( a2 < 0 )
{
fwrite("ERROR: Flow table index less than zero.\n", 1uLL, 0x28uLL, stderr);
result = 0LL;
}
else if ( a4 >= 0.0 && a4 <= 1.0 )
{
v5 = calloc(1uLL, 0x38uLL);
if ( v5 )
{
v5[3] = a2;
v6 = a4;
*((_QWORD *)v5 + 6) = 0LL;
*((_QWORD *)v5 + 3) = 0LL;
v7 = (__int64 *)(160LL * a2 + a1);
*((float *)v5 + 9) = v6;
v8 = *((_DWORD *)v7 + 17);
v9 = *v7;
v5[2] = *((_DWORD *)v7 + 2);
v10 = *(__int64 *)((char *)v7 + 20);
v5[8] = v8;
v11 = *((_DWORD *)v7 + 9);
*(_QWORD *)v5 = v9;
*((_QWORD *)v5 + 2) = v10;
*a3 = v5;
v5[10] = v11;
result = 1LL;
}
else
{
fwrite("ERROR: Failed to allocate flow table adjacency struct.\n", 1uLL, 0x37uLL, stderr);
result = 0LL;
}
}
else
{
fwrite("ERROR: Proportion is out of bounds.\n", 1uLL, 0x24uLL, stderr);
result = 0LL;
}
}
else
{
fwrite("ERROR: Return adjacency pointer is NULL.\n", 1uLL, 0x29uLL, stderr);
result = 0LL;
}
}
else
{
fwrite("ERROR: Flow table pointer is NULL.\n", 1uLL, 0x23uLL, stderr);
result = 0LL;
}
return result;
}

original_code:
bool create_flow_adjacency(
    struct flow_struct* _flow_table,
    int _index,
    double _proportion,
    struct adj_struct** _rtn_adjacency)
{
    bool result = true;
    if(_flow_table == 0) {
        fprintf(stderr, "ERROR: Flow table pointer is NULL.\n");
        result = false;
    } else if(_rtn_adjacency == 0) {
        fprintf(stderr, "ERROR: Return adjacency pointer is NULL.\n");
        result = false;
    } else if(_index < 0) {
        fprintf(stderr, "ERROR: Flow table index less than zero.\n");
        result = false;
    } else if(_proportion < 0 || _proportion > 1) {
        fprintf(stderr, "ERROR: Proportion is out of bounds.\n");
        result = false;
    } else {
        struct adj_struct* adjacency = (struct adj_struct*)calloc(1, sizeof(struct adj_struct));
        if(adjacency == 0) {
            fprintf(stderr, "ERROR: Failed to allocate flow table adjacency struct.\n");
            result = false;
        } else {
            adjacency->patchID = _flow_table[_index].patchID;
            adjacency->hillID = _flow_table[_index].hillID;
            adjacency->zoneID = _flow_table[_index].zoneID;
            adjacency->landtype = _flow_table[_index].land;
            adjacency->sewertype = _flow_table[_index].sewer;
            adjacency->slope = _flow_table[_index].slope;
            adjacency->z = _flow_table[_index].z;
            adjacency->inx = _index;
            adjacency->gamma = (float)_proportion;
            adjacency->next = 0;
            adjacency->perimeter = 0;
            *_rtn_adjacency = adjacency;
        }
    }
    return result;
}

canonical_original_code:
short create_flow_adjacency(struct flow_struct *_flow_table, int _index, double _proportion, struct adj_struct **_rtn_adjacency)
{
    short result = true;
    if(_flow_table == 0) {
        fprintf(stderr, "ERROR: Flow table pointer is NULL.\n");
        result = false;
    } else if(_rtn_adjacency == 0) {
        fprintf(stderr, "ERROR: Return adjacency pointer is NULL.\n");
        result = false;
    } else if(_index < 0) {
        fprintf(stderr, "ERROR: Flow table index less than zero.\n");
        result = false;
    } else if(_proportion < 0 || _proportion > 1) {
        fprintf(stderr, "ERROR: Proportion is out of bounds.\n");
        result = false;
    } else {
        struct adj_struct *adjacency = (struct adj_struct*)calloc(1, sizeof(struct adj_struct));
        if(adjacency == 0) {
            fprintf(stderr, "ERROR: Failed to allocate flow table adjacency struct.\n");
            result = false;
        } else {
            adjacency->patchID = _flow_table[_index].patchID;
            adjacency->hillID = _flow_table[_index].hillID;
            adjacency->zoneID = _flow_table[_index].zoneID;
            adjacency->landtype = _flow_table[_index].land;
            adjacency->sewertype = _flow_table[_index].sewer;
            adjacency->slope = _flow_table[_index].slope;
            adjacency->z = _flow_table[_index].z;
            adjacency->inx = _index;
            adjacency->gamma = (float)_proportion;
            adjacency->next = 0;
            adjacency->perimeter = 0;
            *_rtn_adjacency = adjacency;
        }
    }
    return result;
}

variable_types: result short

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

return_type: short

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


decompiled_code:
__int64 __fastcall add_adjacency_to_contributor(__int64 a1, int a2, __int64 a3)
{
__int64 v3; // rdi
__int64 v4; // rax
__int64 result; // rax

if ( a1 )
{
if ( a3 )
{
if ( a2 < 0 )
{
fwrite("ERROR: Contributor index is less than 0.\n", 1uLL, 0x29uLL, stderr);
result = 0LL;
}
else
{
v3 = 160LL * a2 + a1;
v4 = *(_QWORD *)(v3 + 128);
*(_QWORD *)(v3 + 128) = a3;
*(_QWORD *)(a3 + 48) = v4;
result = 1LL;
++*(_DWORD *)(v3 + 96);
*(_QWORD *)(v3 + 136) = a3;
}
}
else
{
fwrite("ERROR: Adjacency pointer is NULL.\n", 1uLL, 0x22uLL, stderr);
result = 0LL;
}
}
else
{
fwrite("ERROR: Flow table pointer is NULL.\n", 1uLL, 0x23uLL, stderr);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, int a2, __int64 a3)
{
__int64 v3; // rdi
__int64 v4; // rax
__int64 result; // rax

if ( a1 )
{
if ( a3 )
{
if ( a2 < 0 )
{
fwrite("ERROR: Contributor index is less than 0.\n", 1uLL, 0x29uLL, stderr);
result = 0LL;
}
else
{
v3 = 160LL * a2 + a1;
v4 = *(_QWORD *)(v3 + 128);
*(_QWORD *)(v3 + 128) = a3;
*(_QWORD *)(a3 + 48) = v4;
result = 1LL;
++*(_DWORD *)(v3 + 96);
*(_QWORD *)(v3 + 136) = a3;
}
}
else
{
fwrite("ERROR: Adjacency pointer is NULL.\n", 1uLL, 0x22uLL, stderr);
result = 0LL;
}
}
else
{
fwrite("ERROR: Flow table pointer is NULL.\n", 1uLL, 0x23uLL, stderr);
result = 0LL;
}
return result;
}

original_code:
bool add_adjacency_to_contributor(
    struct flow_struct* _flow_table,
    int _index,
    struct adj_struct* _adjacency)
{
    bool result = true;
    if(_flow_table == 0) {
        fprintf(stderr, "ERROR: Flow table pointer is NULL.\n");
        result = false;
    } else if(_adjacency == 0) {
        fprintf(stderr, "ERROR: Adjacency pointer is NULL.\n");
        result = false;
    } else if(_index < 0) {
        fprintf(stderr, "ERROR: Contributor index is less than 0.\n");
        result = false;
    } else {
        struct adj_struct* adjacency_list = _flow_table[_index].adj_list;
        _flow_table[_index].adj_list = _adjacency;
        _adjacency->next = adjacency_list;
        _flow_table[_index].adj_ptr = _flow_table[_index].adj_list;
        ++_flow_table[_index].num_adjacent;
    }
    return result;
}

canonical_original_code:
short add_adjacency_to_contributor(struct flow_struct *_flow_table, int _index, struct adj_struct *_adjacency)
{
    short result = true;
    if(_flow_table == 0) {
        fprintf(stderr, "ERROR: Flow table pointer is NULL.\n");
        result = false;
    } else if(_adjacency == 0) {
        fprintf(stderr, "ERROR: Adjacency pointer is NULL.\n");
        result = false;
    } else if(_index < 0) {
        fprintf(stderr, "ERROR: Contributor index is less than 0.\n");
        result = false;
    } else {
        struct adj_struct *adjacency_list = _flow_table[_index].adj_list;
        _flow_table[_index].adj_list = _adjacency;
        _adjacency->next = adjacency_list;
        _flow_table[_index].adj_ptr = _flow_table[_index].adj_list;
        ++_flow_table[_index].num_adjacent;
    }
    return result;
}

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


decompiled_code:
__int64 __fastcall add_flow_to_table(__int64 a1, __int64 a2, unsigned int a3, unsigned int a4, unsigned int a5, unsigned int a6, double a7, __int64 a8, int a9, __int64 a10, __int64 a11, __int64 a12, __int64 a13, __int64 a14)
{
unsigned int v14; // er8
__int64 result; // rax
int v19; // er12
int v20; // eax
int v21; // er8
unsigned int v22; // er8
unsigned int v24; // [rsp+0h] [rbp-58h]
unsigned int v25; // [rsp+8h] [rbp-50h]
unsigned int v26; // [rsp+8h] [rbp-50h]
unsigned int v27; // [rsp+14h] [rbp-44h]
int v28; // [rsp+20h] [rbp-38h] BYREF
int v29; // [rsp+24h] [rbp-34h] BYREF
__int64 v30[6]; // [rsp+28h] [rbp-30h] BYREF

v28 = 0;
v29 = 0;
if ( a8 )
{
if ( a11 )
{
if ( a7 >= 0.0 && a7 <= 1.0 )
{
v27 = row_col_to_index(a1, a2, a5, a6, &v28);
if ( (_WORD)v27 )
{
v25 = row_col_to_index(a3, a4, a5, a6, &v29);
if ( (_WORD)v25 )
{
v19 = find_patch(
a10,
*(unsigned int *)(a11 + 4LL * v28),
*(unsigned int *)(a13 + 4LL * v28),
*(unsigned int *)(a12 + 4LL * v28));
if ( v19 == -1 )
{
fprintf(
stderr,
"add_flow_to_table:125: Unable to find patch: patchID: %d, zoneID: %d, hillID: %d\n",
*(unsigned int *)(a11 + 4LL * v28),
*(unsigned int *)(a13 + 4LL * v28),
*(unsigned int *)(a12 + 4LL * v28));
exit(1);
}
v20 = find_patch(
a10,
*(unsigned int *)(a11 + 4LL * v29),
*(unsigned int *)(a13 + 4LL * v29),
*(unsigned int *)(a12 + 4LL * v29));
v21 = *(_DWORD *)(a11 + 4LL * v29);
if ( v21 > 0 && *(int *)(a13 + 4LL * v29) > 0 && *(int *)(a12 + 4LL * v29) > 0 )
{
v30[0] = 0LL;
v26 = create_flow_adjacency(a8, v20, v30, a7);
if ( (_WORD)v26 )
{
v22 = add_adjacency_to_contributor(a8, v19, v30[0]);
if ( (_WORD)v22 )
{
v14 = 1;
}
else
{
v24 = v22;
fwrite("ERROR: Failed to add receiver adjacency to the contributor.\n", 1uLL, 0x3CuLL, stderr);
v14 = v24;
}
}
else
{
fwrite("ERROR: Failed to create receiver adjacency.\n", 1uLL, 0x2CuLL, stderr);
v14 = v26;
}
if ( a14 )
{
if ( a7 > 0.0 )
++*(_DWORD *)(a14 + 4LL * v29);
}
}
else
{
printf("Receiver patch %d is outside of basin\n", (unsigned int)v21);
v14 = 1;
}
}
else
{
fprintf(stderr, "ERROR: Failed to map receiver row: %d and column %d to an index.\n", a3, a4);
v14 = v25;
}
}
else
{
fprintf(
stderr,
"ERROR: Failed to map contributor row: %d and column %d to an index.\n",
(unsigned int)a1,
(unsigned int)a2);
v14 = v27;
}
}
else
{
fwrite("ERROR: The roof proportion is out of range.\n", 1uLL, 0x2CuLL, stderr);
v14 = 0;
}
result = v14;
}
else
{
fwrite("ERROR: Patch pointer is NULL.\n", 1uLL, 0x1EuLL, stderr);
result = 0LL;
}
}
else
{
fwrite("ERROR: Flow table pointer is NULL.\n", 1uLL, 0x23uLL, stderr);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2, unsigned int a3, unsigned int a4, unsigned int a5, unsigned int a6, double a7, __int64 a8, int a9, __int64 a10, __int64 a11, __int64 a12, __int64 a13, __int64 a14)
{
unsigned int v14; // er8
__int64 result; // rax
int v19; // er12
int v20; // eax
int v21; // er8
unsigned int v22; // er8
unsigned int v24; // [rsp+0h] [rbp-58h]
unsigned int v25; // [rsp+8h] [rbp-50h]
unsigned int v26; // [rsp+8h] [rbp-50h]
unsigned int v27; // [rsp+14h] [rbp-44h]
int v28; // [rsp+20h] [rbp-38h] BYREF
int v29; // [rsp+24h] [rbp-34h] BYREF
__int64 v30[6]; // [rsp+28h] [rbp-30h] BYREF

v28 = 0;
v29 = 0;
if ( a8 )
{
if ( a11 )
{
if ( a7 >= 0.0 && a7 <= 1.0 )
{
v27 = row_col_to_index(a1, a2, a5, a6, &v28);
if ( (_WORD)v27 )
{
v25 = row_col_to_index(a3, a4, a5, a6, &v29);
if ( (_WORD)v25 )
{
v19 = find_patch(
a10,
*(unsigned int *)(a11 + 4LL * v28),
*(unsigned int *)(a13 + 4LL * v28),
*(unsigned int *)(a12 + 4LL * v28));
if ( v19 == -1 )
{
fprintf(
stderr,
"add_flow_to_table:125: Unable to find patch: patchID: %d, zoneID: %d, hillID: %d\n",
*(unsigned int *)(a11 + 4LL * v28),
*(unsigned int *)(a13 + 4LL * v28),
*(unsigned int *)(a12 + 4LL * v28));
exit(1);
}
v20 = find_patch(
a10,
*(unsigned int *)(a11 + 4LL * v29),
*(unsigned int *)(a13 + 4LL * v29),
*(unsigned int *)(a12 + 4LL * v29));
v21 = *(_DWORD *)(a11 + 4LL * v29);
if ( v21 > 0 && *(int *)(a13 + 4LL * v29) > 0 && *(int *)(a12 + 4LL * v29) > 0 )
{
v30[0] = 0LL;
v26 = func0(a8, v20, v30, a7);
if ( (_WORD)v26 )
{
v22 = func1(a8, v19, v30[0]);
if ( (_WORD)v22 )
{
v14 = 1;
}
else
{
v24 = v22;
fwrite("ERROR: Failed to add receiver adjacency to the contributor.\n", 1uLL, 0x3CuLL, stderr);
v14 = v24;
}
}
else
{
fwrite("ERROR: Failed to create receiver adjacency.\n", 1uLL, 0x2CuLL, stderr);
v14 = v26;
}
if ( a14 )
{
if ( a7 > 0.0 )
++*(_DWORD *)(a14 + 4LL * v29);
}
}
else
{
printf("Receiver patch %d is outside of basin\n", (unsigned int)v21);
v14 = 1;
}
}
else
{
fprintf(stderr, "ERROR: Failed to map receiver row: %d and column %d to an index.\n", a3, a4);
v14 = v25;
}
}
else
{
fprintf(
stderr,
"ERROR: Failed to map contributor row: %d and column %d to an index.\n",
(unsigned int)a1,
(unsigned int)a2);
v14 = v27;
}
}
else
{
fwrite("ERROR: The roof proportion is out of range.\n", 1uLL, 0x2CuLL, stderr);
v14 = 0;
}
result = v14;
}
else
{
fwrite("ERROR: Patch pointer is NULL.\n", 1uLL, 0x1EuLL, stderr);
result = 0LL;
}
}
else
{
fwrite("ERROR: Flow table pointer is NULL.\n", 1uLL, 0x23uLL, stderr);
result = 0LL;
}
return result;
}

original_code:
bool add_flow_to_table(
    int _contributor_row,
    int _contributor_col,
    int _receiver_row,
    int _receiver_col,
    int _maxr,
    int _maxc,
    struct flow_struct* _flow_table,
    int _num_patches,
    PatchTable_t *_patchTable,
    const int* _patch,
    const int* _hill,
    const int* _zone,
    double _proportion,
    int* const _receiver_out)
{
    bool result = true;
    int contributor_index = 0;
    int receiver_index = 0;
    if(_flow_table == 0) {
        fprintf(stderr, "ERROR: Flow table pointer is NULL.\n");
        result = false;
    } else if(_patch == 0) {
        fprintf(stderr, "ERROR: Patch pointer is NULL.\n");
        result = false;
    } else if(_proportion < 0 || _proportion > 1) {
        fprintf(stderr, "ERROR: The roof proportion is out of range.\n");
        result = false;
    } else if(!row_col_to_index(_contributor_row, _contributor_col, _maxr, _maxc, &contributor_index)) {
        fprintf(stderr, "ERROR: Failed to map contributor row: %d and column %d to an index.\n", _contributor_row, _contributor_col);
        result = false;
    } else if(!row_col_to_index(_receiver_row, _receiver_col, _maxr, _maxc, &receiver_index)) {
        fprintf(stderr, "ERROR: Failed to map receiver row: %d and column %d to an index.\n", _receiver_row, _receiver_col);
        result = false;
    }
    else {
     int contributor_patch = find_patch(_patchTable, _patch[contributor_index], _zone[contributor_index], _hill[contributor_index]);
     if ( contributor_patch == -1 ) {
      fprintf(stderr, "add_flow_to_table:125: Unable to find patch: patchID: %d, zoneID: %d, hillID: %d\n",
       _patch[contributor_index], _zone[contributor_index], _hill[contributor_index]);
      exit(1);
     }
     int receiver_patch = find_patch(_patchTable, _patch[receiver_index], _zone[receiver_index], _hill[receiver_index]);
     if ( (_patch[receiver_index] > 0) && (_zone[receiver_index] > 0) && (_hill[receiver_index] > 0)) {
   struct adj_struct* adjacency = 0;
   if(!create_flow_adjacency(_flow_table, receiver_patch, _proportion, &adjacency)) {
    fprintf(stderr, "ERROR: Failed to create receiver adjacency.\n");
    result = false;
   }
   else if(!add_adjacency_to_contributor(_flow_table, contributor_patch, adjacency)) {
    fprintf(stderr, "ERROR: Failed to add receiver adjacency to the contributor.\n");
    result = false;
   }
   if ( _receiver_out && _proportion > 0 ) {
    _receiver_out[receiver_index] += 1;
   }
     } else {
      printf("Receiver patch %d is outside of basin\n", _patch[receiver_index]);
     }
    }
    return result;
}

canonical_original_code:
short add_flow_to_table(int _contributor_row, int _contributor_col, int _receiver_row, int _receiver_col, int _maxr, int _maxc, struct flow_struct *_flow_table, int _num_patches, struct table_s *_patchTable, int *_patch, int *_hill, int *_zone, double _proportion, int *_receiver_out)
{
    short result = true;
    int contributor_index = 0;
    int receiver_index = 0;
    if(_flow_table == 0) {
        fprintf(stderr, "ERROR: Flow table pointer is NULL.\n");
        result = false;
    } else if(_patch == 0) {
        fprintf(stderr, "ERROR: Patch pointer is NULL.\n");
        result = false;
    } else if(_proportion < 0 || _proportion > 1) {
        fprintf(stderr, "ERROR: The roof proportion is out of range.\n");
        result = false;
    } else if(!row_col_to_index(_contributor_row, _contributor_col, _maxr, _maxc, &contributor_index)) {
        fprintf(stderr, "ERROR: Failed to map contributor row: %d and column %d to an index.\n", _contributor_row, _contributor_col);
        result = false;
    } else if(!row_col_to_index(_receiver_row, _receiver_col, _maxr, _maxc, &receiver_index)) {
        fprintf(stderr, "ERROR: Failed to map receiver row: %d and column %d to an index.\n", _receiver_row, _receiver_col);
        result = false;
    }
    else {
     int contributor_patch = find_patch(_patchTable, _patch[contributor_index], _zone[contributor_index], _hill[contributor_index]);
     if ( contributor_patch == -1 ) {
      fprintf(stderr, "add_flow_to_table:125: Unable to find patch: patchID: %d, zoneID: %d, hillID: %d\n",
       _patch[contributor_index], _zone[contributor_index], _hill[contributor_index]);
      exit(1);
     }
     int receiver_patch = find_patch(_patchTable, _patch[receiver_index], _zone[receiver_index], _hill[receiver_index]);
     if ( (_patch[receiver_index] > 0) && (_zone[receiver_index] > 0) && (_hill[receiver_index] > 0)) {
   struct adj_struct *adjacency = 0;
   if(!create_flow_adjacency(_flow_table, receiver_patch, _proportion, &adjacency)) {
    fprintf(stderr, "ERROR: Failed to create receiver adjacency.\n");
    result = false;
   }
   else if(!add_adjacency_to_contributor(_flow_table, contributor_patch, adjacency)) {
    fprintf(stderr, "ERROR: Failed to add receiver adjacency to the contributor.\n");
    result = false;
   }
   if ( _receiver_out && _proportion > 0 ) {
    _receiver_out[receiver_index] += 1;
   }
     } else {
      printf("Receiver patch %d is outside of basin\n", _patch[receiver_index]);
     }
    }
    return result;
}

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

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

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

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


decompiled_code:
__int64 __fastcall parse_albedo_flag(void *ptr)
{
int v2; // eax
unsigned int v3; // er12

v2 = *(unsigned __int8 *)ptr;
if ( v2 != 97 || *((_BYTE *)ptr + 1) != 103 || (v3 = 1, *((_BYTE *)ptr + 2) != 101) )
{
if ( v2 != 65 || *((_BYTE *)ptr + 1) != 71 || (v3 = 1, *((_BYTE *)ptr + 2) != 69) )
{
if ( memcmp(ptr, "bats", 4uLL) && memcmp(ptr, "BATS", 4uLL) )
{
fwrite("\n FATAL ERROR - parse_albedo_flag", 1uLL, 0x21uLL, stderr);
fprintf(stderr, "\n Flag must be age or bats and is %s", (const char *)ptr);
exit(1);
}
v3 = 2;
}
}
free(ptr);
return v3;
}

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

v2 = *(unsigned __int8 *)ptr;
if ( v2 != 97 || *((_BYTE *)ptr + 1) != 103 || (v3 = 1, *((_BYTE *)ptr + 2) != 101) )
{
if ( v2 != 65 || *((_BYTE *)ptr + 1) != 71 || (v3 = 1, *((_BYTE *)ptr + 2) != 69) )
{
if ( memcmp(ptr, "bats", 4uLL) && memcmp(ptr, "BATS", 4uLL) )
{
fwrite("\n FATAL ERROR - parse_albedo_flag", 1uLL, 0x21uLL, stderr);
fprintf(stderr, "\n Flag must be age or bats and is %s", (const char *)ptr);
exit(1);
}
v3 = 2;
}
}
free(ptr);
return v3;
}

original_code:
int parse_albedo_flag( char *input_string)
{
 int albedo_flag;
 if ((strncmp(input_string,"age",3) == 0) ||
  (strncmp(input_string, "AGE",3) == 0) )
  albedo_flag = 1;
 else if ((strncmp(input_string,"bats",4) == 0) ||
  (strncmp(input_string, "BATS",4) == 0) )
  albedo_flag = 2;
 else {
  fprintf(stderr,"\n FATAL ERROR - parse_albedo_flag");
  fprintf(stderr,"\n Flag must be age or bats and is %s" , input_string);
  exit(1);
 }
 free(input_string);
 return(albedo_flag);
}

canonical_original_code:
int parse_albedo_flag(char *input_string)
{
 int albedo_flag;
 if ((strncmp(input_string,"age",3) == 0) ||
  (strncmp(input_string, "AGE",3) == 0) )
  albedo_flag = 1;
 else if ((strncmp(input_string,"bats",4) == 0) ||
  (strncmp(input_string, "BATS",4) == 0) )
  albedo_flag = 2;
 else {
  fprintf(stderr,"\n FATAL ERROR - parse_albedo_flag");
  fprintf(stderr,"\n Flag must be age or bats and is %s" , input_string);
  exit(1);
 }
 free(input_string);
 return(albedo_flag);
}


original_code:
struct tec_entry *construct_tec_entry(
           struct date cal_date,
           char *tec_command)
{
 void *alloc( size_t, char *, char *);
 struct tec_entry *event;
 event = (struct tec_entry *) alloc( 1 *
  sizeof(struct tec_entry),"entry","construct_tec_entry");
 event[0].cal_date.year = cal_date.year;
 event[0].cal_date.month = cal_date.month;
 event[0].cal_date.day = cal_date.day;
 event[0].cal_date.hour = cal_date.hour;
 strcpy(event[0].command, tec_command);
 return(event);
}

canonical_original_code:
struct tec_entry *construct_tec_entry(struct date cal_date, char *tec_command)
{
 void *alloc(unsigned long, char *, char *);
 struct tec_entry *event;
 event = (struct tec_entry *) alloc( 1 *
  sizeof(struct tec_entry),"entry","construct_tec_entry");
 event[0].cal_date.year = cal_date.year;
 event[0].cal_date.month = cal_date.month;
 event[0].cal_date.day = cal_date.day;
 event[0].cal_date.hour = cal_date.hour;
 strcpy(event[0].command, tec_command);
 return(event);
}

variable_types:
alloc
void *(unsigned long, char *, char *)

variable_types: struct tec_entry { struct date { long year; long month; long day; long hour; } cal_date; char command[256]; } *

user_defined_types: struct tec_entry { struct date cal_date; char command[256]; }


variable_types: elevation double

variable_types: Pair double


variable_types: cn double

variable_types:
u
double *

variable_types: z double

variable_types:
ga
double *

variable_types: ra double


alloc

decompiled_code:
void *__fastcall alloc(size_t a1, const char *a2, const char *a3)
{
void *result; // rax

if ( !a1 )
return 0LL;
result = calloc(a1, 1uLL);
if ( !result )
{
fprintf(stderr, "FATAL ERROR: in malloc, unable to allocate %s for %s\n", a2, a3);
exit(1);
}
return result;
}

canonical_decompiled_code:
void *__fastcall func0(size_t a1, const char *a2, const char *a3)
{
void *result; // rax

if ( !a1 )
return 0LL;
result = calloc(a1, 1uLL);
if ( !result )
{
fprintf(stderr, "FATAL ERROR: in malloc, unable to allocate %s for %s\n", a2, a3);
exit(1);
}
return result;
}

original_code:
void *alloc(size_t size, char *array_name, char *calling_function)
{
 void *array;
 if ( size == 0 ){
  return( ((void *)0) );
 }
 else{
  array = malloc(size);
  if ( array == ((void *)0) ){
   fprintf(stderr,
    "FATAL ERROR: in malloc, unable to allocate %s for %s\n",
    array_name, calling_function );
   exit(1);
  }
  else{
   memset(array, 0, size);
   return(array);
  }
 }
}

canonical_original_code:
void *alloc(unsigned long size, char *array_name, char *calling_function)
{
 void *array;
 if ( size == 0 ){
  return( ((void *)0) );
 }
 else{
  array = malloc(size);
  if ( array == ((void *)0) ){
   fprintf(stderr,
    "FATAL ERROR: in malloc, unable to allocate %s for %s\n",
    array_name, calling_function );
   exit(1);
  }
  else{
   memset(array, 0, size);
   return(array);
  }
 }
}

variable_types:
size
unsigned long

variable_types:
array
void *


decompiled_code:
_BOOL8 __fastcall is_approximately(double a1, double a2, double a3)
{
_BOOL8 result; // rax

if ( a2 + a3 <= a1 )
result = 0LL;
else
result = a1 > a2 - a3;
return result;
}

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

if ( a2 + a3 <= a1 )
result = 0LL;
else
result = a1 > a2 - a3;
return result;
}

original_code:
int is_approximately(const double value,const double target,const double tolerance)
{ return ((value) < ((target) +(tolerance))) && ((value) > ((target) - (tolerance)));}

canonical_original_code:
int is_approximately(double value, double target, double tolerance)
{ return ((value) < ((target) +(tolerance))) && ((value) > ((target) - (tolerance)));}

variable_types: value double

variable_types: target double

variable_types: tolerance double


decompiled_code:
__int64 __fastcall in_list(int a1, __int64 a2, int a3)
{
__int64 v3; // rdx
__int64 v4; // rax
unsigned int v5; // er8

if ( a3 <= 0 )
return 0LL;
v3 = (unsigned int)(a3 + 1);
v4 = 1LL;
v5 = 0;
do
{
if ( *(_DWORD *)(a2 + 4 * v4) == a1 )
v5 = v4;
++v4;
}
while ( v4 != v3 );
return v5;
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1, __int64 a2, int a3)
{
__int64 v3; // rdx
__int64 v4; // rax
unsigned int v5; // er8

if ( a3 <= 0 )
return 0LL;
v3 = (unsigned int)(a3 + 1);
v4 = 1LL;
v5 = 0;
do
{
if ( *(_DWORD *)(a2 + 4 * v4) == a1 )
v5 = v4;
++v4;
}
while ( v4 != v3 );
return v5;
}

original_code:
int in_list(int inx, int *list, int num_pit) {
 int i, fnd;
 fnd = 0;
 for (i = 1; i <= num_pit; i++) {
  if (inx == list[i])
   fnd = i;
 }
 return (fnd);
}

canonical_original_code:
int in_list(int inx, int *list, int num_pit) {
 int i; int fnd;
 fnd = 0;
 for (i = 1; i <= num_pit; i++) {
  if (inx == list[i])
   fnd = i;
 }
 return (fnd);
}

variable_types: inx int

variable_types:
list
int *

variable_types: i int

variable_types: fnd int


decompiled_code:
__int64 __fastcall construct_roof_geometry(_QWORD *a1)
{
_QWORD *v1; // rax
__int64 result; // rax

if ( a1 )
{
v1 = calloc(1uLL, 0x20uLL);
if ( v1 )
{
*a1 = v1;
*v1 = 0x7FFFFFFF7FFFFFFFLL;
result = 1LL;
}
else
{
fwrite("ERROR: Failed allocating memory for a roof geometry.\n", 1uLL, 0x35uLL, stderr);
result = 0LL;
}
}
else
{
fwrite("ERROR: Roof geometry pointer is NULL.\n", 1uLL, 0x26uLL, stderr);
result = 0LL;
}
return result;
}

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

if ( a1 )
{
v1 = calloc(1uLL, 0x20uLL);
if ( v1 )
{
*a1 = v1;
*v1 = 0x7FFFFFFF7FFFFFFFLL;
result = 1LL;
}
else
{
fwrite("ERROR: Failed allocating memory for a roof geometry.\n", 1uLL, 0x35uLL, stderr);
result = 0LL;
}
}
else
{
fwrite("ERROR: Roof geometry pointer is NULL.\n", 1uLL, 0x26uLL, stderr);
result = 0LL;
}
return result;
}

original_code:
bool construct_roof_geometry(roof_geometry_t** _rtn_geometry) {
 bool result = true;
 if (_rtn_geometry != 0) {
  roof_geometry_t* geometry = (roof_geometry_t*) calloc(1,
    sizeof(roof_geometry_t));
  if (geometry == 0) {
   fprintf(stderr,
     "ERROR: Failed allocating memory for a roof geometry.\n");
   result = false;
  } else {
   geometry->min_row_ = 0x7fffffff;
   geometry->min_col_ = 0x7fffffff;
   *_rtn_geometry = geometry;
  }
 } else {
  fprintf(stderr, "ERROR: Roof geometry pointer is NULL.\n");
  result = false;
 }
 return result;
}

canonical_original_code:
short construct_roof_geometry(struct roof_geometry_s **_rtn_geometry) {
 short result = true;
 if (_rtn_geometry != 0) {
  struct roof_geometry_s *geometry = (roof_geometry_t*) calloc(1,
    sizeof(roof_geometry_t));
  if (geometry == 0) {
   fprintf(stderr,
     "ERROR: Failed allocating memory for a roof geometry.\n");
   result = false;
  } else {
   geometry->min_row_ = 0x7fffffff;
   geometry->min_col_ = 0x7fffffff;
   *_rtn_geometry = geometry;
  }
 } else {
  fprintf(stderr, "ERROR: Roof geometry pointer is NULL.\n");
  result = false;
 }
 return result;
}

variable_types: struct roof_geometry_s { int min_row_; int min_col_; int max_row_; int max_col_; int num_squares_; struct roof_square_s { int row_; int col_; struct roof_square_s *next_; } *squares_; } **

variable_types: result short

user_defined_types: struct roof_geometry_s { int min_row_; int min_col_; int max_row_; int max_col_; int num_squares_; struct roof_square_s *squares_; }


decompiled_code:
__int64 __fastcall destroy_roof_geometry(_QWORD **a1)
{
_QWORD *v1; // r12
_QWORD *v3; // rbx
void *v4; // rdi
__int64 result; // rax

if ( a1 )
{
v1 = *a1;
if ( *a1 )
{
v3 = (_QWORD *)v1[3];
while ( v3 )
{
v4 = v3;
v3 = (_QWORD *)v3[1];
free(v4);
}
free(v1);
*a1 = 0LL;
result = 1LL;
}
else
{
fwrite("ERROR: Attempting to destroy NULL roof geometry.\n", 1uLL, 0x31uLL, stderr);
result = 0LL;
}
}
else
{
fwrite("ERROR: Roof geometry pointer is NULL.\n", 1uLL, 0x26uLL, stderr);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(_QWORD **a1)
{
_QWORD *v1; // r12
_QWORD *v3; // rbx
void *v4; // rdi
__int64 result; // rax

if ( a1 )
{
v1 = *a1;
if ( *a1 )
{
v3 = (_QWORD *)v1[3];
while ( v3 )
{
v4 = v3;
v3 = (_QWORD *)v3[1];
free(v4);
}
free(v1);
*a1 = 0LL;
result = 1LL;
}
else
{
fwrite("ERROR: Attempting to destroy NULL roof geometry.\n", 1uLL, 0x31uLL, stderr);
result = 0LL;
}
}
else
{
fwrite("ERROR: Roof geometry pointer is NULL.\n", 1uLL, 0x26uLL, stderr);
result = 0LL;
}
return result;
}

original_code:
bool destroy_roof_geometry(roof_geometry_t** _rtn_geometry) {
 bool result = true;
 if (_rtn_geometry != 0) {
  roof_geometry_t* geometry = *_rtn_geometry;
  if (geometry == 0) {
   fprintf(stderr,
     "ERROR: Attempting to destroy NULL roof geometry.\n");
   result = false;
  } else {
   roof_square_t* square = geometry->squares_;
   while (result && square != 0) {
    roof_square_t* current_square = square;
    square = square->next_;
    free(current_square);
   }
   if (result) {
    free(geometry);
    *_rtn_geometry = 0;
   }
  }
 } else {
  fprintf(stderr, "ERROR: Roof geometry pointer is NULL.\n");
  result = false;
 }
 return result;
}

canonical_original_code:
short destroy_roof_geometry(struct roof_geometry_s **_rtn_geometry) {
 short result = true;
 if (_rtn_geometry != 0) {
  struct roof_geometry_s *geometry = *_rtn_geometry;
  if (geometry == 0) {
   fprintf(stderr,
     "ERROR: Attempting to destroy NULL roof geometry.\n");
   result = false;
  } else {
   struct roof_square_s *square = geometry->squares_;
   while (result && square != 0) {
    struct roof_square_s *current_square = square;
    square = square->next_;
    free(current_square);
   }
   if (result) {
    free(geometry);
    *_rtn_geometry = 0;
   }
  }
 } else {
  fprintf(stderr, "ERROR: Roof geometry pointer is NULL.\n");
  result = false;
 }
 return result;
}

variable_types: struct roof_geometry_s { int min_row_; int min_col_; int max_row_; int max_col_; int num_squares_; struct roof_square_s { int row_; int col_; struct roof_square_s *next_; } *squares_; } *


decompiled_code:
__int64 __fastcall add_roof_square(__int64 a1, int a2, int a3)
{
unsigned int v3; // er12
__int64 v4; // rax
__int64 result; // rax
__int64 v6[4]; // [rsp+8h] [rbp-20h] BYREF

if ( a1 )
{
if ( *(_DWORD *)(a1 + 8) < a2 )
*(_DWORD *)(a1 + 8) = a2;
if ( *(_DWORD *)a1 > a2 )
*(_DWORD *)a1 = a2;
if ( *(_DWORD *)(a1 + 12) < a3 )
*(_DWORD *)(a1 + 12) = a3;
if ( *(_DWORD *)(a1 + 4) > a3 )
*(_DWORD *)(a1 + 4) = a3;
v6[0] = 0LL;
v3 = construct_roof_square_constprop_0(a2, a3, v6);
if ( (_WORD)v3 )
{
v4 = v6[0];
*(_QWORD *)(v6[0] + 8) = *(_QWORD *)(a1 + 24);
*(_QWORD *)(a1 + 24) = v4;
result = 1LL;
++*(_DWORD *)(a1 + 16);
}
else
{
fwrite("ERROR: Failed to construct a new roof square.\n", 1uLL, 0x2EuLL, stderr);
result = v3;
}
}
else
{
fwrite("ERROR: Roof geometry pointer is NULL.\n", 1uLL, 0x26uLL, stderr);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, int a2, int a3)
{
unsigned int v3; // er12
__int64 v4; // rax
__int64 result; // rax
__int64 v6[4]; // [rsp+8h] [rbp-20h] BYREF

if ( a1 )
{
if ( *(_DWORD *)(a1 + 8) < a2 )
*(_DWORD *)(a1 + 8) = a2;
if ( *(_DWORD *)a1 > a2 )
*(_DWORD *)a1 = a2;
if ( *(_DWORD *)(a1 + 12) < a3 )
*(_DWORD *)(a1 + 12) = a3;
if ( *(_DWORD *)(a1 + 4) > a3 )
*(_DWORD *)(a1 + 4) = a3;
v6[0] = 0LL;
v3 = func0(a2, a3, v6);
if ( (_WORD)v3 )
{
v4 = v6[0];
*(_QWORD *)(v6[0] + 8) = *(_QWORD *)(a1 + 24);
*(_QWORD *)(a1 + 24) = v4;
result = 1LL;
++*(_DWORD *)(a1 + 16);
}
else
{
fwrite("ERROR: Failed to construct a new roof square.\n", 1uLL, 0x2EuLL, stderr);
result = v3;
}
}
else
{
fwrite("ERROR: Roof geometry pointer is NULL.\n", 1uLL, 0x26uLL, stderr);
result = 0LL;
}
return result;
}

original_code:
bool add_roof_square(roof_geometry_t* _roof_geometry, int _row, int _col) {
 bool result = true;
 if (_roof_geometry != 0) {
  if (_row > _roof_geometry->max_row_) {
   _roof_geometry->max_row_ = _row;
  }
  if (_row < _roof_geometry->min_row_) {
   _roof_geometry->min_row_ = _row;
  }
  if (_col > _roof_geometry->max_col_) {
   _roof_geometry->max_col_ = _col;
  }
  if (_col < _roof_geometry->min_col_) {
   _roof_geometry->min_col_ = _col;
  }
  roof_square_t* square = 0;
  if (!construct_roof_square(_row, _col, &square)) {
   fprintf(stderr, "ERROR: Failed to construct a new roof square.\n");
   result = false;
  } else {
   square->next_ = _roof_geometry->squares_;
   ++(_roof_geometry->num_squares_);
   _roof_geometry->squares_ = square;
  }
 } else {
  fprintf(stderr, "ERROR: Roof geometry pointer is NULL.\n");
  result = false;
 }
 return result;
}

canonical_original_code:
short add_roof_square(struct roof_geometry_s *_roof_geometry, int _row, int _col) {
 short result = true;
 if (_roof_geometry != 0) {
  if (_row > _roof_geometry->max_row_) {
   _roof_geometry->max_row_ = _row;
  }
  if (_row < _roof_geometry->min_row_) {
   _roof_geometry->min_row_ = _row;
  }
  if (_col > _roof_geometry->max_col_) {
   _roof_geometry->max_col_ = _col;
  }
  if (_col < _roof_geometry->min_col_) {
   _roof_geometry->min_col_ = _col;
  }
  struct roof_square_s *square = 0;
  if (!construct_roof_square(_row, _col, &square)) {
   fprintf(stderr, "ERROR: Failed to construct a new roof square.\n");
   result = false;
  } else {
   square->next_ = _roof_geometry->squares_;
   ++(_roof_geometry->num_squares_);
   _roof_geometry->squares_ = square;
  }
 } else {
  fprintf(stderr, "ERROR: Roof geometry pointer is NULL.\n");
  result = false;
 }
 return result;
}

variable_types: struct roof_square_s { int row_; int col_; struct roof_square_s *next_; } *


decompiled_code:
__int64 __fastcall roof_square_row(_DWORD *a1, _DWORD *a2)
{
__int64 result; // rax

if ( a1 )
{
if ( a2 )
{
*a2 = *a1;
result = 1LL;
}
else
{
fwrite("ERROR: Return row pointer is NULL.\n", 1uLL, 0x23uLL, stderr);
result = 0LL;
}
}
else
{
fwrite("ERROR: Roof square pointer is NULL.\n", 1uLL, 0x24uLL, stderr);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(_DWORD *a1, _DWORD *a2)
{
__int64 result; // rax

if ( a1 )
{
if ( a2 )
{
*a2 = *a1;
result = 1LL;
}
else
{
fwrite("ERROR: Return row pointer is NULL.\n", 1uLL, 0x23uLL, stderr);
result = 0LL;
}
}
else
{
fwrite("ERROR: Roof square pointer is NULL.\n", 1uLL, 0x24uLL, stderr);
result = 0LL;
}
return result;
}

original_code:
bool roof_square_row(roof_square_t* _square, int* _rtn_row) {
 bool result = true;
 if (_square == 0) {
  fprintf(stderr, "ERROR: Roof square pointer is NULL.\n");
  result = false;
 } else if (_rtn_row == 0) {
  fprintf(stderr, "ERROR: Return row pointer is NULL.\n");
  result = false;
 } else {
  *_rtn_row = _square->row_;
 }
 return result;
}

canonical_original_code:
short roof_square_row(struct roof_square_s *_square, int *_rtn_row) {
 short result = true;
 if (_square == 0) {
  fprintf(stderr, "ERROR: Roof square pointer is NULL.\n");
  result = false;
 } else if (_rtn_row == 0) {
  fprintf(stderr, "ERROR: Return row pointer is NULL.\n");
  result = false;
 } else {
  *_rtn_row = _square->row_;
 }
 return result;
}

user_defined_types: struct roof_square_s { int row_; int col_; struct roof_square_s *next_; }


decompiled_code:
__int64 __fastcall roof_square_col(__int64 a1, _DWORD *a2)
{
__int64 result; // rax

if ( a1 )
{
if ( a2 )
{
*a2 = *(_DWORD *)(a1 + 4);
result = 1LL;
}
else
{
fwrite("ERROR: Return col pointer is NULL.\n", 1uLL, 0x23uLL, stderr);
result = 0LL;
}
}
else
{
fwrite("ERROR: Roof square pointer is NULL.\n", 1uLL, 0x24uLL, stderr);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, _DWORD *a2)
{
__int64 result; // rax

if ( a1 )
{
if ( a2 )
{
*a2 = *(_DWORD *)(a1 + 4);
result = 1LL;
}
else
{
fwrite("ERROR: Return col pointer is NULL.\n", 1uLL, 0x23uLL, stderr);
result = 0LL;
}
}
else
{
fwrite("ERROR: Roof square pointer is NULL.\n", 1uLL, 0x24uLL, stderr);
result = 0LL;
}
return result;
}

original_code:
bool roof_square_col(roof_square_t* _square, int* _rtn_col) {
 bool result = true;
 if (_square == 0) {
  fprintf(stderr, "ERROR: Roof square pointer is NULL.\n");
  result = false;
 } else if (_rtn_col == 0) {
  fprintf(stderr, "ERROR: Return col pointer is NULL.\n");
  result = false;
 } else {
  *_rtn_col = _square->col_;
 }
 return result;
}

canonical_original_code:
short roof_square_col(struct roof_square_s *_square, int *_rtn_col) {
 short result = true;
 if (_square == 0) {
  fprintf(stderr, "ERROR: Roof square pointer is NULL.\n");
  result = false;
 } else if (_rtn_col == 0) {
  fprintf(stderr, "ERROR: Return col pointer is NULL.\n");
  result = false;
 } else {
  *_rtn_col = _square->col_;
 }
 return result;
}


decompiled_code:
__int64 __fastcall roof_square_next(__int64 a1, _QWORD *a2)
{
__int64 result; // rax

if ( a1 )
{
if ( a2 )
{
*a2 = *(_QWORD *)(a1 + 8);
result = 1LL;
}
else
{
fwrite("ERROR: Return next pointer is NULL.\n", 1uLL, 0x24uLL, stderr);
result = 0LL;
}
}
else
{
fwrite("ERROR: Roof square pointer is NULL.\n", 1uLL, 0x24uLL, stderr);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, _QWORD *a2)
{
__int64 result; // rax

if ( a1 )
{
if ( a2 )
{
*a2 = *(_QWORD *)(a1 + 8);
result = 1LL;
}
else
{
fwrite("ERROR: Return next pointer is NULL.\n", 1uLL, 0x24uLL, stderr);
result = 0LL;
}
}
else
{
fwrite("ERROR: Roof square pointer is NULL.\n", 1uLL, 0x24uLL, stderr);
result = 0LL;
}
return result;
}

original_code:
bool roof_square_next(roof_square_t* _square, roof_square_t** _rtn_next) {
 bool result = true;
 if (_square == 0) {
  fprintf(stderr, "ERROR: Roof square pointer is NULL.\n");
  result = false;
 } else if (_rtn_next == 0) {
  fprintf(stderr, "ERROR: Return next pointer is NULL.\n");
  result = false;
 } else {
  *_rtn_next = _square->next_;
 }
 return result;
}

canonical_original_code:
short roof_square_next(struct roof_square_s *_square, struct roof_square_s **_rtn_next) {
 short result = true;
 if (_square == 0) {
  fprintf(stderr, "ERROR: Roof square pointer is NULL.\n");
  result = false;
 } else if (_rtn_next == 0) {
  fprintf(stderr, "ERROR: Return next pointer is NULL.\n");
  result = false;
 } else {
  *_rtn_next = _square->next_;
 }
 return result;
}


decompiled_code:
__int64 __fastcall roof_geometry_squares(__int64 a1, _QWORD *a2)
{
__int64 result; // rax

if ( a1 )
{
if ( a2 )
{
*a2 = *(_QWORD *)(a1 + 24);
result = 1LL;
}
else
{
fwrite("ERROR: Return next pointer is NULL.\n", 1uLL, 0x24uLL, stderr);
result = 0LL;
}
}
else
{
fwrite("ERROR: Roof geometry pointer is NULL.\n", 1uLL, 0x26uLL, stderr);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1, _QWORD *a2)
{
__int64 result; // rax

if ( a1 )
{
if ( a2 )
{
*a2 = *(_QWORD *)(a1 + 24);
result = 1LL;
}
else
{
fwrite("ERROR: Return next pointer is NULL.\n", 1uLL, 0x24uLL, stderr);
result = 0LL;
}
}
else
{
fwrite("ERROR: Roof geometry pointer is NULL.\n", 1uLL, 0x26uLL, stderr);
result = 0LL;
}
return result;
}

original_code:
bool roof_geometry_squares(roof_geometry_t* _geometry,
  roof_square_t** _rtn_squares) {
 bool result = true;
 if (_geometry == 0) {
  fprintf(stderr, "ERROR: Roof geometry pointer is NULL.\n");
  result = false;
 } else if (_rtn_squares == 0) {
  fprintf(stderr, "ERROR: Return next pointer is NULL.\n");
  result = false;
 } else {
  *_rtn_squares = _geometry->squares_;
 }
 return result;
}

canonical_original_code:
short roof_geometry_squares(struct roof_geometry_s *_geometry, struct roof_square_s **_rtn_squares) {
 short result = true;
 if (_geometry == 0) {
  fprintf(stderr, "ERROR: Roof geometry pointer is NULL.\n");
  result = false;
 } else if (_rtn_squares == 0) {
  fprintf(stderr, "ERROR: Return next pointer is NULL.\n");
  result = false;
 } else {
  *_rtn_squares = _geometry->squares_;
 }
 return result;
}


canonical_original_code:
double compute_ra_understory(int verbose_flag, double cn, double *u, double h_o, double h_u, double *ga)
{
 double d_o; double d_u;
 double zo_o; double zo_u;
 double ra;
 double ra_u;
 ra = 1/(*ga);
 d_o = 0.7 * h_o;
 d_u = 0.7 * h_u;
 zo_o = 0.1 * h_o;
 zo_u = 0.1 * h_u;
 if ( h_o < d_o ){
  fprintf(stderr,
   "FATAL ERROR: screen height < zero plane stratum\n");
  exit(1);
 }
 ra_u = ra + log ( (h_o-d_o)/zo_o ) * h_o * exp(-1*cn)
  * ( exp(-1*cn*(d_u+zo_u)/h_o) - exp(-1*cn*(d_o+zo_o)/h_o))
  / ( *u * 0.41 * 0.41 * cn * (h_o - d_o));
 *u = (((*u * exp(cn*(((h_u) > (0.1*h_o) ? (h_u) : (0.1*h_o))/h_o - 1)))) > (0.0) ? ((*u * exp(cn*(((h_u) > (0.1*h_o) ? (h_u) : (0.1*h_o))/h_o - 1)))) : (0.0));
 if ( h_u <= 0.1*h_o )
  ra_u += pow(log( (0.1*h_o)/ ((zo_u) > (0.01) ? (zo_u) : (0.01))),2.0) / (*u * 0.41*0.41);
 *ga = 1/ra_u;
 return(ra);
}

variable_types: cn double

variable_types:
u
double *


variable_types:
idum
long *

variable_types: j int

variable_types: k long

variable_types: iy long

variable_types:
iv
long [32]

variable_types: temp float

return_type: float


gasdev

original_code:
float gasdev ()
{
 static int iset=0;
 static float gset;
 float fac,rsq,v1,v2;
  if (iset == 0) {
  do {
   v1=2.0*rand()/(2147483647 +1.0)-1.0;
   v2=2.0*rand()/(2147483647 +1.0)-1.0;
   rsq=v1*v1+v2*v2;
   } while (rsq >= 1.0 || rsq == 0.0);
   fac=sqrt(-2.0*log(rsq)/rsq);
   gset=v1*fac;
   iset=1;
   return v2*fac;
  } else {
   iset=0;
   return gset;
  }
 }

canonical_original_code:
float gasdev()
{
 static int iset = 0;
 static float gset;
 float fac; float rsq; float v1; float v2;
  if (iset == 0) {
  do {
   v1=2.0*rand()/(2147483647 +1.0)-1.0;
   v2=2.0*rand()/(2147483647 +1.0)-1.0;
   rsq=v1*v1+v2*v2;
   } while (rsq >= 1.0 || rsq == 0.0);
   fac=sqrt(-2.0*log(rsq)/rsq);
   gset=v1*fac;
   iset=1;
   return v2*fac;
  } else {
   iset=0;
   return gset;
  }
 }

variable_types: iset int

variable_types: gset float

variable_types: fac float

variable_types: rsq float


normdist

decompiled_code:
double __fastcall normdist(double a1, double a2)
{
return gasdev() * a2 + a1;
}

canonical_decompiled_code:
double __fastcall func2(double a1, double a2)
{
return func1() * a2 + a1;
}

original_code:
double normdist(double mean, double std)
{
 double result;
 float gasdev();
 result = gasdev()*std+mean;
 return(result);
}

variable_types: mean double

variable_types: std double

variable_types: result double

variable_types:
gasdev
float ()


unifdist

decompiled_code:
double __fastcall unifdist(double a1, double a2)
{
int v2; // eax
double result; // xmm0_8
double v5; // [rsp+8h] [rbp-10h]

v5 = a1;
v2 = rand();
result = 0.0;
if ( a2 - a1 > 0.0 )
result = (double)v2 * 4.656612873077393e-10 * (a2 - v5) + a1;
return result;
}

canonical_decompiled_code:
double __fastcall func3(double a1, double a2)
{
int v2; // eax
double result; // xmm0_8
double v5; // [rsp+8h] [rbp-10h]

v5 = a1;
v2 = rand();
result = 0.0;
if ( a2 - a1 > 0.0 )
result = (double)v2 * 4.656612873077393e-10 * (a2 - v5) + a1;
return result;
}

original_code:
double unifdist(double min, double max)
{
 double result, range;
    int random_integer = rand();
  range = max-min;
 if (range > 0)
  result = random_integer/(2147483647 +1.0)*range+min;
 else
  result = 0;
 return(result);
}

canonical_original_code:
double unifdist(double min, double max)
{
 double result; double range;
    int random_integer = rand();
  range = max-min;
 if (range > 0)
  result = random_integer/(2147483647 +1.0)*range+min;
 else
  result = 0;
 return(result);
}

variable_types: min double

variable_types: max double

variable_types: range double