decompiled_code:
int __fastcall remove_allocated_node(__int64 a1)
{
_QWORD *v2; // rdi
_QWORD *v3; // rbp
int result; // eax

v2 = head;
if ( head )
{
if ( *(_QWORD *)head == a1 )
{
head = (void *)*((_QWORD *)head + 2);
free(v2);
}
else
{
do
{
v3 = v2;
v2 = (_QWORD *)v2[2];
if ( !v2 )
{
if ( *v3 != a1 )
goto LABEL_7;
goto LABEL_9;
}
}
while ( *v2 != a1 );
v3[2] = v2[2];
free(v2);
if ( *v3 != a1 )
goto LABEL_7;
LABEL_9:
free(v3);
}
LABEL_7:
result = print_nodelist_to_file();
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(__int64 a1)
{
_QWORD *v2; // rdi
_QWORD *v3; // rbp
int result; // eax

v2 = head;
if ( head )
{
if ( *(_QWORD *)head == a1 )
{
head = (void *)*((_QWORD *)head + 2);
free(v2);
}
else
{
do
{
v3 = v2;
v2 = (_QWORD *)v2[2];
if ( !v2 )
{
if ( *v3 != a1 )
goto LABEL_7;
goto LABEL_9;
}
}
while ( *v2 != a1 );
v3[2] = v2[2];
free(v2);
if ( *v3 != a1 )
goto LABEL_7;
LABEL_9:
free(v3);
}
LABEL_7:
result = func0();
}
return result;
}

original_code:
void remove_allocated_node (void *key_address)
{
 ListNode *temp = ((void *)0);
 ListNode *deletenode = ((void *)0);
 if (((void *)0)==head)
 {
  return;
 }
 if ((head)->memaddress == key_address)
 {
   deletenode = head;
   head = (head)->next;
   free(deletenode);
   deletenode = ((void *)0);
 }
 else
 {
  temp = head;
  while (temp->next != ((void *)0))
  {
   if ((temp->next)->memaddress == key_address)
   {
    deletenode = temp->next;
    temp->next = (temp->next)->next;
    free (deletenode);
    deletenode = ((void *)0);
    break;
   }
   temp = temp->next;
  }
  if (temp->memaddress == key_address)
  {
   free (temp);
  }
 }
 print_nodelist_to_file ();
}

canonical_original_code:
void remove_allocated_node(void *key_address)
{
 struct node *temp = ((void *)0);
 struct node *deletenode = ((void *)0);
 if (((void *)0)==head)
 {
  return;
 }
 if ((head)->memaddress == key_address)
 {
   deletenode = head;
   head = (head)->next;
   free(deletenode);
   deletenode = ((void *)0);
 }
 else
 {
  temp = head;
  while (temp->next != ((void *)0))
  {
   if ((temp->next)->memaddress == key_address)
   {
    deletenode = temp->next;
    temp->next = (temp->next)->next;
    free (deletenode);
    deletenode = ((void *)0);
    break;
   }
   temp = temp->next;
  }
  if (temp->memaddress == key_address)
  {
   free (temp);
  }
 }
 print_nodelist_to_file ();
}


main

canonical_name: main

repo: sangeeths/SimplePAM

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
return 0;
}

original_code:
int main(int agrc, char *argv[])
{
    return 0;
}

variable_types: agrc int

variable_types:
argv
char *[]

return_type: int


conversation

decompiled_code:
__int64 __fastcall conversation(int a1, __int64 a2, _QWORD *a3, const char *a4)
{
__int64 result; // rax
char *v7; // rax
char *v8; // r13
char *v9; // rbx
char *v10; // rbp

result = 19LL;
if ( (unsigned int)(a1 - 1) <= 0x1F )
{
v7 = (char *)calloc(a1, 0x10uLL);
v8 = v7;
if ( v7 )
{
v9 = v7;
v10 = &v7[16 * a1];
do
{
*((_DWORD *)v9 + 2) = 0;
v9 += 16;
*((_QWORD *)v9 - 2) = strdup(a4);
}
while ( v9 != v10 );
*a3 = v8;
result = 0LL;
}
else
{
result = 5LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1, __int64 a2, _QWORD *a3, const char *a4)
{
__int64 result; // rax
char *v7; // rax
char *v8; // r13
char *v9; // rbx
char *v10; // rbp

result = 19LL;
if ( (unsigned int)(a1 - 1) <= 0x1F )
{
v7 = (char *)calloc(a1, 0x10uLL);
v8 = v7;
if ( v7 )
{
v9 = v7;
v10 = &v7[16 * a1];
do
{
*((_DWORD *)v9 + 2) = 0;
v9 += 16;
*((_QWORD *)v9 - 2) = strdup(a4);
}
while ( v9 != v10 );
*a3 = v8;
result = 0LL;
}
else
{
result = 5LL;
}
}
return result;
}

original_code:
int conversation(int msg_count,
                 const struct pam_message **msg,
                 struct pam_response **resp,
                 void *pw)
{
    struct pam_response *r = ((void *)0);
    int i = 0;
    if (msg_count <= 0 || msg_count > 32)
        return 19;
    if ((r = (struct pam_response *) calloc(msg_count,
              sizeof(struct pam_response))) == ((void *)0))
        return 5;
    for(i=0; i<msg_count; ++i) {
        r[i].resp_retcode = 0;
        r[i].resp = strdup(pw);
    }
    *resp = r;
    return 0;
}

canonical_original_code:
int conversation(int msg_count, struct pam_message **msg, struct pam_response **resp, void *pw)
{
    struct pam_response *r = ((void *)0);
    int i = 0;
    if (msg_count <= 0 || msg_count > 32)
        return 19;
    if ((r = (struct pam_response *) calloc(msg_count,
              sizeof(struct pam_response))) == ((void *)0))
        return 5;
    for(i=0; i<msg_count; ++i) {
        r[i].resp_retcode = 0;
        r[i].resp = strdup(pw);
    }
    *resp = r;
    return 0;
}

variable_types: struct pam_message { int msg_style; char *msg; } **

variable_types: struct pam_response { char *resp; int resp_retcode; } **

variable_types:
pw
void *

variable_types: i int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax
__int64 v4; // rbp

if ( argc == 2 )
{
v4 = get_results(argv[1]);
result = -1;
if ( v4 )
{
g_slist_foreach(v4, &print_result_info, 0LL);
g_slist_free_full(v4, &result_cleanup);
result = 0;
}
}
else
{
printf("usage: %s <url>\n", *argv);
result = 0;
}
return result;
}

original_code:
int main(int argc, char **argv )
{
 GSList *results = ((void *)0);
 int err;
 if ( argc == 2) {
  results = get_results(argv[1]);
  if (results) {
   g_slist_foreach(results, (GFunc)print_result_info, ((void *)0));
   g_slist_free_full(results, (GDestroyNotify) result_cleanup);
   err = 0;
  } else
   err = -1;
  return err;
 }
 else
  printf( "usage: %s <url>\n", argv[0] );
 return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
 struct _GSList *results = ((void *)0);
 int err;
 if ( argc == 2) {
  results = get_results(argv[1]);
  if (results) {
   g_slist_foreach(results, (void (*)(void *data, void *user_data))print_result_info, ((void *)0));
   g_slist_free_full(results, (void (*)(void *data)) result_cleanup);
   err = 0;
  } else
   err = -1;
  return err;
 }
 else
  printf( "usage: %s <url>\n", argv[0] );
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

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

variable_types: err int


repo: sangyye/recursorscanner

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebp
const char *v4; // r12
int v5; // er14
const char *v6; // r13
__int64 v7; // rax
char v8; // dl
int v9; // ebx
int v10; // er12
int v11; // ebp
__int16 v12; // ax
__int64 v13; // rdx
__int64 v14; // rcx
__int16 v15; // ax
__int16 v16; // cx
char *v17; // rax
int v18; // ebx
size_t v19; // rax
int v20; // eax
pthread_t newthread; // [rsp+8h] [rbp-10060h] BYREF
char v23[27]; // [rsp+15h] [rbp-10053h] BYREF
struct sockaddr addr; // [rsp+30h] [rbp-10038h] BYREF
__int16 v25[3]; // [rsp+40h] [rbp-10028h] BYREF
int v26; // [rsp+46h] [rbp-10022h]
__int16 v27; // [rsp+4Ah] [rbp-1001Eh]
char s[65564]; // [rsp+4Ch] [rbp-1001Ch] BYREF

strcpy(v23, "google.com");
if ( argc != 3 )
{
usage(*argv, 28015LL, envp);
exit(1);
}
v4 = argv[1];
v5 = strlen(v4);
v6 = (const char *)malloc(v5);
if ( !v6 )
error("Could not allocate memory\n");
v7 = 0LL;
if ( v5 > 0 )
{
while ( 1 )
{
v8 = v4[v7];
if ( v8 == 47 )
break;
v6[v7] = v8;
if ( v5 - 1 == v7 )
goto LABEL_9;
++v7;
}
v6[v7] = 0;
v3 = atoi(&v4[v7 + 1]);
}
LABEL_9:
sockfd = socket(2, 2, 0);
if ( sockfd < 0 )
error("Could not open socket\n");
v9 = atoi(argv[2]);
v10 = (int)pow(2.0, (double)(32 - v3));
v11 = 1000 * (1000000 / v9) / 576;
addr.sa_family = 2;
v12 = _bswap_16(53LL, v23, 1LL, 0LL);
v25[1] = v13;
*(_WORD *)addr.sa_data = v12;
v15 = _bswap_16(1LL, v23, v13, v14);
v27 = v16;
LOWORD(v9) = v15;
v25[2] = v15;
v26 = 0;
dns_convert_hostname(s);
v17 = &s[strlen(s) + 1];
*(_WORD *)v17 = v9;
*((_WORD *)v17 + 1) = v9;
v18 = pthread_create(&newthread, 0LL, receive, 0LL);
if ( v18 )
error("Could not create thread\n");
*(_DWORD *)&addr.sa_data[2] = inet_addr(v6);
if ( v10 )
{
do
{
v25[0] = v18;
*(_OWORD *)&v23[11] = 0LL;
inet_ntop(2, &addr.sa_data[2], &v23[11], 0x10u);
do
v19 = strlen(s);
while ( sendto(sockfd, v25, v19 + 17, 0, &addr, 0x10u) < 0 );
++v18;
v20 = _bswap_32(*(unsigned int *)&addr.sa_data[2]);
*(_DWORD *)&addr.sa_data[2] = _bswap_32((unsigned int)(v20 + 1));
usleep(v11);
}
while ( v10 != v18 );
}
sleep(5u);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebp
const char *v4; // r12
int v5; // er14
const char *v6; // r13
__int64 v7; // rax
char v8; // dl
int v9; // ebx
int v10; // er12
int v11; // ebp
__int16 v12; // ax
__int64 v13; // rdx
__int64 v14; // rcx
__int16 v15; // ax
__int16 v16; // cx
char *v17; // rax
int v18; // ebx
size_t v19; // rax
int v20; // eax
pthread_t newthread; // [rsp+8h] [rbp-10060h] BYREF
char v23[27]; // [rsp+15h] [rbp-10053h] BYREF
struct sockaddr addr; // [rsp+30h] [rbp-10038h] BYREF
__int16 v25[3]; // [rsp+40h] [rbp-10028h] BYREF
int v26; // [rsp+46h] [rbp-10022h]
__int16 v27; // [rsp+4Ah] [rbp-1001Eh]
char s[65564]; // [rsp+4Ch] [rbp-1001Ch] BYREF

strcpy(v23, "google.com");
if ( argc != 3 )
{
func10(*argv, 28015LL, envp);
exit(1);
}
v4 = argv[1];
v5 = strlen(v4);
v6 = (const char *)malloc(v5);
if ( !v6 )
func11("Could not allocate memory\n");
v7 = 0LL;
if ( v5 > 0 )
{
while ( 1 )
{
v8 = v4[v7];
if ( v8 == 47 )
break;
v6[v7] = v8;
if ( v5 - 1 == v7 )
goto LABEL_9;
++v7;
}
v6[v7] = 0;
v3 = atoi(&v4[v7 + 1]);
}
LABEL_9:
sockfd = socket(2, 2, 0);
if ( sockfd < 0 )
func11("Could not open socket\n");
v9 = atoi(argv[2]);
v10 = (int)pow(2.0, (double)(32 - v3));
v11 = 1000 * (1000000 / v9) / 576;
addr.sa_family = 2;
v12 = func7(53LL, v23, 1LL, 0LL);
v25[1] = v13;
*(_WORD *)addr.sa_data = v12;
v15 = func7(1LL, v23, v13, v14);
v27 = v16;
LOWORD(v9) = v15;
v25[2] = v15;
v26 = 0;
func12(s);
v17 = &s[strlen(s) + 1];
*(_WORD *)v17 = v9;
*((_WORD *)v17 + 1) = v9;
v18 = pthread_create(&newthread, 0LL, receive, 0LL);
if ( v18 )
func11("Could not create thread\n");
*(_DWORD *)&addr.sa_data[2] = inet_addr(v6);
if ( v10 )
{
do
{
v25[0] = v18;
*(_OWORD *)&v23[11] = 0LL;
inet_ntop(2, &addr.sa_data[2], &v23[11], 0x10u);
do
v19 = strlen(s);
while ( sendto(sockfd, v25, v19 + 17, 0, &addr, 0x10u) < 0 );
++v18;
v20 = func9(*(unsigned int *)&addr.sa_data[2]);
*(_DWORD *)&addr.sa_data[2] = func9((unsigned int)(v20 + 1));
usleep(v11);
}
while ( v10 != v18 );
}
sleep(5u);
return 0;
}

original_code:
int main(int argc, char **argv) {
 pthread_t tid;
 int query_type;
 int end_ip;
 int sleeptime;
 int len;
 int bandwith;
 int mask;
 char buffer[16];
 unsigned char hostname[] = "google.com";
 char *start_ip;
 unsigned char buf[65536];
 unsigned char *qname;
 struct sockaddr_in addr;
 struct DNS_HEADER *dns = ((void *)0);
 struct QUESTION *qinfo = ((void *)0);
 if (argc != 3) {
  usage(argv[0]);
  exit(1);
 }
 len = strlen(argv[1]);
 start_ip = (char *)malloc(sizeof(char) * len);
 if (start_ip == ((void *)0)) {
  error("Could not allocate memory\n");
 }
 for (int i = 0; i < len; i++) {
  if (argv[1][i] != '/') {
   start_ip[i] = argv[1][i];
  }
  else {
   start_ip[i] = '\0';
   mask = atoi(&argv[1][i + 1]);
   break;
  }
 }
 if ((sockfd = socket(2, SOCK_DGRAM, 0)) < 0) {
  error("Could not open socket\n");
 }
 bandwith = atoi(argv[2]);
 end_ip = pow(2, 32 - mask);
 sleeptime = 1000000 / bandwith * 1000 / (72 * 8);
 addr.sin_family = 2;
    addr.sin_port = htons(53);
 dns = (struct DNS_HEADER *)&buf;
 dns->qr = 0;
 dns->opcode = 0;
 dns->aa = 0;
 dns->tc = 0;
 dns->rd = 1;
 dns->ra = 0;
 dns->z = 0;
 dns->ad = 0;
 dns->cd = 0;
 dns->rcode = 0;
 dns->q_count = htons(1);
 dns->ans_count = 0;
 dns->auth_count = 0;
 dns->add_count = 0;
 qname = (unsigned char *)&buf[sizeof(struct DNS_HEADER)];
 query_type = 1;
 dns_convert_hostname(qname , hostname);
 qinfo = (struct QUESTION *)&buf[sizeof(struct DNS_HEADER) + (strlen((const char *)qname) + 1)];
 qinfo->qtype = htons(query_type);
 qinfo->qclass = htons(1);
 if (pthread_create(&tid, ((void *)0), receive, ((void *)0))) {
  error("Could not create thread\n");
 }
 addr.sin_addr.s_addr = inet_addr(start_ip);
 for (int i = 0; i < end_ip; i++) {
  dns->id = (unsigned short)i;
  memset(buffer, 0x00, 16);
  inet_ntop(2, &addr.sin_addr.s_addr, buffer, 16);
  do {
  } while (sendto(sockfd, (char*)buf,sizeof(struct DNS_HEADER) + (strlen((const char*)qname)+1) + sizeof(struct QUESTION), 0, (struct sockaddr*)&addr, sizeof(addr)) < 0);
  addr.sin_addr.s_addr = htonl(addr.sin_addr.s_addr);
  addr.sin_addr.s_addr++;
  addr.sin_addr.s_addr = ntohl(addr.sin_addr.s_addr);
  usleep(sleeptime);
 }
 sleep(5);
 return 0;
}

canonical_original_code:
int main(int argc, char **argv) {
 unsigned long tid;
 int query_type;
 int end_ip;
 int sleeptime;
 int len;
 int bandwith;
 int mask;
 char buffer[16];
 unsigned char hostname[] = "google.com";
 char *start_ip;
 unsigned char buf[65536];
 unsigned char *qname;
 struct sockaddr_in addr;
 struct DNS_HEADER *dns = ((void *)0);
 struct QUESTION *qinfo = ((void *)0);
 if (argc != 3) {
  usage(argv[0]);
  exit(1);
 }
 len = strlen(argv[1]);
 start_ip = (char *)malloc(sizeof(char) * len);
 if (start_ip == ((void *)0)) {
  error("Could not allocate memory\n");
 }
 for (int i = 0; i < len; i++) {
  if (argv[1][i] != '/') {
   start_ip[i] = argv[1][i];
  }
  else {
   start_ip[i] = '\0';
   mask = atoi(&argv[1][i + 1]);
   break;
  }
 }
 if ((sockfd = socket(2, SOCK_DGRAM, 0)) < 0) {
  error("Could not open socket\n");
 }
 bandwith = atoi(argv[2]);
 end_ip = pow(2, 32 - mask);
 sleeptime = 1000000 / bandwith * 1000 / (72 * 8);
 addr.sin_family = 2;
    addr.sin_port = htons(53);
 dns = (struct DNS_HEADER *)&buf;
 dns->qr = 0;
 dns->opcode = 0;
 dns->aa = 0;
 dns->tc = 0;
 dns->rd = 1;
 dns->ra = 0;
 dns->z = 0;
 dns->ad = 0;
 dns->cd = 0;
 dns->rcode = 0;
 dns->q_count = htons(1);
 dns->ans_count = 0;
 dns->auth_count = 0;
 dns->add_count = 0;
 qname = (unsigned char *)&buf[sizeof(struct DNS_HEADER)];
 query_type = 1;
 dns_convert_hostname(qname , hostname);
 qinfo = (struct QUESTION *)&buf[sizeof(struct DNS_HEADER) + (strlen((char *)qname) + 1)];
 qinfo->qtype = htons(query_type);
 qinfo->qclass = htons(1);
 if (pthread_create(&tid, ((void *)0), receive, ((void *)0))) {
  error("Could not create thread\n");
 }
 addr.sin_addr.s_addr = inet_addr(start_ip);
 for (int i = 0; i < end_ip; i++) {
  dns->id = (unsigned short)i;
  memset(buffer, 0x00, 16);
  inet_ntop(2, &addr.sin_addr.s_addr, buffer, 16);
  do {
  } while (sendto(sockfd, (char *)buf,sizeof(struct DNS_HEADER) + (strlen((char *)qname)+1) + sizeof(struct QUESTION), 0, (struct sockaddr *)&addr, sizeof(addr)) < 0);
  addr.sin_addr.s_addr = htonl(addr.sin_addr.s_addr);
  addr.sin_addr.s_addr++;
  addr.sin_addr.s_addr = ntohl(addr.sin_addr.s_addr);
  usleep(sleeptime);
 }
 sleep(5);
 return 0;
}

variable_types:
tid
unsigned long

variable_types: sleeptime int

variable_types: len int

variable_types: bandwith int

variable_types: mask int

variable_types:
buffer
char [16]

variable_types:
hostname
unsigned char []

variable_types:
buf
unsigned char [65536]

variable_types:
qname
unsigned char *

variable_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr { unsigned int s_addr; } sin_addr; unsigned char sin_zero[-1]; }

variable_types: struct DNS_HEADER { unsigned short id; unsigned char rd; unsigned char tc; unsigned char aa; unsigned char opcode; unsigned char qr; unsigned char rcode; unsigned char cd; unsigned char ad; unsigned char z; unsigned char ra; unsigned short q_count; unsigned short ans_count; unsigned short auth_count; unsigned short add_count; } *

variable_types: struct QUESTION { unsigned short qtype; unsigned short qclass; } *

user_defined_types: struct sockaddr_in { unsigned short sin_family; unsigned short sin_port; struct in_addr sin_addr; unsigned char sin_zero[-1]; }

user_defined_types: struct sockaddr { unsigned short sa_family; char sa_data[14]; }


receive

decompiled_code:
void __fastcall __noreturn receive(void *a1)
{
char *v1; // rax
socklen_t addr_len; // [rsp+Ch] [rbp-1001Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-10018h] BYREF
char s[6]; // [rsp+20h] [rbp-10008h] BYREF
__int16 v5; // [rsp+26h] [rbp-10002h]

addr_len = 16;
while ( 1 )
{
do
memset(s, 0, 0x10000uLL);
while ( recvfrom(sockfd, s, 0x10000uLL, 0, &addr, &addr_len) < 0 );
if ( _bswap_16(v5) )
{
v1 = inet_ntoa(*(struct in_addr *)&addr.sa_data[2]);
puts(v1);
}
}
}

canonical_decompiled_code:
void __fastcall __noreturn func8(void *a1)
{
char *v1; // rax
socklen_t addr_len; // [rsp+Ch] [rbp-1001Ch] BYREF
struct sockaddr addr; // [rsp+10h] [rbp-10018h] BYREF
char s[6]; // [rsp+20h] [rbp-10008h] BYREF
__int16 v5; // [rsp+26h] [rbp-10002h]

addr_len = 16;
while ( 1 )
{
do
memset(s, 0, 0x10000uLL);
while ( recvfrom(sockfd, s, 0x10000uLL, 0, &addr, &addr_len) < 0 );
if ( func7(v5) )
{
v1 = inet_ntoa(*(struct in_addr *)&addr.sa_data[2]);
puts(v1);
}
}
}

original_code:
void *receive(void *arg) {
 char buffer[65536];
 socklen_t addrlen;
 struct sockaddr_in rsystem;
 struct DNS_HEADER *dns = ((void *)0);
 addrlen = sizeof(rsystem);
 for(;;) {
  memset(buffer, 0x00, 65536);
  if (recvfrom(sockfd, (char*)buffer, 65536, 0, (struct sockaddr*)&rsystem, &addrlen) >= 0) {
   dns = (struct DNS_HEADER*) buffer;
   if (ntohs(dns->ans_count) > 0) {
    printf("%s\n", inet_ntoa(rsystem.sin_addr));
   }
  }
 }
}

canonical_original_code:
void *receive(void *arg) {
 char buffer[65536];
 unsigned int addrlen;
 struct sockaddr_in rsystem;
 struct DNS_HEADER *dns = ((void *)0);
 addrlen = sizeof(rsystem);
 for(;;) {
  memset(buffer, 0x00, 65536);
  if (recvfrom(sockfd, (char *)buffer, 65536, 0, (struct sockaddr *)&rsystem, &addrlen) >= 0) {
   dns = (struct DNS_HEADER *) buffer;
   if (ntohs(dns->ans_count) > 0) {
    printf("%s\n", inet_ntoa(rsystem.sin_addr));
   }
  }
 }
}

variable_types:
arg
void *

variable_types:
buffer
char [65536]

variable_types:
addrlen
unsigned int

return_type: void *

user_defined_types: struct DNS_HEADER { unsigned short id; unsigned char rd; unsigned char tc; unsigned char aa; unsigned char opcode; unsigned char qr; unsigned char rcode; unsigned char cd; unsigned char ad; unsigned char z; unsigned char ra; unsigned short q_count; unsigned short ans_count; unsigned short auth_count; unsigned short add_count; }


usage

decompiled_code:
int __fastcall usage(const char *a1)
{
return printf("Usage: %s <address/mask> <bandwith in kbps>\n", a1);
}

canonical_decompiled_code:
int __fastcall func10(const char *a1)
{
return printf("Usage: %s <address/mask> <bandwith in kbps>\n", a1);
}

original_code:
void usage(char *cmd) {
 printf("Usage: %s <address/mask> <bandwith in kbps>\n", cmd);
}

variable_types:
cmd
char *

return_type: void


error

decompiled_code:
void __fastcall __noreturn error(const char *a1)
{
fprintf(stderr, "Fatal Error: %s\n", a1);
exit(1);
}

canonical_decompiled_code:
void __fastcall __noreturn func11(const char *a1)
{
fprintf(stderr, "Fatal Error: %s\n", a1);
exit(1);
}

original_code:
void error (char * msg) {
 fprintf(stderr, "Fatal Error: %s\n", msg);
 exit(1);
}

canonical_original_code:
void error(char *msg) {
 fprintf(stderr, "Fatal Error: %s\n", msg);
 exit(1);
}

variable_types:
msg
char *


repo: sanjoy/CmdArgs

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

if ( a1 == 0.0 )
return a3 > COERCE_DOUBLE(*(_QWORD *)&a1 & LC1);
*(_QWORD *)&v3 = *(_QWORD *)&a2 & LC1;
if ( a2 == 0.0 )
result = a3 > v3;
else
result = a3 > COERCE_DOUBLE(COERCE_UNSIGNED_INT64(a1 - a2) & LC1) / fmax(COERCE_DOUBLE(*(_QWORD *)&a1 & LC1), v3);
return result;
}

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

if ( a1 == 0.0 )
return a3 > COERCE_DOUBLE(*(_QWORD *)&a1 & LC1);
*(_QWORD *)&v3 = *(_QWORD *)&a2 & LC1;
if ( a2 == 0.0 )
result = a3 > v3;
else
result = a3 > COERCE_DOUBLE(COERCE_UNSIGNED_INT64(a1 - a2) & LC1) / fmax(COERCE_DOUBLE(*(_QWORD *)&a1 & LC1), v3);
return result;
}

original_code:
int
almost_equal_eps (double x, double y, double eps)
{
    if (x == 0) return fabs (x) < eps;
    if (y == 0) return fabs (y) < eps;
    double max = (fabs (x) > fabs (y)) ? fabs (x) : fabs (y);
    return (fabs (x - y) / max) < eps;
}

canonical_original_code:
int almost_equal_eps(double x, double y, double eps)
{
    if (x == 0) return fabs (x) < eps;
    if (y == 0) return fabs (y) < eps;
    double max = (fabs (x) > fabs (y)) ? fabs (x) : fabs (y);
    return (fabs (x - y) / max) < eps;
}

variable_types: x double

variable_types: y double

variable_types: eps double

variable_types: max double


repo: sanjoy/L

decompiled_code:
__int64 __fastcall is_memblock_free_slow(__int64 *a1)
{
__int64 v1; // rdx
unsigned __int64 v2; // rcx
__int64 v3; // rax
__int64 result; // rax

v1 = *a1;
v2 = (unsigned __int64)(a1[2] - *a1) >> 6;
if ( ((*((_BYTE *)a1 + 16) - *(_BYTE *)a1) & 0x38) != 0 )
{
++v2;
}
else if ( !v2 )
{
LABEL_8:
result = 1LL;
*a1 = v1 | 1;
return result;
}
v3 = 0LL;
while ( !*(_BYTE *)(v1 + v3) )
{
if ( ++v3 >= v2 )
goto LABEL_8;
}
return 0LL;
}

original_code:
static int
is_memblock_free_slow (MempoolNode *block)
{
 int i;
 size_t sz = ((size_t) ((block)->real_end - (block)->begin)) / (sizeof (void *));
 if (sz % 8 != 0)
  sz = sz / 8 + 1;
 else
  sz = sz / 8;
 for (i = 0; i < sz; i++)
  if (((char *) (block->begin)) [i])
   return 0;
 block->begin = ((void *) (((unsigned long) block->begin) | (unsigned long) 1));
 return 1;
}

canonical_original_code:
static int is_memblock_free_slow(struct _MempoolNode *block)
{
 int i;
 unsigned long sz = ((size_t) ((block)->real_end - (block)->begin)) / (sizeof (void *));
 if (sz % 8 != 0)
  sz = sz / 8 + 1;
 else
  sz = sz / 8;
 for (i = 0; i < sz; i++)
  if (((char *) (block->begin)) [i])
   return 0;
 block->begin = ((void *) (((unsigned long) block->begin) | (unsigned long) 1));
 return 1;
}

variable_types: struct _MempoolNode { void *begin; int offset; struct _MempoolNode *next; } *

variable_types: i int

variable_types:
sz
unsigned long


decompiled_code:
__int64 __fastcall find_and_mark(unsigned __int64 *a1, unsigned __int64 a2, int a3)
{
unsigned __int64 v4; // rdx
int v6; // er8
unsigned __int64 v7; // r9
unsigned __int64 v8; // rcx
bool v9; // sf
int v10; // ecx
int v11; // eax
int v12; // eax

if ( !a1 )
return 0LL;
while ( 1 )
{
v4 = *a1;
if ( *a1 <= a2 && a1[1] > a2 )
break;
a1 = (unsigned __int64 *)a1[4];
if ( !a1 )
return 0LL;
}
if ( (((_BYTE)a2 - (_BYTE)v4) & 7) != 0 )
_assert_fail("(((size_t) (to_find - iter->begin)) % SIZEOF_PTR) == 0", "src/l-mempool.c", 0x98u, "find_and_mark");
v6 = 0;
v7 = (unsigned __int64)a3 >> 3;
while ( 1 )
{
v8 = (a2 - v4) >> 3;
v9 = v6 + (int)v8 < 0;
v10 = v6 + v8;
v11 = v10 + 7;
if ( !v9 )
v11 = v10;
v12 = v11 >> 3;
if ( v12 >= *((_DWORD *)a1 + 6) )
_assert_fail("(n / 8 + 1) <= (iter)->offset", "src/l-mempool.c", 0x9Au, "find_and_mark");
++v6;
*(_BYTE *)(v4 + v12) |= 1 << (v10 % 8);
if ( v6 == (_DWORD)v7 )
break;
v4 = *a1;
}
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned __int64 *a1, unsigned __int64 a2, int a3)
{
unsigned __int64 v4; // rdx
int v6; // er8
unsigned __int64 v7; // r9
unsigned __int64 v8; // rcx
bool v9; // sf
int v10; // ecx
int v11; // eax
int v12; // eax

if ( !a1 )
return 0LL;
while ( 1 )
{
v4 = *a1;
if ( *a1 <= a2 && a1[1] > a2 )
break;
a1 = (unsigned __int64 *)a1[4];
if ( !a1 )
return 0LL;
}
if ( (((_BYTE)a2 - (_BYTE)v4) & 7) != 0 )
_assert_fail("(((size_t) (to_find - iter->begin)) % SIZEOF_PTR) == 0", "src/l-mempool.c", 0x98u, "find_and_mark");
v6 = 0;
v7 = (unsigned __int64)a3 >> 3;
while ( 1 )
{
v8 = (a2 - v4) >> 3;
v9 = v6 + (int)v8 < 0;
v10 = v6 + v8;
v11 = v10 + 7;
if ( !v9 )
v11 = v10;
v12 = v11 >> 3;
if ( v12 >= *((_DWORD *)a1 + 6) )
_assert_fail("(n / 8 + 1) <= (iter)->offset", "src/l-mempool.c", 0x9Au, "find_and_mark");
++v6;
*(_BYTE *)(v4 + v12) |= 1 << (v10 % 8);
if ( v6 == (_DWORD)v7 )
break;
v4 = *a1;
}
return 1LL;
}

original_code:
static int
find_and_mark (MempoolNode *blocks, void *to_find, int sz)
{
 MempoolNode *iter;
 int i;
 for (iter = blocks; iter; iter = iter->next) {
  if (to_find >= iter->begin && to_find < iter->end) {
   ((void) sizeof (((((size_t) (to_find - iter->begin)) % (sizeof (void *))) == 0) ? 1 : 0), __extension__ ({ if ((((size_t) (to_find - iter->begin)) % (sizeof (void *))) == 0) ; else __assert_fail ("(((size_t) (to_find - iter->begin)) % SIZEOF_PTR) == 0", "src/l-mempool.c", 152, __extension__ __PRETTY_FUNCTION__); }));
   for (i = 0; i < sz / (sizeof (void *)); i++) {
    do { char *__tmp = (char *) ((iter)->begin); int n = (((size_t) (to_find - iter->begin)) / (sizeof (void *)) + i); ((void) sizeof (((n / 8 + 1) <= (iter)->offset) ? 1 : 0), __extension__ ({ if ((n / 8 + 1) <= (iter)->offset) ; else __assert_fail ("(n / 8 + 1) <= (iter)->offset", "src/l-mempool.c", 154, __extension__ __PRETTY_FUNCTION__); })); __tmp [n / 8] |= 1 << (n % 8); } while (0);
   }
   return 1;
  }
 }
 return 0;
}

canonical_original_code:
static int find_and_mark(struct _MempoolNode *blocks, void *to_find, int sz)
{
 struct _MempoolNode *iter;
 int i;
 for (iter = blocks; iter; iter = iter->next) {
  if (to_find >= iter->begin && to_find < iter->end) {
   ((void) sizeof (((((unsigned long) (to_find - iter->begin)) % (sizeof (void *))) == 0) ? 1 : 0), __extension__ ({ if ((((unsigned long) (to_find - iter->begin)) % (sizeof (void *))) == 0) ; else __assert_fail ("(((size_t) (to_find - iter->begin)) % SIZEOF_PTR) == 0", "src/l-mempool.c", 152, __extension__ __PRETTY_FUNCTION__); }));
   for (i = 0; i < sz / (sizeof (void *)); i++) {
    do { char *__tmp = (char *) ((iter)->begin); int n = (((size_t) (to_find - iter->begin)) / (sizeof (void *)) + i); ((void) sizeof (((n / 8 + 1) <= (iter)->offset) ? 1 : 0), __extension__ ({ if ((n / 8 + 1) <= (iter)->offset) ; else __assert_fail ("(n / 8 + 1) <= (iter)->offset", "src/l-mempool.c", 154, __extension__ __PRETTY_FUNCTION__); })); __tmp [n / 8] |= 1 << (n % 8); } while (0);
   }
   return 1;
  }
 }
 return 0;
}

variable_types: sz int

variable_types: n int

user_defined_types: struct _MempoolNode { void *begin; int offset; struct _MempoolNode *next; }


decompiled_code:
void __fastcall mark_mark_list(__int64 a1, unsigned __int64 *a2)
{
unsigned __int64 *v2; // rbx

if ( a2 )
{
v2 = a2;
do
{
if ( !(unsigned int)find_and_mark(*(unsigned __int64 **)(a1 + 24), (unsigned __int64)v2, 16) )
_assert_fail(
"find_and_mark ((pool)->blocks, (iter), sizeof (LListNode))",
"src/l-mempool-scan.inc",
0x20u,
"mark_mark_list");
if ( !(unsigned int)find_and_mark(*(unsigned __int64 **)(a1 + 24), *v2, 24) )
_assert_fail(
"find_and_mark ((pool)->blocks, (iter->token), sizeof (LToken))",
"src/l-mempool-scan.inc",
0x21u,
"mark_mark_list");
v2 = (unsigned __int64 *)v2[1];
}
while ( v2 );
}
}

canonical_decompiled_code:
void __fastcall func2(__int64 a1, unsigned __int64 *a2)
{
unsigned __int64 *v2; // rbx

if ( a2 )
{
v2 = a2;
do
{
if ( !(unsigned int)func1(*(unsigned __int64 **)(a1 + 24), (unsigned __int64)v2, 16) )
_assert_fail(
"find_and_mark ((pool)->blocks, (iter), sizeof (LListNode))",
"src/l-mempool-scan.inc",
0x20u,
"mark_mark_list");
if ( !(unsigned int)func1(*(unsigned __int64 **)(a1 + 24), *v2, 24) )
_assert_fail(
"find_and_mark ((pool)->blocks, (iter->token), sizeof (LToken))",
"src/l-mempool-scan.inc",
0x21u,
"mark_mark_list");
v2 = (unsigned __int64 *)v2[1];
}
while ( v2 );
}
}

original_code:
static void
mark_mark_list (LMempool *pool, LListNode *iter)
{
 for (; iter; iter = iter->next) {
  ((void) sizeof ((find_and_mark ((pool)->blocks, (iter), sizeof (LListNode))) ? 1 : 0), __extension__ ({ if (find_and_mark ((pool)->blocks, (iter), sizeof (LListNode))) ; else __assert_fail ("find_and_mark ((pool)->blocks, (iter), sizeof (LListNode))", "src/l-mempool-scan.inc", 32, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((find_and_mark ((pool)->blocks, (iter->token), sizeof (LToken))) ? 1 : 0), __extension__ ({ if (find_and_mark ((pool)->blocks, (iter->token), sizeof (LToken))) ; else __assert_fail ("find_and_mark ((pool)->blocks, (iter->token), sizeof (LToken))", "src/l-mempool-scan.inc", 33, __extension__ __PRETTY_FUNCTION__); }));
 }
}

canonical_original_code:
static void mark_mark_list(struct _LMempool *pool, struct _LListNode *iter)
{
 for (; iter; iter = iter->next) {
  ((void) sizeof ((find_and_mark ((pool)->blocks, (iter), sizeof (LListNode))) ? 1 : 0), __extension__ ({ if (find_and_mark ((pool)->blocks, (iter), sizeof (LListNode))) ; else __assert_fail ("find_and_mark ((pool)->blocks, (iter), sizeof (LListNode))", "src/l-mempool-scan.inc", 32, __extension__ __PRETTY_FUNCTION__); }));
  ((void) sizeof ((find_and_mark ((pool)->blocks, (iter->token), sizeof (LToken))) ? 1 : 0), __extension__ ({ if (find_and_mark ((pool)->blocks, (iter->token), sizeof (LToken))) ; else __assert_fail ("find_and_mark ((pool)->blocks, (iter->token), sizeof (LToken))", "src/l-mempool-scan.inc", 33, __extension__ __PRETTY_FUNCTION__); }));
 }
}

variable_types: struct _LMempool { unsigned long page_size; int dev_zero_fd; unsigned long total_bytes; struct _MempoolNode { void *begin; int offset; struct _MempoolNode *next; } *blocks; } *

variable_types: struct _LListNode { struct LToken { char *name; int idx; struct _LLambda { struct _LListNode *args; struct _LTreeNode { struct LToken *token; struct _LLambda *lambda; struct _LTreeNode *left; } *body; struct _LLambda *next; } *parent; } *token; struct _LListNode *next; } *

user_defined_types: struct _LMempool { unsigned long page_size; int dev_zero_fd; unsigned long total_bytes; struct _MempoolNode *blocks; }

user_defined_types: struct _LListNode { struct LToken *token; struct _LListNode *next; }

user_defined_types: struct LToken { char *name; int idx; struct _LLambda *parent; }

user_defined_types: struct _LLambda { struct _LListNode *args; struct _LTreeNode *body; struct _LLambda *next; }


decompiled_code:
void __fastcall mark_recursive_lambda(__int64 a1, unsigned __int64 a2)
{
if ( a2 )
{
if ( !(unsigned int)find_and_mark(*(unsigned __int64 **)(a1 + 24), a2, 24) )
_assert_fail(
"find_and_mark ((pool)->blocks, (lambda), sizeof (LLambda))",
"src/l-mempool-scan.inc",
0x2Au,
"mark_recursive_lambda");
mark_mark_list(a1, *(unsigned __int64 **)a2);
mark_recursive_tree(a1, *(_QWORD *)(a2 + 8));
}
}

canonical_decompiled_code:
void __fastcall func3(__int64 a1, unsigned __int64 a2)
{
if ( a2 )
{
if ( !(unsigned int)func1(*(unsigned __int64 **)(a1 + 24), a2, 24) )
_assert_fail(
"find_and_mark ((pool)->blocks, (lambda), sizeof (LLambda))",
"src/l-mempool-scan.inc",
0x2Au,
"mark_recursive_lambda");
func2(a1, *(unsigned __int64 **)a2);
func4(a1, *(_QWORD *)(a2 + 8));
}
}

original_code:
static void
mark_recursive_lambda (LMempool *pool, LLambda *lambda)
{
 if (lambda == ((void *)0))
  return;
 ((void) sizeof ((find_and_mark ((pool)->blocks, (lambda), sizeof (LLambda))) ? 1 : 0), __extension__ ({ if (find_and_mark ((pool)->blocks, (lambda), sizeof (LLambda))) ; else __assert_fail ("find_and_mark ((pool)->blocks, (lambda), sizeof (LLambda))", "src/l-mempool-scan.inc", 42, __extension__ __PRETTY_FUNCTION__); }));
 mark_mark_list (pool, lambda->args);
 mark_recursive_tree (pool, lambda->body);
}

canonical_original_code:
static void mark_recursive_lambda(struct _LMempool *pool, struct _LLambda *lambda)
{
 if (lambda == ((void *)0))
  return;
 ((void) sizeof ((find_and_mark ((pool)->blocks, (lambda), sizeof (LLambda))) ? 1 : 0), __extension__ ({ if (find_and_mark ((pool)->blocks, (lambda), sizeof (LLambda))) ; else __assert_fail ("find_and_mark ((pool)->blocks, (lambda), sizeof (LLambda))", "src/l-mempool-scan.inc", 42, __extension__ __PRETTY_FUNCTION__); }));
 mark_mark_list (pool, lambda->args);
 mark_recursive_tree (pool, lambda->body);
}

variable_types: struct _LLambda { struct _LListNode { struct LToken { char *name; int idx; struct _LLambda *parent; } *token; struct _LListNode *next; } *args; struct _LTreeNode { struct LToken *token; struct _LLambda *lambda; struct _LTreeNode *left; } *body; struct _LLambda *next; } *


decompiled_code:
void __fastcall mark_recursive_tree(__int64 a1, unsigned __int64 *a2)
{
unsigned __int64 v3; // rsi

if ( a2 )
{
if ( !(unsigned int)find_and_mark(*(unsigned __int64 **)(a1 + 24), (unsigned __int64)a2, 40) )
_assert_fail(
"find_and_mark ((pool)->blocks, (node), sizeof (LTreeNode))",
"src/l-mempool-scan.inc",
9u,
"mark_recursive_tree");
mark_recursive_tree(a1, a2[2]);
mark_recursive_tree(a1, a2[3]);
mark_recursive_tree(a1, a2[4]);
mark_recursive_lambda(a1, a2[1]);
v3 = *a2;
if ( *a2 )
{
if ( !(unsigned int)find_and_mark(*(unsigned __int64 **)(a1 + 24), v3, 24) )
_assert_fail(
"find_and_mark ((pool)->blocks, (node->token), sizeof (LToken))",
"src/l-mempool-scan.inc",
0x11u,
"mark_recursive_tree");
}
}
}

canonical_decompiled_code:
void __fastcall func4(__int64 a1, unsigned __int64 *a2)
{
unsigned __int64 v3; // rsi

if ( a2 )
{
if ( !(unsigned int)func1(*(unsigned __int64 **)(a1 + 24), (unsigned __int64)a2, 40) )
_assert_fail(
"find_and_mark ((pool)->blocks, (node), sizeof (LTreeNode))",
"src/l-mempool-scan.inc",
9u,
"mark_recursive_tree");
func4(a1, a2[2]);
func4(a1, a2[3]);
func4(a1, a2[4]);
func3(a1, a2[1]);
v3 = *a2;
if ( *a2 )
{
if ( !(unsigned int)func1(*(unsigned __int64 **)(a1 + 24), v3, 24) )
_assert_fail(
"find_and_mark ((pool)->blocks, (node->token), sizeof (LToken))",
"src/l-mempool-scan.inc",
0x11u,
"mark_recursive_tree");
}
}
}

original_code:
static void
mark_recursive_tree (LMempool *pool, LTreeNode *node)
{
 if (node == ((void *)0))
  return;
 ((void) sizeof ((find_and_mark ((pool)->blocks, (node), sizeof (LTreeNode))) ? 1 : 0), __extension__ ({ if (find_and_mark ((pool)->blocks, (node), sizeof (LTreeNode))) ; else __assert_fail ("find_and_mark ((pool)->blocks, (node), sizeof (LTreeNode))", "src/l-mempool-scan.inc", 9, __extension__ __PRETTY_FUNCTION__); }));
 mark_recursive_tree (pool, node->left);
 mark_recursive_tree (pool, node->right);
 mark_recursive_tree (pool, node->lazy);
 mark_recursive_lambda (pool, node->lambda);
 if (node->token != ((void *)0))
  ((void) sizeof ((find_and_mark ((pool)->blocks, (node->token), sizeof (LToken))) ? 1 : 0), __extension__ ({ if (find_and_mark ((pool)->blocks, (node->token), sizeof (LToken))) ; else __assert_fail ("find_and_mark ((pool)->blocks, (node->token), sizeof (LToken))", "src/l-mempool-scan.inc", 17, __extension__ __PRETTY_FUNCTION__); }));
}

canonical_original_code:
static void mark_recursive_tree(struct _LMempool *pool, struct _LTreeNode *node)
{
 if (node == ((void *)0))
  return;
 ((void) sizeof ((find_and_mark ((pool)->blocks, (node), sizeof (LTreeNode))) ? 1 : 0), __extension__ ({ if (find_and_mark ((pool)->blocks, (node), sizeof (LTreeNode))) ; else __assert_fail ("find_and_mark ((pool)->blocks, (node), sizeof (LTreeNode))", "src/l-mempool-scan.inc", 9, __extension__ __PRETTY_FUNCTION__); }));
 mark_recursive_tree (pool, node->left);
 mark_recursive_tree (pool, node->right);
 mark_recursive_tree (pool, node->lazy);
 mark_recursive_lambda (pool, node->lambda);
 if (node->token != ((void *)0))
  ((void) sizeof ((find_and_mark ((pool)->blocks, (node->token), sizeof (LToken))) ? 1 : 0), __extension__ ({ if (find_and_mark ((pool)->blocks, (node->token), sizeof (LToken))) ; else __assert_fail ("find_and_mark ((pool)->blocks, (node->token), sizeof (LToken))", "src/l-mempool-scan.inc", 17, __extension__ __PRETTY_FUNCTION__); }));
}

variable_types: struct _LTreeNode { struct LToken { char *name; int idx; struct _LLambda { struct _LListNode { struct LToken *token; struct _LListNode *next; } *args; struct _LTreeNode *body; struct _LLambda *next; } *parent; } *token; struct _LLambda *lambda; struct _LTreeNode *left; } *

user_defined_types: struct _LTreeNode { struct LToken *token; struct _LLambda *lambda; struct _LTreeNode *left; }


decompiled_code:
void __fastcall mark_recursive_assignment(__int64 a1, unsigned __int64 a2)
{
if ( !(unsigned int)find_and_mark(*(unsigned __int64 **)(a1 + 24), a2, 24) )
_assert_fail(
"find_and_mark ((pool)->blocks, (assignment), sizeof (LAssignment))",
"src/l-mempool-scan.inc",
0x17u,
"mark_recursive_assignment");
if ( !(unsigned int)find_and_mark(*(unsigned __int64 **)(a1 + 24), *(_QWORD *)a2, 24) )
_assert_fail(
"find_and_mark ((pool)->blocks, (assignment->lhs), sizeof (LToken))",
"src/l-mempool-scan.inc",
0x18u,
"mark_recursive_assignment");
mark_recursive_tree(a1, *(unsigned __int64 **)(a2 + 8));
}

canonical_decompiled_code:
void __fastcall func5(__int64 a1, unsigned __int64 a2)
{
if ( !(unsigned int)func1(*(unsigned __int64 **)(a1 + 24), a2, 24) )
_assert_fail(
"find_and_mark ((pool)->blocks, (assignment), sizeof (LAssignment))",
"src/l-mempool-scan.inc",
0x17u,
"mark_recursive_assignment");
if ( !(unsigned int)func1(*(unsigned __int64 **)(a1 + 24), *(_QWORD *)a2, 24) )
_assert_fail(
"find_and_mark ((pool)->blocks, (assignment->lhs), sizeof (LToken))",
"src/l-mempool-scan.inc",
0x18u,
"mark_recursive_assignment");
func4(a1, *(unsigned __int64 **)(a2 + 8));
}

original_code:
static void
mark_recursive_assignment (LMempool *pool, LAssignment *assignment)
{
 ((void) sizeof ((find_and_mark ((pool)->blocks, (assignment), sizeof (LAssignment))) ? 1 : 0), __extension__ ({ if (find_and_mark ((pool)->blocks, (assignment), sizeof (LAssignment))) ; else __assert_fail ("find_and_mark ((pool)->blocks, (assignment), sizeof (LAssignment))", "src/l-mempool-scan.inc", 23, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((find_and_mark ((pool)->blocks, (assignment->lhs), sizeof (LToken))) ? 1 : 0), __extension__ ({ if (find_and_mark ((pool)->blocks, (assignment->lhs), sizeof (LToken))) ; else __assert_fail ("find_and_mark ((pool)->blocks, (assignment->lhs), sizeof (LToken))", "src/l-mempool-scan.inc", 24, __extension__ __PRETTY_FUNCTION__); }));
 mark_recursive_tree (pool, assignment->rhs);
}

canonical_original_code:
static void mark_recursive_assignment(struct _LMempool *pool, struct _LAssignment *assignment)
{
 ((void) sizeof ((find_and_mark ((pool)->blocks, (assignment), sizeof (LAssignment))) ? 1 : 0), __extension__ ({ if (find_and_mark ((pool)->blocks, (assignment), sizeof (LAssignment))) ; else __assert_fail ("find_and_mark ((pool)->blocks, (assignment), sizeof (LAssignment))", "src/l-mempool-scan.inc", 23, __extension__ __PRETTY_FUNCTION__); }));
 ((void) sizeof ((find_and_mark ((pool)->blocks, (assignment->lhs), sizeof (LToken))) ? 1 : 0), __extension__ ({ if (find_and_mark ((pool)->blocks, (assignment->lhs), sizeof (LToken))) ; else __assert_fail ("find_and_mark ((pool)->blocks, (assignment->lhs), sizeof (LToken))", "src/l-mempool-scan.inc", 24, __extension__ __PRETTY_FUNCTION__); }));
 mark_recursive_tree (pool, assignment->rhs);
}

variable_types: struct _LAssignment { struct LToken { char *name; int idx; struct _LLambda { struct _LListNode { struct LToken *token; struct _LListNode *next; } *args; struct _LTreeNode { struct LToken *token; struct _LLambda *lambda; struct _LTreeNode *left; } *body; struct _LLambda *next; } *parent; } *lhs; struct _LTreeNode *rhs; struct _LAssignment *next; } *

user_defined_types: struct _LAssignment { struct LToken *lhs; struct _LTreeNode *rhs; struct _LAssignment *next; }


original_code:
void *
l_mempool_alloc (LMempool *pool, size_t size)
{
 void *ret;
 if (size == 0)
  return ((void *)0);
 if (pool->gc) {
  if (size % (sizeof (void *)) != 0)
   size = (size / (sizeof (void *)) + 1) * (sizeof (void *));
 }
 if ((pool->blocks->real_end - pool->blocks->end) < size) {
  do { size_t sz = (size), offset; MempoolNode *new_node = ((void *)0); if ((sz % ((pool)->page_size)) != 0) sz = (sz / ((pool)->page_size) + 1) * ((pool)->page_size); if ((new_node = (mmap (((void *)0), sz, 0x1 | 0x2, 0x02, pool->dev_zero_fd, 0))) == (void *) -1) perror ("ALLOC_NEW_NODE"); new_node->begin = ((char *) new_node) + sizeof (MempoolNode); offset = (sz / ((sizeof (void *)) * 8) + 1); if (offset % (sizeof (void *)) != 0) offset = (offset / (sizeof (void *)) + 1) * (sizeof (void *)); new_node->end = ((char *) (new_node->begin)) + offset; new_node->real_end = ((char *) new_node) + sz; new_node->next = (pool)->blocks; new_node->offset = offset; ((void) sizeof ((new_node->offset >= (((new_node->real_end - new_node->begin) / (sizeof (void *))) / 8 + 1)) ? 1 : 0), __extension__ ({ if (new_node->offset >= (((new_node->real_end - new_node->begin) / (sizeof (void *))) / 8 + 1)) ; else __assert_fail ("new_node->offset >= (((new_node->real_end - new_node->begin) / SIZEOF_PTR) / 8 + 1)", "src/l-mempool.c", 115, __extension__ __PRETTY_FUNCTION__); })); (pool)->blocks = new_node; (pool)->total_bytes += sz; } while (0);
 }
 ret = pool->blocks->end;
 pool->blocks->end += size;
 return ret;
}

canonical_original_code:
void *l_mempool_alloc(struct _LMempool *pool, unsigned long size)
{
 void *ret;
 if (size == 0)
  return ((void *)0);
 if (pool->gc) {
  if (size % (sizeof (void *)) != 0)
   size = (size / (sizeof (void *)) + 1) * (sizeof (void *));
 }
 if ((pool->blocks->real_end - pool->blocks->end) < size) {
  do { unsigned long sz = (size); unsigned long offset; struct _MempoolNode *new_node = ((void *)0); if ((sz % ((pool)->page_size)) != 0) sz = (sz / ((pool)->page_size) + 1) * ((pool)->page_size); if ((new_node = (mmap (((void *)0), sz, 0x1 | 0x2, 0x02, pool->dev_zero_fd, 0))) == (void *) -1) perror ("ALLOC_NEW_NODE"); new_node->begin = ((char *) new_node) + sizeof (MempoolNode); offset = (sz / ((sizeof (void *)) * 8) + 1); if (offset % (sizeof (void *)) != 0) offset = (offset / (sizeof (void *)) + 1) * (sizeof (void *)); new_node->end = ((char *) (new_node->begin)) + offset; new_node->real_end = ((char *) new_node) + sz; new_node->next = (pool)->blocks; new_node->offset = offset; ((void) sizeof ((new_node->offset >= (((new_node->real_end - new_node->begin) / (sizeof (void *))) / 8 + 1)) ? 1 : 0), __extension__ ({ if (new_node->offset >= (((new_node->real_end - new_node->begin) / (sizeof (void *))) / 8 + 1)) ; else __assert_fail ("new_node->offset >= (((new_node->real_end - new_node->begin) / SIZEOF_PTR) / 8 + 1)", "src/l-mempool.c", 115, __extension__ __PRETTY_FUNCTION__); })); (pool)->blocks = new_node; (pool)->total_bytes += sz; } while (0);
 }
 ret = pool->blocks->end;
 pool->blocks->end += size;
 return ret;
}

variable_types:
size
unsigned long

variable_types:
ret
void *

variable_types:
offset
unsigned long


decompiled_code:
unsigned __int64 __fastcall l_mempool_pre_alloc(__int64 a1, unsigned __int64 a2)
{
unsigned __int64 result; // rax
size_t v3; // r12
_QWORD *v4; // rbp
__int64 v5; // rdx

result = *(_QWORD *)(*(_QWORD *)(a1 + 24) + 16LL) - *(_QWORD *)(*(_QWORD *)(a1 + 24) + 8LL);
if ( result < a2 )
{
v3 = a2 + 40;
if ( (a2 + 40) % *(_QWORD *)a1 )
v3 = *(_QWORD *)a1 * ((a2 + 40) / *(_QWORD *)a1 + 1);
v4 = mmap(0LL, v3, 3, 2, *(_DWORD *)(a1 + 8), 0LL);
if ( v4 == (_QWORD *)-1LL )
perror("ALLOC_NEW_NODE");
*v4 = v4 + 5;
result = (v3 >> 6) + 1;
if ( (result & 7) != 0 )
result = 8 * (result >> 3) + 8;
v4[1] = (char *)v4 + result + 40;
v4[2] = (char *)v4 + v3;
v5 = *(_QWORD *)(a1 + 24);
*((_DWORD *)v4 + 6) = result;
result = (int)result;
v4[4] = v5;
if ( (int)result < ((v3 - 40) >> 6) + 1 )
_assert_fail(
"new_node->offset >= (((new_node->real_end - new_node->begin) / SIZEOF_PTR) / 8 + 1)",
"src/l-mempool.c",
0x7Fu,
"l_mempool_pre_alloc");
*(_QWORD *)(a1 + 16) += v3;
*(_QWORD *)(a1 + 24) = v4;
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func8(__int64 a1, unsigned __int64 a2)
{
unsigned __int64 result; // rax
size_t v3; // r12
_QWORD *v4; // rbp
__int64 v5; // rdx

result = *(_QWORD *)(*(_QWORD *)(a1 + 24) + 16LL) - *(_QWORD *)(*(_QWORD *)(a1 + 24) + 8LL);
if ( result < a2 )
{
v3 = a2 + 40;
if ( (a2 + 40) % *(_QWORD *)a1 )
v3 = *(_QWORD *)a1 * ((a2 + 40) / *(_QWORD *)a1 + 1);
v4 = mmap(0LL, v3, 3, 2, *(_DWORD *)(a1 + 8), 0LL);
if ( v4 == (_QWORD *)-1LL )
perror("ALLOC_NEW_NODE");
*v4 = v4 + 5;
result = (v3 >> 6) + 1;
if ( (result & 7) != 0 )
result = 8 * (result >> 3) + 8;
v4[1] = (char *)v4 + result + 40;
v4[2] = (char *)v4 + v3;
v5 = *(_QWORD *)(a1 + 24);
*((_DWORD *)v4 + 6) = result;
result = (int)result;
v4[4] = v5;
if ( (int)result < ((v3 - 40) >> 6) + 1 )
_assert_fail(
"new_node->offset >= (((new_node->real_end - new_node->begin) / SIZEOF_PTR) / 8 + 1)",
"src/l-mempool.c",
0x7Fu,
"l_mempool_pre_alloc");
*(_QWORD *)(a1 + 16) += v3;
*(_QWORD *)(a1 + 24) = v4;
}
return result;
}

original_code:
void
l_mempool_pre_alloc (LMempool *pool, size_t size)
{
 if ((pool->blocks->real_end - pool->blocks->end) < size)
  do { size_t sz = (size + sizeof (MempoolNode)), offset; MempoolNode *new_node = ((void *)0); if ((sz % ((pool)->page_size)) != 0) sz = (sz / ((pool)->page_size) + 1) * ((pool)->page_size); if ((new_node = (mmap (((void *)0), sz, 0x1 | 0x2, 0x02, pool->dev_zero_fd, 0))) == (void *) -1) perror ("ALLOC_NEW_NODE"); new_node->begin = ((char *) new_node) + sizeof (MempoolNode); offset = (sz / ((sizeof (void *)) * 8) + 1); if (offset % (sizeof (void *)) != 0) offset = (offset / (sizeof (void *)) + 1) * (sizeof (void *)); new_node->end = ((char *) (new_node->begin)) + offset; new_node->real_end = ((char *) new_node) + sz; new_node->next = (pool)->blocks; new_node->offset = offset; ((void) sizeof ((new_node->offset >= (((new_node->real_end - new_node->begin) / (sizeof (void *))) / 8 + 1)) ? 1 : 0), __extension__ ({ if (new_node->offset >= (((new_node->real_end - new_node->begin) / (sizeof (void *))) / 8 + 1)) ; else __assert_fail ("new_node->offset >= (((new_node->real_end - new_node->begin) / SIZEOF_PTR) / 8 + 1)", "src/l-mempool.c", 127, __extension__ __PRETTY_FUNCTION__); })); (pool)->blocks = new_node; (pool)->total_bytes += sz; } while (0);
}

canonical_original_code:
void l_mempool_pre_alloc(struct _LMempool *pool, unsigned long size)
{
 if ((pool->blocks->real_end - pool->blocks->end) < size)
  do { unsigned long sz = (size + sizeof (MempoolNode)); unsigned long offset; struct _MempoolNode *new_node = ((void *)0); if ((sz % ((pool)->page_size)) != 0) sz = (sz / ((pool)->page_size) + 1) * ((pool)->page_size); if ((new_node = (mmap (((void *)0), sz, 0x1 | 0x2, 0x02, pool->dev_zero_fd, 0))) == (void *) -1) perror ("ALLOC_NEW_NODE"); new_node->begin = ((char *) new_node) + sizeof (MempoolNode); offset = (sz / ((sizeof (void *)) * 8) + 1); if (offset % (sizeof (void *)) != 0) offset = (offset / (sizeof (void *)) + 1) * (sizeof (void *)); new_node->end = ((char *) (new_node->begin)) + offset; new_node->real_end = ((char *) new_node) + sz; new_node->next = (pool)->blocks; new_node->offset = offset; ((void) sizeof ((new_node->offset >= (((new_node->real_end - new_node->begin) / (sizeof (void *))) / 8 + 1)) ? 1 : 0), __extension__ ({ if (new_node->offset >= (((new_node->real_end - new_node->begin) / (sizeof (void *))) / 8 + 1)) ; else __assert_fail ("new_node->offset >= (((new_node->real_end - new_node->begin) / SIZEOF_PTR) / 8 + 1)", "src/l-mempool.c", 127, __extension__ __PRETTY_FUNCTION__); })); (pool)->blocks = new_node; (pool)->total_bytes += sz; } while (0);
}


decompiled_code:
void __fastcall l_mempool_destroy(void *ptr)
{
_QWORD *v2; // rbx
_QWORD *v3; // rdi

v2 = (_QWORD *)*((_QWORD *)ptr + 3);
while ( v2 )
{
v3 = v2;
v2 = (_QWORD *)v2[4];
munmap(v3, v3[2] - (_QWORD)v3);
}
close(*((_DWORD *)ptr + 2));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func9(void *ptr)
{
_QWORD *v2; // rbx
_QWORD *v3; // rdi

v2 = (_QWORD *)*((_QWORD *)ptr + 3);
while ( v2 )
{
v3 = v2;
v2 = (_QWORD *)v2[4];
munmap(v3, v3[2] - (_QWORD)v3);
}
close(*((_DWORD *)ptr + 2));
free(ptr);
}

original_code:
void
l_mempool_destroy (LMempool *pool)
{
 MempoolNode *i, *j;
 i = pool->blocks;
 while (i != ((void *)0)) {
  j = i->next;
  munmap (i, i->real_end - (void *) i);
  i = j;
 }
 close (pool->dev_zero_fd);
 free (pool);
}

canonical_original_code:
void l_mempool_destroy(struct _LMempool *pool)
{
 struct _MempoolNode *i; struct _MempoolNode *j;
 i = pool->blocks;
 while (i != ((void *)0)) {
  j = i->next;
  munmap (i, i->real_end - (void *) i);
  i = j;
 }
 close (pool->dev_zero_fd);
 free (pool);
}


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
if ( argc <= 1 )
l_start_repl(0LL, argv, envp);
else
l_start_repl(argv[1], argv, envp);
return 0;
}

original_code:
int
main (int argc, char **argv)
{
 if (argc < 2) {
  l_start_repl (((void *)0));
 } else {
  l_start_repl (argv [1]);
 }
 return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
 if (argc < 2) {
  l_start_repl (((void *)0));
 } else {
  l_start_repl (argv [1]);
 }
 return 0;
}

variable_types: argc int

variable_types:
argv
char **


original_code:
static void
replace_nonfree (LTreeNode *node, LLambda *parent, int token_idx)
{
 if (node != ((void *)0)) {
  if (node->lambda != ((void *)0)) {
   replace_nonfree (node->lambda->body, parent, token_idx);
  } else if (node->token != ((void *)0) && node->token->parent == ((void *)0) &&
             node->token->idx == token_idx) {
   node->token->parent = parent;
  }
  replace_nonfree (node->left, parent, token_idx);
  replace_nonfree (node->right, parent, token_idx);
 }
}

canonical_original_code:
static void replace_nonfree(struct _LTreeNode *node, struct _LLambda *parent, int token_idx)
{
 if (node != ((void *)0)) {
  if (node->lambda != ((void *)0)) {
   replace_nonfree (node->lambda->body, parent, token_idx);
  } else if (node->token != ((void *)0) && node->token->parent == ((void *)0) &&
             node->token->idx == token_idx) {
   node->token->parent = parent;
  }
  replace_nonfree (node->left, parent, token_idx);
  replace_nonfree (node->right, parent, token_idx);
 }
}

variable_types:
parent
struct _LLambda *


decompiled_code:
_BOOL8 __fastcall replace_by_token_id_predicate(__int64 a1, _DWORD *a2)
{
return *(_DWORD *)(a1 + 8) == *a2;
}

canonical_decompiled_code:
_BOOL8 __fastcall func1(__int64 a1, _DWORD *a2)
{
return *(_DWORD *)(a1 + 8) == *a2;
}

original_code:
static int
replace_by_token_id_predicate (LToken *token, void *user_data)
{
 int token_id = *((int *) user_data);
 return token->idx == token_id;
}

canonical_original_code:
static int replace_by_token_id_predicate(struct LToken *token, void *user_data)
{
 int token_id = *((int *) user_data);
 return token->idx == token_id;
}

variable_types: struct LToken { char *name; int idx; struct _LLambda { struct _LListNode { struct LToken *token; struct _LListNode *next; } *args; struct _LTreeNode { struct LToken *token; struct _LLambda *lambda; struct _LTreeNode *left; } *body; struct _LLambda *next; } *parent; } *


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

result = 0LL;
if ( *(_QWORD *)(a2 + 8) == *(_QWORD *)(a1 + 16) )
result = *(_DWORD *)a2 == *(_DWORD *)(a1 + 8);
return result;
}

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

result = 0LL;
if ( *(_QWORD *)(a2 + 8) == *(_QWORD *)(a1 + 16) )
result = *(_DWORD *)a2 == *(_DWORD *)(a1 + 8);
return result;
}

original_code:
static int
replace_by_param_id_predicate (LToken *token, void *user_data)
{
 ReplaceByParamArgs *args = user_data;
 return (args->parent == token->parent && args->param_idx == token->idx);
}

canonical_original_code:
static int replace_by_param_id_predicate(struct LToken *token, void *user_data)
{
 struct ReplaceByParamArgs *args = user_data;
 return (args->parent == token->parent && args->param_idx == token->idx);
}

variable_types: struct ReplaceByParamArgs { int param_idx; struct _LLambda { struct _LListNode { struct LToken { char *name; int idx; struct _LLambda *parent; } *token; struct _LListNode *next; } *args; struct _LTreeNode { struct LToken *token; struct _LLambda *lambda; struct _LTreeNode *left; } *body; struct _LLambda *next; } *parent; } *

user_defined_types: struct ReplaceByParamArgs { int param_idx; struct _LLambda *parent; }


strsplit

repo: santhoshn/panchanga

decompiled_code:
__int64 __fastcall strsplit(char *a1, char a2)
{
char v2; // al
int v3; // edx

v2 = *a1;
if ( !*a1 )
return 1LL;
v3 = 0;
do
{
if ( a2 == v2 )
{
*a1 = 32;
++v3;
}
v2 = *++a1;
}
while ( v2 );
return (unsigned int)(v3 + 1);
}

canonical_decompiled_code:
__int64 __fastcall func0(char *a1, char a2)
{
char v2; // al
int v3; // edx

v2 = *a1;
if ( !*a1 )
return 1LL;
v3 = 0;
do
{
if ( a2 == v2 )
{
*a1 = 32;
++v3;
}
v2 = *++a1;
}
while ( v2 );
return (unsigned int)(v3 + 1);
}

original_code:
int strsplit(char *str, char c)
{
 int n=0;
 char *tmp;
 for(tmp=str; *tmp; tmp++)
  if(*tmp==c) {
   *tmp=' ';
   n++;
  }
 return n+1;
}

canonical_original_code:
int strsplit(char *str, char c)
{
 int n = 0;
 char *tmp;
 for(tmp=str; *tmp; tmp++)
  if(*tmp==c) {
   *tmp=' ';
   n++;
  }
 return n+1;
}

variable_types:
str
char *

variable_types: c char

variable_types:
tmp
char *


decompiled_code:
void __fastcall __noreturn show_usage(int status)
{
fwrite("Usage: panchanga -d dd/mm/yyy -t hh:mm -z [+/-]hh:mm\n", 1uLL, 0x35uLL, stderr);
fwrite("-d : Date in dd/mm/yyyy format.\n", 1uLL, 0x20uLL, stderr);
fwrite("-t : Time in hh:mm 24-hour format.\n", 1uLL, 0x23uLL, stderr);
fwrite("-z : Zone with respect to GMT in [+/-]hh:mm format.\n", 1uLL, 0x34uLL, stderr);
exit(status);
}

canonical_decompiled_code:
void __fastcall __noreturn func1(int status)
{
fwrite("Usage: panchanga -d dd/mm/yyy -t hh:mm -z [+/-]hh:mm\n", 1uLL, 0x35uLL, stderr);
fwrite("-d : Date in dd/mm/yyyy format.\n", 1uLL, 0x20uLL, stderr);
fwrite("-t : Time in hh:mm 24-hour format.\n", 1uLL, 0x23uLL, stderr);
fwrite("-z : Zone with respect to GMT in [+/-]hh:mm format.\n", 1uLL, 0x34uLL, stderr);
exit(status);
}

original_code:
void show_usage(int ret)
{
 fprintf(stderr,"Usage: panchanga -d dd/mm/yyy -t hh:mm -z [+/-]hh:mm\n");
 fprintf(stderr,"-d : Date in dd/mm/yyyy format.\n");
 fprintf(stderr,"-t : Time in hh:mm 24-hour format.\n");
 fprintf(stderr,"-z : Zone with respect to GMT in [+/-]hh:mm format.\n");
 exit(ret);
}

variable_types: ret int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
double v4; // xmm0_8
unsigned int v6; // [rsp+0h] [rbp-210h] BYREF
unsigned int v7; // [rsp+4h] [rbp-20Ch] BYREF
int v8; // [rsp+8h] [rbp-208h] BYREF
int v9; // [rsp+Ch] [rbp-204h] BYREF
double v10; // [rsp+10h] [rbp-200h] BYREF
double v11; // [rsp+18h] [rbp-1F8h] BYREF
double v12; // [rsp+20h] [rbp-1F0h] BYREF
char dest[16]; // [rsp+28h] [rbp-1E8h] BYREF
int v14; // [rsp+38h] [rbp-1D8h]
char v15[16]; // [rsp+48h] [rbp-1C8h] BYREF
int v16; // [rsp+58h] [rbp-1B8h]
char v17[16]; // [rsp+68h] [rbp-1A8h] BYREF
int v18; // [rsp+78h] [rbp-198h]
char v19[16]; // [rsp+88h] [rbp-188h] BYREF
char v20[64]; // [rsp+98h] [rbp-178h] BYREF
char v21[64]; // [rsp+D8h] [rbp-138h] BYREF
char v22[64]; // [rsp+118h] [rbp-F8h] BYREF
char v23[64]; // [rsp+158h] [rbp-B8h] BYREF
char v24[64]; // [rsp+198h] [rbp-78h] BYREF
char v25[56]; // [rsp+1D8h] [rbp-38h] BYREF

opterr = 0;
v14 = 0;
v16 = 0;
v18 = 0;
*(_OWORD *)dest = 0LL;
*(_OWORD *)v15 = 0LL;
*(_OWORD *)v17 = 0LL;
while ( 1 )
{
v3 = getopt(argc, (char *const *)argv, "d:t:z:h");
if ( v3 == -1 )
break;
if ( v3 == 116 )
{
strcpy(v15, optarg);
}
else if ( v3 > 116 )
{
if ( v3 != 122 )
goto LABEL_24;
strcpy(v17, optarg);
}
else
{
if ( v3 != 100 )
{
if ( v3 == 104 )
show_usage(0);
if ( v3 == 63 )
{
fprintf(stderr, "Unknown option `-%c'.\n", (unsigned int)optopt);
exit(1);
}
LABEL_24:
main_cold();
}
strcpy(dest, optarg);
}
}
if ( !dest[0]
|| !v15[0]
|| !v17[0]
|| (unsigned int)strsplit(dest, 47) != 3
|| (_isoc99_sscanf(dest, "%lf %d %d", &v10, &v6, &v7), (unsigned int)strsplit(v15, 58) != 2)
|| (_isoc99_sscanf(v15, "%lf %d", &v11, &v8), v11 = (double)v8 / 60.0 + v11, (unsigned int)strsplit(v17, 58) != 2) )
{
show_usage(1);
}
_isoc99_sscanf(v17, "%lf %d", &v12, &v9);
v4 = (double)v9 / 60.0;
if ( v12 < 0.0 )
*(_QWORD *)&v4 ^= LC10;
v12 = v12 + v4;
calculate_panchanga((unsigned int)(int)v10, v6, v7, v19, v11);
printf("Tithi : %s, %s Paksha\n", v22, v24);
printf("Nakshatra : %s\n", v21);
printf("Yoga : %s\n", v20);
printf("Karana : %s\n", v23);
printf("Rashi : %s\n", v25);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // eax
double v4; // xmm0_8
unsigned int v6; // [rsp+0h] [rbp-210h] BYREF
unsigned int v7; // [rsp+4h] [rbp-20Ch] BYREF
int v8; // [rsp+8h] [rbp-208h] BYREF
int v9; // [rsp+Ch] [rbp-204h] BYREF
double v10; // [rsp+10h] [rbp-200h] BYREF
double v11; // [rsp+18h] [rbp-1F8h] BYREF
double v12; // [rsp+20h] [rbp-1F0h] BYREF
char dest[16]; // [rsp+28h] [rbp-1E8h] BYREF
int v14; // [rsp+38h] [rbp-1D8h]
char v15[16]; // [rsp+48h] [rbp-1C8h] BYREF
int v16; // [rsp+58h] [rbp-1B8h]
char v17[16]; // [rsp+68h] [rbp-1A8h] BYREF
int v18; // [rsp+78h] [rbp-198h]
char v19[16]; // [rsp+88h] [rbp-188h] BYREF
char v20[64]; // [rsp+98h] [rbp-178h] BYREF
char v21[64]; // [rsp+D8h] [rbp-138h] BYREF
char v22[64]; // [rsp+118h] [rbp-F8h] BYREF
char v23[64]; // [rsp+158h] [rbp-B8h] BYREF
char v24[64]; // [rsp+198h] [rbp-78h] BYREF
char v25[56]; // [rsp+1D8h] [rbp-38h] BYREF

opterr = 0;
v14 = 0;
v16 = 0;
v18 = 0;
*(_OWORD *)dest = 0LL;
*(_OWORD *)v15 = 0LL;
*(_OWORD *)v17 = 0LL;
while ( 1 )
{
v3 = getopt(argc, (char *const *)argv, "d:t:z:h");
if ( v3 == -1 )
break;
if ( v3 == 116 )
{
strcpy(v15, optarg);
}
else if ( v3 > 116 )
{
if ( v3 != 122 )
goto LABEL_24;
strcpy(v17, optarg);
}
else
{
if ( v3 != 100 )
{
if ( v3 == 104 )
func1(0);
if ( v3 == 63 )
{
fprintf(stderr, "Unknown option `-%c'.\n", (unsigned int)optopt);
exit(1);
}
LABEL_24:
func2();
}
strcpy(dest, optarg);
}
}
if ( !dest[0]
|| !v15[0]
|| !v17[0]
|| (unsigned int)func0(dest, 47) != 3
|| (_isoc99_sscanf(dest, "%lf %d %d", &v10, &v6, &v7), (unsigned int)func0(v15, 58) != 2)
|| (_isoc99_sscanf(v15, "%lf %d", &v11, &v8), v11 = (double)v8 / 60.0 + v11, (unsigned int)func0(v17, 58) != 2) )
{
func1(1);
}
_isoc99_sscanf(v17, "%lf %d", &v12, &v9);
v4 = (double)v9 / 60.0;
if ( v12 < 0.0 )
*(_QWORD *)&v4 ^= LC10;
v12 = v12 + v4;
calculate_panchanga((unsigned int)(int)v10, v6, v7, v19, v11);
printf("Tithi : %s, %s Paksha\n", v22, v24);
printf("Nakshatra : %s\n", v21);
printf("Yoga : %s\n", v20);
printf("Karana : %s\n", v23);
printf("Rashi : %s\n", v25);
return 0;
}

original_code:
int main(int argc, char **argv)
{
 char date[20]={0}, time[20]={0}, zone[20]={0};
 double dd, hr, zhr;
 int mm, yy, mn, zmn, c;
 struct panchanga pdata;
 opterr = 0;
 while((c=getopt(argc,argv,"d:t:z:h"))!=-1) {
       switch(c) {
   case 'd':
    strcpy(date,optarg);
    break;
   case 't':
    strcpy(time,optarg);
    break;
   case 'z':
    strcpy(zone,optarg);
    break;
   case 'h':
    show_usage(0);
   case '?':
    fprintf(stderr, "Unknown option `-%c'.\n", optopt);
    exit(1);
         default:
    abort();
  }
        }
 if(!date[0] || !time[0] || !zone[0])
  show_usage(1);
 if(strsplit(date,'/')!=3)
  show_usage(1);
 sscanf(date,"%lf %d %d",&dd,&mm,&yy);
 if(strsplit(time,':')!=2)
  show_usage(1);
 sscanf(time,"%lf %d",&hr,&mn);
 hr+=mn/60.0;
 if(strsplit(zone,':')!=2)
  show_usage(1);
 sscanf(zone,"%lf %d",&zhr,&zmn);
 zhr+=(zhr<0.0)?-(zmn/60.0):(zmn/60.0);
 calculate_panchanga(dd, mm, yy, hr, zhr, &pdata);
 printf("Tithi     : %s, %s Paksha\n", pdata.dtithi, pdata.dpaksha);
 printf("Nakshatra : %s\n", pdata.dnakshatra);
 printf("Yoga      : %s\n", pdata.dyoga);
 printf("Karana    : %s\n", pdata.dkarana);
 printf("Rashi     : %s\n", pdata.drashi);
}

canonical_original_code:
int main(int argc, char **argv)
{
 char date[20] = {0}; char time[20] = {0}; char zone[20] = {0};
 double dd; double hr; double zhr;
 int mm; int yy; int mn; int zmn; int c;
 struct panchanga pdata;
 opterr = 0;
 while((c=getopt(argc,argv,"d:t:z:h"))!=-1) {
       switch(c) {
   case 'd':
    strcpy(date,optarg);
    break;
   case 't':
    strcpy(time,optarg);
    break;
   case 'z':
    strcpy(zone,optarg);
    break;
   case 'h':
    show_usage(0);
   case '?':
    fprintf(stderr, "Unknown option `-%c'.\n", optopt);
    exit(1);
         default:
    abort();
  }
        }
 if(!date[0] || !time[0] || !zone[0])
  show_usage(1);
 if(strsplit(date,'/')!=3)
  show_usage(1);
 sscanf(date,"%lf %d %d",&dd,&mm,&yy);
 if(strsplit(time,':')!=2)
  show_usage(1);
 sscanf(time,"%lf %d",&hr,&mn);
 hr+=mn/60.0;
 if(strsplit(zone,':')!=2)
  show_usage(1);
 sscanf(zone,"%lf %d",&zhr,&zmn);
 zhr+=(zhr<0.0)?-(zmn/60.0):(zmn/60.0);
 calculate_panchanga(dd, mm, yy, hr, zhr, &pdata);
 printf("Tithi     : %s, %s Paksha\n", pdata.dtithi, pdata.dpaksha);
 printf("Nakshatra : %s\n", pdata.dnakshatra);
 printf("Yoga      : %s\n", pdata.dyoga);
 printf("Karana    : %s\n", pdata.dkarana);
 printf("Rashi     : %s\n", pdata.drashi);
}

variable_types:
date
char [20]

variable_types:
time
char [20]

variable_types:
zone
char [20]

variable_types: dd double

variable_types: hr double

variable_types: zhr double

variable_types: mm int

variable_types: yy int

variable_types: mn int

variable_types: zmn int

variable_types: c int

variable_types: struct panchanga { char dtoday[16]; char dyoga[64]; char dnakshatra[64]; char dtithi[64]; char dkarana[64]; char dpaksha[64]; char drashi[32]; }


variable_types: d double

variable_types: t double

variable_types: o double

variable_types: l double

variable_types: ayan double

return_type: double


variable_types: w double

variable_types: a double

variable_types: e double

variable_types: M double

variable_types: E double

variable_types: x double

variable_types: y double

variable_types: r double

variable_types: v double

variable_types: tmp double


original_code:
void calculate_panchanga(int dd, int mm, int yy, double hr, double zhr, struct panchanga *pdata)
{
 double d, ayanamsa, slon, mlon, tmlon, tslon;
 int n;
 d = (367*yy-7*(yy+(mm+9)/12)/4+275*mm/9+dd-730530);
 ayanamsa = calc_ayanamsa(d);
 slon = sun_long(d+((hr-zhr)/24.0));
 mlon = moon_long(d+((hr-zhr)/24.0));
 tmlon = mlon+((mlon<slon)?360:0);
 tslon = slon;
 n = (int)((tmlon-tslon)/12);
 strcpy(pdata->dtithi,tithi[n]);
 (n<=14)?strcpy(pdata->dpaksha,"Shukla"):strcpy(pdata->dpaksha,"Krishna");
 tmlon = ((mlon+ayanamsa)-floor((mlon+ayanamsa)/360.0)*360.0);
 strcpy(pdata->dnakshatra,nakshatra[(int)(tmlon*6/80)]);
 tmlon = mlon+ayanamsa;
 tslon = slon+ayanamsa;
 strcpy(pdata->dyoga,yoga[(int)(((tmlon+tslon)-floor((tmlon+tslon)/360.0)*360.0)*6/80)]);
 tmlon = mlon+((mlon<slon)?360:0);
 tslon = slon;
 n = (int)((tmlon-tslon)/6);
 if(n==0) n=10;
 if(n>=57) n-=50;
 if(n>0 && n<57) n=(n-1)-((n-1)/7*7);
 strcpy(pdata->dkarana,karan[n]);
 tmlon = ((mlon+ayanamsa)-floor((mlon+ayanamsa)/360.0)*360.0);
 strcpy(pdata->drashi,rashi[(int)(tmlon/30)]);
}

canonical_original_code:
void calculate_panchanga(int dd, int mm, int yy, double hr, double zhr, struct panchanga *pdata)
{
 double d; double ayanamsa; double slon; double mlon; double tmlon; double tslon;
 int n;
 d = (367*yy-7*(yy+(mm+9)/12)/4+275*mm/9+dd-730530);
 ayanamsa = calc_ayanamsa(d);
 slon = sun_long(d+((hr-zhr)/24.0));
 mlon = moon_long(d+((hr-zhr)/24.0));
 tmlon = mlon+((mlon<slon)?360:0);
 tslon = slon;
 n = (int)((tmlon-tslon)/12);
 strcpy(pdata->dtithi,tithi[n]);
 (n<=14)?strcpy(pdata->dpaksha,"Shukla"):strcpy(pdata->dpaksha,"Krishna");
 tmlon = ((mlon+ayanamsa)-floor((mlon+ayanamsa)/360.0)*360.0);
 strcpy(pdata->dnakshatra,nakshatra[(int)(tmlon*6/80)]);
 tmlon = mlon+ayanamsa;
 tslon = slon+ayanamsa;
 strcpy(pdata->dyoga,yoga[(int)(((tmlon+tslon)-floor((tmlon+tslon)/360.0)*360.0)*6/80)]);
 tmlon = mlon+((mlon<slon)?360:0);
 tslon = slon;
 n = (int)((tmlon-tslon)/6);
 if(n==0) n=10;
 if(n>=57) n-=50;
 if(n>0 && n<57) n=(n-1)-((n-1)/7*7);
 strcpy(pdata->dkarana,karan[n]);
 tmlon = ((mlon+ayanamsa)-floor((mlon+ayanamsa)/360.0)*360.0);
 strcpy(pdata->drashi,rashi[(int)(tmlon/30)]);
}

variable_types: dd int

variable_types: mm int

variable_types: yy int

variable_types: hr double

variable_types: zhr double

variable_types: struct panchanga { char dtoday[16]; char dyoga[64]; char dnakshatra[64]; char dtithi[64]; char dkarana[64]; char dpaksha[64]; char drashi[32]; } *

variable_types: ayanamsa double

variable_types: slon double

variable_types: mlon double

variable_types: tmlon double

variable_types: tslon double

variable_types: n int


repo: santifa/paralleles-rechnen

decompiled_code:
float random_range()
{
double v0; // xmm1_8
int v1; // eax

v0 = pr_random();
return (double)v1 / 714025.0 * v0;
}

canonical_decompiled_code:
float func8()
{
double v0; // xmm1_8
int v1; // eax

v0 = func7();
return (double)v1 / 714025.0 * v0;
}

original_code:
float random_range(double range) {
return ((double) pr_random() / (double) 714025) * range;
}

variable_types: range double

return_type: float


original_code:
pi_t *calculate_pi(pi_t *pi) {
unsigned long hits = 0;
double x, y;
int i;

#pragma omp parallel private(i,x,y) reduction(+:hits)
{

#pragma omp for schedule(dynamic)
    for (i = pi->samples; i <= 0; i--) {
        x = random_range(1.0);
        y = random_range(1.0);
        if (x*x + y*y <= 1) {
            hits++;
        }
    }
}
printf("Hits: %lu \t", hits);
pi->result = (double) 4 * hits / pi->samples;
pi->error = (pi->result - 3.14159265358979323846) / 3.14159265358979323846;
return pi;
}

canonical_original_code:
struct pi_t *calculate_pi(struct pi_t *pi) {
unsigned long hits = 0;
double x; double y;
int i;

#pragma omp parallel private(i,x,y) reduction(+:hits)
{

#pragma omp for schedule(dynamic)
    for (i = pi->samples; i <= 0; i--) {
        x = random_range(1.0);
        y = random_range(1.0);
        if (x*x + y*y <= 1) {
            hits++;
        }
    }
}
printf("Hits: %lu \t", hits);
pi->result = (double) 4 * hits / pi->samples;
pi->error = (pi->result - 3.14159265358979323846) / 3.14159265358979323846;
return pi;
}

variable_types:
pi
struct pi_t *

variable_types:
hits
unsigned long

variable_types: x double

variable_types: y double

variable_types: i int

return_type: struct pi_t { double result; unsigned long samples; double error; } *


decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_QWORD *v3; // rax
_QWORD *v4; // rbp
const char *v5; // rdi
int v6; // eax
const char *v7; // rdi
double *v8; // rbp
__time_t v9; // rsi
__syscall_slong_t v10; // rcx
struct timespec v12; // [rsp+0h] [rbp-38h] BYREF
struct timespec tp; // [rsp+10h] [rbp-28h] BYREF

clock_gettime(2, &v12);
if ( argc != 3 )
{
puts("Falsche argument anzahl.");
exit(1);
}
v3 = malloc(0x18uLL);
v4 = v3;
if ( !v3 )
{
puts("Something went wrong.");
exit(1);
}
*v3 = 0LL;
v5 = argv[1];
v3[2] = 0LL;
v6 = atoi(v5);
v7 = argv[2];
v4[1] = v6;
atoi(v7);
omp_set_num_threads();
v8 = (double *)calculate_pi(v4);
printf("Pi ist %f10 .\n", *v8);
printf(aDerFehlerBetr, v8[2]);
free(v8);
clock_gettime(2, &tp);
v9 = tp.tv_sec - v12.tv_sec;
v10 = tp.tv_nsec - v12.tv_nsec;
if ( tp.tv_nsec - v12.tv_nsec < 0 )
{
--v9;
v10 = tp.tv_nsec + 1000000000 - v12.tv_nsec;
}
printf("Zeit %ld msec", v10 / 1000000 + 1000 * v9);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
_QWORD *v3; // rax
_QWORD *v4; // rbp
const char *v5; // rdi
int v6; // eax
const char *v7; // rdi
double *v8; // rbp
__time_t v9; // rsi
__syscall_slong_t v10; // rcx
struct timespec v12; // [rsp+0h] [rbp-38h] BYREF
struct timespec tp; // [rsp+10h] [rbp-28h] BYREF

clock_gettime(2, &v12);
if ( argc != 3 )
{
puts("Falsche argument anzahl.");
exit(1);
}
v3 = malloc(0x18uLL);
v4 = v3;
if ( !v3 )
{
puts("Something went wrong.");
exit(1);
}
*v3 = 0LL;
v5 = argv[1];
v3[2] = 0LL;
v6 = atoi(v5);
v7 = argv[2];
v4[1] = v6;
atoi(v7);
omp_set_num_threads();
v8 = (double *)func10(v4);
printf("Pi ist %f10 .\n", *v8);
printf(aDerFehlerBetr, v8[2]);
free(v8);
clock_gettime(2, &tp);
v9 = tp.tv_sec - v12.tv_sec;
v10 = tp.tv_nsec - v12.tv_nsec;
if ( tp.tv_nsec - v12.tv_nsec < 0 )
{
--v9;
v10 = tp.tv_nsec + 1000000000 - v12.tv_nsec;
}
printf("Zeit %ld msec", v10 / 1000000 + 1000 * v9);
return 0;
}

original_code:
int main(int argc, const char *argv[]) {
    pi_t *pi;
    unsigned long msec;
    struct timespec start, end, tmp;
    clock_gettime(2, &start);
    if (argc != 3) {
        printf("Falsche argument anzahl.\n");
        exit(1);
    }
    pi = (pi_t *) malloc(sizeof(pi_t));
    if (pi == ((void *)0)) {
        printf("Something went wrong.\n");
        exit(1);
    } else {
        pi->result = 0.0;
        pi->error = 0.0;
        pi->samples = atoi(argv[1]);
        omp_set_num_threads(atoi(argv[2]));
        pi = calculate_pi(pi);
        printf("Pi ist %f10 .\n", pi->result);
        printf("Der Fehler beträgt: %f10\n", pi->error);
        free(pi);
        pi = ((void *)0);
    }
    clock_gettime(2, &end);
    if ((end.tv_nsec - start.tv_nsec) < 0) {
        tmp.tv_sec = end.tv_sec - start.tv_sec - 1;
        tmp.tv_nsec = 1000000000 + end.tv_nsec - start.tv_nsec;
    } else {
        tmp.tv_sec = end.tv_sec - start.tv_sec;
        tmp.tv_nsec = end.tv_nsec - start.tv_nsec;
    }
    msec = tmp.tv_sec * 1000;
    msec += tmp.tv_nsec / 1000000;
    printf("Zeit %ld msec", msec);
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[]) {
    struct pi_t *pi;
    unsigned long msec;
    struct timespec start; struct timespec end; struct timespec tmp;
    clock_gettime(2, &start);
    if (argc != 3) {
        printf("Falsche argument anzahl.\n");
        exit(1);
    }
    pi = (struct pi_t *) malloc(sizeof(pi_t));
    if (pi == ((void *)0)) {
        printf("Something went wrong.\n");
        exit(1);
    } else {
        pi->result = 0.0;
        pi->error = 0.0;
        pi->samples = atoi(argv[1]);
        omp_set_num_threads(atoi(argv[2]));
        pi = calculate_pi(pi);
        printf("Pi ist %f10 .\n", pi->result);
        printf("Der Fehler beträgt: %f10\n", pi->error);
        free(pi);
        pi = ((void *)0);
    }
    clock_gettime(2, &end);
    if ((end.tv_nsec - start.tv_nsec) < 0) {
        tmp.tv_sec = end.tv_sec - start.tv_sec - 1;
        tmp.tv_nsec = 1000000000 + end.tv_nsec - start.tv_nsec;
    } else {
        tmp.tv_sec = end.tv_sec - start.tv_sec;
        tmp.tv_nsec = end.tv_nsec - start.tv_nsec;
    }
    msec = tmp.tv_sec * 1000;
    msec += tmp.tv_nsec / 1000000;
    printf("Zeit %ld msec", msec);
    return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types: struct pi_t { double result; unsigned long samples; double error; } *

variable_types:
msec
unsigned long

variable_types: struct timespec { long tv_sec; long tv_nsec; }


decompiled_code:
__int64 pr_random()
{
__int64 result; // rax

result = (unsigned int)((int)(1366 * __readfsdword(0xFFFFFFFC) + 150889) % 714025);
__writefsdword(0xFFFFFFFC, result);
return result;
}

canonical_decompiled_code:
__int64 func7()
{
__int64 result; // rax

result = (unsigned int)((int)(1366 * __readfsdword(0xFFFFFFFC) + 150889) % 714025);
__writefsdword(0xFFFFFFFC, result);
return result;
}

original_code:
int pr_random(void){
return (state = (1366 * state + 150889) % 714025);
}


decompiled_code:
double pr_random_f()
{
double v0; // xmm1_8
int v1; // eax

v0 = pr_random();
return (double)v1 / 714025.0 * v0;
}

canonical_decompiled_code:
double func8()
{
double v0; // xmm1_8
int v1; // eax

v0 = func7();
return (double)v1 / 714025.0 * v0;
}

original_code:
double pr_random_f(double range){
    return ((double) pr_random() / (double) 714025) * range;
}


piGenerator

decompiled_code:
void *__fastcall piGenerator(void *a1)
{
unsigned __int64 v2; // rsi
double v3; // xmm2_8
double v4; // xmm0_8

if ( *(_QWORD *)a1 )
{
v2 = 0LL;
do
{
v3 = pr_random_f();
v4 = pr_random_f();
if ( v3 * v3 + v4 * v4 <= 1.0 )
++*((_QWORD *)a1 + 1);
++v2;
}
while ( *(_QWORD *)a1 > v2 );
}
return a1;
}

canonical_decompiled_code:
void *__fastcall func9(void *a1)
{
unsigned __int64 v2; // rsi
double v3; // xmm2_8
double v4; // xmm0_8

if ( *(_QWORD *)a1 )
{
v2 = 0LL;
do
{
v3 = func8();
v4 = func8();
if ( v3 * v3 + v4 * v4 <= 1.0 )
++*((_QWORD *)a1 + 1);
++v2;
}
while ( *(_QWORD *)a1 > v2 );
}
return a1;
}

original_code:
static void *piGenerator(void *arg){
    data *f=(data *)arg;
    unsigned long i ;
    for ( i = 0; i < f->iter; ++i){
        double x = pr_random_f(1.000);
        double y = pr_random_f(1.000);
        if (x*x + y*y <= 1.0){
            f->value++;
        }
    }
    return arg;
}

canonical_original_code:
static void *piGenerator(void *arg){
    struct data *f = (data *)arg;
    unsigned long i;
    for ( i = 0; i < f->iter; ++i){
        double x = pr_random_f(1.000);
        double y = pr_random_f(1.000);
        if (x*x + y*y <= 1.0){
            f->value++;
        }
    }
    return arg;
}

variable_types:
arg
void *

variable_types:
f
struct data { unsigned long iter; } *

variable_types:
i
unsigned long


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__int64 v3; // r12
signed __int64 v4; // rax
void *v5; // rsp
void *v6; // rsp
__time_t v7; // rsi
__syscall_slong_t v8; // rcx
__int64 *v10; // [rsp+0h] [rbp-60h] BYREF
struct timespec tp; // [rsp+10h] [rbp-50h] BYREF
struct timespec v12; // [rsp+20h] [rbp-40h] BYREF

v3 = atoi(argv[1]);
atoi(argv[2]);
v4 = 16 * ((unsigned __int64)(8 * v3 + 15) >> 4);
v5 = alloca(v4);
v6 = alloca(v4);
v10 = (__int64 *)&v10;
clock_gettime(2, &tp);
puts("Falsche Parameter anzahl");
clock_gettime(2, &v12);
v7 = v12.tv_sec - tp.tv_sec;
v8 = v12.tv_nsec - tp.tv_nsec;
if ( v12.tv_nsec - tp.tv_nsec < 0 )
{
--v7;
v8 = v12.tv_nsec + 1000000000 - tp.tv_nsec;
}
printf("Zeit %lld msec", v8 / 1000000 + 1000 * v7);
return 0;
}

original_code:
int main(int argc, const char *argv[]){
    unsigned long thcount = atoi(argv[1]);
    unsigned long stepcount = atoi(argv[2]);
    unsigned long i;
    unsigned long long msec;
    struct timespec start, end, tmp;
    pthread_t th[thcount];
    data *ret[thcount];
    double erg = 0.0;
    clock_gettime(2, &start);
    if (argc != 3){
        printf("%s\n", "Falsche Parameter anzahl");
    }
    else {
        for ( i = 0; i < thcount; i++) {
            ret[i] = (data*)malloc(sizeof(data));
            if(ret[i] == ((void *)0)) {
                printf("Konnte keinen Speicher reservieren ...!\n");
                exit(1);
            }
            ret[i]->iter = stepcount / thcount;
            if (i == 0){
                ret[i]->iter = ret[i]->iter + (stepcount % thcount);
            }
            if(pthread_create(&th[i], ((void *)0), &piGenerator, ret[i]) != 0) {
                fprintf (stderr, "Konnte Thread nicht erzeugen\n");
                exit (1);
            }
        }
        for( i=0; i < thcount; i++){
            pthread_join(th[i], (void**) &ret[i]);
            erg = erg + ret[i]->value;
        }
        erg = 4*(erg/stepcount);
        printf("Ergebnis: %f\n", erg);
        printf("relativer Fehler : %f\n", (erg - 3.14159265358979323846) / 3.14159265358979323846);
    }
    clock_gettime(2, &end);
    if ((end.tv_nsec - start.tv_nsec) < 0) {
        tmp.tv_sec = end.tv_sec - start.tv_sec - 1;
        tmp.tv_nsec = 1000000000 + end.tv_nsec - start.tv_nsec;
    } else {
        tmp.tv_sec = end.tv_sec - start.tv_sec;
        tmp.tv_nsec = end.tv_nsec - start.tv_nsec;
    }
    msec = tmp.tv_sec * 1000;
    msec += tmp.tv_nsec / 1000000;
    printf("Zeit %lld msec", msec);
    return 0;
}

canonical_original_code:
int main(int argc, char *argv[]){
    unsigned long thcount = atoi(argv[1]);
    unsigned long stepcount = atoi(argv[2]);
    unsigned long i;
    unsigned long long msec;
    struct timespec start; struct timespec end; struct timespec tmp;
    unsigned long th[-1];
    struct data *ret[-1];
    double erg = 0.0;
    clock_gettime(2, &start);
    if (argc != 3){
        printf("%s\n", "Falsche Parameter anzahl");
    }
    else {
        for ( i = 0; i < thcount; i++) {
            ret[i] = (struct data *)malloc(sizeof(data));
            if(ret[i] == ((void *)0)) {
                printf("Konnte keinen Speicher reservieren ...!\n");
                exit(1);
            }
            ret[i]->iter = stepcount / thcount;
            if (i == 0){
                ret[i]->iter = ret[i]->iter + (stepcount % thcount);
            }
            if(pthread_create(&th[i], ((void *)0), &piGenerator, ret[i]) != 0) {
                fprintf (stderr, "Konnte Thread nicht erzeugen\n");
                exit (1);
            }
        }
        for( i=0; i < thcount; i++){
            pthread_join(th[i], (void **) &ret[i]);
            erg = erg + ret[i]->value;
        }
        erg = 4*(erg/stepcount);
        printf("Ergebnis: %f\n", erg);
        printf("relativer Fehler : %f\n", (erg - 3.14159265358979323846) / 3.14159265358979323846);
    }
    clock_gettime(2, &end);
    if ((end.tv_nsec - start.tv_nsec) < 0) {
        tmp.tv_sec = end.tv_sec - start.tv_sec - 1;
        tmp.tv_nsec = 1000000000 + end.tv_nsec - start.tv_nsec;
    } else {
        tmp.tv_sec = end.tv_sec - start.tv_sec;
        tmp.tv_nsec = end.tv_nsec - start.tv_nsec;
    }
    msec = tmp.tv_sec * 1000;
    msec += tmp.tv_nsec / 1000000;
    printf("Zeit %lld msec", msec);
    return 0;
}

variable_types:
thcount
unsigned long

variable_types:
stepcount
unsigned long

variable_types:
msec
unsigned long long

variable_types:
th
unsigned long [-1]

variable_types: struct data { unsigned long iter; } *[-1]

variable_types: erg double

user_defined_types: struct timespec { long tv_sec; long tv_nsec; }


original_code:
int pr_random(void){
    static int state = 0;
    return (state = (1366 * state + 150889) % 714025);
}

canonical_original_code:
int pr_random(){
    static int state = 0;
    return (state = (1366 * state + 150889) % 714025);
}

variable_types: state int


repo: santoshs/noncoreutils

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

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

original_code:
int get_week_of_year(time_t * t)
{
 return 0;
}

canonical_original_code:
int get_week_of_year(long *t)
{
 return 0;
}

variable_types:
t
long *


decompiled_code:
__int64 __fastcall del_slashn(void *dest)
{
unsigned __int8 *v1; // rbx
int v2; // ebp
__int64 result; // rax
int v4; // er12
unsigned __int8 *v5; // rdi

v1 = (unsigned __int8 *)dest;
v2 = strlen((const char *)dest);
result = *(unsigned __int8 *)dest;
if ( (_BYTE)result )
{
v4 = (_DWORD)dest + 1;
do
{
while ( 1 )
{
v5 = v1++;
if ( (_BYTE)result == 10 )
break;
result = *v1;
if ( !(_BYTE)result )
return result;
}
memmove(v5, v1, v4 + v2 - (int)v1);
result = *v1;
}
while ( (_BYTE)result );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func10(void *dest)
{
unsigned __int8 *v1; // rbx
int v2; // ebp
__int64 result; // rax
int v4; // er12
unsigned __int8 *v5; // rdi

v1 = (unsigned __int8 *)dest;
v2 = strlen((const char *)dest);
result = *(unsigned __int8 *)dest;
if ( (_BYTE)result )
{
v4 = (_DWORD)dest + 1;
do
{
while ( 1 )
{
v5 = v1++;
if ( (_BYTE)result == 10 )
break;
result = *v1;
if ( !(_BYTE)result )
return result;
}
memmove(v5, v1, v4 + v2 - (int)v1);
result = *v1;
}
while ( (_BYTE)result );
}
return result;
}

original_code:
void del_slashn(char *str)
{
 char *s = str;
 int len = strlen(str), i = 0;
 while (*s) {
  if (*s == '\n')
   memmove(s, s + 1, len - i);
  i++, s++;
 }
}

canonical_original_code:
void del_slashn(char *str)
{
 char *s = str;
 int len = strlen(str); int i = 0;
 while (*s) {
  if (*s == '\n')
   memmove(s, s + 1, len - i);
  i++, s++;
 }
}

variable_types:
str
char *

variable_types:
s
char *

variable_types: len int

variable_types: i int


strip

decompiled_code:
void *__fastcall strip(void *dest)
{
const unsigned __int16 *v2; // rbx
__int64 v3; // rdx
char *v4; // rax

v2 = *__ctype_b_loc();
while ( 1 )
{
v3 = *(char *)dest;
if ( (v2[v3] & 0x2000) == 0 )
break;
dest = (char *)dest + 1;
}
if ( (_BYTE)v3 )
{
v4 = (char *)dest + strlen((const char *)dest) - 1;
if ( dest < v4 )
{
do
{
if ( (v2[*v4] & 0x2000) == 0 )
break;
--v4;
}
while ( dest != v4 );
}
v4[1] = 0;
del_slashn(dest);
}
return dest;
}

canonical_decompiled_code:
void *__fastcall func11(void *dest)
{
const unsigned __int16 *v2; // rbx
__int64 v3; // rdx
char *v4; // rax

v2 = *__ctype_b_loc();
while ( 1 )
{
v3 = *(char *)dest;
if ( (v2[v3] & 0x2000) == 0 )
break;
dest = (char *)dest + 1;
}
if ( (_BYTE)v3 )
{
v4 = (char *)dest + strlen((const char *)dest) - 1;
if ( dest < v4 )
{
do
{
if ( (v2[*v4] & 0x2000) == 0 )
break;
--v4;
}
while ( dest != v4 );
}
v4[1] = 0;
func10(dest);
}
return dest;
}

original_code:
char *strip(char *str)
{
 register char *s, *t;
 for (s = str; ((*__ctype_b_loc ())[(int) ((*s))] & (unsigned short int) _ISspace); s++) ;
 if (*s == 0)
  return (s);
 t = s + strlen(s) - 1;
 while (t > s && ((*__ctype_b_loc ())[(int) ((*t))] & (unsigned short int) _ISspace))
  t--;
 *++t = '\0';
 del_slashn(s);
 return s;
}

canonical_original_code:
char *strip(char *str)
{
 register char *s; register char *t;
 for (s = str; ((*__ctype_b_loc ())[(int) ((*s))] & (unsigned short) _ISspace); s++) ;
 if (*s == 0)
  return (s);
 t = s + strlen(s) - 1;
 while (t > s && ((*__ctype_b_loc ())[(int) ((*t))] & (unsigned short) _ISspace))
  t--;
 *++t = '\0';
 del_slashn(s);
 return s;
}

variable_types:
t
char *

return_type: char *


main

repo: saper/strp

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
const char *v4; // rsi
const char *v5; // rdi
char *v6; // rbp
int result; // eax
const char *i; // rbx
struct tm v9; // [rsp+0h] [rbp-58h] BYREF

if ( argc == 3 )
{
v4 = argv[2];
v5 = argv[1];
v9.tm_mday = 5555;
*(_QWORD *)&v9.tm_mon = 0x15B3000015B3LL;
v9.tm_yday = 5555;
v6 = strptime(v5, v4, &v9);
fprintf(stderr, "%p\n", v6);
result = 0;
if ( v6 )
{
fprintf(stderr, "%s\n", argv[1]);
for ( i = argv[1]; *i; ++i )
{
if ( v6 <= i )
break;
fputc(32, stderr);
}
fwrite("^\n", 1uLL, 2uLL, stderr);
fprintf(
stdout,
"Year = %d, month = %d, day = %d, days = %d\n",
(unsigned int)v9.tm_year,
(unsigned int)v9.tm_mon,
(unsigned int)v9.tm_mday,
(unsigned int)v9.tm_yday);
result = 0;
}
}
else
{
fwrite("Usage: strp date format\n", 1uLL, 0x18uLL, stderr);
result = 255;
}
return result;
}

original_code:
int
main(int argc, char **argv)
{
 struct tm tp;
 char *out, *p;
 if (argc != 3) {
  fprintf(stderr, "Usage: strp date format\n");
  return 255;
 }
 tp.tm_year = 5555;
 tp.tm_mon = 5555;
 tp.tm_mday = 5555;
 tp.tm_yday = 5555;
 out = strptime(argv[1], argv[2], &tp);
 fprintf(stderr, "%p\n", out);
 if (out != ((void *)0)) {
  fprintf(stderr, "%s\n", argv[1]);
  for(p = argv[1]; *p && p < out; p++)
   fprintf(stderr, " ");
  fprintf(stderr, "^\n");
  fprintf(stdout, "Year = %d, month = %d, day = %d, days = %d\n",
   tp.tm_year, tp.tm_mon, tp.tm_mday, tp.tm_yday);
 }
 return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
 struct tm tp;
 char *out; char *p;
 if (argc != 3) {
  fprintf(stderr, "Usage: strp date format\n");
  return 255;
 }
 tp.tm_year = 5555;
 tp.tm_mon = 5555;
 tp.tm_mday = 5555;
 tp.tm_yday = 5555;
 out = strptime(argv[1], argv[2], &tp);
 fprintf(stderr, "%p\n", out);
 if (out != ((void *)0)) {
  fprintf(stderr, "%s\n", argv[1]);
  for(p = argv[1]; *p && p < out; p++)
   fprintf(stderr, " ");
  fprintf(stderr, "^\n");
  fprintf(stdout, "Year = %d, month = %d, day = %d, days = %d\n",
   tp.tm_year, tp.tm_mon, tp.tm_mday, tp.tm_yday);
 }
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: struct tm { int tm_sec; int tm_min; int tm_hour; int tm_mday; int tm_mon; int tm_year; int tm_wday; int tm_yday; int tm_isdst; long __tm_gmtoff; char *__tm_zone; }

variable_types:
out
char *

variable_types:
p
char *


repo: sardylan/netgraph

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
startup(argc, argv, envp);
if ( (unsigned int)ngCheckSystem() == 1 )
{
fwrite("OK\n", 1uLL, 3uLL, stderr);
mainLoop();
}
fwrite("ERROR\n", 1uLL, 6uLL, stderr);
fwrite("File /proc/net/dev doesn't exists!!!\n", 1uLL, 0x25uLL, stderr);
uiByeBye();
return 1;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
func7(argc, argv, envp);
if ( (unsigned int)func8() == 1 )
{
fwrite("OK\n", 1uLL, 3uLL, stderr);
func9();
}
fwrite("ERROR\n", 1uLL, 6uLL, stderr);
fwrite("File /proc/net/dev doesn't exists!!!\n", 1uLL, 0x25uLL, stderr);
func11();
return 1;
}

original_code:
int main(int argc, char **argv)
{
    int ret;
    ret = 0;
    startup();
    if(ngCheckSystem() == 1) {
        fprintf(stderr, "OK\n");
        mainLoop();
    } else {
        fprintf(stderr, "ERROR\n");
        fprintf(stderr, "File /proc/net/dev doesn't exists!!!\n");
        ret = 1;
    }
    uiByeBye();
    return ret;
}

variable_types: ret int


startup

decompiled_code:
__int64 startup()
{
return uiWelcome();
}

canonical_decompiled_code:
__int64 func7()
{
return func10();
}

original_code:
void startup()
{
    uiWelcome();
}

canonical_original_code:
void startup()
{
    uiWelcome();
}


uiByeBye

decompiled_code:
int uiByeBye()
{
return puts("\n\n");
}

canonical_decompiled_code:
int func11()
{
return puts("\n\n");
}

original_code:
void uiByeBye()
{
    printf("\n\n\n");
}

canonical_original_code:
void uiByeBye()
{
    printf("\n\n\n");
}