decompiled_code:
__int64 __fastcall DS18X20_scratchpad_to_eeprom(__int64 a1, __int64 a2)
{
ow_reset();
ow_command(72LL, a2);
delay_ms(10LL);
return 0LL;
}

canonical_decompiled_code:
__int64 __fastcall func14(__int64 a1, __int64 a2)
{
ow_reset();
ow_command(72LL, a2);
delay_ms(10LL);
return 0LL;
}

original_code:
uint8_t DS18X20_scratchpad_to_eeprom(uint8_t with_power_extern, uint8_t id[]) {
  ow_reset();
  ow_command(0x48, id);
  delay_ms(10);
  return 0x00;
}

canonical_original_code:
unsigned char DS18X20_scratchpad_to_eeprom(unsigned char with_power_extern, unsigned char id[]) {
  ow_reset();
  ow_command(0x48, id);
  delay_ms(10);
  return 0x00;
}


decompiled_code:
bool __fastcall DS18X20_eeprom_to_scratchpad(__int64 a1)
{
char i; // bl

ow_reset();
ow_command(184LL, a1);
for ( i = -2; i != -1; --i )
{
if ( (unsigned __int8)ow_bit(1LL) )
break;
}
return i == 0;
}

canonical_decompiled_code:
bool __fastcall func15(__int64 a1)
{
char i; // bl

ow_reset();
ow_command(184LL, a1);
for ( i = -2; i != -1; --i )
{
if ( (unsigned __int8)ow_bit(1LL) )
break;
}
return i == 0;
}

original_code:
uint8_t DS18X20_eeprom_to_scratchpad(uint8_t id[]) {
  uint8_t ret;
  uint8_t retry_count = 255;
  ow_reset();
  ow_command(0xB8, id);
  while(retry_count-- && !(ow_bit(1)));
  if(retry_count) ret = 0x00;
  else ret = 0x01;
  return ret;
}

canonical_original_code:
unsigned char DS18X20_eeprom_to_scratchpad(unsigned char id[]) {
  unsigned char ret;
  unsigned char retry_count = 255;
  ow_reset();
  ow_command(0xB8, id);
  while(retry_count-- && !(ow_bit(1)));
  if(retry_count) ret = 0x00;
  else ret = 0x01;
  return ret;
}

variable_types:
id
unsigned char []

variable_types:
ret
unsigned char

return_type: unsigned char


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

result = "DS1822";
if ( a1 != 34 )
{
result = "DS18B20";
if ( a1 != 40 )
{
result = "WTF?!";
if ( a1 == 16 )
result = "DS18S20";
}
}
return result;
}

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

result = "DS1822";
if ( a1 != 34 )
{
result = "DS18B20";
if ( a1 != 40 )
{
result = "WTF?!";
if ( a1 == 16 )
result = "DS18S20";
}
}
return result;
}

original_code:
char *get_type_by_id(uint8_t id) {
  switch (id) {
    case 0x10: return "DS18S20";
    case 0x28: return "DS18B20";
    case 0x22 : return "DS1822";
    default: return "WTF?!";
  }
}

canonical_original_code:
char *get_type_by_id(unsigned char id) {
  switch (id) {
    case 0x10: return "DS18S20";
    case 0x28: return "DS18B20";
    case 0x22 : return "DS1822";
    default: return "WTF?!";
  }
}

variable_types:
id
unsigned char

return_type: char *


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax
int v4; // ebx
unsigned int v5; // ebp
const char *v6; // rax
__int64 v7; // rcx
__int16 v8; // [rsp+Ch] [rbp-1Ch] BYREF
char v9[25]; // [rsp+Fh] [rbp-19h] BYREF

if ( argc == 2 )
{
v4 = ow_init(argv[1]);
if ( (_BYTE)v4 )
{
puts("Bus INIT failed. Check COM port.\n");
result = 1;
}
else
{
v9[0] = -1;
do
{
DS18X20_find_sensor(v9, &id);
if ( v9[0] == -1 )
{
puts("All sensors are offline now.\n");
ow_finit();
return 1;
}
if ( v9[0] == -2 )
{
puts("Bus error.\n");
ow_finit();
return 1;
}
v5 = (unsigned __int8)id;
v6 = get_type_by_id(id);
fprintf(
stdout,
"Bus %s Device %03u Type 0x%02hx (%s) ID %02hx%02hx%02hx%02hx%02hx%02hx CRC 0x%02hx ",
argv[1],
(unsigned __int8)v4,
v5,
v6,
(unsigned __int8)*(&id + 6),
(unsigned __int8)*(&id + 5),
(unsigned __int8)*(&id + 4),
(unsigned __int8)*(&id + 3),
(unsigned __int8)*(&id + 2),
(unsigned __int8)*(&id + 1),
(unsigned __int8)*(&id + 7));
fflush(stdout);
++v4;
if ( (unsigned __int8)DS18X20_start_meas(1LL, 0LL) )
goto LABEL_11;
while ( (unsigned __int8)DS18X20_conversion_in_progress() == 1 )
delay_ms(100LL);
if ( (unsigned __int8)DS18X20_read_decicelsius(&id, &v8) )
{
LABEL_11:
puts("MEASURE FAILED!\n");
}
else
{
if ( v8 <= 0 )
v7 = (unsigned int)(-v8 % 10);
else
v7 = (unsigned int)(v8 % 10);
fprintf(stdout, "TEMP %3d.%01d C\n", (unsigned int)(v8 / 10), v7);
}
}
while ( v9[0] );
puts("Sensors listed.\n");
ow_finit();
result = 0;
}
}
else
{
puts("Path to COM port required.\n");
result = 1;
}
return result;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int result; // eax
int v4; // ebx
unsigned int v5; // ebp
const char *v6; // rax
__int64 v7; // rcx
__int16 v8; // [rsp+Ch] [rbp-1Ch] BYREF
char v9[25]; // [rsp+Fh] [rbp-19h] BYREF

if ( argc == 2 )
{
v4 = ow_init(argv[1]);
if ( (_BYTE)v4 )
{
puts("Bus INIT failed. Check COM port.\n");
result = 1;
}
else
{
v9[0] = -1;
do
{
DS18X20_find_sensor(v9, &id);
if ( v9[0] == -1 )
{
puts("All sensors are offline now.\n");
ow_finit();
return 1;
}
if ( v9[0] == -2 )
{
puts("Bus error.\n");
ow_finit();
return 1;
}
v5 = (unsigned __int8)id;
v6 = func0(id);
fprintf(
stdout,
"Bus %s Device %03u Type 0x%02hx (%s) ID %02hx%02hx%02hx%02hx%02hx%02hx CRC 0x%02hx ",
argv[1],
(unsigned __int8)v4,
v5,
v6,
(unsigned __int8)*(&id + 6),
(unsigned __int8)*(&id + 5),
(unsigned __int8)*(&id + 4),
(unsigned __int8)*(&id + 3),
(unsigned __int8)*(&id + 2),
(unsigned __int8)*(&id + 1),
(unsigned __int8)*(&id + 7));
fflush(stdout);
++v4;
if ( (unsigned __int8)DS18X20_start_meas(1LL, 0LL) )
goto LABEL_11;
while ( (unsigned __int8)DS18X20_conversion_in_progress() == 1 )
delay_ms(100LL);
if ( (unsigned __int8)DS18X20_read_decicelsius(&id, &v8) )
{
LABEL_11:
puts("MEASURE FAILED!\n");
}
else
{
if ( v8 <= 0 )
v7 = (unsigned int)(-v8 % 10);
else
v7 = (unsigned int)(v8 % 10);
fprintf(stdout, "TEMP %3d.%01d C\n", (unsigned int)(v8 / 10), v7);
}
}
while ( v9[0] );
puts("Sensors listed.\n");
ow_finit();
result = 0;
}
}
else
{
puts("Path to COM port required.\n");
result = 1;
}
return result;
}

original_code:
int main(int argc, char *argv[]) {
  if (argc != 2) {
    puts("Path to COM port required.\n");
    return 1;
  }
  if (ow_init(argv[1])) {
    puts("Bus INIT failed. Check COM port.\n");
    return 1;
  }
  uint8_t c = 0, diff = 0xFF;
  int16_t temp_dc;
  while (diff != 0x00) {
    DS18X20_find_sensor(&diff, id);
    if (diff == 0xFF) {
      puts("All sensors are offline now.\n");
      ow_finit();
      return 1;
    }
    if (diff == 0xFE) {
      puts("Bus error.\n");
      ow_finit();
      return 1;
    }
    fprintf(stdout, "Bus %s Device %03u Type 0x%02hx (%s) ID %02hx%02hx%02hx%02hx%02hx%02hx CRC 0x%02hx ", argv[1], c, id[0], get_type_by_id(id[0]), id[6], id[5], id[4], id[3], id[2], id[1], id[7]);
    fflush(stdout);
    c ++;
    if (DS18X20_start_meas(0x01, ((void *)0)) == 0x00) {
      while (DS18X20_conversion_in_progress() == 0x01) {
        delay_ms(100);
      }
      if (DS18X20_read_decicelsius(id, &temp_dc) == 0x00) {
        fprintf(stdout, "TEMP %3d.%01d C\n", temp_dc / 10, temp_dc > 0 ? temp_dc % 10 : -temp_dc % 10);
        continue;
      }
    }
    puts("MEASURE FAILED!\n");
  }
  puts("Sensors listed.\n");
  ow_finit();
  return 0;
}

canonical_original_code:
int main(int argc, char *argv[]) {
  if (argc != 2) {
    puts("Path to COM port required.\n");
    return 1;
  }
  if (ow_init(argv[1])) {
    puts("Bus INIT failed. Check COM port.\n");
    return 1;
  }
  unsigned char c = 0; unsigned char diff = 0xFF;
  short temp_dc;
  while (diff != 0x00) {
    DS18X20_find_sensor(&diff, id);
    if (diff == 0xFF) {
      puts("All sensors are offline now.\n");
      ow_finit();
      return 1;
    }
    if (diff == 0xFE) {
      puts("Bus error.\n");
      ow_finit();
      return 1;
    }
    fprintf(stdout, "Bus %s Device %03u Type 0x%02hx (%s) ID %02hx%02hx%02hx%02hx%02hx%02hx CRC 0x%02hx ", argv[1], c, id[0], get_type_by_id(id[0]), id[6], id[5], id[4], id[3], id[2], id[1], id[7]);
    fflush(stdout);
    c ++;
    if (DS18X20_start_meas(0x01, ((void *)0)) == 0x00) {
      while (DS18X20_conversion_in_progress() == 0x01) {
        delay_ms(100);
      }
      if (DS18X20_read_decicelsius(id, &temp_dc) == 0x00) {
        fprintf(stdout, "TEMP %3d.%01d C\n", temp_dc / 10, temp_dc > 0 ? temp_dc % 10 : -temp_dc % 10);
        continue;
      }
    }
    puts("MEASURE FAILED!\n");
  }
  puts("Sensors listed.\n");
  ow_finit();
  return 0;
}

variable_types: argc int

variable_types:
argv
char *[]

variable_types:
c
unsigned char

variable_types:
diff
unsigned char

return_type: int


decompiled_code:
char __fastcall crc8(unsigned __int8 *a1, __int16 a2)
{
unsigned __int8 *v2; // r8
__int64 v3; // r9
unsigned int v4; // eax
unsigned __int8 v5; // si
char v6; // cl
char v7; // di
unsigned int v8; // edx
unsigned int v9; // edx

if ( a2 )
{
v2 = a1;
v3 = (__int64)&a1[(unsigned __int16)(a2 - 1) + 1];
v4 = 0;
do
{
v5 = *v2;
v6 = 8;
do
{
v7 = v5 ^ v4;
v8 = v4;
LOBYTE(v8) = (unsigned __int8)v4 >> 1;
v9 = v8 ^ 0xFFFFFF8C;
LOBYTE(v4) = (unsigned __int8)v4 >> 1;
if ( (v7 & 1) != 0 )
v4 = v9;
v5 >>= 1;
--v6;
}
while ( v6 );
++v2;
}
while ( v2 != (unsigned __int8 *)v3 );
}
else
{
LOBYTE(v4) = 0;
}
return v4;
}

canonical_decompiled_code:
char __fastcall func0(unsigned __int8 *a1, __int16 a2)
{
unsigned __int8 *v2; // r8
__int64 v3; // r9
unsigned int v4; // eax
unsigned __int8 v5; // si
char v6; // cl
char v7; // di
unsigned int v8; // edx
unsigned int v9; // edx

if ( a2 )
{
v2 = a1;
v3 = (__int64)&a1[(unsigned __int16)(a2 - 1) + 1];
v4 = 0;
do
{
v5 = *v2;
v6 = 8;
do
{
v7 = v5 ^ v4;
v8 = v4;
LOBYTE(v8) = (unsigned __int8)v4 >> 1;
v9 = v8 ^ 0xFFFFFF8C;
LOBYTE(v4) = (unsigned __int8)v4 >> 1;
if ( (v7 & 1) != 0 )
v4 = v9;
v5 >>= 1;
--v6;
}
while ( v6 );
++v2;
}
while ( v2 != (unsigned __int8 *)v3 );
}
else
{
LOBYTE(v4) = 0;
}
return v4;
}

original_code:
uint8_t crc8(uint8_t *data_in, uint16_t number_of_bytes_to_read) {
  uint8_t crc = 0x00;
  uint16_t loop_count;
  uint8_t bit_counter;
  uint8_t data;
  uint8_t feedback_bit;
  for(loop_count = 0; loop_count != number_of_bytes_to_read; loop_count++) {
    data = data_in[loop_count];
    bit_counter = 8;
    do {
      feedback_bit = (crc ^ data) & 0x01;
      if ( feedback_bit == 0x01 ) crc = crc ^ 0x18;
      crc = (crc >> 1) & 0x7F;
      if ( feedback_bit == 0x01 ) crc = crc | 0x80;
      data = data >> 1;
      bit_counter--;
    } while(bit_counter > 0);
  }
  return crc;
}

canonical_original_code:
unsigned char crc8(unsigned char *data_in, unsigned short number_of_bytes_to_read) {
  unsigned char crc = 0x00;
  unsigned short loop_count;
  unsigned char bit_counter;
  unsigned char data;
  unsigned char feedback_bit;
  for(loop_count = 0; loop_count != number_of_bytes_to_read; loop_count++) {
    data = data_in[loop_count];
    bit_counter = 8;
    do {
      feedback_bit = (crc ^ data) & 0x01;
      if ( feedback_bit == 0x01 ) crc = crc ^ 0x18;
      crc = (crc >> 1) & 0x7F;
      if ( feedback_bit == 0x01 ) crc = crc | 0x80;
      data = data >> 1;
      bit_counter--;
    } while(bit_counter > 0);
  }
  return crc;
}

variable_types:
crc
unsigned char

variable_types:
data
unsigned char


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

v2.tv_sec = a1 / 0x3E8;
v2.tv_nsec = 1000000 * (a1 % 0x3E8);
return nanosleep(&v2, 0LL);
}

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

v2.tv_sec = a1 / 0x3E8;
v2.tv_nsec = 1000000 * (a1 % 0x3E8);
return nanosleep(&v2, 0LL);
}

original_code:
void delay_ms(uint32_t ms) {
  struct timespec tv = {
    .tv_sec = ms / 1000,
    .tv_nsec = (ms % 1000) * 1000000,
  };
  nanosleep(&tv, ((void *)0));
}

canonical_original_code:
void delay_ms(unsigned int ms) {
  struct timespec tv = {
    .tv_sec = ms / 1000,
    .tv_nsec = (ms % 1000) * 1000000,
  };
  nanosleep(&tv, ((void *)0));
}

variable_types:
ms
unsigned int

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

return_type: void


decompiled_code:
int __fastcall uart_init(const char *a1)
{
int result; // eax

result = open(a1, 2306);
fd = result;
if ( result > 0 )
result = 0;
return result;
}

canonical_decompiled_code:
int __fastcall func0(const char *a1)
{
int result; // eax

result = open(a1, 2306);
fd = result;
if ( result > 0 )
result = 0;
return result;
}

original_code:
int uart_init(char *dev_path) {
  fd = open(dev_path, 02 | 0400 | 04000);
  if(fd < 0) return fd;
  return 0;
}


decompiled_code:
int uart_finit()
{
int result; // eax

if ( fd >= 0 )
result = close(fd);
return result;
}

canonical_decompiled_code:
int func1()
{
int result; // eax

if ( fd >= 0 )
result = close(fd);
return result;
}

original_code:
void uart_finit(void) {
  if(fd < 0) return;
  close(fd);
}

canonical_original_code:
void uart_finit() {
  if(fd < 0) return;
  close(fd);
}


decompiled_code:
int __fastcall uart_setb(unsigned int a1)
{
int result; // eax
struct termios v2; // [rsp+0h] [rbp-48h] BYREF

if ( fd >= 0 )
{
if ( a1 == 38400 )
{
tio_buad_2 = 15;
goto LABEL_11;
}
if ( a1 <= 0x9600 )
{
if ( a1 == 9600 )
{
tio_buad_2 = 13;
goto LABEL_11;
}
if ( a1 == 19200 )
{
tio_buad_2 = 14;
goto LABEL_11;
}
}
else
{
if ( a1 == 57600 )
{
tio_buad_2 = 4097;
goto LABEL_11;
}
if ( a1 == 115200 )
{
tio_buad_2 = 4098;
LABEL_11:
*(_QWORD *)&v2.c_iflag = 0LL;
*(_QWORD *)&v2.c_line = 0LL;
*(_QWORD *)&v2.c_cc[7] = 0LL;
*(_QWORD *)&v2.c_cc[15] = 0LL;
*(_QWORD *)&v2.c_cc[23] = 0LL;
*(_QWORD *)&v2.c_cc[31] = 0LL;
v2.c_ospeed = 0;
v2.c_cflag = tio_buad_2 | 0x8B0;
v2.c_lflag = 128;
tcflush(fd, 0);
return tcsetattr(fd, 0, &v2);
}
}
tio_buad_2 = 13;
goto LABEL_11;
}
return result;
}

canonical_decompiled_code:
int __fastcall func2(unsigned int a1)
{
int result; // eax
struct termios v2; // [rsp+0h] [rbp-48h] BYREF

if ( fd >= 0 )
{
if ( a1 == 38400 )
{
tio_buad_2 = 15;
goto LABEL_11;
}
if ( a1 <= 0x9600 )
{
if ( a1 == 9600 )
{
tio_buad_2 = 13;
goto LABEL_11;
}
if ( a1 == 19200 )
{
tio_buad_2 = 14;
goto LABEL_11;
}
}
else
{
if ( a1 == 57600 )
{
tio_buad_2 = 4097;
goto LABEL_11;
}
if ( a1 == 115200 )
{
tio_buad_2 = 4098;
LABEL_11:
*(_QWORD *)&v2.c_iflag = 0LL;
*(_QWORD *)&v2.c_line = 0LL;
*(_QWORD *)&v2.c_cc[7] = 0LL;
*(_QWORD *)&v2.c_cc[15] = 0LL;
*(_QWORD *)&v2.c_cc[23] = 0LL;
*(_QWORD *)&v2.c_cc[31] = 0LL;
v2.c_ospeed = 0;
v2.c_cflag = tio_buad_2 | 0x8B0;
v2.c_lflag = 128;
tcflush(fd, 0);
return tcsetattr(fd, 0, &v2);
}
}
tio_buad_2 = 13;
goto LABEL_11;
}
return result;
}

original_code:
void uart_setb(uint32_t baud) {
  if(fd < 0) return;
  static int tio_buad;
  switch(baud) {
    case 9600:
      tio_buad = 0000015;
      break;
    case 19200:
      tio_buad = 0000016;
      break;
    case 38400:
      tio_buad = 0000017;
      break;
    case 57600:
      tio_buad = 0010001;
      break;
    case 115200:
      tio_buad = 0010002;
      break;
    default:
      tio_buad = 0000015;
  }
  struct termios tio = {
    .c_cflag = tio_buad | 0000060 | 0004000 | 0000200,
    .c_iflag = 0,
    .c_oflag = 0,
    .c_lflag = 0000200,
    .c_cc = {0},
  };
  tcflush(fd, 0);
  tcsetattr(fd, 0, &tio);
}

canonical_original_code:
void uart_setb(unsigned int baud) {
  if(fd < 0) return;
  static int tio_buad;
  switch(baud) {
    case 9600:
      tio_buad = 0000015;
      break;
    case 19200:
      tio_buad = 0000016;
      break;
    case 38400:
      tio_buad = 0000017;
      break;
    case 57600:
      tio_buad = 0010001;
      break;
    case 115200:
      tio_buad = 0010002;
      break;
    default:
      tio_buad = 0000015;
  }
  struct termios tio = {
    .c_cflag = tio_buad | 0000060 | 0004000 | 0000200,
    .c_iflag = 0,
    .c_oflag = 0,
    .c_lflag = 0000200,
    .c_cc = {0},
  };
  tcflush(fd, 0);
  tcsetattr(fd, 0, &tio);
}

variable_types:
baud
unsigned int

variable_types: struct termios { unsigned int c_iflag; unsigned int c_oflag; unsigned int c_cflag; unsigned int c_lflag; unsigned char c_line; unsigned char c_cc[32]; unsigned int c_ispeed; unsigned int c_ospeed; }


decompiled_code:
void __fastcall uart_putc(char a1)
{
char buf[12]; // [rsp+Ch] [rbp-Ch] BYREF

buf[0] = a1;
if ( fd >= 0 && write(fd, buf, 1uLL) != 1 )
_assert_fail("ret == 1", "uart_posix.c", 0x60u, "uart_putc");
}

canonical_decompiled_code:
void __fastcall func3(char a1)
{
char buf[12]; // [rsp+Ch] [rbp-Ch] BYREF

buf[0] = a1;
if ( fd >= 0 && write(fd, buf, 1uLL) != 1 )
_assert_fail("ret == 1", "uart_posix.c", 0x60u, "uart_putc");
}

original_code:
void uart_putc(unsigned char c) {
  ssize_t ret;
  if(fd < 0) return;
  ret = write(fd, &c, 1);
  ((void) sizeof ((ret == 1) ? 1 : 0), __extension__ ({ if (ret == 1) ; else __assert_fail ("ret == 1", "uart_posix.c", 96, __extension__ __PRETTY_FUNCTION__); }));
}

canonical_original_code:
void uart_putc(unsigned char c) {
  long ret;
  if(fd < 0) return;
  ret = write(fd, &c, 1);
  ((void) sizeof ((ret == 1) ? 1 : 0), __extension__ ({ if (ret == 1) ; else __assert_fail ("ret == 1", "uart_posix.c", 96, __extension__ __PRETTY_FUNCTION__); }));
}

variable_types: ret long


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

result = 0LL;
if ( fd >= 0 )
{
while ( !read(fd, &c_0, 1uLL) )
;
result = (unsigned __int8)c_0;
}
return result;
}

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

result = 0LL;
if ( fd >= 0 )
{
while ( !read(fd, &c_0, 1uLL) )
;
result = (unsigned __int8)c_0;
}
return result;
}

original_code:
unsigned char uart_getc(void) {
  if(fd < 0) return 0x00;
  static unsigned char c = 0x00;
  while(!read(fd, &c, 1));
  return c;
}

canonical_original_code:
unsigned char uart_getc() {
  if(fd < 0) return 0x00;
  static unsigned char c = 0x00;
  while(!read(fd, &c, 1));
  return c;
}


repo: dwyer/li

decompiled_code:
void *__fastcall li_allocate(void *ptr, size_t nmemb, size_t size)
{
void *v3; // rbx

if ( ptr )
v3 = realloc(ptr, nmemb * size);
else
v3 = calloc(nmemb, size);
if ( !v3 )
li_error_fmt("out of memory");
return v3;
}

canonical_decompiled_code:
void *__fastcall func1(void *ptr, size_t nmemb, size_t size)
{
void *v3; // rbx

if ( ptr )
v3 = realloc(ptr, nmemb * size);
else
v3 = calloc(nmemb, size);
if ( !v3 )
li_error_fmt("out of memory");
return v3;
}

original_code:
extern void *li_allocate(void *ptr, size_t count, size_t size)
{
    if (ptr)
        ptr = realloc(ptr, count*size);
    else
        ptr = calloc(count, size);
    if (!ptr)
        li_error_fmt("out of memory");
    return ptr;
}

canonical_original_code:
extern void *li_allocate(void *ptr, unsigned long count, unsigned long size)
{
    if (ptr)
        ptr = realloc(ptr, count*size);
    else
        ptr = calloc(count, size);
    if (!ptr)
        li_error_fmt("out of memory");
    return ptr;
}

variable_types:
ptr
void *

variable_types:
count
unsigned long

variable_types:
size
unsigned long

return_type: void *


decompiled_code:
__int64 __fastcall li_nat_read(__int64 *a1, const char *a2)
{
char v2; // bl
const unsigned __int16 *v3; // rax
__int64 v4; // rbp

v2 = *a2;
if ( !*a2 )
return 0LL;
v3 = *_ctype_b_loc();
v4 = 0LL;
do
{
if ( (v3[v2] & 0x800) == 0 )
break;
v2 = a2[++v4];
}
while ( v2 );
if ( v4 )
*a1 = atol(a2);
return v4;
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 *a1, const char *a2)
{
char v2; // bl
const unsigned __int16 *v3; // rax
__int64 v4; // rbp

v2 = *a2;
if ( !*a2 )
return 0LL;
v3 = *_ctype_b_loc();
v4 = 0LL;
do
{
if ( (v3[v2] & 0x800) == 0 )
break;
v2 = a2[++v4];
}
while ( v2 );
if ( v4 )
*a1 = atol(a2);
return v4;
}

original_code:
extern size_t li_nat_read(li_nat_t *dst, const char *s)
{
    size_t n;
    for (n = 0; s[n] && ((*__ctype_b_loc ())[(int) ((s[n]))] & (unsigned short int) _ISdigit); ++n)
        ;
    if (n)
        dst->data = atol(s);
    return n;
}

canonical_original_code:
extern unsigned long li_nat_read(struct li_nat_t *dst, char *s)
{
    unsigned long n;
    for (n = 0; s[n] && ((*__ctype_b_loc ())[(int) ((s[n]))] & (unsigned short) _ISdigit); ++n)
        ;
    if (n)
        dst->data = atol(s);
    return n;
}

variable_types: struct li_nat_t { unsigned long data; } *

variable_types:
s
char *

variable_types:
n
unsigned long

return_type: unsigned long


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

if ( !li_nat_read(&v2, a1) )
_assert_fail("li_nat_read(&x, s)", "src/nat.c", 0x14u, "li_nat_parse");
return v2;
}

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

if ( !func0(&v2, a1) )
_assert_fail("li_nat_read(&x, s)", "src/nat.c", 0x14u, "li_nat_parse");
return v2;
}

original_code:
extern li_nat_t li_nat_parse(const char *s)
{
    li_nat_t x;
    ((li_nat_read(&x, s)) ? (void) (0) : __assert_fail ("li_nat_read(&x, s)", "src/nat.c", 20, __extension__ __PRETTY_FUNCTION__));
    return x;
}

canonical_original_code:
extern struct li_nat_t li_nat_parse(char *s)
{
    struct li_nat_t x;
    ((li_nat_read(&x, s)) ? (void) (0) : __assert_fail ("li_nat_read(&x, s)", "src/nat.c", 20, __extension__ __PRETTY_FUNCTION__));
    return x;
}

variable_types:
x
struct li_nat_t { unsigned long data; }

return_type: struct li_nat_t { unsigned long data; }


decompiled_code:
unsigned __int64 __fastcall li_nat_with_int(__int64 a1)
{
return abs64(a1);
}

canonical_decompiled_code:
unsigned __int64 __fastcall func2(__int64 a1)
{
return abs64(a1);
}

original_code:
extern li_nat_t li_nat_with_int(li_int_t x)
{
    li_nat_t z;
    z.data = labs(x);
    return z;
}

canonical_original_code:
extern struct li_nat_t li_nat_with_int(long x)
{
    struct li_nat_t z;
    z.data = labs(x);
    return z;
}

variable_types: x long

variable_types:
z
struct li_nat_t { unsigned long data; }


decompiled_code:
double __fastcall li_nat_to_dec(__int64 a1)
{
double result; // xmm0_8

if ( a1 < 0 )
result = (double)(int)(a1 & 1 | ((unsigned __int64)a1 >> 1)) + (double)(int)(a1 & 1 | ((unsigned __int64)a1 >> 1));
else
result = (double)(int)a1;
return result;
}

canonical_decompiled_code:
double __fastcall func3(__int64 a1)
{
double result; // xmm0_8

if ( a1 < 0 )
result = (double)(int)(a1 & 1 | ((unsigned __int64)a1 >> 1)) + (double)(int)(a1 & 1 | ((unsigned __int64)a1 >> 1));
else
result = (double)(int)a1;
return result;
}

original_code:
extern li_dec_t li_nat_to_dec(li_nat_t x)
{
    return (li_dec_t)x.data;
}

canonical_original_code:
extern double li_nat_to_dec(struct li_nat_t x)
{
    return (double)x.data;
}

return_type: double


decompiled_code:
__int64 __fastcall li_nat_to_int(__int64 a1)
{
return a1;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1)
{
return a1;
}

original_code:
extern li_int_t li_nat_to_int(li_nat_t x)
{
    return (li_int_t)x.data;
}

canonical_original_code:
extern long li_nat_to_int(struct li_nat_t x)
{
    return (long)x.data;
}

return_type: long


decompiled_code:
_BOOL8 __fastcall li_nat_is_zero(__int64 a1)
{
return a1 == 0;
}

canonical_decompiled_code:
_BOOL8 __fastcall func5(__int64 a1)
{
return a1 == 0;
}

original_code:
extern li_bool_t li_nat_is_zero(li_nat_t x)
{
    return x.data == 0;
}

canonical_original_code:
extern int li_nat_is_zero(struct li_nat_t x)
{
    return x.data == 0;
}


decompiled_code:
__int64 __fastcall li_nat_add(__int64 a1, __int64 a2)
{
return a2 + a1;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1, __int64 a2)
{
return a2 + a1;
}

original_code:
extern li_nat_t li_nat_add(li_nat_t x, li_nat_t y)
{
    x.data += y.data;
    return x;
}

canonical_original_code:
extern struct li_nat_t li_nat_add(struct li_nat_t x, struct li_nat_t y)
{
    x.data += y.data;
    return x;
}

variable_types:
x
struct li_nat_t

variable_types:
y
struct li_nat_t


decompiled_code:
__int64 __fastcall li_nat_mul(__int64 a1, __int64 a2)
{
return a1 * a2;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1, __int64 a2)
{
return a1 * a2;
}

original_code:
extern li_nat_t li_nat_mul(li_nat_t x, li_nat_t y)
{
    x.data *= y.data;
    return x;
}

canonical_original_code:
extern struct li_nat_t li_nat_mul(struct li_nat_t x, struct li_nat_t y)
{
    x.data *= y.data;
    return x;
}


decompiled_code:
unsigned __int64 __fastcall li_nat_sub(unsigned __int64 a1, unsigned __int64 a2)
{
if ( a1 < a2 )
_assert_fail("x.data >= y.data", "src/nat.c", 0x3Cu, "li_nat_sub");
return a1 - a2;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func8(unsigned __int64 a1, unsigned __int64 a2)
{
if ( a1 < a2 )
_assert_fail("x.data >= y.data", "src/nat.c", 0x3Cu, "li_nat_sub");
return a1 - a2;
}

original_code:
extern li_nat_t li_nat_sub(li_nat_t x, li_nat_t y)
{
    ((x.data >= y.data) ? (void) (0) : __assert_fail ("x.data >= y.data", "src/nat.c", 60, __extension__ __PRETTY_FUNCTION__));
    x.data -= y.data;
    return x;
}

canonical_original_code:
extern struct li_nat_t li_nat_sub(struct li_nat_t x, struct li_nat_t y)
{
    ((x.data >= y.data) ? (void) (0) : __assert_fail ("x.data >= y.data", "src/nat.c", 60, __extension__ __PRETTY_FUNCTION__));
    x.data -= y.data;
    return x;
}


decompiled_code:
unsigned __int64 __fastcall li_nat_div(unsigned __int64 a1, unsigned __int64 a2)
{
if ( !a2 )
_assert_fail("y.data", "src/nat.c", 0x43u, "li_nat_div");
return a1 / a2;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func9(unsigned __int64 a1, unsigned __int64 a2)
{
if ( !a2 )
_assert_fail("y.data", "src/nat.c", 0x43u, "li_nat_div");
return a1 / a2;
}

original_code:
extern li_nat_t li_nat_div(li_nat_t x, li_nat_t y)
{
    ((y.data) ? (void) (0) : __assert_fail ("y.data", "src/nat.c", 67, __extension__ __PRETTY_FUNCTION__));
    x.data /= y.data;
    return x;
}

canonical_original_code:
extern struct li_nat_t li_nat_div(struct li_nat_t x, struct li_nat_t y)
{
    ((y.data) ? (void) (0) : __assert_fail ("y.data", "src/nat.c", 67, __extension__ __PRETTY_FUNCTION__));
    x.data /= y.data;
    return x;
}


decompiled_code:
unsigned __int64 __fastcall li_nat_mod(unsigned __int64 a1, unsigned __int64 a2)
{
if ( !a2 )
_assert_fail("y.data", "src/nat.c", 0x4Au, "li_nat_mod");
return a1 % a2;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func10(unsigned __int64 a1, unsigned __int64 a2)
{
if ( !a2 )
_assert_fail("y.data", "src/nat.c", 0x4Au, "li_nat_mod");
return a1 % a2;
}

original_code:
extern li_nat_t li_nat_mod(li_nat_t x, li_nat_t y)
{
    ((y.data) ? (void) (0) : __assert_fail ("y.data", "src/nat.c", 74, __extension__ __PRETTY_FUNCTION__));
    x.data %= y.data;
    return x;
}

canonical_original_code:
extern struct li_nat_t li_nat_mod(struct li_nat_t x, struct li_nat_t y)
{
    ((y.data) ? (void) (0) : __assert_fail ("y.data", "src/nat.c", 74, __extension__ __PRETTY_FUNCTION__));
    x.data %= y.data;
    return x;
}


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

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

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

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

original_code:
extern li_cmp_t li_nat_cmp(li_nat_t x, li_nat_t y)
{
    if (x.data < y.data)
        return LI_CMP_LT;
    else if (x.data > y.data)
        return LI_CMP_GT;
    return LI_CMP_EQ;
}

canonical_original_code:
extern enum li_cmp_t li_nat_cmp(struct li_nat_t x, struct li_nat_t y)
{
    if (x.data < y.data)
        return LI_CMP_LT;
    else if (x.data > y.data)
        return LI_CMP_GT;
    return LI_CMP_EQ;
}

return_type: enum li_cmp_t { LI_CMP_LT=-1, LI_CMP_EQ=0, LI_CMP_GT=1 }


decompiled_code:
unsigned __int64 __fastcall li_nat_gcd(unsigned __int64 a1, unsigned __int64 a2)
{
unsigned __int64 v4; // r12

while ( !li_nat_is_zero(a2) )
{
v4 = a2;
a2 = li_nat_mod(a1, a2);
a1 = v4;
}
return a1;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func12(unsigned __int64 a1, unsigned __int64 a2)
{
unsigned __int64 v4; // r12

while ( !func5(a2) )
{
v4 = a2;
a2 = func10(a1, a2);
a1 = v4;
}
return a1;
}

original_code:
extern li_nat_t li_nat_gcd(li_nat_t x, li_nat_t y)
{
    while (!li_nat_is_zero(y)) {
        li_nat_t z = y;
        y = li_nat_mod(x, y);
        x = z;
    }
    return x;
}

canonical_original_code:
extern struct li_nat_t li_nat_gcd(struct li_nat_t x, struct li_nat_t y)
{
    while (!li_nat_is_zero(y)) {
        struct li_nat_t z = y;
        y = li_nat_mod(x, y);
        x = z;
    }
    return x;
}


decompiled_code:
size_t __fastcall li_chr_decode(int *a1, const char *a2)
{
size_t result; // rax
char v5; // si
unsigned __int8 v6; // cl
size_t v7; // rsi
__int64 v8; // rcx
unsigned __int8 v9; // r9
unsigned __int8 v10; // r8
int v11; // ecx
char v12; // dl
size_t v13; // rdi
unsigned __int8 v14; // dl

result = strlen(a2);
if ( result )
{
v5 = *a2;
v6 = first[(unsigned __int8)v5];
if ( v6 > 0xEFu )
{
result = 1LL;
if ( a1 )
{
*a1 = (v5 ^ 0xFFFD) & v6 & 1 ^ v5;
result = 1LL;
}
}
else
{
v7 = v6 & 7;
if ( result >= v7 )
{
v8 = v6 >> 4;
v9 = accept_ranges[2 * v8];
v10 = accept_ranges[2 * v8 + 1];
if ( a1 )
*a1 = 0;
if ( !v7 )
return 0LL;
result = 0LL;
while ( 1 )
{
if ( result )
{
v14 = a2[result];
if ( v14 > v10 || v14 < v9 )
{
result = 1LL;
if ( a1 )
*a1 = 65533;
return result;
}
if ( a1 )
{
v11 = *a1 << 6;
*a1 = v11;
v12 = a2[result];
v13 = 0LL;
goto LABEL_20;
}
}
else if ( a1 )
{
v11 = *a1 << 6;
*a1 = v11;
v12 = *a2;
v13 = v7 - 1;
LABEL_20:
*a1 = v11 | (unsigned __int8)(masks[v13] & v12);
goto LABEL_21;
}
LABEL_21:
if ( v7 == ++result )
return result;
}
}
result = 1LL;
if ( a1 )
*a1 = 65533;
}
}
else if ( a1 )
{
*a1 = 65533;
}
return result;
}

canonical_decompiled_code:
size_t __fastcall func0(int *a1, const char *a2)
{
size_t result; // rax
char v5; // si
unsigned __int8 v6; // cl
size_t v7; // rsi
__int64 v8; // rcx
unsigned __int8 v9; // r9
unsigned __int8 v10; // r8
int v11; // ecx
char v12; // dl
size_t v13; // rdi
unsigned __int8 v14; // dl

result = strlen(a2);
if ( result )
{
v5 = *a2;
v6 = first[(unsigned __int8)v5];
if ( v6 > 0xEFu )
{
result = 1LL;
if ( a1 )
{
*a1 = (v5 ^ 0xFFFD) & v6 & 1 ^ v5;
result = 1LL;
}
}
else
{
v7 = v6 & 7;
if ( result >= v7 )
{
v8 = v6 >> 4;
v9 = accept_ranges[2 * v8];
v10 = accept_ranges[2 * v8 + 1];
if ( a1 )
*a1 = 0;
if ( !v7 )
return 0LL;
result = 0LL;
while ( 1 )
{
if ( result )
{
v14 = a2[result];
if ( v14 > v10 || v14 < v9 )
{
result = 1LL;
if ( a1 )
*a1 = 65533;
return result;
}
if ( a1 )
{
v11 = *a1 << 6;
*a1 = v11;
v12 = a2[result];
v13 = 0LL;
goto LABEL_20;
}
}
else if ( a1 )
{
v11 = *a1 << 6;
*a1 = v11;
v12 = *a2;
v13 = v7 - 1;
LABEL_20:
*a1 = v11 | (unsigned __int8)(masks[v13] & v12);
goto LABEL_21;
}
LABEL_21:
if ( v7 == ++result )
return result;
}
}
result = 1LL;
if ( a1 )
*a1 = 65533;
}
}
else if ( a1 )
{
*a1 = 65533;
}
return result;
}

original_code:
extern size_t li_chr_decode(li_character_t *chr, const char *s)
{
    size_t sz, i;
    size_t n = strlen(s);
    struct accept_range accept;
    if (n < 1) {
        if (chr)
            *chr = ((li_character_t)0xFFFD);
        return 0;
    }
    do {
        li_byte_t x = first[(li_byte_t)s[0]];
        if (x >= as) {
            li_character_t mask = (li_character_t)x << 31 >> 31;
            if (chr)
                *chr = ((li_character_t)s[0] & ~mask) | (((li_character_t)0xFFFD) & mask);
            return 1;
        }
        sz = x & 7;
        accept = accept_ranges[x >> 4];
    } while (0);
    if (n < sz) {
        if (chr)
            *chr = ((li_character_t)0xFFFD);
        return 1;
    }
    if (chr)
        *chr = 0;
    for (i = 0; i < sz; ++i) {
        if (i && ((li_byte_t)s[i] < accept.lo || accept.hi < (li_byte_t)s[i])) {
            if (chr)
                *chr = ((li_character_t)0xFFFD);
            return 1;
        }
        if (chr) {
            *chr <<= 6;
            *chr |= (li_character_t)((li_byte_t)s[i] & masks[i ? 0 : sz-1]);
        }
    }
    return sz;
}

canonical_original_code:
extern unsigned long li_chr_decode(unsigned int *chr, char *s)
{
    unsigned long sz; unsigned long i;
    unsigned long n = strlen(s);
    struct accept_range accept;
    if (n < 1) {
        if (chr)
            *chr = ((unsigned int)0xFFFD);
        return 0;
    }
    do {
        unsigned char x = first[(li_byte_t)s[0]];
        if (x >= as) {
            unsigned int mask = (li_character_t)x << 31 >> 31;
            if (chr)
                *chr = ((unsigned int)s[0] & ~mask) | (((unsigned int)0xFFFD) & mask);
            return 1;
        }
        sz = x & 7;
        accept = accept_ranges[x >> 4];
    } while (0);
    if (n < sz) {
        if (chr)
            *chr = ((unsigned int)0xFFFD);
        return 1;
    }
    if (chr)
        *chr = 0;
    for (i = 0; i < sz; ++i) {
        if (i && ((unsigned char)s[i] < accept.lo || accept.hi < (unsigned char)s[i])) {
            if (chr)
                *chr = ((unsigned int)0xFFFD);
            return 1;
        }
        if (chr) {
            *chr <<= 6;
            *chr |= (li_character_t)((unsigned char)s[i] & masks[i ? 0 : sz-1]);
        }
    }
    return sz;
}

variable_types:
chr
unsigned int *

variable_types:
sz
unsigned long

variable_types:
i
unsigned long

variable_types: struct accept_range { unsigned char lo; unsigned char hi; }

variable_types:
x
unsigned char

variable_types:
mask
unsigned int


decompiled_code:
unsigned __int64 __fastcall li_chr_encode(unsigned int a1, _BYTE *a2, unsigned __int64 a3)
{
unsigned __int64 v4; // rax
unsigned __int64 v5; // rsi
char v6; // cl
__int64 v7; // rdx
unsigned int v8; // eax

if ( a1 > 0x10FFFF )
{
a1 = 65533;
v4 = 65533LL;
}
else
{
v4 = a1;
if ( a1 <= 0x7F )
{
v5 = 1LL;
goto LABEL_7;
}
}
if ( v4 <= 0x7FF )
v5 = 2LL;
else
v5 = (v4 > 0xFFFF) + 3LL;
LABEL_7:
if ( a3 < v5 )
return 0LL;
v6 = 6 * v5 - 6;
v7 = 0LL;
do
{
v8 = a1 >> v6;
if ( v7 )
a2[v7] = v8 & 0x3F | 0x80;
else
*a2 = t[v5] | v8;
++v7;
v6 -= 6;
}
while ( v7 != v5 );
a2[v5] = 0;
return v5;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func1(unsigned int a1, _BYTE *a2, unsigned __int64 a3)
{
unsigned __int64 v4; // rax
unsigned __int64 v5; // rsi
char v6; // cl
__int64 v7; // rdx
unsigned int v8; // eax

if ( a1 > 0x10FFFF )
{
a1 = 65533;
v4 = 65533LL;
}
else
{
v4 = a1;
if ( a1 <= 0x7F )
{
v5 = 1LL;
goto LABEL_7;
}
}
if ( v4 <= 0x7FF )
v5 = 2LL;
else
v5 = (v4 > 0xFFFF) + 3LL;
LABEL_7:
if ( a3 < v5 )
return 0LL;
v6 = 6 * v5 - 6;
v7 = 0LL;
do
{
v8 = a1 >> v6;
if ( v7 )
a2[v7] = v8 & 0x3F | 0x80;
else
*a2 = t[v5] | v8;
++v7;
v6 -= 6;
}
while ( v7 != v5 );
a2[v5] = 0;
return v5;
}

original_code:
extern size_t li_chr_encode(li_character_t chr, char *s, size_t n)
{
    size_t i, sz;
    if (chr > ((li_character_t)0x0010FFFF))
        chr = ((li_character_t)0xFFFD);
    for (sz = 1; sz < 4; ++sz)
        if (chr <= rune_max[sz])
            break;
    if (n < sz)
        return 0;
    for (i = 0; i < sz; ++i) {
        uint8_t b = (li_byte_t)(chr >> ((sz-i-1) * 6));
        if (i)
            s[i] = t[0] | (b & masks[0]);
        else
            s[i] = t[sz] | b;
    }
    s[i] = '\0';
    return sz;
}

canonical_original_code:
extern unsigned long li_chr_encode(unsigned int chr, char *s, unsigned long n)
{
    unsigned long i; unsigned long sz;
    if (chr > ((unsigned int)0x0010FFFF))
        chr = ((unsigned int)0xFFFD);
    for (sz = 1; sz < 4; ++sz)
        if (chr <= rune_max[sz])
            break;
    if (n < sz)
        return 0;
    for (i = 0; i < sz; ++i) {
        unsigned char b = (li_byte_t)(chr >> ((sz-i-1) * 6));
        if (i)
            s[i] = t[0] | (b & masks[0]);
        else
            s[i] = t[sz] | b;
    }
    s[i] = '\0';
    return sz;
}

variable_types:
chr
unsigned int

variable_types:
b
unsigned char


decompiled_code:
__int64 __fastcall li_chr_count(const char *a1)
{
__int64 i; // rbp
size_t v3; // rax

for ( i = 0LL; ; ++i )
{
v3 = li_chr_decode(0LL, a1);
if ( !v3 )
break;
a1 += v3;
}
return i;
}

canonical_decompiled_code:
__int64 __fastcall func2(const char *a1)
{
__int64 i; // rbp
size_t v3; // rax

for ( i = 0LL; ; ++i )
{
v3 = func0(0LL, a1);
if ( !v3 )
break;
a1 += v3;
}
return i;
}

original_code:
extern size_t li_chr_count(const char *s)
{
    size_t count = 0;
    size_t n;
    while ((n = li_chr_decode(((void *)0), s))) {
        s += n;
        count++;
    }
    return count;
}

canonical_original_code:
extern unsigned long li_chr_count(char *s)
{
    unsigned long count = 0;
    unsigned long n;
    while ((n = li_chr_decode(((void *)0), s))) {
        s += n;
        count++;
    }
    return count;
}

variable_types:
count
unsigned long


yyerror

decompiled_code:
__int64 __fastcall yyerror(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // rax

v1 = li_num_with_int(yylineno);
v2 = li_string_make(a1);
return li_error_fmt("read: ~a: line ~a", v2, v1);
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
__int64 v1; // rbx
__int64 v2; // rax

v1 = li_num_with_int(yylineno);
v2 = li_string_make(a1);
return li_error_fmt("read: ~a: line ~a", v2, v1);
}

original_code:
static void yyerror(char *s)
{
    li_error_fmt("read: ~a: line ~a", li_string_make(s), li_num_with_int(yylineno));
}


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

result = li_cdr(stack);
stack = result;
return result;
}

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

result = li_cdr(stack);
stack = result;
return result;
}

original_code:
extern void li_stack_trace_pop(void)
{
    stack = li_cdr(stack);
}

canonical_original_code:
extern void li_stack_trace_pop()
{
    stack = li_cdr(stack);
}


decompiled_code:
void li_stack_trace_clear()
{
stack = 0LL;
}

canonical_decompiled_code:
void func4()
{
stack = 0LL;
}

original_code:
extern void li_stack_trace_clear(void)
{
    stack = ((void *)0);
}

canonical_original_code:
extern void li_stack_trace_clear()
{
    stack = ((void *)0);
}


repo: dylan-evans/objspace

decompiled_code:
void map_hash_set()
{
;
}

canonical_decompiled_code:
void func0()
{
;
}

original_code:
int map_hash_set(Object *self, Key *key, Object *value)
{
}

canonical_original_code:
int map_hash_set(struct _object *self, struct _key *key, struct _object *value)
{
}

variable_types: struct _object { int type; struct _object *container; struct _engine { int (*set)(struct _object *, struct _key { char *str; unsigned int index; } *, struct _object *); struct _object *(*get)(struct _object *, struct _key *); int (*destroy)(struct _object *, struct _key *); struct _iter { struct _object *object; int index; } *(*iter)(struct _object *); struct _object *(*next)(struct _iter *); struct _lock { int id; struct _object *object; } *(*lock)(struct _object *, int); int (*unlock)(struct _lock *); int (*length)(struct _object *); char *(*string)(struct _object *); } *engine; } *

variable_types:
key
struct _key *

variable_types:
value
struct _object *

user_defined_types: struct _object { int type; struct _object *container; struct _engine *engine; }

user_defined_types: struct _engine { int (*set)(struct _object *, struct _key *, struct _object *); struct _object *(*get)(struct _object *, struct _key *); int (*destroy)(struct _object *, struct _key *); struct _iter *(*iter)(struct _object *); struct _object *(*next)(struct _iter *); struct _lock *(*lock)(struct _object *, int); int (*unlock)(struct _lock *); int (*length)(struct _object *); char *(*string)(struct _object *); }


decompiled_code:
void map_hash_get()
{
;
}

canonical_decompiled_code:
void func1()
{
;
}

original_code:
Object *map_hash_get(Object *self, Key *key)
{
}

canonical_original_code:
struct _object *map_hash_get(struct _object *self, struct _key *key)
{
}

variable_types:
self
struct _object *

return_type: struct _object { int type; struct _object *container; struct _engine { int (*set)(struct _object *, struct _key { char *str; unsigned int index; } *, struct _object *); struct _object *(*get)(struct _object *, struct _key *); int (*destroy)(struct _object *, struct _key *); struct _iter { struct _object *object; int index; } *(*iter)(struct _object *); struct _object *(*next)(struct _iter *); struct _lock { int id; struct _object *object; } *(*lock)(struct _object *, int); int (*unlock)(struct _lock *); int (*length)(struct _object *); char *(*string)(struct _object *); } *engine; } *


decompiled_code:
void map_hash_destroy()
{
;
}

canonical_decompiled_code:
void func2()
{
;
}

original_code:
int map_hash_destroy(Object *self, Key *key)
{
}

canonical_original_code:
int map_hash_destroy(struct _object *self, struct _key *key)
{
}

user_defined_types: struct _key { char *str; unsigned int index; }

user_defined_types: struct _iter { struct _object *object; int index; }

user_defined_types: struct _lock { int id; struct _object *object; }


decompiled_code:
void map_hash_iter()
{
;
}

canonical_decompiled_code:
void func3()
{
;
}

original_code:
Iter *map_hash_iter(Object *self)
{
}

canonical_original_code:
struct _iter *map_hash_iter(struct _object *self)
{
}

return_type: struct _iter { struct _object { int type; struct _object *container; struct _engine { int (*set)(struct _object *, struct _key { char *str; unsigned int index; } *, struct _object *); struct _object *(*get)(struct _object *, struct _key *); int (*destroy)(struct _object *, struct _key *); struct _iter *(*iter)(struct _object *); struct _object *(*next)(struct _iter *); struct _lock { int id; struct _object *object; } *(*lock)(struct _object *, int); int (*unlock)(struct _lock *); int (*length)(struct _object *); char *(*string)(struct _object *); } *engine; } *object; int index; } *


decompiled_code:
void map_hash_next()
{
;
}

canonical_decompiled_code:
void func4()
{
;
}

original_code:
Object *map_hash_next(Iter *iter)
{
}

canonical_original_code:
struct _object *map_hash_next(struct _iter *iter)
{
}

variable_types:
iter
struct _iter *


decompiled_code:
void map_hash_lock()
{
;
}

canonical_decompiled_code:
void func5()
{
;
}

original_code:
Lock *map_hash_lock(Object *self, int timeout)
{
}

canonical_original_code:
struct _lock *map_hash_lock(struct _object *self, int timeout)
{
}

variable_types: timeout int

return_type: struct _lock { int id; struct _object { int type; struct _object *container; struct _engine { int (*set)(struct _object *, struct _key { char *str; unsigned int index; } *, struct _object *); struct _object *(*get)(struct _object *, struct _key *); int (*destroy)(struct _object *, struct _key *); struct _iter { struct _object *object; int index; } *(*iter)(struct _object *); struct _object *(*next)(struct _iter *); struct _lock *(*lock)(struct _object *, int); int (*unlock)(struct _lock *); int (*length)(struct _object *); char *(*string)(struct _object *); } *engine; } *object; } *


decompiled_code:
_DWORD *map_hash_create()
{
return map_create_with_engine((__int64)&map_engine_0, 33);
}

canonical_decompiled_code:
_DWORD *func6()
{
return map_create_with_engine((__int64)&map_engine_0, 33);
}

original_code:
Object *map_hash_create()
{
    static Engine map_engine = {
        .set = map_hash_set,
        .get = map_hash_get,
        .destroy = map_hash_destroy,
        .iter = map_hash_iter,
        .next = map_hash_next,
        .lock = map_hash_lock
    };
    return map_create_with_engine(&map_engine, 0x21);
}

canonical_original_code:
struct _object *map_hash_create()
{
    static struct _engine map_engine = {
        .set = map_hash_set,
        .get = map_hash_get,
        .destroy = map_hash_destroy,
        .iter = map_hash_iter,
        .next = map_hash_next,
        .lock = map_hash_lock
    };
    return map_create_with_engine(&map_engine, 0x21);
}

variable_types: struct _engine { int (*set)(struct _object { int type; struct _object *container; struct _engine *engine; } *, struct _key { char *str; unsigned int index; } *, struct _object *); struct _object *(*get)(struct _object *, struct _key *); int (*destroy)(struct _object *, struct _key *); struct _iter { struct _object *object; int index; } *(*iter)(struct _object *); struct _object *(*next)(struct _iter *); struct _lock { int id; struct _object *object; } *(*lock)(struct _object *, int); int (*unlock)(struct _lock *); int (*length)(struct _object *); char *(*string)(struct _object *); }


main

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

if ( (unsigned int)CU_initialize_registry(argc, argv, envp) )
return CU_get_error();
if ( (unsigned int)setup_object_tests() && (unsigned int)setup_list_tests() )
{
CU_basic_set_mode(2LL);
CU_basic_run_tests();
putchar(10);
v4 = CU_get_failure_list();
CU_basic_show_failures(v4);
puts("\n");
CU_automated_run_tests();
CU_list_tests_to_file();
CU_cleanup_registry();
result = CU_get_error();
}
else
{
CU_cleanup_registry();
result = CU_get_error();
}
return result;
}

original_code:
int main(int argc, char **argv)
{
    int status;
    if(CUE_SUCCESS != CU_initialize_registry())
        return CU_get_error();
    if(!(status = setup_object_tests())
        || !(status = setup_list_tests()))
    {
        CU_cleanup_registry();
        return CU_get_error();
    }
    CU_basic_set_mode(CU_BRM_VERBOSE);
    CU_basic_run_tests();
    printf("\n");
    CU_basic_show_failures(CU_get_failure_list());
    printf("\n\n");
    CU_automated_run_tests();
    CU_list_tests_to_file();
    CU_cleanup_registry();
    return CU_get_error();
}

variable_types: argc int

variable_types:
argv
char **

variable_types: status int


decompiled_code:
char *__fastcall number_string(double *a1)
{
char *v1; // rbx

v1 = (char *)malloc(0x40uLL);
if ( *(_DWORD *)a1 == 17 )
{
sprintf(v1, "%d", *((unsigned int *)a1 + 6));
}
else if ( *(_DWORD *)a1 == 18 )
{
sprintf(v1, "%f", a1[3]);
}
else
{
free(v1);
v1 = 0LL;
}
return v1;
}

canonical_decompiled_code:
char *__fastcall func0(double *a1)
{
char *v1; // rbx

v1 = (char *)malloc(0x40uLL);
if ( *(_DWORD *)a1 == 17 )
{
sprintf(v1, "%d", *((unsigned int *)a1 + 6));
}
else if ( *(_DWORD *)a1 == 18 )
{
sprintf(v1, "%f", a1[3]);
}
else
{
free(v1);
v1 = 0LL;
}
return v1;
}

original_code:
char *number_string(Object *obj)
{
    char *buf;
    buf = malloc(64);
    switch(obj->type)
    {
        case 0x11:
            sprintf(buf, "%d", ((Number *)(obj))->value.num_int);
            break;
        case 0x12:
            sprintf(buf, "%f", ((Number *)(obj))->value.num_float);
            break;
        default:
            free(buf);
            return ((void *)0);
    }
    return buf;
}

canonical_original_code:
char *number_string(struct _object *obj)
{
    char *buf;
    buf = malloc(64);
    switch(obj->type)
    {
        case 0x11:
            sprintf(buf, "%d", ((struct Number *)(obj))->value.num_int);
            break;
        case 0x12:
            sprintf(buf, "%f", ((struct Number *)(obj))->value.num_float);
            break;
        default:
            free(buf);
            return ((void *)0);
    }
    return buf;
}

variable_types:
buf
char *

user_defined_types: struct Number { struct _object object; union { int num_int; double num_float; } value; }


decompiled_code:
__int64 __fastcall obj_set(__int64 a1)
{
__int64 (*v1)(void); // rax
__int64 result; // rax

v1 = **(__int64 (***)(void))(a1 + 16);
if ( v1 )
result = v1();
else
result = 0LL;
return result;
}

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

v1 = **(__int64 (***)(void))(a1 + 16);
if ( v1 )
result = v1();
else
result = 0LL;
return result;
}

original_code:
int obj_set(Object *self, Key *key, Object *obj)
{
    if(self->engine->set == ((void *)0))
        return 0;
    return self->engine->set(self, key, obj);
}

canonical_original_code:
int obj_set(struct _object *self, struct _key *key, struct _object *obj)
{
    if(self->engine->set == ((void *)0))
        return 0;
    return self->engine->set(self, key, obj);
}

variable_types:
obj
struct _object *


decompiled_code:
__int64 __fastcall obj_get(__int64 a1)
{
__int64 (*v1)(void); // rax
__int64 result; // rax

v1 = *(__int64 (**)(void))(*(_QWORD *)(a1 + 16) + 8LL);
if ( v1 )
result = v1();
else
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
__int64 (*v1)(void); // rax
__int64 result; // rax

v1 = *(__int64 (**)(void))(*(_QWORD *)(a1 + 16) + 8LL);
if ( v1 )
result = v1();
else
result = 0LL;
return result;
}

original_code:
Object *obj_get(Object *self, Key *key)
{
    if(self->engine->get == ((void *)0))
        return ((void *)0);
    return self->engine->get(self, key);
}

canonical_original_code:
struct _object *obj_get(struct _object *self, struct _key *key)
{
    if(self->engine->get == ((void *)0))
        return ((void *)0);
    return self->engine->get(self, key);
}


decompiled_code:
__int64 __fastcall obj_destroy(__int64 a1)
{
__int64 (*v1)(void); // rax
__int64 result; // rax

v1 = *(__int64 (**)(void))(*(_QWORD *)(a1 + 16) + 16LL);
if ( v1 )
result = v1();
else
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1)
{
__int64 (*v1)(void); // rax
__int64 result; // rax

v1 = *(__int64 (**)(void))(*(_QWORD *)(a1 + 16) + 16LL);
if ( v1 )
result = v1();
else
result = 0LL;
return result;
}

original_code:
int obj_destroy(Object *self, Key *key)
{
    if(self->engine->destroy == ((void *)0))
        return 0;
    return self->engine->destroy(self, key);
}

canonical_original_code:
int obj_destroy(struct _object *self, struct _key *key)
{
    if(self->engine->destroy == ((void *)0))
        return 0;
    return self->engine->destroy(self, key);
}


decompiled_code:
__int64 __fastcall obj_iter(__int64 a1)
{
__int64 (*v1)(void); // rax
__int64 result; // rax

v1 = *(__int64 (**)(void))(*(_QWORD *)(a1 + 16) + 24LL);
if ( v1 )
result = v1();
else
result = 0LL;
return result;
}

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

v1 = *(__int64 (**)(void))(*(_QWORD *)(a1 + 16) + 24LL);
if ( v1 )
result = v1();
else
result = 0LL;
return result;
}

original_code:
Iter *obj_iter(Object *self)
{
    if(self->engine->iter == ((void *)0))
        return ((void *)0);
    return self->engine->iter(self);
}

canonical_original_code:
struct _iter *obj_iter(struct _object *self)
{
    if(self->engine->iter == ((void *)0))
        return ((void *)0);
    return self->engine->iter(self);
}


decompiled_code:
__int64 __fastcall obj_next(__int64 a1)
{
__int64 (*v1)(void); // rax
__int64 result; // rax

v1 = *(__int64 (**)(void))(*(_QWORD *)(*(_QWORD *)a1 + 16LL) + 32LL);
if ( v1 )
result = v1();
else
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(__int64 a1)
{
__int64 (*v1)(void); // rax
__int64 result; // rax

v1 = *(__int64 (**)(void))(*(_QWORD *)(*(_QWORD *)a1 + 16LL) + 32LL);
if ( v1 )
result = v1();
else
result = 0LL;
return result;
}

original_code:
Object *obj_next(Iter *iter)
{
    if(iter->object->engine->next == ((void *)0))
        return ((void *)0);
    return iter->object->engine->next(iter);
}

canonical_original_code:
struct _object *obj_next(struct _iter *iter)
{
    if(iter->object->engine->next == ((void *)0))
        return ((void *)0);
    return iter->object->engine->next(iter);
}


decompiled_code:
__int64 __fastcall obj_lock(__int64 a1)
{
__int64 (*v1)(void); // rax
__int64 result; // rax

v1 = *(__int64 (**)(void))(*(_QWORD *)(a1 + 16) + 40LL);
if ( v1 )
result = v1();
else
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(__int64 a1)
{
__int64 (*v1)(void); // rax
__int64 result; // rax

v1 = *(__int64 (**)(void))(*(_QWORD *)(a1 + 16) + 40LL);
if ( v1 )
result = v1();
else
result = 0LL;
return result;
}

original_code:
Lock *obj_lock(Object *self, int timeout)
{
    if(self->engine->lock == ((void *)0))
        return ((void *)0);
    return self->engine->lock(self, timeout);
}

canonical_original_code:
struct _lock *obj_lock(struct _object *self, int timeout)
{
    if(self->engine->lock == ((void *)0))
        return ((void *)0);
    return self->engine->lock(self, timeout);
}


decompiled_code:
__int64 __fastcall obj_unlock(__int64 a1)
{
__int64 (*v1)(void); // rax
__int64 result; // rax

v1 = *(__int64 (**)(void))(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 16LL) + 48LL);
if ( v1 )
result = v1();
else
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func7(__int64 a1)
{
__int64 (*v1)(void); // rax
__int64 result; // rax

v1 = *(__int64 (**)(void))(*(_QWORD *)(*(_QWORD *)(a1 + 8) + 16LL) + 48LL);
if ( v1 )
result = v1();
else
result = 0LL;
return result;
}

original_code:
int obj_unlock(Lock *lock)
{
    if(lock->object->engine->unlock == ((void *)0))
        return 0;
    return lock->object->engine->unlock(lock);
}

canonical_original_code:
int obj_unlock(struct _lock *lock)
{
    if(lock->object->engine->unlock == ((void *)0))
        return 0;
    return lock->object->engine->unlock(lock);
}

variable_types: struct _lock { int id; struct _object { int type; struct _object *container; struct _engine { int (*set)(struct _object *, struct _key { char *str; unsigned int index; } *, struct _object *); struct _object *(*get)(struct _object *, struct _key *); int (*destroy)(struct _object *, struct _key *); struct _iter { struct _object *object; int index; } *(*iter)(struct _object *); struct _object *(*next)(struct _iter *); struct _lock *(*lock)(struct _object *, int); int (*unlock)(struct _lock *); int (*length)(struct _object *); char *(*string)(struct _object *); } *engine; } *object; } *


decompiled_code:
__int64 __fastcall obj_length(__int64 a1)
{
__int64 (*v1)(void); // rax
__int64 result; // rax

v1 = *(__int64 (**)(void))(*(_QWORD *)(a1 + 16) + 56LL);
if ( v1 )
result = v1();
else
result = 0xFFFFFFFFLL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(__int64 a1)
{
__int64 (*v1)(void); // rax
__int64 result; // rax

v1 = *(__int64 (**)(void))(*(_QWORD *)(a1 + 16) + 56LL);
if ( v1 )
result = v1();
else
result = 0xFFFFFFFFLL;
return result;
}

original_code:
int obj_length(Object *self)
{
    if(self->engine->length == ((void *)0))
        return -1;
    return self->engine->length(self);
}

canonical_original_code:
int obj_length(struct _object *self)
{
    if(self->engine->length == ((void *)0))
        return -1;
    return self->engine->length(self);
}


decompiled_code:
__int64 __fastcall obj_string(__int64 a1)
{
__int64 (*v1)(void); // rax
__int64 result; // rax

v1 = *(__int64 (**)(void))(*(_QWORD *)(a1 + 16) + 64LL);
if ( v1 )
result = v1();
else
result = 0LL;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(__int64 a1)
{
__int64 (*v1)(void); // rax
__int64 result; // rax

v1 = *(__int64 (**)(void))(*(_QWORD *)(a1 + 16) + 64LL);
if ( v1 )
result = v1();
else
result = 0LL;
return result;
}

original_code:
char *obj_string(Object *self)
{
    if(self->engine->string == ((void *)0))
        return ((void *)0);
    return self->engine->string(self);
}

canonical_original_code:
char *obj_string(struct _object *self)
{
    if(self->engine->string == ((void *)0))
        return ((void *)0);
    return self->engine->string(self);
}


decompiled_code:
void object_lock()
{
;
}

canonical_decompiled_code:
void func10()
{
;
}

original_code:
Lock *object_lock(Object *object, int timeout)
{
    Lock *lock;
}

canonical_original_code:
struct _lock *object_lock(struct _object *object, int timeout)
{
    struct _lock *lock;
}

variable_types:
object
struct _object *


decompiled_code:
void key_from_int()
{
;
}

canonical_decompiled_code:
void func11()
{
;
}

original_code:
Key *key_from_int(Object *object, int index)
{
}

canonical_original_code:
struct _key *key_from_int(struct _object *object, int index)
{
}

variable_types: struct _object { int type; struct _object *container; struct _engine { int (*set)(struct _object *, struct _key *, struct _object *); struct _object *(*get)(struct _object *, struct _key *); int (*destroy)(struct _object *, struct _key *); struct _iter { struct _object *object; int index; } *(*iter)(struct _object *); struct _object *(*next)(struct _iter *); struct _lock { int id; struct _object *object; } *(*lock)(struct _object *, int); int (*unlock)(struct _lock *); int (*length)(struct _object *); char *(*string)(struct _object *); } *engine; } *

variable_types: index int

return_type: struct _key { char *str; unsigned int index; } *


decompiled_code:
double *__fastcall object_float(double a1)
{
double *result; // rax

result = (double *)number_create(18);
result[3] = a1;
return result;
}

canonical_decompiled_code:
double *__fastcall func12(double a1)
{
double *result; // rax

result = (double *)number_create(18);
result[3] = a1;
return result;
}

original_code:
Object *object_float(double value)
{
    Number *num;
    num = number_create(0x12);
    num->value.num_float = value;
    return (Object*)num;
}

canonical_original_code:
struct _object *object_float(double value)
{
    struct Number *num;
    num = number_create(0x12);
    num->value.num_float = value;
    return (struct _object *)num;
}

variable_types: value double

variable_types: struct Number { struct _object { int type; struct _object *container; struct _engine { int (*set)(struct _object *, struct _key { char *str; unsigned int index; } *, struct _object *); struct _object *(*get)(struct _object *, struct _key *); int (*destroy)(struct _object *, struct _key *); struct _iter { struct _object *object; int index; } *(*iter)(struct _object *); struct _object *(*next)(struct _iter *); struct _lock { int id; struct _object *object; } *(*lock)(struct _object *, int); int (*unlock)(struct _lock *); int (*length)(struct _object *); char *(*string)(struct _object *); } *engine; } object; union { int num_int; double num_float; } value; } *


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

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

original_code:
int init_suite_object()
{
    return 0;
}

canonical_original_code:
int init_suite_object()
{
    return 0;
}


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

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

original_code:
int clean_suite_object()
{
    return 0;
}

canonical_original_code:
int clean_suite_object()
{
    return 0;
}


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

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

original_code:
int init_suite_num()
{
    return 0;
}

canonical_original_code:
int init_suite_num()
{
    return 0;
}


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

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

original_code:
int clean_suite_num()
{
    return 0;
}

canonical_original_code:
int clean_suite_num()
{
    return 0;
}


decompiled_code:
__int64 test_object1()
{
__int64 v0; // rbx
char v2[27]; // [rsp+Dh] [rbp-1Bh] BYREF

strcpy(v2, "42");
v0 = object_string(v2);
CU_assertImplementation(v0 != 0, 32LL, "obj != NULL", "tests/test_object.c", &unk_28E, 0LL);
CU_assertImplementation(*(_DWORD *)v0 == 129, 34LL, "obj->type == STRING_TYPE", "tests/test_object.c", &unk_28E, 0LL);
return CU_assertImplementation(
*(_QWORD *)(v0 + 24) == (_QWORD)v2,
36LL,
"((String*)obj)->ptr == buf",
"tests/test_object.c",
&unk_28E,
0LL);
}

canonical_decompiled_code:
__int64 func4()
{
__int64 v0; // rbx
char v2[27]; // [rsp+Dh] [rbp-1Bh] BYREF

strcpy(v2, "42");
v0 = object_string(v2);
CU_assertImplementation(v0 != 0, 32LL, "obj != NULL", "tests/test_object.c", &unk_28E, 0LL);
CU_assertImplementation(*(_DWORD *)v0 == 129, 34LL, "obj->type == STRING_TYPE", "tests/test_object.c", &unk_28E, 0LL);
return CU_assertImplementation(
*(_QWORD *)(v0 + 24) == (_QWORD)v2,
36LL,
"((String*)obj)->ptr == buf",
"tests/test_object.c",
&unk_28E,
0LL);
}

original_code:
void test_object1()
{
    char buf[] = "42";
    Object *obj;
    obj = object_string(buf);
    { CU_assertImplementation((obj != ((void *)0)), 32, "obj != NULL", "tests/test_object.c", "", 0); };
    { CU_assertImplementation((obj->type == 0x81), 34, "obj->type == STRING_TYPE", "tests/test_object.c", "", 0); };
    { CU_assertImplementation((((String*)obj)->ptr == buf), 36, "((String*)obj)->ptr == buf", "tests/test_object.c", "", 0); };
}

canonical_original_code:
void test_object1()
{
    char buf[] = "42";
    struct _object *obj;
    obj = object_string(buf);
    { CU_assertImplementation((obj != ((void *)0)), 32, "obj != NULL", "tests/test_object.c", "", 0); };
    { CU_assertImplementation((obj->type == 0x81), 34, "obj->type == STRING_TYPE", "tests/test_object.c", "", 0); };
    { CU_assertImplementation((((struct _string *)obj)->ptr == buf), 36, "((String*)obj)->ptr == buf", "tests/test_object.c", "", 0); };
}

variable_types:
buf
char []

variable_types: struct _object { int type; struct _object *container; struct _engine { int (*set)(struct _object *, struct _key { char *str; unsigned int index; } *, struct _object *); struct _object *(*get)(struct _object *, struct _key *); int (*destroy)(struct _object *, struct _key *); struct _iter { struct _object *object; int index; } *(*iter)(struct _object *); struct _object *(*next)(struct _iter *); struct _lock { int id; struct _object *object; } *(*lock)(struct _object *, int); int (*unlock)(struct _lock *); int (*length)(struct _object *); char *(*string)(struct _object *); } *engine; } *

user_defined_types: struct _string { struct _object object; char *ptr; }


decompiled_code:
__int64 test_num1()
{
__int64 v0; // rbx

v0 = object_float(0.6);
CU_assertImplementation(v0 != 0, 59LL, "obj != NULL", "tests/test_object.c", &unk_28E, 0LL);
CU_assertImplementation(*(_DWORD *)v0 == 18, 61LL, "obj->type == NUMBER_FLOAT", "tests/test_object.c", &unk_28E, 0LL);
return CU_assertImplementation(
0.6 == *(double *)(v0 + 24),
63LL,
"((Number*)obj)->value.num_float == test_val",
"tests/test_object.c",
&unk_28E,
0LL);
}

canonical_decompiled_code:
__int64 func5()
{
__int64 v0; // rbx

v0 = object_float(0.6);
CU_assertImplementation(v0 != 0, 59LL, "obj != NULL", "tests/test_object.c", &unk_28E, 0LL);
CU_assertImplementation(*(_DWORD *)v0 == 18, 61LL, "obj->type == NUMBER_FLOAT", "tests/test_object.c", &unk_28E, 0LL);
return CU_assertImplementation(
0.6 == *(double *)(v0 + 24),
63LL,
"((Number*)obj)->value.num_float == test_val",
"tests/test_object.c",
&unk_28E,
0LL);
}

original_code:
void test_num1()
{
    double test_val;
    Object *obj;
    test_val = 4.2 / 7;
    obj = object_float(test_val);
    { CU_assertImplementation((obj != ((void *)0)), 59, "obj != NULL", "tests/test_object.c", "", 0); };
    { CU_assertImplementation((obj->type == 0x12), 61, "obj->type == NUMBER_FLOAT", "tests/test_object.c", "", 0); };
    { CU_assertImplementation((((Number*)obj)->value.num_float == test_val), 63, "((Number*)obj)->value.num_float == test_val", "tests/test_object.c", "", 0); };
}

canonical_original_code:
void test_num1()
{
    double test_val;
    struct _object *obj;
    test_val = 4.2 / 7;
    obj = object_float(test_val);
    { CU_assertImplementation((obj != ((void *)0)), 59, "obj != NULL", "tests/test_object.c", "", 0); };
    { CU_assertImplementation((obj->type == 0x12), 61, "obj->type == NUMBER_FLOAT", "tests/test_object.c", "", 0); };
    { CU_assertImplementation((((struct Number *)obj)->value.num_float == test_val), 63, "((Number*)obj)->value.num_float == test_val", "tests/test_object.c", "", 0); };
}


decompiled_code:
__int64 test_num2()
{
_DWORD *v0; // rbx

v0 = (_DWORD *)object_int(42LL);
CU_assertImplementation(v0 != 0LL, 75LL, "obj != NULL", "tests/test_object.c", &unk_28E, 0LL);
CU_assertImplementation(*v0 == 17, 77LL, "obj->type == NUMBER_INT", "tests/test_object.c", &unk_28E, 0LL);
return CU_assertImplementation(
v0[6] == 42,
79LL,
"((Number*)obj)->value.num_int == test_val",
"tests/test_object.c",
&unk_28E,
0LL);
}

canonical_decompiled_code:
__int64 func6()
{
_DWORD *v0; // rbx

v0 = (_DWORD *)object_int(42LL);
CU_assertImplementation(v0 != 0LL, 75LL, "obj != NULL", "tests/test_object.c", &unk_28E, 0LL);
CU_assertImplementation(*v0 == 17, 77LL, "obj->type == NUMBER_INT", "tests/test_object.c", &unk_28E, 0LL);
return CU_assertImplementation(
v0[6] == 42,
79LL,
"((Number*)obj)->value.num_int == test_val",
"tests/test_object.c",
&unk_28E,
0LL);
}

original_code:
void test_num2()
{
    int test_val;
    Object *obj;
    test_val = 42;
    obj = object_int(test_val);
    { CU_assertImplementation((obj != ((void *)0)), 75, "obj != NULL", "tests/test_object.c", "", 0); };
    { CU_assertImplementation((obj->type == 0x11), 77, "obj->type == NUMBER_INT", "tests/test_object.c", "", 0); };
    { CU_assertImplementation((((Number*)obj)->value.num_int == test_val), 79, "((Number*)obj)->value.num_int == test_val", "tests/test_object.c", "", 0); };
}

canonical_original_code:
void test_num2()
{
    int test_val;
    struct _object *obj;
    test_val = 42;
    obj = object_int(test_val);
    { CU_assertImplementation((obj != ((void *)0)), 75, "obj != NULL", "tests/test_object.c", "", 0); };
    { CU_assertImplementation((obj->type == 0x11), 77, "obj->type == NUMBER_INT", "tests/test_object.c", "", 0); };
    { CU_assertImplementation((((struct Number *)obj)->value.num_int == test_val), 79, "((Number*)obj)->value.num_int == test_val", "tests/test_object.c", "", 0); };
}


decompiled_code:
__int64 setup_object_tests()
{
__int64 v0; // rax
__int64 v1; // rdi
__int64 result; // rax

v0 = CU_add_suite("Object Suite", init_suite_object, clean_suite_object);
if ( v0 && CU_add_test(v0, "Object test 1", test_object1) )
{
v1 = CU_add_suite("Number Suite", init_suite_num, clean_suite_num);
result = 0LL;
if ( v1 )
result = CU_add_test(v1, "Number test 1", test_num1) != 0;
}
else
{
CU_cleanup_registry();
result = CU_get_error();
}
return result;
}

canonical_decompiled_code:
__int64 func7()
{
__int64 v0; // rax
__int64 v1; // rdi
__int64 result; // rax

v0 = CU_add_suite("Object Suite", init_suite_object, clean_suite_object);
if ( v0 && CU_add_test(v0, "Object test 1", test_object1) )
{
v1 = CU_add_suite("Number Suite", init_suite_num, clean_suite_num);
result = 0LL;
if ( v1 )
result = CU_add_test(v1, "Number test 1", test_num1) != 0;
}
else
{
CU_cleanup_registry();
result = CU_get_error();
}
return result;
}

original_code:
int setup_object_tests()
{
    CU_pSuite pSuite = ((void *)0);
    pSuite = CU_add_suite("Object Suite", init_suite_object,
                          clean_suite_object);
    if(pSuite == ((void *)0)
        || !CU_add_test(pSuite, "Object test 1", test_object1))
    {
        CU_cleanup_registry();
        return CU_get_error();
    }
    pSuite = CU_add_suite("Number Suite", init_suite_num, clean_suite_num);
    if(!pSuite
        || !CU_add_test(pSuite, "Number test 1", test_num1))
    {
        return 0;
    }
    return 1;
}

canonical_original_code:
int setup_object_tests()
{
    struct CU_Suite *pSuite = ((void *)0);
    pSuite = CU_add_suite("Object Suite", init_suite_object,
                          clean_suite_object);
    if(pSuite == ((void *)0)
        || !CU_add_test(pSuite, "Object test 1", test_object1))
    {
        CU_cleanup_registry();
        return CU_get_error();
    }
    pSuite = CU_add_suite("Number Suite", init_suite_num, clean_suite_num);
    if(!pSuite
        || !CU_add_test(pSuite, "Number test 1", test_num1))
    {
        return 0;
    }
    return 1;
}

variable_types: struct CU_Suite { char *pName; int fActive; struct CU_Test { char *pName; int fActive; void (*pTestFunc)(); struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t { unsigned long __val[-1]; } __saved_mask; } (*pJumpBuf)[1]; struct CU_Test *pNext; struct CU_Test *pPrev; } *pTest; int (*pInitializeFunc)(); int (*pCleanupFunc)(); void (*pSetUpFunc)(); void (*pTearDownFunc)(); unsigned int uiNumberOfTests; struct CU_Suite *pNext; struct CU_Suite *pPrev; unsigned int uiNumberOfTestsFailed; unsigned int uiNumberOfTestsSuccess; } *

user_defined_types: struct CU_Suite { char *pName; int fActive; struct CU_Test *pTest; int (*pInitializeFunc)(); int (*pCleanupFunc)(); void (*pSetUpFunc)(); void (*pTearDownFunc)(); unsigned int uiNumberOfTests; struct CU_Suite *pNext; struct CU_Suite *pPrev; unsigned int uiNumberOfTestsFailed; unsigned int uiNumberOfTestsSuccess; }

user_defined_types: struct CU_Test { char *pName; int fActive; void (*pTestFunc)(); struct __jmp_buf_tag (*pJumpBuf)[1]; struct CU_Test *pNext; struct CU_Test *pPrev; }

user_defined_types: struct __jmp_buf_tag { long __jmpbuf[8]; int __mask_was_saved; struct __sigset_t __saved_mask; }


toprime

repo: dylan-k/Dadadodomax

decompiled_code:
__int64 __fastcall toprime(unsigned __int64 a1)
{
unsigned __int64 *v1; // rax
unsigned __int64 v2; // rdx

v1 = (unsigned __int64 *)ℙ
while ( 1 )
{
v2 = *v1;
if ( *v1 >= a1 )
break;
if ( ++v1 == (unsigned __int64 *)&unk_658 )
return 2411033LL;
}
return v2;
}

canonical_decompiled_code:
__int64 __fastcall func0(unsigned __int64 a1)
{
unsigned __int64 *v1; // rax
unsigned __int64 v2; // rdx

v1 = (unsigned __int64 *)ℙ
while ( 1 )
{
v2 = *v1;
if ( *v1 >= a1 )
break;
if ( ++v1 == (unsigned __int64 *)&unk_658 )
return 2411033LL;
}
return v2;
}

original_code:
static unsigned long
toprime (unsigned long size)
{
  unsigned int i;
  static unsigned int s = (sizeof (primes) / sizeof (*primes)) - 1;
  for (i = 0; i < s; i++)
    if (size <= primes[i])
      return primes[i];
  return primes[s-1];
}

canonical_original_code:
static unsigned long toprime(unsigned long size)
{
  unsigned int i;
  static unsigned int s = (sizeof (primes) / sizeof (*primes)) - 1;
  for (i = 0; i < s; i++)
    if (size <= primes[i])
      return primes[i];
  return primes[s-1];
}

variable_types:
size
unsigned long

variable_types:
i
unsigned int

variable_types:
s
unsigned int


clrhash

decompiled_code:
void *__fastcall clrhash(__int64 a1)
{
*(_QWORD *)(a1 + 8) = 0LL;
return memset(*(void **)(a1 + 32), 0, 16LL * *(_QWORD *)a1);
}

canonical_decompiled_code:
void *__fastcall func1(__int64 a1)
{
*(_QWORD *)(a1 + 8) = 0LL;
return memset(*(void **)(a1 + 32), 0, 16LL * *(_QWORD *)a1);
}

original_code:
void
clrhash (hash_table *table)
{
  table->count = 0;
  memset (table->buckets, 0, table->size * sizeof(*table->buckets));
}

canonical_original_code:
void clrhash(struct hash_table *table)
{
  table->count = 0;
  memset (table->buckets, 0, table->size * sizeof(*table->buckets));
}

variable_types: struct hash_table { unsigned long size; unsigned long count; long (*hash)(void *); int (*compare)(void *, void *); struct bucket { void *key; void *value; } *buckets; } *

user_defined_types: struct hash_table { unsigned long size; unsigned long count; long (*hash)(void *); int (*compare)(void *, void *); struct bucket *buckets; }


decompiled_code:
void __fastcall free_hash_table(void *ptr)
{
free(*((void **)ptr + 4));
free(ptr);
}

canonical_decompiled_code:
void __fastcall func2(void *ptr)
{
free(*((void **)ptr + 4));
free(ptr);
}

original_code:
void
free_hash_table (hash_table *table)
{
  free (table->buckets);
  free (table);
}

canonical_original_code:
void free_hash_table(struct hash_table *table)
{
  free (table->buckets);
  free (table);
}

user_defined_types: struct bucket { void *key; void *value; }


puthash

original_code:
int
puthash (hash_table *table, const void *key, void *value)
{
  unsigned long hash = table->hash (key);
  unsigned long size = table->size;
  unsigned long n;
  bucket *b;
  if (size < (1 + ((13 * table->count) / 10)))
    {
      int status;
      status = growhash (table, size + 1);
      if (status < 0) return status;
      size = table->size;
    }
  n = hash % size;
  b = &table->buckets[n];
  if (b->key &&
      key != b->key &&
      table->compare (key, b->key) != 0)
    {
      unsigned long h2 = size - 2;
      unsigned long i = (hash % h2) + 1;
      do
 {
   n += i;
   if (n >= size) n -= size;
   b = &table->buckets [n];
 }
      while (b->key &&
      key != b->key &&
      table->compare (key, b->key) != 0);
    }
  if (!b->key)
    table->count++;
  b->key = key;
  b->value = value;
  return 0;
}

canonical_original_code:
int puthash(struct hash_table *table, void *key, void *value)
{
  unsigned long hash = table->hash (key);
  unsigned long size = table->size;
  unsigned long n;
  struct bucket *b;
  if (size < (1 + ((13 * table->count) / 10)))
    {
      int status;
      status = growhash (table, size + 1);
      if (status < 0) return status;
      size = table->size;
    }
  n = hash % size;
  b = &table->buckets[n];
  if (b->key &&
      key != b->key &&
      table->compare (key, b->key) != 0)
    {
      unsigned long h2 = size - 2;
      unsigned long i = (hash % h2) + 1;
      do
 {
   n += i;
   if (n >= size) n -= size;
   b = &table->buckets [n];
 }
      while (b->key &&
      key != b->key &&
      table->compare (key, b->key) != 0);
    }
  if (!b->key)
    table->count++;
  b->key = key;
  b->value = value;
  return 0;
}

variable_types:
key
void *

variable_types:
value
void *

variable_types:
hash
unsigned long

variable_types:
n
unsigned long

variable_types: struct bucket { void *key; void *value; } *

variable_types:
i
unsigned long


growhash

original_code:
static int
growhash (hash_table *table, unsigned long new_size)
{
  unsigned long i;
  unsigned long old_size = table->size;
  bucket *old_buckets = table->buckets;
  bucket *new_buckets;
  new_size = toprime (new_size);
  new_buckets = (bucket *) calloc(new_size, sizeof(*table->buckets));
  if (!new_buckets)
    return -1;
  table->size = new_size;
  table->buckets = new_buckets;
  table->count = 0;
  for (i = 0; i < old_size; i++)
    if (old_buckets[i].key)
      puthash (table, old_buckets[i].key, old_buckets[i].value);
  free (old_buckets);
  return 0;
}

canonical_original_code:
static int growhash(struct hash_table *table, unsigned long new_size)
{
  unsigned long i;
  unsigned long old_size = table->size;
  struct bucket *old_buckets = table->buckets;
  struct bucket *new_buckets;
  new_size = toprime (new_size);
  new_buckets = (struct bucket *) calloc(new_size, sizeof(*table->buckets));
  if (!new_buckets)
    return -1;
  table->size = new_size;
  table->buckets = new_buckets;
  table->count = 0;
  for (i = 0; i < old_size; i++)
    if (old_buckets[i].key)
      puthash (table, old_buckets[i].key, old_buckets[i].value);
  free (old_buckets);
  return 0;
}


gethash

original_code:
void *
gethash (hash_table *table, const void *key, void *def)
{
  unsigned long hash = table->hash (key);
  unsigned long size = table->size;
  unsigned long n = hash % size;
  bucket *b = &table->buckets[n];
  if (b->key &&
      key != b->key &&
      table->compare (key, b->key) != 0)
    {
      unsigned long h2 = size - 2;
      unsigned long i = (hash % h2) + 1;
      do
 {
   n += i;
   if (n >= size) n -= size;
   b = &table->buckets [n];
 }
      while (b->key &&
      key != b->key &&
      table->compare (key, b->key) != 0);
    }
  return b->value;
}

canonical_original_code:
void *gethash(struct hash_table *table, void *key, void *def)
{
  unsigned long hash = table->hash (key);
  unsigned long size = table->size;
  unsigned long n = hash % size;
  struct bucket *b = &table->buckets[n];
  if (b->key &&
      key != b->key &&
      table->compare (key, b->key) != 0)
    {
      unsigned long h2 = size - 2;
      unsigned long i = (hash % h2) + 1;
      do
 {
   n += i;
   if (n >= size) n -= size;
   b = &table->buckets [n];
 }
      while (b->key &&
      key != b->key &&
      table->compare (key, b->key) != 0);
    }
  return b->value;
}

variable_types:
def
void *


maphash

decompiled_code:
__int64 __fastcall maphash(_QWORD *a1, __int64 (__fastcall *a2)(_QWORD, _QWORD, __int64), __int64 a3)
{
__int64 result; // rax
__int64 v5; // rbx
_QWORD *v6; // rax

result = 0LL;
if ( a1 )
{
if ( *a1 )
{
v5 = 0LL;
while ( 1 )
{
v6 = (_QWORD *)(a1[4] + 16 * v5);
if ( *v6 )
{
result = a2(*v6, v6[1], a3);
if ( (_DWORD)result )
break;
}
if ( *a1 <= (unsigned __int64)++v5 )
return 0LL;
}
}
else
{
result = 0LL;
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func6(_QWORD *a1, __int64 (__fastcall *a2)(_QWORD, _QWORD, __int64), __int64 a3)
{
__int64 result; // rax
__int64 v5; // rbx
_QWORD *v6; // rax

result = 0LL;
if ( a1 )
{
if ( *a1 )
{
v5 = 0LL;
while ( 1 )
{
v6 = (_QWORD *)(a1[4] + 16 * v5);
if ( *v6 )
{
result = a2(*v6, v6[1], a3);
if ( (_DWORD)result )
break;
}
if ( *a1 <= (unsigned __int64)++v5 )
return 0LL;
}
}
else
{
result = 0LL;
}
}
return result;
}

original_code:
int
maphash (hash_table *table,
  int (*mapper) (const void *key, const void *value, void *arg),
  void *arg)
{
  unsigned long i;
  int status;
  if (table)
    for (i = 0; i < table->size; i++)
      if (table->buckets[i].key)
 {
   status = mapper (table->buckets[i].key, table->buckets[i].value,arg);
   if (status != 0) return status;
 }
  return 0;
}

canonical_original_code:
int maphash(struct hash_table *table, int (*mapper)(void *key, void *value, void *arg), void *arg)
{
  unsigned long i;
  int status;
  if (table)
    for (i = 0; i < table->size; i++)
      if (table->buckets[i].key)
 {
   status = mapper (table->buckets[i].key, table->buckets[i].value,arg);
   if (status != 0) return status;
 }
  return 0;
}

variable_types: int (*)(void *key, void *value, void *arg)

variable_types:
arg
void *

variable_types: status int


decompiled_code:
unsigned __int64 __fastcall string_hash(unsigned __int8 *a1)
{
unsigned __int8 v1; // dl
unsigned __int8 *v2; // rdi
unsigned __int64 result; // rax
unsigned __int8 v4; // dl

if ( !a1 )
return 0LL;
v1 = *a1;
v2 = a1 + 1;
result = v1;
if ( !v1 )
return 0LL;
while ( 1 )
{
v4 = *v2;
if ( !*v2 )
break;
++v2;
result = v4 + 16 * result;
if ( (result & 0xF0000000) != 0 )
result = ((unsigned __int64)((unsigned int)result & 0xF0000000) >> 24) ^ result & 0xFFFFFFFF0FFFFFFFLL;
}
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func7(unsigned __int8 *a1)
{
unsigned __int8 v1; // dl
unsigned __int8 *v2; // rdi
unsigned __int64 result; // rax
unsigned __int8 v4; // dl

if ( !a1 )
return 0LL;
v1 = *a1;
v2 = a1 + 1;
result = v1;
if ( !v1 )
return 0LL;
while ( 1 )
{
v4 = *v2;
if ( !*v2 )
break;
++v2;
result = v4 + 16 * result;
if ( (result & 0xF0000000) != 0 )
result = ((unsigned __int64)((unsigned int)result & 0xF0000000) >> 24) ^ result & 0xFFFFFFFF0FFFFFFFLL;
}
return result;
}

original_code:
unsigned long
string_hash (const unsigned char *x)
{
  unsigned long g, h = 0;
  if (!x) return 0;
  while (*x != 0)
    {
      h = (h << 4) + *x++;
      if ((g = h & 0xf0000000) != 0)
 h = (h ^ (g >> 24)) ^ g;
    }
  return h;
}

canonical_original_code:
unsigned long string_hash(unsigned char *x)
{
  unsigned long g; unsigned long h = 0;
  if (!x) return 0;
  while (*x != 0)
    {
      h = (h << 4) + *x++;
      if ((g = h & 0xf0000000) != 0)
 h = (h ^ (g >> 24)) ^ g;
    }
  return h;
}

variable_types:
x
unsigned char *

variable_types:
g
unsigned long

variable_types:
h
unsigned long


decompiled_code:
unsigned __int64 __fastcall string_case_hash(unsigned __int8 *a1)
{
unsigned __int8 *v1; // rbp
unsigned __int8 v2; // bl
const __int32_t *v3; // rcx
unsigned __int64 result; // rax

if ( !a1 )
return 0LL;
v1 = a1;
v2 = *a1;
if ( !*a1 )
return 0LL;
v3 = *_ctype_toupper_loc();
result = 0LL;
do
{
++v1;
result = v3[v2] + 16 * result;
if ( (result & 0xF0000000) != 0 )
result = ((unsigned __int64)((unsigned int)result & 0xF0000000) >> 24) ^ result & 0xFFFFFFFF0FFFFFFFLL;
v2 = *v1;
}
while ( *v1 );
return result;
}

canonical_decompiled_code:
unsigned __int64 __fastcall func8(unsigned __int8 *a1)
{
unsigned __int8 *v1; // rbp
unsigned __int8 v2; // bl
const __int32_t *v3; // rcx
unsigned __int64 result; // rax

if ( !a1 )
return 0LL;
v1 = a1;
v2 = *a1;
if ( !*a1 )
return 0LL;
v3 = *_ctype_toupper_loc();
result = 0LL;
do
{
++v1;
result = v3[v2] + 16 * result;
if ( (result & 0xF0000000) != 0 )
result = ((unsigned __int64)((unsigned int)result & 0xF0000000) >> 24) ^ result & 0xFFFFFFFF0FFFFFFFLL;
v2 = *v1;
}
while ( *v1 );
return result;
}

original_code:
unsigned long
string_case_hash (const unsigned char *x)
{
  unsigned long g, h = 0;
  if (!x) return 0;
  while (*x != 0)
    {
      h = (h << 4) + toupper(*x++);
      if ((g = h & 0xf0000000) != 0)
 h = (h ^ (g >> 24)) ^ g;
    }
  return h;
}

canonical_original_code:
unsigned long string_case_hash(unsigned char *x)
{
  unsigned long g; unsigned long h = 0;
  if (!x) return 0;
  while (*x != 0)
    {
      h = (h << 4) + toupper(*x++);
      if ((g = h & 0xf0000000) != 0)
 h = (h ^ (g >> 24)) ^ g;
    }
  return h;
}


increment

original_code:
static int
increment (pword *pword, pword_link **listP, int *lengthP, int *sizeP)
{
  int size = *sizeP;
  int length = *lengthP;
  pword_link *list = *listP;
  int bot = 0;
  int top = length;
  while (top > bot)
    {
      int mid = ((top - bot) >> 1) + bot;
      if (pword == list[mid].word)
 {
   list[mid].count++;
   return 0;
 }
      else if (pword < list[mid].word)
 top = mid;
      else if (bot == mid)
 break;
      else
 bot = mid;
    }
  if (size == 0)
    {
      size = 10;
      list = (pword_link *) calloc (size, sizeof(*list));
      if (!list) return 0;
      *listP = list;
      *sizeP = size;
    }
  else if (length+1 >= size)
    {
      size = (((*sizeP + 10) * 13) / 10);
      list = (pword_link *) realloc (list, size * sizeof(*list));
      if (!list) return 0;
      memset (list+length, 0, (size-length) * sizeof(*list));
      *listP = list;
      *sizeP = size;
    }
  if (top != length)
    memmove (list+top+1, list+top, (length - top) * sizeof(*list));
  total_links++;
  (*lengthP)++;
  list[top].word = pword;
  list[top].count = 1;
  return 0;
}

canonical_original_code:
static int increment(struct pword *pword, struct pword_link **listP, int *lengthP, int *sizeP)
{
  int size = *sizeP;
  int length = *lengthP;
  struct pword_link *list = *listP;
  int bot = 0;
  int top = length;
  while (top > bot)
    {
      int mid = ((top - bot) >> 1) + bot;
      if (pword == list[mid].word)
 {
   list[mid].count++;
   return 0;
 }
      else if (pword < list[mid].word)
 top = mid;
      else if (bot == mid)
 break;
      else
 bot = mid;
    }
  if (size == 0)
    {
      size = 10;
      list = (struct pword_link *) calloc (size, sizeof(*list));
      if (!list) return 0;
      *listP = list;
      *sizeP = size;
    }
  else if (length+1 >= size)
    {
      size = (((*sizeP + 10) * 13) / 10);
      list = (struct pword_link *) realloc (list, size * sizeof(*list));
      if (!list) return 0;
      memset (list+length, 0, (size-length) * sizeof(*list));
      *listP = list;
      *sizeP = size;
    }
  if (top != length)
    memmove (list+top+1, list+top, (length - top) * sizeof(*list));
  total_links++;
  (*lengthP)++;
  list[top].word = pword;
  list[top].count = 1;
  return 0;
}

variable_types: struct pword { int id; unsigned char *string; int count; int start; int cap; int comma; int period; int quem; int bang; struct pword_link { int count; struct pword *word; } *succ; int succ_length; int succ_size; } *

variable_types:
listP
struct pword_link **

variable_types:
lengthP
int *

variable_types:
sizeP
int *

variable_types: size int

variable_types: length int

variable_types: struct pword_link { int count; struct pword { int id; unsigned char *string; int count; int start; int cap; int comma; int period; int quem; int bang; struct pword_link *succ; int succ_length; int succ_size; } *word; } *

variable_types: bot int

variable_types: top int

variable_types: mid int


original_code:
unsigned int
ya_random (void)
{
  register int ret = a[i1] + a[i2];
  a[i1] = ret;
  if (++i1 >= 55) i1 = 0;
  if (++i2 >= 55) i2 = 0;
  return ret;
}

canonical_original_code:
unsigned int ya_random()
{
  register int ret = a[i1] + a[i2];
  a[i1] = ret;
  if (++i1 >= 55) i1 = 0;
  if (++i2 >= 55) i2 = 0;
  return ret;
}

variable_types: ret int

return_type: unsigned int


decompiled_code:
__int64 __fastcall ya_rand_init(int a1)
{
int *v1; // rax
__int64 result; // rax
int v3; // ebx
struct timezone tz; // [rsp+8h] [rbp-20h] BYREF
struct timeval tv; // [rsp+10h] [rbp-18h] BYREF

if ( !a1 )
{
gettimeofday(&tv, &tz);
v3 = 999 * LODWORD(tv.tv_sec) + 1001 * LODWORD(tv.tv_usec);
a1 = v3 + 1003 * getpid();
}
a[0] += a1;
v1 = (int *)&unk_124;
do
{
a1 = 1001 * *(v1 - 1) + 999 * a1;
*v1++ += a1;
}
while ( v1 != &i2 );
i1 = a[0] % 0x37u;
result = (unsigned int)((int)(a[0] % 0x37u + 20) % 55);
i2 = (int)(a[0] % 0x37u + 20) % 55;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(int a1)
{
int *v1; // rax
__int64 result; // rax
int v3; // ebx
struct timezone tz; // [rsp+8h] [rbp-20h] BYREF
struct timeval tv; // [rsp+10h] [rbp-18h] BYREF

if ( !a1 )
{
gettimeofday(&tv, &tz);
v3 = 999 * LODWORD(tv.tv_sec) + 1001 * LODWORD(tv.tv_usec);
a1 = v3 + 1003 * getpid();
}
a[0] += a1;
v1 = (int *)&unk_124;
do
{
a1 = 1001 * *(v1 - 1) + 999 * a1;
*v1++ += a1;
}
while ( v1 != &i2 );
i1 = a[0] % 0x37u;
result = (unsigned int)((int)(a[0] % 0x37u + 20) % 55);
i2 = (int)(a[0] % 0x37u + 20) % 55;
return result;
}

original_code:
void
ya_rand_init(unsigned int seed)
{
  int i;
  if (seed == 0)
    {
      struct timeval tp;
      struct timezone tzp;
      gettimeofday(&tp, &tzp);
      seed = (999*tp.tv_sec) + (1001*tp.tv_usec) + (1003 * getpid());
    }
  a[0] += seed;
  for (i = 1; i < 55; i++)
    {
      seed = a[i-1]*1001 + seed*999;
      a[i] += seed;
    }
  i1 = a[0] % 55;
  i2 = (i1 + 024) % 55;
}

variable_types:
seed
unsigned int

variable_types: i int

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

variable_types: struct timezone { int tz_minuteswest; int tz_dsttime; }


decompiled_code:
__int64 random_first_word()
{
int *v0; // rbx
int v1; // edx
__int64 result; // rax

v0 = (int *)starters;
v1 = (ya_random() & 0x7FFFFFFFuLL) % (unsigned int)total_starters;
do
{
result = all_words + 56LL * *v0;
v1 -= *(_DWORD *)(result + 8);
++v0;
}
while ( v1 > 0 );
return result;
}

canonical_decompiled_code:
__int64 func0()
{
int *v0; // rbx
int v1; // edx
__int64 result; // rax

v0 = (int *)starters;
v1 = (ya_random() & 0x7FFFFFFFuLL) % (unsigned int)total_starters;
do
{
result = all_words + 56LL * *v0;
v1 -= *(_DWORD *)(result + 8);
++v0;
}
while ( v1 > 0 );
return result;
}

original_code:
static word *
random_first_word (void)
{
  word *w = 0;
  int *s = starters;
  int i = ((ya_random() & 0x7FFFFFFF) % (total_starters));
  do {
    w = &all_words[*s];
    i -= w->start;
    s++;
  } while (i > 0);
  return w;
}

canonical_original_code:
static struct word *random_first_word()
{
  struct word *w = 0;
  int *s = starters;
  int i = ((ya_random() & 0x7FFFFFFF) % (total_starters));
  do {
    w = &all_words[*s];
    i -= w->start;
    s++;
  } while (i > 0);
  return w;
}

variable_types: struct word { int string; int count; int start; int cap; int comma; int period; int quem; int bang; int succ_length; struct word_link { int count; int word; } *succ; } *

variable_types:
s
int *

user_defined_types: struct word { int string; int count; int start; int cap; int comma; int period; int quem; int bang; int succ_length; struct word_link *succ; }


decompiled_code:
__int64 __fastcall random_linked(_DWORD *a1, int a2)
{
_DWORD *v2; // rbp
_DWORD *v3; // rax
__int64 v4; // rbx
unsigned int v5; // er12
int v6; // edx
_DWORD *v7; // rax

if ( a2 <= 0 )
{
ya_random();
goto LABEL_9;
}
v2 = a1;
v3 = a1;
v4 = (__int64)&a1[2 * (a2 - 1) + 2];
v5 = 0;
do
{
v5 += *v3;
v3 += 2;
}
while ( v3 != (_DWORD *)v4 );
v6 = (ya_random() & 0x7FFFFFFFuLL) % v5 - *a1;
v7 = a1 + 2;
if ( v6 > 0 )
{
while ( v7 != (_DWORD *)v4 )
{
v2 = v7;
v6 -= *v7;
v7 += 2;
if ( v6 <= 0 )
return all_words + 56LL * (int)v2[1];
}
LABEL_9:
abort();
}
return all_words + 56LL * (int)v2[1];
}

canonical_decompiled_code:
__int64 __fastcall func1(_DWORD *a1, int a2)
{
_DWORD *v2; // rbp
_DWORD *v3; // rax
__int64 v4; // rbx
unsigned int v5; // er12
int v6; // edx
_DWORD *v7; // rax

if ( a2 <= 0 )
{
ya_random();
goto LABEL_9;
}
v2 = a1;
v3 = a1;
v4 = (__int64)&a1[2 * (a2 - 1) + 2];
v5 = 0;
do
{
v5 += *v3;
v3 += 2;
}
while ( v3 != (_DWORD *)v4 );
v6 = (ya_random() & 0x7FFFFFFFuLL) % v5 - *a1;
v7 = a1 + 2;
if ( v6 > 0 )
{
while ( v7 != (_DWORD *)v4 )
{
v2 = v7;
v6 -= *v7;
v7 += 2;
if ( v6 <= 0 )
return all_words + 56LL * (int)v2[1];
}
LABEL_9:
abort();
}
return all_words + 56LL * (int)v2[1];
}

original_code:
static word *
random_linked (word_link *links, int link_length)
{
  int i;
  int count = 0;
  for (i = 0; i < link_length; i++)
    count += links[i].count;
  count = ((ya_random() & 0x7FFFFFFF) % (count));
  for (i = 0; i < link_length; i++)
    {
      count -= links[i].count;
      if (count <= 0)
 return &all_words [links[i].word];
    }
  abort();
}

canonical_original_code:
static struct word *random_linked(struct word_link *links, int link_length)
{
  int i;
  int count = 0;
  for (i = 0; i < link_length; i++)
    count += links[i].count;
  count = ((ya_random() & 0x7FFFFFFF) % (count));
  for (i = 0; i < link_length; i++)
    {
      count -= links[i].count;
      if (count <= 0)
 return &all_words [links[i].word];
    }
  abort();
}

variable_types:
links
struct word_link *

variable_types: count int

return_type: struct word { int string; int count; int start; int cap; int comma; int period; int quem; int bang; int succ_length; struct word_link { int count; int word; } *succ; } *


decompiled_code:
__int64 __fastcall random_next_word(__int64 a1)
{
int v1; // esi
char v2; // dl
__int64 result; // rax
__int64 v4; // rbx
int v5; // eax
__int64 v6; // rax

if ( !*(_DWORD *)(a1 + 36)
|| (v5 = ya_random(), (v5 & 0x7FFFFFFF) != 10 * ((v5 & 0x7FFFFFFFu) / 0xA))
|| (v6 = random_linked(*(_DWORD **)(a1 + 48), *(_DWORD *)(a1 + 36)), result = random_next_word(v6), a1 == result) )
{
v1 = *(_DWORD *)(a1 + 32);
if ( v1 )
{
result = random_linked(*(_DWORD **)(a1 + 40), v1);
}
else
{
v2 = ya_random();
result = 0LL;
if ( (v2 & 3) != 0 )
{
v4 = all_words;
result = v4 + 56 * ((ya_random() & 0x7FFFFFFFuLL) % total_words);
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int64 a1)
{
int v1; // esi
char v2; // dl
__int64 result; // rax
__int64 v4; // rbx
int v5; // eax
__int64 v6; // rax

if ( !*(_DWORD *)(a1 + 36)
|| (v5 = ya_random(), (v5 & 0x7FFFFFFF) != 10 * ((v5 & 0x7FFFFFFFu) / 0xA))
|| (v6 = func1(*(_DWORD **)(a1 + 48), *(_DWORD *)(a1 + 36)), result = func2(v6), a1 == result) )
{
v1 = *(_DWORD *)(a1 + 32);
if ( v1 )
{
result = func1(*(_DWORD **)(a1 + 40), v1);
}
else
{
v2 = ya_random();
result = 0LL;
if ( (v2 & 3) != 0 )
{
v4 = all_words;
result = v4 + 56 * ((ya_random() & 0x7FFFFFFFuLL) % total_words);
}
}
}
return result;
}

original_code:
static word *
random_next_word (word *w)
{
  if (w->pred_length && !(((ya_random() & 0x7FFFFFFF) % (10))))
    {
      word *w2 = random_next_word (random_linked (w->pred, w->pred_length));
      if (w != w2)
 return w2;
    }
  if (w->succ_length)
    return random_linked (w->succ, w->succ_length);
  else if (ya_random() % 4)
    return &all_words[((ya_random() & 0x7FFFFFFF) % (total_words))];
  else
    return 0;
}

canonical_original_code:
static struct word *random_next_word(struct word *w)
{
  if (w->pred_length && !(((ya_random() & 0x7FFFFFFF) % (10))))
    {
      struct word *w2 = random_next_word (random_linked (w->pred, w->pred_length));
      if (w != w2)
 return w2;
    }
  if (w->succ_length)
    return random_linked (w->succ, w->succ_length);
  else if (ya_random() % 4)
    return &all_words[((ya_random() & 0x7FFFFFFF) % (total_words))];
  else
    return 0;
}

variable_types:
w
struct word *

user_defined_types: struct word_link { int count; int word; }


repo: dynup/kpatch

decompiled_code:
__int64 __fastcall inat_last_prefix_id(char a1)
{
__int64 result; // rax

result = a1 & 0xF;
if ( (a1 & 0xC) != 0 )
result = 0LL;
return result;
}

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

result = a1 & 0xF;
if ( (a1 & 0xC) != 0 )
result = 0LL;
return result;
}

original_code:
static inline int inat_last_prefix_id(insn_attr_t attr)
{
 if ((attr & (((1 << 4) - 1) << 0)) > 3)
  return 0;
 else
  return attr & (((1 << 4) - 1) << 0);
}

canonical_original_code:
static inline int inat_last_prefix_id(unsigned int attr)
{
 if ((attr & (((1 << 4) - 1) << 0)) > 3)
  return 0;
 else
  return attr & (((1 << 4) - 1) << 0);
}

variable_types:
attr
unsigned int


decompiled_code:
__int64 __fastcall inat_escape_id(unsigned int a1)
{
return (a1 >> 4) & 3;
}

canonical_decompiled_code:
__int64 __fastcall func1(unsigned int a1)
{
return (a1 >> 4) & 3;
}

original_code:
static inline int inat_escape_id(insn_attr_t attr)
{
 return (attr & (((1 << 2) - 1) << (0 + 4))) >> (0 + 4);
}

canonical_original_code:
static inline int inat_escape_id(unsigned int attr)
{
 return (attr & (((1 << 2) - 1) << (0 + 4))) >> (0 + 4);
}


decompiled_code:
__int64 __fastcall inat_is_group(__int16 a1)
{
return a1 & 0x7C0;
}

canonical_decompiled_code:
__int64 __fastcall func2(__int16 a1)
{
return a1 & 0x7C0;
}

original_code:
static inline int inat_is_group(insn_attr_t attr)
{
 return attr & (((1 << 5) - 1) << ((0 + 4) + 2));
}

canonical_original_code:
static inline int inat_is_group(unsigned int attr)
{
 return attr & (((1 << 5) - 1) << ((0 + 4) + 2));
}


decompiled_code:
__int64 __fastcall inat_group_id(unsigned int a1)
{
return (a1 >> 6) & 0x1F;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int a1)
{
return (a1 >> 6) & 0x1F;
}

original_code:
static inline int inat_group_id(insn_attr_t attr)
{
 return (attr & (((1 << 5) - 1) << ((0 + 4) + 2))) >> ((0 + 4) + 2);
}

canonical_original_code:
static inline int inat_group_id(unsigned int attr)
{
 return (attr & (((1 << 5) - 1) << ((0 + 4) + 2))) >> ((0 + 4) + 2);
}


decompiled_code:
__int64 __fastcall inat_group_common_attribute(int a1)
{
return a1 & 0xFFFFF83F;
}

canonical_decompiled_code:
__int64 __fastcall func4(int a1)
{
return a1 & 0xFFFFF83F;
}

original_code:
static inline int inat_group_common_attribute(insn_attr_t attr)
{
 return attr & ~(((1 << 5) - 1) << ((0 + 4) + 2));
}

canonical_original_code:
static inline int inat_group_common_attribute(unsigned int attr)
{
 return attr & ~(((1 << 5) - 1) << ((0 + 4) + 2));
}


decompiled_code:
__int64 __fastcall inat_has_variant(int a1)
{
return a1 & 0x40000;
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1)
{
return a1 & 0x40000;
}

original_code:
static inline int inat_has_variant(insn_attr_t attr)
{
 return attr & (1 << (((((0 + 4) + 2) + 5) + 3) + 4));
}

canonical_original_code:
static inline int inat_has_variant(unsigned int attr)
{
 return attr & (1 << (((((0 + 4) + 2) + 5) + 3) + 4));
}


decompiled_code:
__int64 __fastcall inat_get_opcode_attribute(unsigned __int8 a1)
{
return (unsigned int)inat_primary_table[a1];
}

canonical_decompiled_code:
__int64 __fastcall func6(unsigned __int8 a1)
{
return (unsigned int)inat_primary_table[a1];
}

original_code:
insn_attr_t inat_get_opcode_attribute(insn_byte_t opcode)
{
 return inat_primary_table[opcode];
}

canonical_original_code:
unsigned int inat_get_opcode_attribute(unsigned char opcode)
{
 return inat_primary_table[opcode];
}

variable_types:
opcode
unsigned char


decompiled_code:
__int64 __fastcall inat_get_last_prefix_id(unsigned __int8 a1)
{
char v1; // al

v1 = inat_get_opcode_attribute(a1);
return inat_last_prefix_id(v1);
}

canonical_decompiled_code:
__int64 __fastcall func7(unsigned __int8 a1)
{
char v1; // al

v1 = func6(a1);
return func0(v1);
}

original_code:
int inat_get_last_prefix_id(insn_byte_t last_pfx)
{
 insn_attr_t lpfx_attr;
 lpfx_attr = inat_get_opcode_attribute(last_pfx);
 return inat_last_prefix_id(lpfx_attr);
}

canonical_original_code:
int inat_get_last_prefix_id(unsigned char last_pfx)
{
 unsigned int lpfx_attr;
 lpfx_attr = inat_get_opcode_attribute(last_pfx);
 return inat_last_prefix_id(lpfx_attr);
}


decompiled_code:
__int64 __fastcall inat_get_escape_attribute(unsigned __int8 a1, int a2, unsigned int a3)
{
int v3; // ebp
__int64 v4; // r13
int v5; // eax
__int64 result; // rax

v3 = inat_escape_id(a3);
v4 = inat_escape_tables[4 * v3];
if ( !v4 )
return 0LL;
v5 = inat_has_variant(*(_DWORD *)(v4 + 4LL * a1));
if ( a2 && v5 && (v4 = inat_escape_tables[4 * v3 + a2]) == 0 )
result = 0LL;
else
result = *(unsigned int *)(v4 + 4LL * a1);
return result;
}

canonical_decompiled_code:
__int64 __fastcall func8(unsigned __int8 a1, int a2, unsigned int a3)
{
int v3; // ebp
__int64 v4; // r13
int v5; // eax
__int64 result; // rax

v3 = func1(a3);
v4 = inat_escape_tables[4 * v3];
if ( !v4 )
return 0LL;
v5 = func5(*(_DWORD *)(v4 + 4LL * a1));
if ( a2 && v5 && (v4 = inat_escape_tables[4 * v3 + a2]) == 0 )
result = 0LL;
else
result = *(unsigned int *)(v4 + 4LL * a1);
return result;
}

original_code:
insn_attr_t inat_get_escape_attribute(insn_byte_t opcode, int lpfx_id,
          insn_attr_t esc_attr)
{
 const insn_attr_t *table;
 int n;
 n = inat_escape_id(esc_attr);
 table = inat_escape_tables[n][0];
 if (!table)
  return 0;
 if (inat_has_variant(table[opcode]) && lpfx_id) {
  table = inat_escape_tables[n][lpfx_id];
  if (!table)
   return 0;
 }
 return table[opcode];
}

canonical_original_code:
unsigned int inat_get_escape_attribute(unsigned char opcode, int lpfx_id, unsigned int esc_attr)
{
 unsigned int *table;
 int n;
 n = inat_escape_id(esc_attr);
 table = inat_escape_tables[n][0];
 if (!table)
  return 0;
 if (inat_has_variant(table[opcode]) && lpfx_id) {
  table = inat_escape_tables[n][lpfx_id];
  if (!table)
   return 0;
 }
 return table[opcode];
}

variable_types:
table
unsigned int *

variable_types: n int


decompiled_code:
__int64 __fastcall inat_get_group_attribute(unsigned int a1, int a2, unsigned int a3)
{
int v4; // er12
__int64 v5; // r14
unsigned int v6; // ebx
int v7; // eax
__int64 result; // rax

v4 = inat_group_id(a3);
v5 = inat_group_tables[4 * v4];
if ( v5
&& ((v6 = (a1 >> 3) & 7, v7 = inat_has_variant(*(_DWORD *)(v5 + 4LL * v6)), !a2)
|| !v7
|| (v5 = inat_group_tables[4 * v4 + a2]) != 0) )
{
result = *(_DWORD *)(v5 + 4LL * v6) | (unsigned int)inat_group_common_attribute(a3);
}
else
{
result = inat_group_common_attribute(a3);
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func9(unsigned int a1, int a2, unsigned int a3)
{
int v4; // er12
__int64 v5; // r14
unsigned int v6; // ebx
int v7; // eax
__int64 result; // rax

v4 = func3(a3);
v5 = inat_group_tables[4 * v4];
if ( v5
&& ((v6 = (a1 >> 3) & 7, v7 = func5(*(_DWORD *)(v5 + 4LL * v6)), !a2)
|| !v7
|| (v5 = inat_group_tables[4 * v4 + a2]) != 0) )
{
result = *(_DWORD *)(v5 + 4LL * v6) | (unsigned int)func4(a3);
}
else
{
result = func4(a3);
}
return result;
}

original_code:
insn_attr_t inat_get_group_attribute(insn_byte_t modrm, int lpfx_id,
         insn_attr_t grp_attr)
{
 const insn_attr_t *table;
 int n;
 n = inat_group_id(grp_attr);
 table = inat_group_tables[n][0];
 if (!table)
  return inat_group_common_attribute(grp_attr);
 if (inat_has_variant(table[(((modrm) & 0x38) >> 3)]) && lpfx_id) {
  table = inat_group_tables[n][lpfx_id];
  if (!table)
   return inat_group_common_attribute(grp_attr);
 }
 return table[(((modrm) & 0x38) >> 3)] |
        inat_group_common_attribute(grp_attr);
}

canonical_original_code:
unsigned int inat_get_group_attribute(unsigned char modrm, int lpfx_id, unsigned int grp_attr)
{
 unsigned int *table;
 int n;
 n = inat_group_id(grp_attr);
 table = inat_group_tables[n][0];
 if (!table)
  return inat_group_common_attribute(grp_attr);
 if (inat_has_variant(table[(((modrm) & 0x38) >> 3)]) && lpfx_id) {
  table = inat_group_tables[n][lpfx_id];
  if (!table)
   return inat_group_common_attribute(grp_attr);
 }
 return table[(((modrm) & 0x38) >> 3)] |
        inat_group_common_attribute(grp_attr);
}

variable_types:
modrm
unsigned char