original_code:
_Bool hash_remove(hash_table* ht, const void* key,
                 void** removed_key_ptr, void** removed_value_ptr) {
  uint64_t idx = ht->hasher(key);
  while (ht->buckets[idx % ht->num_buckets]) {
    hash_entry *cur = ht->buckets[idx % ht->num_buckets];
    if (!ht->hc(cur->key, key)) {
      *removed_key_ptr = cur->key;
      *removed_value_ptr = cur->value;
      free(cur);
      ht->buckets[idx % ht->num_buckets] = ((void *)0);
      ht->num_elements--;
      idx++;
      void *dummykey, *dummyval;
      while (ht->buckets[idx % ht->num_buckets]) {
        ht->num_elements--;
        cur = ht->buckets[idx % ht->num_buckets];
        ht->buckets[idx % ht->num_buckets] = ((void *)0);
        hash_insert(ht, cur->key, cur->value, &dummykey, &dummyval);
        free(cur);
        idx++;
      }
      return 1;
    }
    idx++;
  }
  return 0;
}

canonical_original_code:
_Bool hash_remove(struct _hash_table *ht, void *key, void **removed_key_ptr, void **removed_value_ptr) {
  unsigned long idx = ht->hasher(key);
  while (ht->buckets[idx % ht->num_buckets]) {
    struct _hash_entry *cur = ht->buckets[idx % ht->num_buckets];
    if (!ht->hc(cur->key, key)) {
      *removed_key_ptr = cur->key;
      *removed_value_ptr = cur->value;
      free(cur);
      ht->buckets[idx % ht->num_buckets] = ((void *)0);
      ht->num_elements--;
      idx++;
      void *dummykey; void *dummyval;
      while (ht->buckets[idx % ht->num_buckets]) {
        ht->num_elements--;
        cur = ht->buckets[idx % ht->num_buckets];
        ht->buckets[idx % ht->num_buckets] = ((void *)0);
        hash_insert(ht, cur->key, cur->value, &dummykey, &dummyval);
        free(cur);
        idx++;
      }
      return 1;
    }
    idx++;
  }
  return 0;
}


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

result = 0xFFFFFFFFLL;
if ( *a1 >= *a2 )
result = *a1 != *a2;
return result;
}

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

result = 0xFFFFFFFFLL;
if ( *a1 >= *a2 )
result = *a1 != *a2;
return result;
}

original_code:
int compare_two(queue_element* e1, queue_element* e2) {
  int x = *(int*) e1;
  int y = *(int*) e2;
  if (x < y)
    return -1;
  else if (x == y)
    return 0;
  else
    return 1;
}

canonical_original_code:
int compare_two(void *e1, void *e2) {
  int x = *(int*) e1;
  int y = *(int*) e2;
  if (x < y)
    return -1;
  else if (x == y)
    return 0;
  else
    return 1;
}

variable_types: x int

variable_types: y int

return_type: int


decompiled_code:
__int64 __fastcall show_one(unsigned int *a1, unsigned int *a2)
{
printf("Item %d == %d\n", *a2, *a1);
++*a2;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned int *a1, unsigned int *a2)
{
printf("Item %d == %d\n", *a2, *a1);
++*a2;
return 1LL;
}

original_code:
_Bool show_one(queue_element* elem, queue_function_args* args) {
  printf("Item %d == %d\n", *(int*) args, *(int*) elem);
  *(int*) args = *(int*) args + 1;
  return 1;
}

canonical_original_code:
_Bool show_one(void *elem, void *args) {
  printf("Item %d == %d\n", *(int *) args, *(int *) elem);
  *(int *) args = *(int *) args + 1;
  return 1;
}

variable_types:
elem
void *

variable_types:
args
void *


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
void *v3; // rbx
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
_BYTE v10[12]; // [rsp+0h] [rbp-28h] BYREF
int v11; // [rsp+Ch] [rbp-1Ch] BYREF
int v12; // [rsp+10h] [rbp-18h] BYREF
int v13; // [rsp+14h] [rbp-14h] BYREF
int v14; // [rsp+18h] [rbp-10h] BYREF
int v15[3]; // [rsp+1Ch] [rbp-Ch] BYREF

v3 = (void *)queue_create(argc, argv, envp);
v15[0] = 4;
v14 = 3;
v13 = 4;
v12 = 3;
queue_append(v3, v15);
queue_append(v3, &v14);
queue_append(v3, &v13);
queue_append(v3, &v12);
v4 = queue_size(v3);
printf("Queue size is %zu\n", v4);
v11 = 0;
queue_apply(v3, show_one, &v11);
queue_reverse(v3);
v5 = queue_size(v3);
printf("Queue size is %zu\n", v5);
v11 = 0;
queue_apply(v3, show_one, &v11);
queue_sort(v3, compare_two);
v6 = queue_size(v3);
printf("Queue size is %zu\n", v6);
v11 = 0;
queue_apply(v3, show_one, &v11);
queue_remove(v3, v10);
v7 = queue_size(v3);
printf("Queue size is %zu\n", v7);
v11 = 0;
queue_apply(v3, show_one, &v11);
while ( !(unsigned __int8)queue_is_empty(v3) )
queue_remove(v3, v10);
v8 = queue_size(v3);
printf("Queue size is %zu\n", v8);
free(v3);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
void *v3; // rbx
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
_BYTE v10[12]; // [rsp+0h] [rbp-28h] BYREF
int v11; // [rsp+Ch] [rbp-1Ch] BYREF
int v12; // [rsp+10h] [rbp-18h] BYREF
int v13; // [rsp+14h] [rbp-14h] BYREF
int v14; // [rsp+18h] [rbp-10h] BYREF
int v15[3]; // [rsp+1Ch] [rbp-Ch] BYREF

v3 = (void *)func10(argc, argv, envp);
v15[0] = 4;
v14 = 3;
v13 = 4;
v12 = 3;
queue_append(v3, v15);
queue_append(v3, &v14);
queue_append(v3, &v13);
queue_append(v3, &v12);
v4 = func14(v3);
printf("Queue size is %zu\n", v4);
v11 = 0;
func13(v3, show_one, &v11);
func15(v3);
v5 = func14(v3);
printf("Queue size is %zu\n", v5);
v11 = 0;
func13(v3, show_one, &v11);
func16(v3, compare_two);
v6 = func14(v3);
printf("Queue size is %zu\n", v6);
v11 = 0;
func13(v3, show_one, &v11);
func12(v3, v10);
v7 = func14(v3);
printf("Queue size is %zu\n", v7);
v11 = 0;
func13(v3, show_one, &v11);
while ( !(unsigned __int8)func11(v3) )
func12(v3, v10);
v8 = func14(v3);
printf("Queue size is %zu\n", v8);
free(v3);
return 0;
}

original_code:
int main(int argc, char * argv[], char * envp[]){
  int exit_stat = 0;
  while(1){
    char* input = readline("CSE451Shell\% ");
    if(!strcmp(input, "")){
      free(input);
      continue;
    }
    exit_stat = exec_command(input, exit_stat);
    free(input);
  }
  return 0;
}

canonical_original_code:
int main(int argc, char *argv[], char *envp[]){
  int exit_stat = 0;
  while(1){
    char *input = readline("CSE451Shell\% ");
    if(!strcmp(input, "")){
      free(input);
      continue;
    }
    exit_stat = exec_command(input, exit_stat);
    free(input);
  }
  return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
envp
char *[]

variable_types:
input
char *


decompiled_code:
__int64 __fastcall queue_count_one(__int64 a1, _QWORD *a2)
{
++*a2;
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1, _QWORD *a2)
{
++*a2;
return 1LL;
}

original_code:
static _Bool queue_count_one(queue_element* elem, queue_function_args* args) {
  size_t* count = (size_t*) args;
  *count = *count + 1;
  return 1;
}

canonical_original_code:
static _Bool queue_count_one(void *elem, void *args) {
  unsigned long *count = (size_t*) args;
  *count = *count + 1;
  return 1;
}

variable_types:
count
unsigned long *


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

result = malloc(8uLL);
if ( result )
*result = 0LL;
return result;
}

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

result = malloc(8uLL);
if ( result )
*result = 0LL;
return result;
}

original_code:
queue* queue_create() {
  queue* q = (queue*) malloc(sizeof(queue));
  if (!q) {
    return ((void *)0);
  }
  q->head = ((void *)0);
  return q;
}

canonical_original_code:
struct _queue *queue_create() {
  struct _queue *q = (queue*) malloc(sizeof(queue));
  if (!q) {
    return ((void *)0);
  }
  q->head = ((void *)0);
  return q;
}

variable_types: struct _queue { struct _queue_link { void *elem; struct _queue_link *next; } *head; } *

user_defined_types: struct _queue { struct _queue_link *head; }


decompiled_code:
bool __fastcall queue_is_empty(_QWORD *a1)
{
if ( !a1 )
__assert_fail("q != NULL", "queue.c", 0x53u, "queue_is_empty");
return *a1 == 0LL;
}

canonical_decompiled_code:
bool __fastcall func11(_QWORD *a1)
{
if ( !a1 )
__assert_fail("q != NULL", "queue.c", 0x53u, "queue_is_empty");
return *a1 == 0LL;
}

original_code:
_Bool queue_is_empty(queue* q) {
  ((void) sizeof ((q != ((void *)0)) ? 1 : 0), __extension__ ({ if (q != ((void *)0)) ; else __assert_fail ("q != NULL", "queue.c", 83, __extension__ __PRETTY_FUNCTION__); }));
  return q->head == ((void *)0);
}

canonical_original_code:
_Bool queue_is_empty(struct _queue *q) {
  ((void) sizeof ((q != ((void *)0)) ? 1 : 0), __extension__ ({ if (q != ((void *)0)) ; else __assert_fail ("q != NULL", "queue.c", 83, __extension__ __PRETTY_FUNCTION__); }));
  return q->head == ((void *)0);
}

user_defined_types: struct _queue_link { void *elem; struct _queue_link *next; }


decompiled_code:
__int64 __fastcall queue_remove(_QWORD *a1, _QWORD *a2)
{
bool v3; // dl
__int64 result; // rax
_QWORD *v5; // rdi

if ( !a1 )
__assert_fail("q != NULL", "queue.c", 0x43u, "queue_remove");
if ( !a2 )
__assert_fail("elem_ptr != NULL", "queue.c", 0x44u, "queue_remove");
v3 = queue_is_empty(a1);
result = 0LL;
if ( !v3 )
{
*a2 = *(_QWORD *)*a1;
v5 = (_QWORD *)*a1;
*a1 = *(_QWORD *)(*a1 + 8LL);
free(v5);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func12(_QWORD *a1, _QWORD *a2)
{
bool v3; // dl
__int64 result; // rax
_QWORD *v5; // rdi

if ( !a1 )
__assert_fail("q != NULL", "queue.c", 0x43u, "queue_remove");
if ( !a2 )
__assert_fail("elem_ptr != NULL", "queue.c", 0x44u, "queue_remove");
v3 = func11(a1);
result = 0LL;
if ( !v3 )
{
*a2 = *(_QWORD *)*a1;
v5 = (_QWORD *)*a1;
*a1 = *(_QWORD *)(*a1 + 8LL);
free(v5);
result = 1LL;
}
return result;
}

original_code:
_Bool queue_remove(queue* q, queue_element** elem_ptr) {
  queue_link* old_head;
  ((void) sizeof ((q != ((void *)0)) ? 1 : 0), __extension__ ({ if (q != ((void *)0)) ; else __assert_fail ("q != NULL", "queue.c", 67, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((elem_ptr != ((void *)0)) ? 1 : 0), __extension__ ({ if (elem_ptr != ((void *)0)) ; else __assert_fail ("elem_ptr != NULL", "queue.c", 68, __extension__ __PRETTY_FUNCTION__); }));
  if (queue_is_empty(q)) {
    return 0;
  }
  *elem_ptr = q->head->elem;
  old_head = q->head;
  q->head = q->head->next;
  free(old_head);
  return 1;
}

canonical_original_code:
_Bool queue_remove(struct _queue *q, void **elem_ptr) {
  struct _queue_link *old_head;
  ((void) sizeof ((q != ((void *)0)) ? 1 : 0), __extension__ ({ if (q != ((void *)0)) ; else __assert_fail ("q != NULL", "queue.c", 67, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((elem_ptr != ((void *)0)) ? 1 : 0), __extension__ ({ if (elem_ptr != ((void *)0)) ; else __assert_fail ("elem_ptr != NULL", "queue.c", 68, __extension__ __PRETTY_FUNCTION__); }));
  if (queue_is_empty(q)) {
    return 0;
  }
  *elem_ptr = q->head->elem;
  old_head = q->head;
  q->head = q->head->next;
  free(old_head);
  return 1;
}

variable_types: struct _queue_link { void *elem; struct _queue_link *next; } *


decompiled_code:
__int64 __fastcall queue_apply(_QWORD *a1, __int64 (__fastcall *a2)(_QWORD, __int64), __int64 a3)
{
unsigned int v3; // er13
_QWORD *v5; // rbx
unsigned int v6; // eax

LOBYTE(v3) = a2 != 0LL && a1 != 0LL;
if ( !(_BYTE)v3 )
__assert_fail("q != NULL && qf != NULL", "queue.c", 0x65u, "queue_apply");
if ( queue_is_empty(a1) )
return 0;
v5 = (_QWORD *)*a1;
if ( *a1 )
{
while ( 1 )
{
v6 = a2(*v5, a3);
if ( !(_BYTE)v6 )
break;
v5 = (_QWORD *)v5[1];
if ( !v5 )
return v6;
}
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func13(_QWORD *a1, __int64 (__fastcall *a2)(_QWORD, __int64), __int64 a3)
{
unsigned int v3; // er13
_QWORD *v5; // rbx
unsigned int v6; // eax

LOBYTE(v3) = a2 != 0LL && a1 != 0LL;
if ( !(_BYTE)v3 )
__assert_fail("q != NULL && qf != NULL", "queue.c", 0x65u, "queue_apply");
if ( func11(a1) )
return 0;
v5 = (_QWORD *)*a1;
if ( *a1 )
{
while ( 1 )
{
v6 = a2(*v5, a3);
if ( !(_BYTE)v6 )
break;
v5 = (_QWORD *)v5[1];
if ( !v5 )
return v6;
}
}
return v3;
}

original_code:
_Bool queue_apply(queue* q, queue_function qf, queue_function_args* args) {
  ((void) sizeof ((q != ((void *)0) && qf != ((void *)0)) ? 1 : 0), __extension__ ({ if (q != ((void *)0) && qf != ((void *)0)) ; else __assert_fail ("q != NULL && qf != NULL", "queue.c", 101, __extension__ __PRETTY_FUNCTION__); }));
  if (queue_is_empty(q))
    return 0;
  for (queue_link* cur = q->head; cur; cur = cur->next) {
    if (!qf(cur->elem, args))
      break;
  }
  return 1;
}

canonical_original_code:
_Bool queue_apply(struct _queue *q, _Bool qf(void *, void *), void *args) {
  ((void) sizeof ((q != ((void *)0) && qf != ((void *)0)) ? 1 : 0), __extension__ ({ if (q != ((void *)0) && qf != ((void *)0)) ; else __assert_fail ("q != NULL && qf != NULL", "queue.c", 101, __extension__ __PRETTY_FUNCTION__); }));
  if (queue_is_empty(q))
    return 0;
  for (struct _queue_link *cur = q->head; cur; cur = cur->next) {
    if (!qf(cur->elem, args))
      break;
  }
  return 1;
}

variable_types:
qf
_Bool (void *, void *)


decompiled_code:
__int64 __fastcall queue_size(_QWORD *a1)
{
__int64 v2; // [rsp+8h] [rbp-10h] BYREF

v2 = 0LL;
queue_apply(a1, (__int64 (__fastcall *)(_QWORD, __int64))queue_count_one, (__int64)&v2);
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func14(_QWORD *a1)
{
__int64 v2; // [rsp+8h] [rbp-10h] BYREF

v2 = 0LL;
func13(a1, (__int64 (__fastcall *)(_QWORD, __int64))queue_count_one, (__int64)&v2);
return v2;
}

original_code:
size_t queue_size(queue* q) {
  size_t count = 0;
  queue_apply(q, queue_count_one, &count);
  return count;
}

canonical_original_code:
unsigned long queue_size(struct _queue *q) {
  unsigned long count = 0;
  queue_apply(q, queue_count_one, &count);
  return count;
}

variable_types:
count
unsigned long

return_type: unsigned long


original_code:
void queue_reverse(queue* q) {
  if (queue_is_empty(q))
    return;
  queue_link* last;
  for (last = q->head; last->next; last = last->next) {}
  while (q->head != last) {
    queue_link* tmp = q->head;
    q->head = tmp->next;
    tmp->next = last->next;
    last->next = tmp;
  }
}

canonical_original_code:
void queue_reverse(struct _queue *q) {
  if (queue_is_empty(q))
    return;
  struct _queue_link *last;
  for (last = q->head; last->next; last = last->next) {}
  while (q->head != last) {
    struct _queue_link *tmp = q->head;
    q->head = tmp->next;
    tmp->next = last->next;
    last->next = tmp;
  }
}

return_type: void


decompiled_code:
__int64 __fastcall exec_command(void *ptr, int status)
{
unsigned int v3; // er13
char **v4; // rax
char **v5; // r12
char *v6; // rax
char **v7; // rbx
const char *v9; // rbx
const char *v10; // rdi
int v11; // eax
char *v12; // rax
const char *v13; // rdi
unsigned int v14; // ebx
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-2Ch] BYREF

v3 = status;
v4 = (char **)calloc(0x14uLL, 8uLL);
if ( v4 )
{
v5 = v4;
v6 = strtok((char *)ptr, " ");
v7 = v5;
if ( v6 )
{
while ( 1 )
{
*v7 = v6;
v6 = strtok(0LL, " ");
if ( !v6 )
break;
if ( ++v7 == v5 + 19 )
{
puts("Argument Limit Exceeded");
free(v5);
return v3;
}
}
}
v9 = *v5;
if ( !strcmp("chdir", *v5) )
{
v10 = v5[1];
if ( v10 )
{
v11 = chdir(v10);
}
else
{
v12 = getenv("HOME");
v11 = chdir(v12);
}
if ( v11 )
puts("Directory does not exist");
goto LABEL_13;
}
if ( !strcmp(".", *v5) )
{
v3 = read_from_file(v5[1], (unsigned int)status);
LABEL_13:
free(v5);
return v3;
}
if ( !strcmp("exit", *v5) )
{
v13 = v5[1];
if ( v13 )
{
v14 = atoi(v13);
free(ptr);
free(v5);
printf("exit: %d\n", v14);
exit(v14);
}
free(ptr);
free(v5);
exit(status);
}
if ( !fork() )
{
if ( execvp(v9, v5) == -1 )
puts("Invalid Command");
exit(0);
}
v3 = -1;
if ( wait((__WAIT_STATUS)&stat_loc) > 0 )
v3 = BYTE1(stat_loc.__uptr);
free(v5);
}
else
{
puts("Error allocating memory");
}
return v3;
}

canonical_decompiled_code:
__int64 __fastcall func7(void *ptr, int status)
{
unsigned int v3; // er13
char **v4; // rax
char **v5; // r12
char *v6; // rax
char **v7; // rbx
const char *v9; // rbx
const char *v10; // rdi
int v11; // eax
char *v12; // rax
const char *v13; // rdi
unsigned int v14; // ebx
__WAIT_STATUS stat_loc; // [rsp+Ch] [rbp-2Ch] BYREF

v3 = status;
v4 = (char **)calloc(0x14uLL, 8uLL);
if ( v4 )
{
v5 = v4;
v6 = strtok((char *)ptr, " ");
v7 = v5;
if ( v6 )
{
while ( 1 )
{
*v7 = v6;
v6 = strtok(0LL, " ");
if ( !v6 )
break;
if ( ++v7 == v5 + 19 )
{
puts("Argument Limit Exceeded");
free(v5);
return v3;
}
}
}
v9 = *v5;
if ( !strcmp("chdir", *v5) )
{
v10 = v5[1];
if ( v10 )
{
v11 = chdir(v10);
}
else
{
v12 = getenv("HOME");
v11 = chdir(v12);
}
if ( v11 )
puts("Directory does not exist");
goto LABEL_13;
}
if ( !strcmp(".", *v5) )
{
v3 = func8(v5[1], (unsigned int)status);
LABEL_13:
free(v5);
return v3;
}
if ( !strcmp("exit", *v5) )
{
v13 = v5[1];
if ( v13 )
{
v14 = atoi(v13);
free(ptr);
free(v5);
printf("exit: %d\n", v14);
exit(v14);
}
free(ptr);
free(v5);
exit(status);
}
if ( !fork() )
{
if ( execvp(v9, v5) == -1 )
puts("Invalid Command");
exit(0);
}
v3 = -1;
if ( wait((__WAIT_STATUS)&stat_loc) > 0 )
v3 = BYTE1(stat_loc.__uptr);
free(v5);
}
else
{
puts("Error allocating memory");
}
return v3;
}

original_code:
int exec_command(char* input, int old_exit_status){
  int num_args = 20;
  char** args = calloc(num_args, sizeof(char*));
    if(args == ((void *)0)){
      printf("Error allocating memory\n");
      return old_exit_status;
    }
    int i;
    char* arg = strtok(input, " ");
    for(i = 0; arg != ((void *)0); i++){
      if(i >= num_args - 1){
 printf("Argument Limit Exceeded\n");
 free(args);
 return old_exit_status;
      }
      args[i] = arg;
      arg = strtok(((void *)0), " ");
    }
    char* command = args[0];
    if(!strncmp("chdir", command, 6)){
      int ret;
      if(args[1] != ((void *)0)){
 ret = chdir(args[1]);
      }else{
 char* home = getenv("HOME");
 ret = chdir(home);
      }
      if(ret != 0){
 printf("Directory does not exist\n");
      }
    }else if(!strncmp(".", command, 2)){
      old_exit_status = read_from_file(args[1], old_exit_status);
    }else if(!strncmp("exit", command, 5)){
      if(args[1] != ((void *)0)){
 int x = atoi(args[1]);
 free(input);
 free(args);
 printf("exit: %d\n", x);
 exit(x);
      }
      free(input);
      free(args);
      exit(old_exit_status);
    }else{
      pid_t pid = fork();
      if(pid == 0){
 int exe = execvp(command, args);
 if(exe == -1){
   printf("Invalid Command\n");
 }
 exit(0);
      }else{
 int status;
 int exit_status = -1;
 if(wait(&status) > 0){
   exit_status = (((status) & 0xff00) >> 8);
 }
 free(args);
 return exit_status;
      }
    }
    free(args);
    return old_exit_status;
}

canonical_original_code:
int exec_command(char *input, int old_exit_status){
  int num_args = 20;
  char **args = calloc(num_args, sizeof(char*));
    if(args == ((void *)0)){
      printf("Error allocating memory\n");
      return old_exit_status;
    }
    int i;
    char *arg = strtok(input, " ");
    for(i = 0; arg != ((void *)0); i++){
      if(i >= num_args - 1){
 printf("Argument Limit Exceeded\n");
 free(args);
 return old_exit_status;
      }
      args[i] = arg;
      arg = strtok(((void *)0), " ");
    }
    char *command = args[0];
    if(!strncmp("chdir", command, 6)){
      int ret;
      if(args[1] != ((void *)0)){
 ret = chdir(args[1]);
      }else{
 char *home = getenv("HOME");
 ret = chdir(home);
      }
      if(ret != 0){
 printf("Directory does not exist\n");
      }
    }else if(!strncmp(".", command, 2)){
      old_exit_status = read_from_file(args[1], old_exit_status);
    }else if(!strncmp("exit", command, 5)){
      if(args[1] != ((void *)0)){
 int x = atoi(args[1]);
 free(input);
 free(args);
 printf("exit: %d\n", x);
 exit(x);
      }
      free(input);
      free(args);
      exit(old_exit_status);
    }else{
      int pid = fork();
      if(pid == 0){
 int exe = execvp(command, args);
 if(exe == -1){
   printf("Invalid Command\n");
 }
 exit(0);
      }else{
 int status;
 int exit_status = -1;
 if(wait(&status) > 0){
   exit_status = (((status) & 0xff00) >> 8);
 }
 free(args);
 return exit_status;
      }
    }
    free(args);
    return old_exit_status;
}

variable_types:
args
char **

variable_types: i int

variable_types:
arg
char *

variable_types:
command
char *

variable_types: ret int

variable_types:
home
char *

variable_types: pid int

variable_types: exe int

variable_types: status int


decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // ebp
_BYTE *v4; // rax
void *v5; // rbx

v3 = 0;
while ( 1 )
{
v4 = (_BYTE *)readline();
v5 = v4;
if ( *v4 )
{
v3 = exec_command(v4, v3);
free(v5);
}
else
{
free(v4);
}
}
}

canonical_decompiled_code:
int __cdecl __noreturn main(int argc, const char **argv, const char **envp)
{
int v3; // ebp
_BYTE *v4; // rax
void *v5; // rbx

v3 = 0;
while ( 1 )
{
v4 = (_BYTE *)readline();
v5 = v4;
if ( *v4 )
{
v3 = func7(v4, v3);
free(v5);
}
else
{
free(v4);
}
}
}

variable_types: argc int

variable_types:
argv
char *[]


decompiled_code:
int osip_build_random_number()
{
unsigned int v1; // ebp
int v2; // er12
int v3; // ebx
int buf; // [rsp+Ch] [rbp-3Ch] BYREF
struct timeval tv; // [rsp+10h] [rbp-38h] BYREF

if ( !random_seed_set )
{
gettimeofday(&tv, 0LL);
v1 = LODWORD(tv.tv_sec) + LODWORD(tv.tv_usec);
v2 = open("/dev/urandom", 0);
if ( v2 > 0 )
{
v3 = 512;
do
{
read(v2, &buf, 4uLL);
v1 += buf;
--v3;
}
while ( v3 );
close(v2);
}
srand(v1);
random_seed_set = 1;
}
return rand();
}

canonical_decompiled_code:
int func0()
{
unsigned int v1; // ebp
int v2; // er12
int v3; // ebx
int buf; // [rsp+Ch] [rbp-3Ch] BYREF
struct timeval tv; // [rsp+10h] [rbp-38h] BYREF

if ( !random_seed_set )
{
gettimeofday(&tv, 0LL);
v1 = LODWORD(tv.tv_sec) + LODWORD(tv.tv_usec);
v2 = open("/dev/urandom", 0);
if ( v2 > 0 )
{
v3 = 512;
do
{
read(v2, &buf, 4uLL);
v1 += buf;
--v3;
}
while ( v3 );
close(v2);
}
srand(v1);
random_seed_set = 1;
}
return rand();
}

original_code:
unsigned int
osip_build_random_number ()
{
  if (!random_seed_set)
    {
      unsigned int ticks;
      struct timeval tv;
      int fd;
      gettimeofday (&tv, ((void *)0));
      ticks = tv.tv_sec + tv.tv_usec;
      fd = open ("/dev/urandom", 00);
      if (fd > 0)
        {
          unsigned int r;
          int i;
          for (i = 0; i < 512; i++)
            {
              read (fd, &r, sizeof (r));
              ticks += r;
            }
          close (fd);
        }
      srand (ticks);
      random_seed_set = 1;
    }
  return rand ();
}

canonical_original_code:
unsigned int osip_build_random_number()
{
  if (!random_seed_set)
    {
      unsigned int ticks;
      struct timeval tv;
      int fd;
      gettimeofday (&tv, ((void *)0));
      ticks = tv.tv_sec + tv.tv_usec;
      fd = open ("/dev/urandom", 00);
      if (fd > 0)
        {
          unsigned int r;
          int i;
          for (i = 0; i < 512; i++)
            {
              read (fd, &r, sizeof (r));
              ticks += r;
            }
          close (fd);
        }
      srand (ticks);
      random_seed_set = 1;
    }
  return rand ();
}

variable_types:
ticks
unsigned int

variable_types: struct timeval { long tv_sec; long tv_usec; }

variable_types: fd int

variable_types:
r
unsigned int

return_type: unsigned int


decompiled_code:
__int64 __fastcall osip_atoi(const char *a1)
{
__int64 result; // rax

if ( a1 )
result = strtol(a1, 0LL, 10);
else
result = 0xFFFFFFFFLL;
return result;
}

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

if ( a1 )
result = strtol(a1, 0LL, 10);
else
result = 0xFFFFFFFFLL;
return result;
}

original_code:
int
osip_atoi (const char *number)
{
  int i;
  if (number == ((void *)0))
    return -1;
  i = strtol (number, (char **) ((void *)0), 10);
  if (i == (-0x7fffffffffffffffL - 1L) || i == 0x7fffffffffffffffL)
    return -1;
  return i;
  return atoi (number);
}

canonical_original_code:
int osip_atoi(char *number)
{
  int i;
  if (number == ((void *)0))
    return -1;
  i = strtol (number, (char **) ((void *)0), 10);
  if (i == (-0x7fffffffffffffffL - 1L) || i == 0x7fffffffffffffffL)
    return -1;
  return i;
  return atoi (number);
}

variable_types:
number
char *


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

result = strncpy(a1, a2, a3);
a1[a3] = 0;
return result;
}

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

result = strncpy(a1, a2, a3);
a1[a3] = 0;
return result;
}

original_code:
char *
osip_strncpy (char *dest, const char *src, size_t length)
{
  strncpy (dest, src, length);
  dest[length] = '\0';
  return dest;
}

canonical_original_code:
char *osip_strncpy(char *dest, char *src, unsigned long length)
{
  strncpy (dest, src, length);
  dest[length] = '\0';
  return dest;
}

variable_types:
dest
char *

variable_types:
src
char *

variable_types:
length
unsigned long

return_type: char *


decompiled_code:
int __fastcall osip_usleep(int a1)
{
struct timeval v2; // [rsp+0h] [rbp-18h] BYREF

if ( a1 <= 999999 )
{
v2.tv_sec = 0LL;
v2.tv_usec = a1;
}
else
{
v2.tv_sec = a1 / 1000000;
v2.tv_usec = 0LL;
}
return select(0, 0LL, 0LL, 0LL, &v2);
}

canonical_decompiled_code:
int __fastcall func4(int a1)
{
struct timeval v2; // [rsp+0h] [rbp-18h] BYREF

if ( a1 <= 999999 )
{
v2.tv_sec = 0LL;
v2.tv_usec = a1;
}
else
{
v2.tv_sec = a1 / 1000000;
v2.tv_usec = 0LL;
}
return select(0, 0LL, 0LL, 0LL, &v2);
}

original_code:
void
osip_usleep (int useconds)
{
  struct timeval delay;
  int sec;
  sec = (int) useconds / 1000000;
  if (sec > 0)
    {
      delay.tv_sec = sec;
      delay.tv_usec = 0;
  } else
    {
      delay.tv_sec = 0;
      delay.tv_usec = useconds;
    }
  select (0, 0, 0, 0, &delay);
}

canonical_original_code:
void osip_usleep(int useconds)
{
  struct timeval delay;
  int sec;
  sec = (int) useconds / 1000000;
  if (sec > 0)
    {
      delay.tv_sec = sec;
      delay.tv_usec = 0;
  } else
    {
      delay.tv_sec = 0;
      delay.tv_usec = useconds;
    }
  select (0, 0, 0, 0, &delay);
}

variable_types: useconds int

variable_types: sec int

user_defined_types: struct timeval { long tv_sec; long tv_usec; }


decompiled_code:
char *__fastcall osip_strdup(const char *a1)
{
size_t v1; // r12
char *v2; // rbp

if ( !a1 )
return 0LL;
v1 = strlen(a1);
if ( osip_malloc_func )
v2 = (char *)osip_malloc_func(v1 + 1);
else
v2 = (char *)malloc(v1 + 1);
osip_strncpy(v2, a1, v1);
return v2;
}

canonical_decompiled_code:
char *__fastcall func5(const char *a1)
{
size_t v1; // r12
char *v2; // rbp

if ( !a1 )
return 0LL;
v1 = strlen(a1);
if ( osip_malloc_func )
v2 = (char *)osip_malloc_func(v1 + 1);
else
v2 = (char *)malloc(v1 + 1);
func2(v2, a1, v1);
return v2;
}

original_code:
char *
osip_strdup (const char *ch)
{
  char *copy;
  size_t length;
  if (ch == ((void *)0))
    return ((void *)0);
  length = strlen (ch);
  copy = (char *) (osip_malloc_func?osip_malloc_func(length + 1):malloc(length + 1));
  osip_strncpy (copy, ch, length);
  return copy;
}

canonical_original_code:
char *osip_strdup(char *ch)
{
  char *copy;
  unsigned long length;
  if (ch == ((void *)0))
    return ((void *)0);
  length = strlen (ch);
  copy = (char *) (osip_malloc_func?osip_malloc_func(length + 1):malloc(length + 1));
  osip_strncpy (copy, ch, length);
  return copy;
}

variable_types:
ch
char *

variable_types:
copy
char *


decompiled_code:
char *__fastcall osip_strdup_without_quote(char *s)
{
__int64 (__fastcall *v1)(size_t); // rbp
size_t v2; // rax
char *v3; // rbp
size_t v4; // rax
size_t v6; // rax
size_t v7; // rax
size_t v8; // rax

v1 = osip_malloc_func;
if ( osip_malloc_func )
{
v2 = strlen(s);
v3 = (char *)v1(v2 + 1);
}
else
{
v6 = strlen(s);
v3 = (char *)malloc(v6 + 1);
}
if ( *s == 34 )
{
v7 = strlen(s + 1);
osip_strncpy(v3, s + 1, v7);
v8 = strlen(v3);
osip_strncpy(&v3[v8 - 1], byte_859, 1uLL);
}
else
{
v4 = strlen(s);
osip_strncpy(v3, s, v4);
}
return v3;
}

canonical_decompiled_code:
char *__fastcall func6(char *s)
{
__int64 (__fastcall *v1)(size_t); // rbp
size_t v2; // rax
char *v3; // rbp
size_t v4; // rax
size_t v6; // rax
size_t v7; // rax
size_t v8; // rax

v1 = osip_malloc_func;
if ( osip_malloc_func )
{
v2 = strlen(s);
v3 = (char *)v1(v2 + 1);
}
else
{
v6 = strlen(s);
v3 = (char *)malloc(v6 + 1);
}
if ( *s == 34 )
{
v7 = strlen(s + 1);
func2(v3, s + 1, v7);
v8 = strlen(v3);
func2(&v3[v8 - 1], byte_859, 1uLL);
}
else
{
v4 = strlen(s);
func2(v3, s, v4);
}
return v3;
}

original_code:
char *
osip_strdup_without_quote (const char *ch)
{
  char *copy = (char *) (osip_malloc_func?osip_malloc_func(strlen (ch) + 1):malloc(strlen (ch) + 1));
  if ((*ch == '\"'))
    {
      osip_strncpy (copy, ch + 1, strlen (ch + 1));
      osip_strncpy (copy + strlen (copy) - 1, "\0", 1);
  } else
    osip_strncpy (copy, ch, strlen (ch));
  return copy;
}

canonical_original_code:
char *osip_strdup_without_quote(char *ch)
{
  char *copy = (char *) (osip_malloc_func?osip_malloc_func(strlen (ch) + 1):malloc(strlen (ch) + 1));
  if ((*ch == '\"'))
    {
      osip_strncpy (copy, ch + 1, strlen (ch + 1));
      osip_strncpy (copy + strlen (copy) - 1, "\0", 1);
  } else
    osip_strncpy (copy, ch, strlen (ch));
  return copy;
}


decompiled_code:
__int64 __fastcall osip_tolower(char *a1)
{
char v1; // bl
char *v2; // rbp
const __int32_t **v3; // rdx

v1 = *a1;
if ( *a1 )
{
v2 = a1;
v3 = _ctype_tolower_loc();
do
{
*v2++ = (*v3)[v1];
v1 = *v2;
}
while ( *v2 );
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func7(char *a1)
{
char v1; // bl
char *v2; // rbp
const __int32_t **v3; // rdx

v1 = *a1;
if ( *a1 )
{
v2 = a1;
v3 = _ctype_tolower_loc();
do
{
*v2++ = (*v3)[v1];
v1 = *v2;
}
while ( *v2 );
}
return 0LL;
}

original_code:
int
osip_tolower (char *word)
{
  for (; *word; word++)
    *word = (char) tolower (*word);
  return 0;
}

canonical_original_code:
int osip_tolower(char *word)
{
  for (; *word; word++)
    *word = (char) tolower (*word);
  return 0;
}

variable_types:
word
char *


decompiled_code:
int __fastcall osip_strcasecmp(const char *a1, const char *a2)
{
return strcasecmp(a1, a2);
}

canonical_decompiled_code:
int __fastcall func8(const char *a1, const char *a2)
{
return strcasecmp(a1, a2);
}

original_code:
int
osip_strcasecmp (const char *s1, const char *s2)
{
  return strcasecmp (s1, s2);
}

canonical_original_code:
int osip_strcasecmp(char *s1, char *s2)
{
  return strcasecmp (s1, s2);
}


decompiled_code:
int __fastcall osip_strncasecmp(const char *a1, const char *a2, size_t a3)
{
return strncasecmp(a1, a2, a3);
}

canonical_decompiled_code:
int __fastcall func9(const char *a1, const char *a2, size_t a3)
{
return strncasecmp(a1, a2, a3);
}

original_code:
int
osip_strncasecmp (const char *s1, const char *s2, size_t len)
{
  return strncasecmp (s1, s2, len);
}

canonical_original_code:
int osip_strncasecmp(char *s1, char *s2, unsigned long len)
{
  return strncasecmp (s1, s2, len);
}

variable_types:
len
unsigned long


decompiled_code:
__int64 __fastcall osip_clrspace(void *dest)
{
unsigned __int8 *v1; // rbx
unsigned __int64 v2; // rbp
size_t v3; // rcx
unsigned __int8 *v4; // rsi
__int64 v5; // rax
__int64 v6; // rdx
unsigned __int64 v7; // rax
char *v8; // rdi
char *v9; // rax
__int64 v10; // rcx
unsigned __int64 v12; // rdx

if ( !dest )
return 0xFFFFFFFFLL;
v1 = (unsigned __int8 *)dest;
v2 = *(unsigned __int8 *)dest;
if ( (_BYTE)v2 )
{
v3 = strlen((const char *)dest);
v4 = (unsigned __int8 *)dest;
if ( (unsigned __int8)v2 <= 0x20u )
{
v5 = 0x100002600LL;
if ( _bittest64(&v5, v2) )
{
v6 = 0x100002600LL;
do
v7 = *++v4;
while ( (unsigned __int8)v7 <= 0x20u && _bittest64(&v6, v7) );
}
}
v8 = (char *)dest + v3 - 1;
v9 = (char *)&v1[v3 - 1];
v10 = 0x100002600LL;
while ( 1 )
{
v12 = (unsigned __int8)*v9;
if ( (unsigned __int8)v12 > 0x20u || !_bittest64(&v10, v12) )
break;
if ( --v9 < (char *)v4 )
{
*v1 = 0;
return 0LL;
}
}
if ( v8 >= v9 + 1 )
v9[1] = 0;
if ( v1 != v4 )
memmove(v1, v4, v9 - (char *)v4 + 2);
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func10(void *dest)
{
unsigned __int8 *v1; // rbx
unsigned __int64 v2; // rbp
size_t v3; // rcx
unsigned __int8 *v4; // rsi
__int64 v5; // rax
__int64 v6; // rdx
unsigned __int64 v7; // rax
char *v8; // rdi
char *v9; // rax
__int64 v10; // rcx
unsigned __int64 v12; // rdx

if ( !dest )
return 0xFFFFFFFFLL;
v1 = (unsigned __int8 *)dest;
v2 = *(unsigned __int8 *)dest;
if ( (_BYTE)v2 )
{
v3 = strlen((const char *)dest);
v4 = (unsigned __int8 *)dest;
if ( (unsigned __int8)v2 <= 0x20u )
{
v5 = 0x100002600LL;
if ( _bittest64(&v5, v2) )
{
v6 = 0x100002600LL;
do
v7 = *++v4;
while ( (unsigned __int8)v7 <= 0x20u && _bittest64(&v6, v7) );
}
}
v8 = (char *)dest + v3 - 1;
v9 = (char *)&v1[v3 - 1];
v10 = 0x100002600LL;
while ( 1 )
{
v12 = (unsigned __int8)*v9;
if ( (unsigned __int8)v12 > 0x20u || !_bittest64(&v10, v12) )
break;
if ( --v9 < (char *)v4 )
{
*v1 = 0;
return 0LL;
}
}
if ( v8 >= v9 + 1 )
v9[1] = 0;
if ( v1 != v4 )
memmove(v1, v4, v9 - (char *)v4 + 2);
}
return 0LL;
}

original_code:
int
osip_clrspace (char *word)
{
  char *pbeg;
  char *pend;
  size_t len;
  if (word == ((void *)0))
    return -1;
  if (*word == '\0')
    return 0;
  len = strlen (word);
  pbeg = word;
  while ((' ' == *pbeg) || ('\r' == *pbeg) || ('\n' == *pbeg) || ('\t' == *pbeg))
    pbeg++;
  pend = word + len - 1;
  while ((' ' == *pend) || ('\r' == *pend) || ('\n' == *pend) || ('\t' == *pend))
    {
      pend--;
      if (pend < pbeg)
        {
          *word = '\0';
          return 0;
        }
    }
  if (pend + 1 <= word + (len - 1))
    pend[1] = '\0';
  if (pbeg != word)
    memmove (word, pbeg, pend - pbeg + 2);
  return 0;
}

canonical_original_code:
int osip_clrspace(char *word)
{
  char *pbeg;
  char *pend;
  unsigned long len;
  if (word == ((void *)0))
    return -1;
  if (*word == '\0')
    return 0;
  len = strlen (word);
  pbeg = word;
  while ((' ' == *pbeg) || ('\r' == *pbeg) || ('\n' == *pbeg) || ('\t' == *pbeg))
    pbeg++;
  pend = word + len - 1;
  while ((' ' == *pend) || ('\r' == *pend) || ('\n' == *pend) || ('\t' == *pend))
    {
      pend--;
      if (pend < pbeg)
        {
          *word = '\0';
          return 0;
        }
    }
  if (pend + 1 <= word + (len - 1))
    pend[1] = '\0';
  if (pbeg != word)
    memmove (word, pbeg, pend - pbeg + 2);
  return 0;
}

variable_types:
pbeg
char *

variable_types:
pend
char *


decompiled_code:
void __fastcall osip_dequote(void *dest)
{
char *v1; // rbx
size_t v2; // r12
size_t v3; // rbp
size_t v4; // r12
char v5; // al

if ( *(_BYTE *)dest == 34 )
{
v1 = (char *)dest;
v2 = strlen((const char *)dest);
v3 = v2 - 1;
memmove(dest, (char *)dest + 1, v2);
if ( v2 != 1 )
{
v4 = v2 - 2;
if ( *((_BYTE *)dest + v4) == 34 )
{
*((_BYTE *)dest + v4) = 0;
v3 = v4;
}
}
v5 = *(_BYTE *)dest;
if ( *(_BYTE *)dest )
{
do
{
if ( v5 == 92 )
memmove(v1, v1 + 1, v3--);
++v1;
--v3;
v5 = *v1;
}
while ( *v1 );
}
}
}

canonical_decompiled_code:
void __fastcall func13(void *dest)
{
char *v1; // rbx
size_t v2; // r12
size_t v3; // rbp
size_t v4; // r12
char v5; // al

if ( *(_BYTE *)dest == 34 )
{
v1 = (char *)dest;
v2 = strlen((const char *)dest);
v3 = v2 - 1;
memmove(dest, (char *)dest + 1, v2);
if ( v2 != 1 )
{
v4 = v2 - 2;
if ( *((_BYTE *)dest + v4) == 34 )
{
*((_BYTE *)dest + v4) = 0;
v3 = v4;
}
}
v5 = *(_BYTE *)dest;
if ( *(_BYTE *)dest )
{
do
{
if ( v5 == 92 )
memmove(v1, v1 + 1, v3--);
++v1;
--v3;
v5 = *v1;
}
while ( *v1 );
}
}
}

original_code:
void
osip_dequote (char *s)
{
  size_t len;
  if (*s == '\0')
    return;
  if (*s != '"')
    return;
  len = strlen (s);
  memmove (s, s + 1, len--);
  if (len > 0 && s[len - 1] == '"')
    s[--len] = '\0';
  for (; *s != '\0'; s++, len--)
    {
      if (*s == '\\')
        memmove (s, s + 1, len--);
    }
}

canonical_original_code:
void osip_dequote(char *s)
{
  unsigned long len;
  if (*s == '\0')
    return;
  if (*s != '"')
    return;
  len = strlen (s);
  memmove (s, s + 1, len--);
  if (len > 0 && s[len - 1] == '"')
    s[--len] = '\0';
  for (; *s != '\0'; s++, len--)
    {
      if (*s == '\\')
        memmove (s, s + 1, len--);
    }
}

variable_types:
s
char *


decompiled_code:
void osip_trace_initialize_func()
{
;
}

canonical_decompiled_code:
void func14()
{
;
}

original_code:
void
osip_trace_initialize_func (osip_trace_level_t level, osip_trace_func_t * func)
{
}

canonical_original_code:
void osip_trace_initialize_func(enum _trace_level level, void (*func)(char *fi, int li, enum _trace_level level, char *chfr, __builtin_va_list ap))
{
}

variable_types: void (*)(char *fi, int li, enum _trace_level { TRACE_LEVEL0=0, TRACE_LEVEL1=1, TRACE_LEVEL2=2, TRACE_LEVEL3=3, TRACE_LEVEL4=4, TRACE_LEVEL5=5, TRACE_LEVEL6=6, TRACE_LEVEL7=7, END_TRACE_LEVEL=8 } level, char *chfr, __builtin_va_list ap)


decompiled_code:
void osip_trace_disable_level()
{
;
}

canonical_decompiled_code:
void func18()
{
;
}

original_code:
void
osip_trace_disable_level (osip_trace_level_t level)
{
}

canonical_original_code:
void osip_trace_disable_level(enum _trace_level level)
{
}

variable_types: enum _trace_level { TRACE_LEVEL0=0, TRACE_LEVEL1=1, TRACE_LEVEL2=2, TRACE_LEVEL3=3, TRACE_LEVEL4=4, TRACE_LEVEL5=5, TRACE_LEVEL6=6, TRACE_LEVEL7=7, END_TRACE_LEVEL=8 }


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

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

original_code:
int
osip_is_trace_level_activate (osip_trace_level_t level)
{
  return 0;
}

canonical_original_code:
int osip_is_trace_level_activate(enum _trace_level level)
{
  return 0;
}

user_defined_types: enum _trace_level { TRACE_LEVEL0=0, TRACE_LEVEL1=1, TRACE_LEVEL2=2, TRACE_LEVEL3=3, TRACE_LEVEL4=4, TRACE_LEVEL5=5, TRACE_LEVEL6=6, TRACE_LEVEL7=7, END_TRACE_LEVEL=8 }


decompiled_code:
__int64 __fastcall osip_hash(char *a1)
{
char *v1; // rsi
char v2; // al
__int64 v3; // rcx

v1 = a1 + 1;
v2 = *a1;
if ( !*a1 )
return 5381LL;
v3 = 5381LL;
do
{
v3 += 32 * v3 + v2;
v2 = *v1++;
}
while ( v2 );
return v3;
}

original_code:
unsigned long
osip_hash (const char *str)
{
  unsigned long hash = 5381;
  int c;
  while (c = *str++)
    hash = ((hash << 5) + hash) + c;
  return hash;
}

canonical_original_code:
unsigned long osip_hash(char *str)
{
  unsigned long hash = 5381;
  int c;
  while (c = *str++)
    hash = ((hash << 5) + hash) + c;
  return hash;
}

variable_types:
str
char *

variable_types:
hash
unsigned long

variable_types: c int


decompiled_code:
__int64 __fastcall add_fdt_lct_he(__int64 a1, int a2, int a3)
{
*(_DWORD *)(a1 + a2) = _bswap_32(a3 & 0xFFFFF | 0xC0100000);
return 4LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, int a2, int a3)
{
*(_DWORD *)(a1 + a2) = func0(a3 & 0xFFFFF | 0xC0100000);
return 4LL;
}

original_code:
int add_fdt_lct_he(def_lct_hdr_t *def_lct_hdr, int hdrlen, unsigned int fdt_instance_id) {
 unsigned int word;
 int len = 0;
 word = ((192 << 24) | ((1 & 0xF) << 20) | (fdt_instance_id & 0x000FFFFF));
 *(unsigned int*)((unsigned char*)def_lct_hdr + hdrlen) = htonl(word);
 len += 4;
 return len;
}

canonical_original_code:
int add_fdt_lct_he(struct def_lct_hdr *def_lct_hdr, int hdrlen, unsigned int fdt_instance_id) {
 unsigned int word;
 int len = 0;
 word = ((192 << 24) | ((1 & 0xF) << 20) | (fdt_instance_id & 0x000FFFFF));
 *(unsigned int *)((unsigned char *)def_lct_hdr + hdrlen) = htonl(word);
 len += 4;
 return len;
}

variable_types: struct def_lct_hdr { unsigned short flag_b; unsigned short flag_a; unsigned short flag_r; unsigned short flag_t; unsigned short flag_h; unsigned short flag_o; unsigned short flag_s; unsigned short reserved; unsigned short flag_c; unsigned short version; unsigned char hdr_len; unsigned char codepoint; unsigned int cci; } *

variable_types: hdrlen int

variable_types:
word
unsigned int

variable_types: len int


decompiled_code:
__int64 __fastcall add_cenc_lct_he(__int64 a1, int a2, unsigned __int8 a3)
{
*(_DWORD *)(a1 + a2) = _bswap_32((a3 << 16) | 0xC1000000);
return 4LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, int a2, unsigned __int8 a3)
{
*(_DWORD *)(a1 + a2) = func0((a3 << 16) | 0xC1000000);
return 4LL;
}

original_code:
int add_cenc_lct_he(def_lct_hdr_t *def_lct_hdr, int hdrlen, unsigned char content_enc_algo) {
        unsigned int word;
        int len = 0;
        word = ((193 << 24) | (content_enc_algo << 16) | (0 & 0x0000FFFF));
        *(unsigned int*)((unsigned char*)def_lct_hdr + hdrlen) = htonl(word);
        len += 4;
        return len;
}

canonical_original_code:
int add_cenc_lct_he(struct def_lct_hdr *def_lct_hdr, int hdrlen, unsigned char content_enc_algo) {
        unsigned int word;
        int len = 0;
        word = ((193 << 24) | (content_enc_algo << 16) | (0 & 0x0000FFFF));
        *(unsigned int *)((unsigned char *)def_lct_hdr + hdrlen) = htonl(word);
        len += 4;
        return len;
}

user_defined_types: struct def_lct_hdr { unsigned short flag_b; unsigned short flag_a; unsigned short flag_r; unsigned short flag_t; unsigned short flag_h; unsigned short flag_o; unsigned short flag_s; unsigned short reserved; unsigned short flag_c; unsigned short version; unsigned char hdr_len; unsigned char codepoint; unsigned int cci; }


canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, int a2, __int64 a3, int a4, unsigned __int16 a5, unsigned int a6)
{
unsigned int v6; // er14

v6 = a3;
*(_DWORD *)(a1 + a2) = func0(WORD2(a3) | 0x40040000u);
*(_DWORD *)(a1 + a2 + 4) = func0(v6);
*(_DWORD *)(a1 + a2 + 8) = func0((a4 << 16) | (unsigned int)a5);
*(_DWORD *)(a1 + a2 + 12) = func0(a6);
return 16LL;
}

original_code:
int add_fti_0_2_128_130_lct_he(def_lct_hdr_t *def_lct_hdr, int hdrlen,
       unsigned long long transferlen,
       unsigned short fec_inst_id, unsigned short eslen, unsigned int max_sblen) {
 unsigned int word;
 unsigned short tmp;
 int len = 0;
 tmp = ((unsigned int)(transferlen >> 32) & 0x0000FFFF);
 word = ((64 << 24) | (4 << 16) | tmp);
 *(unsigned int*)((unsigned char*)def_lct_hdr + hdrlen) = htonl(word);
 len += 4;
 *(unsigned int*)((unsigned char*)def_lct_hdr + hdrlen + len) = htonl((unsigned int)transferlen);
 len += 4;
 word = ((fec_inst_id << 16) | eslen);
 *(unsigned int*)((unsigned char*)def_lct_hdr + hdrlen + len) = htonl(word);
 len += 4;
 *(unsigned int*)((unsigned char*)def_lct_hdr + hdrlen + len) = htonl(max_sblen);
 len += 4;
 return len;
}

canonical_original_code:
int add_fti_0_2_128_130_lct_he(struct def_lct_hdr *def_lct_hdr, int hdrlen, unsigned long long transferlen, unsigned short fec_inst_id, unsigned short eslen, unsigned int max_sblen) {
 unsigned int word;
 unsigned short tmp;
 int len = 0;
 tmp = ((unsigned int)(transferlen >> 32) & 0x0000FFFF);
 word = ((64 << 24) | (4 << 16) | tmp);
 *(unsigned int *)((unsigned char *)def_lct_hdr + hdrlen) = htonl(word);
 len += 4;
 *(unsigned int *)((unsigned char *)def_lct_hdr + hdrlen + len) = htonl((unsigned int)transferlen);
 len += 4;
 word = ((fec_inst_id << 16) | eslen);
 *(unsigned int *)((unsigned char *)def_lct_hdr + hdrlen + len) = htonl(word);
 len += 4;
 *(unsigned int *)((unsigned char *)def_lct_hdr + hdrlen + len) = htonl(max_sblen);
 len += 4;
 return len;
}

variable_types:
transferlen
unsigned long long

variable_types:
eslen
unsigned short

variable_types:
tmp
unsigned short


original_code:
int add_fti_3_lct_he(def_lct_hdr_t *def_lct_hdr, int hdrlen,
        unsigned long long transferlen,
        unsigned char m, unsigned char G, unsigned short eslen,
        unsigned short max_sblen, unsigned short mxnbofes) {
  unsigned int word;
  unsigned short tmp;
  int len = 0;
  tmp = ((unsigned int)(transferlen >> 32) & 0x0000FFFF);
  word = ((64 << 24) | (4 << 16) | tmp);
  *(unsigned int*)((unsigned char*)def_lct_hdr + hdrlen) = htonl(word);
  len += 4;
  *(unsigned int*)((unsigned char*)def_lct_hdr + hdrlen + len) = htonl((unsigned int)transferlen);
  len += 4;
  word = ((m << 24) | (G << 16) | eslen);
  *(unsigned int*)((unsigned char*)def_lct_hdr + hdrlen + len) = htonl(word);
  len += 4;
  word = ((max_sblen << 16) | mxnbofes);
  *(unsigned int*)((unsigned char*)def_lct_hdr + hdrlen + len) = htonl(word);
  len += 4;
  return len;
}

canonical_original_code:
int add_fti_3_lct_he(struct def_lct_hdr *def_lct_hdr, int hdrlen, unsigned long long transferlen, unsigned char m, unsigned char G, unsigned short eslen, unsigned short max_sblen, unsigned short mxnbofes) {
  unsigned int word;
  unsigned short tmp;
  int len = 0;
  tmp = ((unsigned int)(transferlen >> 32) & 0x0000FFFF);
  word = ((64 << 24) | (4 << 16) | tmp);
  *(unsigned int *)((unsigned char *)def_lct_hdr + hdrlen) = htonl(word);
  len += 4;
  *(unsigned int *)((unsigned char *)def_lct_hdr + hdrlen + len) = htonl((unsigned int)transferlen);
  len += 4;
  word = ((m << 24) | (G << 16) | eslen);
  *(unsigned int *)((unsigned char *)def_lct_hdr + hdrlen + len) = htonl(word);
  len += 4;
  word = ((max_sblen << 16) | mxnbofes);
  *(unsigned int *)((unsigned char *)def_lct_hdr + hdrlen + len) = htonl(word);
  len += 4;
  return len;
}

variable_types:
m
unsigned char

variable_types:
G
unsigned char

variable_types:
mxnbofes
unsigned short


canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1, int a2, __int64 a3, int a4, unsigned __int16 a5, int a6, unsigned __int16 a7)
{
unsigned int v7; // er14

v7 = a3;
*(_DWORD *)(a1 + a2) = func0(WORD2(a3) | 0x40040000u);
*(_DWORD *)(a1 + a2 + 4) = func0(v7);
*(_DWORD *)(a1 + a2 + 8) = func0((a4 << 16) | (unsigned int)a5);
*(_DWORD *)(a1 + a2 + 12) = func0(a7 | (unsigned int)(a6 << 16));
return 16LL;
}

original_code:
int add_fti_129_lct_he(def_lct_hdr_t *def_lct_hdr, int hdrlen,
      unsigned long long transferlen,
      unsigned short fec_inst_id, unsigned short eslen,
      unsigned short max_sblen, unsigned short mxnbofes) {
 unsigned int word;
 unsigned short tmp;
 int len = 0;
 tmp = ((unsigned int)(transferlen >> 32) & 0x0000FFFF);
 word = ((64 << 24) | (4 << 16) | tmp);
 *(unsigned int*)((unsigned char*)def_lct_hdr + hdrlen) = htonl(word);
 len += 4;
 *(unsigned int*)((unsigned char*)def_lct_hdr + hdrlen + len) = htonl((unsigned int)transferlen);
 len += 4;
 word = ((fec_inst_id << 16) | eslen);
 *(unsigned int*)((unsigned char*)def_lct_hdr + hdrlen + len) = htonl(word);
 len += 4;
 word = ((max_sblen << 16) | mxnbofes);
 *(unsigned int*)((unsigned char*)def_lct_hdr + hdrlen + len) = htonl(word);
 len += 4;
 return len;
}

canonical_original_code:
int add_fti_129_lct_he(struct def_lct_hdr *def_lct_hdr, int hdrlen, unsigned long long transferlen, unsigned short fec_inst_id, unsigned short eslen, unsigned short max_sblen, unsigned short mxnbofes) {
 unsigned int word;
 unsigned short tmp;
 int len = 0;
 tmp = ((unsigned int)(transferlen >> 32) & 0x0000FFFF);
 word = ((64 << 24) | (4 << 16) | tmp);
 *(unsigned int *)((unsigned char *)def_lct_hdr + hdrlen) = htonl(word);
 len += 4;
 *(unsigned int *)((unsigned char *)def_lct_hdr + hdrlen + len) = htonl((unsigned int)transferlen);
 len += 4;
 word = ((fec_inst_id << 16) | eslen);
 *(unsigned int *)((unsigned char *)def_lct_hdr + hdrlen + len) = htonl(word);
 len += 4;
 word = ((max_sblen << 16) | mxnbofes);
 *(unsigned int *)((unsigned char *)def_lct_hdr + hdrlen + len) = htonl(word);
 len += 4;
 return len;
}


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

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

original_code:
int add_auth_lct_he(void) {
 int len = 0;
 return len;
}

canonical_original_code:
int add_auth_lct_he() {
 int len = 0;
 return len;
}


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

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

original_code:
int add_time_lct_he(void) {
 int len = 0;
 return len;
}

canonical_original_code:
int add_time_lct_he() {
 int len = 0;
 return len;
}


getdnsname

decompiled_code:
_DWORD *getdnsname()
{
struct hostent *v0; // rax
const char *v1; // rbp
size_t v2; // rax
size_t v3; // rax
_DWORD *v4; // rbx
unsigned int v5; // eax
size_t v6; // rax
_DWORD v8[262]; // [rsp+0h] [rbp-418h] BYREF

memset(v8, 0, 0x400uLL);
gethostname((char *)v8, 0x400uLL);
v0 = gethostbyname((const char *)v8);
if ( v0 )
{
memset(v8, 0, 0x400uLL);
v1 = v0->h_name;
v2 = strlen(v0->h_name);
memcpy(v8, v1, v2);
v3 = strlen((const char *)v8);
v4 = calloc(v3 + 1, 1uLL);
if ( v4 )
{
v5 = strlen((const char *)v8);
if ( v5 < 8 )
{
if ( (v5 & 4) != 0 )
{
*v4 = v8[0];
*(_DWORD *)((char *)v4 + v5 - 4) = *(_DWORD *)((char *)&v8[-1] + v5);
}
else if ( v5 )
{
*(_BYTE *)v4 = v8[0];
if ( (v5 & 2) != 0 )
*(_WORD *)((char *)v4 + v5 - 2) = *(_WORD *)((char *)v8 + v5 - 2);
}
return v4;
}
LABEL_19:
*(_QWORD *)((char *)v4 + v5 - 8) = *(_QWORD *)((char *)&v8[-2] + v5);
qmemcpy(v4, v8, 8LL * ((v5 - 1) >> 3));
return v4;
}
LABEL_14:
puts("Could not alloc memory for hostname!");
fflush(stdout);
return v4;
}
v6 = strlen((const char *)v8);
v4 = calloc(v6 + 1, 1uLL);
if ( !v4 )
goto LABEL_14;
v5 = strlen((const char *)v8);
if ( v5 >= 8 )
goto LABEL_19;
if ( (v5 & 4) != 0 )
{
*v4 = v8[0];
*(_DWORD *)((char *)v4 + v5 - 4) = *(_DWORD *)((char *)&v8[-1] + v5);
}
else if ( v5 )
{
*(_BYTE *)v4 = v8[0];
if ( (v5 & 2) != 0 )
*(_WORD *)((char *)v4 + v5 - 2) = *(_WORD *)((char *)v8 + v5 - 2);
}
return v4;
}

canonical_decompiled_code:
_DWORD *func0()
{
struct hostent *v0; // rax
const char *v1; // rbp
size_t v2; // rax
size_t v3; // rax
_DWORD *v4; // rbx
unsigned int v5; // eax
size_t v6; // rax
_DWORD v8[262]; // [rsp+0h] [rbp-418h] BYREF

memset(v8, 0, 0x400uLL);
gethostname((char *)v8, 0x400uLL);
v0 = gethostbyname((const char *)v8);
if ( v0 )
{
memset(v8, 0, 0x400uLL);
v1 = v0->h_name;
v2 = strlen(v0->h_name);
memcpy(v8, v1, v2);
v3 = strlen((const char *)v8);
v4 = calloc(v3 + 1, 1uLL);
if ( v4 )
{
v5 = strlen((const char *)v8);
if ( v5 < 8 )
{
if ( (v5 & 4) != 0 )
{
*v4 = v8[0];
*(_DWORD *)((char *)v4 + v5 - 4) = *(_DWORD *)((char *)&v8[-1] + v5);
}
else if ( v5 )
{
*(_BYTE *)v4 = v8[0];
if ( (v5 & 2) != 0 )
*(_WORD *)((char *)v4 + v5 - 2) = *(_WORD *)((char *)v8 + v5 - 2);
}
return v4;
}
LABEL_19:
*(_QWORD *)((char *)v4 + v5 - 8) = *(_QWORD *)((char *)&v8[-2] + v5);
qmemcpy(v4, v8, 8LL * ((v5 - 1) >> 3));
return v4;
}
LABEL_14:
puts("Could not alloc memory for hostname!");
fflush(stdout);
return v4;
}
v6 = strlen((const char *)v8);
v4 = calloc(v6 + 1, 1uLL);
if ( !v4 )
goto LABEL_14;
v5 = strlen((const char *)v8);
if ( v5 >= 8 )
goto LABEL_19;
if ( (v5 & 4) != 0 )
{
*v4 = v8[0];
*(_DWORD *)((char *)v4 + v5 - 4) = *(_DWORD *)((char *)&v8[-1] + v5);
}
else if ( v5 )
{
*(_BYTE *)v4 = v8[0];
if ( (v5 & 2) != 0 )
*(_WORD *)((char *)v4 + v5 - 2) = *(_WORD *)((char *)v8 + v5 - 2);
}
return v4;
}

original_code:
char* getdnsname() {
  char *hostname = ((void *)0);
  char host[1024];
  struct hostent *hptr;
  memset(host, 0, 1024);
  gethostname(host, 1024);
  if((hptr = gethostbyname(host)) == ((void *)0)) {
    if(!(hostname = (char*)calloc((strlen(host) + 1), sizeof(char)))) {
      printf("Could not alloc memory for hostname!\n");
      fflush(stdout);
      return ((void *)0);
    }
    memcpy(hostname, host, strlen(host));
    return hostname;
  }
  else {
    memset(host, 0, 1024);
    memcpy(host, hptr->h_name, strlen(hptr->h_name));
  }
  if(!(hostname = (char*)calloc((strlen(host) + 1), sizeof(char)))) {
    printf("Could not alloc memory for hostname!\n");
    fflush(stdout);
    return ((void *)0);
  }
  memcpy(hostname, host, strlen(host));
  return hostname;
}

canonical_original_code:
char *getdnsname() {
  char *hostname = ((void *)0);
  char host[1024];
  struct hostent *hptr;
  memset(host, 0, 1024);
  gethostname(host, 1024);
  if((hptr = gethostbyname(host)) == ((void *)0)) {
    if(!(hostname = (char *)calloc((strlen(host) + 1), sizeof(char)))) {
      printf("Could not alloc memory for hostname!\n");
      fflush(stdout);
      return ((void *)0);
    }
    memcpy(hostname, host, strlen(host));
    return hostname;
  }
  else {
    memset(host, 0, 1024);
    memcpy(host, hptr->h_name, strlen(hptr->h_name));
  }
  if(!(hostname = (char *)calloc((strlen(host) + 1), sizeof(char)))) {
    printf("Could not alloc memory for hostname!\n");
    fflush(stdout);
    return ((void *)0);
  }
  memcpy(hostname, host, strlen(host));
  return hostname;
}

variable_types:
hostname
char *

variable_types:
host
char [1024]

variable_types: struct hostent { char *h_name; char **h_aliases; int h_addrtype; int h_length; char **h_addr_list; } *


decompiled_code:
int __fastcall get_time_of_day(struct timeval *a1)
{
return gettimeofday(a1, 0LL);
}

canonical_decompiled_code:
int __fastcall func0(struct timeval *a1)
{
return gettimeofday(a1, 0LL);
}

original_code:
int get_time_of_day(struct timeval *tv){
  return gettimeofday(tv, ((void *)0));
}

variable_types: struct timeval { long tv_sec; long tv_usec; } *


decompiled_code:
int __fastcall lock_list(__int64 a1)
{
return pthread_mutex_lock((pthread_mutex_t *)(a1 + 16));
}

canonical_decompiled_code:
int __fastcall func1(__int64 a1)
{
return pthread_mutex_lock((pthread_mutex_t *)(a1 + 16));
}

original_code:
void lock_list(alc_list_t *a_list) {
  pthread_mutex_lock(&(a_list->session_variables_semaphore));
}

canonical_original_code:
void lock_list(struct alc_list *a_list) {
  pthread_mutex_lock(&(a_list->session_variables_semaphore));
}

variable_types: struct alc_list { struct alc_list_node { struct alc_list_node *next; void *data; } *first_elem; struct alc_list_node *last_elem; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } session_variables_semaphore; } *

user_defined_types: struct alc_list { struct alc_list_node *first_elem; struct alc_list_node *last_elem; union pthread_mutex_t session_variables_semaphore; }

user_defined_types: union pthread_mutex_t { struct __pthread_mutex_s __data; char __size[40]; long __align; }

user_defined_types: struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list __list; }


decompiled_code:
int __fastcall unlock_list(__int64 a1)
{
return pthread_mutex_unlock((pthread_mutex_t *)(a1 + 16));
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1)
{
return pthread_mutex_unlock((pthread_mutex_t *)(a1 + 16));
}

original_code:
void unlock_list(alc_list_t *a_list) {
  pthread_mutex_unlock(&(a_list->session_variables_semaphore));
}

canonical_original_code:
void unlock_list(struct alc_list *a_list) {
  pthread_mutex_unlock(&(a_list->session_variables_semaphore));
}

user_defined_types: struct alc_list_node { struct alc_list_node *next; void *data; }

user_defined_types: struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; }


decompiled_code:
_BOOL8 __fastcall is_empty_private(_QWORD *a1)
{
return *a1 == 0LL;
}

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

original_code:
int is_empty_private(const alc_list_t *a_list) {
 return a_list->first_elem == ((void *)0);
}

canonical_original_code:
int is_empty_private(struct alc_list *a_list) {
 return a_list->first_elem == ((void *)0);
}


decompiled_code:
int __fastcall push_back(__int64 a1, __int64 a2)
{
_QWORD *v2; // rax
_QWORD *v3; // rbp

v2 = prepare_insert(a2);
if ( v2 )
{
v3 = v2;
lock_list(a1);
if ( is_empty_private((_QWORD *)a1) )
*(_QWORD *)a1 = v3;
else
**(_QWORD **)(a1 + 8) = v3;
*(_QWORD *)(a1 + 8) = v3;
LODWORD(v2) = unlock_list(a1);
}
return (int)v2;
}

canonical_decompiled_code:
int __fastcall func4(__int64 a1, __int64 a2)
{
_QWORD *v2; // rax
_QWORD *v3; // rbp

v2 = prepare_insert(a2);
if ( v2 )
{
v3 = v2;
func1(a1);
if ( func3((_QWORD *)a1) )
*(_QWORD *)a1 = v3;
else
**(_QWORD **)(a1 + 8) = v3;
*(_QWORD *)(a1 + 8) = v3;
LODWORD(v2) = func2(a1);
}
return (int)v2;
}

original_code:
void push_back(alc_list_t *a_list, alc_rcv_container_t *a_data) {
  struct alc_list_node *my_node;
  my_node = prepare_insert(a_data);
  if(my_node == ((void *)0)) {
    return;
  }
  lock_list(a_list);
  if(is_empty_private(a_list)) {
    a_list->first_elem = my_node;
    a_list->last_elem = my_node;
  }
  else {
    a_list->last_elem->next = my_node;
    a_list->last_elem = my_node;
  }
  unlock_list(a_list);
}

canonical_original_code:
void push_back(struct alc_list *a_list, struct alc_rcv_container *a_data) {
  struct alc_list_node *my_node;
  my_node = prepare_insert(a_data);
  if(my_node == ((void *)0)) {
    return;
  }
  lock_list(a_list);
  if(is_empty_private(a_list)) {
    a_list->first_elem = my_node;
    a_list->last_elem = my_node;
  }
  else {
    a_list->last_elem->next = my_node;
    a_list->last_elem = my_node;
  }
  unlock_list(a_list);
}

variable_types: struct alc_rcv_container { char recvbuf[1500]; struct sockaddr_storage { unsigned short ss_family; char __ss_padding[-1]; unsigned long __ss_align; } from; unsigned int fromlen; int recvlen; struct timeval { long tv_sec; long tv_usec; } time_stamp; } *

variable_types: struct alc_list_node { struct alc_list_node *next; void *data; } *

user_defined_types: struct alc_rcv_container { char recvbuf[1500]; struct sockaddr_storage from; unsigned int fromlen; int recvlen; struct timeval time_stamp; }


decompiled_code:
int __fastcall push_front(_QWORD *a1, __int64 a2)
{
_QWORD *v2; // rax
_QWORD *v3; // rbp

v2 = prepare_insert(a2);
if ( v2 )
{
v3 = v2;
lock_list((__int64)a1);
if ( is_empty_private(a1) )
{
*a1 = v3;
a1[1] = v3;
}
else
{
*v3 = *a1;
*a1 = v3;
}
LODWORD(v2) = unlock_list((__int64)a1);
}
return (int)v2;
}

canonical_decompiled_code:
int __fastcall func5(_QWORD *a1, __int64 a2)
{
_QWORD *v2; // rax
_QWORD *v3; // rbp

v2 = prepare_insert(a2);
if ( v2 )
{
v3 = v2;
func1((__int64)a1);
if ( func3(a1) )
{
*a1 = v3;
a1[1] = v3;
}
else
{
*v3 = *a1;
*a1 = v3;
}
LODWORD(v2) = func2((__int64)a1);
}
return (int)v2;
}

original_code:
void push_front(alc_list_t *a_list, alc_rcv_container_t *a_data) {
  struct alc_list_node *my_node;
  my_node = prepare_insert(a_data);
  if(my_node == ((void *)0)) {
    return;
  }
  lock_list(a_list);
  if(is_empty_private(a_list)) {
    a_list->first_elem = my_node;
    a_list->last_elem = my_node;
  }
  else {
    my_node->next = a_list->first_elem;
    a_list->first_elem = my_node;
  }
  unlock_list(a_list);
}

canonical_original_code:
void push_front(struct alc_list *a_list, struct alc_rcv_container *a_data) {
  struct alc_list_node *my_node;
  my_node = prepare_insert(a_data);
  if(my_node == ((void *)0)) {
    return;
  }
  lock_list(a_list);
  if(is_empty_private(a_list)) {
    a_list->first_elem = my_node;
    a_list->last_elem = my_node;
  }
  else {
    my_node->next = a_list->first_elem;
    a_list->first_elem = my_node;
  }
  unlock_list(a_list);
}

user_defined_types: struct sockaddr_storage { unsigned short ss_family; char __ss_padding[-1]; unsigned long __ss_align; }


decompiled_code:
__int64 __fastcall pop_front(_QWORD *a1)
{
_QWORD *v1; // rbp
__int64 v2; // r12

lock_list((__int64)a1);
if ( is_empty_private(a1) )
{
v2 = 0LL;
v1 = 0LL;
}
else
{
v1 = (_QWORD *)*a1;
if ( a1[1] == *a1 )
{
if ( *v1 )
_assert_fail("my_node->next == NULL", "alc_list.c", 0xE2u, "pop_front");
*a1 = 0LL;
a1[1] = 0LL;
}
else
{
*a1 = *v1;
}
v2 = v1[1];
}
unlock_list((__int64)a1);
free(v1);
return v2;
}

original_code:
alc_rcv_container_t* pop_front(alc_list_t *a_list) {
  struct alc_list_node *my_node = ((void *)0);
  void *my_ret = ((void *)0);
  lock_list(a_list);
  if(is_empty_private(a_list)) {
  }
  else {
    my_node = a_list->first_elem;
    if(a_list->first_elem == a_list->last_elem) {
      ((void) sizeof ((my_node->next == ((void *)0)) ? 1 : 0), __extension__ ({ if (my_node->next == ((void *)0)) ; else __assert_fail ("my_node->next == NULL", "alc_list.c", 226, __extension__ __PRETTY_FUNCTION__); }));
      a_list->first_elem = ((void *)0);
      a_list->last_elem = ((void *)0);
    }
    else {
      a_list->first_elem = my_node->next;
    }
    my_ret = my_node->data;
  }
  unlock_list(a_list);
  free(my_node);
  return my_ret;
}

canonical_original_code:
struct alc_rcv_container *pop_front(struct alc_list *a_list) {
  struct alc_list_node *my_node = ((void *)0);
  void *my_ret = ((void *)0);
  lock_list(a_list);
  if(is_empty_private(a_list)) {
  }
  else {
    my_node = a_list->first_elem;
    if(a_list->first_elem == a_list->last_elem) {
      ((void) sizeof ((my_node->next == ((void *)0)) ? 1 : 0), __extension__ ({ if (my_node->next == ((void *)0)) ; else __assert_fail ("my_node->next == NULL", "alc_list.c", 226, __extension__ __PRETTY_FUNCTION__); }));
      a_list->first_elem = ((void *)0);
      a_list->last_elem = ((void *)0);
    }
    else {
      a_list->first_elem = my_node->next;
    }
    my_ret = my_node->data;
  }
  unlock_list(a_list);
  free(my_node);
  return my_ret;
}

return_type: struct alc_rcv_container { char recvbuf[1500]; struct sockaddr_storage { unsigned short ss_family; char __ss_padding[-1]; unsigned long __ss_align; } from; unsigned int fromlen; int recvlen; struct timeval { long tv_sec; long tv_usec; } time_stamp; } *


decompiled_code:
_BOOL8 __fastcall is_empty(_QWORD *a1)
{
_BOOL4 v1; // ebp

lock_list((__int64)a1);
v1 = *a1 == 0LL;
unlock_list((__int64)a1);
return v1;
}

canonical_decompiled_code:
_BOOL8 __fastcall func7(_QWORD *a1)
{
_BOOL4 v1; // ebp

func1((__int64)a1);
v1 = *a1 == 0LL;
func2((__int64)a1);
return v1;
}

original_code:
int is_empty(const alc_list_t *a_list) {
  int my_ret;
  lock_list((alc_list_t*)a_list);
  my_ret = (a_list->first_elem == ((void *)0));
 unlock_list((alc_list_t*)a_list);
 return my_ret;
}

canonical_original_code:
int is_empty(struct alc_list *a_list) {
  int my_ret;
  lock_list((struct alc_list *)a_list);
  my_ret = (a_list->first_elem == ((void *)0));
 unlock_list((struct alc_list *)a_list);
 return my_ret;
}


decompiled_code:
void *build_list()
{
return calloc(1uLL, 0x38uLL);
}

canonical_decompiled_code:
void *func8()
{
return calloc(1uLL, 0x38uLL);
}

original_code:
alc_list_t* build_list(void) {
  alc_list_t *my_list;
  my_list = calloc(1, sizeof(alc_list_t));
  my_list->session_variables_semaphore = (pthread_mutex_t){ { 0, 0, 0, 0, 0, 0, 0, { 0, 0 } } };
  return my_list;
}

canonical_original_code:
struct alc_list *build_list() {
  struct alc_list *my_list;
  my_list = calloc(1, sizeof(alc_list_t));
  my_list->session_variables_semaphore = (union pthread_mutex_t){ { 0, 0, 0, 0, 0, 0, 0, { 0, 0 } } };
  return my_list;
}

return_type: struct alc_list { struct alc_list_node { struct alc_list_node *next; void *data; } *first_elem; struct alc_list_node *last_elem; union pthread_mutex_t { struct __pthread_mutex_s { int __lock; unsigned int __count; int __owner; unsigned int __nusers; int __kind; short __spins; short __elision; struct __pthread_internal_list { struct __pthread_internal_list *__prev; struct __pthread_internal_list *__next; } __list; } __data; char __size[40]; long __align; } session_variables_semaphore; } *


decompiled_code:
void __fastcall destroy_list(void *ptr)
{
void **v1; // rbx
void **v2; // rbp

if ( ptr )
{
lock_list((__int64)ptr);
v1 = *(void ***)ptr;
if ( *(_QWORD *)ptr )
{
do
{
v2 = v1;
v1 = (void **)*v1;
free(v2[1]);
free(v2);
}
while ( v1 );
}
unlock_list((__int64)ptr);
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func9(void *ptr)
{
void **v1; // rbx
void **v2; // rbp

if ( ptr )
{
func1((__int64)ptr);
v1 = *(void ***)ptr;
if ( *(_QWORD *)ptr )
{
do
{
v2 = v1;
v1 = (void **)*v1;
free(v2[1]);
free(v2);
}
while ( v1 );
}
func2((__int64)ptr);
free(ptr);
}
}

original_code:
void destroy_list(alc_list_t *a_list) {
  struct alc_list_node *my_node = ((void *)0);
  struct alc_list_node *my_currentnode = ((void *)0);
  if(a_list == ((void *)0)) {
    return;
  }
  lock_list(a_list);
  for(my_node = a_list->first_elem; my_node != ((void *)0);) {
    my_currentnode = my_node;
    my_node = my_node->next;
    free(my_currentnode->data);
    free(my_currentnode);
  }
  unlock_list(a_list);
  free(a_list);
}

canonical_original_code:
void destroy_list(struct alc_list *a_list) {
  struct alc_list_node *my_node = ((void *)0);
  struct alc_list_node *my_currentnode = ((void *)0);
  if(a_list == ((void *)0)) {
    return;
  }
  lock_list(a_list);
  for(my_node = a_list->first_elem; my_node != ((void *)0);) {
    my_currentnode = my_node;
    my_node = my_node->next;
    free(my_currentnode->data);
    free(my_currentnode);
  }
  unlock_list(a_list);
  free(a_list);
}


decompiled_code:
char *__fastcall null_fec_decode_src_block(__int64 a1, _QWORD *a2, unsigned __int16 a3)
{
unsigned int v3; // edx
__int64 v4; // r14
char *v5; // r12
__int64 v6; // rbx
int v7; // ebp

v3 = *(_DWORD *)(a1 + 32) * a3;
v4 = v3;
v5 = (char *)calloc(v3 + 1, 1uLL);
if ( v5 )
{
v6 = *(_QWORD *)(a1 + 8);
if ( v6 )
{
v7 = 0;
do
{
memcpy(&v5[v7], *(const void **)(v6 + 24), *(unsigned __int16 *)(v6 + 20));
v7 += *(unsigned __int16 *)(v6 + 20);
v6 = *(_QWORD *)(v6 + 8);
}
while ( v6 );
}
*a2 = v4;
}
else
{
puts("Could not alloc memory for buf!");
}
return v5;
}

canonical_decompiled_code:
char *__fastcall func0(__int64 a1, _QWORD *a2, unsigned __int16 a3)
{
unsigned int v3; // edx
__int64 v4; // r14
char *v5; // r12
__int64 v6; // rbx
int v7; // ebp

v3 = *(_DWORD *)(a1 + 32) * a3;
v4 = v3;
v5 = (char *)calloc(v3 + 1, 1uLL);
if ( v5 )
{
v6 = *(_QWORD *)(a1 + 8);
if ( v6 )
{
v7 = 0;
do
{
memcpy(&v5[v7], *(const void **)(v6 + 24), *(unsigned __int16 *)(v6 + 20));
v7 += *(unsigned __int16 *)(v6 + 20);
v6 = *(_QWORD *)(v6 + 8);
}
while ( v6 );
}
*a2 = v4;
}
else
{
puts("Could not alloc memory for buf!");
}
return v5;
}

original_code:
char *null_fec_decode_src_block(trans_block_t *tr_block, unsigned long long *block_len,
        unsigned short eslen) {
 char *buf = ((void *)0);
    trans_unit_t *next_tu;
    trans_unit_t *tu;
 unsigned long long len;
 unsigned long long tmp;
    len = eslen*tr_block->k;
    if(!(buf = (char*)calloc((unsigned int)(len + 1), sizeof(char)))) {
        printf("Could not alloc memory for buf!\n");
        return ((void *)0);
    }
    tmp = 0;
 next_tu = tr_block->unit_list;
 while(next_tu != ((void *)0)) {
        tu = next_tu;
        memcpy((buf+(unsigned int)tmp), tu->data, tu->len);
        tmp += tu->len;
        next_tu = tu->next;
 }
 *block_len = len;
 return buf;
}

canonical_original_code:
char *null_fec_decode_src_block(struct trans_block *tr_block, unsigned long long *block_len, unsigned short eslen) {
 char *buf = ((void *)0);
    struct trans_unit *next_tu;
    struct trans_unit *tu;
 unsigned long long len;
 unsigned long long tmp;
    len = eslen*tr_block->k;
    if(!(buf = (char *)calloc((unsigned int)(len + 1), sizeof(char)))) {
        printf("Could not alloc memory for buf!\n");
        return ((void *)0);
    }
    tmp = 0;
 next_tu = tr_block->unit_list;
 while(next_tu != ((void *)0)) {
        tu = next_tu;
        memcpy((buf+(unsigned int)tmp), tu->data, tu->len);
        tmp += tu->len;
        next_tu = tu->next;
 }
 *block_len = len;
 return buf;
}

variable_types: struct trans_block { unsigned int sbn; struct trans_unit { struct trans_unit *prev; struct trans_unit *next; unsigned int esi; unsigned short len; char *data; long offset; unsigned char used; } *unit_list; struct trans_unit *last_unit; unsigned int nb_of_rx_units; unsigned int n; unsigned int k; unsigned int max_k; unsigned int max_n; unsigned char finite_field; } *

variable_types:
buf
char *

variable_types:
len
unsigned long long

variable_types:
tmp
unsigned long long

user_defined_types: struct trans_block { unsigned int sbn; struct trans_unit *unit_list; struct trans_unit *last_unit; unsigned int nb_of_rx_units; unsigned int n; unsigned int k; unsigned int max_k; unsigned int max_n; unsigned char finite_field; }


decompiled_code:
__int64 __fastcall add_alc_fpi_2_128(__int64 a1, int a2, unsigned int a3, unsigned int a4)
{
*(_DWORD *)(a1 + a2) = _bswap_32(a3);
*(_DWORD *)(a1 + a2 + 4) = _bswap_32(a4);
return 8LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, int a2, unsigned int a3, unsigned int a4)
{
*(_DWORD *)(a1 + a2) = func0(a3);
*(_DWORD *)(a1 + a2 + 4) = func0(a4);
return 8LL;
}

original_code:
int add_alc_fpi_2_128(def_lct_hdr_t *def_lct_hdr, int hdrlen, unsigned int sbn, unsigned int es_id) {
 int len = 0;
 *(unsigned int*)((unsigned char*)def_lct_hdr + hdrlen) = htonl(sbn);
 len += 4;
 *(unsigned int*)((unsigned char*)def_lct_hdr + hdrlen + len) = htonl(es_id);
 len += 4;
 return len;
}

canonical_original_code:
int add_alc_fpi_2_128(struct def_lct_hdr *def_lct_hdr, int hdrlen, unsigned int sbn, unsigned int es_id) {
 int len = 0;
 *(unsigned int *)((unsigned char *)def_lct_hdr + hdrlen) = htonl(sbn);
 len += 4;
 *(unsigned int *)((unsigned char *)def_lct_hdr + hdrlen + len) = htonl(es_id);
 len += 4;
 return len;
}

variable_types: struct def_lct_hdr { unsigned short flag_b; unsigned short flag_a; unsigned short flag_r; unsigned short flag_t; unsigned short flag_h; unsigned short flag_o; unsigned short flag_s; unsigned short reserved; unsigned short flag_c; unsigned short version; unsigned char hdr_len; unsigned char codepoint; unsigned int cci; } *

variable_types: hdrlen int

variable_types:
sbn
unsigned int

variable_types: len int


decompiled_code:
__int64 __fastcall add_alc_fpi_129(__int64 a1, int a2, unsigned int a3, int a4, unsigned __int16 a5)
{
*(_DWORD *)(a1 + a2) = _bswap_32(a3);
*(_DWORD *)(a1 + a2 + 4) = _bswap_32((a4 << 16) | (unsigned int)a5);
return 8LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, int a2, unsigned int a3, int a4, unsigned __int16 a5)
{
*(_DWORD *)(a1 + a2) = func0(a3);
*(_DWORD *)(a1 + a2 + 4) = func0((a4 << 16) | (unsigned int)a5);
return 8LL;
}

original_code:
int add_alc_fpi_129(def_lct_hdr_t *def_lct_hdr, int hdrlen, unsigned int sbn,
     unsigned short sbl, unsigned short es_id) {
 int len = 0;
 unsigned int word = 0;
 *(unsigned int*)((unsigned char*)def_lct_hdr + hdrlen) = htonl(sbn);
 len += 4;
 word = ((sbl << 16) | (es_id & 0xFFFF));
 *(unsigned int*)((unsigned char*)def_lct_hdr + hdrlen + len) = htonl(word);
 len += 4;
 return len;
}

canonical_original_code:
int add_alc_fpi_129(struct def_lct_hdr *def_lct_hdr, int hdrlen, unsigned int sbn, unsigned short sbl, unsigned short es_id) {
 int len = 0;
 unsigned int word = 0;
 *(unsigned int *)((unsigned char *)def_lct_hdr + hdrlen) = htonl(sbn);
 len += 4;
 word = ((sbl << 16) | (es_id & 0xFFFF));
 *(unsigned int *)((unsigned char *)def_lct_hdr + hdrlen + len) = htonl(word);
 len += 4;
 return len;
}

variable_types:
sbl
unsigned short

variable_types:
word
unsigned int


decompiled_code:
__int64 __fastcall add_alc_fpi_0_130(__int64 a1, int a2, int a3, unsigned __int16 a4)
{
*(_DWORD *)(a1 + a2) = _bswap_32((a3 << 16) | (unsigned int)a4);
return 4LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, int a2, int a3, unsigned __int16 a4)
{
*(_DWORD *)(a1 + a2) = func0((a3 << 16) | (unsigned int)a4);
return 4LL;
}

original_code:
int add_alc_fpi_0_130(def_lct_hdr_t *def_lct_hdr, int hdrlen, unsigned short sbn, unsigned short es_id) {
 int len = 0;
 unsigned int word = 0;
 word = ((sbn << 16) | (es_id & 0xFFFF));
 *(unsigned int*)((unsigned char*)def_lct_hdr + hdrlen) = htonl(word);
 len += 4;
 return len;
}

canonical_original_code:
int add_alc_fpi_0_130(struct def_lct_hdr *def_lct_hdr, int hdrlen, unsigned short sbn, unsigned short es_id) {
 int len = 0;
 unsigned int word = 0;
 word = ((sbn << 16) | (es_id & 0xFFFF));
 *(unsigned int *)((unsigned char *)def_lct_hdr + hdrlen) = htonl(word);
 len += 4;
 return len;
}

variable_types:
sbn
unsigned short


decompiled_code:
__int64 __fastcall add_alc_fpi_3(__int64 a1, int a2, int a3, int a4, char a5)
{
*(_DWORD *)(a1 + a2) = _bswap_32((a3 << a5) | a4 & (unsigned int)((1 << a5) - 1));
return 4LL;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, int a2, int a3, int a4, char a5)
{
*(_DWORD *)(a1 + a2) = func0((a3 << a5) | a4 & (unsigned int)((1 << a5) - 1));
return 4LL;
}

original_code:
int add_alc_fpi_3(def_lct_hdr_t *def_lct_hdr, int hdrlen, unsigned int sbn,
    unsigned int es_id, unsigned char m) {
 int len = 0;
 unsigned int word = 0;
 word = ((sbn << m) | (es_id & ((1 << m) - 1)));
 *(unsigned int*)((unsigned char*)def_lct_hdr + hdrlen) = htonl(word);
 len += 4;
 return len;
}

canonical_original_code:
int add_alc_fpi_3(struct def_lct_hdr *def_lct_hdr, int hdrlen, unsigned int sbn, unsigned int es_id, unsigned char m) {
 int len = 0;
 unsigned int word = 0;
 word = ((sbn << m) | (es_id & ((1 << m) - 1)));
 *(unsigned int *)((unsigned char *)def_lct_hdr + hdrlen) = htonl(word);
 len += 4;
 return len;
}

variable_types:
m
unsigned char


decompiled_code:
__int64 __fastcall osip_list_init(_QWORD *a1)
{
if ( !a1 )
return 0xFFFFFFFFLL;
*a1 = 0LL;
a1[1] = 0LL;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1)
{
if ( !a1 )
return 0xFFFFFFFFLL;
*a1 = 0LL;
a1[1] = 0LL;
return 0LL;
}

original_code:
int
osip_list_init (osip_list_t * li)
{
  if (li == ((void *)0))
    return -1;
  memset (li, 0, sizeof (osip_list_t));
  return 0;
}

canonical_original_code:
int osip_list_init(struct osip_list *li)
{
  if (li == ((void *)0))
    return -1;
  memset (li, 0, sizeof (osip_list_t));
  return 0;
}

variable_types: struct osip_list { int nb_elt; struct __node { void *next; void *element; } *node; } *

user_defined_types: struct osip_list { int nb_elt; struct __node *node; }


decompiled_code:
__int64 __fastcall osip_list_size(unsigned int *a1)
{
__int64 result; // rax

if ( a1 )
result = *a1;
else
result = 0xFFFFFFFFLL;
return result;
}

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

if ( a1 )
result = *a1;
else
result = 0xFFFFFFFFLL;
return result;
}

original_code:
int
osip_list_size (const osip_list_t * li)
{
  if (li != ((void *)0))
    return li->nb_elt;
  else
    return -1;
}

canonical_original_code:
int osip_list_size(struct osip_list *li)
{
  if (li != ((void *)0))
    return li->nb_elt;
  else
    return -1;
}

user_defined_types: struct __node { void *next; void *element; }


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

if ( a1 )
result = *a1 <= a2;
else
result = 0xFFFFFFFFLL;
return result;
}

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

if ( a1 )
result = *a1 <= a2;
else
result = 0xFFFFFFFFLL;
return result;
}

original_code:
int
osip_list_eol (const osip_list_t * li, int i)
{
  if (li == ((void *)0))
    return -1;
  if (i < li->nb_elt)
    return 0;
  return 1;
}

canonical_original_code:
int osip_list_eol(struct osip_list *li, int i)
{
  if (li == ((void *)0))
    return -1;
  if (i < li->nb_elt)
    return 0;
  return 1;
}

variable_types: i int


decompiled_code:
__int64 __fastcall osip_list_add(__int64 a1, __int64 a2, int a3)
{
int v3; // ecx
_QWORD *v4; // rax
__int64 result; // rax
_QWORD *v6; // rbp
int v7; // eax
_QWORD *v8; // r13
_QWORD *v9; // rax
_QWORD *v10; // rax
_QWORD *v11; // rax

if ( !a1 )
return 0xFFFFFFFFLL;
v3 = *(_DWORD *)a1;
if ( !*(_DWORD *)a1 )
{
if ( osip_malloc_func )
v4 = (_QWORD *)osip_malloc_func(16LL);
else
v4 = malloc(0x10uLL);
*(_QWORD *)(a1 + 8) = v4;
if ( !v4 )
return 0xFFFFFFFFLL;
v4[1] = a2;
**(_QWORD **)(a1 + 8) = 0LL;
result = (unsigned int)(*(_DWORD *)a1 + 1);
*(_DWORD *)a1 = result;
return result;
}
if ( v3 <= a3 || a3 == -1 )
{
v6 = *(_QWORD **)(a1 + 8);
a3 = *(_DWORD *)a1;
if ( v3 <= 1 )
{
LABEL_26:
if ( osip_malloc_func )
v11 = (_QWORD *)osip_malloc_func(16LL);
else
v11 = malloc(0x10uLL);
*v6 = v11;
if ( !v11 )
return 0xFFFFFFFFLL;
v11[1] = a2;
*v11 = 0LL;
result = (unsigned int)(*(_DWORD *)a1 + 1);
*(_DWORD *)a1 = result;
return result;
}
LABEL_12:
v7 = 0;
do
{
v6 = (_QWORD *)*v6;
++v7;
}
while ( v7 != a3 - 1 );
if ( v3 != a3 )
{
LABEL_15:
v8 = (_QWORD *)*v6;
if ( osip_malloc_func )
v9 = (_QWORD *)osip_malloc_func(16LL);
else
v9 = malloc(0x10uLL);
*v6 = v9;
if ( v9 )
{
v9[1] = a2;
*v9 = v8;
result = (unsigned int)(*(_DWORD *)a1 + 1);
*(_DWORD *)a1 = result;
}
else
{
*v6 = v8;
result = 0xFFFFFFFFLL;
}
return result;
}
goto LABEL_26;
}
v6 = *(_QWORD **)(a1 + 8);
if ( a3 )
{
if ( a3 <= 1 )
goto LABEL_15;
goto LABEL_12;
}
if ( osip_malloc_func )
v10 = (_QWORD *)osip_malloc_func(16LL);
else
v10 = malloc(0x10uLL);
*(_QWORD *)(a1 + 8) = v10;
if ( v10 )
{
v10[1] = a2;
**(_QWORD **)(a1 + 8) = v6;
result = (unsigned int)(*(_DWORD *)a1 + 1);
*(_DWORD *)a1 = result;
}
else
{
*(_QWORD *)(a1 + 8) = v6;
result = 0xFFFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, __int64 a2, int a3)
{
int v3; // ecx
_QWORD *v4; // rax
__int64 result; // rax
_QWORD *v6; // rbp
int v7; // eax
_QWORD *v8; // r13
_QWORD *v9; // rax
_QWORD *v10; // rax
_QWORD *v11; // rax

if ( !a1 )
return 0xFFFFFFFFLL;
v3 = *(_DWORD *)a1;
if ( !*(_DWORD *)a1 )
{
if ( osip_malloc_func )
v4 = (_QWORD *)osip_malloc_func(16LL);
else
v4 = malloc(0x10uLL);
*(_QWORD *)(a1 + 8) = v4;
if ( !v4 )
return 0xFFFFFFFFLL;
v4[1] = a2;
**(_QWORD **)(a1 + 8) = 0LL;
result = (unsigned int)(*(_DWORD *)a1 + 1);
*(_DWORD *)a1 = result;
return result;
}
if ( v3 <= a3 || a3 == -1 )
{
v6 = *(_QWORD **)(a1 + 8);
a3 = *(_DWORD *)a1;
if ( v3 <= 1 )
{
LABEL_26:
if ( osip_malloc_func )
v11 = (_QWORD *)osip_malloc_func(16LL);
else
v11 = malloc(0x10uLL);
*v6 = v11;
if ( !v11 )
return 0xFFFFFFFFLL;
v11[1] = a2;
*v11 = 0LL;
result = (unsigned int)(*(_DWORD *)a1 + 1);
*(_DWORD *)a1 = result;
return result;
}
LABEL_12:
v7 = 0;
do
{
v6 = (_QWORD *)*v6;
++v7;
}
while ( v7 != a3 - 1 );
if ( v3 != a3 )
{
LABEL_15:
v8 = (_QWORD *)*v6;
if ( osip_malloc_func )
v9 = (_QWORD *)osip_malloc_func(16LL);
else
v9 = malloc(0x10uLL);
*v6 = v9;
if ( v9 )
{
v9[1] = a2;
*v9 = v8;
result = (unsigned int)(*(_DWORD *)a1 + 1);
*(_DWORD *)a1 = result;
}
else
{
*v6 = v8;
result = 0xFFFFFFFFLL;
}
return result;
}
goto LABEL_26;
}
v6 = *(_QWORD **)(a1 + 8);
if ( a3 )
{
if ( a3 <= 1 )
goto LABEL_15;
goto LABEL_12;
}
if ( osip_malloc_func )
v10 = (_QWORD *)osip_malloc_func(16LL);
else
v10 = malloc(0x10uLL);
*(_QWORD *)(a1 + 8) = v10;
if ( v10 )
{
v10[1] = a2;
**(_QWORD **)(a1 + 8) = v6;
result = (unsigned int)(*(_DWORD *)a1 + 1);
*(_DWORD *)a1 = result;
}
else
{
*(_QWORD *)(a1 + 8) = v6;
result = 0xFFFFFFFFLL;
}
return result;
}

original_code:
int
osip_list_add (osip_list_t * li, void *el, int pos)
{
  __node_t *ntmp;
  int i = 0;
  if (li == ((void *)0))
    return -1;
  if (li->nb_elt == 0)
    {
      li->node = (__node_t *) (osip_malloc_func?osip_malloc_func(sizeof (__node_t)):malloc(sizeof (__node_t)));
      if (li->node == ((void *)0))
        return -1;
      li->node->element = el;
      li->node->next = ((void *)0);
      li->nb_elt++;
      return li->nb_elt;
    }
  if (pos == -1 || pos >= li->nb_elt)
    {
      pos = li->nb_elt;
    }
  ntmp = li->node;
  if (pos == 0)
    {
      li->node = (__node_t *) (osip_malloc_func?osip_malloc_func(sizeof (__node_t)):malloc(sizeof (__node_t)));
      if (li->node == ((void *)0))
        {
          li->node = ntmp;
          return -1;
        }
      li->node->element = el;
      li->node->next = ntmp;
      li->nb_elt++;
      return li->nb_elt;
    }
  while (pos > i + 1)
    {
      i++;
      ntmp = (__node_t *) ntmp->next;
    }
  if (pos == li->nb_elt)
    {
      ntmp->next = (__node_t *) (osip_malloc_func?osip_malloc_func(sizeof (__node_t)):malloc(sizeof (__node_t)));
      if (ntmp->next == ((void *)0))
        return -1;
      ntmp = (__node_t *) ntmp->next;
      ntmp->element = el;
      ntmp->next = ((void *)0);
      li->nb_elt++;
      return li->nb_elt;
    }
  {
    __node_t *nextnode = (__node_t *) ntmp->next;
    ntmp->next = (__node_t *) (osip_malloc_func?osip_malloc_func(sizeof (__node_t)):malloc(sizeof (__node_t)));
    if (ntmp->next == ((void *)0))
      {
        ntmp->next = nextnode;
        return -1;
      }
    ntmp = (__node_t *) ntmp->next;
    ntmp->element = el;
    ntmp->next = nextnode;
    li->nb_elt++;
  }
  return li->nb_elt;
}

canonical_original_code:
int osip_list_add(struct osip_list *li, void *el, int pos)
{
  struct __node *ntmp;
  int i = 0;
  if (li == ((void *)0))
    return -1;
  if (li->nb_elt == 0)
    {
      li->node = (struct __node *) (osip_malloc_func?osip_malloc_func(sizeof (__node_t)):malloc(sizeof (__node_t)));
      if (li->node == ((void *)0))
        return -1;
      li->node->element = el;
      li->node->next = ((void *)0);
      li->nb_elt++;
      return li->nb_elt;
    }
  if (pos == -1 || pos >= li->nb_elt)
    {
      pos = li->nb_elt;
    }
  ntmp = li->node;
  if (pos == 0)
    {
      li->node = (struct __node *) (osip_malloc_func?osip_malloc_func(sizeof (__node_t)):malloc(sizeof (__node_t)));
      if (li->node == ((void *)0))
        {
          li->node = ntmp;
          return -1;
        }
      li->node->element = el;
      li->node->next = ntmp;
      li->nb_elt++;
      return li->nb_elt;
    }
  while (pos > i + 1)
    {
      i++;
      ntmp = (struct __node *) ntmp->next;
    }
  if (pos == li->nb_elt)
    {
      ntmp->next = (struct __node *) (osip_malloc_func?osip_malloc_func(sizeof (__node_t)):malloc(sizeof (__node_t)));
      if (ntmp->next == ((void *)0))
        return -1;
      ntmp = (struct __node *) ntmp->next;
      ntmp->element = el;
      ntmp->next = ((void *)0);
      li->nb_elt++;
      return li->nb_elt;
    }
  {
    struct __node *nextnode = (__node_t *) ntmp->next;
    ntmp->next = (struct __node *) (osip_malloc_func?osip_malloc_func(sizeof (__node_t)):malloc(sizeof (__node_t)));
    if (ntmp->next == ((void *)0))
      {
        ntmp->next = nextnode;
        return -1;
      }
    ntmp = (struct __node *) ntmp->next;
    ntmp->element = el;
    ntmp->next = nextnode;
    li->nb_elt++;
  }
  return li->nb_elt;
}

variable_types:
el
void *

variable_types: pos int

variable_types: struct __node { void *next; void *element; } *


decompiled_code:
__int64 __fastcall osip_list_get(__int64 a1, int a2)
{
_QWORD *v2; // rdx
int i; // eax

if ( a2 < 0 || !a1 )
return 0LL;
if ( *(_DWORD *)a1 <= a2 )
return 0LL;
v2 = *(_QWORD **)(a1 + 8);
if ( a2 > 0 )
{
for ( i = 0; i != a2; ++i )
v2 = (_QWORD *)*v2;
}
return v2[1];
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, int a2)
{
_QWORD *v2; // rdx
int i; // eax

if ( a2 < 0 || !a1 )
return 0LL;
if ( *(_DWORD *)a1 <= a2 )
return 0LL;
v2 = *(_QWORD **)(a1 + 8);
if ( a2 > 0 )
{
for ( i = 0; i != a2; ++i )
v2 = (_QWORD *)*v2;
}
return v2[1];
}

original_code:
void *
osip_list_get (const osip_list_t * li, int pos)
{
  __node_t *ntmp;
  int i = 0;
  if (li == ((void *)0))
    return ((void *)0);
  if (pos < 0 || pos >= li->nb_elt)
    return ((void *)0);
  ntmp = li->node;
  while (pos > i)
    {
      i++;
      ntmp = (__node_t *) ntmp->next;
    }
  return ntmp->element;
}

canonical_original_code:
void *osip_list_get(struct osip_list *li, int pos)
{
  struct __node *ntmp;
  int i = 0;
  if (li == ((void *)0))
    return ((void *)0);
  if (pos < 0 || pos >= li->nb_elt)
    return ((void *)0);
  ntmp = li->node;
  while (pos > i)
    {
      i++;
      ntmp = (struct __node *) ntmp->next;
    }
  return ntmp->element;
}

return_type: void *


original_code:
void *
osip_list_get_first (osip_list_t * li, osip_list_iterator_t * iterator)
{
  if (0 >= li->nb_elt)
    {
      iterator->actual = 0;
      return 0;
    }
  iterator->actual = li->node;
  iterator->prev = &li->node;
  iterator->li = li;
  iterator->pos = 0;
  return li->node->element;
}

canonical_original_code:
void *osip_list_get_first(struct osip_list *li, struct osip_list_iterator_t *iterator)
{
  if (0 >= li->nb_elt)
    {
      iterator->actual = 0;
      return 0;
    }
  iterator->actual = li->node;
  iterator->prev = &li->node;
  iterator->li = li;
  iterator->pos = 0;
  return li->node->element;
}

variable_types: struct osip_list_iterator_t { struct __node *actual; struct __node **prev; struct osip_list *li; int pos; } *


original_code:
void *
osip_list_get_next (osip_list_iterator_t * iterator)
{
  iterator->prev = (__node_t **) & (iterator->actual->next);
  iterator->actual = iterator->actual->next;
  ++(iterator->pos);
  if (( 0 != (*iterator).actual && (*iterator).pos < (*iterator).li->nb_elt ))
    {
      return iterator->actual->element;
    }
  iterator->actual = 0;
  return 0;
}

canonical_original_code:
void *osip_list_get_next(struct osip_list_iterator_t *iterator)
{
  iterator->prev = (struct __node **) & (iterator->actual->next);
  iterator->actual = iterator->actual->next;
  ++(iterator->pos);
  if (( 0 != (*iterator).actual && (*iterator).pos < (*iterator).li->nb_elt ))
    {
      return iterator->actual->element;
    }
  iterator->actual = 0;
  return 0;
}

variable_types: struct osip_list_iterator_t { struct __node { void *next; void *element; } *actual; struct __node **prev; struct osip_list { int nb_elt; struct __node *node; } *li; int pos; } *

user_defined_types: struct osip_list_iterator_t { struct __node *actual; struct __node **prev; struct osip_list *li; int pos; }


decompiled_code:
__int64 __fastcall osip_list_remove(int *a1, int a2)
{
int v3; // eax
_QWORD **v4; // rdi
int v5; // eax
_QWORD **v6; // rax
__int64 result; // rax

if ( a2 < 0 )
return 0xFFFFFFFFLL;
if ( !a1 )
return 0xFFFFFFFFLL;
v3 = *a1;
if ( *a1 <= a2 )
return 0xFFFFFFFFLL;
v4 = (_QWORD **)*((_QWORD *)a1 + 1);
if ( a2 )
{
v5 = 0;
if ( a2 > 1 )
{
do
{
v4 = (_QWORD **)*v4;
++v5;
}
while ( v5 != a2 - 1 );
}
v6 = (_QWORD **)*v4;
*v4 = (_QWORD *)**v4;
if ( osip_free_func )
osip_free_func(v6);
else
free(v6);
result = (unsigned int)(*a1 - 1);
*a1 = result;
}
else
{
*((_QWORD *)a1 + 1) = *v4;
*a1 = v3 - 1;
if ( osip_free_func )
((void (*)(void))osip_free_func)();
else
free(v4);
result = (unsigned int)*a1;
}
return result;
}

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

if ( a2 < 0 )
return 0xFFFFFFFFLL;
if ( !a1 )
return 0xFFFFFFFFLL;
v3 = *a1;
if ( *a1 <= a2 )
return 0xFFFFFFFFLL;
v4 = (_QWORD **)*((_QWORD *)a1 + 1);
if ( a2 )
{
v5 = 0;
if ( a2 > 1 )
{
do
{
v4 = (_QWORD **)*v4;
++v5;
}
while ( v5 != a2 - 1 );
}
v6 = (_QWORD **)*v4;
*v4 = (_QWORD *)**v4;
if ( osip_free_func )
osip_free_func(v6);
else
free(v6);
result = (unsigned int)(*a1 - 1);
*a1 = result;
}
else
{
*((_QWORD *)a1 + 1) = *v4;
*a1 = v3 - 1;
if ( osip_free_func )
((void (*)(void))osip_free_func)();
else
free(v4);
result = (unsigned int)*a1;
}
return result;
}

original_code:
int
osip_list_remove (osip_list_t * li, int pos)
{
  __node_t *ntmp;
  int i = 0;
  if (li == ((void *)0))
    return -1;
  if (pos < 0 || pos >= li->nb_elt)
    return -1;
  ntmp = li->node;
  if ((pos == 0))
    {
      li->node = (__node_t *) ntmp->next;
      li->nb_elt--;
      { if (ntmp!=((void *)0)) { if (osip_free_func) osip_free_func(ntmp); else free(ntmp);} };
      return li->nb_elt;
    }
  while (pos > i + 1)
    {
      i++;
      ntmp = (__node_t *) ntmp->next;
    }
  {
    __node_t *remnode;
    remnode = (__node_t *) ntmp->next;
    ntmp->next = ((__node_t *) ntmp->next)->next;
    { if (remnode!=((void *)0)) { if (osip_free_func) osip_free_func(remnode); else free(remnode);} };
    li->nb_elt--;
  }
  return li->nb_elt;
}

canonical_original_code:
int osip_list_remove(struct osip_list *li, int pos)
{
  struct __node *ntmp;
  int i = 0;
  if (li == ((void *)0))
    return -1;
  if (pos < 0 || pos >= li->nb_elt)
    return -1;
  ntmp = li->node;
  if ((pos == 0))
    {
      li->node = (struct __node *) ntmp->next;
      li->nb_elt--;
      { if (ntmp!=((void *)0)) { if (osip_free_func) osip_free_func(ntmp); else free(ntmp);} };
      return li->nb_elt;
    }
  while (pos > i + 1)
    {
      i++;
      ntmp = (struct __node *) ntmp->next;
    }
  {
    struct __node *remnode;
    remnode = (struct __node *) ntmp->next;
    ntmp->next = ((struct __node *) ntmp->next)->next;
    { if (remnode!=((void *)0)) { if (osip_free_func) osip_free_func(remnode); else free(remnode);} };
    li->nb_elt--;
  }
  return li->nb_elt;
}


decompiled_code:
void __fastcall osip_list_special_free(void *ptr, void (__fastcall *a2)(__int64))
{
__int64 v2; // rbp

if ( ptr )
{
while ( !(unsigned int)osip_list_eol(ptr, 0) )
{
v2 = osip_list_get((__int64)ptr, 0);
osip_list_remove((int *)ptr, 0);
if ( a2 )
a2(v2);
}
if ( osip_free_func )
osip_free_func(ptr);
else
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func8(void *ptr, void (__fastcall *a2)(__int64))
{
__int64 v2; // rbp

if ( ptr )
{
while ( !(unsigned int)func2(ptr, 0) )
{
v2 = func4((__int64)ptr, 0);
func7((int *)ptr, 0);
if ( a2 )
a2(v2);
}
if ( osip_free_func )
osip_free_func(ptr);
else
free(ptr);
}
}

original_code:
void
osip_list_special_free (osip_list_t * li, void *(*free_func) (void *))
{
  int pos = 0;
  void *element;
  if (li == ((void *)0))
    return;
  while (!osip_list_eol (li, pos))
    {
      element = (void *) osip_list_get (li, pos);
      osip_list_remove (li, pos);
      if (free_func != ((void *)0))
        free_func (element);
    }
  { if (li!=((void *)0)) { if (osip_free_func) osip_free_func(li); else free(li);} };
}

canonical_original_code:
void osip_list_special_free(struct osip_list *li, void *(*free_func)(void *))
{
  int pos = 0;
  void *element;
  if (li == ((void *)0))
    return;
  while (!osip_list_eol (li, pos))
    {
      element = (void *) osip_list_get (li, pos);
      osip_list_remove (li, pos);
      if (free_func != ((void *)0))
        free_func (element);
    }
  { if (li!=((void *)0)) { if (osip_free_func) osip_free_func(li); else free(li);} };
}

variable_types:
element
void *


decompiled_code:
void __fastcall osip_list_ofchar_free(void *ptr)
{
void *v1; // rbx

if ( ptr )
{
while ( !(unsigned int)osip_list_eol(ptr, 0) )
{
v1 = (void *)osip_list_get((__int64)ptr, 0);
osip_list_remove((int *)ptr, 0);
if ( v1 )
{
if ( osip_free_func )
osip_free_func(v1);
else
free(v1);
}
}
if ( osip_free_func )
osip_free_func(ptr);
else
free(ptr);
}
}

canonical_decompiled_code:
void __fastcall func9(void *ptr)
{
void *v1; // rbx

if ( ptr )
{
while ( !(unsigned int)func2(ptr, 0) )
{
v1 = (void *)func4((__int64)ptr, 0);
func7((int *)ptr, 0);
if ( v1 )
{
if ( osip_free_func )
osip_free_func(v1);
else
free(v1);
}
}
if ( osip_free_func )
osip_free_func(ptr);
else
free(ptr);
}
}

original_code:
void
osip_list_ofchar_free (osip_list_t * li)
{
  int pos = 0;
  char *chain;
  if (li == ((void *)0))
    return;
  while (!osip_list_eol (li, pos))
    {
      chain = (char *) osip_list_get (li, pos);
      osip_list_remove (li, pos);
      { if (chain!=((void *)0)) { if (osip_free_func) osip_free_func(chain); else free(chain);} };
    }
  { if (li!=((void *)0)) { if (osip_free_func) osip_free_func(li); else free(li);} };
}

canonical_original_code:
void osip_list_ofchar_free(struct osip_list *li)
{
  int pos = 0;
  char *chain;
  if (li == ((void *)0))
    return;
  while (!osip_list_eol (li, pos))
    {
      chain = (char *) osip_list_get (li, pos);
      osip_list_remove (li, pos);
      { if (chain!=((void *)0)) { if (osip_free_func) osip_free_func(chain); else free(chain);} };
    }
  { if (li!=((void *)0)) { if (osip_free_func) osip_free_func(li); else free(li);} };
}

variable_types:
chain
char *


decompiled_code:
int __fastcall add_fec_plid_128(unsigned int a1, unsigned int a2)
{
putchar(HIBYTE(a1));
putchar(BYTE2(a1));
putchar(BYTE1(a1));
putchar((unsigned __int8)a1);
putchar(HIBYTE(a2));
putchar(BYTE2(a2));
putchar(BYTE1(a2));
return putchar((unsigned __int8)a2);
}

canonical_decompiled_code:
int __fastcall func0(unsigned int a1, unsigned int a2)
{
putchar(HIBYTE(a1));
putchar(BYTE2(a1));
putchar(BYTE1(a1));
putchar((unsigned __int8)a1);
putchar(HIBYTE(a2));
putchar(BYTE2(a2));
putchar(BYTE1(a2));
return putchar((unsigned __int8)a2);
}

original_code:
void add_fec_plid_128(unsigned int sbn, unsigned int esi) {
  printf("%c", (unsigned char)((sbn >> 24) & 0xFF));
  printf("%c", (unsigned char)((sbn >> 16) & 0xFF));
  printf("%c", (unsigned char)((sbn >> 8) & 0xFF));
  printf("%c", (unsigned char)(sbn & 0xFF));
  printf("%c", (unsigned char)((esi >> 24) & 0xFF));
  printf("%c", (unsigned char)((esi >> 16) & 0xFF));
  printf("%c", (unsigned char)((esi >> 8) & 0xFF));
  printf("%c", (unsigned char)(esi & 0xFF));
}

variable_types:
esi
unsigned int


decompiled_code:
int __fastcall add_fec_plid_129(unsigned int a1, __int16 a2, __int16 a3)
{
putchar(HIBYTE(a1));
putchar(BYTE2(a1));
putchar(BYTE1(a1));
putchar((unsigned __int8)a1);
putchar(HIBYTE(a2));
putchar((unsigned __int8)a2);
putchar(HIBYTE(a3));
return putchar((unsigned __int8)a3);
}

canonical_decompiled_code:
int __fastcall func1(unsigned int a1, __int16 a2, __int16 a3)
{
putchar(HIBYTE(a1));
putchar(BYTE2(a1));
putchar(BYTE1(a1));
putchar((unsigned __int8)a1);
putchar(HIBYTE(a2));
putchar((unsigned __int8)a2);
putchar(HIBYTE(a3));
return putchar((unsigned __int8)a3);
}

original_code:
void add_fec_plid_129(unsigned int sbn, unsigned short sbl, unsigned short esi) {
  printf("%c", (unsigned char)((sbn >> 24) & 0xFF));
  printf("%c", (unsigned char)((sbn >> 16) & 0xFF));
  printf("%c", (unsigned char)((sbn >> 8) & 0xFF));
  printf("%c", (unsigned char)(sbn & 0xFF));
  printf("%c", (unsigned char)((sbl >> 8) & 0xFF));
  printf("%c", (unsigned char)(sbl & 0xFF));
  printf("%c", (unsigned char)((esi >> 8) & 0xFF));
  printf("%c", (unsigned char)(esi & 0xFF));
}

variable_types:
esi
unsigned short


decompiled_code:
int __fastcall add_fec_plid_0_130(__int16 a1, __int16 a2)
{
putchar(HIBYTE(a1));
putchar((unsigned __int8)a1);
putchar(HIBYTE(a2));
return putchar((unsigned __int8)a2);
}

canonical_decompiled_code:
int __fastcall func2(__int16 a1, __int16 a2)
{
putchar(HIBYTE(a1));
putchar((unsigned __int8)a1);
putchar(HIBYTE(a2));
return putchar((unsigned __int8)a2);
}

original_code:
void add_fec_plid_0_130(unsigned short sbn, unsigned short esi) {
  printf("%c", (unsigned char)((sbn >> 8) & 0xFF));
  printf("%c", (unsigned char)(sbn & 0xFF));
  printf("%c", (unsigned char)((esi >> 8) & 0xFF));
  printf("%c", (unsigned char)(esi & 0xFF));
}


decompiled_code:
int __fastcall add_length_indicator(__int16 a1)
{
putchar(HIBYTE(a1));
return putchar((unsigned __int8)a1);
}

canonical_decompiled_code:
int __fastcall func3(__int16 a1)
{
putchar(HIBYTE(a1));
return putchar((unsigned __int8)a1);
}

original_code:
void add_length_indicator(unsigned short li) {
  printf("%c", (unsigned char)((li >> 8) & 0xFF));
  printf("%c", (unsigned char)(li & 0xFF));
}

variable_types:
li
unsigned short


original_code:
char* buffer_zlib_compress(char *buf,
       unsigned long long buflen,
       unsigned long long *comprlen
         ) {
 int err;
 Byte *compr;
 uLong comprLen;
    comprLen = (uLong)ceil((double)1.001*(double)(unsigned int)buflen) + 12;
 if((compr = (Byte*)calloc((uInt)comprLen, 1)) == 0) {
        printf("out of memory\n");
  fflush(stdout);
        return ((void *)0);
    }
 if((err = compress(compr, &comprLen, (const Bytef*)buf, (unsigned int)buflen)) != 0) {
        printf("Error: %d in buffer_compress\n", err);
  return ((void *)0);
    }
 *comprlen = comprLen;
 return (char*)compr;
}

canonical_original_code:
char *buffer_zlib_compress(char *buf, unsigned long long buflen, unsigned long long *comprlen) {
 int err;
 unsigned char *compr;
 unsigned long comprLen;
    comprLen = (unsigned long)ceil((double)1.001*(double)(unsigned int)buflen) + 12;
 if((compr = (unsigned char *)calloc((unsigned int)comprLen, 1)) == 0) {
        printf("out of memory\n");
  fflush(stdout);
        return ((void *)0);
    }
 if((err = compress(compr, &comprLen, (unsigned char *)buf, (unsigned int)buflen)) != 0) {
        printf("Error: %d in buffer_compress\n", err);
  return ((void *)0);
    }
 *comprlen = comprLen;
 return (char *)compr;
}

variable_types:
buf
char *

variable_types:
buflen
unsigned long long

variable_types:
comprlen
unsigned long long *

variable_types: err int

variable_types:
compr
unsigned char *

variable_types:
comprLen
unsigned long