original_code:
uint32_t smbios_probe(device_t *dev)
{
 char *mem = (unsigned char *) 0xF0000;
 uint32_t length, i;
 char checksum;
 while ((uint32_t) mem < 0x100000)
 {
  if(mem[0] == '_' && mem[1] == 'S' && mem[2] == 'M' && mem[3] == '_')
  {
   length = mem[5];
   checksum = 0;
   for(i = 0; i < length; i++)
    checksum += mem[i];
   if(checksum == 0)
   {
    smbios_mem = mem;
    driver_puts(&driver_smbios, 0x1, "found");
    return 1;
   }
  }
  mem += 16;
 }
 return 0;
}

canonical_original_code:
unsigned int smbios_probe(struct device_p *dev)
{
 char *mem = (unsigned char *) 0xF0000;
 unsigned int length; unsigned int i;
 char checksum;
 while ((unsigned int) mem < 0x100000)
 {
  if(mem[0] == '_' && mem[1] == 'S' && mem[2] == 'M' && mem[3] == '_')
  {
   length = mem[5];
   checksum = 0;
   for(i = 0; i < length; i++)
    checksum += mem[i];
   if(checksum == 0)
   {
    smbios_mem = mem;
    driver_puts(&driver_smbios, 0x1, "found");
    return 1;
   }
  }
  mem += 16;
 }
 return 0;
}

variable_types: struct device_p { unsigned int io_base; char vendor[32]; char vendor_full[32]; char device[32]; char device_desc[32]; char class[32]; char class_desc[32]; char class_prog_desc[32]; unsigned char bus_type; void *pci_dev; unsigned char interrupt; unsigned int base_addresses[6]; char file[32]; struct device_p *next; } *

variable_types:
mem
char *

variable_types:
length
unsigned int

variable_types:
i
unsigned int

variable_types: checksum char


repo: dakk/spiderpig-os

decompiled_code:
__int64 smbios_init()
{
__int64 v0; // rbp
int v1; // ebx
__int64 v2; // r12
__int64 v3; // rsi
__int64 result; // rax

if ( smbios_mem || (unsigned int)smbios_probe(0LL) )
{
devfs_reg_device(0LL, 0LL, "smbios0");
v0 = smbios_mem;
if ( *(_WORD *)(smbios_mem + 28) )
{
v1 = 0;
do
{
while ( 1 )
{
v2 = *(_DWORD *)(v0 + 24) + v1 * (unsigned int)*(unsigned __int16 *)(v0 + 22);
if ( *(_BYTE *)v2 == 4 )
break;
if ( *(unsigned __int16 *)(v0 + 28) <= ++v1 )
goto LABEL_7;
}
v3 = *((unsigned __int8 *)&loc_E0 + *(_DWORD *)(v0 + 24) + v1 * (unsigned int)*(unsigned __int16 *)(v0 + 22) + 3);
++v1;
printf("core_count: %d\n", v3);
printf("core_enabled: %d\n", *(unsigned __int8 *)(v2 + 228));
printf("voltage: %d\n", *(unsigned __int8 *)(v2 + 209));
printf("max_speed: %d\n", *(unsigned __int16 *)(v2 + 212));
}
while ( *(unsigned __int16 *)(v0 + 28) > v1 );
}
LABEL_7:
result = 0LL;
}
else
{
driver_puts(driver_smbios, 2LL, "cannot found a valid smbios table");
result = 10LL;
}
return result;
}

canonical_decompiled_code:
__int64 func1()
{
__int64 v0; // rbp
int v1; // ebx
__int64 v2; // r12
__int64 v3; // rsi
__int64 result; // rax

if ( smbios_mem || (unsigned int)func0(0LL) )
{
devfs_reg_device(0LL, 0LL, "smbios0");
v0 = smbios_mem;
if ( *(_WORD *)(smbios_mem + 28) )
{
v1 = 0;
do
{
while ( 1 )
{
v2 = *(_DWORD *)(v0 + 24) + v1 * (unsigned int)*(unsigned __int16 *)(v0 + 22);
if ( *(_BYTE *)v2 == 4 )
break;
if ( *(unsigned __int16 *)(v0 + 28) <= ++v1 )
goto LABEL_7;
}
v3 = *((unsigned __int8 *)&loc_E0 + *(_DWORD *)(v0 + 24) + v1 * (unsigned int)*(unsigned __int16 *)(v0 + 22) + 3);
++v1;
printf("core_count: %d\n", v3);
printf("core_enabled: %d\n", *(unsigned __int8 *)(v2 + 228));
printf("voltage: %d\n", *(unsigned __int8 *)(v2 + 209));
printf("max_speed: %d\n", *(unsigned __int16 *)(v2 + 212));
}
while ( *(unsigned __int16 *)(v0 + 28) > v1 );
}
LABEL_7:
result = 0LL;
}
else
{
driver_puts(driver_smbios, 2LL, "cannot found a valid smbios table");
result = 10LL;
}
return result;
}

original_code:
uint32_t smbios_init()
{
 if(smbios_mem == 0)
  if(smbios_probe(0) == 0)
  {
   driver_puts(&driver_smbios, 0x2, "cannot found a valid smbios table");
   return 10;
  }
 devfs_reg_device(0, 0, "smbios0");
 smbios_entry_t *smbios = (smbios_entry_t *) smbios_mem;
 int i;
 for(i = 0; i < smbios->number_of_struct; i++)
 {
  smbios_header_t *head = (smbios_header_t *) (smbios->table_address + smbios->table_length * i);
  if(head->type == 4)
  {
   smbios_type4_t *t4 = (smbios_type4_t *) head + sizeof(smbios_header_t);
   printf("core_count: %d\n", t4->core_count);
   printf("core_enabled: %d\n", t4->core_enabled);
   printf("voltage: %d\n", t4->voltage);
   printf("max_speed: %d\n", t4->max_speed);
  }
 }
 return 0;
}

canonical_original_code:
unsigned int smbios_init()
{
 if(smbios_mem == 0)
  if(smbios_probe(0) == 0)
  {
   driver_puts(&driver_smbios, 0x2, "cannot found a valid smbios table");
   return 10;
  }
 devfs_reg_device(0, 0, "smbios0");
 struct smbios_entry_t *smbios = (smbios_entry_t *) smbios_mem;
 int i;
 for(i = 0; i < smbios->number_of_struct; i++)
 {
  struct smbios_header_t *head = (smbios_header_t *) (smbios->table_address + smbios->table_length * i);
  if(head->type == 4)
  {
   struct smbios_type4_t *t4 = (smbios_type4_t *) head + sizeof(smbios_header_t);
   printf("core_count: %d\n", t4->core_count);
   printf("core_enabled: %d\n", t4->core_enabled);
   printf("voltage: %d\n", t4->voltage);
   printf("max_speed: %d\n", t4->max_speed);
  }
 }
 return 0;
}

variable_types: struct smbios_entry_t { char entry_string[4]; unsigned char checksum; unsigned char length; unsigned char major_version; unsigned char minor_version; unsigned short max_structure_size; unsigned char entry_revision; char formatted_area[5]; char entry_string2[5]; unsigned char checksum2; unsigned short table_length; unsigned int table_address; unsigned short number_of_struct; unsigned char bcd_revision; } *

variable_types: i int

variable_types: struct smbios_header_t { unsigned char type; unsigned char length; unsigned short handle; } *

variable_types: struct smbios_type4_t { unsigned char socket_designation; unsigned char proc_type; unsigned char proc_family; unsigned char proc_manufacturer; unsigned long long proc_id; unsigned char proc_version; unsigned char voltage; unsigned short external_clock; unsigned short max_speed; unsigned short current_speed; unsigned char status; unsigned char proc_upgrade; unsigned short l1_cache_handle; unsigned short l2_cache_handle; unsigned short l3_cache_handle; unsigned char serial_num; unsigned char asset_tag; unsigned char part_number; unsigned char core_count; unsigned char core_enabled; unsigned char thread_count; unsigned short proc_charact; unsigned short proc_family_2; } *

return_type: unsigned int


puts

decompiled_code:
void __fastcall puts(_BYTE *a1)
{
while ( *a1 )
++a1;
}

canonical_decompiled_code:
void __fastcall func1(_BYTE *a1)
{
while ( *a1 )
++a1;
}

original_code:
void puts(char *str)
{
 while(*str != '\0')
 {
  putchar(*str);
  str++;
 }
}

variable_types:
str
char *

return_type: void


atoi

decompiled_code:
__int64 __fastcall atoi(const char *a1)
{
const char *v1; // rdi
int v2; // eax
int v3; // edx
unsigned int v4; // er8
int v5; // eax

v1 = &a1[(unsigned int)strlen(a1) - 1];
v2 = *v1;
if ( !*v1 )
return 0LL;
v3 = 1;
v4 = 0;
do
{
--v1;
v5 = v3 * (v2 - 48);
v3 *= 10;
v4 += v5;
v2 = *v1;
}
while ( *v1 );
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1)
{
const char *v1; // rdi
int v2; // eax
int v3; // edx
unsigned int v4; // er8
int v5; // eax

v1 = &a1[(unsigned int)strlen(a1) - 1];
v2 = *v1;
if ( !*v1 )
return 0LL;
v3 = 1;
v4 = 0;
do
{
--v1;
v5 = v3 * (v2 - 48);
v3 *= 10;
v4 += v5;
v2 = *v1;
}
while ( *v1 );
return v4;
}

original_code:
int atoi(const char *str)
{
 int num = 0;
 int pot = 1;
 str += strlen(str)-1;
 while(*str != '\0')
 {
  num += ((int)(*str)-48) * pot;
  pot *= 10;
  str--;
 }
 return num;
}

canonical_original_code:
int atoi(char *str)
{
 int num = 0;
 int pot = 1;
 str += strlen(str)-1;
 while(*str != '\0')
 {
  num += ((int)(*str)-48) * pot;
  pot *= 10;
  str--;
 }
 return num;
}

variable_types: num int

variable_types: pot int

return_type: int


printf

original_code:
int printf(const char *format, ...)
{
 int len = 0;
 char output[255];
 char *current = &output[0];
 va_list ap;
 (ap = &format);
 while(*format != '\0')
 {
  if(*format == '%')
  {
   format++;
   switch (*format)
   {
    case 's':
     current = *((char * *)(ap += sizeof(int)));
     puts(current);
     break;
    case 'c':
     current = *((char * *)(ap += sizeof(int)));
     putchar(current[0]);
     break;
    case 'x':
     puts(itox(*((int *)(ap += sizeof(int)))));
     break;
    case 'd':
     puts(itoa(*((int *)(ap += sizeof(int)))));
     break;
    case '%':
     putchar('%');
     break;
   }
  }
  else
   putchar(*format);
  format++;
  len++;
 }
 return len;
}

canonical_original_code:
int printf(char *format, ...)
{
 int len = 0;
 char output[255];
 char *current = &output[0];
 void *ap;
 (ap = &format);
 while(*format != '\0')
 {
  if(*format == '%')
  {
   format++;
   switch (*format)
   {
    case 's':
     current = *((char **)(ap += sizeof(int)));
     puts(current);
     break;
    case 'c':
     current = *((char **)(ap += sizeof(int)));
     putchar(current[0]);
     break;
    case 'x':
     puts(itox(*((int *)(ap += sizeof(int)))));
     break;
    case 'd':
     puts(itoa(*((int *)(ap += sizeof(int)))));
     break;
    case '%':
     putchar('%');
     break;
   }
  }
  else
   putchar(*format);
  format++;
  len++;
 }
 return len;
}

variable_types:
format
char *

variable_types: len int

variable_types:
output
char [255]

variable_types:
current
char *

variable_types:
ap
void *


getchar

decompiled_code:
__int64 getchar()
{
char v0; // al

v0 = getch();
if ( !v0 )
{
while ( 1 )
;
}
return (unsigned int)v0;
}

canonical_decompiled_code:
__int64 func5()
{
char v0; // al

v0 = func4();
if ( !v0 )
{
while ( 1 )
;
}
return (unsigned int)v0;
}

original_code:
int getchar()
{
 char c;
 while((c = getch()) == 0);
 return c;
}

variable_types: c char


scanf

original_code:
int scanf(const char *format, ...)
{
 int len = 0;
 char buffer[255];
 char *current = &buffer[0];
 int *num;
 va_list ap;
 (ap = &format);
 while(*format != '\0')
 {
  if(*format == '%')
  {
   format++;
   switch (*format)
   {
    case 's':
     current = *((char * *)(ap += sizeof(int)));
     gets(current);
     break;
    case 'c':
     current = *((char * *)(ap += sizeof(int)));
     break;
    case 'd':
     num = *((int * *)(ap += sizeof(int)));
     gets(buffer);
     *num = atoi(buffer);
     break;
   }
  }
  format++;
  len++;
 }
 return len;
}

canonical_original_code:
int scanf(char *format, ...)
{
 int len = 0;
 char buffer[255];
 char *current = &buffer[0];
 int *num;
 void *ap;
 (ap = &format);
 while(*format != '\0')
 {
  if(*format == '%')
  {
   format++;
   switch (*format)
   {
    case 's':
     current = *((char **)(ap += sizeof(int)));
     gets(current);
     break;
    case 'c':
     current = *((char **)(ap += sizeof(int)));
     break;
    case 'd':
     num = *((int **)(ap += sizeof(int)));
     gets(buffer);
     *num = atoi(buffer);
     break;
   }
  }
  format++;
  len++;
 }
 return len;
}

variable_types:
buffer
char [255]

variable_types:
num
int *


fopen

decompiled_code:
void fopen()
{
;
}

canonical_decompiled_code:
void func7()
{
;
}

original_code:
FILE *fopen(const char *path, const char *mode)
{
}

canonical_original_code:
struct FILE *fopen(char *path, char *mode)
{
}

variable_types:
path
char *

variable_types:
mode
char *

return_type: struct FILE { unsigned int fn; } *


fclose

decompiled_code:
void fclose()
{
;
}

canonical_decompiled_code:
void func8()
{
;
}

original_code:
int fclose (FILE *fd)
{
}

canonical_original_code:
int fclose(struct FILE *fd)
{
}

variable_types:
fd
struct FILE { unsigned int fn; } *


fgetc

decompiled_code:
// attributes: thunk
void fgetc()
{
fclose();
}

canonical_decompiled_code:
void func9()
{
func8();
}

original_code:
int fgetc (FILE *fd)
{
}

canonical_original_code:
int fgetc(struct FILE *fd)
{
}


fputc

decompiled_code:
void fputc()
{
;
}

canonical_decompiled_code:
void func10()
{
;
}

original_code:
int fputc (int ch, FILE *fd)
{
}

canonical_original_code:
int fputc(int ch, struct FILE *fd)
{
}

variable_types: ch int


fseek

decompiled_code:
void fseek()
{
;
}

canonical_decompiled_code:
void func11()
{
;
}

original_code:
int fseek (FILE *fd, long int off, int type)
{
}

canonical_original_code:
int fseek(struct FILE *fd, long off, int type)
{
}

variable_types: off long

variable_types: type int


decompiled_code:
// write access to const memory has been detected, the output may be wrong!
__int64 __fastcall vesa_get_pixel(unsigned int a1, unsigned int a2)
{
if ( *(unsigned __int16 *)(vmi + 18) >= a1 && *(unsigned __int16 *)(vmi + 20) >= a2 )
*(_BYTE *)vesa_draw_pixel = *(_BYTE *)(*(unsigned int *)(vmi + 40)
+ (unsigned __int64)((*(_BYTE *)(vmi + 25) >> 3) * a1
+ *(unsigned __int16 *)(vmi + 16) * a2));
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1, unsigned int a2)
{
if ( *(unsigned __int16 *)(vmi + 18) >= a1 && *(unsigned __int16 *)(vmi + 20) >= a2 )
*(_BYTE *)vesa_draw_pixel = *(_BYTE *)(*(unsigned int *)(vmi + 40)
+ (unsigned __int64)((*(_BYTE *)(vmi + 25) >> 3) * a1
+ *(unsigned __int16 *)(vmi + 16) * a2));
return 0LL;
}

original_code:
uint32_t vesa_get_pixel(uint32_t x, uint32_t y)
{
 register char *ptmp;
 if (x < 0 || x > vmi->width || y < 0 || y > vmi->height) return 0;
 x = (x * (vmi->bits_per_pixel >> 3));
 y = (y * vmi->bytes_per_scan_line);
 char *asd = (char *)vmi->phys_base_ptr;
 *ptmp = asd[x+y];
 return *ptmp;
}

canonical_original_code:
unsigned int vesa_get_pixel(unsigned int x, unsigned int y)
{
 register char *ptmp;
 if (x < 0 || x > vmi->width || y < 0 || y > vmi->height) return 0;
 x = (x * (vmi->bits_per_pixel >> 3));
 y = (y * vmi->bytes_per_scan_line);
 char *asd = (char *)vmi->phys_base_ptr;
 *ptmp = asd[x+y];
 return *ptmp;
}

variable_types:
x
unsigned int

variable_types:
y
unsigned int

variable_types:
ptmp
char *

variable_types:
asd
char *


decompiled_code:
void vesa_set_mode()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
uint32_t vesa_set_mode(uint32_t x, uint32_t y, uint32_t bit)
{
}

canonical_original_code:
unsigned int vesa_set_mode(unsigned int x, unsigned int y, unsigned int bit)
{
}

variable_types:
bit
unsigned int


decompiled_code:
__int64 vesa_get_mode_info()
{
return vmi;
}

canonical_decompiled_code:
__int64 func2()
{
return vmi;
}

canonical_original_code:
struct vesa_mode_info_t *vesa_get_mode_info()
{
 return vmi;
}

return_type: struct vesa_mode_info_t { unsigned short mode_attributes; unsigned char wina_attributes; unsigned char winb_attributes; unsigned short win_granularity; unsigned short win_size; unsigned short wina_segment; unsigned short winb_segment; unsigned int win_pos_func_ptr; unsigned short bytes_per_scan_line; unsigned short width; unsigned short height; unsigned char char_width; unsigned char char_height; unsigned char num_planes; unsigned char bits_per_pixel; unsigned char num_banks; unsigned char memory_model_type; unsigned char bank_size; unsigned char num_image_pages; unsigned char reserved1; unsigned char red_mask_size; unsigned char red_field_position; unsigned char green_mask_size; unsigned char green_field_position; unsigned char blue_mask_size; unsigned char blue_field_position; unsigned char reserved_mask_size; unsigned char reserved_mask_position; unsigned char direct_color_mode_info; unsigned int phys_base_ptr; unsigned int offscreen_mem_ptr; unsigned short offscreen_mem_size; unsigned short lin_bytes_per_scan_line; unsigned char bnk_num_image_pages; unsigned char lin_num_image_pages; unsigned char lin_red_mask_size; unsigned char lin_red_field_position; unsigned char lin_green_mask_size; unsigned char lin_green_field_position; unsigned char lin_blue_mask_size; unsigned char lin_blue_field_position; unsigned char lin_rsvd_mask_size; unsigned char lin_rsvd_field_position; unsigned int max_pixel_clock; unsigned char reserved4[190]; } *


decompiled_code:
void __fastcall vesa_init(__int64 a1, __int64 a2)
{
vci = a1;
vmi = a2;
}

canonical_decompiled_code:
void __fastcall func3(__int64 a1, __int64 a2)
{
vci = a1;
vmi = a2;
}

original_code:
uint32_t vesa_init(void *vbe_control_info, void *vbe_mode_info)
{
 vci = (vesa_info_t *) vbe_control_info;
 vmi = (vesa_mode_info_t *) vbe_mode_info;
}

canonical_original_code:
unsigned int vesa_init(void *vbe_control_info, void *vbe_mode_info)
{
 vci = (struct vesa_info_t *) vbe_control_info;
 vmi = (struct vesa_mode_info_t *) vbe_mode_info;
}

user_defined_types: struct vesa_info_t { char signature[4]; unsigned short version; unsigned int oem_string_ptr; unsigned int capabilities; unsigned int video_mode_ptr; unsigned short total_memory; unsigned int oem_software_rev; char *oem_vendor_name; char *oem_product_name; char *oem_product_rev; }

user_defined_types: struct vesa_mode_info_t { unsigned short mode_attributes; unsigned char wina_attributes; unsigned char winb_attributes; unsigned short win_granularity; unsigned short win_size; unsigned short wina_segment; unsigned short winb_segment; unsigned int win_pos_func_ptr; unsigned short bytes_per_scan_line; unsigned short width; unsigned short height; unsigned char char_width; unsigned char char_height; unsigned char num_planes; unsigned char bits_per_pixel; unsigned char num_banks; unsigned char memory_model_type; unsigned char bank_size; unsigned char num_image_pages; unsigned char reserved1; unsigned char red_mask_size; unsigned char red_field_position; unsigned char green_mask_size; unsigned char green_field_position; unsigned char blue_mask_size; unsigned char blue_field_position; unsigned char reserved_mask_size; unsigned char reserved_mask_position; unsigned char direct_color_mode_info; unsigned int phys_base_ptr; unsigned int offscreen_mem_ptr; unsigned short offscreen_mem_size; unsigned short lin_bytes_per_scan_line; unsigned char bnk_num_image_pages; unsigned char lin_num_image_pages; unsigned char lin_red_mask_size; unsigned char lin_red_field_position; unsigned char lin_green_mask_size; unsigned char lin_green_field_position; unsigned char lin_blue_mask_size; unsigned char lin_blue_field_position; unsigned char lin_rsvd_mask_size; unsigned char lin_rsvd_field_position; unsigned int max_pixel_clock; unsigned char reserved4[190]; }


decompiled_code:
void eth_up()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
uint32_t eth_up(network_iface_t *iface)
{
}

canonical_original_code:
unsigned int eth_up(struct network_iface_p *iface)
{
}

variable_types: struct network_iface_p { char name[32]; char addr[4]; char mask[4]; char bcast[4]; char mac[6]; unsigned char if_up; unsigned char if_mac; unsigned char if_bcast; unsigned char type; unsigned int tx_bytes; unsigned int rx_bytes; struct driver_p { char name[32]; char desc[128]; char author[128]; unsigned char type; struct driver_fs_t { unsigned int (*mount)(char *, unsigned int, struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *); unsigned int (*umount)(struct inode_p *); unsigned int (*mkdir)(struct inode_p *, char *); unsigned int (*readdir)(struct inode_p *, unsigned int, struct dirent { char name[255]; unsigned int inode; } *); unsigned int (*get_node)(struct inode_p *, unsigned int, struct inode_p **); unsigned int (*delete_node)(struct inode_p *, char *); unsigned int (*create_node)(struct inode_p *, char *, unsigned int); unsigned int (*write_stat)(struct inode_p *, struct stat { unsigned int st_dev; unsigned int st_ino; int st_uid; int st_gid; unsigned long long st_blksize; unsigned long long st_blocks; } *, unsigned int); unsigned int (*read_stat)(struct inode_p *, struct stat *); unsigned int (*open)(struct inode_p *, char *); unsigned int (*close)(struct inode_p *); unsigned int (*read)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*link)(struct inode_p *, char *, struct inode_p *, char *); unsigned int (*unlink)(struct inode_p *, char *); unsigned char ifdev; } fs; struct driver_video_t { char *buffer; void (*put_pixel)(unsigned int, unsigned int, unsigned int); unsigned int (*get_pixel)(unsigned int, unsigned int); unsigned int (*set_mode)(unsigned int, unsigned int, unsigned int); } video; unsigned char loaded; unsigned int (*init)(); unsigned int (*free)(); unsigned int (*probe)(struct device_p { unsigned int io_base; char vendor[32]; char vendor_full[32]; char device[32]; char device_desc[32]; char class[32]; char class_desc[32]; char class_prog_desc[32]; unsigned char bus_type; void *pci_dev; unsigned char interrupt; unsigned int base_addresses[6]; char file[32]; struct device_p *next; } *); unsigned int (*read)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*ioctl)(struct device_p *, unsigned int, unsigned int, unsigned int); struct driver_p *next; } *drv; struct device_p *dev; void *link_protocol; struct network_iface_p *next; } *

user_defined_types: struct network_iface_p { char name[32]; char addr[4]; char mask[4]; char bcast[4]; char mac[6]; unsigned char if_up; unsigned char if_mac; unsigned char if_bcast; unsigned char type; unsigned int tx_bytes; unsigned int rx_bytes; struct driver_p *drv; struct device_p *dev; void *link_protocol; struct network_iface_p *next; }

user_defined_types: struct driver_p { char name[32]; char desc[128]; char author[128]; unsigned char type; struct driver_fs_t fs; struct driver_video_t video; unsigned char loaded; unsigned int (*init)(); unsigned int (*free)(); unsigned int (*probe)(struct device_p *); unsigned int (*read)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*ioctl)(struct device_p *, unsigned int, unsigned int, unsigned int); struct driver_p *next; }

user_defined_types: struct driver_fs_t { unsigned int (*mount)(char *, unsigned int, struct inode_p *); unsigned int (*umount)(struct inode_p *); unsigned int (*mkdir)(struct inode_p *, char *); unsigned int (*readdir)(struct inode_p *, unsigned int, struct dirent *); unsigned int (*get_node)(struct inode_p *, unsigned int, struct inode_p **); unsigned int (*delete_node)(struct inode_p *, char *); unsigned int (*create_node)(struct inode_p *, char *, unsigned int); unsigned int (*write_stat)(struct inode_p *, struct stat *, unsigned int); unsigned int (*read_stat)(struct inode_p *, struct stat *); unsigned int (*open)(struct inode_p *, char *); unsigned int (*close)(struct inode_p *); unsigned int (*read)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*link)(struct inode_p *, char *, struct inode_p *, char *); unsigned int (*unlink)(struct inode_p *, char *); unsigned char ifdev; }


decompiled_code:
// attributes: thunk
void eth_down()
{
eth_up();
}

canonical_decompiled_code:
void func1()
{
func0();
}

original_code:
uint32_t eth_down(network_iface_t *iface)
{
}

canonical_original_code:
unsigned int eth_down(struct network_iface_p *iface)
{
}

user_defined_types: struct driver_video_t { char *buffer; void (*put_pixel)(unsigned int, unsigned int, unsigned int); unsigned int (*get_pixel)(unsigned int, unsigned int); unsigned int (*set_mode)(unsigned int, unsigned int, unsigned int); }

user_defined_types: struct device_p { unsigned int io_base; char vendor[32]; char vendor_full[32]; char device[32]; char device_desc[32]; char class[32]; char class_desc[32]; char class_prog_desc[32]; unsigned char bus_type; void *pci_dev; unsigned char interrupt; unsigned int base_addresses[6]; char file[32]; struct device_p *next; }

user_defined_types: struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; }

user_defined_types: struct dirent { char name[255]; unsigned int inode; }

user_defined_types: struct stat { unsigned int st_dev; unsigned int st_ino; int st_uid; int st_gid; unsigned long long st_blksize; unsigned long long st_blocks; }


decompiled_code:
__int64 __fastcall eth_handle_frame(__int64 a1, unsigned int *a2)
{
if ( *(_WORD *)(*((_QWORD *)a2 + 1) + 20LL) <= 0x5DBu )
{
printf("eth: received packet (sizeof %d)\n", *a2);
packet_del_header(a2, 26LL);
ip_handle_packet(a1, a2);
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1, unsigned int *a2)
{
if ( *(_WORD *)(*((_QWORD *)a2 + 1) + 20LL) <= 0x5DBu )
{
printf("eth: received packet (sizeof %d)\n", *a2);
packet_del_header(a2, 26LL);
ip_handle_packet(a1, a2);
}
return 0LL;
}

original_code:
uint32_t eth_handle_frame(network_iface_t *iface, packet_t *p)
{
 eth_header_t *ethead = (eth_header_t *) p->data;
 if(ethead->len < 1500)
 {
  printf("eth: received packet (sizeof %d)\n", p->size);
  packet_del_header(p, sizeof(eth_header_t));
  ip_handle_packet(iface, p);
 }
 return 0;
}

canonical_original_code:
unsigned int eth_handle_frame(struct network_iface_p *iface, struct packet_t *p)
{
 struct eth_header_t *ethead = (eth_header_t *) p->data;
 if(ethead->len < 1500)
 {
  printf("eth: received packet (sizeof %d)\n", p->size);
  packet_del_header(p, sizeof(eth_header_t));
  ip_handle_packet(iface, p);
 }
 return 0;
}

variable_types: struct packet_t { unsigned int size; char *data; } *

variable_types: struct eth_header_t { unsigned char preamble[7]; unsigned char sfd; char dest[6]; char source[6]; unsigned short len; struct llc_t { unsigned char dsap; unsigned char ssap; unsigned char control; } llc; } *

user_defined_types: struct eth_header_t { unsigned char preamble[7]; unsigned char sfd; char dest[6]; char source[6]; unsigned short len; struct llc_t llc; }


decompiled_code:
__int64 __fastcall eth_send_frame(__int64 a1, unsigned int *a2)
{
__int64 v2; // r13
__int64 v3; // r12
__int64 (__fastcall *v4)(_QWORD, _QWORD, _QWORD, _QWORD); // rax
__int64 result; // rax

v2 = *((_QWORD *)a2 + 1);
packet_add_header(a2, 26LL);
v3 = *((_QWORD *)a2 + 1);
*(_QWORD *)v3 = 0xABAAAAAAAAAAAAAALL;
arp_resolve(v2 + 16, v3 + 8);
arp_resolve(v2 + 12, v3 + 14);
*(_WORD *)(v3 + 20) = 8;
v4 = *(__int64 (__fastcall **)(_QWORD, _QWORD, _QWORD, _QWORD))(*(_QWORD *)(a1 + 64) + 496LL);
if ( !v4 )
return 0LL;
result = v4(*(_QWORD *)(a1 + 72), *((_QWORD *)a2 + 1), *a2, 0LL);
*(_DWORD *)(a1 + 56) += result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, unsigned int *a2)
{
__int64 v2; // r13
__int64 v3; // r12
__int64 (__fastcall *v4)(_QWORD, _QWORD, _QWORD, _QWORD); // rax
__int64 result; // rax

v2 = *((_QWORD *)a2 + 1);
packet_add_header(a2, 26LL);
v3 = *((_QWORD *)a2 + 1);
*(_QWORD *)v3 = 0xABAAAAAAAAAAAAAALL;
arp_resolve(v2 + 16, v3 + 8);
arp_resolve(v2 + 12, v3 + 14);
*(_WORD *)(v3 + 20) = 8;
v4 = *(__int64 (__fastcall **)(_QWORD, _QWORD, _QWORD, _QWORD))(*(_QWORD *)(a1 + 64) + 496LL);
if ( !v4 )
return 0LL;
result = v4(*(_QWORD *)(a1 + 72), *((_QWORD *)a2 + 1), *a2, 0LL);
*(_DWORD *)(a1 + 56) += result;
return result;
}

original_code:
uint32_t eth_send_frame(network_iface_t *iface, packet_t *p)
{
 ip_header_t *iphead = (ip_header_t *) p->data;
 packet_add_header(p, sizeof(eth_header_t));
 eth_header_t *ethead = (eth_header_t *) p->data;
 ethead->preamble[0] = 0xAA;
 ethead->preamble[1] = 0xAA;
 ethead->preamble[2] = 0xAA;
 ethead->preamble[3] = 0xAA;
 ethead->preamble[4] = 0xAA;
 ethead->preamble[5] = 0xAA;
 ethead->preamble[6] = 0xAA;
 ethead->sfd = 0xAB;
 arp_resolve((char *) &iphead->dest, ethead->dest);
 arp_resolve((char *) &iphead->source, ethead->source);
 ethead->len = sizeof(p->data);
 uint32_t sended_b;
 if((iface->drv)->write != 0)
  sended_b = (iface->drv)->write(iface->dev, p->data, p->size, 0);
 else
  return 0;
 iface->tx_bytes = iface->tx_bytes + sended_b;
 return sended_b;
}

canonical_original_code:
unsigned int eth_send_frame(struct network_iface_p *iface, struct packet_t *p)
{
 struct ip_header_t *iphead = (ip_header_t *) p->data;
 packet_add_header(p, sizeof(eth_header_t));
 struct eth_header_t *ethead = (eth_header_t *) p->data;
 ethead->preamble[0] = 0xAA;
 ethead->preamble[1] = 0xAA;
 ethead->preamble[2] = 0xAA;
 ethead->preamble[3] = 0xAA;
 ethead->preamble[4] = 0xAA;
 ethead->preamble[5] = 0xAA;
 ethead->preamble[6] = 0xAA;
 ethead->sfd = 0xAB;
 arp_resolve((char *) &iphead->dest, ethead->dest);
 arp_resolve((char *) &iphead->source, ethead->source);
 ethead->len = sizeof(p->data);
 unsigned int sended_b;
 if((iface->drv)->write != 0)
  sended_b = (iface->drv)->write(iface->dev, p->data, p->size, 0);
 else
  return 0;
 iface->tx_bytes = iface->tx_bytes + sended_b;
 return sended_b;
}

variable_types: struct ip_header_t { unsigned char version; unsigned char head_len; unsigned char tos; unsigned short total_len; unsigned short ident; unsigned char flags; unsigned short offset; unsigned char time_to_live; unsigned char protocol; unsigned short header_checksum; unsigned int source; unsigned int dest; } *

user_defined_types: struct packet_t { unsigned int size; char *data; }

user_defined_types: struct llc_t { unsigned char dsap; unsigned char ssap; unsigned char control; }


decompiled_code:
int clear_screen()
{
return system("clear");
}

canonical_decompiled_code:
int func0()
{
return system("clear");
}

original_code:
void clear_screen()
{
 system("clear");
}


main

canonical_name: main

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

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

original_code:
int main(int argc, char **argv)
{
 int choice;
 clear_screen();
 return 0;
}

variable_types: argc int

variable_types:
argv
char **

variable_types: choice int


decompiled_code:
void apic_probe()
{
;
}

original_code:
uint32_t apic_probe()
{
 uint16_t a;
 uint16_t d;
}

canonical_original_code:
unsigned int apic_probe()
{
 unsigned short a;
 unsigned short d;
}

variable_types:
a
unsigned short

variable_types:
d
unsigned short


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

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

original_code:
uint32_t apic_get_base()
{
 uint16_t a;
 uint16_t d;
 return (a&0xfffff000);
}

canonical_original_code:
unsigned int apic_get_base()
{
 unsigned short a;
 unsigned short d;
 return (a&0xfffff000);
}


original_code:
uint32_t udp_handle_packet(network_iface_t *iface, packet_t *p)
{
 ip_header_t *iphead = (ip_header_t *) p->data;
 udp_header_t *udphead = (udp_header_t *) p->data + sizeof(ip_header_t);
 if(video_getx() != 0)
  printf("\n");
 printf("udp: received packet (sizeof %d) on port %x\n", p->size - sizeof(ip_header_t) - sizeof(udp_header_t), udphead->dest_port);
 socket_t *s;
 uint32_t i;
 while(sock_iget(i, &s))
 {
  if(s->port == udphead->source_port)
  {
   for(i = 0; i < (p->size - sizeof(ip_header_t) - sizeof(udp_header_t)); i++)
   {
    s->rec_buf[s->rec_p1] = p->data[i + sizeof(udp_header_t) + sizeof(ip_header_t)];
    s->rec_p1++;
    s->rec_data_len++;
   }
   break;
  }
  i++;
 }
 free(p);
}

canonical_original_code:
unsigned int udp_handle_packet(struct network_iface_p *iface, struct packet_t *p)
{
 struct ip_header_t *iphead = (ip_header_t *) p->data;
 struct udp_header_t *udphead = (udp_header_t *) p->data + sizeof(ip_header_t);
 if(video_getx() != 0)
  printf("\n");
 printf("udp: received packet (sizeof %d) on port %x\n", p->size - sizeof(ip_header_t) - sizeof(udp_header_t), udphead->dest_port);
 struct socket_t *s;
 unsigned int i;
 while(sock_iget(i, &s))
 {
  if(s->port == udphead->source_port)
  {
   for(i = 0; i < (p->size - sizeof(ip_header_t) - sizeof(udp_header_t)); i++)
   {
    s->rec_buf[s->rec_p1] = p->data[i + sizeof(udp_header_t) + sizeof(ip_header_t)];
    s->rec_p1++;
    s->rec_data_len++;
   }
   break;
  }
  i++;
 }
 free(p);
}

variable_types: struct udp_header_t { unsigned short source_port; unsigned short dest_port; unsigned short lenght; unsigned short checksum; } *

variable_types: struct socket_t { struct network_iface_p { char name[32]; char addr[4]; char mask[4]; char bcast[4]; char mac[6]; unsigned char if_up; unsigned char if_mac; unsigned char if_bcast; unsigned char type; unsigned int tx_bytes; unsigned int rx_bytes; struct driver_p { char name[32]; char desc[128]; char author[128]; unsigned char type; struct driver_fs_t { unsigned int (*mount)(char *, unsigned int, struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *); unsigned int (*umount)(struct inode_p *); unsigned int (*mkdir)(struct inode_p *, char *); unsigned int (*readdir)(struct inode_p *, unsigned int, struct dirent { char name[255]; unsigned int inode; } *); unsigned int (*get_node)(struct inode_p *, unsigned int, struct inode_p **); unsigned int (*delete_node)(struct inode_p *, char *); unsigned int (*create_node)(struct inode_p *, char *, unsigned int); unsigned int (*write_stat)(struct inode_p *, struct stat { unsigned int st_dev; unsigned int st_ino; int st_uid; int st_gid; unsigned long long st_blksize; unsigned long long st_blocks; } *, unsigned int); unsigned int (*read_stat)(struct inode_p *, struct stat *); unsigned int (*open)(struct inode_p *, char *); unsigned int (*close)(struct inode_p *); unsigned int (*read)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*link)(struct inode_p *, char *, struct inode_p *, char *); unsigned int (*unlink)(struct inode_p *, char *); unsigned char ifdev; } fs; struct driver_video_t { char *buffer; void (*put_pixel)(unsigned int, unsigned int, unsigned int); unsigned int (*get_pixel)(unsigned int, unsigned int); unsigned int (*set_mode)(unsigned int, unsigned int, unsigned int); } video; unsigned char loaded; unsigned int (*init)(); unsigned int (*free)(); unsigned int (*probe)(struct device_p { unsigned int io_base; char vendor[32]; char vendor_full[32]; char device[32]; char device_desc[32]; char class[32]; char class_desc[32]; char class_prog_desc[32]; unsigned char bus_type; void *pci_dev; unsigned char interrupt; unsigned int base_addresses[6]; char file[32]; struct device_p *next; } *); unsigned int (*read)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*ioctl)(struct device_p *, unsigned int, unsigned int, unsigned int); struct driver_p *next; } *drv; struct device_p *dev; void *link_protocol; struct network_iface_p *next; } *iface; unsigned int protocol; unsigned int type; unsigned int domain; unsigned char is_server; unsigned short port; char addr[4]; int uid; unsigned int used; char rec_buf[8192]; int rec_p1; int rec_p2; int rec_data_len; char send_buf[8192]; int send_p1; int send_p2; int send_data_len; } *

variable_types:
i
unsigned int

user_defined_types: struct ip_header_t { unsigned char version; unsigned char head_len; unsigned char tos; unsigned short total_len; unsigned short ident; unsigned char flags; unsigned short offset; unsigned char time_to_live; unsigned char protocol; unsigned short header_checksum; unsigned int source; unsigned int dest; }

user_defined_types: struct socket_t { struct network_iface_p *iface; unsigned int protocol; unsigned int type; unsigned int domain; unsigned char is_server; unsigned short port; char addr[4]; int uid; unsigned int used; char rec_buf[8192]; int rec_p1; int rec_p2; int rec_data_len; char send_buf[8192]; int send_p1; int send_p2; int send_data_len; }


decompiled_code:
__int64 __fastcall udp_send_packet(__int64 *a1, __int64 a2)
{
__int16 v3; // dx
_WORD *v4; // rax
__int64 v5; // rcx
__int64 v6; // rdi

printf("sending udp pack\n");
packet_add_header(a2, 8LL);
v3 = *((_WORD *)a1 + 11);
v4 = *(_WORD **)(a2 + 8);
v5 = *((unsigned __int8 *)a1 + 8);
v6 = *a1;
*v4 = v3;
v4[1] = v3;
return ip_send_frame(v6, a2, a1 + 3, v5);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 *a1, __int64 a2)
{
__int16 v3; // dx
_WORD *v4; // rax
__int64 v5; // rcx
__int64 v6; // rdi

printf("sending udp pack\n");
packet_add_header(a2, 8LL);
v3 = *((_WORD *)a1 + 11);
v4 = *(_WORD **)(a2 + 8);
v5 = *((unsigned __int8 *)a1 + 8);
v6 = *a1;
*v4 = v3;
v4[1] = v3;
return ip_send_frame(v6, a2, a1 + 3, v5);
}

original_code:
uint32_t udp_send_packet(socket_t *s, packet_t *p)
{
 printf("sending udp pack\n");
 packet_add_header(p, sizeof(udp_header_t));
 udp_header_t *h = p->data;
 h->source_port = s->port;
 h->dest_port = s->port;
 return ip_send_frame(s->iface, p, s->addr, s->protocol);
}

canonical_original_code:
unsigned int udp_send_packet(struct socket_t *s, struct packet_t *p)
{
 printf("sending udp pack\n");
 packet_add_header(p, sizeof(udp_header_t));
 struct udp_header_t *h = p->data;
 h->source_port = s->port;
 h->dest_port = s->port;
 return ip_send_frame(s->iface, p, s->addr, s->protocol);
}

user_defined_types: struct udp_header_t { unsigned short source_port; unsigned short dest_port; unsigned short lenght; unsigned short checksum; }


decompiled_code:
__int64 pfs_umount()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func0()
{
return 1LL;
}

original_code:
uint32_t pfs_umount(inode_t *root)
{
 return 1;
}

canonical_original_code:
unsigned int pfs_umount(struct inode_p *root)
{
 return 1;
}

variable_types: struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *


decompiled_code:
__int64 pfs_mount()
{
return 1LL;
}

canonical_decompiled_code:
__int64 func1()
{
return 1LL;
}

original_code:
uint32_t pfs_mount(char *dev, uint32_t flags, inode_t *root)
{
 return 1;
}

canonical_original_code:
unsigned int pfs_mount(char *dev, unsigned int flags, struct inode_p *root)
{
 return 1;
}

variable_types:
dev
char *

variable_types:
flags
unsigned int


decompiled_code:
void pfs_read_node()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
uint32_t pfs_read_node(int n, pfs_nodeblock_t *node)
{
}

canonical_original_code:
unsigned int pfs_read_node(int n, struct pfs_nodeblock_t *node)
{
}

variable_types: n int

variable_types: struct pfs_nodeblock_t { unsigned short checksum; char name[128]; unsigned char type; unsigned long long offset; unsigned long long number; unsigned long long parent_n; unsigned long long size; } *


fdopendir

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

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

original_code:
DIR *fdopendir(int fd)
{
 return 0;
}

canonical_original_code:
struct DIR *fdopendir(int fd)
{
 return 0;
}

variable_types: fd int

return_type: struct DIR { unsigned int i; } *


closedir

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

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

original_code:
int closedir(DIR *fd)
{
 return 0;
}

canonical_original_code:
int closedir(struct DIR *fd)
{
 return 0;
}

variable_types:
fd
struct DIR { unsigned int i; } *


readdir

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

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

original_code:
int readdir(unsigned int fd, struct dirent *d, unsigned int off)
{
 return 0;
}

variable_types:
fd
unsigned int

variable_types:
d
struct dirent { unsigned int i; } *

variable_types:
off
unsigned int


decompiled_code:
__int64 device_update()
{
void *v0; // rbx
void *v1; // rdi
__int64 result; // rax
char *v3; // rbx
char v4[56]; // [rsp+0h] [rbp-38h] BYREF

v0 = device_list;
while ( v0 )
{
v1 = v0;
v0 = (void *)*((_QWORD *)v0 + 38);
free(v1);
}
device_list = 0LL;
result = pci_update(&device_list);
v3 = (char *)device_list;
if ( device_list )
{
do
{
devfs_find_freen(v3 + 268, v4);
strcpy(v3 + 268, v4);
result = devfs_reg_device(v3, 0LL, v3 + 268);
v3 = (char *)*((_QWORD *)v3 + 38);
}
while ( v3 );
}
return result;
}

canonical_decompiled_code:
__int64 func0()
{
void *v0; // rbx
void *v1; // rdi
__int64 result; // rax
char *v3; // rbx
char v4[56]; // [rsp+0h] [rbp-38h] BYREF

v0 = device_list;
while ( v0 )
{
v1 = v0;
v0 = (void *)*((_QWORD *)v0 + 38);
free(v1);
}
device_list = 0LL;
result = pci_update(&device_list);
v3 = (char *)device_list;
if ( device_list )
{
do
{
devfs_find_freen(v3 + 268, v4);
strcpy(v3 + 268, v4);
result = devfs_reg_device(v3, 0LL, v3 + 268);
v3 = (char *)*((_QWORD *)v3 + 38);
}
while ( v3 );
}
return result;
}

original_code:
void device_update()
{
 device_t *dev;
 device_t *next;
 dev = device_list;
 while(dev != 0)
 {
  next = dev->next;
  free(dev);
  dev = next;
 }
 device_list = 0;
  pci_update(&device_list);
 dev = device_list;
 while(dev != 0)
 {
  char tmp[32];
  devfs_find_freen(dev->file, tmp);
  strcpy(dev->file, tmp);
  devfs_reg_device(dev, 0, dev->file);
  switch(dev->bus_type)
  {
   case 0x01:
    break;
   default:
    break;
  }
  dev = dev->next;
 }
}

canonical_original_code:
void device_update()
{
 struct device_p *dev;
 struct device_p *next;
 dev = device_list;
 while(dev != 0)
 {
  next = dev->next;
  free(dev);
  dev = next;
 }
 device_list = 0;
  pci_update(&device_list);
 dev = device_list;
 while(dev != 0)
 {
  char tmp[32];
  devfs_find_freen(dev->file, tmp);
  strcpy(dev->file, tmp);
  devfs_reg_device(dev, 0, dev->file);
  switch(dev->bus_type)
  {
   case 0x01:
    break;
   default:
    break;
  }
  dev = dev->next;
 }
}

variable_types: struct device_p { unsigned int io_base; char vendor[32]; char vendor_full[32]; char device[32]; char device_desc[32]; char class[32]; char class_desc[32]; char class_prog_desc[32]; unsigned char bus_type; void *pci_dev; unsigned char interrupt; unsigned int base_addresses[6]; char file[32]; struct device_p *next; } *

variable_types:
tmp
char [32]


decompiled_code:
__int64 __fastcall device_iget(int a1, _QWORD *a2)
{
_QWORD *v2; // rax
int i; // edx

v2 = device_list;
*a2 = 0LL;
if ( !v2 )
return 1LL;
if ( a1 )
{
for ( i = 0; i != a1; ++i )
{
v2 = (_QWORD *)v2[38];
if ( !v2 )
return 1LL;
}
}
*a2 = v2;
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1, _QWORD *a2)
{
_QWORD *v2; // rax
int i; // edx

v2 = device_list;
*a2 = 0LL;
if ( !v2 )
return 1LL;
if ( a1 )
{
for ( i = 0; i != a1; ++i )
{
v2 = (_QWORD *)v2[38];
if ( !v2 )
return 1LL;
}
}
*a2 = v2;
return 0LL;
}

original_code:
uint32_t device_iget(uint32_t x, device_t **dev)
{
 device_t *cf = device_list;
 uint32_t i = 0;
 *dev = 0;
 while(cf != 0)
 {
  if(i == x)
  {
   *dev = cf;
   return 0;
  }
  i++;
  cf = cf->next;
 }
 return 1;
}

canonical_original_code:
unsigned int device_iget(unsigned int x, struct device_p **dev)
{
 struct device_p *cf = device_list;
 unsigned int i = 0;
 *dev = 0;
 while(cf != 0)
 {
  if(i == x)
  {
   *dev = cf;
   return 0;
  }
  i++;
  cf = cf->next;
 }
 return 1;
}

variable_types:
x
unsigned int

variable_types: struct device_p { unsigned int io_base; char vendor[32]; char vendor_full[32]; char device[32]; char device_desc[32]; char class[32]; char class_desc[32]; char class_prog_desc[32]; unsigned char bus_type; void *pci_dev; unsigned char interrupt; unsigned int base_addresses[6]; char file[32]; struct device_p *next; } **


decompiled_code:
__int64 __fastcall icmp_handle_packet(__int64 a1, unsigned int *a2)
{
__int64 v2; // r13
unsigned __int8 v3; // bl
__int64 v5; // rsi
__int64 v6; // rax

v2 = *((_QWORD *)a2 + 1);
v3 = *(_BYTE *)(v2 + 80);
if ( (unsigned int)video_getx() )
printf("\n");
printf("icmp: received packet (sizeof %d) request: %d: ", *a2, v3);
switch ( v3 )
{
case 0u:
printf("pong\n");
break;
case 3u:
printf("destination not reachable\n");
break;
case 4u:
printf("source quench\n");
break;
case 5u:
printf("redirect\n");
break;
case 6u:
printf("alternative host address\n");
break;
case 8u:
printf("ping\n");
v5 = packet_create(0LL, 4LL);
v6 = *(_QWORD *)(v5 + 8);
*(_WORD *)(v6 + 2) = 0;
*(_BYTE *)v6 = 0;
ip_send_frame(a1, v5, v2 + 12, 1LL);
break;
case 9u:
printf("router advertisement\n");
break;
case 0xAu:
printf("router selection\n");
break;
case 0xBu:
printf("expired request\n");
break;
case 0xCu:
printf("parameters error\n");
break;
case 0xDu:
printf("timestamp request\n");
break;
case 0xEu:
printf("timestamp reply\n");
break;
case 0xFu:
printf("information request\n");
break;
case 0x10u:
printf("information reply\n");
break;
case 0x11u:
printf("address mask request\n");
break;
case 0x12u:
printf("address mask reply\n");
break;
case 0x1Eu:
printf("traceroute\n");
break;
case 0x1Fu:
printf("datagram conversion error\n");
break;
case 0x20u:
printf("mobile host redirect\n");
break;
case 0x21u:
printf("ipv6 where are you?\n");
break;
case 0x22u:
printf("ipv6 i'm here!\n");
break;
case 0x23u:
printf("mobile registration request\n");
break;
case 0x24u:
printf("mobile registration reply\n");
break;
case 0x25u:
printf("domain name request\n");
break;
case 0x26u:
printf("domain name reply\n");
break;
default:
return 0LL;
}
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, unsigned int *a2)
{
__int64 v2; // r13
unsigned __int8 v3; // bl
__int64 v5; // rsi
__int64 v6; // rax

v2 = *((_QWORD *)a2 + 1);
v3 = *(_BYTE *)(v2 + 80);
if ( (unsigned int)video_getx() )
printf("\n");
printf("icmp: received packet (sizeof %d) request: %d: ", *a2, v3);
switch ( v3 )
{
case 0u:
printf("pong\n");
break;
case 3u:
printf("destination not reachable\n");
break;
case 4u:
printf("source quench\n");
break;
case 5u:
printf("redirect\n");
break;
case 6u:
printf("alternative host address\n");
break;
case 8u:
printf("ping\n");
v5 = packet_create(0LL, 4LL);
v6 = *(_QWORD *)(v5 + 8);
*(_WORD *)(v6 + 2) = 0;
*(_BYTE *)v6 = 0;
ip_send_frame(a1, v5, v2 + 12, 1LL);
break;
case 9u:
printf("router advertisement\n");
break;
case 0xAu:
printf("router selection\n");
break;
case 0xBu:
printf("expired request\n");
break;
case 0xCu:
printf("parameters error\n");
break;
case 0xDu:
printf("timestamp request\n");
break;
case 0xEu:
printf("timestamp reply\n");
break;
case 0xFu:
printf("information request\n");
break;
case 0x10u:
printf("information reply\n");
break;
case 0x11u:
printf("address mask request\n");
break;
case 0x12u:
printf("address mask reply\n");
break;
case 0x1Eu:
printf("traceroute\n");
break;
case 0x1Fu:
printf("datagram conversion error\n");
break;
case 0x20u:
printf("mobile host redirect\n");
break;
case 0x21u:
printf("ipv6 where are you?\n");
break;
case 0x22u:
printf("ipv6 i'm here!\n");
break;
case 0x23u:
printf("mobile registration request\n");
break;
case 0x24u:
printf("mobile registration reply\n");
break;
case 0x25u:
printf("domain name request\n");
break;
case 0x26u:
printf("domain name reply\n");
break;
default:
return 0LL;
}
return 0LL;
}

original_code:
uint32_t icmp_handle_packet(network_iface_t *iface, packet_t *p)
{
 uint8_t protocol;
 ip_header_t *iphead = (ip_header_t *) p->data;
 icmp_header_t *icmphead = (icmp_header_t *) p->data + sizeof(ip_header_t);
 protocol = icmphead->type;
 if(video_getx() != 0)
  printf("\n");
 printf("icmp: received packet (sizeof %d) request: %d: ", p->size, protocol);
 switch(protocol)
 {
  case 0:
   printf("pong\n");
   break;
  case 8:
   printf("ping\n");
   packet_t *pong = packet_create(0, sizeof(icmp_header_t));
   icmp_header_t *ponghead = (icmp_header_t *) pong->data;
   ponghead->type = 0;
   ponghead->checksum = 0;
   ip_send_frame(iface, pong, (char *) &(iphead->source), 1);
   break;
  case 5:
   printf("redirect\n");
   break;
  case 4:
   printf("source quench\n");
   break;
  case 3:
   printf("destination not reachable\n");
   break;
  case 6:
   printf("alternative host address\n");
   break;
  case 9:
   printf("router advertisement\n");
   break;
  case 10:
   printf("router selection\n");
   break;
  case 33:
   printf("ipv6 where are you?\n");
   break;
  case 34:
   printf("ipv6 i'm here!\n");
   break;
  case 17:
   printf("address mask request\n");
   break;
  case 18:
   printf("address mask reply\n");
   break;
  case 13:
   printf("timestamp request\n");
   break;
  case 14:
   printf("timestamp reply\n");
   break;
  case 15:
   printf("information request\n");
   break;
  case 16:
   printf("information reply\n");
   break;
  case 30:
   printf("traceroute\n");
   break;
  case 32:
   printf("mobile host redirect\n");
   break;
  case 35:
   printf("mobile registration request\n");
   break;
  case 36:
   printf("mobile registration reply\n");
   break;
  case 37:
   printf("domain name request\n");
   break;
  case 38:
   printf("domain name reply\n");
   break;
  case 31:
   printf("datagram conversion error\n");
   break;
  case 11:
   printf("expired request\n");
   break;
  case 12:
   printf("parameters error\n");
   break;
  default:
   break;
 }
 return 0;
}

canonical_original_code:
unsigned int icmp_handle_packet(struct network_iface_p *iface, struct packet_t *p)
{
 unsigned char protocol;
 struct ip_header_t *iphead = (ip_header_t *) p->data;
 struct icmp_header_t *icmphead = (icmp_header_t *) p->data + sizeof(ip_header_t);
 protocol = icmphead->type;
 if(video_getx() != 0)
  printf("\n");
 printf("icmp: received packet (sizeof %d) request: %d: ", p->size, protocol);
 switch(protocol)
 {
  case 0:
   printf("pong\n");
   break;
  case 8:
   printf("ping\n");
   struct packet_t *pong = packet_create(0, sizeof(icmp_header_t));
   struct icmp_header_t *ponghead = (icmp_header_t *) pong->data;
   ponghead->type = 0;
   ponghead->checksum = 0;
   ip_send_frame(iface, pong, (char *) &(iphead->source), 1);
   break;
  case 5:
   printf("redirect\n");
   break;
  case 4:
   printf("source quench\n");
   break;
  case 3:
   printf("destination not reachable\n");
   break;
  case 6:
   printf("alternative host address\n");
   break;
  case 9:
   printf("router advertisement\n");
   break;
  case 10:
   printf("router selection\n");
   break;
  case 33:
   printf("ipv6 where are you?\n");
   break;
  case 34:
   printf("ipv6 i'm here!\n");
   break;
  case 17:
   printf("address mask request\n");
   break;
  case 18:
   printf("address mask reply\n");
   break;
  case 13:
   printf("timestamp request\n");
   break;
  case 14:
   printf("timestamp reply\n");
   break;
  case 15:
   printf("information request\n");
   break;
  case 16:
   printf("information reply\n");
   break;
  case 30:
   printf("traceroute\n");
   break;
  case 32:
   printf("mobile host redirect\n");
   break;
  case 35:
   printf("mobile registration request\n");
   break;
  case 36:
   printf("mobile registration reply\n");
   break;
  case 37:
   printf("domain name request\n");
   break;
  case 38:
   printf("domain name reply\n");
   break;
  case 31:
   printf("datagram conversion error\n");
   break;
  case 11:
   printf("expired request\n");
   break;
  case 12:
   printf("parameters error\n");
   break;
  default:
   break;
 }
 return 0;
}

variable_types: struct network_iface_p { char name[32]; char addr[4]; char mask[4]; char bcast[4]; char mac[6]; unsigned char if_up; unsigned char if_mac; unsigned char if_bcast; unsigned char type; unsigned int tx_bytes; unsigned int rx_bytes; struct driver_p { char name[32]; char desc[128]; char author[128]; unsigned char type; struct driver_fs_t { unsigned int (*mount)(char *, unsigned int, struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *); unsigned int (*umount)(struct inode_p *); unsigned int (*mkdir)(struct inode_p *, char *); unsigned int (*readdir)(struct inode_p *, unsigned int, struct dirent { char name[255]; unsigned int inode; } *); unsigned int (*get_node)(struct inode_p *, unsigned int, struct inode_p **); unsigned int (*delete_node)(struct inode_p *, char *); unsigned int (*create_node)(struct inode_p *, char *, unsigned int); unsigned int (*write_stat)(struct inode_p *, struct stat { unsigned int st_dev; unsigned int st_ino; int st_uid; int st_gid; unsigned long long st_blksize; unsigned long long st_blocks; } *, unsigned int); unsigned int (*read_stat)(struct inode_p *, struct stat *); unsigned int (*open)(struct inode_p *, char *); unsigned int (*close)(struct inode_p *); unsigned int (*read)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*link)(struct inode_p *, char *, struct inode_p *, char *); unsigned int (*unlink)(struct inode_p *, char *); unsigned char ifdev; } fs; struct driver_video_t { char *buffer; void (*put_pixel)(unsigned int, unsigned int, unsigned int); unsigned int (*get_pixel)(unsigned int, unsigned int); unsigned int (*set_mode)(unsigned int, unsigned int, unsigned int); } video; unsigned char loaded; unsigned int (*init)(); unsigned int (*free)(); unsigned int (*probe)(struct device_p { unsigned int io_base; char vendor[32]; char vendor_full[32]; char device[32]; char device_desc[32]; char class[32]; char class_desc[32]; char class_prog_desc[32]; unsigned char bus_type; void *pci_dev; unsigned char interrupt; unsigned int base_addresses[6]; char file[32]; struct device_p *next; } *); unsigned int (*read)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*ioctl)(struct device_p *, unsigned int, unsigned int, unsigned int); struct driver_p *next; } *drv; struct device_p *dev; void *link_protocol; struct network_iface_p *next; } *

variable_types: struct packet_t { unsigned int size; char *data; } *

variable_types:
protocol
unsigned char

variable_types: struct ip_header_t { unsigned char version; unsigned char head_len; unsigned char tos; unsigned short total_len; unsigned short ident; unsigned char flags; unsigned short offset; unsigned char time_to_live; unsigned char protocol; unsigned short header_checksum; unsigned int source; unsigned int dest; } *

variable_types: struct icmp_header_t { unsigned char type; unsigned char code; unsigned short checksum; } *


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

original_code:
uint8_t dns_resolve(char *site, char *addr)
{
 return 0;
}

canonical_original_code:
unsigned char dns_resolve(char *site, char *addr)
{
 return 0;
}

variable_types:
site
char *

variable_types:
addr
char *

return_type: unsigned char


localtime

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

original_code:
struct tm *localtime(const time_t *timer)
{
 return 0;
}

canonical_original_code:
struct tm *localtime(long *timer)
{
 return 0;
}

variable_types:
timer
long *

return_type: struct tm { int Y; int tm_year; } *


decompiled_code:
__int64 __fastcall ip_handle_packet(__int64 a1, unsigned int *a2)
{
unsigned int v2; // er13
char v3; // bl
__int64 result; // rax

v2 = *(unsigned __int8 *)(*((_QWORD *)a2 + 1) + 9LL);
v3 = *(_BYTE *)(*((_QWORD *)a2 + 1) + 9LL);
if ( (unsigned int)video_getx() )
printf("\n");
printf("ip: received packet (sizeof %d) of protocol %x\n", *a2, v2);
udp_handle_packet(a1, a2);
if ( v3 == 1 )
{
icmp_handle_packet(a1, a2);
result = 0LL;
}
else
{
if ( v3 == 17 )
udp_handle_packet(a1, a2);
result = 0LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1, unsigned int *a2)
{
unsigned int v2; // er13
char v3; // bl
__int64 result; // rax

v2 = *(unsigned __int8 *)(*((_QWORD *)a2 + 1) + 9LL);
v3 = *(_BYTE *)(*((_QWORD *)a2 + 1) + 9LL);
if ( (unsigned int)video_getx() )
printf("\n");
printf("ip: received packet (sizeof %d) of protocol %x\n", *a2, v2);
udp_handle_packet(a1, a2);
if ( v3 == 1 )
{
icmp_handle_packet(a1, a2);
result = 0LL;
}
else
{
if ( v3 == 17 )
udp_handle_packet(a1, a2);
result = 0LL;
}
return result;
}

original_code:
uint32_t ip_handle_packet(network_iface_t *iface, packet_t *p)
{
 uint32_t protocol;
 ip_header_t *iphead = (ip_header_t *) p->data;
 protocol = iphead->protocol;
 if(video_getx() != 0)
  printf("\n");
 printf("ip: received packet (sizeof %d) of protocol %x\n", p->size, protocol);
  udp_handle_packet(iface, p);
 switch(protocol)
 {
  case 1:
   icmp_handle_packet(iface, p);
   break;
  case 17:
   udp_handle_packet(iface, p);
   break;
  case 6:
   break;
 }
 return 0;
}

canonical_original_code:
unsigned int ip_handle_packet(struct network_iface_p *iface, struct packet_t *p)
{
 unsigned int protocol;
 struct ip_header_t *iphead = (ip_header_t *) p->data;
 protocol = iphead->protocol;
 if(video_getx() != 0)
  printf("\n");
 printf("ip: received packet (sizeof %d) of protocol %x\n", p->size, protocol);
  udp_handle_packet(iface, p);
 switch(protocol)
 {
  case 1:
   icmp_handle_packet(iface, p);
   break;
  case 17:
   udp_handle_packet(iface, p);
   break;
  case 6:
   break;
 }
 return 0;
}

variable_types:
protocol
unsigned int


decompiled_code:
__int64 __fastcall ip_send_frame(__int64 a1, __int64 a2, const void *a3)
{
char v5[4]; // [rsp+Ch] [rbp-2Ch] BYREF
char dest[4]; // [rsp+10h] [rbp-28h] BYREF

printf("sending ip frame\n");
memcpy(dest, a3, sizeof(dest));
memcpy(v5, (const void *)(a1 + 32), sizeof(v5));
return (*(__int64 (__fastcall **)(__int64, __int64))(*(_QWORD *)(a1 + 80) + 24LL))(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, __int64 a2, const void *a3)
{
char v5[4]; // [rsp+Ch] [rbp-2Ch] BYREF
char dest[4]; // [rsp+10h] [rbp-28h] BYREF

printf("sending ip frame\n");
memcpy(dest, a3, sizeof(dest));
memcpy(v5, (const void *)(a1 + 32), sizeof(v5));
return (*(__int64 (__fastcall **)(__int64, __int64))(*(_QWORD *)(a1 + 80) + 24LL))(a1, a2);
}

original_code:
uint32_t ip_send_frame(network_iface_t *iface, packet_t *p, char *adr, uint8_t proto)
{
 printf("sending ip frame\n");
 ip_header_t header;
 memcpy(&(header.dest), adr, 4);
 memcpy(&(header.source), (iface->addr), 4);
 return ((netlink_t *) (iface->link_protocol))->send_frame(iface, p);
 if((p->size + ((netlink_t *) (iface->link_protocol))->header_size) > ((netlink_t *) (iface->link_protocol))->frame_max_size)
 {
  ip_header_t *fragheader;
  uint32_t i;
  uint32_t nf = (p->size + ((netlink_t *) (iface->link_protocol))->header_size) /
     ((netlink_t *) (iface->link_protocol))->frame_max_size;
  uint32_t offset = 0;
  for(i = 0; i < nf; i++)
  {
   packet_t *frag = packet_create(0, 1);
   fragheader = (ip_header_t *) frag->data;
   fragheader->offset = offset;
   fragheader->time_to_live = 255;
   ((netlink_t *) (iface->link_protocol))->send_frame(iface, frag);
  }
 }
 else
  ((netlink_t *) (iface->link_protocol))->send_frame(iface, p);
 return 0;
}

canonical_original_code:
unsigned int ip_send_frame(struct network_iface_p *iface, struct packet_t *p, char *adr, unsigned char proto)
{
 printf("sending ip frame\n");
 struct ip_header_t header;
 memcpy(&(header.dest), adr, 4);
 memcpy(&(header.source), (iface->addr), 4);
 return ((struct netlink_t *) (iface->link_protocol))->send_frame(iface, p);
 if((p->size + ((struct netlink_t *) (iface->link_protocol))->header_size) > ((struct netlink_t *) (iface->link_protocol))->frame_max_size)
 {
  struct ip_header_t *fragheader;
  unsigned int i;
  unsigned int nf = (p->size + ((netlink_t *) (iface->link_protocol))->header_size) /
     ((netlink_t *) (iface->link_protocol))->frame_max_size;
  unsigned int offset = 0;
  for(i = 0; i < nf; i++)
  {
   struct packet_t *frag = packet_create(0, 1);
   fragheader = (struct ip_header_t *) frag->data;
   fragheader->offset = offset;
   fragheader->time_to_live = 255;
   ((struct netlink_t *) (iface->link_protocol))->send_frame(iface, frag);
  }
 }
 else
  ((struct netlink_t *) (iface->link_protocol))->send_frame(iface, p);
 return 0;
}

variable_types:
adr
char *

variable_types:
proto
unsigned char

variable_types: struct ip_header_t { unsigned char version; unsigned char head_len; unsigned char tos; unsigned short total_len; unsigned short ident; unsigned char flags; unsigned short offset; unsigned char time_to_live; unsigned char protocol; unsigned short header_checksum; unsigned int source; unsigned int dest; }

variable_types:
i
unsigned int

variable_types:
nf
unsigned int

variable_types:
offset
unsigned int

user_defined_types: struct netlink_t { unsigned int (*up)(struct network_iface_p *); unsigned int (*down)(struct network_iface_p *); unsigned int (*handle_frame)(struct network_iface_p *, struct packet_t *); unsigned int (*send_frame)(struct network_iface_p *, struct packet_t *); unsigned int frame_min_size; unsigned int frame_max_size; unsigned int header_size; }


decompiled_code:
__int64 md5_encode()
{
return 32LL;
}

canonical_decompiled_code:
__int64 func0()
{
return 32LL;
}

original_code:
uint32_t md5_encode(char *string, uint32_t size, char *md5_code)
{
 return 32;
}

canonical_original_code:
unsigned int md5_encode(char *string, unsigned int size, char *md5_code)
{
 return 32;
}

variable_types:
string
char *

variable_types:
size
unsigned int


decompiled_code:
_BOOL8 __fastcall elf_check(_BYTE *a1)
{
_BOOL8 result; // rax

result = 0LL;
if ( a1[1] == 69 && a1[2] == 76 && a1[3] == 70 )
result = *a1 == 127;
return result;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(_BYTE *a1)
{
_BOOL8 result; // rax

result = 0LL;
if ( a1[1] == 69 && a1[2] == 76 && a1[3] == 70 )
result = *a1 == 127;
return result;
}

original_code:
uint32_t elf_check(char *buf)
{
 elf_header_t *header = (elf_header_t *) buf;
 if( (*(header->ident+1) == 'E') &&
  (*(header->ident+2) == 'L') &&
  (*(header->ident+3) == 'F') &&
  (*(header->ident) == 0x7f))
  return 1;
 return 0;
}

canonical_original_code:
unsigned int elf_check(char *buf)
{
 struct elf_header_t *header = (elf_header_t *) buf;
 if( (*(header->ident+1) == 'E') &&
  (*(header->ident+2) == 'L') &&
  (*(header->ident+3) == 'F') &&
  (*(header->ident) == 0x7f))
  return 1;
 return 0;
}

variable_types:
buf
char *

variable_types: struct elf_header_t { char ident[16]; unsigned short type; unsigned short machine; unsigned int version; unsigned int entry; unsigned int phoff; unsigned int shoff; unsigned int flags; unsigned short ehsize; unsigned short phentsize; unsigned short phnum; unsigned short shentsize; unsigned short shnum; unsigned short shstrndx; } *


decompiled_code:
__int64 __fastcall arp_resolve(void *s1, void *dest)
{
unsigned int v2; // ebx
__int64 v3; // rbp

if ( !arp_table_pointer )
return 0xFFFFFFFFLL;
v2 = 0;
do
{
v3 = 10LL * v2;
if ( !memcmp(s1, (char *)&arp_table + v3, 4uLL) )
{
memcpy(dest, (char *)&arp_table + v3 + 4, 8uLL);
return v2;
}
++v2;
}
while ( arp_table_pointer > v2 );
return 0xFFFFFFFFLL;
}

canonical_decompiled_code:
__int64 __fastcall func0(void *s1, void *dest)
{
unsigned int v2; // ebx
__int64 v3; // rbp

if ( !arp_table_pointer )
return 0xFFFFFFFFLL;
v2 = 0;
do
{
v3 = 10LL * v2;
if ( !memcmp(s1, (char *)&arp_table + v3, 4uLL) )
{
memcpy(dest, (char *)&arp_table + v3 + 4, 8uLL);
return v2;
}
++v2;
}
while ( arp_table_pointer > v2 );
return 0xFFFFFFFFLL;
}

original_code:
int32_t arp_resolve(ip_t ip, mac_t hw)
{
 uint32_t i;
 for(i = 0; i < arp_table_pointer; i++)
 {
  if(memcmp(ip, arp_table[i].ip, 4) == 0)
  {
   memcpy(hw, arp_table[i].mac, 8);
   return i;
  }
 }
 return -1;
}

canonical_original_code:
int arp_resolve(char ip[4], char hw[6])
{
 unsigned int i;
 for(i = 0; i < arp_table_pointer; i++)
 {
  if(memcmp(ip, arp_table[i].ip, 4) == 0)
  {
   memcpy(hw, arp_table[i].mac, 8);
   return i;
  }
 }
 return -1;
}

variable_types:
ip
char [4]

variable_types:
hw
char [6]


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

original_code:
uint32_t arp_request(network_iface_t *iface, ip_t ip)
{
 return 0;
}

canonical_original_code:
unsigned int arp_request(struct network_iface_p *iface, char ip[4])
{
 return 0;
}

variable_types: struct network_iface_p { char name[32]; char addr[4]; char mask[4]; char bcast[4]; char mac[6]; unsigned char if_up; unsigned char if_mac; unsigned char if_bcast; unsigned char type; unsigned int tx_bytes; unsigned int rx_bytes; struct driver_p { char name[32]; char desc[128]; char author[128]; unsigned char type; struct driver_fs_t { unsigned int (*mount)(char *, unsigned int, struct inode_p { char name[255]; unsigned int inode_n; unsigned char type; unsigned char ow; void *fs_node; void *fs_driver; struct inode_p *link; struct inode_p *next; struct inode_p *prev; struct inode_p *parent; struct inode_p *childs; } *); unsigned int (*umount)(struct inode_p *); unsigned int (*mkdir)(struct inode_p *, char *); unsigned int (*readdir)(struct inode_p *, unsigned int, struct dirent { char name[255]; unsigned int inode; } *); unsigned int (*get_node)(struct inode_p *, unsigned int, struct inode_p **); unsigned int (*delete_node)(struct inode_p *, char *); unsigned int (*create_node)(struct inode_p *, char *, unsigned int); unsigned int (*write_stat)(struct inode_p *, struct stat { unsigned int st_dev; unsigned int st_ino; int st_uid; int st_gid; unsigned long long st_blksize; unsigned long long st_blocks; } *, unsigned int); unsigned int (*read_stat)(struct inode_p *, struct stat *); unsigned int (*open)(struct inode_p *, char *); unsigned int (*close)(struct inode_p *); unsigned int (*read)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct inode_p *, char *, unsigned int, unsigned long long); unsigned int (*link)(struct inode_p *, char *, struct inode_p *, char *); unsigned int (*unlink)(struct inode_p *, char *); unsigned char ifdev; } fs; struct driver_video_t { char *buffer; void (*put_pixel)(unsigned int, unsigned int, unsigned int); unsigned int (*get_pixel)(unsigned int, unsigned int); unsigned int (*set_mode)(unsigned int, unsigned int, unsigned int); } video; unsigned char loaded; unsigned int (*init)(); unsigned int (*free)(); unsigned int (*probe)(struct device_p { unsigned int io_base; char vendor[32]; char vendor_full[32]; char device[32]; char device_desc[32]; char class[32]; char class_desc[32]; char class_prog_desc[32]; unsigned char bus_type; void *pci_dev; unsigned char interrupt; unsigned int base_addresses[6]; char file[32]; struct device_p *next; } *); unsigned int (*read)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*write)(struct device_p *, char *, unsigned int, unsigned long long); unsigned int (*ioctl)(struct device_p *, unsigned int, unsigned int, unsigned int); struct driver_p *next; } *drv; struct device_p *dev; void *link_protocol; struct network_iface_p *next; } *


decompiled_code:
// attributes: thunk
__int64 arp_handle_frame()
{
return arp_request();
}

canonical_decompiled_code:
__int64 func2()
{
return func1();
}

original_code:
uint32_t arp_handle_frame(network_iface_t *iface, packet_t *p)
{
 return 0;
}

canonical_original_code:
unsigned int arp_handle_frame(struct network_iface_p *iface, struct packet_t *p)
{
 return 0;
}

variable_types: struct packet_t { unsigned int size; char *data; } *


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

original_code:
uint32_t isa_probe()
{
 return 0;
}

canonical_original_code:
unsigned int isa_probe()
{
 return 0;
}


loadsplash

decompiled_code:
__int64 __fastcall loadsplash(unsigned int a1, unsigned int a2)
{
void *v2; // r12
_BYTE v4[66584]; // [rsp+0h] [rbp-10418h] BYREF

v2 = (void *)*(unsigned int *)(vesa_get_mode_info() + 40);
render_draw_rect_fill(0LL, 0LL, a1, a2, 3722304989LL);
if ( (unsigned int)load_raw_bitmap("/initr/splash.raw", v4, 130LL, 128LL) )
render_bit_map(v4, (unsigned int)((int)a1 / 2 - 64), (unsigned int)((int)a2 / 2 - 65), 130LL, 128LL);
render_write_text(16LL, "SpiderpigOS is loading...", 0xFFFFFFFLL, 10LL, 10LL);
memcpy(v2, &render_buffer, (size_t)&unk_1D4C00);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned int a1, unsigned int a2)
{
void *v2; // r12
_BYTE v4[66584]; // [rsp+0h] [rbp-10418h] BYREF

v2 = (void *)*(unsigned int *)(vesa_get_mode_info() + 40);
render_draw_rect_fill(0LL, 0LL, a1, a2, 3722304989LL);
if ( (unsigned int)load_raw_bitmap("/initr/splash.raw", v4, 130LL, 128LL) )
render_bit_map(v4, (unsigned int)((int)a1 / 2 - 64), (unsigned int)((int)a2 / 2 - 65), 130LL, 128LL);
render_write_text(16LL, "SpiderpigOS is loading...", 0xFFFFFFFLL, 10LL, 10LL);
memcpy(v2, &render_buffer, (size_t)&unk_1D4C00);
return 0LL;
}

original_code:
int loadsplash(int x, int y)
{
 uint32_t i;
 int b;
 char *phys;
 char img[130*128*4];
 b = (x - 100) / 5;
 phys = (char *) (((vesa_mode_info_t *) vesa_get_mode_info())->phys_base_ptr);
 render_draw_rect_fill(0, 0, x, y, 0xDDDDDDDD);
 if(load_raw_bitmap("/initr/splash.raw", img, 130, 128))
  render_bit_map((uint32_t *) img, x / 2 - 64, y / 2 - 65, 130, 128);
 render_write_text(16, "SpiderpigOS is loading...", 0xFFFFFFF, 10, 10);
 memcpy(phys, render_buffer, sizeof(render_buffer));
 return 0;
}

canonical_original_code:
int loadsplash(int x, int y)
{
 unsigned int i;
 int b;
 char *phys;
 char img[-1];
 b = (x - 100) / 5;
 phys = (char *) (((struct vesa_mode_info_t *) vesa_get_mode_info())->phys_base_ptr);
 render_draw_rect_fill(0, 0, x, y, 0xDDDDDDDD);
 if(load_raw_bitmap("/initr/splash.raw", img, 130, 128))
  render_bit_map((unsigned int *) img, x / 2 - 64, y / 2 - 65, 130, 128);
 render_write_text(16, "SpiderpigOS is loading...", 0xFFFFFFF, 10, 10);
 memcpy(phys, render_buffer, sizeof(render_buffer));
 return 0;
}

variable_types: x int

variable_types: y int

variable_types: b int

variable_types:
phys
char *

variable_types:
img
char [-1]


decompiled_code:
__int64 __fastcall syscall_call5()
{
__int64 result; // rax

__asm { int 84h }
return (unsigned int)result;
}

canonical_decompiled_code:
__int64 __fastcall func0()
{
__int64 result; // rax

__asm { int 84h }
return (unsigned int)result;
}

original_code:
int syscall_call5(uint32_t call, uint32_t p1, uint32_t p2, uint32_t p3, uint32_t p4, uint32_t p5)
{
 int ret;
 asm ("int %0\n" : : "g" (0x84));
 asm ("movl %%eax, %0\n\t" : "=r" (ret));
 return ret;
}

canonical_original_code:
int syscall_call5(unsigned int call, unsigned int p1, unsigned int p2, unsigned int p3, unsigned int p4, unsigned int p5)
{
 int ret;
 asm ("int %0\n" : : "g" (0x84));
 asm ("movl %%eax, %0\n\t" : "=r" (ret));
 return ret;
}

variable_types:
call
unsigned int

variable_types: ret int


decompiled_code:
__int64 __fastcall timing_beh(__int64 a1)
{
int v1; // edx
__int64 v2; // rax
const char *v3; // r12
const char *v5; // [rsp+0h] [rbp-48h] BYREF
int v6; // [rsp+8h] [rbp-40h]
int v7; // [rsp+Ch] [rbp-3Ch]
void *v8; // [rsp+10h] [rbp-38h]
char **v9; // [rsp+18h] [rbp-30h]
__int64 v10; // [rsp+20h] [rbp-28h]

v5 = "timing_beh";
v1 = *(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 8LL);
v10 = *(_QWORD *)(dbug_cfg + 80LL);
v7 = 25;
v6 = v1;
v8 = &unk_8F3;
v9 = dbug_unit;
dbug_enter(&v5);
v2 = tv_create(*(_QWORD *)(a1 + 80), *(_QWORD *)(a1 + 88));
v3 = (const char *)cons_to_str(v2);
if ( dbug_on )
{
*(_QWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 16LL) = &unk_8F3;
if ( (unsigned int)dbug_keyword(&unk_8F3) )
{
*(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 12LL) = 27;
dbug_print("[timestamp] %s", v3);
}
}
fprintf(stderr, "[timestamp] %s\n", v3);
v7 = 29;
return dbug_return(&v5);
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
int v1; // edx
__int64 v2; // rax
const char *v3; // r12
const char *v5; // [rsp+0h] [rbp-48h] BYREF
int v6; // [rsp+8h] [rbp-40h]
int v7; // [rsp+Ch] [rbp-3Ch]
void *v8; // [rsp+10h] [rbp-38h]
char **v9; // [rsp+18h] [rbp-30h]
__int64 v10; // [rsp+20h] [rbp-28h]

v5 = "timing_beh";
v1 = *(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 8LL);
v10 = *(_QWORD *)(dbug_cfg + 80LL);
v7 = 25;
v6 = v1;
v8 = &unk_8F3;
v9 = dbug_unit;
dbug_enter(&v5);
v2 = tv_create(*(_QWORD *)(a1 + 80), *(_QWORD *)(a1 + 88));
v3 = (const char *)cons_to_str(v2);
if ( dbug_on )
{
*(_QWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 16LL) = &unk_8F3;
if ( (unsigned int)dbug_keyword(&unk_8F3) )
{
*(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 12LL) = 27;
dbug_print("[timestamp] %s", v3);
}
}
fprintf(stderr, "[timestamp] %s\n", v3);
v7 = 29;
return dbug_return(&v5);
}

original_code:
void timing_beh (CONFIG* abe__config)
{
 char* s;
 struct dbug_ctx_t dbug_ctx; dbug_ctx.name = ("timing_beh"); dbug_ctx.depth = dbug_cfg->ctx->depth; dbug_ctx.line = 25; dbug_ctx.keyword = ""; dbug_ctx.unit = &dbug_unit; dbug_ctx.caller = dbug_cfg->ctx; dbug_enter (&dbug_ctx);
 s = cons_to_str(tv_create((abe__config)->t_now_s, (abe__config)->t_now_us));
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 27; dbug_print ("[timestamp] %s", s); }}while(0);
 fprintf(stderr, "[timestamp] %s\n", s);
 dbug_ctx.line = 29; dbug_return (&dbug_ctx); return;
}

canonical_original_code:
void timing_beh(struct config *abe__config)
{
 char *s;
 struct dbug_ctx_t dbug_ctx; dbug_ctx.name = ("timing_beh"); dbug_ctx.depth = dbug_cfg->ctx->depth; dbug_ctx.line = 25; dbug_ctx.keyword = ""; dbug_ctx.unit = &dbug_unit; dbug_ctx.caller = dbug_cfg->ctx; dbug_enter (&dbug_ctx);
 s = cons_to_str(tv_create((abe__config)->t_now_s, (abe__config)->t_now_us));
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 27; dbug_print ("[timestamp] %s", s); }}while(0);
 fprintf(stderr, "[timestamp] %s\n", s);
 dbug_ctx.line = 29; dbug_return (&dbug_ctx); return;
}

variable_types: struct config { struct cell { struct cons { struct cons *first; struct cons *rest; } *first; struct cons *rest; long _prev; long _next; } msg_queue; struct cons *gc_root; int q_count; struct cons *q_entry; int msg_cnt_hi; int msg_cnt_lo; int q_limit; long t_epoch; long t_now_s; long t_now_us; struct cons *t_queue; int t_count; } *

variable_types:
s
char *

variable_types: struct dbug_ctx_t { char *name; int depth; int line; char *keyword; struct dbug_unit_t { char *name; char *unit; } *unit; struct dbug_ctx_t *caller; }

user_defined_types: struct dbug_ctx_t { char *name; int depth; int line; char *keyword; struct dbug_unit_t *unit; struct dbug_ctx_t *caller; }

user_defined_types: struct config { struct cell msg_queue; struct cons *gc_root; int q_count; struct cons *q_entry; int msg_cnt_hi; int msg_cnt_lo; int q_limit; long t_epoch; long t_now_s; long t_now_us; struct cons *t_queue; int t_count; }

user_defined_types: struct cell { struct cons *first; struct cons *rest; long _prev; long _next; }


original_code:
void countdown_ring_0_beh (CONFIG* abe__config)
{
 CONS* m = _cdr((abe__config)->q_entry);
 CONS* first = _mine(_car((abe__config)->q_entry));
 int m_int = ((int)(((WORD)(m))>>2));
 struct dbug_ctx_t dbug_ctx; dbug_ctx.name = ("countdown_ring_0_beh"); dbug_ctx.depth = dbug_cfg->ctx->depth; dbug_ctx.line = 47; dbug_ctx.keyword = ""; dbug_ctx.unit = &dbug_unit; dbug_ctx.caller = dbug_cfg->ctx; dbug_enter (&dbug_ctx);
 if (m_int <= 0) {
  abe__become(_car((abe__config)->q_entry),(sink_beh),(((CONS*)(&nil__cons))));
  abe__send((abe__config),(timing_actor),(((CONS*)(&nil__cons))));
 } else {
  abe__send((abe__config),(first),(((CONS*)((((WORD)(m_int - 1))<<2) | ((WORD)(0x00000003))))));
 }
 dbug_ctx.line = 54; dbug_return (&dbug_ctx); return;
}

canonical_original_code:
void countdown_ring_0_beh(struct config *abe__config)
{
 struct cons *m = _cdr((abe__config)->q_entry);
 struct cons *first = _mine(_car((abe__config)->q_entry));
 int m_int = ((int)(((WORD)(m))>>2));
 struct dbug_ctx_t dbug_ctx; dbug_ctx.name = ("countdown_ring_0_beh"); dbug_ctx.depth = dbug_cfg->ctx->depth; dbug_ctx.line = 47; dbug_ctx.keyword = ""; dbug_ctx.unit = &dbug_unit; dbug_ctx.caller = dbug_cfg->ctx; dbug_enter (&dbug_ctx);
 if (m_int <= 0) {
  abe__become(_car((abe__config)->q_entry),(sink_beh),(((struct cons *)(&nil__cons))));
  abe__send((abe__config),(timing_actor),(((struct cons *)(&nil__cons))));
 } else {
  abe__send((abe__config),(first),(((struct cons *)((((WORD)(m_int - 1))<<2) | ((WORD)(0x00000003))))));
 }
 dbug_ctx.line = 54; dbug_return (&dbug_ctx); return;
}

variable_types: struct cons { struct cons *first; struct cons *rest; } *

user_defined_types: struct dbug_unit_t { char *name; char *unit; }


decompiled_code:
__int64 __fastcall countdown_ring_beh(__int64 a1)
{
__int64 v1; // r13
__int64 v2; // rax
__int64 v3; // r12
int v4; // edx
const char *v6; // [rsp+0h] [rbp-48h] BYREF
int v7; // [rsp+8h] [rbp-40h]
int v8; // [rsp+Ch] [rbp-3Ch]
void *v9; // [rsp+10h] [rbp-38h]
char **v10; // [rsp+18h] [rbp-30h]
__int64 v11; // [rsp+20h] [rbp-28h]

v1 = cdr(*(_QWORD *)(a1 + 48));
v2 = car(*(_QWORD *)(a1 + 48));
v6 = "countdown_ring_beh";
v3 = mine(v2);
v4 = *(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 8LL);
v11 = *(_QWORD *)(dbug_cfg + 80LL);
v8 = 67;
v7 = v4;
v9 = &unk_8F3;
v10 = dbug_unit;
dbug_enter(&v6);
abe__send(a1, v3, v1);
v8 = 69;
return dbug_return(&v6);
}

original_code:
void countdown_ring_beh (CONFIG* abe__config)
{
 CONS* m = _cdr((abe__config)->q_entry);
 CONS* next = _mine(_car((abe__config)->q_entry));
 struct dbug_ctx_t dbug_ctx; dbug_ctx.name = ("countdown_ring_beh"); dbug_ctx.depth = dbug_cfg->ctx->depth; dbug_ctx.line = 67; dbug_ctx.keyword = ""; dbug_ctx.unit = &dbug_unit; dbug_ctx.caller = dbug_cfg->ctx; dbug_enter (&dbug_ctx);
 abe__send((abe__config),(next),(m));
 dbug_ctx.line = 69; dbug_return (&dbug_ctx); return;
}

canonical_original_code:
void countdown_ring_beh(struct config *abe__config)
{
 struct cons *m = _cdr((abe__config)->q_entry);
 struct cons *next = _mine(_car((abe__config)->q_entry));
 struct dbug_ctx_t dbug_ctx; dbug_ctx.name = ("countdown_ring_beh"); dbug_ctx.depth = dbug_cfg->ctx->depth; dbug_ctx.line = 67; dbug_ctx.keyword = ""; dbug_ctx.unit = &dbug_unit; dbug_ctx.caller = dbug_cfg->ctx; dbug_enter (&dbug_ctx);
 abe__send((abe__config),(next),(m));
 dbug_ctx.line = 69; dbug_return (&dbug_ctx); return;
}

user_defined_types: struct cons { struct cons *first; struct cons *rest; }


original_code:
void ring_link_beh (CONFIG* abe__config)
{
 CONS* next = _mine(_car((abe__config)->q_entry));
 CONS* first = _cdr((abe__config)->q_entry);
 struct dbug_ctx_t dbug_ctx; dbug_ctx.name = ("countdown_ring_beh"); dbug_ctx.depth = dbug_cfg->ctx->depth; dbug_ctx.line = 130; dbug_ctx.keyword = ""; dbug_ctx.unit = &dbug_unit; dbug_ctx.caller = dbug_cfg->ctx; dbug_enter (&dbug_ctx);
 abe__send((abe__config),(next),(first));
 dbug_ctx.line = 132; dbug_return (&dbug_ctx); return;
}

canonical_original_code:
void ring_link_beh(struct config *abe__config)
{
 struct cons *next = _mine(_car((abe__config)->q_entry));
 struct cons *first = _cdr((abe__config)->q_entry);
 struct dbug_ctx_t dbug_ctx; dbug_ctx.name = ("countdown_ring_beh"); dbug_ctx.depth = dbug_cfg->ctx->depth; dbug_ctx.line = 130; dbug_ctx.keyword = ""; dbug_ctx.unit = &dbug_unit; dbug_ctx.caller = dbug_cfg->ctx; dbug_enter (&dbug_ctx);
 abe__send((abe__config),(next),(first));
 dbug_ctx.line = 132; dbug_return (&dbug_ctx); return;
}


decompiled_code:
__int64 __fastcall countdown_builder_beh(__int64 a1)
{
int v1; // edx
__int64 v2; // rax
__int64 v3; // rbx
__int64 v4; // rax
__int64 v5; // r12
__int64 v6; // rax
__int64 v7; // r13
__int64 v8; // rbx
__int64 v9; // r12
__int64 v10; // rax
__int64 v11; // rax
__int64 v13; // rax
const char *v14; // [rsp+0h] [rbp-58h] BYREF
int v15; // [rsp+8h] [rbp-50h]
int v16; // [rsp+Ch] [rbp-4Ch]
void *v17; // [rsp+10h] [rbp-48h]
char **v18; // [rsp+18h] [rbp-40h]
__int64 v19; // [rsp+20h] [rbp-38h]

v14 = "countdown_builder_beh";
v1 = *(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 8LL);
v19 = *(_QWORD *)(dbug_cfg + 80LL);
v16 = 96;
v15 = v1;
v17 = &unk_8F3;
v18 = dbug_unit;
dbug_enter(&v14);
v2 = car(*(_QWORD *)(a1 + 48));
v3 = mine(v2);
if ( (v3 & 3) != 3 )
_assert_fail("numberp(n)", "echallenge.c", 0x62u, "countdown_builder_beh");
if ( !cdr(*(_QWORD *)(a1 + 48)) || (cdr(*(_QWORD *)(a1 + 48)) & 3) != 0 )
_assert_fail("consp(WHAT)", "echallenge.c", 0x63u, "countdown_builder_beh");
v4 = cdr(*(_QWORD *)(a1 + 48));
v5 = car(v4);
if ( (v5 & 3) != 1 )
_assert_fail("actorp(first)", "echallenge.c", 0x65u, "countdown_builder_beh");
v6 = cdr(*(_QWORD *)(a1 + 48));
v7 = cdr(v6);
if ( (v7 & 3) != 3 )
_assert_fail("numberp(m)", "echallenge.c", 0x67u, "countdown_builder_beh");
v8 = v3 >> 2;
if ( dbug_on )
{
*(_QWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 16LL) = &unk_8F3;
if ( (unsigned int)dbug_keyword(&unk_8F3) )
{
*(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 12LL) = 105;
dbug_print("n=%d m=%d", (unsigned int)v8, v7 >> 2);
}
}
if ( (int)v8 <= 0 )
{
v13 = car(*(_QWORD *)(a1 + 48));
abe__become(v13, countdown_ring_0_beh, v5);
abe__send(a1, timing_actor, &nil__cons);
abe__send(a1, v5, v7);
}
else
{
v9 = abe__actor(a1, countdown_builder_beh, 4LL * ((int)v8 - 1) + 3);
v10 = car(*(_QWORD *)(a1 + 48));
abe__become(v10, countdown_ring_beh, v9);
v11 = cdr(*(_QWORD *)(a1 + 48));
abe__send(a1, v9, v11);
}
v16 = 117;
return dbug_return(&v14);
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
int v1; // edx
__int64 v2; // rax
__int64 v3; // rbx
__int64 v4; // rax
__int64 v5; // r12
__int64 v6; // rax
__int64 v7; // r13
__int64 v8; // rbx
__int64 v9; // r12
__int64 v10; // rax
__int64 v11; // rax
__int64 v13; // rax
const char *v14; // [rsp+0h] [rbp-58h] BYREF
int v15; // [rsp+8h] [rbp-50h]
int v16; // [rsp+Ch] [rbp-4Ch]
void *v17; // [rsp+10h] [rbp-48h]
char **v18; // [rsp+18h] [rbp-40h]
__int64 v19; // [rsp+20h] [rbp-38h]

v14 = "countdown_builder_beh";
v1 = *(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 8LL);
v19 = *(_QWORD *)(dbug_cfg + 80LL);
v16 = 96;
v15 = v1;
v17 = &unk_8F3;
v18 = dbug_unit;
dbug_enter(&v14);
v2 = car(*(_QWORD *)(a1 + 48));
v3 = mine(v2);
if ( (v3 & 3) != 3 )
_assert_fail("numberp(n)", "echallenge.c", 0x62u, "countdown_builder_beh");
if ( !cdr(*(_QWORD *)(a1 + 48)) || (cdr(*(_QWORD *)(a1 + 48)) & 3) != 0 )
_assert_fail("consp(WHAT)", "echallenge.c", 0x63u, "countdown_builder_beh");
v4 = cdr(*(_QWORD *)(a1 + 48));
v5 = car(v4);
if ( (v5 & 3) != 1 )
_assert_fail("actorp(first)", "echallenge.c", 0x65u, "countdown_builder_beh");
v6 = cdr(*(_QWORD *)(a1 + 48));
v7 = cdr(v6);
if ( (v7 & 3) != 3 )
_assert_fail("numberp(m)", "echallenge.c", 0x67u, "countdown_builder_beh");
v8 = v3 >> 2;
if ( dbug_on )
{
*(_QWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 16LL) = &unk_8F3;
if ( (unsigned int)dbug_keyword(&unk_8F3) )
{
*(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 12LL) = 105;
dbug_print("n=%d m=%d", (unsigned int)v8, v7 >> 2);
}
}
if ( (int)v8 <= 0 )
{
v13 = car(*(_QWORD *)(a1 + 48));
abe__become(v13, countdown_ring_0_beh, v5);
abe__send(a1, timing_actor, &nil__cons);
abe__send(a1, v5, v7);
}
else
{
v9 = abe__actor(a1, countdown_builder_beh, 4LL * ((int)v8 - 1) + 3);
v10 = car(*(_QWORD *)(a1 + 48));
abe__become(v10, countdown_ring_beh, v9);
v11 = cdr(*(_QWORD *)(a1 + 48));
abe__send(a1, v9, v11);
}
v16 = 117;
return dbug_return(&v14);
}

original_code:
void countdown_builder_beh (CONFIG* abe__config)
{
 CONS* n;
 CONS* first;
 CONS* m;
 int n_int;
 struct dbug_ctx_t dbug_ctx; dbug_ctx.name = ("countdown_builder_beh"); dbug_ctx.depth = dbug_cfg->ctx->depth; dbug_ctx.line = 96; dbug_ctx.keyword = ""; dbug_ctx.unit = &dbug_unit; dbug_ctx.caller = dbug_cfg->ctx; dbug_enter (&dbug_ctx);
 n = _mine(_car((abe__config)->q_entry));
 ((((BOOL)((((WORD)(n)) & ((WORD)(0x00000003))) == ((WORD)(0x00000003))))) ? (void) (0) : __assert_fail ("numberp(n)", "echallenge.c", 98, __extension__ __PRETTY_FUNCTION__));
 ((((BOOL)(((_cdr((abe__config)->q_entry))!=((BOOL)(0)))&&((((WORD)(_cdr((abe__config)->q_entry))) & ((WORD)(0x00000003))) == ((WORD)(0x00000000)))))) ? (void) (0) : __assert_fail ("consp(WHAT)", "echallenge.c", 99, __extension__ __PRETTY_FUNCTION__));
 first = _car(_cdr((abe__config)->q_entry));
 ((((BOOL)((((WORD)(first)) & ((WORD)(0x00000003))) == ((WORD)(0x00000001))))) ? (void) (0) : __assert_fail ("actorp(first)", "echallenge.c", 101, __extension__ __PRETTY_FUNCTION__));
 m = _cdr(_cdr((abe__config)->q_entry));
 ((((BOOL)((((WORD)(m)) & ((WORD)(0x00000003))) == ((WORD)(0x00000003))))) ? (void) (0) : __assert_fail ("numberp(m)", "echallenge.c", 103, __extension__ __PRETTY_FUNCTION__));
 n_int = ((int)(((WORD)(n))>>2));
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 105; dbug_print ("n=%d m=%d", n_int, ((int)(((WORD)(m))>>2))); }}while(0);
 if (n_int <= 0) {
  abe__become(_car((abe__config)->q_entry),(countdown_ring_0_beh),(first));
  abe__send((abe__config),(timing_actor),(((CONS*)(&nil__cons))));
  abe__send((abe__config),(first),(m));
 } else {
  CONS* next;
  next = abe__actor((abe__config),(countdown_builder_beh),(((CONS*)((((WORD)(n_int - 1))<<2) | ((WORD)(0x00000003))))));
  abe__become(_car((abe__config)->q_entry),(countdown_ring_beh),(next));
  abe__send((abe__config),(next),(_cdr((abe__config)->q_entry)));
 }
 dbug_ctx.line = 117; dbug_return (&dbug_ctx); return;
}

canonical_original_code:
void countdown_builder_beh(struct config *abe__config)
{
 struct cons *n;
 struct cons *first;
 struct cons *m;
 int n_int;
 struct dbug_ctx_t dbug_ctx; dbug_ctx.name = ("countdown_builder_beh"); dbug_ctx.depth = dbug_cfg->ctx->depth; dbug_ctx.line = 96; dbug_ctx.keyword = ""; dbug_ctx.unit = &dbug_unit; dbug_ctx.caller = dbug_cfg->ctx; dbug_enter (&dbug_ctx);
 n = _mine(_car((abe__config)->q_entry));
 ((((BOOL)((((WORD)(n)) & ((WORD)(0x00000003))) == ((WORD)(0x00000003))))) ? (void) (0) : __assert_fail ("numberp(n)", "echallenge.c", 98, __extension__ __PRETTY_FUNCTION__));
 ((((BOOL)(((_cdr((abe__config)->q_entry))!=((BOOL)(0)))&&((((WORD)(_cdr((abe__config)->q_entry))) & ((WORD)(0x00000003))) == ((WORD)(0x00000000)))))) ? (void) (0) : __assert_fail ("consp(WHAT)", "echallenge.c", 99, __extension__ __PRETTY_FUNCTION__));
 first = _car(_cdr((abe__config)->q_entry));
 ((((BOOL)((((WORD)(first)) & ((WORD)(0x00000003))) == ((WORD)(0x00000001))))) ? (void) (0) : __assert_fail ("actorp(first)", "echallenge.c", 101, __extension__ __PRETTY_FUNCTION__));
 m = _cdr(_cdr((abe__config)->q_entry));
 ((((BOOL)((((WORD)(m)) & ((WORD)(0x00000003))) == ((WORD)(0x00000003))))) ? (void) (0) : __assert_fail ("numberp(m)", "echallenge.c", 103, __extension__ __PRETTY_FUNCTION__));
 n_int = ((int)(((WORD)(n))>>2));
 do{ if(dbug_on && dbug_keyword (dbug_cfg->ctx->keyword = (""))){ dbug_cfg->ctx->line = 105; dbug_print ("n=%d m=%d", n_int, ((int)(((WORD)(m))>>2))); }}while(0);
 if (n_int <= 0) {
  abe__become(_car((abe__config)->q_entry),(countdown_ring_0_beh),(first));
  abe__send((abe__config),(timing_actor),(((struct cons *)(&nil__cons))));
  abe__send((abe__config),(first),(m));
 } else {
  struct cons *next;
  next = abe__actor((abe__config),(countdown_builder_beh),(((struct cons *)((((WORD)(n_int - 1))<<2) | ((WORD)(0x00000003))))));
  abe__become(_car((abe__config)->q_entry),(countdown_ring_beh),(next));
  abe__send((abe__config),(next),(_cdr((abe__config)->q_entry)));
 }
 dbug_ctx.line = 117; dbug_return (&dbug_ctx); return;
}


decompiled_code:
__int64 __fastcall ring_seed_beh(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rbx
__int64 v3; // rax
__int64 v4; // rbx
__int64 v5; // rbp
int v6; // edx
__int64 v7; // r13
__int64 v8; // rax
const char *v10; // [rsp+0h] [rbp-58h] BYREF
int v11; // [rsp+8h] [rbp-50h]
int v12; // [rsp+Ch] [rbp-4Ch]
void *v13; // [rsp+10h] [rbp-48h]
char **v14; // [rsp+18h] [rbp-40h]
__int64 v15; // [rsp+20h] [rbp-38h]

v1 = car(*(_QWORD *)(a1 + 48));
v2 = mine(v1);
v3 = cdr(*(_QWORD *)(a1 + 48));
v4 = v2 >> 2;
v10 = "ring_seed_beh";
v5 = v3;
v6 = *(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 8LL);
v15 = *(_QWORD *)(dbug_cfg + 80LL);
v12 = 150;
v11 = v6;
v13 = &unk_8F3;
v14 = dbug_unit;
dbug_enter(&v10);
if ( thresh_0 <= (int)v4 )
{
thresh_0 *= 2;
fprintf(stderr, "%d:", (unsigned int)v4);
abe__send(a1, timing_actor, &nil__cons);
}
v7 = abe__actor(a1, ring_seed_beh, 4LL * ((int)v4 + 1) + 3);
v8 = car(*(_QWORD *)(a1 + 48));
abe__become(v8, ring_link_beh, v7);
abe__send(a1, v5, v5);
v12 = 159;
return dbug_return(&v10);
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
__int64 v1; // rax
__int64 v2; // rbx
__int64 v3; // rax
__int64 v4; // rbx
__int64 v5; // rbp
int v6; // edx
__int64 v7; // r13
__int64 v8; // rax
const char *v10; // [rsp+0h] [rbp-58h] BYREF
int v11; // [rsp+8h] [rbp-50h]
int v12; // [rsp+Ch] [rbp-4Ch]
void *v13; // [rsp+10h] [rbp-48h]
char **v14; // [rsp+18h] [rbp-40h]
__int64 v15; // [rsp+20h] [rbp-38h]

v1 = car(*(_QWORD *)(a1 + 48));
v2 = mine(v1);
v3 = cdr(*(_QWORD *)(a1 + 48));
v4 = v2 >> 2;
v10 = "ring_seed_beh";
v5 = v3;
v6 = *(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 8LL);
v15 = *(_QWORD *)(dbug_cfg + 80LL);
v12 = 150;
v11 = v6;
v13 = &unk_8F3;
v14 = dbug_unit;
dbug_enter(&v10);
if ( thresh_0 <= (int)v4 )
{
thresh_0 *= 2;
fprintf(stderr, "%d:", (unsigned int)v4);
abe__send(a1, timing_actor, &nil__cons);
}
v7 = abe__actor(a1, ring_seed_beh, 4LL * ((int)v4 + 1) + 3);
v8 = car(*(_QWORD *)(a1 + 48));
abe__become(v8, ring_link_beh, v7);
abe__send(a1, v5, v5);
v12 = 159;
return dbug_return(&v10);
}

original_code:
void ring_seed_beh (CONFIG* abe__config)
{
 static int thresh = 1 << 10;
 CONS* n = _mine(_car((abe__config)->q_entry));
 CONS* first = _cdr((abe__config)->q_entry);
 CONS* next;
 int n_int = ((int)(((WORD)(n))>>2));
 struct dbug_ctx_t dbug_ctx; dbug_ctx.name = ("ring_seed_beh"); dbug_ctx.depth = dbug_cfg->ctx->depth; dbug_ctx.line = 150; dbug_ctx.keyword = ""; dbug_ctx.unit = &dbug_unit; dbug_ctx.caller = dbug_cfg->ctx; dbug_enter (&dbug_ctx);
 if (n_int >= thresh) {
  thresh <<= 1;
  fprintf(stderr, "%d:", n_int);
  abe__send((abe__config),(timing_actor),(((CONS*)(&nil__cons))));
 }
 next = abe__actor((abe__config),(ring_seed_beh),(((CONS*)((((WORD)(n_int + 1))<<2) | ((WORD)(0x00000003))))));
 abe__become(_car((abe__config)->q_entry),(ring_link_beh),(next));
 abe__send((abe__config),(first),(first));
 dbug_ctx.line = 159; dbug_return (&dbug_ctx); return;
}

canonical_original_code:
void ring_seed_beh(struct config *abe__config)
{
 static int thresh = 1 << 10;
 struct cons *n = _mine(_car((abe__config)->q_entry));
 struct cons *first = _cdr((abe__config)->q_entry);
 struct cons *next;
 int n_int = ((int)(((WORD)(n))>>2));
 struct dbug_ctx_t dbug_ctx; dbug_ctx.name = ("ring_seed_beh"); dbug_ctx.depth = dbug_cfg->ctx->depth; dbug_ctx.line = 150; dbug_ctx.keyword = ""; dbug_ctx.unit = &dbug_unit; dbug_ctx.caller = dbug_cfg->ctx; dbug_enter (&dbug_ctx);
 if (n_int >= thresh) {
  thresh <<= 1;
  fprintf(stderr, "%d:", n_int);
  abe__send((abe__config),(timing_actor),(((struct cons *)(&nil__cons))));
 }
 next = abe__actor((abe__config),(ring_seed_beh),(((struct cons *)((((WORD)(n_int + 1))<<2) | ((WORD)(0x00000003))))));
 abe__become(_car((abe__config)->q_entry),(ring_link_beh),(next));
 abe__send((abe__config),(first),(first));
 dbug_ctx.line = 159; dbug_return (&dbug_ctx); return;
}

variable_types: thresh int


decompiled_code:
__int64 __fastcall erlang_challenge(int a1, unsigned int a2)
{
int v2; // edx
__int64 v3; // r12
__int64 v4; // rbp
__int64 v5; // rax
unsigned int v6; // ebp
__int64 v8; // rax
const char *v9; // [rsp+0h] [rbp-48h] BYREF
int v10; // [rsp+8h] [rbp-40h]
int v11; // [rsp+Ch] [rbp-3Ch]
void *v12; // [rsp+10h] [rbp-38h]
char **v13; // [rsp+18h] [rbp-30h]
__int64 v14; // [rsp+20h] [rbp-28h]

v9 = "erlang_challenge";
v2 = *(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 8LL);
v14 = *(_QWORD *)(dbug_cfg + 80LL);
v11 = 177;
v10 = v2;
v12 = &unk_8F3;
v13 = dbug_unit;
dbug_enter(&v9);
v3 = new_configuration(10LL);
timing_actor = abe__actor(v3, timing_beh, &nil__cons);
if ( a1 <= 0 )
{
puts("Seeding unbounded growth message ring.");
v8 = abe__actor(v3, ring_seed_beh, 3LL);
abe__send(v3, v8, v8);
}
else
{
printf("Sending %d messages around a ring of %d processes.\n", a2, (unsigned int)a1);
v4 = abe__actor(v3, countdown_builder_beh, 4LL * a1 + 3);
v5 = cons(v4, 4LL * (int)a2 + 3);
abe__send(v3, v4, v5);
}
v6 = 1;
abe__send(v3, timing_actor, &nil__cons);
do
{
run_configuration(v3, 1000000LL);
fputc(46, stderr);
if ( *(int *)(v3 + 40) <= 0 )
break;
++v6;
}
while ( v6 != 1000000 );
printf("< %dM messages delivered.\n", v6);
report_actor_usage(v3);
v11 = 208;
return dbug_return(&v9);
}

canonical_decompiled_code:
__int64 __fastcall func6(int a1, unsigned int a2)
{
int v2; // edx
__int64 v3; // r12
__int64 v4; // rbp
__int64 v5; // rax
unsigned int v6; // ebp
__int64 v8; // rax
const char *v9; // [rsp+0h] [rbp-48h] BYREF
int v10; // [rsp+8h] [rbp-40h]
int v11; // [rsp+Ch] [rbp-3Ch]
void *v12; // [rsp+10h] [rbp-38h]
char **v13; // [rsp+18h] [rbp-30h]
__int64 v14; // [rsp+20h] [rbp-28h]

v9 = "erlang_challenge";
v2 = *(_DWORD *)(*(_QWORD *)(dbug_cfg + 80LL) + 8LL);
v14 = *(_QWORD *)(dbug_cfg + 80LL);
v11 = 177;
v10 = v2;
v12 = &unk_8F3;
v13 = dbug_unit;
dbug_enter(&v9);
v3 = new_configuration(10LL);
timing_actor = abe__actor(v3, timing_beh, &nil__cons);
if ( a1 <= 0 )
{
puts("Seeding unbounded growth message ring.");
v8 = abe__actor(v3, ring_seed_beh, 3LL);
abe__send(v3, v8, v8);
}
else
{
printf("Sending %d messages around a ring of %d processes.\n", a2, (unsigned int)a1);
v4 = abe__actor(v3, countdown_builder_beh, 4LL * a1 + 3);
v5 = cons(v4, 4LL * (int)a2 + 3);
abe__send(v3, v4, v5);
}
v6 = 1;
abe__send(v3, timing_actor, &nil__cons);
do
{
run_configuration(v3, 1000000LL);
fputc(46, stderr);
if ( *(int *)(v3 + 40) <= 0 )
break;
++v6;
}
while ( v6 != 1000000 );
printf("< %dM messages delivered.\n", v6);
report_actor_usage(v3);
v11 = 208;
return dbug_return(&v9);
}

original_code:
void
erlang_challenge(int n, int m)
{
 CONFIG* cfg;
 int cnt;
 struct dbug_ctx_t dbug_ctx; dbug_ctx.name = ("erlang_challenge"); dbug_ctx.depth = dbug_cfg->ctx->depth; dbug_ctx.line = 177; dbug_ctx.keyword = ""; dbug_ctx.unit = &dbug_unit; dbug_ctx.caller = dbug_cfg->ctx; dbug_enter (&dbug_ctx);
 cfg = new_configuration(10);
 timing_actor = abe__actor((cfg),(timing_beh),(((CONS*)(&nil__cons))));
 if (n <= 0) {
  CONS* ring;
  printf("Seeding unbounded growth message ring.\n");
  ring = abe__actor((cfg),(ring_seed_beh),(((CONS*)((((WORD)(0))<<2) | ((WORD)(0x00000003))))));
  abe__send((cfg),(ring),(ring));
 } else {
  CONS* countdown;
  printf("Sending %d messages around a ring of %d processes.\n", m, n);
  countdown = abe__actor((cfg),(countdown_builder_beh),(((CONS*)((((WORD)(n))<<2) | ((WORD)(0x00000003))))));
  abe__send((cfg),(countdown),(cons(countdown, ((CONS*)((((WORD)(m))<<2) | ((WORD)(0x00000003)))))));
 }
 abe__send((cfg),(timing_actor),(((CONS*)(&nil__cons))));
 for (cnt = 1; cnt < 1000000; ++cnt) {
  int max = 1000000;
  int rem;
  rem = run_configuration(cfg, max);
  fputc('.', stderr);
  if (cfg->q_count <= 0) {
   break;
  }
 }
 printf("< %dM messages delivered.\n", cnt);
 report_actor_usage(cfg);
 dbug_ctx.line = 208; dbug_return (&dbug_ctx); return;
}

canonical_original_code:
void erlang_challenge(int n, int m)
{
 struct config *cfg;
 int cnt;
 struct dbug_ctx_t dbug_ctx; dbug_ctx.name = ("erlang_challenge"); dbug_ctx.depth = dbug_cfg->ctx->depth; dbug_ctx.line = 177; dbug_ctx.keyword = ""; dbug_ctx.unit = &dbug_unit; dbug_ctx.caller = dbug_cfg->ctx; dbug_enter (&dbug_ctx);
 cfg = new_configuration(10);
 timing_actor = abe__actor((cfg),(timing_beh),(((struct cons *)(&nil__cons))));
 if (n <= 0) {
  struct cons *ring;
  printf("Seeding unbounded growth message ring.\n");
  ring = abe__actor((cfg),(ring_seed_beh),(((struct cons *)((((WORD)(0))<<2) | ((WORD)(0x00000003))))));
  abe__send((cfg),(ring),(ring));
 } else {
  struct cons *countdown;
  printf("Sending %d messages around a ring of %d processes.\n", m, n);
  countdown = abe__actor((cfg),(countdown_builder_beh),(((struct cons *)((((WORD)(n))<<2) | ((WORD)(0x00000003))))));
  abe__send((cfg),(countdown),(cons(countdown, ((struct cons *)((((WORD)(m))<<2) | ((WORD)(0x00000003)))))));
 }
 abe__send((cfg),(timing_actor),(((struct cons *)(&nil__cons))));
 for (cnt = 1; cnt < 1000000; ++cnt) {
  int max = 1000000;
  int rem;
  rem = run_configuration(cfg, max);
  fputc('.', stderr);
  if (cfg->q_count <= 0) {
   break;
  }
 }
 printf("< %dM messages delivered.\n", cnt);
 report_actor_usage(cfg);
 dbug_ctx.line = 208; dbug_return (&dbug_ctx); return;
}

variable_types: n int

variable_types: m int

variable_types: cnt int

variable_types: max int

variable_types: rem int


banner

decompiled_code:
int banner()
{
return printf("%s v%s -- %s\n", Program, Version, Copyright);
}

canonical_decompiled_code:
int func9()
{
return printf("%s v%s -- %s\n", Program, Version, Copyright);
}

original_code:
void
banner(void)
{
 printf("%s v%s -- %s\n", _Program, _Version, _Copyright);
}

canonical_original_code:
void banner()
{
 printf("%s v%s -- %s\n", _Program, _Version, _Copyright);
}


decompiled_code:
_BOOL8 __fastcall match_set(char *s1, char *s2)
{
char *v2; // r14
unsigned __int64 v3; // rbp
int v4; // er15
char *v5; // rbx
__int64 v6; // r13
int v7; // eax
int v9; // [rsp+Ch] [rbp-3Ch]

if ( !s1 )
return 1LL;
v2 = s1;
v3 = (unsigned __int8)*s1;
if ( (_BYTE)v3 == 58 || !(_BYTE)v3 )
return 1LL;
if ( !s2 )
return 0LL;
v9 = 1;
v4 = strlen(s2);
if ( (_BYTE)v3 == 94 )
{
v9 = 0;
v3 = (unsigned __int8)s1[1];
v2 = s1 + 1;
}
v5 = v2 + 1;
v6 = 0x400100000000001LL;
while ( (unsigned __int8)v3 > 0x3Au || !_bittest64(&v6, v3) )
LABEL_11:
v3 = (unsigned __int8)*v5++;
if ( v4 == (_DWORD)v5 - 1 - (_DWORD)v2 && !strncmp(v2, s2, v4) )
{
v7 = 1;
return v9 == v7;
}
if ( (_BYTE)v3 != 58 && (_BYTE)v3 )
{
v2 = v5;
goto LABEL_11;
}
v7 = 0;
return v9 == v7;
}

canonical_decompiled_code:
_BOOL8 __fastcall func0(char *s1, char *s2)
{
char *v2; // r14
unsigned __int64 v3; // rbp
int v4; // er15
char *v5; // rbx
__int64 v6; // r13
int v7; // eax
int v9; // [rsp+Ch] [rbp-3Ch]

if ( !s1 )
return 1LL;
v2 = s1;
v3 = (unsigned __int8)*s1;
if ( (_BYTE)v3 == 58 || !(_BYTE)v3 )
return 1LL;
if ( !s2 )
return 0LL;
v9 = 1;
v4 = strlen(s2);
if ( (_BYTE)v3 == 94 )
{
v9 = 0;
v3 = (unsigned __int8)s1[1];
v2 = s1 + 1;
}
v5 = v2 + 1;
v6 = 0x400100000000001LL;
while ( (unsigned __int8)v3 > 0x3Au || !_bittest64(&v6, v3) )
LABEL_11:
v3 = (unsigned __int8)*v5++;
if ( v4 == (_DWORD)v5 - 1 - (_DWORD)v2 && !strncmp(v2, s2, v4) )
{
v7 = 1;
return v9 == v7;
}
if ( (_BYTE)v3 != 58 && (_BYTE)v3 )
{
v2 = v5;
goto LABEL_11;
}
v7 = 0;
return v9 == v7;
}

original_code:
static int
match_set(char *set, char *key)
{
 int sense = 1;
 int match = 1;
 int klen;
 int len;
 char *p;
 if ((set == ((void *)0)) || (*set == '\0') || (*set == ':')) {
  return 1;
 }
 if (key == ((void *)0)) {
  return 0;
 }
 match = 0;
 klen = strlen(key);
 if (*set == '^') {
  sense = !sense;
  ++set;
 }
 p = set;
 for (;;) {
  while ((*p != ',') && (*p != ':') && (*p != '\0')) {
   ++p;
  }
  len = (int) (p - set);
  if ((len == klen) && (strncmp(set, key, klen) == 0)) {
   match = 1;
   break;
  }
  if ((*p == ':') || (*p == '\0')) {
   break;
  }
  set = ++p;
 }
 return (match == sense);
}

variable_types:
set
char *

variable_types:
key
char *

variable_types: sense int

variable_types: match int

variable_types: klen int

variable_types: len int

variable_types:
p
char *