repo: rosmo/mysql-jsonget

decompiled_code:
__int64 __fastcall json_get_init(__int64 a1, __int64 a2, __m128i *a3)
{
_DWORD *v3; // rax
__int64 result; // rax

if ( *(_DWORD *)a2 == 2 )
{
v3 = *(_DWORD **)(a2 + 8);
if ( v3[1] )
{
strcpy(a3[2].m128i_i8, "s expected");
*a3 = _mm_load_si128((const __m128i *)&xmmword_2040);
result = 1LL;
a3[1] = _mm_load_si128((const __m128i *)&xmmword_2050);
}
else
{
*v3 = 0;
result = 0LL;
*(_BYTE *)a1 = 1;
*(_DWORD *)(a1 + 8) = 0xFFFF;
}
}
else
{
strcpy(a3[1].m128i_i8, "arguments");
result = 1LL;
*a3 = _mm_load_si128((const __m128i *)&xmmword_2030);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func15(__int64 a1, __int64 a2, __m128i *a3)
{
_DWORD *v3; // rax
__int64 result; // rax

if ( *(_DWORD *)a2 == 2 )
{
v3 = *(_DWORD **)(a2 + 8);
if ( v3[1] )
{
strcpy(a3[2].m128i_i8, "s expected");
*a3 = _mm_load_si128((const __m128i *)&xmmword_2040);
result = 1LL;
a3[1] = _mm_load_si128((const __m128i *)&xmmword_2050);
}
else
{
*v3 = 0;
result = 0LL;
*(_BYTE *)a1 = 1;
*(_DWORD *)(a1 + 8) = 0xFFFF;
}
}
else
{
strcpy(a3[1].m128i_i8, "arguments");
result = 1LL;
*a3 = _mm_load_si128((const __m128i *)&xmmword_2030);
}
return result;
}

original_code:
my_bool json_get_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
{
  if (args->arg_count != 2)
  {
    strcpy(message, "Too few or many arguments");
    return 1;
  }
  if (args->arg_type[1] != STRING_RESULT)
  {
    strcpy(message, "Wrong type of argument, string is expected");
    return 1;
  }
  args->arg_type[0] = STRING_RESULT;
  initid->maybe_null = 1;
  initid->max_length = 0xFFFF;
  return 0;
}

canonical_original_code:
char json_get_init(struct st_udf_init *initid, struct st_udf_args *args, char *message)
{
  if (args->arg_count != 2)
  {
    strcpy(message, "Too few or many arguments");
    return 1;
  }
  if (args->arg_type[1] != STRING_RESULT)
  {
    strcpy(message, "Wrong type of argument, string is expected");
    return 1;
  }
  args->arg_type[0] = STRING_RESULT;
  initid->maybe_null = 1;
  initid->max_length = 0xFFFF;
  return 0;
}

variable_types: struct st_udf_init { char maybe_null; unsigned int decimals; unsigned int max_length; char *ptr; char const_item; } *

variable_types: struct st_udf_args { unsigned int arg_count; enum Item_result { STRING_RESULT=0, REAL_RESULT=1, INT_RESULT=2, ROW_RESULT=3, DECIMAL_RESULT=4 } *arg_type; char **args; unsigned long *lengths; char *maybe_null; } *

variable_types:
message
char *

return_type: char

user_defined_types: struct st_udf_args { unsigned int arg_count; enum Item_result *arg_type; char **args; unsigned long *lengths; char *maybe_null; }


decompiled_code:
void __fastcall json_get_deinit(__int64 a1)
{
void *v1; // rdi

v1 = *(void **)(a1 + 16);
if ( v1 )
free(v1);
}

canonical_decompiled_code:
void __fastcall func16(__int64 a1)
{
void *v1; // rdi

v1 = *(void **)(a1 + 16);
if ( v1 )
free(v1);
}

original_code:
void json_get_deinit(UDF_INIT *initid)
{
  if (initid->ptr != ((void *)0)) {
    free(initid->ptr);
  }
}

canonical_original_code:
void json_get_deinit(struct st_udf_init *initid)
{
  if (initid->ptr != ((void *)0)) {
    free(initid->ptr);
  }
}

return_type: void

user_defined_types: struct st_udf_init { char maybe_null; unsigned int decimals; unsigned int max_length; char *ptr; char const_item; }


repo: rothrock/Roxanne

decompiled_code:
int __fastcall keydb_lock(__int64 a1)
{
unsigned int v1; // ebp
__int128 v3; // [rsp+0h] [rbp-408h] BYREF
char v4[1008]; // [rsp+10h] [rbp-3F8h] BYREF

v3 = 0LL;
memset(v4, 0, sizeof(v4));
sprintf((char *)&v3, "%llu", a1);
v1 = get_hash_val(10LL, &v3);
while ( 1 )
{
sem_wait(KEYDB_LOCK);
if ( !(unsigned int)bit_array_test(SHM_KEYDB_BITMAP, v1) )
break;
sem_post(KEYDB_LOCK);
}
bit_array_set(SHM_KEYDB_BITMAP, v1);
return sem_post(KEYDB_LOCK);
}

canonical_decompiled_code:
int __fastcall func0(__int64 a1)
{
unsigned int v1; // ebp
__int128 v3; // [rsp+0h] [rbp-408h] BYREF
char v4[1008]; // [rsp+10h] [rbp-3F8h] BYREF

v3 = 0LL;
memset(v4, 0, sizeof(v4));
sprintf((char *)&v3, "%llu", a1);
v1 = get_hash_val(10LL, &v3);
while ( 1 )
{
sem_wait(KEYDB_LOCK);
if ( !(unsigned int)bit_array_test(SHM_KEYDB_BITMAP, v1) )
break;
sem_post(KEYDB_LOCK);
}
bit_array_set(SHM_KEYDB_BITMAP, v1);
return sem_post(KEYDB_LOCK);
}

original_code:
void keydb_lock(int64_t pos) {
  char key[1024] = "";
  int hash_number;
  sprintf(key, "%llu", pos);
  hash_number = get_hash_val(10, key);
  while (1) {
    sem_wait(KEYDB_LOCK);
    if ((bit_array_test(SHM_KEYDB_BITMAP, hash_number)) == 0) {
      bit_array_set(SHM_KEYDB_BITMAP, hash_number);
      sem_post(KEYDB_LOCK);
      break;
    }
    sem_post(KEYDB_LOCK);
  }
}

canonical_original_code:
void keydb_lock(long pos) {
  char key[1024] = "";
  int hash_number;
  sprintf(key, "%llu", pos);
  hash_number = get_hash_val(10, key);
  while (1) {
    sem_wait(KEYDB_LOCK);
    if ((bit_array_test(SHM_KEYDB_BITMAP, hash_number)) == 0) {
      bit_array_set(SHM_KEYDB_BITMAP, hash_number);
      sem_post(KEYDB_LOCK);
      break;
    }
    sem_post(KEYDB_LOCK);
  }
}

variable_types: pos long

variable_types:
key
char [1024]


decompiled_code:
int __fastcall keydb_unlock(__int64 a1)
{
unsigned int v1; // ebp
__int128 v3; // [rsp+0h] [rbp-408h] BYREF
char v4[1008]; // [rsp+10h] [rbp-3F8h] BYREF

v3 = 0LL;
memset(v4, 0, sizeof(v4));
sprintf((char *)&v3, "%llu", a1);
v1 = get_hash_val(10LL, &v3);
sem_wait(KEYDB_LOCK);
bit_array_clear(SHM_KEYDB_BITMAP, v1);
return sem_post(KEYDB_LOCK);
}

canonical_decompiled_code:
int __fastcall func1(__int64 a1)
{
unsigned int v1; // ebp
__int128 v3; // [rsp+0h] [rbp-408h] BYREF
char v4[1008]; // [rsp+10h] [rbp-3F8h] BYREF

v3 = 0LL;
memset(v4, 0, sizeof(v4));
sprintf((char *)&v3, "%llu", a1);
v1 = get_hash_val(10LL, &v3);
sem_wait(KEYDB_LOCK);
bit_array_clear(SHM_KEYDB_BITMAP, v1);
return sem_post(KEYDB_LOCK);
}

original_code:
void keydb_unlock(int64_t pos) {
  char key[1024] = "";
  int hash_number;
  sprintf(key, "%llu", pos);
  hash_number = get_hash_val(10, key);
  sem_wait(KEYDB_LOCK);
  bit_array_clear(SHM_KEYDB_BITMAP, hash_number);
  sem_post(KEYDB_LOCK);
}

canonical_original_code:
void keydb_unlock(long pos) {
  char key[1024] = "";
  int hash_number;
  sprintf(key, "%llu", pos);
  hash_number = get_hash_val(10, key);
  sem_wait(KEYDB_LOCK);
  bit_array_clear(SHM_KEYDB_BITMAP, hash_number);
  sem_post(KEYDB_LOCK);
}


decompiled_code:
__int64 __fastcall keydb_tree(unsigned int a1, __off_t a2, __int64 *a3)
{
_DWORD *v4; // rax
_DWORD *v5; // rbp
_BYTE *v6; // rbx
int v7; // eax
__int64 v8; // rsi
__int64 v9; // rax
__int64 v10; // rsi

v4 = key_buf_read(a1, a2);
if ( !v4 )
return 0LL;
v5 = v4;
v6 = malloc(0x400uLL);
if ( !v6 )
{
perror(0LL);
cleanup_and_exit(0LL);
}
v7 = v5[252];
*((_QWORD *)v6 + 127) = 0LL;
if ( v7 > 0 )
{
qmemcpy(v6, v5, 0x3F0uLL);
v8 = *((_QWORD *)v5 + 128);
*((_DWORD *)v6 + 252) = v5[252];
if ( !v8 )
goto LABEL_6;
LABEL_11:
keydb_tree(a1, v8, a3);
goto LABEL_6;
}
*v6 = 0;
v8 = *((_QWORD *)v5 + 128);
if ( v8 )
goto LABEL_11;
LABEL_6:
v9 = *a3;
v10 = *((_QWORD *)v5 + 127);
*a3 = (__int64)v6;
*((_QWORD *)v6 + 127) = v9;
if ( v10 )
keydb_tree(a1, v10, a3);
free(v5);
return 0LL;
}

original_code:
void* keydb_tree(int fd, int64_t pos, struct keydb_column **list) {
  struct keydb_node* parent;
  struct keydb_node* buffer;
  struct keydb_column *mid = ((void *)0);
  int64_t next_pos;
  int64_t n;
  buffer = key_buf_read(fd, pos);
  if (buffer == ((void *)0)) return ((void *)0);
  if ((mid = malloc(sizeof(struct keydb_column))) == ((void *)0)) {
    perror(((void *)0));
    cleanup_and_exit(0);
  }
  mid->next = ((void *)0);
  if (buffer->refcount <= 0) {
    mid->column[0] = '\0';
  } else {
    memcpy(mid->column, buffer->column, (1024 - 2*(sizeof(int)) - sizeof(int64_t)));
    mid->refcount = buffer->refcount;
  }
  if (buffer->right != 0) keydb_tree(fd, buffer->right, list);
  mid->next = *list;
  *list = mid;
  if (buffer->left != 0) keydb_tree(fd, buffer->left, list);
  free(buffer);
  return ((void *)0);
}

canonical_original_code:
void *keydb_tree(int fd, long pos, struct keydb_column **list) {
  struct keydb_node *parent;
  struct keydb_node *buffer;
  struct keydb_column *mid = ((void *)0);
  long next_pos;
  long n;
  buffer = key_buf_read(fd, pos);
  if (buffer == ((void *)0)) return ((void *)0);
  if ((mid = malloc(sizeof(struct keydb_column))) == ((void *)0)) {
    perror(((void *)0));
    cleanup_and_exit(0);
  }
  mid->next = ((void *)0);
  if (buffer->refcount <= 0) {
    mid->column[0] = '\0';
  } else {
    memcpy(mid->column, buffer->column, (1024 - 2*(sizeof(int)) - sizeof(long)));
    mid->refcount = buffer->refcount;
  }
  if (buffer->right != 0) keydb_tree(fd, buffer->right, list);
  mid->next = *list;
  *list = mid;
  if (buffer->left != 0) keydb_tree(fd, buffer->left, list);
  free(buffer);
  return ((void *)0);
}

variable_types: fd int

variable_types: struct keydb_column { char column[-1]; int refcount; struct keydb_column *next; } **

variable_types: struct keydb_node { char column[-1]; int refcount; long left; long right; long next; long pos; } *

variable_types: n long

return_type: void *


decompiled_code:
__int64 __fastcall composite_delete(int fd, char *s2)
{
__int64 v2; // r12
char *v3; // rbx
__int64 v4; // r12
__off_t *v5; // rax
__off_t *v6; // rbp

if ( !s2 )
return 0LL;
v2 = 0LL;
v3 = s2;
while ( 1 )
{
keydb_lock(v2);
v5 = keydb_find(fd, v3, v2);
v6 = v5;
if ( !v5 )
goto LABEL_7;
if ( !*((_DWORD *)v5 + 252) )
{
free(v5);
LABEL_7:
keydb_unlock(v2);
return 0xFFFFFFFFLL;
}
keydb_unlock(v2);
v4 = v6[130];
keydb_lock(v4);
--*((_DWORD *)v6 + 252);
if ( pwrite(fd, v6, 0x418uLL, v4) == -1 )
break;
keydb_unlock(v4);
v3 = (char *)*((_QWORD *)v3 + 127);
v2 = v6[129];
free(v6);
if ( !v3 )
return 0LL;
}
fprintf(stderr, "Problem writing node at %llu in composite_delete().\n", v4);
keydb_unlock(v4);
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func4(int fd, char *s2)
{
__int64 v2; // r12
char *v3; // rbx
__int64 v4; // r12
__off_t *v5; // rax
__off_t *v6; // rbp

if ( !s2 )
return 0LL;
v2 = 0LL;
v3 = s2;
while ( 1 )
{
func0(v2);
v5 = keydb_find(fd, v3, v2);
v6 = v5;
if ( !v5 )
goto LABEL_7;
if ( !*((_DWORD *)v5 + 252) )
{
free(v5);
LABEL_7:
func1(v2);
return 0xFFFFFFFFLL;
}
func1(v2);
v4 = v6[130];
func0(v4);
--*((_DWORD *)v6 + 252);
if ( pwrite(fd, v6, 0x418uLL, v4) == -1 )
break;
func1(v4);
v3 = (char *)*((_QWORD *)v3 + 127);
v2 = v6[129];
free(v6);
if ( !v3 )
return 0LL;
}
fprintf(stderr, "Problem writing node at %llu in composite_delete().\n", v4);
func1(v4);
return 0xFFFFFFFFLL;
}

original_code:
int composite_delete(int fd, struct keydb_column *tuple) {
  int64_t pos = 0;
  struct keydb_node *node;
  while (tuple) {
    keydb_lock(pos);
    node = keydb_find(fd, tuple->column, pos);
    if (node == ((void *)0)) {
      keydb_unlock(pos);
      return -1;
    }
    if (node->refcount == 0) {
      free(node);
      keydb_unlock(pos);
      return(-1);
    }
    keydb_unlock(pos);
    pos = node->pos;
    keydb_lock(pos);
    node->refcount--;
    if ((pwrite(fd, node, sizeof(struct keydb_node), pos)) == -1) {
      fprintf(stderr, "Problem writing node at %llu in composite_delete().\n", pos);
      keydb_unlock(pos);
      return(-1);
      free(node);
    };
    keydb_unlock(pos);
    pos = node->next;
    tuple = tuple->next;
    free(node);
  }
  return 0;
}

canonical_original_code:
int composite_delete(int fd, struct keydb_column *tuple) {
  long pos = 0;
  struct keydb_node *node;
  while (tuple) {
    keydb_lock(pos);
    node = keydb_find(fd, tuple->column, pos);
    if (node == ((void *)0)) {
      keydb_unlock(pos);
      return -1;
    }
    if (node->refcount == 0) {
      free(node);
      keydb_unlock(pos);
      return(-1);
    }
    keydb_unlock(pos);
    pos = node->pos;
    keydb_lock(pos);
    node->refcount--;
    if ((pwrite(fd, node, sizeof(struct keydb_node), pos)) == -1) {
      fprintf(stderr, "Problem writing node at %llu in composite_delete().\n", pos);
      keydb_unlock(pos);
      return(-1);
      free(node);
    };
    keydb_unlock(pos);
    pos = node->next;
    tuple = tuple->next;
    free(node);
  }
  return 0;
}

variable_types: struct keydb_column { char column[-1]; int refcount; struct keydb_column *next; } *

return_type: int

user_defined_types: struct keydb_node { char column[-1]; int refcount; long left; long right; long next; long pos; }


decompiled_code:
__int64 __fastcall find_free_key_node(int fd)
{
__off_t v1; // rax
unsigned int v2; // ebx
__int64 result; // rax
_BYTE v4[1080]; // [rsp+0h] [rbp-438h] BYREF

memset(v4, 0, 0x418uLL);
v1 = lseek(fd, 0LL, 2);
if ( v1 == -1 )
{
perror("lseek failed in find_free_key_node\n");
result = 0xFFFFFFFFLL;
}
else
{
v2 = v1;
if ( pwrite(fd, v4, 0x418uLL, v1) == -1 )
{
perror("pwrite() failed in find_free_key_node.");
result = 0xFFFFFFFFLL;
}
else
{
result = v2;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(int fd)
{
__off_t v1; // rax
unsigned int v2; // ebx
__int64 result; // rax
_BYTE v4[1080]; // [rsp+0h] [rbp-438h] BYREF

memset(v4, 0, 0x418uLL);
v1 = lseek(fd, 0LL, 2);
if ( v1 == -1 )
{
perror("lseek failed in find_free_key_node\n");
result = 0xFFFFFFFFLL;
}
else
{
v2 = v1;
if ( pwrite(fd, v4, 0x418uLL, v1) == -1 )
{
perror("pwrite() failed in find_free_key_node.");
result = 0xFFFFFFFFLL;
}
else
{
result = v2;
}
}
return result;
}

original_code:
int find_free_key_node(int fd) {
  uint64_t pos = 0;
  struct keydb_node buffer = {};
  if (pos == 0) {
    if ((pos = lseek(fd, 0, 2)) == -1) {
      perror("lseek failed in find_free_key_node\n");
      return -1;
    } else {
      if (pwrite(fd, &buffer, sizeof(buffer), pos) == -1) {
        perror("pwrite() failed in find_free_key_node.");
        return -1;
      }
    }
  }
 return pos;
}

canonical_original_code:
int find_free_key_node(int fd) {
  unsigned long pos = 0;
  struct keydb_node buffer = {};
  if (pos == 0) {
    if ((pos = lseek(fd, 0, 2)) == -1) {
      perror("lseek failed in find_free_key_node\n");
      return -1;
    } else {
      if (pwrite(fd, &buffer, sizeof(buffer), pos) == -1) {
        perror("pwrite() failed in find_free_key_node.");
        return -1;
      }
    }
  }
 return pos;
}

variable_types:
pos
unsigned long

variable_types: struct keydb_node { char column[-1]; int refcount; long left; long right; long next; long pos; }


decompiled_code:
__int64 __fastcall new_subkey_tree(int fd, char *src, __off_t offset, char *dest)
{
signed int v6; // eax
__off_t v7; // r15
unsigned int v8; // er12

v6 = find_free_key_node(fd);
v7 = v6;
v8 = v6;
if ( v6 == -1 )
{
fwrite("find_free_key_node_failed.\n", 1uLL, 0x1BuLL, stderr);
free(dest);
}
else
{
*((_QWORD *)dest + 129) = v6;
if ( pwrite(fd, dest, 0x418uLL, offset) == -1
|| (*(_QWORD *)dest = 0LL,
*((_QWORD *)dest + 130) = 0LL,
memset(
(void *)((unsigned __int64)(dest + 8) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)dest - (((_DWORD)dest + 8) & 0xFFFFFFF8) + 1048) >> 3)),
strcpy(dest, src),
*((_DWORD *)dest + 252) = 1,
*((_QWORD *)dest + 130) = v7,
pwrite(fd, dest, 0x418uLL, v7) == -1) )
{
v8 = -1;
perror("pwrite() failed in new_subkey_tree.");
free(dest);
}
else
{
free(dest);
}
}
return v8;
}

canonical_decompiled_code:
__int64 __fastcall func6(int fd, char *src, __off_t offset, char *dest)
{
signed int v6; // eax
__off_t v7; // r15
unsigned int v8; // er12

v6 = func5(fd);
v7 = v6;
v8 = v6;
if ( v6 == -1 )
{
fwrite("find_free_key_node_failed.\n", 1uLL, 0x1BuLL, stderr);
free(dest);
}
else
{
*((_QWORD *)dest + 129) = v6;
if ( pwrite(fd, dest, 0x418uLL, offset) == -1
|| (*(_QWORD *)dest = 0LL,
*((_QWORD *)dest + 130) = 0LL,
memset(
(void *)((unsigned __int64)(dest + 8) & 0xFFFFFFFFFFFFFFF8LL),
0,
8LL * (((unsigned int)dest - (((_DWORD)dest + 8) & 0xFFFFFFF8) + 1048) >> 3)),
strcpy(dest, src),
*((_DWORD *)dest + 252) = 1,
*((_QWORD *)dest + 130) = v7,
pwrite(fd, dest, 0x418uLL, v7) == -1) )
{
v8 = -1;
perror("pwrite() failed in new_subkey_tree.");
free(dest);
}
else
{
free(dest);
}
}
return v8;
}

original_code:
int new_subkey_tree(int fd, char column[], int64_t pos, struct keydb_node *buffer) {
  int64_t next_pos;
  if ((next_pos = find_free_key_node(fd)) == -1) {
    fprintf(stderr, "find_free_key_node_failed.\n");
    free(buffer);
    return -1;
  }
  buffer->next = next_pos;
  if (pwrite(fd, buffer, sizeof(struct keydb_node), pos) == -1) {
    perror("pwrite() failed in new_subkey_tree.");
    free(buffer);
    return -1;
  }
  bzero(buffer, sizeof(struct keydb_node));
  strcpy(buffer->column, column);
  buffer->refcount = 1;
  buffer->pos = next_pos;
  if (pwrite(fd, buffer, sizeof(struct keydb_node), next_pos) == -1) {
    perror("pwrite() failed in new_subkey_tree.");
    free(buffer);
    return -1;
  }
  free(buffer);
  return next_pos;
}

canonical_original_code:
int new_subkey_tree(int fd, char column[], long pos, struct keydb_node *buffer) {
  long next_pos;
  if ((next_pos = find_free_key_node(fd)) == -1) {
    fprintf(stderr, "find_free_key_node_failed.\n");
    free(buffer);
    return -1;
  }
  buffer->next = next_pos;
  if (pwrite(fd, buffer, sizeof(struct keydb_node), pos) == -1) {
    perror("pwrite() failed in new_subkey_tree.");
    free(buffer);
    return -1;
  }
  bzero(buffer, sizeof(struct keydb_node));
  strcpy(buffer->column, column);
  buffer->refcount = 1;
  buffer->pos = next_pos;
  if (pwrite(fd, buffer, sizeof(struct keydb_node), next_pos) == -1) {
    perror("pwrite() failed in new_subkey_tree.");
    free(buffer);
    return -1;
  }
  free(buffer);
  return next_pos;
}

variable_types:
column
char []


decompiled_code:
__int64 keydb_txlog_append()
{
return 0LL;
}

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

original_code:
int keydb_txlog_append(int64_t pos) {
  return 0;
}

canonical_original_code:
int keydb_txlog_append(long pos) {
  return 0;
}


decompiled_code:
__int64 __fastcall connect_and_add_node(int a1, _QWORD *a2, _QWORD *a3, int a4, int a5)
{
signed int v7; // eax
unsigned int v8; // er12
__off_t v9; // r15
char *v10; // rdi

v7 = find_free_key_node(a5);
v8 = v7;
if ( v7 == -1 )
{
fwrite("find_free_key_node_failed.\n", 1uLL, 0x1BuLL, stderr);
free(a2);
}
else
{
v9 = v7;
if ( a1 )
a2[128] = v7;
else
a2[127] = v7;
if ( pwrite(a5, a2, 0x418uLL, a4) == -1 )
{
v8 = -1;
perror("Call to pwrite failed in connect_and_add_node.\n");
}
else
{
*a2 = 0LL;
a2[130] = 0LL;
v10 = (char *)((unsigned __int64)(a2 + 1) & 0xFFFFFFFFFFFFFFF8LL);
memset(v10, 0, 8LL * ((unsigned int)((_DWORD)a2 - (_DWORD)v10 + 1048) >> 3));
*a2 = *a3;
a2[125] = a3[125];
qmemcpy(v10, (char *)a3 - ((char *)a2 - v10), 8LL * ((unsigned int)((_DWORD)a2 - (_DWORD)v10 + 1008) >> 3));
a2[130] = v9;
*((_DWORD *)a2 + 252) = 1;
if ( pwrite(a5, a2, 0x418uLL, v9) == -1 )
{
v8 = -1;
perror("Call to pwrite failed in connect_and_add_node.\n");
}
free(a2);
}
}
return v8;
}

canonical_decompiled_code:
__int64 __fastcall func8(int a1, _QWORD *a2, _QWORD *a3, int a4, int a5)
{
signed int v7; // eax
unsigned int v8; // er12
__off_t v9; // r15
char *v10; // rdi

v7 = func5(a5);
v8 = v7;
if ( v7 == -1 )
{
fwrite("find_free_key_node_failed.\n", 1uLL, 0x1BuLL, stderr);
free(a2);
}
else
{
v9 = v7;
if ( a1 )
a2[128] = v7;
else
a2[127] = v7;
if ( pwrite(a5, a2, 0x418uLL, a4) == -1 )
{
v8 = -1;
perror("Call to pwrite failed in connect_and_add_node.\n");
}
else
{
*a2 = 0LL;
a2[130] = 0LL;
v10 = (char *)((unsigned __int64)(a2 + 1) & 0xFFFFFFFFFFFFFFF8LL);
memset(v10, 0, 8LL * ((unsigned int)((_DWORD)a2 - (_DWORD)v10 + 1048) >> 3));
*a2 = *a3;
a2[125] = a3[125];
qmemcpy(v10, (char *)a3 - ((char *)a2 - v10), 8LL * ((unsigned int)((_DWORD)a2 - (_DWORD)v10 + 1008) >> 3));
a2[130] = v9;
*((_DWORD *)a2 + 252) = 1;
if ( pwrite(a5, a2, 0x418uLL, v9) == -1 )
{
v8 = -1;
perror("Call to pwrite failed in connect_and_add_node.\n");
}
free(a2);
}
}
return v8;
}

original_code:
int connect_and_add_node(int direction, struct keydb_node* buffer, char column[], int pos, int fd) {
  int next_pos;
  if ((next_pos = find_free_key_node(fd)) == -1) {
    fprintf(stderr, "find_free_key_node_failed.\n");
    free(buffer);
    return -1;
  }
  if (direction == 0) {
    buffer->left = next_pos;
  } else {
    buffer->right = next_pos;
  }
  if ((pwrite(fd, buffer, sizeof(struct keydb_node), pos)) == -1) {
    perror("Call to pwrite failed in connect_and_add_node.\n");
    return -1;
  }
  bzero(buffer, sizeof(struct keydb_node));
  memcpy(buffer->column, column, (1024 - 2*(sizeof(int)) - sizeof(int64_t)));
  buffer->refcount = 1;
  buffer->pos = next_pos;
  if ((pwrite(fd, buffer, sizeof(struct keydb_node), next_pos)) == -1) {
    perror("Call to pwrite failed in connect_and_add_node.\n");
    free(buffer);
    return -1;
  }
  free(buffer);
  return next_pos;
}

canonical_original_code:
int connect_and_add_node(int direction, struct keydb_node *buffer, char column[], int pos, int fd) {
  int next_pos;
  if ((next_pos = find_free_key_node(fd)) == -1) {
    fprintf(stderr, "find_free_key_node_failed.\n");
    free(buffer);
    return -1;
  }
  if (direction == 0) {
    buffer->left = next_pos;
  } else {
    buffer->right = next_pos;
  }
  if ((pwrite(fd, buffer, sizeof(struct keydb_node), pos)) == -1) {
    perror("Call to pwrite failed in connect_and_add_node.\n");
    return -1;
  }
  bzero(buffer, sizeof(struct keydb_node));
  memcpy(buffer->column, column, (1024 - 2*(sizeof(int)) - sizeof(long)));
  buffer->refcount = 1;
  buffer->pos = next_pos;
  if ((pwrite(fd, buffer, sizeof(struct keydb_node), next_pos)) == -1) {
    perror("Call to pwrite failed in connect_and_add_node.\n");
    free(buffer);
    return -1;
  }
  free(buffer);
  return next_pos;
}

variable_types: direction int

variable_types: pos int


decompiled_code:
__int64 __fastcall keydb_insert(int a1, __int64 a2, __off_t a3, char a4)
{
__off_t v4; // r14
char v5; // bl
_QWORD *v6; // rax
_QWORD *v7; // rbp
unsigned int v8; // eax
unsigned int v9; // er15
__off_t v10; // r15
int v12; // eax

while ( 1 )
{
v4 = a3;
v5 = a4;
v6 = calloc(0x418uLL, 1uLL);
if ( !v6 )
{
v9 = -1;
perror("Call to malloc() failed in keydb_insert.");
return v9;
}
v7 = v6;
v8 = pread(a1, v6, 0x418uLL, v4);
v9 = v8;
if ( v8 == -1 )
{
perror("pread() failed in keydb_insert.");
free(v7);
return v9;
}
if ( v5 )
{
if ( v8 )
{
v10 = v7[129];
if ( !v10 )
return new_subkey_tree(a1, (char *)a2, v4, (char *)v7);
goto LABEL_13;
}
v9 = -1;
fwrite("pos is at EOF but we need to read a real record.\n", 1uLL, 0x31uLL, stderr);
free(v7);
return v9;
}
if ( !v8 )
{
*v7 = *(_QWORD *)a2;
v7[125] = *(_QWORD *)(a2 + 1000);
qmemcpy(
(void *)((unsigned __int64)(v7 + 1) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)(a2 - ((_QWORD)v7 - ((unsigned __int64)(v7 + 1) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * (((unsigned int)v7 - (((_DWORD)v7 + 8) & 0xFFFFFFF8) + 1008) >> 3));
v7[130] = v4;
*((_DWORD *)v7 + 252) = 1;
LABEL_15:
if ( pwrite(a1, v7, 0x418uLL, v4) == -1 )
{
v9 = -1;
perror("pwrite() failed in keydb_insert.");
}
else
{
v9 = v4;
}
free(v7);
return v9;
}
v12 = strcmp((const char *)v7, (const char *)a2);
if ( v12 <= 0 )
break;
v10 = v7[127];
if ( !v10 )
return connect_and_add_node(0, v7, (_QWORD *)a2, v4, a1);
LABEL_13:
free(v7);
a3 = v10;
a4 = 0;
}
if ( !v12 )
{
++*((_DWORD *)v7 + 252);
goto LABEL_15;
}
v10 = v7[128];
if ( v10 )
goto LABEL_13;
return connect_and_add_node(1, v7, (_QWORD *)a2, v4, a1);
}

canonical_decompiled_code:
__int64 __fastcall func9(int a1, __int64 a2, __off_t a3, char a4)
{
__off_t v4; // r14
char v5; // bl
_QWORD *v6; // rax
_QWORD *v7; // rbp
unsigned int v8; // eax
unsigned int v9; // er15
__off_t v10; // r15
int v12; // eax

while ( 1 )
{
v4 = a3;
v5 = a4;
v6 = calloc(0x418uLL, 1uLL);
if ( !v6 )
{
v9 = -1;
perror("Call to malloc() failed in keydb_insert.");
return v9;
}
v7 = v6;
v8 = pread(a1, v6, 0x418uLL, v4);
v9 = v8;
if ( v8 == -1 )
{
perror("pread() failed in keydb_insert.");
free(v7);
return v9;
}
if ( v5 )
{
if ( v8 )
{
v10 = v7[129];
if ( !v10 )
return func6(a1, (char *)a2, v4, (char *)v7);
goto LABEL_13;
}
v9 = -1;
fwrite("pos is at EOF but we need to read a real record.\n", 1uLL, 0x31uLL, stderr);
free(v7);
return v9;
}
if ( !v8 )
{
*v7 = *(_QWORD *)a2;
v7[125] = *(_QWORD *)(a2 + 1000);
qmemcpy(
(void *)((unsigned __int64)(v7 + 1) & 0xFFFFFFFFFFFFFFF8LL),
(const void *)(a2 - ((_QWORD)v7 - ((unsigned __int64)(v7 + 1) & 0xFFFFFFFFFFFFFFF8LL))),
8LL * (((unsigned int)v7 - (((_DWORD)v7 + 8) & 0xFFFFFFF8) + 1008) >> 3));
v7[130] = v4;
*((_DWORD *)v7 + 252) = 1;
LABEL_15:
if ( pwrite(a1, v7, 0x418uLL, v4) == -1 )
{
v9 = -1;
perror("pwrite() failed in keydb_insert.");
}
else
{
v9 = v4;
}
free(v7);
return v9;
}
v12 = strcmp((const char *)v7, (const char *)a2);
if ( v12 <= 0 )
break;
v10 = v7[127];
if ( !v10 )
return func8(0, v7, (_QWORD *)a2, v4, a1);
LABEL_13:
free(v7);
a3 = v10;
a4 = 0;
}
if ( !v12 )
{
++*((_DWORD *)v7 + 252);
goto LABEL_15;
}
v10 = v7[128];
if ( v10 )
goto LABEL_13;
return func8(1, v7, (_QWORD *)a2, v4, a1);
}

original_code:
int keydb_insert(int fd, char column[], int64_t pos, _Bool go_next) {
  int n;
  int comparison;
  int64_t next_pos;
  struct keydb_node *buffer;
  if ((buffer = malloc(sizeof(struct keydb_node))) == ((void *)0)) {
    perror("Call to malloc() failed in keydb_insert.");
    return -1;
  }
  bzero(buffer, sizeof(struct keydb_node));
  n = pread(fd, buffer, sizeof(struct keydb_node), pos);
  if (n == -1) {
    perror("pread() failed in keydb_insert.");
    free(buffer);
    return -1;
  }
  if (go_next) {
    if (n == 0) {
      fprintf(stderr, "pos is at EOF but we need to read a real record.\n");
      free(buffer);
      return -1;
    }
    if (buffer->next == 0) {
      return(new_subkey_tree(fd, column, pos, buffer));
    } else {
      next_pos = buffer->next;
      free(buffer);
      return(keydb_insert(fd, column, next_pos, 0));
    }
  }
  if (n == 0) {
    memcpy(buffer->column, column, (1024 - 2*(sizeof(int)) - sizeof(int64_t)));
    buffer->refcount = 1;
    buffer->pos = pos;
    if (pwrite(fd, buffer, sizeof(struct keydb_node), pos) == -1) {
      perror("pwrite() failed in keydb_insert.");
      free(buffer);
      return -1;
    }
    free(buffer);
    return pos;
  }
  comparison = strcmp(buffer->column, column);
  if (comparison > 0) {
    if (buffer->left != 0) {
      pos = buffer->left;
      free(buffer);
      return keydb_insert(fd, column, pos, 0);
    } else {
      return connect_and_add_node(0, buffer, column, pos, fd);
    }
  } else if (comparison < 0) {
    if (buffer->right != 0) {
      pos = buffer->right;
      free(buffer);
      return keydb_insert(fd, column, pos, 0);
    } else {
      return connect_and_add_node(1, buffer, column, pos, fd);
    }
  } else {
    buffer->refcount++;
    if (pwrite(fd, buffer, sizeof(struct keydb_node), pos) == -1) {
      perror("pwrite() failed in keydb_insert.");
      free(buffer);
      return -1;
    }
    free(buffer);
    return pos;
  }
  return 0;
}

canonical_original_code:
int keydb_insert(int fd, char column[], long pos, _Bool go_next) {
  int n;
  int comparison;
  long next_pos;
  struct keydb_node *buffer;
  if ((buffer = malloc(sizeof(struct keydb_node))) == ((void *)0)) {
    perror("Call to malloc() failed in keydb_insert.");
    return -1;
  }
  bzero(buffer, sizeof(struct keydb_node));
  n = pread(fd, buffer, sizeof(struct keydb_node), pos);
  if (n == -1) {
    perror("pread() failed in keydb_insert.");
    free(buffer);
    return -1;
  }
  if (go_next) {
    if (n == 0) {
      fprintf(stderr, "pos is at EOF but we need to read a real record.\n");
      free(buffer);
      return -1;
    }
    if (buffer->next == 0) {
      return(new_subkey_tree(fd, column, pos, buffer));
    } else {
      next_pos = buffer->next;
      free(buffer);
      return(keydb_insert(fd, column, next_pos, 0));
    }
  }
  if (n == 0) {
    memcpy(buffer->column, column, (1024 - 2*(sizeof(int)) - sizeof(long)));
    buffer->refcount = 1;
    buffer->pos = pos;
    if (pwrite(fd, buffer, sizeof(struct keydb_node), pos) == -1) {
      perror("pwrite() failed in keydb_insert.");
      free(buffer);
      return -1;
    }
    free(buffer);
    return pos;
  }
  comparison = strcmp(buffer->column, column);
  if (comparison > 0) {
    if (buffer->left != 0) {
      pos = buffer->left;
      free(buffer);
      return keydb_insert(fd, column, pos, 0);
    } else {
      return connect_and_add_node(0, buffer, column, pos, fd);
    }
  } else if (comparison < 0) {
    if (buffer->right != 0) {
      pos = buffer->right;
      free(buffer);
      return keydb_insert(fd, column, pos, 0);
    } else {
      return connect_and_add_node(1, buffer, column, pos, fd);
    }
  } else {
    buffer->refcount++;
    if (pwrite(fd, buffer, sizeof(struct keydb_node), pos) == -1) {
      perror("pwrite() failed in keydb_insert.");
      free(buffer);
      return -1;
    }
    free(buffer);
    return pos;
  }
  return 0;
}

variable_types: n int

variable_types: comparison int


decompiled_code:
__int64 __fastcall composite_insert(int a1, __int64 a2)
{
__int64 v3; // rbp
__int64 v4; // rbx
__int64 v5; // rdi

v3 = a2;
keydb_lock(0LL);
v4 = (int)keydb_insert(a1, a2, 0LL, 0);
keydb_unlock(0LL);
if ( v4 == -1 )
return 0xFFFFFFFFLL;
while ( 1 )
{
v3 = *(_QWORD *)(v3 + 1016);
if ( !v3 )
break;
keydb_lock(v4);
v5 = v4;
v4 = (int)keydb_insert(a1, v3, v4, 1);
keydb_unlock(v5);
if ( v4 == -1 )
return 0xFFFFFFFFLL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func10(int a1, __int64 a2)
{
__int64 v3; // rbp
__int64 v4; // rbx
__int64 v5; // rdi

v3 = a2;
func0(0LL);
v4 = (int)func9(a1, a2, 0LL, 0);
func1(0LL);
if ( v4 == -1 )
return 0xFFFFFFFFLL;
while ( 1 )
{
v3 = *(_QWORD *)(v3 + 1016);
if ( !v3 )
break;
func0(v4);
v5 = v4;
v4 = (int)func9(a1, v3, v4, 1);
func1(v5);
if ( v4 == -1 )
return 0xFFFFFFFFLL;
}
return 0LL;
}

original_code:
int composite_insert(int fd, struct keydb_column *tuple) {
  int64_t pos = 0;
  int64_t previous_pos = 0;
  keydb_lock(pos);
  previous_pos = pos;
  pos = keydb_insert(fd, tuple->column, pos, 0);
  keydb_unlock(previous_pos);
  if (pos == -1) {
    return -1;
  }
  tuple = tuple->next;
  while (tuple) {
    keydb_lock(pos);
    previous_pos = pos;
    pos = keydb_insert(fd, tuple->column, pos, 1);
    keydb_unlock(previous_pos);
    if (pos == -1){
      return -1;
    }
    tuple = tuple->next;
  };
  return 0;
}

canonical_original_code:
int composite_insert(int fd, struct keydb_column *tuple) {
  long pos = 0;
  long previous_pos = 0;
  keydb_lock(pos);
  previous_pos = pos;
  pos = keydb_insert(fd, tuple->column, pos, 0);
  keydb_unlock(previous_pos);
  if (pos == -1) {
    return -1;
  }
  tuple = tuple->next;
  while (tuple) {
    keydb_lock(pos);
    previous_pos = pos;
    pos = keydb_insert(fd, tuple->column, pos, 1);
    keydb_unlock(previous_pos);
    if (pos == -1){
      return -1;
    }
    tuple = tuple->next;
  };
  return 0;
}

user_defined_types: struct keydb_column { char column[-1]; int refcount; struct keydb_column *next; }


decompiled_code:
__int64 __fastcall fnv_32_buf(unsigned __int8 *a1, __int64 a2, unsigned int a3)
{
unsigned __int8 *v3; // rsi
__int64 result; // rax
int v5; // edx

v3 = &a1[a2];
result = a3;
if ( a1 < v3 )
{
do
{
v5 = *a1++;
result = v5 ^ (unsigned int)(16777619 * result);
}
while ( v3 != a1 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int8 *a1, __int64 a2, unsigned int a3)
{
unsigned __int8 *v3; // rsi
__int64 result; // rax
int v5; // edx

v3 = &a1[a2];
result = a3;
if ( a1 < v3 )
{
do
{
v5 = *a1++;
result = v5 ^ (unsigned int)(16777619 * result);
}
while ( v3 != a1 );
}
return result;
}

original_code:
Fnv32_t
fnv_32_buf(void *buf, size_t len, Fnv32_t hval)
{
    unsigned char *bp = (unsigned char *)buf;
    unsigned char *be = bp + len;
    while (bp < be) {
 hval += (hval<<1) + (hval<<4) + (hval<<7) + (hval<<8) + (hval<<24);
 hval ^= (Fnv32_t)*bp++;
    }
    return hval;
}

canonical_original_code:
unsigned int fnv_32_buf(void *buf, unsigned long len, unsigned int hval)
{
    unsigned char *bp = (unsigned char *)buf;
    unsigned char *be = bp + len;
    while (bp < be) {
 hval += (hval<<1) + (hval<<4) + (hval<<7) + (hval<<8) + (hval<<24);
 hval ^= (Fnv32_t)*bp++;
    }
    return hval;
}

variable_types:
buf
void *

variable_types:
len
unsigned long

variable_types:
hval
unsigned int

variable_types:
bp
unsigned char *

variable_types:
be
unsigned char *

return_type: unsigned int


decompiled_code:
__int64 __fastcall fnv_32_str(unsigned __int8 *a1, unsigned int a2)
{
__int64 result; // rax
unsigned __int8 i; // si
int v4; // edx
unsigned int v5; // eax

result = a2;
for ( i = *a1; *a1; result = v4 ^ v5 )
{
v4 = 16777619 * result;
++a1;
v5 = i;
i = *a1;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned __int8 *a1, unsigned int a2)
{
__int64 result; // rax
unsigned __int8 i; // si
int v4; // edx
unsigned int v5; // eax

result = a2;
for ( i = *a1; *a1; result = v4 ^ v5 )
{
v4 = 16777619 * result;
++a1;
v5 = i;
i = *a1;
}
return result;
}

original_code:
Fnv32_t
fnv_32_str(char *str, Fnv32_t hval)
{
    unsigned char *s = (unsigned char *)str;
    while (*s) {
 hval += (hval<<1) + (hval<<4) + (hval<<7) + (hval<<8) + (hval<<24);
 hval ^= (Fnv32_t)*s++;
    }
    return hval;
}

canonical_original_code:
unsigned int fnv_32_str(char *str, unsigned int hval)
{
    unsigned char *s = (unsigned char *)str;
    while (*s) {
 hval += (hval<<1) + (hval<<4) + (hval<<7) + (hval<<8) + (hval<<24);
 hval ^= (Fnv32_t)*s++;
    }
    return hval;
}

variable_types:
str
char *

variable_types:
s
unsigned char *


main

canonical_name: main

repo: rpoisel/feasibility

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // er12
pthread_t newthread[2]; // [rsp+8h] [rbp-10h] BYREF

if ( pthread_create(newthread, 0LL, reader, 0LL) )
return 1;
puts("Started.");
v3 = pthread_join(newthread[0], 0LL);
if ( v3 )
return 1;
puts("Finished.");
return v3;
}

original_code:
int main(void)
{
    pthread_t thread_id;
    if (pthread_create(&thread_id, ((void *)0), reader, ((void *)0)) != 0)
    {
        return 1;
    }
    printf("Started.\n");
    if (pthread_join(thread_id, ((void *)0)) != 0)
    {
        return 1;
    }
    printf("Finished.\n");
    return 0;
}

canonical_original_code:
int main()
{
    unsigned long thread_id;
    if (pthread_create(&thread_id, ((void *)0), reader, ((void *)0)) != 0)
    {
        return 1;
    }
    printf("Started.\n");
    if (pthread_join(thread_id, ((void *)0)) != 0)
    {
        return 1;
    }
    printf("Finished.\n");
    return 0;
}


reader

decompiled_code:
void *__fastcall reader(void *a1)
{
puts("Hello Thread.");
return 0LL;
}

canonical_decompiled_code:
void *__fastcall func7(void *a1)
{
puts("Hello Thread.");
return 0LL;
}

original_code:
void* reader(void* thread_params)
{
    printf("Hello Thread.\n");
    return ((void *)0);
}

canonical_original_code:
void *reader(void *thread_params)
{
    printf("Hello Thread.\n");
    return ((void *)0);
}


main

repo: rprata/labprog-uerj

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // rbp
__int64 v4; // rdx
__int64 v5; // r13
__int64 v6; // rdx
__int64 v7; // r12

v3 = make_point(0LL, 0LL, envp);
v5 = make_point(1LL, 2LL, v4);
v7 = make_point(0LL, 0LL, v6);
if ( (unsigned int)compare_point(v3, v5) )
puts("P1 e P2 sao iguais");
else
puts("P1 e P2 sao diferentes");
if ( (unsigned int)compare_point(v3, v7) )
puts("P1 e P3 sao iguais");
else
puts("P1 e P3 sao diferentes");
return 0;
}

original_code:
int main (int argc, char ** argv)
{
 Point p1 = make_point(0,0);
 Point p2 = make_point(1, 2);
 Point p3 = make_point(0, 0);
 int res = compare_point(p1, p2);
 if (!res)
  printf("P1 e P2 sao diferentes\n");
 else
  printf("P1 e P2 sao iguais\n");
 res = compare_point(p1, p3);
 if (!res)
  printf("P1 e P3 sao diferentes\n");
 else
  printf("P1 e P3 sao iguais\n");
 return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
 struct Point_st p1 = make_point(0,0);
 struct Point_st p2 = make_point(1, 2);
 struct Point_st p3 = make_point(0, 0);
 int res = compare_point(p1, p2);
 if (!res)
  printf("P1 e P2 sao diferentes\n");
 else
  printf("P1 e P2 sao iguais\n");
 res = compare_point(p1, p3);
 if (!res)
  printf("P1 e P3 sao diferentes\n");
 else
  printf("P1 e P3 sao iguais\n");
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: res int


decompiled_code:
__int64 __fastcall make_point(unsigned int a1, __int64 a2)
{
return (a2 << 32) | a1;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1, __int64 a2)
{
return (a2 << 32) | a1;
}

original_code:
Point make_point (int x, int y)
{
  Point p;
  p.x = x;
  p.y = y;
  return p;
}

canonical_original_code:
struct Point_st make_point(int x, int y)
{
  struct Point_st p;
  p.x = x;
  p.y = y;
  return p;
}

variable_types: x int

variable_types: y int

variable_types:
p
struct Point_st { int x; int y; }

return_type: struct Point_st { int x; int y; }


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

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

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

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

original_code:
int compare_point (Point p1, Point p2)
{
  if (p1.x == p2.x && p1.y == p2.y)
    return 1;
  else
    return 0;
}

canonical_original_code:
int compare_point(struct Point_st p1, struct Point_st p2)
{
  if (p1.x == p2.x && p1.y == p2.y)
    return 1;
  else
    return 0;
}


decompiled_code:
__int64 __fastcall add_point(__int64 a1, __int64 a2)
{
return make_point((int)a2 + (int)a1, (unsigned int)(HIDWORD(a2) + HIDWORD(a1)));
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, __int64 a2)
{
return func0((int)a2 + (int)a1, (unsigned int)(HIDWORD(a2) + HIDWORD(a1)));
}

original_code:
Point add_point (Point p1, Point p2)
{
  return make_point(p1.x + p2.x, p1.y + p2.y);
}

canonical_original_code:
struct Point_st add_point(struct Point_st p1, struct Point_st p2)
{
  return make_point(p1.x + p2.x, p1.y + p2.y);
}


fibonacci

original_code:
unsigned long fibonacci (unsigned int n)
{
  f[0] = 0;
  f[1] = 1;
  for (int i = 2; i <= n; i++)
    f[i] = f[i - 1] + f[i - 2];
   return f[n];
}

canonical_original_code:
unsigned long fibonacci(unsigned int n)
{
  f[0] = 0;
  f[1] = 1;
  for (int i = 2; i <= n; i++)
    f[i] = f[i - 1] + f[i - 2];
   return f[n];
}

variable_types:
n
unsigned int

variable_types: i int

return_type: unsigned long


decompiled_code:
__int64 __fastcall fibonacci_rec(unsigned int a1)
{
int v2; // er8
__int64 v3; // rax
__int64 v4; // r9

if ( a1 <= 1 )
return a1;
fibonacci(a1 - 1);
v3 = fibonacci(v2 - 2);
return v4 + v3;
}

canonical_decompiled_code:
__int64 __fastcall func4(unsigned int a1)
{
int v2; // er8
__int64 v3; // rax
__int64 v4; // r9

if ( a1 <= 1 )
return a1;
func3(a1 - 1);
v3 = func3(v2 - 2);
return v4 + v3;
}

original_code:
unsigned long fibonacci_rec (unsigned int n)
{
  return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2);
}

canonical_original_code:
unsigned long fibonacci_rec(unsigned int n)
{
  return n <= 1 ? n : fibonacci(n - 1) + fibonacci(n - 2);
}


swap

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

result = (unsigned int)*a1;
*a1 = *a2;
*a2 = result;
return result;
}

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

result = (unsigned int)*a1;
*a1 = *a2;
*a2 = result;
return result;
}

original_code:
void swap (int * a, int * b)
{
  int tmp;
  tmp = *a;
  *a = *b;
  *b = tmp;
}

canonical_original_code:
void swap(int *a, int *b)
{
  int tmp;
  tmp = *a;
  *a = *b;
  *b = tmp;
}

variable_types:
a
int *

variable_types:
b
int *

variable_types: tmp int


partition

decompiled_code:
__int64 __fastcall partition(__int64 a1, int a2, int a3)
{
__int64 v5; // rcx
_DWORD *v7; // r11
unsigned int v8; // er9
__int64 result; // rax
unsigned int v10; // er9

LODWORD(v5) = a2 + 1;
v7 = (_DWORD *)(a1 + 4LL * a2);
if ( a2 + 1 > a3 )
{
swap(v7, (_DWORD *)(a1 + 4LL * a2));
result = v10;
}
else
{
v5 = (int)v5;
do
{
while ( *(_DWORD *)(a1 + 4 * v5) >= *v7 )
{
if ( a3 < (int)++v5 )
goto LABEL_6;
}
swap((_DWORD *)(a1 + 4LL * (a2 + 1)), (_DWORD *)(a1 + 4 * v5));
}
while ( a3 >= (int)v5 );
LABEL_6:
swap(v7, (_DWORD *)(a1 + 4LL * a2));
result = v8;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, int a2, int a3)
{
__int64 v5; // rcx
_DWORD *v7; // r11
unsigned int v8; // er9
__int64 result; // rax
unsigned int v10; // er9

LODWORD(v5) = a2 + 1;
v7 = (_DWORD *)(a1 + 4LL * a2);
if ( a2 + 1 > a3 )
{
func5(v7, (_DWORD *)(a1 + 4LL * a2));
result = v10;
}
else
{
v5 = (int)v5;
do
{
while ( *(_DWORD *)(a1 + 4 * v5) >= *v7 )
{
if ( a3 < (int)++v5 )
goto LABEL_6;
}
func5((_DWORD *)(a1 + 4LL * (a2 + 1)), (_DWORD *)(a1 + 4 * v5));
}
while ( a3 >= (int)v5 );
LABEL_6:
func5(v7, (_DWORD *)(a1 + 4LL * a2));
result = v8;
}
return result;
}

original_code:
int partition (int vec[], int left, int right)
{
  int i, j;
  i = left;
  for (j = left + 1; j <= right; ++j) {
    if (vec[j] < vec[left]) {
      ++i;
      swap(&vec[i], &vec[j]);
    }
  }
  swap(&vec[left], &vec[i]);
  return i;
}

canonical_original_code:
int partition(int vec[], int left, int right)
{
  int i; int j;
  i = left;
  for (j = left + 1; j <= right; ++j) {
    if (vec[j] < vec[left]) {
      ++i;
      swap(&vec[i], &vec[j]);
    }
  }
  swap(&vec[left], &vec[i]);
  return i;
}

variable_types:
vec
int []

variable_types: left int

variable_types: right int

variable_types: j int


decompiled_code:
__int64 __fastcall binary_search(__int64 a1, int a2, int a3, int a4)
{
int v6; // esi
int v7; // eax
unsigned int v8; // er9

v6 = a3;
if ( a2 > a3 )
return (unsigned int)-1;
while ( 1 )
{
while ( 1 )
{
v7 = (v6 + a2) / 2;
v8 = v7;
if ( *(_DWORD *)(a1 + 4LL * v7) <= a4 )
break;
v6 = v7 - 1;
if ( v7 - 1 < a2 )
return (unsigned int)-1;
}
if ( *(_DWORD *)(a1 + 4LL * v7) >= a4 )
break;
a2 = v7 + 1;
if ( v6 < v7 + 1 )
return (unsigned int)-1;
}
return v8;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, int a2, int a3, int a4)
{
int v6; // esi
int v7; // eax
unsigned int v8; // er9

v6 = a3;
if ( a2 > a3 )
return (unsigned int)-1;
while ( 1 )
{
while ( 1 )
{
v7 = (v6 + a2) / 2;
v8 = v7;
if ( *(_DWORD *)(a1 + 4LL * v7) <= a4 )
break;
v6 = v7 - 1;
if ( v7 - 1 < a2 )
return (unsigned int)-1;
}
if ( *(_DWORD *)(a1 + 4LL * v7) >= a4 )
break;
a2 = v7 + 1;
if ( v6 < v7 + 1 )
return (unsigned int)-1;
}
return v8;
}

original_code:
int binary_search(int a[], int low, int high, int target)
{
    if (high < low)
        return -1;
    int middle = (low + high)/2;
    if (target < a[middle])
        return binary_search(a, low, middle-1, target);
    else if (target > a[middle])
        return binary_search(a, middle+1, high, target);
    else
        return middle;
}

variable_types:
a
int []

variable_types: low int

variable_types: high int

variable_types: target int

variable_types: middle int


decompiled_code:
void __fastcall quick_sort(__int64 a1, int a2, int a3)
{
unsigned int v4; // ebp
int v5; // ebx

if ( a3 > a2 )
{
v4 = a2;
do
{
v5 = partition(a1, v4, a3);
quick_sort(a1, v4, (unsigned int)(v5 - 1));
v4 = v5 + 1;
}
while ( v5 + 1 < a3 );
}
}

canonical_decompiled_code:
void __fastcall func8(__int64 a1, int a2, int a3)
{
unsigned int v4; // ebp
int v5; // ebx

if ( a3 > a2 )
{
v4 = a2;
do
{
v5 = func6(a1, v4, a3);
func8(a1, v4, (unsigned int)(v5 - 1));
v4 = v5 + 1;
}
while ( v5 + 1 < a3 );
}
}

original_code:
void quick_sort (int vec[], int left, int right)
{
 int r;
   if (right > left)
   {
     r = partition(vec, left, right);
     quick_sort(vec, left, r - 1);
     quick_sort(vec, r + 1, right);
   }
}

canonical_original_code:
void quick_sort(int vec[], int left, int right)
{
 int r;
   if (right > left)
   {
     r = partition(vec, left, right);
     quick_sort(vec, left, r - 1);
     quick_sort(vec, r + 1, right);
   }
}

variable_types: r int


decompiled_code:
__int64 __fastcall bubble_sort(_DWORD *a1, int a2)
{
int v3; // er9
_DWORD *v4; // rcx
int v5; // er8
_DWORD *v6; // rdi
__int64 result; // rax

v3 = a2;
if ( a2 > 0 )
{
do
{
v4 = a1;
v5 = 0;
do
{
while ( 1 )
{
v6 = v4++;
result = (unsigned int)v6[1];
if ( *v6 > (int)result )
break;
if ( v3 <= ++v5 )
goto LABEL_6;
}
result = swap(v6, v4);
}
while ( v3 > v5 );
LABEL_6:
--v3;
}
while ( v3 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(_DWORD *a1, int a2)
{
int v3; // er9
_DWORD *v4; // rcx
int v5; // er8
_DWORD *v6; // rdi
__int64 result; // rax

v3 = a2;
if ( a2 > 0 )
{
do
{
v4 = a1;
v5 = 0;
do
{
while ( 1 )
{
v6 = v4++;
result = (unsigned int)v6[1];
if ( *v6 > (int)result )
break;
if ( v3 <= ++v5 )
goto LABEL_6;
}
result = func5(v6, v4);
}
while ( v3 > v5 );
LABEL_6:
--v3;
}
while ( v3 );
}
return result;
}

original_code:
void bubble_sort(int vec[], int length)
{
  int i;
  if(length > 0)
  {
    for(i = 0; i < length; i++)
    {
      int first = vec[i];
      int second = vec[i + 1];
      if(second < first)
      {
        swap(&vec[i], &vec[i + 1]);
      }
    }
    bubble_sort(vec,length - 1);
  }
}

variable_types: length int

variable_types: first int

variable_types: second int


decompiled_code:
unsigned __int64 __fastcall shell_sort(__int64 a1, int a2)
{
int v2; // er12
int v3; // er14
unsigned __int64 result; // rax
int v5; // edi
int v6; // er13
int v7; // ebx
_DWORD *v8; // r11
__int64 v9; // r8
int v10; // er9
int v11; // ecx
_DWORD *v12; // rdx
_DWORD *v13; // r10

v2 = 1;
do
v2 = 3 * v2 + 1;
while ( v2 < a2 );
do
{
v3 = v2;
result = (unsigned int)(v2 >> 31);
v5 = v2 / 3;
v2 = v5;
if ( a2 > v5 )
{
v6 = a2 - v5;
v7 = 0;
v8 = (_DWORD *)(a1 + 4LL * v5);
v9 = 4LL * -v5;
LABEL_5:
while ( 2 )
{
v10 = *v8;
v11 = v7;
result = (unsigned __int64)&v8[-v5];
v12 = v8;
while ( 1 )
{
v13 = (_DWORD *)result;
if ( *(_DWORD *)result <= v10 )
break;
*v12 = *(_DWORD *)result;
result += v9;
v12 = (_DWORD *)((char *)v12 + v9);
v11 -= v5;
if ( v11 < 0 )
{
++v7;
*v13 = v10;
++v8;
if ( v7 != v6 )
goto LABEL_5;
goto LABEL_9;
}
}
++v7;
++v8;
*v12 = v10;
if ( v7 != v6 )
continue;
break;
}
}
LABEL_9:
;
}
while ( v3 > 5 );
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func10(__int64 a1, int a2)
{
int v2; // er12
int v3; // er14
unsigned __int64 result; // rax
int v5; // edi
int v6; // er13
int v7; // ebx
_DWORD *v8; // r11
__int64 v9; // r8
int v10; // er9
int v11; // ecx
_DWORD *v12; // rdx
_DWORD *v13; // r10

v2 = 1;
do
v2 = 3 * v2 + 1;
while ( v2 < a2 );
do
{
v3 = v2;
result = (unsigned int)(v2 >> 31);
v5 = v2 / 3;
v2 = v5;
if ( a2 > v5 )
{
v6 = a2 - v5;
v7 = 0;
v8 = (_DWORD *)(a1 + 4LL * v5);
v9 = 4LL * -v5;
LABEL_5:
while ( 2 )
{
v10 = *v8;
v11 = v7;
result = (unsigned __int64)&v8[-v5];
v12 = v8;
while ( 1 )
{
v13 = (_DWORD *)result;
if ( *(_DWORD *)result <= v10 )
break;
*v12 = *(_DWORD *)result;
result += v9;
v12 = (_DWORD *)((char *)v12 + v9);
v11 -= v5;
if ( v11 < 0 )
{
++v7;
*v13 = v10;
++v8;
if ( v7 != v6 )
goto LABEL_5;
goto LABEL_9;
}
}
++v7;
++v8;
*v12 = v10;
if ( v7 != v6 )
continue;
break;
}
}
LABEL_9:
;
}
while ( v3 > 5 );
return result;
}

original_code:
void shell_sort (int vec[], int length)
{
    int i , j , value;
    int gap = 1;
    do
    {
        gap = 3*gap+1;
    } while(gap < length);
    do
    {
        gap /= 3;
        for(i = gap; i < length; i++)
        {
            value = vec[i];
            j = i - gap;
            while (j >= 0 && value < vec[j])
            {
                vec [j + gap] = vec[j];
                j -= gap;
            }
            vec [j + gap] = value;
        }
    } while ( gap > 1);
}

canonical_original_code:
void shell_sort(int vec[], int length)
{
    int i; int j; int value;
    int gap = 1;
    do
    {
        gap = 3*gap+1;
    } while(gap < length);
    do
    {
        gap /= 3;
        for(i = gap; i < length; i++)
        {
            value = vec[i];
            j = i - gap;
            while (j >= 0 && value < vec[j])
            {
                vec [j + gap] = vec[j];
                j -= gap;
            }
            vec [j + gap] = value;
        }
    } while ( gap > 1);
}

variable_types: i int

variable_types: value int

variable_types: gap int


isTreeEmpty

decompiled_code:
bool __fastcall isTreeEmpty(__int64 a1)
{
return a1 != 0;
}

canonical_decompiled_code:
bool __fastcall func8(__int64 a1)
{
return a1 != 0;
}

original_code:
_Bool isTreeEmpty ( BinaryTree aTree )
{
  _Bool returnValue = 0;
  if(aTree != ((void *)0)) {
    returnValue = 1;
  }
  return returnValue;
}

canonical_original_code:
_Bool isTreeEmpty(struct treeNode *aTree)
{
  _Bool returnValue = 0;
  if(aTree != ((void *)0)) {
    returnValue = 1;
  }
  return returnValue;
}

variable_types: struct treeNode { int data; struct treeNode *left; struct treeNode *right; } *


isTreeFull

decompiled_code:
bool isTreeFull()
{
void *v0; // rbx

v0 = malloc(8uLL);
free(v0);
return v0 == 0LL;
}

canonical_decompiled_code:
bool func9()
{
void *v0; // rbx

v0 = malloc(8uLL);
free(v0);
return v0 == 0LL;
}

original_code:
_Bool isTreeFull ( BinaryTree aTree )
{
  _Bool returnValue = 1;
  BinaryTree temp = ((void *)0);
  temp = (BinaryTree) malloc(sizeof(BinaryTree));
  if(temp != ((void *)0)) {
    returnValue = 0;
  }
  free(temp);
  return returnValue;
}

canonical_original_code:
_Bool isTreeFull(struct treeNode *aTree)
{
  _Bool returnValue = 1;
  struct treeNode *temp = ((void *)0);
  temp = (struct treeNode *) malloc(sizeof(BinaryTree));
  if(temp != ((void *)0)) {
    returnValue = 0;
  }
  free(temp);
  return returnValue;
}

user_defined_types: struct treeNode { int data; struct treeNode *left; struct treeNode *right; }


deleteFromTree

decompiled_code:
void __fastcall deleteFromTree(_QWORD **a1, int a2)
{
_QWORD *v2; // r8
_QWORD *v3; // rdx
_QWORD *v4; // rax

v2 = *a1;
if ( *a1 && *(_DWORD *)v2 == a2 )
{
v3 = (_QWORD *)v2[2];
v4 = (_QWORD *)v2[1];
if ( v3 )
{
if ( !v4 )
{
*a1 = v3;
free(v2);
}
}
else
{
if ( v4 )
*a1 = v4;
else
*a1 = 0LL;
free(v2);
}
}
}

original_code:
void deleteFromTree ( BinaryTree *aTree, int data )
{
  BinaryTree tempNode = ( *aTree );
  if ( tempNode != ((void *)0) )
    {
      if ( tempNode->data == data )
        {
          if ( tempNode->right != ((void *)0) )
            {
              if ( tempNode->left == ((void *)0) )
                {
                  ( *aTree ) = ( *aTree )->right;
                  free ( tempNode );
                  tempNode = ((void *)0);
                }
              else
                {
                }
            }
          else
            {
              if ( tempNode->left != ((void *)0) )
                {
                  ( *aTree ) = ( *aTree )->left;
                  free ( tempNode );
                  tempNode = ((void *)0);
                }
              else
                {
                  ( *aTree ) = ((void *)0);
                  free ( tempNode );
                  tempNode = ((void *)0);
                }
            }
        }
    }
}

canonical_original_code:
void deleteFromTree(struct treeNode **aTree, int data)
{
  struct treeNode *tempNode = ( *aTree );
  if ( tempNode != ((void *)0) )
    {
      if ( tempNode->data == data )
        {
          if ( tempNode->right != ((void *)0) )
            {
              if ( tempNode->left == ((void *)0) )
                {
                  ( *aTree ) = ( *aTree )->right;
                  free ( tempNode );
                  tempNode = ((void *)0);
                }
              else
                {
                }
            }
          else
            {
              if ( tempNode->left != ((void *)0) )
                {
                  ( *aTree ) = ( *aTree )->left;
                  free ( tempNode );
                  tempNode = ((void *)0);
                }
              else
                {
                  ( *aTree ) = ((void *)0);
                  free ( tempNode );
                  tempNode = ((void *)0);
                }
            }
        }
    }
}

variable_types: struct treeNode { int data; struct treeNode *left; struct treeNode *right; } **

variable_types: data int


printTree

decompiled_code:
void printTree()
{
;
}

canonical_decompiled_code:
void func12()
{
;
}

original_code:
void printTree ( BinaryTree* aTree )
{
}

canonical_original_code:
void printTree(struct treeNode **aTree)
{
}


emptyTree

decompiled_code:
void __fastcall emptyTree(__int64 a1)
{
_QWORD *v1; // rbp

v1 = *(_QWORD **)a1;
if ( *(_QWORD *)(*(_QWORD *)a1 + 8LL) )
emptyTree(v1 + 1);
if ( v1[2] )
emptyTree(v1 + 2);
free(v1);
}

original_code:
void emptyTree ( BinaryTree* aTree )
{
  BinaryTree temp = *aTree;
  if(temp->left != ((void *)0)) {
    emptyTree(&(temp->left));
  }
  if(temp->right != ((void *)0)) {
    emptyTree(&(temp->right));
  }
  aTree = ((void *)0);
  free(temp);
}

canonical_original_code:
void emptyTree(struct treeNode **aTree)
{
  struct treeNode *temp = *aTree;
  if(temp->left != ((void *)0)) {
    emptyTree(&(temp->left));
  }
  if(temp->right != ((void *)0)) {
    emptyTree(&(temp->right));
  }
  aTree = ((void *)0);
  free(temp);
}


takeFromTree

decompiled_code:
__int64 takeFromTree()
{
return 0LL;
}

canonical_decompiled_code:
__int64 func14()
{
return 0LL;
}

original_code:
int takeFromTree ( BinaryTree* aTree, int data )
{
  int returnValue = 0;
  return returnValue;
}

canonical_original_code:
int takeFromTree(struct treeNode **aTree, int data)
{
  int returnValue = 0;
  return returnValue;
}

variable_types: returnValue int


popStack

decompiled_code:
__int64 __fastcall popStack(unsigned int **a1)
{
unsigned int *v1; // r8
unsigned int v2; // er12

v1 = *a1;
v2 = **a1;
*a1 = (unsigned int *)*((_QWORD *)*a1 + 1);
free(v1);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned int **a1)
{
unsigned int *v1; // r8
unsigned int v2; // er12

v1 = *a1;
v2 = **a1;
*a1 = (unsigned int *)*((_QWORD *)*a1 + 1);
free(v1);
return v2;
}

original_code:
int popStack(stackNode *pointerToAStack) {
  stackNode tempNode = *pointerToAStack;
  int tempData = (*pointerToAStack)->data;
  *pointerToAStack = (*pointerToAStack)->next;
  free(tempNode);
  tempNode = ((void *)0);
  return tempData;
}

canonical_original_code:
int popStack(struct aNode **pointerToAStack) {
  struct aNode *tempNode = *pointerToAStack;
  int tempData = (*pointerToAStack)->data;
  *pointerToAStack = (*pointerToAStack)->next;
  free(tempNode);
  tempNode = ((void *)0);
  return tempData;
}

variable_types: struct aNode { int data; struct aNode *next; } **

variable_types: tempData int


isStackEmpty

decompiled_code:
bool __fastcall isStackEmpty(__int64 a1)
{
return a1 == 0;
}

canonical_decompiled_code:
bool __fastcall func9(__int64 a1)
{
return a1 == 0;
}

original_code:
_Bool isStackEmpty(stackNode stack) {
  if(stack == ((void *)0)) {
    return 1;
  } else {
    return 0;
  }
}

canonical_original_code:
_Bool isStackEmpty(struct aNode *stack) {
  if(stack == ((void *)0)) {
    return 1;
  } else {
    return 0;
  }
}

variable_types: struct aNode { int data; struct aNode *next; } *


isStackFull

decompiled_code:
bool isStackFull()
{
void *v0; // rbx

v0 = malloc(0x10uLL);
free(v0);
return v0 == 0LL;
}

canonical_decompiled_code:
bool func10()
{
void *v0; // rbx

v0 = malloc(0x10uLL);
free(v0);
return v0 == 0LL;
}

original_code:
_Bool isStackFull(stackNode stack) {
  stackNode tempNode = (struct aNode *) malloc(sizeof(struct aNode));
  _Bool returnValue = 0;
  if(tempNode == ((void *)0)) {
    returnValue = 1;
  }
  free(tempNode);
  return returnValue;
}

canonical_original_code:
_Bool isStackFull(struct aNode *stack) {
  struct aNode *tempNode = (struct aNode *) malloc(sizeof(struct aNode));
  _Bool returnValue = 0;
  if(tempNode == ((void *)0)) {
    returnValue = 1;
  }
  free(tempNode);
  return returnValue;
}

user_defined_types: struct aNode { int data; struct aNode *next; }


listStack

decompiled_code:
bool __fastcall listStack(unsigned int *a1)
{
bool result; // al

while ( 1 )
{
result = isStackEmpty((__int64)a1);
if ( result )
break;
printf("Node: %p\nData: %i\n", a1, *a1);
a1 = (unsigned int *)*((_QWORD *)a1 + 1);
}
return result;
}

canonical_decompiled_code:
bool __fastcall func11(unsigned int *a1)
{
bool result; // al

while ( 1 )
{
result = func9((__int64)a1);
if ( result )
break;
printf("Node: %p\nData: %i\n", a1, *a1);
a1 = (unsigned int *)*((_QWORD *)a1 + 1);
}
return result;
}

original_code:
void listStack(stackNode stack) {
  stackNode currentNode = stack;
  while(!isStackEmpty(currentNode)) {
    printf("Node: %p\nData: %i\n",
    (void*) currentNode, currentNode->data);
    currentNode = currentNode->next;
  }
}

canonical_original_code:
void listStack(struct aNode *stack) {
  struct aNode *currentNode = stack;
  while(!isStackEmpty(currentNode)) {
    printf("Node: %p\nData: %i\n",
    (void *) currentNode, currentNode->data);
    currentNode = currentNode->next;
  }
}


emptyStack

decompiled_code:
bool __fastcall emptyStack(_QWORD **a1)
{
_QWORD *i; // rdi
_QWORD *v2; // rbx
bool result; // al

for ( i = *a1; ; i = v2 )
{
result = isStackEmpty((__int64)i);
if ( !result )
break;
v2 = (_QWORD *)i[1];
free(i);
}
return result;
}

canonical_decompiled_code:
bool __fastcall func12(_QWORD **a1)
{
_QWORD *i; // rdi
_QWORD *v2; // rbx
bool result; // al

for ( i = *a1; ; i = v2 )
{
result = func9((__int64)i);
if ( !result )
break;
v2 = (_QWORD *)i[1];
free(i);
}
return result;
}

original_code:
void emptyStack(stackNode *pointerToAStack) {
  stackNode currentNode = *pointerToAStack;
  while(isStackEmpty(currentNode)) {
    stackNode tempNode = currentNode;
    currentNode = currentNode->next;
    free(tempNode);
  }
}

canonical_original_code:
void emptyStack(struct aNode **pointerToAStack) {
  struct aNode *currentNode = *pointerToAStack;
  while(isStackEmpty(currentNode)) {
    struct aNode *tempNode = currentNode;
    currentNode = currentNode->next;
    free(tempNode);
  }
}


printrandoms

decompiled_code:
int __fastcall printrandoms(__int64 a1, __int64 a2)
{
__int64 i; // rbx
__int64 v4; // rsi
int result; // eax

if ( a2 )
{
for ( i = 0LL; i != a2; ++i )
{
v4 = *(_QWORD *)(a1 + 8 * i);
result = printf("%015lu\n", v4);
}
}
return result;
}

canonical_decompiled_code:
int __fastcall func8(__int64 a1, __int64 a2)
{
__int64 i; // rbx
__int64 v4; // rsi
int result; // eax

if ( a2 )
{
for ( i = 0LL; i != a2; ++i )
{
v4 = *(_QWORD *)(a1 + 8 * i);
result = printf("%015lu\n", v4);
}
}
return result;
}

original_code:
void printrandoms(size_t numbers[], size_t HowManyNumbers) {
  size_t counter = 0;
  for( ; counter < HowManyNumbers; ++counter) {
    printf("%015lu\n", numbers[counter]);
  }
}

canonical_original_code:
void printrandoms(unsigned long numbers[], unsigned long HowManyNumbers) {
  unsigned long counter = 0;
  for( ; counter < HowManyNumbers; ++counter) {
    printf("%015lu\n", numbers[counter]);
  }
}

variable_types:
numbers
unsigned long []

variable_types:
HowManyNumbers
unsigned long

variable_types:
counter
unsigned long


minimum

decompiled_code:
unsigned __int64 __fastcall minimum(__int64 a1, unsigned __int64 a2, unsigned __int64 a3)
{
unsigned __int64 v3; // r8
unsigned __int64 v4; // rax

v3 = a2;
if ( a2 < a3 )
{
v4 = a2;
do
{
if ( *(_QWORD *)(a1 + 8 * v4) < *(_QWORD *)(a1 + 8 * v3) )
v3 = v4;
++v4;
}
while ( a3 != v4 );
}
return v3;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func9(__int64 a1, unsigned __int64 a2, unsigned __int64 a3)
{
unsigned __int64 v3; // r8
unsigned __int64 v4; // rax

v3 = a2;
if ( a2 < a3 )
{
v4 = a2;
do
{
if ( *(_QWORD *)(a1 + 8 * v4) < *(_QWORD *)(a1 + 8 * v3) )
v3 = v4;
++v4;
}
while ( a3 != v4 );
}
return v3;
}

original_code:
size_t minimum(size_t numbers[], size_t start, size_t HowManyNumbers) {
  size_t indexOfSmallest = start;
  size_t counter = 0;
  for(counter = start; counter < HowManyNumbers; ++counter) {
    if(numbers[counter] < numbers[indexOfSmallest]) {
      indexOfSmallest = counter;
    }
  }
  return indexOfSmallest;
}

canonical_original_code:
unsigned long minimum(unsigned long numbers[], unsigned long start, unsigned long HowManyNumbers) {
  unsigned long indexOfSmallest = start;
  unsigned long counter = 0;
  for(counter = start; counter < HowManyNumbers; ++counter) {
    if(numbers[counter] < numbers[indexOfSmallest]) {
      indexOfSmallest = counter;
    }
  }
  return indexOfSmallest;
}

variable_types:
start
unsigned long

variable_types:
indexOfSmallest
unsigned long


sort

original_code:
void sort(size_t numbers[], size_t HowManyNumbers) {
  size_t counter = 0;
  size_t temporary = 0;
  for(; counter < HowManyNumbers; ++counter) {
    size_t swapwith = minimum(numbers, counter, HowManyNumbers);
    temporary = numbers[swapwith];
    numbers[swapwith] = numbers[counter];
    numbers[counter] = temporary;
  }
}

canonical_original_code:
void sort(unsigned long numbers[], unsigned long HowManyNumbers) {
  unsigned long counter = 0;
  unsigned long temporary = 0;
  for(; counter < HowManyNumbers; ++counter) {
    unsigned long swapwith = minimum(numbers, counter, HowManyNumbers);
    temporary = numbers[swapwith];
    numbers[swapwith] = numbers[counter];
    numbers[counter] = temporary;
  }
}

variable_types:
temporary
unsigned long

variable_types:
swapwith
unsigned long


decompiled_code:
__int64 __fastcall satisfy_constraints(int a1, __int64 a2, _DWORD *a3)
{
__int64 result; // rax
int v5; // eax

if ( a1 != 4 )
{
fwrite("table requires three arguments: ", 1uLL, 0x20uLL, stderr);
fwrite("\"the starting bound\" \"the ending bound\" ", 1uLL, 0x28uLL, stderr);
fwrite("\"and the increment\"\n", 1uLL, 0x14uLL, stderr);
return 0LL;
}
if ( (unsigned int)__isoc99_sscanf() == -1
|| (unsigned int)__isoc99_sscanf() == -1
|| (unsigned int)__isoc99_sscanf() == -1 )
{
return 0LL;
}
v5 = a3[1];
if ( *a3 < v5 )
{
result = 1LL;
if ( (int)a3[2] <= 0 )
return 0LL;
}
else
{
if ( *a3 <= v5 )
return 0LL;
result = 1LL;
if ( (int)a3[2] >= 0 )
return 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(int a1, __int64 a2, _DWORD *a3)
{
__int64 result; // rax
int v5; // eax

if ( a1 != 4 )
{
fwrite("table requires three arguments: ", 1uLL, 0x20uLL, stderr);
fwrite("\"the starting bound\" \"the ending bound\" ", 1uLL, 0x28uLL, stderr);
fwrite("\"and the increment\"\n", 1uLL, 0x14uLL, stderr);
return 0LL;
}
if ( (unsigned int)__isoc99_sscanf() == -1
|| (unsigned int)__isoc99_sscanf() == -1
|| (unsigned int)__isoc99_sscanf() == -1 )
{
return 0LL;
}
v5 = a3[1];
if ( *a3 < v5 )
{
result = 1LL;
if ( (int)a3[2] <= 0 )
return 0LL;
}
else
{
if ( *a3 <= v5 )
return 0LL;
result = 1LL;
if ( (int)a3[2] >= 0 )
return 0LL;
}
return result;
}

original_code:
_Bool satisfy_constraints(int argcount, char *arguments[],
         struct bounds_struct *bounds) {
  _Bool return_value = 0;
  if(argcount == NUMBER_OF_ARGUMENTS) {
    if((sscanf(arguments[1], "%d", &bounds->starting) != (-1)) &&
       (sscanf(arguments[2], "%d", &bounds->ending) != (-1)) &&
       (sscanf(arguments[3], "%d", &bounds->increment) != (-1))) {
      if((((bounds->starting < bounds->ending) && (bounds->increment > 0))) ||
  ((bounds->starting > bounds->ending) && (bounds->increment < 0))) {
 return_value = 1;
      }
    }
  } else {
    fprintf(stderr, "table requires three arguments: ");
    fprintf(stderr, "\"the starting bound\" \"the ending bound\" ");
    fprintf(stderr, "\"and the increment\"\n");
  }
  return return_value;
}

variable_types: argcount int

variable_types:
arguments
char *[]

variable_types: struct bounds_struct { int starting; int ending; int increment; } *


decompiled_code:
int __fastcall table_generator(__int64 a1, int a2)
{
int v3; // ebx
int v4; // er13
double v5; // xmm0_8
double v6; // xmm0_8
__int64 v7; // rsi
double v8; // xmm0_8
double v9; // xmm0_8
__int64 v10; // rsi
double v12; // xmm0_8
double v13; // xmm0_8
double v14; // xmm0_8
double v15; // xmm0_8
char format[8]; // [rsp+11h] [rbp-57h] BYREF
char v17[16]; // [rsp+20h] [rbp-48h] BYREF
char v18[10]; // [rsp+30h] [rbp-38h] BYREF

v3 = a1;
v4 = -(int)a1;
strcpy(format, "%d & %.4f \\\\ \n");
*(__m128i *)v17 = _mm_load_si128((const __m128i *)&xmmword_4020C0);
strcpy(v18, "$ \\\\ \n");
puts("\\begin{tabular}{l|l}");
puts("Number & Square Root \\\\ \\hline");
if ( (int)a1 >= SHIDWORD(a1) )
{
do
{
if ( v3 >= 0 )
{
v12 = (double)v3;
if ( (double)v3 < 0.0 )
v13 = sqrt(v12);
else
v13 = sqrt(v12);
printf(format, (unsigned int)v3, v13);
}
else
{
v14 = (double)v4;
if ( (double)v4 < 0.0 )
v15 = sqrt(v14);
else
v15 = sqrt(v14);
printf(v17, (unsigned int)v3, v15);
}
v3 += a2;
v4 -= a2;
}
while ( v3 >= SHIDWORD(a1) );
}
else
{
do
{
while ( v3 < 0 )
{
v8 = (double)v4;
if ( (double)v4 < 0.0 )
v9 = sqrt(v8);
else
v9 = sqrt(v8);
v10 = (unsigned int)v3;
v3 += a2;
printf(v17, v10, v9);
v4 -= a2;
if ( v3 > SHIDWORD(a1) )
return puts("\\end{tabular}");
}
v5 = (double)v3;
if ( (double)v3 < 0.0 )
v6 = sqrt(v5);
else
v6 = sqrt(v5);
v7 = (unsigned int)v3;
v3 += a2;
printf(format, v7, v6);
v4 -= a2;
}
while ( v3 <= SHIDWORD(a1) );
}
return puts("\\end{tabular}");
}

canonical_decompiled_code:
int __fastcall func8(__int64 a1, int a2)
{
int v3; // ebx
int v4; // er13
double v5; // xmm0_8
double v6; // xmm0_8
__int64 v7; // rsi
double v8; // xmm0_8
double v9; // xmm0_8
__int64 v10; // rsi
double v12; // xmm0_8
double v13; // xmm0_8
double v14; // xmm0_8
double v15; // xmm0_8
char format[8]; // [rsp+11h] [rbp-57h] BYREF
char v17[16]; // [rsp+20h] [rbp-48h] BYREF
char v18[10]; // [rsp+30h] [rbp-38h] BYREF

v3 = a1;
v4 = -(int)a1;
strcpy(format, "%d & %.4f \\\\ \n");
*(__m128i *)v17 = _mm_load_si128((const __m128i *)&xmmword_4020C0);
strcpy(v18, "$ \\\\ \n");
puts("\\begin{tabular}{l|l}");
puts("Number & Square Root \\\\ \\hline");
if ( (int)a1 >= SHIDWORD(a1) )
{
do
{
if ( v3 >= 0 )
{
v12 = (double)v3;
if ( (double)v3 < 0.0 )
v13 = sqrt(v12);
else
v13 = sqrt(v12);
printf(format, (unsigned int)v3, v13);
}
else
{
v14 = (double)v4;
if ( (double)v4 < 0.0 )
v15 = sqrt(v14);
else
v15 = sqrt(v14);
printf(v17, (unsigned int)v3, v15);
}
v3 += a2;
v4 -= a2;
}
while ( v3 >= SHIDWORD(a1) );
}
else
{
do
{
while ( v3 < 0 )
{
v8 = (double)v4;
if ( (double)v4 < 0.0 )
v9 = sqrt(v8);
else
v9 = sqrt(v8);
v10 = (unsigned int)v3;
v3 += a2;
printf(v17, v10, v9);
v4 -= a2;
if ( v3 > SHIDWORD(a1) )
return puts("\\end{tabular}");
}
v5 = (double)v3;
if ( (double)v3 < 0.0 )
v6 = sqrt(v5);
else
v6 = sqrt(v5);
v7 = (unsigned int)v3;
v3 += a2;
printf(format, v7, v6);
v4 -= a2;
}
while ( v3 <= SHIDWORD(a1) );
}
return puts("\\end{tabular}");
}

original_code:
void table_generator(struct bounds_struct bounds) {
  int counter;
  double result;
  char normal_format_string[] = "%d & %.4f \\\\ \n";
  char imaginary_format_string[] = "%d & %.4f$\\imath$ \\\\ \n";
  printf("\\begin{tabular}{l|l}\n");
  printf("Number & Square Root \\\\ \\hline\n");
  if(bounds.starting < bounds.ending) {
    counter = bounds.starting;
    while(counter <= bounds.ending) {
      if(counter < 0) {
 result = sqrt(abs(counter));
 printf(imaginary_format_string, counter, result);
      } else {
 result = sqrt(counter);
 printf(normal_format_string, counter, result);
      }
      counter += bounds.increment;
    }
  } else {
    counter = bounds.starting;
    while(counter >= bounds.ending) {
      if(counter < 0) {
 result = sqrt(abs(counter));
 printf(imaginary_format_string, counter, result);
      } else {
 result = sqrt(counter);
 printf(normal_format_string, counter, result);
      }
      counter += bounds.increment;
    }
  }
  printf("\\end{tabular}\n");
}

variable_types: struct bounds_struct { int starting; int ending; int increment; }

variable_types: counter int

variable_types: result double


SolveLinear

decompiled_code:
int __fastcall SolveLinear(float a1, float a2)
{
if ( a1 != 0.0 )
return printf("%f\n", (float)((float)-a2 / a1));
if ( a2 == 0.0 )
return puts("Infinitely many solutions");
return puts("Pure absurdity");
}

canonical_decompiled_code:
int __fastcall func7(float a1, float a2)
{
if ( a1 != 0.0 )
return printf("%f\n", (float)((float)-a2 / a1));
if ( a2 == 0.0 )
return puts("Infinitely many solutions");
return puts("Pure absurdity");
}

original_code:
void SolveLinear(float b, float c) {
  if(b == 0.0) {
    if(c != 0.0) {
      printf("Pure absurdity\n");
    } else {
      printf("Infinitely many solutions\n");
    }
  } else {
    printf("%f\n", -c/b);
  }
}

variable_types: b float

variable_types: c float


SolveQuadratic

decompiled_code:
__int64 __fastcall SolveQuadratic(float a1, float a2, float a3)
{
__int64 result; // rax

if ( (float)((float)(a2 * a2) - (float)((float)(4.0 * a1) * a3)) < 0.0 )
result = SolveComplex();
else
result = SolveReal();
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(float a1, float a2, float a3)
{
__int64 result; // rax

if ( (float)((float)(a2 * a2) - (float)((float)(4.0 * a1) * a3)) < 0.0 )
result = func9();
else
result = func10();
return result;
}

original_code:
void SolveQuadratic(float a, float b, float c) {
  if((powf(b,2.0)-4*a*c) < 0) {
    SolveComplex(a, b, c);
  } else {
    SolveReal(a, b, c);
  }
}

variable_types: a float


SolveComplex

original_code:
void SolveComplex(float a, float b, float c) {
  printf("%f+%f*i and ", -b/(2*a), sqrtf(-1*(powf(b,2.0)-4*a*c))/(2*a));
  printf("%f-%f*i\n", -b/(2*a), sqrtf(-1*(powf(b,2.0)-4*a*c))/(2*a));
}


SolveReal

decompiled_code:
int __fastcall SolveReal(float a1, float a2, float a3)
{
float v3; // xmm4_4
float v4; // xmm3_4
float v5; // xmm1_4
float v6; // xmm4_4
float v8; // xmm0_4
float v9; // [rsp+0h] [rbp-18h]
float x; // [rsp+8h] [rbp-10h]

v3 = a1 + a1;
v4 = (float)-a2 / (float)(a1 + a1);
v5 = (float)(a2 * a2) - (float)((float)(a1 * 4.0) * a3);
if ( v5 < 0.0 )
{
v9 = a1 + a1;
v8 = sqrtf(v5) / v3;
printf("%f and ", (float)(v8 + v4));
v6 = v9;
if ( v5 >= 0.0 )
{
v5 = fsqrt(v5);
}
else
{
sqrtf(v5);
v6 = v9;
}
}
else
{
x = fsqrt(v5);
printf("%f and ", (float)((float)(x / v3) + v4));
v6 = a1 + a1;
v5 = x;
}
return printf("%f\n", (float)(v4 - (float)(v5 / v6)));
}

canonical_decompiled_code:
int __fastcall func10(float a1, float a2, float a3)
{
float v3; // xmm4_4
float v4; // xmm3_4
float v5; // xmm1_4
float v6; // xmm4_4
float v8; // xmm0_4
float v9; // [rsp+0h] [rbp-18h]
float x; // [rsp+8h] [rbp-10h]

v3 = a1 + a1;
v4 = (float)-a2 / (float)(a1 + a1);
v5 = (float)(a2 * a2) - (float)((float)(a1 * 4.0) * a3);
if ( v5 < 0.0 )
{
v9 = a1 + a1;
v8 = sqrtf(v5) / v3;
printf("%f and ", (float)(v8 + v4));
v6 = v9;
if ( v5 >= 0.0 )
{
v5 = fsqrt(v5);
}
else
{
sqrtf(v5);
v6 = v9;
}
}
else
{
x = fsqrt(v5);
printf("%f and ", (float)((float)(x / v3) + v4));
v6 = a1 + a1;
v5 = x;
}
return printf("%f\n", (float)(v4 - (float)(v5 / v6)));
}

original_code:
void SolveReal(float a, float b, float c) {
  printf("%f and ", -b/(2*a)+sqrtf(powf(b,2.0)-4*a*c)/(2*a));
  printf("%f\n", -b/(2*a)-sqrtf(powf(b,2.0)-4*a*c)/(2*a));
}


takeFromQueue

decompiled_code:
__int64 __fastcall takeFromQueue(unsigned int **a1)
{
unsigned int *v1; // r8
unsigned int *v2; // rax
unsigned int v3; // er12

v1 = *a1;
v2 = (unsigned int *)*((_QWORD *)*a1 + 1);
v3 = **a1;
*a1 = v2;
if ( !v2 )
a1[1] = 0LL;
free(v1);
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned int **a1)
{
unsigned int *v1; // r8
unsigned int *v2; // rax
unsigned int v3; // er12

v1 = *a1;
v2 = (unsigned int *)*((_QWORD *)*a1 + 1);
v3 = **a1;
*a1 = v2;
if ( !v2 )
a1[1] = 0LL;
free(v1);
return v3;
}

original_code:
int takeFromQueue(queue aQueue) {
  int data;
  queueNode temp = aQueue->first;
  data = aQueue->first->data;
  aQueue->first = aQueue->first->next;
  if(aQueue->first == ((void *)0)) {
    aQueue->last = ((void *)0);
  }
  free(temp);
  return data;
}

canonical_original_code:
int takeFromQueue(struct queueStruct *aQueue) {
  int data;
  struct aNode *temp = aQueue->first;
  data = aQueue->first->data;
  aQueue->first = aQueue->first->next;
  if(aQueue->first == ((void *)0)) {
    aQueue->last = ((void *)0);
  }
  free(temp);
  return data;
}

variable_types: struct queueStruct { struct aNode { int data; struct aNode *next; } *first; struct aNode *last; } *

variable_types: data int

user_defined_types: struct queueStruct { struct aNode *first; struct aNode *last; }


isQueueEmpty

decompiled_code:
bool __fastcall isQueueEmpty(_QWORD *a1)
{
bool result; // al

result = 0;
if ( !a1[1] )
result = *a1 == 0LL;
return result;
}

canonical_decompiled_code:
bool __fastcall func8(_QWORD *a1)
{
bool result; // al

result = 0;
if ( !a1[1] )
result = *a1 == 0LL;
return result;
}

original_code:
_Bool isQueueEmpty(queue aQueue) {
  _Bool result = 0;
  if(aQueue->last == ((void *)0) && aQueue->first == ((void *)0)) {
    result = 1;
  }
  return result;
 }

canonical_original_code:
_Bool isQueueEmpty(struct queueStruct *aQueue) {
  _Bool result = 0;
  if(aQueue->last == ((void *)0) && aQueue->first == ((void *)0)) {
    result = 1;
  }
  return result;
 }


isQueueFull

decompiled_code:
bool isQueueFull()
{
void *v0; // rbx

v0 = malloc(0x10uLL);
free(v0);
return v0 == 0LL;
}

original_code:
_Bool isQueueFull(queue aQueue) {
  _Bool result = 0;
  queueNode temp = (queueNode) malloc(sizeof(struct aNode));
  if(temp == ((void *)0)) {
    result = 1;
  }
  free(temp);
  return result;
}

canonical_original_code:
_Bool isQueueFull(struct queueStruct *aQueue) {
  _Bool result = 0;
  struct aNode *temp = (queueNode) malloc(sizeof(struct aNode));
  if(temp == ((void *)0)) {
    result = 1;
  }
  free(temp);
  return result;
}

variable_types: struct aNode { int data; struct aNode *next; } *


printQueue

decompiled_code:
int __fastcall printQueue(unsigned int **a1)
{
unsigned int *i; // rbx
int result; // eax

for ( i = *a1; i; i = (unsigned int *)*((_QWORD *)i + 1) )
result = printf("Node: %p\nData: %i\n", i, *i);
return result;
}

canonical_decompiled_code:
int __fastcall func11(unsigned int **a1)
{
unsigned int *i; // rbx
int result; // eax

for ( i = *a1; i; i = (unsigned int *)*((_QWORD *)i + 1) )
result = printf("Node: %p\nData: %i\n", i, *i);
return result;
}

original_code:
void printQueue(queue aQueue) {
  queueNode current = aQueue->first;
  while(current != ((void *)0)) {
    printf("Node: %p\nData: %i\n", (void*) current,
    current->data);
    current = current->next;
  }
}

canonical_original_code:
void printQueue(struct queueStruct *aQueue) {
  struct aNode *current = aQueue->first;
  while(current != ((void *)0)) {
    printf("Node: %p\nData: %i\n", (void *) current,
    current->data);
    current = current->next;
  }
}


emptyQueue

decompiled_code:
bool __fastcall emptyQueue(unsigned int **a1)
{
bool result; // al

while ( 1 )
{
result = isQueueEmpty(a1);
if ( result )
break;
takeFromQueue(a1);
}
return result;
}

canonical_decompiled_code:
bool __fastcall func12(unsigned int **a1)
{
bool result; // al

while ( 1 )
{
result = func8(a1);
if ( result )
break;
func7(a1);
}
return result;
}

original_code:
void emptyQueue(queue aQueue) {
  while(!isQueueEmpty(aQueue)) {
    takeFromQueue(aQueue);
  }
}

canonical_original_code:
void emptyQueue(struct queueStruct *aQueue) {
  while(!isQueueEmpty(aQueue)) {
    takeFromQueue(aQueue);
  }
}


wci

decompiled_code:
float __fastcall wci(int a1, int a2)
{
float result; // xmm0_4

if ( a2 > 3 && a1 <= 49 )
result = (0.4275 * (double)a1 - 35.75) * powf((float)a2, 0.16) + (double)a1 * 0.6215000000000001 + 35.74;
else
result = (float)a1;
return result;
}

canonical_decompiled_code:
float __fastcall func7(int a1, int a2)
{
float result; // xmm0_4

if ( a2 > 3 && a1 <= 49 )
result = (0.4275 * (double)a1 - 35.75) * powf((float)a2, 0.16) + (double)a1 * 0.6215000000000001 + 35.74;
else
result = (float)a1;
return result;
}

original_code:
float wci(int temperature, int wind_speed) {
 float result;
 if(wind_speed <= 3 || temperature >= 50) {
  result = temperature;
 } else {
 result = 35.74 + 0.6215*temperature + (0.4275*temperature - 35.75) *
  powf(wind_speed,0.16);
 }
 return result;
}

variable_types: temperature int

variable_types: result float

return_type: float


GetArrayMinMax

repo: rreusser/octree-gravity

decompiled_code:
void __fastcall GetArrayMinMax(double *a1, int a2, double *a3, double *a4)
{
double *v6; // rbx
double v7; // xmm0_8

v6 = a1;
*(_QWORD *)a3 = COERCE_UNSIGNED_INT64(log(0.0)) ^ LC4;
*a4 = log(0.0);
if ( a2 > 0 )
{
do
{
v7 = *v6++;
*a3 = fmin(v7, *a3);
*a4 = fmax(*(v6 - 1), *a4);
}
while ( v6 != &a1[(unsigned int)(a2 - 1) + 1] );
}
}

canonical_decompiled_code:
void __fastcall func1(double *a1, int a2, double *a3, double *a4)
{
double *v6; // rbx
double v7; // xmm0_8

v6 = a1;
*(_QWORD *)a3 = COERCE_UNSIGNED_INT64(log(0.0)) ^ LC4;
*a4 = log(0.0);
if ( a2 > 0 )
{
do
{
v7 = *v6++;
*a3 = fmin(v7, *a3);
*a4 = fmax(*(v6 - 1), *a4);
}
while ( v6 != &a1[(unsigned int)(a2 - 1) + 1] );
}
}

original_code:
void GetArrayMinMax( real* a, const int n, real* min, real* max) {
    int i;
    *min = -log(0);
    *max = log(0);
    for(i=0;i<n;i++) {
 *min = fmin(a[i],*min);
 *max = fmax(a[i],*max);
    }
}

canonical_original_code:
void GetArrayMinMax(double *a, int n, double *min, double *max) {
    int i;
    *min = -log(0);
    *max = log(0);
    for(i=0;i<n;i++) {
 *min = fmin(a[i],*min);
 *max = fmax(a[i],*max);
    }
}

variable_types:
a
double *

variable_types: n int

variable_types:
min
double *

variable_types:
max
double *

variable_types: i int


GetIntArrayMinMax

decompiled_code:
__int64 __fastcall GetIntArrayMinMax(unsigned int *a1, int a2, int *a3, _DWORD *a4)
{
__int64 result; // rax
__int64 v7; // rdx
int v8; // eax

*a3 = (int)COERCE_DOUBLE(COERCE_UNSIGNED_INT64(log(0.0)) ^ LC4);
result = (unsigned int)(int)log(0.0);
*a4 = result;
if ( a2 > 0 )
{
v7 = (__int64)&a1[a2 - 1 + 1];
do
{
v8 = *a1;
if ( *a3 <= (int)*a1 )
v8 = *a3;
*a3 = v8;
result = (unsigned int)*a4;
if ( (int)*a1 >= (int)result )
result = *a1;
++a1;
*a4 = result;
}
while ( a1 != (unsigned int *)v7 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(unsigned int *a1, int a2, int *a3, _DWORD *a4)
{
__int64 result; // rax
__int64 v7; // rdx
int v8; // eax

*a3 = (int)COERCE_DOUBLE(COERCE_UNSIGNED_INT64(log(0.0)) ^ LC4);
result = (unsigned int)(int)log(0.0);
*a4 = result;
if ( a2 > 0 )
{
v7 = (__int64)&a1[a2 - 1 + 1];
do
{
v8 = *a1;
if ( *a3 <= (int)*a1 )
v8 = *a3;
*a3 = v8;
result = (unsigned int)*a4;
if ( (int)*a1 >= (int)result )
result = *a1;
++a1;
*a4 = result;
}
while ( a1 != (unsigned int *)v7 );
}
return result;
}

original_code:
void GetIntArrayMinMax( int* a, const int n, int* min, int* max) {
    int i;
    *min = -log(0);
    *max = log(0);
    for(i=0;i<n;i++) {
 *min = ((a[i])<(*min)?(a[i]):(*min));
 *max = ((a[i])<(*max)?(*max):(a[i]));
    }
}

canonical_original_code:
void GetIntArrayMinMax(int *a, int n, int *min, int *max) {
    int i;
    *min = -log(0);
    *max = log(0);
    for(i=0;i<n;i++) {
 *min = ((a[i])<(*min)?(a[i]):(*min));
 *max = ((a[i])<(*max)?(*max):(a[i]));
    }
}

variable_types:
a
int *

variable_types:
min
int *

variable_types:
max
int *


dbgp

decompiled_code:
int __fastcall dbgp(const char *a1, __int64 a2)
{
return fprintf(stderr, "%s = 0x%x\n", a1, a2);
}

canonical_decompiled_code:
int __fastcall func3(const char *a1, __int64 a2)
{
return fprintf(stderr, "%s = 0x%x\n", a1, a2);
}

original_code:
void dbgp( const char* s, void* ptr ) {
    fprintf(stderr,"%s = 0x%x\n",s,(unsigned int)ptr);
}

canonical_original_code:
void dbgp(char *s, void *ptr) {
    fprintf(stderr,"%s = 0x%x\n",s,(unsigned int)ptr);
}

variable_types:
s
char *

variable_types:
ptr
void *


decompiled_code:
char *__fastcall create_filename(char *s, __int64 a2, unsigned int a3, unsigned int a4, __int64 a5)
{
char *result; // rax
char sa[50]; // [rsp+6h] [rbp-32h] BYREF

sprintf(sa, "%%s%%%ii%%s", a4);
sprintf(s, sa, a2, a3, a5);
result = (char *)strlen(s);
if ( (int)result > 0 )
{
result = &s[(_DWORD)result - 1 + 1];
do
{
if ( *s == 32 )
*s = 48;
++s;
}
while ( s != result );
}
return result;
}

canonical_decompiled_code:
char *__fastcall func4(char *s, __int64 a2, unsigned int a3, unsigned int a4, __int64 a5)
{
char *result; // rax
char sa[50]; // [rsp+6h] [rbp-32h] BYREF

sprintf(sa, "%%s%%%ii%%s", a4);
sprintf(s, sa, a2, a3, a5);
result = (char *)strlen(s);
if ( (int)result > 0 )
{
result = &s[(_DWORD)result - 1 + 1];
do
{
if ( *s == 32 )
*s = 48;
++s;
}
while ( s != result );
}
return result;
}

original_code:
void create_filename(char* dest, const char* prefix, int i, int digits, const char* suffix ) {
    char fmt[10];
    int l;
    sprintf(fmt,"%%s%%%ii%%s",digits);
    sprintf(dest,fmt,prefix,i,suffix);
    l=strlen(dest);
    for(i=0;i<l;i++) {
 if(dest[i]==' ') {
     dest[i]='0';
 }
    }
}

canonical_original_code:
void create_filename(char *dest, char *prefix, int i, int digits, char *suffix) {
    char fmt[10];
    int l;
    sprintf(fmt,"%%s%%%ii%%s",digits);
    sprintf(dest,fmt,prefix,i,suffix);
    l=strlen(dest);
    for(i=0;i<l;i++) {
 if(dest[i]==' ') {
     dest[i]='0';
 }
    }
}

variable_types:
dest
char *

variable_types:
prefix
char *

variable_types: digits int

variable_types:
suffix
char *

variable_types:
fmt
char [10]

variable_types: l int


vfAdd

decompiled_code:
float *__fastcall vfAdd(float *a1, float *a2, float *a3)
{
float *result; // rax

result = a1;
*a1 = *a2 + *a3;
a1[1] = a2[1] + a3[1];
a1[2] = a2[2] + a3[2];
return result;
}

canonical_decompiled_code:
float *__fastcall func1(float *a1, float *a2, float *a3)
{
float *result; // rax

result = a1;
*a1 = *a2 + *a3;
a1[1] = a2[1] + a3[1];
a1[2] = a2[2] + a3[2];
return result;
}

original_code:
vector3f* vfAdd(vector3f* A, vector3f* B, vector3f* C) {
    A->x = B->x+C->x;
    A->y = B->y+C->y;
    A->z = B->z+C->z;
    return A;
}

canonical_original_code:
struct vector3f *vfAdd(struct vector3f *A, struct vector3f *B, struct vector3f *C) {
    A->x = B->x+C->x;
    A->y = B->y+C->y;
    A->z = B->z+C->z;
    return A;
}

variable_types:
A
struct vector3f *

variable_types:
B
struct vector3f *

variable_types:
C
struct vector3f *

return_type: struct vector3f { float x; } *


vfPlusEq

decompiled_code:
float *__fastcall vfPlusEq(float *a1, float *a2)
{
float *result; // rax

result = a1;
*a1 = *a1 + *a2;
a1[1] = a1[1] + a2[1];
a1[2] = a1[2] + a2[2];
return result;
}

canonical_decompiled_code:
float *__fastcall func2(float *a1, float *a2)
{
float *result; // rax

result = a1;
*a1 = *a1 + *a2;
a1[1] = a1[1] + a2[1];
a1[2] = a1[2] + a2[2];
return result;
}

original_code:
vector3f* vfPlusEq(vector3f* A, vector3f* B) {
    A->x += B->x;
    A->y += B->y;
    A->z += B->z;
    return A;
}

canonical_original_code:
struct vector3f *vfPlusEq(struct vector3f *A, struct vector3f *B) {
    A->x += B->x;
    A->y += B->y;
    A->z += B->z;
    return A;
}


vfSub

decompiled_code:
float *__fastcall vfSub(float *a1, float *a2, float *a3)
{
float *result; // rax

result = a1;
*a1 = *a2 - *a3;
a1[1] = a2[1] - a3[1];
a1[2] = a2[2] - a3[2];
return result;
}

canonical_decompiled_code:
float *__fastcall func3(float *a1, float *a2, float *a3)
{
float *result; // rax

result = a1;
*a1 = *a2 - *a3;
a1[1] = a2[1] - a3[1];
a1[2] = a2[2] - a3[2];
return result;
}

original_code:
vector3f* vfSub(vector3f* A, vector3f* B, vector3f* C) {
    A->x = B->x-C->x;
    A->y = B->y-C->y;
    A->z = B->z-C->z;
    return A;
}

canonical_original_code:
struct vector3f *vfSub(struct vector3f *A, struct vector3f *B, struct vector3f *C) {
    A->x = B->x-C->x;
    A->y = B->y-C->y;
    A->z = B->z-C->z;
    return A;
}


vfMinusEq

decompiled_code:
float *__fastcall vfMinusEq(float *a1, float *a2)
{
float *result; // rax

result = a1;
*a1 = *a1 - *a2;
a1[1] = a1[1] - a2[1];
a1[2] = a1[2] - a2[2];
return result;
}

canonical_decompiled_code:
float *__fastcall func4(float *a1, float *a2)
{
float *result; // rax

result = a1;
*a1 = *a1 - *a2;
a1[1] = a1[1] - a2[1];
a1[2] = a1[2] - a2[2];
return result;
}

original_code:
vector3f* vfMinusEq(vector3f* A, vector3f* B) {
    A->x -= B->x;
    A->y -= B->y;
    A->z -= B->z;
    return A;
}

canonical_original_code:
struct vector3f *vfMinusEq(struct vector3f *A, struct vector3f *B) {
    A->x -= B->x;
    A->y -= B->y;
    A->z -= B->z;
    return A;
}


vfMult

decompiled_code:
float *__fastcall vfMult(float *a1, float *a2, float *a3)
{
float *result; // rax

result = a1;
*a1 = *a2 * *a3;
a1[1] = a2[1] * a3[1];
a1[2] = a2[2] * a3[2];
return result;
}

canonical_decompiled_code:
float *__fastcall func5(float *a1, float *a2, float *a3)
{
float *result; // rax

result = a1;
*a1 = *a2 * *a3;
a1[1] = a2[1] * a3[1];
a1[2] = a2[2] * a3[2];
return result;
}

original_code:
vector3f* vfMult(vector3f* A, vector3f* B, vector3f* C) {
    A->x = B->x*C->x;
    A->y = B->y*C->y;
    A->z = B->z*C->z;
    return A;
}

canonical_original_code:
struct vector3f *vfMult(struct vector3f *A, struct vector3f *B, struct vector3f *C) {
    A->x = B->x*C->x;
    A->y = B->y*C->y;
    A->z = B->z*C->z;
    return A;
}


vfTimesEq

decompiled_code:
float *__fastcall vfTimesEq(float *a1, float *a2)
{
float *result; // rax

result = a1;
*a1 = *a1 * *a2;
a1[1] = a1[1] * a2[1];
a1[2] = a1[2] * a2[2];
return result;
}

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

result = a1;
*a1 = *a1 * *a2;
a1[1] = a1[1] * a2[1];
a1[2] = a1[2] * a2[2];
return result;
}

original_code:
vector3f* vfTimesEq(vector3f* A, vector3f* B) {
    A->x *= B->x;
    A->y *= B->y;
    A->z *= B->z;
    return A;
}

canonical_original_code:
struct vector3f *vfTimesEq(struct vector3f *A, struct vector3f *B) {
    A->x *= B->x;
    A->y *= B->y;
    A->z *= B->z;
    return A;
}


vffMult

decompiled_code:
float *__fastcall vffMult(float *a1, float *a2, float a3)
{
float *result; // rax
float v4; // xmm1_4
float v5; // xmm0_4

result = a1;
*a1 = *a2 * a3;
v4 = a2[1] * a3;
v5 = a3 * a2[2];
a1[1] = v4;
a1[2] = v5;
return result;
}

canonical_decompiled_code:
float *__fastcall func7(float *a1, float *a2, float a3)
{
float *result; // rax
float v4; // xmm1_4
float v5; // xmm0_4

result = a1;
*a1 = *a2 * a3;
v4 = a2[1] * a3;
v5 = a3 * a2[2];
a1[1] = v4;
a1[2] = v5;
return result;
}

original_code:
vector3f* vffMult(vector3f* A, vector3f* B, float mult) {
    A->x = B->x * mult;
    A->y = B->y * mult;
    A->z = B->z * mult;
    return A;
}

canonical_original_code:
struct vector3f *vffMult(struct vector3f *A, struct vector3f *B, float mult) {
    A->x = B->x * mult;
    A->y = B->y * mult;
    A->z = B->z * mult;
    return A;
}

variable_types: mult float


vffTimesEq

decompiled_code:
float *__fastcall vffTimesEq(float *a1, float a2)
{
float *result; // rax
float v3; // xmm1_4
float v4; // xmm0_4

result = a1;
*a1 = *a1 * a2;
v3 = a1[1] * a2;
v4 = a2 * a1[2];
a1[1] = v3;
a1[2] = v4;
return result;
}

canonical_decompiled_code:
float *__fastcall func8(float *a1, float a2)
{
float *result; // rax
float v3; // xmm1_4
float v4; // xmm0_4

result = a1;
*a1 = *a1 * a2;
v3 = a1[1] * a2;
v4 = a2 * a1[2];
a1[1] = v3;
a1[2] = v4;
return result;
}

original_code:
vector3f* vffTimesEq(vector3f* A, float mult) {
    A->x *= mult;
    A->y *= mult;
    A->z *= mult;
    return A;
}

canonical_original_code:
struct vector3f *vffTimesEq(struct vector3f *A, float mult) {
    A->x *= mult;
    A->y *= mult;
    A->z *= mult;
    return A;
}


vfDiv

decompiled_code:
float *__fastcall vfDiv(float *a1, float *a2)
{
float *result; // rax

result = a1;
*a1 = *a1 / *a2;
a1[1] = a1[1] / a2[1];
a1[2] = a1[2] / a2[2];
return result;
}

canonical_decompiled_code:
float *__fastcall func9(float *a1, float *a2)
{
float *result; // rax

result = a1;
*a1 = *a1 / *a2;
a1[1] = a1[1] / a2[1];
a1[2] = a1[2] / a2[2];
return result;
}

original_code:
vector3f* vfDiv(vector3f* A, vector3f* B, vector3f* C) {
    A->x = A->x/B->x;
    A->y = A->y/B->y;
    A->z = A->z/B->z;
    return A;
}

canonical_original_code:
struct vector3f *vfDiv(struct vector3f *A, struct vector3f *B, struct vector3f *C) {
    A->x = A->x/B->x;
    A->y = A->y/B->y;
    A->z = A->z/B->z;
    return A;
}


vfDivEq

decompiled_code:
float *__fastcall vfDivEq(float *a1, float *a2)
{
float *result; // rax

result = a1;
*a1 = *a1 / *a2;
a1[1] = a1[1] / a2[1];
a1[2] = a1[2] / a2[2];
return result;
}

canonical_decompiled_code:
float *__fastcall func10(float *a1, float *a2)
{
float *result; // rax

result = a1;
*a1 = *a1 / *a2;
a1[1] = a1[1] / a2[1];
a1[2] = a1[2] / a2[2];
return result;
}

original_code:
vector3f* vfDivEq(vector3f* A, vector3f* B) {
    A->x /= B->x;
    A->y /= B->y;
    A->z /= B->z;
    return A;
}

canonical_original_code:
struct vector3f *vfDivEq(struct vector3f *A, struct vector3f *B) {
    A->x /= B->x;
    A->y /= B->y;
    A->z /= B->z;
    return A;
}


vffDiv

decompiled_code:
float *__fastcall vffDiv(float *a1, float *a2, float a3)
{
float *result; // rax

result = a1;
*a1 = *a2 / a3;
a1[1] = a2[1] / a3;
a1[2] = a2[2] / a3;
return result;
}

canonical_decompiled_code:
float *__fastcall func11(float *a1, float *a2, float a3)
{
float *result; // rax

result = a1;
*a1 = *a2 / a3;
a1[1] = a2[1] / a3;
a1[2] = a2[2] / a3;
return result;
}

original_code:
vector3f* vffDiv(vector3f* A, vector3f* B, float div) {
    A->x = B->x / div;
    A->y = B->y / div;
    A->z = B->z / div;
    return A;
}

canonical_original_code:
struct vector3f *vffDiv(struct vector3f *A, struct vector3f *B, float div) {
    A->x = B->x / div;
    A->y = B->y / div;
    A->z = B->z / div;
    return A;
}

variable_types: div float


vffDivEq

decompiled_code:
float *__fastcall vffDivEq(float *a1, float a2)
{
float *result; // rax

result = a1;
*a1 = *a1 / a2;
a1[1] = a1[1] / a2;
a1[2] = a1[2] / a2;
return result;
}

canonical_decompiled_code:
float *__fastcall func12(float *a1, float a2)
{
float *result; // rax

result = a1;
*a1 = *a1 / a2;
a1[1] = a1[1] / a2;
a1[2] = a1[2] / a2;
return result;
}

original_code:
vector3f* vffDivEq(vector3f* A, float div) {
    A->x /= div;
    A->y /= div;
    A->z /= div;
    return A;
}

canonical_original_code:
struct vector3f *vffDivEq(struct vector3f *A, float div) {
    A->x /= div;
    A->y /= div;
    A->z /= div;
    return A;
}


vfDot

decompiled_code:
float __fastcall vfDot(float *a1, float *a2)
{
return (float)(a1[2] * a2[2]) + (float)((float)(*a1 * *a2) + (float)(a1[1] * a2[1]));
}

canonical_decompiled_code:
float __fastcall func13(float *a1, float *a2)
{
return (float)(a1[2] * a2[2]) + (float)((float)(*a1 * *a2) + (float)(a1[1] * a2[1]));
}

original_code:
float vfDot(vector3f* A, vector3f* B) {
    float sum;
    sum=A->x*B->x;
    sum+=A->y*B->y;
    sum+=A->z*B->z;
    return sum;
}

canonical_original_code:
float vfDot(struct vector3f *A, struct vector3f *B) {
    float sum;
    sum=A->x*B->x;
    sum+=A->y*B->y;
    sum+=A->z*B->z;
    return sum;
}

variable_types:
A
struct vector3f { float x; } *

variable_types: sum float


vfLength

decompiled_code:
void __fastcall vfLength(float *a1)
{
float v1; // xmm0_4

v1 = (float)((float)(a1[1] * a1[1]) + (float)(*a1 * *a1)) + (float)(a1[2] * a1[2]);
if ( v1 < 0.0 )
sqrtf(v1);
}

original_code:
float vfLength(vector3f* A) {
    float len = sqrt(A->x*A->x+A->y*A->y+A->z*A->z);
    return len;
}

canonical_original_code:
float vfLength(struct vector3f *A) {
    float len = sqrt(A->x*A->x+A->y*A->y+A->z*A->z);
    return len;
}

variable_types: len float


vfNormalize

decompiled_code:
float *__fastcall vfNormalize(float *a1, float a2)
{
float *result; // rax

vfLength(a1);
result = a1;
*a1 = *a1 / a2;
a1[1] = a1[1] / a2;
a1[2] = a1[2] / a2;
return result;
}

canonical_decompiled_code:
float *__fastcall func15(float *a1, float a2)
{
float *result; // rax

func14(a1);
result = a1;
*a1 = *a1 / a2;
a1[1] = a1[1] / a2;
a1[2] = a1[2] / a2;
return result;
}

original_code:
vector3f* vfNormalize(vector3f* A) {
    float len = vfLength(A);
    A->x /= len;
    A->y /= len;
    A->z /= len;
    return A;
}

canonical_original_code:
struct vector3f *vfNormalize(struct vector3f *A) {
    float len = vfLength(A);
    A->x /= len;
    A->y /= len;
    A->z /= len;
    return A;
}


vfCross

decompiled_code:
float *__fastcall vfCross(float *a1, float *a2, float *a3)
{
float v3; // xmm3_4
float v4; // xmm1_4
float *result; // rax
float v6; // xmm2_4
float v7; // xmm0_4

v3 = a3[2];
v4 = a2[2];
result = a1;
*a1 = (float)(a2[1] * v3) - (float)(a3[1] * v4);
v6 = *a3;
v7 = *a2;
a1[1] = (float)(v4 * *a3) - (float)(v3 * *a2);
a1[2] = (float)(v7 * a3[1]) - (float)(v6 * a2[1]);
return result;
}

canonical_decompiled_code:
float *__fastcall func16(float *a1, float *a2, float *a3)
{
float v3; // xmm3_4
float v4; // xmm1_4
float *result; // rax
float v6; // xmm2_4
float v7; // xmm0_4

v3 = a3[2];
v4 = a2[2];
result = a1;
*a1 = (float)(a2[1] * v3) - (float)(a3[1] * v4);
v6 = *a3;
v7 = *a2;
a1[1] = (float)(v4 * *a3) - (float)(v3 * *a2);
a1[2] = (float)(v7 * a3[1]) - (float)(v6 * a2[1]);
return result;
}

original_code:
vector3f* vfCross(vector3f* A, vector3f* B, vector3f* C) {
    A->x = B->y*C->z - B->z*C->y;
    A->y = B->z*C->x - B->x*C->z;
    A->z = B->x*C->y - B->y*C->x;
    return A;
}

canonical_original_code:
struct vector3f *vfCross(struct vector3f *A, struct vector3f *B, struct vector3f *C) {
    A->x = B->y*C->z - B->z*C->y;
    A->y = B->z*C->x - B->x*C->z;
    A->z = B->x*C->y - B->y*C->x;
    return A;
}


vfAxisRotate

original_code:
vector3f* vfAxisRotate(vector3f* target, vector3f* origin, vector3f* axis, double theta) {
    double x = target->x;
    double y = target->y;
    double z = target->z;
    double a = origin->x;
    double b = origin->y;
    double c = origin->z;
    double u = axis->x;
    double v = axis->y;
    double w = axis->z;
    target->x = (a*(v*v+w*w)+u*(-b*v-c*w+u*x+v*y+w*z)+
 ((x-a)*(v*v+w*w)+u*(b*v+c*w-v*y-w*z))*cos(theta)+
 sqrt(u*u+v*v+w*w)*(b*w-c*v-w*y+v*z)*sin(theta))/
 (u*u+v*v+w*w);
    target->y = (b*(u*u+w*w)+v*(-a*u-c*w+u*x+v*y+w*z)+
 ((y-b)*(u*u+w*w)+v*(a*u+c*w-u*x-w*z))*cos(theta)+
 sqrt(u*u+v*v+w*w)*(-a*w+c*u+w*x-u*z)*sin(theta))/
 (u*u+v*v+w*w);
    target->z = (c*(u*u+v*v)+w*(-a*u-b*v+u*x+v*y+w*z)+
 ((z-c)*(u*u+v*v)+w*(a*u+b*v-u*x-v*y))*cos(theta)+
 sqrt(u*u+v*v+w*w)*(a*v-b*u-v*x+u*y)*sin(theta))/
 (u*u+v*v+w*w);
    return target;
}

canonical_original_code:
struct vector3f *vfAxisRotate(struct vector3f *target, struct vector3f *origin, struct vector3f *axis, double theta) {
    double x = target->x;
    double y = target->y;
    double z = target->z;
    double a = origin->x;
    double b = origin->y;
    double c = origin->z;
    double u = axis->x;
    double v = axis->y;
    double w = axis->z;
    target->x = (a*(v*v+w*w)+u*(-b*v-c*w+u*x+v*y+w*z)+
 ((x-a)*(v*v+w*w)+u*(b*v+c*w-v*y-w*z))*cos(theta)+
 sqrt(u*u+v*v+w*w)*(b*w-c*v-w*y+v*z)*sin(theta))/
 (u*u+v*v+w*w);
    target->y = (b*(u*u+w*w)+v*(-a*u-c*w+u*x+v*y+w*z)+
 ((y-b)*(u*u+w*w)+v*(a*u+c*w-u*x-w*z))*cos(theta)+
 sqrt(u*u+v*v+w*w)*(-a*w+c*u+w*x-u*z)*sin(theta))/
 (u*u+v*v+w*w);
    target->z = (c*(u*u+v*v)+w*(-a*u-b*v+u*x+v*y+w*z)+
 ((z-c)*(u*u+v*v)+w*(a*u+b*v-u*x-v*y))*cos(theta)+
 sqrt(u*u+v*v+w*w)*(a*v-b*u-v*x+u*y)*sin(theta))/
 (u*u+v*v+w*w);
    return target;
}

variable_types:
target
struct vector3f *

variable_types:
origin
struct vector3f *

variable_types:
axis
struct vector3f *

variable_types: theta double

variable_types: x double

variable_types: y double

variable_types: z double

variable_types: a double

variable_types: b double

variable_types: c double

variable_types: u double

variable_types: v double

variable_types: w double