decompiled_code:
__int64 __fastcall SCPI_Control(__int64 a1, unsigned int a2, unsigned __int16 a3)
{
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax
__int64 v12; // rax

if ( a2 == 1 )
{
v3 = std::operator<<<std::char_traits<char>>(&std::cerr, "**SRQ: 0x");
}
else
{
v10 = std::operator<<<std::char_traits<char>>(&std::cerr, "**CTRL: ");
v11 = std::ostream::operator<<(v10, std::hex);
v12 = std::ostream::operator<<(v11, a2);
v3 = std::operator<<<std::char_traits<char>>(v12, ": 0x");
}
v4 = std::ostream::operator<<(v3, std::hex);
v5 = std::ostream::operator<<(v4, a3);
v6 = std::operator<<<std::char_traits<char>>(v5, "(");
v7 = std::ostream::operator<<(v6, std::dec);
v8 = std::ostream::operator<<(v7, a3);
v9 = std::operator<<<std::char_traits<char>>(v8, ")");
std::ostream::operator<<(v9, &std::endl<char,std::char_traits<char>>);
return 1LL;
}

canonical_decompiled_code:
__int64 __fastcall func3(__int64 a1, unsigned int a2, unsigned __int16 a3)
{
__int64 v3; // rax
__int64 v4; // rax
__int64 v5; // rax
__int64 v6; // rax
__int64 v7; // rax
__int64 v8; // rax
__int64 v9; // rax
__int64 v10; // rax
__int64 v11; // rax
__int64 v12; // rax

if ( a2 == 1 )
{
v3 = std::operator<<<std::char_traits<char>>(&std::cerr, "**SRQ: 0x");
}
else
{
v10 = std::operator<<<std::char_traits<char>>(&std::cerr, "**CTRL: ");
v11 = std::ostream::operator<<(v10, std::hex);
v12 = std::ostream::operator<<(v11, a2);
v3 = std::operator<<<std::char_traits<char>>(v12, ": 0x");
}
v4 = std::ostream::operator<<(v3, std::hex);
v5 = std::ostream::operator<<(v4, a3);
v6 = std::operator<<<std::char_traits<char>>(v5, "(");
v7 = std::ostream::operator<<(v6, std::dec);
v8 = std::ostream::operator<<(v7, a3);
v9 = std::operator<<<std::char_traits<char>>(v8, ")");
std::ostream::operator<<(v9, &std::endl<char,std::char_traits<char>>);
return 1LL;
}

variable_types: enum _scpi_ctrl_name_t { SCPI_CTRL_SRQ=1, SCPI_CTRL_GTL=2, SCPI_CTRL_SDC=3, SCPI_CTRL_PPC=4, SCPI_CTRL_GET=5, SCPI_CTRL_TCT=6, SCPI_CTRL_LLO=7, SCPI_CTRL_DCL=8, SCPI_CTRL_PPU=9, SCPI_CTRL_SPE=10, SCPI_CTRL_SPD=11, SCPI_CTRL_MLA=12, SCPI_CTRL_UNL=13, SCPI_CTRL_MTA=14, SCPI_CTRL_UNT=15, SCPI_CTRL_MSA=16 }

variable_types:
val
unsigned short

user_defined_types: struct _scpi_buffer_t { unsigned long length; unsigned long position; char *data; }

user_defined_types: struct _scpi_token_t { enum _scpi_token_type_t type; char *ptr; int len; }


decompiled_code:
__int64 SCPI_Reset()
{
__int64 v0; // rax

v0 = std::operator<<<std::char_traits<char>>(&std::cerr, "**Reset");
std::ostream::operator<<(v0, &std::endl<char,std::char_traits<char>>);
return 1LL;
}

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

v0 = std::operator<<<std::char_traits<char>>(&std::cerr, "**Reset");
std::ostream::operator<<(v0, &std::endl<char,std::char_traits<char>>);
return 1LL;
}

original_code:
scpi_result_t SCPI_Reset(scpi_t * context) {
    (void) context;
    fprintf(stderr, "**Reset\r\n");
    return SCPI_RES_OK;
}

canonical_original_code:
enum _scpi_result_t SCPI_Reset(struct _scpi_t *context) {
    (void) context;
    fprintf(stderr, "**Reset\r\n");
    return SCPI_RES_OK;
}

variable_types: struct _scpi_t { struct _scpi_command_t { char *pattern; enum _scpi_result_t { SCPI_RES_OK=1, SCPI_RES_ERR=-1 } (*callback)(struct _scpi_t *); int tag; } *cmdlist; struct _scpi_buffer_t { unsigned long length; unsigned long position; char *data; } buffer; struct _scpi_param_list_t { struct _scpi_command_t *cmd; struct _lex_state_t { char *buffer; char *pos; int len; } lex_state; struct _scpi_const_buffer_t { unsigned long length; unsigned long position; char *data; } cmd_raw; } param_list; struct _scpi_interface_t { int (*error)(struct _scpi_t *context, long error); unsigned long (*write)(struct _scpi_t *context, char *data, unsigned long len); enum _scpi_result_t { SCPI_RES_OK=1, SCPI_RES_ERR=-1 } (*control)(struct _scpi_t *context, enum _scpi_ctrl_name_t { SCPI_CTRL_SRQ=1, SCPI_CTRL_GTL=2, SCPI_CTRL_SDC=3, SCPI_CTRL_PPC=4, SCPI_CTRL_GET=5, SCPI_CTRL_TCT=6, SCPI_CTRL_LLO=7, SCPI_CTRL_DCL=8, SCPI_CTRL_PPU=9, SCPI_CTRL_SPE=10, SCPI_CTRL_SPD=11, SCPI_CTRL_MLA=12, SCPI_CTRL_UNL=13, SCPI_CTRL_MTA=14, SCPI_CTRL_UNT=15, SCPI_CTRL_MSA=16 } ctrl, unsigned short val); enum _scpi_result_t { SCPI_RES_OK=1, SCPI_RES_ERR=-1 } (*flush)(struct _scpi_t *); enum _scpi_result_t { SCPI_RES_OK=1, SCPI_RES_ERR=-1 } (*reset)(struct _scpi_t *); } *interface; long output_count; long input_count; _Bool first_output; _Bool cmd_error; struct _scpi_fifo_t { short wr; short rd; short count; short size; struct _scpi_error_t { short error_code; char *device_dependent_info; } *data; } error_queue; unsigned short registers[-1]; struct _scpi_unit_def_t { char *name; enum _scpi_unit_t { SCPI_UNIT_NONE=0, SCPI_UNIT_VOLT=1, SCPI_UNIT_AMPER=2, SCPI_UNIT_OHM=3, SCPI_UNIT_HERTZ=4, SCPI_UNIT_CELSIUS=5, SCPI_UNIT_SECOND=6, SCPI_UNIT_METER=7, SCPI_UNIT_GRAY=8, SCPI_UNIT_BECQUEREL=9, SCPI_UNIT_MOLE=10, SCPI_UNIT_DEGREE=11, SCPI_UNIT_GRADE=12, SCPI_UNIT_RADIAN=13, SCPI_UNIT_REVOLUTION=14, SCPI_UNIT_STERADIAN=15, SCPI_UNIT_SIEVERT=16, SCPI_UNIT_FARAD=17, SCPI_UNIT_COULOMB=18, SCPI_UNIT_SIEMENS=19, SCPI_UNIT_ELECTRONVOLT=20, SCPI_UNIT_JOULE=21, SCPI_UNIT_NEWTON=22, SCPI_UNIT_LUX=23, SCPI_UNIT_HENRY=24, SCPI_UNIT_ASTRONOMIC_UNIT=25, SCPI_UNIT_INCH=26, SCPI_UNIT_FOOT=27, SCPI_UNIT_PARSEC=28, SCPI_UNIT_MILE=29, SCPI_UNIT_NAUTICAL_MILE=30, SCPI_UNIT_LUMEN=31, SCPI_UNIT_CANDELA=32, SCPI_UNIT_WEBER=33, SCPI_UNIT_TESLA=34, SCPI_UNIT_ATOMIC_MASS=35, SCPI_UNIT_KILOGRAM=36, SCPI_UNIT_WATT=37, SCPI_UNIT_DBM=38, SCPI_UNIT_ATMOSPHERE=39, SCPI_UNIT_INCH_OF_MERCURY=40, SCPI_UNIT_MM_OF_MERCURY=41, SCPI_UNIT_PASCAL=42, SCPI_UNIT_TORT=43, SCPI_UNIT_BAR=44, SCPI_UNIT_DECIBEL=45, SCPI_UNIT_UNITLESS=46, SCPI_UNIT_FAHRENHEIT=47, SCPI_UNIT_KELVIN=48, SCPI_UNIT_DAY=49, SCPI_UNIT_YEAR=50, SCPI_UNIT_STROKES=51, SCPI_UNIT_POISE=52, SCPI_UNIT_LITER=53 } unit; double mult; } *units; void *user_context; struct _scpi_parser_state_t { struct _scpi_token_t { enum _scpi_token_type_t { SCPI_TOKEN_COMMA=0, SCPI_TOKEN_SEMICOLON=1, SCPI_TOKEN_COLON=2, SCPI_TOKEN_SPECIFIC_CHARACTER=3, SCPI_TOKEN_QUESTION=4, SCPI_TOKEN_NL=5, SCPI_TOKEN_HEXNUM=6, SCPI_TOKEN_OCTNUM=7, SCPI_TOKEN_BINNUM=8, SCPI_TOKEN_PROGRAM_MNEMONIC=9, SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA=10, SCPI_TOKEN_DECIMAL_NUMERIC_PROGRAM_DATA_WITH_SUFFIX=11, SCPI_TOKEN_SUFFIX_PROGRAM_DATA=12, SCPI_TOKEN_ARBITRARY_BLOCK_PROGRAM_DATA=13, SCPI_TOKEN_SINGLE_QUOTE_PROGRAM_DATA=14, SCPI_TOKEN_DOUBLE_QUOTE_PROGRAM_DATA=15, SCPI_TOKEN_PROGRAM_EXPRESSION=16, SCPI_TOKEN_COMPOUND_PROGRAM_HEADER=17, SCPI_TOKEN_INCOMPLETE_COMPOUND_PROGRAM_HEADER=18, SCPI_TOKEN_COMMON_PROGRAM_HEADER=19, SCPI_TOKEN_INCOMPLETE_COMMON_PROGRAM_HEADER=20, SCPI_TOKEN_COMPOUND_QUERY_PROGRAM_HEADER=21, SCPI_TOKEN_COMMON_QUERY_PROGRAM_HEADER=22, SCPI_TOKEN_WS=23, SCPI_TOKEN_ALL_PROGRAM_DATA=24, SCPI_TOKEN_INVALID=25, SCPI_TOKEN_UNKNOWN=26 } type; char *ptr; int len; } programHeader; struct _scpi_token_t programData; int numberOfParameters; enum _message_termination_t { SCPI_MESSAGE_TERMINATION_NONE=0, SCPI_MESSAGE_TERMINATION_NL=1, SCPI_MESSAGE_TERMINATION_SEMICOLON=2 } termination; } parser_state; char *idn[4]; unsigned long arbitrary_remaining; } *

user_defined_types: struct _scpi_t { struct _scpi_command_t *cmdlist; struct _scpi_buffer_t buffer; struct _scpi_param_list_t param_list; struct _scpi_interface_t *interface; long output_count; long input_count; _Bool first_output; _Bool cmd_error; struct _scpi_fifo_t error_queue; unsigned short registers[-1]; struct _scpi_unit_def_t *units; void *user_context; struct _scpi_parser_state_t parser_state; char *idn[4]; unsigned long arbitrary_remaining; }

user_defined_types: struct _scpi_param_list_t { struct _scpi_command_t *cmd; struct _lex_state_t lex_state; struct _scpi_const_buffer_t cmd_raw; }

user_defined_types: struct _scpi_fifo_t { short wr; short rd; short count; short size; struct _scpi_error_t *data; }

user_defined_types: struct _scpi_parser_state_t { struct _scpi_token_t programHeader; struct _scpi_token_t programData; int numberOfParameters; enum _message_termination_t termination; }

user_defined_types: struct _scpi_command_t { char *pattern; enum _scpi_result_t (*callback)(struct _scpi_t *); int tag; }

user_defined_types: struct _scpi_interface_t { int (*error)(struct _scpi_t *context, long error); unsigned long (*write)(struct _scpi_t *context, char *data, unsigned long len); enum _scpi_result_t (*control)(struct _scpi_t *context, enum _scpi_ctrl_name_t ctrl, unsigned short val); enum _scpi_result_t (*flush)(struct _scpi_t *); enum _scpi_result_t (*reset)(struct _scpi_t *); }

user_defined_types: struct _scpi_unit_def_t { char *name; enum _scpi_unit_t unit; double mult; }


decompiled_code:
size_t mod_exp()
{
__gmpz_init();
fwrite(&unk_402004, 1uLL, 3uLL, _bss_start);
__gmpz_out_str();
fwrite(&unk_402008, 1uLL, 2uLL, _bss_start);
fwrite("b: ", 1uLL, 3uLL, _bss_start);
__gmpz_out_str();
fwrite(&unk_402008, 1uLL, 2uLL, _bss_start);
fwrite("c: ", 1uLL, 3uLL, _bss_start);
__gmpz_out_str();
fwrite(&unk_402008, 1uLL, 2uLL, _bss_start);
__gmpz_powm();
fwrite("(a^b)modc: ", 1uLL, 0xBuLL, _bss_start);
__gmpz_out_str();
return fwrite(&unk_402008, 1uLL, 2uLL, _bss_start);
}

canonical_decompiled_code:
size_t func7()
{
__gmpz_init();
fwrite(&unk_402004, 1uLL, 3uLL, _bss_start);
__gmpz_out_str();
fwrite(&unk_402008, 1uLL, 2uLL, _bss_start);
fwrite("b: ", 1uLL, 3uLL, _bss_start);
__gmpz_out_str();
fwrite(&unk_402008, 1uLL, 2uLL, _bss_start);
fwrite("c: ", 1uLL, 3uLL, _bss_start);
__gmpz_out_str();
fwrite(&unk_402008, 1uLL, 2uLL, _bss_start);
__gmpz_powm();
fwrite("(a^b)modc: ", 1uLL, 0xBuLL, _bss_start);
__gmpz_out_str();
return fwrite(&unk_402008, 1uLL, 2uLL, _bss_start);
}

original_code:
void mod_exp(mpz_t a, mpz_t b, mpz_t c) {
   mpz_t res;
   __gmpz_init(res);
   fprintf(stdout, "a: ");
   __gmpz_out_str(stdout, 10, a);
   fprintf(stdout, "\n\n");
   fprintf(stdout, "b: ");
   __gmpz_out_str(stdout, 10, b);
   fprintf(stdout, "\n\n");
   fprintf(stdout, "c: ");
   __gmpz_out_str(stdout, 10, c);
   fprintf(stdout, "\n\n");
   __gmpz_powm(res, a, b, c);
   fprintf(stdout, "(a^b)modc: ");
   __gmpz_out_str(stdout, 10, res);
   fprintf(stdout, "\n\n");
}

canonical_original_code:
void mod_exp(struct __mpz_struct a[1], struct __mpz_struct b[1], struct __mpz_struct c[1]) {
   struct __mpz_struct res[1];
   __gmpz_init(res);
   fprintf(stdout, "a: ");
   __gmpz_out_str(stdout, 10, a);
   fprintf(stdout, "\n\n");
   fprintf(stdout, "b: ");
   __gmpz_out_str(stdout, 10, b);
   fprintf(stdout, "\n\n");
   fprintf(stdout, "c: ");
   __gmpz_out_str(stdout, 10, c);
   fprintf(stdout, "\n\n");
   __gmpz_powm(res, a, b, c);
   fprintf(stdout, "(a^b)modc: ");
   __gmpz_out_str(stdout, 10, res);
   fprintf(stdout, "\n\n");
}

variable_types: struct __mpz_struct { int _mp_alloc; int _mp_size; unsigned long *_mp_d; } [1]

variable_types:
b
struct __mpz_struct [1]

variable_types:
c
struct __mpz_struct [1]

return_type: void


decompiled_code:
int read_write_large_ints()
{
__gmpz_init();
read_large_int("largeint.txt");
__gmp_randinit_mt();
__gmp_randseed();
fwrite("read from file: ", 1uLL, 0x10uLL, _bss_start);
__gmpz_out_str();
fwrite(&unk_402008, 1uLL, 2uLL, _bss_start);
__gmpz_urandomb();
fwrite("writing to file: ", 1uLL, 0x11uLL, _bss_start);
__gmpz_out_str();
fwrite(&unk_402008, 1uLL, 2uLL, _bss_start);
return write_large_int("largeint.txt");
}

canonical_decompiled_code:
int func12()
{
__gmpz_init();
func10("largeint.txt");
__gmp_randinit_mt();
__gmp_randseed();
fwrite("read from file: ", 1uLL, 0x10uLL, _bss_start);
__gmpz_out_str();
fwrite(&unk_402008, 1uLL, 2uLL, _bss_start);
__gmpz_urandomb();
fwrite("writing to file: ", 1uLL, 0x11uLL, _bss_start);
__gmpz_out_str();
fwrite(&unk_402008, 1uLL, 2uLL, _bss_start);
return func11("largeint.txt");
}

original_code:
void read_write_large_ints() {
   mpz_t i;
   __gmpz_init(i);
   read_large_int("largeint.txt", i);
   gmp_randstate_t randstate;
   __gmp_randinit_mt(randstate);
   __gmp_randseed(randstate, i);
   fprintf(stdout, "read from file: ");
   __gmpz_out_str(stdout, 10, i);
   fprintf(stdout, "\n\n");
   __gmpz_urandomb(i, randstate, 512);
   fprintf(stdout, "writing to file: ");
   __gmpz_out_str(stdout, 10, i);
   fprintf(stdout, "\n\n");
   write_large_int("largeint.txt", i);
}

canonical_original_code:
void read_write_large_ints() {
   struct __mpz_struct i[1];
   __gmpz_init(i);
   read_large_int("largeint.txt", i);
   struct __gmp_randstate_struct randstate[1];
   __gmp_randinit_mt(randstate);
   __gmp_randseed(randstate, i);
   fprintf(stdout, "read from file: ");
   __gmpz_out_str(stdout, 10, i);
   fprintf(stdout, "\n\n");
   __gmpz_urandomb(i, randstate, 512);
   fprintf(stdout, "writing to file: ");
   __gmpz_out_str(stdout, 10, i);
   fprintf(stdout, "\n\n");
   write_large_int("largeint.txt", i);
}

variable_types: struct __gmp_randstate_struct { struct __mpz_struct { int _mp_alloc; int _mp_size; unsigned long *_mp_d; } _mp_seed[1]; enum gmp_randalg_t { GMP_RAND_ALG_DEFAULT=0, GMP_RAND_ALG_LC=expr } _mp_alg; union { void *_mp_lc; } _mp_algdata; } [1]

user_defined_types: struct __gmp_randstate_struct { struct __mpz_struct _mp_seed[1]; enum gmp_randalg_t _mp_alg; union { void *_mp_lc; } _mp_algdata; }


main

canonical_name: main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__gmpz_init();
__gmpz_init();
__gmpz_init();
__gmp_randinit_mt();
time(0LL);
__gmp_randseed_ui();
__gmpz_urandomb();
__gmpz_urandomb();
__gmpz_urandomb();
basic_gmp();
fputc(10, _bss_start);
read_write_large_ints();
add_subtract_multiply();
mod_exp();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
__gmpz_init();
__gmpz_init();
__gmpz_init();
__gmp_randinit_mt();
time(0LL);
__gmp_randseed_ui();
__gmpz_urandomb();
__gmpz_urandomb();
__gmpz_urandomb();
func9();
fputc(10, _bss_start);
func12();
func8();
func7();
return 0;
}

original_code:
int main() {
   mpz_t a;
   mpz_t b;
   mpz_t c;
   __gmpz_init(a);
   __gmpz_init(b);
   __gmpz_init(c);
   mp_bitcnt_t num_bits = 512;
   gmp_randstate_t randstate;
   __gmp_randinit_mt(randstate);
   __gmp_randseed_ui(randstate, time(0));
   __gmpz_urandomb(a, randstate, num_bits);
   __gmpz_urandomb(b, randstate, num_bits);
   __gmpz_urandomb(c, randstate, num_bits);
   basic_gmp();
   fprintf(stdout, "\n");
   read_write_large_ints();
   add_subtract_multiply(a, b);
   mod_exp(a, b, c);
   return 0;
}

canonical_original_code:
int main() {
   struct __mpz_struct a[1];
   struct __mpz_struct b[1];
   struct __mpz_struct c[1];
   __gmpz_init(a);
   __gmpz_init(b);
   __gmpz_init(c);
   unsigned long num_bits = 512;
   struct __gmp_randstate_struct randstate[1];
   __gmp_randinit_mt(randstate);
   __gmp_randseed_ui(randstate, time(0));
   __gmpz_urandomb(a, randstate, num_bits);
   __gmpz_urandomb(b, randstate, num_bits);
   __gmpz_urandomb(c, randstate, num_bits);
   basic_gmp();
   fprintf(stdout, "\n");
   read_write_large_ints();
   add_subtract_multiply(a, b);
   mod_exp(a, b, c);
   return 0;
}

return_type: int

user_defined_types: struct __mpz_struct { int _mp_alloc; int _mp_size; unsigned long *_mp_d; }

user_defined_types: enum gmp_randalg_t { GMP_RAND_ALG_DEFAULT=0, GMP_RAND_ALG_LC=expr }


gcd

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

if ( !(_DWORD)a1 || !(_DWORD)a2 )
return 0LL;
if ( (((unsigned __int8)a2 | (unsigned __int8)a1) & 1) == 0 )
return 2 * (unsigned int)gcd((unsigned int)((int)a1 / 2), (unsigned int)((int)a2 / 2));
if ( (a1 & 1) == 0 && (a2 & 1) != 0 )
return gcd((unsigned int)((int)a1 / 2), a2);
if ( (a2 & 1) == 0 && (a1 & 1) != 0 )
return gcd(a1, (unsigned int)((int)a2 / 2));
result = (unsigned int)a2;
if ( (_DWORD)a1 != (_DWORD)a2 )
{
if ( (int)a1 >= (int)a2 )
result = gcd((unsigned int)(((int)a1 - (int)a2) / 2), a2);
else
result = gcd((unsigned int)(((int)a2 - (int)a1) / 2), (unsigned int)a1);
}
return result;
}

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

if ( !(_DWORD)a1 || !(_DWORD)a2 )
return 0LL;
if ( (((unsigned __int8)a2 | (unsigned __int8)a1) & 1) == 0 )
return 2 * (unsigned int)func7((unsigned int)((int)a1 / 2), (unsigned int)((int)a2 / 2));
if ( (a1 & 1) == 0 && (a2 & 1) != 0 )
return func7((unsigned int)((int)a1 / 2), a2);
if ( (a2 & 1) == 0 && (a1 & 1) != 0 )
return func7(a1, (unsigned int)((int)a2 / 2));
result = (unsigned int)a2;
if ( (_DWORD)a1 != (_DWORD)a2 )
{
if ( (int)a1 >= (int)a2 )
result = func7((unsigned int)(((int)a1 - (int)a2) / 2), a2);
else
result = func7((unsigned int)(((int)a2 - (int)a1) / 2), (unsigned int)a1);
}
return result;
}

original_code:
int gcd(int a, int b) {
   int a_even = (a%2 == 0);
   int b_even = (b%2 == 0);
   if (a == 0 || b == 0)
      return 0;
   if (a_even && b_even) {
      return 2*gcd(a/2, b/2);
   }
   else if (a_even && !b_even) {
      return gcd(a/2, b);
   }
   else if (!a_even && b_even) {
      return gcd(a, b/2);
   }
   else {
      if (a == b)
         return a;
      else if (a < b)
         return gcd((b-a)/2, a);
      else
         return gcd((a-b)/2, b);
   }
}

variable_types: a int

variable_types: b int


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
unsigned int v4; // ebp
unsigned int v5; // ebx
unsigned int v6; // eax

v3 = time(0LL);
srand(v3);
v4 = rand();
v5 = rand();
puts("my gcd function");
v6 = gcd(v4, v5);
printf("gcd of %d and %d is: %d\n\n", v4, v5, v6);
__gmpz_init();
__gmpz_init();
__gmpz_init();
__gmpz_set_ui();
__gmpz_set_ui();
__gmpz_gcd();
puts("gmp gcd function");
printf("gcd of ");
__gmpz_out_str();
printf(" and ");
__gmpz_out_str();
printf(" is: ");
__gmpz_out_str();
putchar(10);
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
unsigned int v3; // eax
unsigned int v4; // ebp
unsigned int v5; // ebx
unsigned int v6; // eax

v3 = time(0LL);
srand(v3);
v4 = rand();
v5 = rand();
puts("my gcd function");
v6 = func7(v4, v5);
printf("gcd of %d and %d is: %d\n\n", v4, v5, v6);
__gmpz_init();
__gmpz_init();
__gmpz_init();
__gmpz_set_ui();
__gmpz_set_ui();
__gmpz_gcd();
puts("gmp gcd function");
printf("gcd of ");
__gmpz_out_str();
printf(" and ");
__gmpz_out_str();
printf(" is: ");
__gmpz_out_str();
putchar(10);
return 0;
}

original_code:
int main() {
   srand(time(0));
   int a = rand();
   int b = rand();
   printf("my gcd function\n");
   printf("gcd of %d and %d is: %d\n\n", a, b, gcd(a, b));
   mpz_t mpz_a;
   mpz_t mpz_b;
   mpz_t mpz_result;
   __gmpz_init(mpz_a);
   __gmpz_init(mpz_b);
   __gmpz_init(mpz_result);
   __gmpz_set_ui(mpz_a, a);
   __gmpz_set_ui(mpz_b, b);
   __gmpz_gcd(mpz_result, mpz_a, mpz_b);
   printf("gmp gcd function\n");
   printf("gcd of ");
   __gmpz_out_str(stdout, 10, mpz_a);
   printf(" and ");
   __gmpz_out_str(stdout, 10, mpz_b);
   printf(" is: ");
   __gmpz_out_str(stdout, 10, mpz_result);
   printf("\n");
   return 0;
}

canonical_original_code:
int main() {
   srand(time(0));
   int a = rand();
   int b = rand();
   printf("my gcd function\n");
   printf("gcd of %d and %d is: %d\n\n", a, b, gcd(a, b));
   struct __mpz_struct mpz_a[1];
   struct __mpz_struct mpz_b[1];
   struct __mpz_struct mpz_result[1];
   __gmpz_init(mpz_a);
   __gmpz_init(mpz_b);
   __gmpz_init(mpz_result);
   __gmpz_set_ui(mpz_a, a);
   __gmpz_set_ui(mpz_b, b);
   __gmpz_gcd(mpz_result, mpz_a, mpz_b);
   printf("gmp gcd function\n");
   printf("gcd of ");
   __gmpz_out_str(stdout, 10, mpz_a);
   printf(" and ");
   __gmpz_out_str(stdout, 10, mpz_b);
   printf(" is: ");
   __gmpz_out_str(stdout, 10, mpz_result);
   printf("\n");
   return 0;
}


loop

repo: jabberx/snaps

decompiled_code:
void loop()
{
float v0; // xmm0_4
float v1; // xmm0_4
int v2; // eax
int v3; // edx
char v4[264]; // [rsp+0h] [rbp-108h] BYREF

while ( !exit_flag )
{
if ( last_ticks_3 == -1 )
last_ticks_3 = SDL_GetTicks();
SDL_HandleEvents();
mouse_look();
if ( KEY[66] )
{
v0 = (double)delta_2 * 0.05;
fly_forward(v0);
}
if ( KEY[62] )
{
v1 = (double)delta_2 * -0.05;
fly_forward(v1);
}
if ( KEY[5] )
exit_flag = 1;
clear_zbuffer();
clear_img(3466633376LL);
if ( KEY[113] )
fill_holes();
SDL_FlipScreen();
v2 = SDL_GetTicks();
v3 = v2 - last_ticks_3;
delta_2 = v3;
last_ticks_3 = v2;
if ( v3 <= 15 )
{
SDL_Delay((unsigned int)(16 - v3));
delta_2 = 16;
}
if ( ++fps_upd_cnt_0 > 10 )
{
fps_upd_cnt_0 = 0;
sprintf(v4, "fps: %d yaw: %.0f pit: %.0f", (unsigned int)(1000 / delta_2), yaw, pitch);
SDL_WM_SetCaption(v4, 0LL);
}
}
}

canonical_decompiled_code:
void func0()
{
float v0; // xmm0_4
float v1; // xmm0_4
int v2; // eax
int v3; // edx
char v4[264]; // [rsp+0h] [rbp-108h] BYREF

while ( !exit_flag )
{
if ( last_ticks_3 == -1 )
last_ticks_3 = SDL_GetTicks();
SDL_HandleEvents();
mouse_look();
if ( KEY[66] )
{
v0 = (double)delta_2 * 0.05;
fly_forward(v0);
}
if ( KEY[62] )
{
v1 = (double)delta_2 * -0.05;
fly_forward(v1);
}
if ( KEY[5] )
exit_flag = 1;
clear_zbuffer();
clear_img(3466633376LL);
if ( KEY[113] )
fill_holes();
SDL_FlipScreen();
v2 = SDL_GetTicks();
v3 = v2 - last_ticks_3;
delta_2 = v3;
last_ticks_3 = v2;
if ( v3 <= 15 )
{
SDL_Delay((unsigned int)(16 - v3));
delta_2 = 16;
}
if ( ++fps_upd_cnt_0 > 10 )
{
fps_upd_cnt_0 = 0;
sprintf(v4, "fps: %d yaw: %.0f pit: %.0f", (unsigned int)(1000 / delta_2), yaw, pitch);
SDL_WM_SetCaption(v4, 0LL);
}
}
}

original_code:
void loop() { while(!exit_flag)
{
 static int32_t delta=16, last_ticks=-1, ticks;
 static int32_t fps_upd_cnt = 0;
 static int32_t taken = 0;
 if (last_ticks == -1) last_ticks = SDL_GetTicks();
 SDL_HandleEvents();
 mouse_look();
 if (KEY[key_w]) fly_forward(delta*0.05);
 if (KEY[key_s]) fly_forward(delta*-0.05);
 if (KEY[ESCAPE]) exit_flag=1;
 clear_zbuffer();
 clear_img(0xCEA0A0A0);
 if (KEY[CAPSLOCK]) fill_holes();
 SDL_FlipScreen();
 ticks = SDL_GetTicks();
 delta = ticks - last_ticks;
 last_ticks = ticks;
 if (delta<16){ SDL_Delay(16-delta); delta = 16; }
 fps_upd_cnt++;
 if (fps_upd_cnt>10) {
  fps_upd_cnt = 0;
  char buffer[256];
  sprintf(buffer,"fps: %d yaw: %.0f pit: %.0f", 1000/delta, yaw, pitch);
  SDL_WM_SetCaption(buffer, ((void *)0));
 }
}}

canonical_original_code:
void loop() { while(!exit_flag)
{
 static int delta = 16; static int last_ticks = -1; static int ticks;
 static int fps_upd_cnt = 0;
 static int taken = 0;
 if (last_ticks == -1) last_ticks = SDL_GetTicks();
 SDL_HandleEvents();
 mouse_look();
 if (KEY[key_w]) fly_forward(delta*0.05);
 if (KEY[key_s]) fly_forward(delta*-0.05);
 if (KEY[ESCAPE]) exit_flag=1;
 clear_zbuffer();
 clear_img(0xCEA0A0A0);
 if (KEY[CAPSLOCK]) fill_holes();
 SDL_FlipScreen();
 ticks = SDL_GetTicks();
 delta = ticks - last_ticks;
 last_ticks = ticks;
 if (delta<16){ SDL_Delay(16-delta); delta = 16; }
 fps_upd_cnt++;
 if (fps_upd_cnt>10) {
  fps_upd_cnt = 0;
  char buffer[256];
  sprintf(buffer,"fps: %d yaw: %.0f pit: %.0f", 1000/delta, yaw, pitch);
  SDL_WM_SetCaption(buffer, ((void *)0));
 }
}}

variable_types: delta int

variable_types: ticks int

variable_types: taken int

variable_types:
buffer
char [256]


main

decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
int v4; // er13
size_t v5; // rbp

SDL_Initialize(argc, argv, envp);
SDL_WM_SetCaption("test", 0LL);
v3 = WIDTH;
v4 = HEIGHT;
v5 = HEIGHT * WIDTH;
zbuffer = malloc(4 * v5);
Xbuf = malloc(4 * v5);
Ybuf = malloc(4 * v5);
Zbuf = malloc(4 * v5);
NXbuf = malloc(v5);
NYbuf = malloc(v5);
NZbuf = malloc(v5);
SHbuf = malloc(v5);
SDL_ShowCursor(0LL);
SDL_WarpMouse((unsigned __int16)(v3 / 2), (unsigned __int16)(v4 / 2));
loop();
return 0;
}

canonical_decompiled_code:
int __cdecl main(int argc, const char **argv, const char **envp)
{
int v3; // ebx
int v4; // er13
size_t v5; // rbp

SDL_Initialize(argc, argv, envp);
SDL_WM_SetCaption("test", 0LL);
v3 = WIDTH;
v4 = HEIGHT;
v5 = HEIGHT * WIDTH;
zbuffer = malloc(4 * v5);
Xbuf = malloc(4 * v5);
Ybuf = malloc(4 * v5);
Zbuf = malloc(4 * v5);
NXbuf = malloc(v5);
NYbuf = malloc(v5);
NZbuf = malloc(v5);
SHbuf = malloc(v5);
SDL_ShowCursor(0LL);
SDL_WarpMouse((unsigned __int16)(v3 / 2), (unsigned __int16)(v4 / 2));
func0();
return 0;
}

original_code:
int main(int argc, char **argv)
{
 SDL_Initialize();
 SDL_WM_SetCaption("test", ((void *)0));
 zbuffer = (float*) malloc(WIDTH*HEIGHT*sizeof(float));
 Xbuf = (int32_t*) malloc(WIDTH*HEIGHT*4);
 Ybuf = (int32_t*) malloc(WIDTH*HEIGHT*4);
 Zbuf = (int32_t*) malloc(WIDTH*HEIGHT*4);
 NXbuf = (int8_t*) malloc(WIDTH*HEIGHT);
 NYbuf = (int8_t*) malloc(WIDTH*HEIGHT);
 NZbuf = (int8_t*) malloc(WIDTH*HEIGHT);
 SHbuf = (uint8_t*) malloc(WIDTH*HEIGHT);
 SDL_ShowCursor(0);
 SDL_WarpMouse(WIDTH/2, HEIGHT/2);
 loop();
 return 0;
}

canonical_original_code:
int main(int argc, char **argv)
{
 SDL_Initialize();
 SDL_WM_SetCaption("test", ((void *)0));
 zbuffer = (float *) malloc(WIDTH*HEIGHT*sizeof(float));
 Xbuf = (int *) malloc(WIDTH*HEIGHT*4);
 Ybuf = (int *) malloc(WIDTH*HEIGHT*4);
 Zbuf = (int *) malloc(WIDTH*HEIGHT*4);
 NXbuf = (char *) malloc(WIDTH*HEIGHT);
 NYbuf = (char *) malloc(WIDTH*HEIGHT);
 NZbuf = (char *) malloc(WIDTH*HEIGHT);
 SHbuf = (unsigned char *) malloc(WIDTH*HEIGHT);
 SDL_ShowCursor(0);
 SDL_WarpMouse(WIDTH/2, HEIGHT/2);
 loop();
 return 0;
}

variable_types: argc int

variable_types:
argv
char **


decompiled_code:
float __fastcall p_d(float a1)
{
return (float)((float)((float)((float)(a1 * 6.0) - 15.0) * a1) + 10.0) * (float)(a1 * (float)(a1 * a1));
}

canonical_decompiled_code:
float __fastcall func0(float a1)
{
return (float)((float)((float)((float)(a1 * 6.0) - 15.0) * a1) + 10.0) * (float)(a1 * (float)(a1 * a1));
}

original_code: float p_d(float t){return t*t*t*(t*(t*6-15)+10);}

variable_types: t float

return_type: float


decompiled_code:
float __fastcall p_l(float a1, float a2, float a3)
{
return (float)((float)(a3 - a2) * a1) + a2;
}

canonical_decompiled_code:
float __fastcall func1(float a1, float a2, float a3)
{
return (float)((float)(a3 - a2) * a1) + a2;
}

original_code:
float p_l(float t,
float a,float b){return a+t*(b-a);}

canonical_original_code: float p_l(float t, float a, float b){return a+t*(b-a);}

variable_types: a float

variable_types: b float


decompiled_code:
__int64 noise_init()
{
__int64 i; // rbx
__int64 result; // rax

p_p = (__int64)malloc(0x800uLL);
for ( i = 0LL; i != 1024; i += 4LL )
{
result = (unsigned int)((int)randm() % 256);
*(_DWORD *)(p_p + i) = result;
*(_DWORD *)(p_p + i + 1024) = result;
}
return result;
}

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

p_p = (__int64)malloc(0x800uLL);
for ( i = 0LL; i != 1024; i += 4LL )
{
result = (unsigned int)((int)randm() % 256);
*(_DWORD *)(p_p + i) = result;
*(_DWORD *)(p_p + i + 1024) = result;
}
return result;
}

original_code:
void noise_init(){int i;p_p=(int*)malloc(512*sizeof(int));for (i=0;i<256;i++)
p_p[256+i]=p_p[i]=randm()%256;}

canonical_original_code:
void noise_init(){int i;p_p=(int *)malloc(512*sizeof(int));for (i=0;i<256;i++)
p_p[256+i]=p_p[i]=randm()%256;}

variable_types: i int


decompiled_code:
unsigned int *__fastcall render_scene(_QWORD *a1, unsigned int *a2, __m128i a3, __m128i a4)
{
unsigned int v4; // er14
__int64 i; // rbx
__int64 v6; // r12
_WORD *v7; // r15
_WORD *v8; // r15
_WORD *v9; // r15
_WORD *v10; // r12
unsigned int *result; // rax
__int64 v12; // [rsp+0h] [rbp-48h]

v4 = *a2;
clear_zbuffer();
clear_img(3466633376LL);
yaw = _mm_cvtsi128_si32(a3);
pitch = _mm_cvtsi128_si32(a4);
compute_yp();
render_cloud(&cloud, 0LL, 0LL, 0LL, 1LL);
if ( HEIGHT * WIDTH )
{
v12 = (unsigned int)(HEIGHT * WIDTH - 1);
for ( i = 0LL; ; ++i )
{
if ( *(_DWORD *)(img + 4 * i) != -828333920 )
{
v6 = 2LL * v4;
v7 = (_WORD *)(a1[2] + v6);
*v7 = shrink(*(unsigned int *)(Xbuf + 4 * i), shrink_val);
v8 = (_WORD *)(a1[3] + v6);
*v8 = shrink(*(unsigned int *)(Ybuf + 4 * i), shrink_val);
v9 = (_WORD *)(a1[4] + v6);
*v9 = shrink(*(unsigned int *)(Zbuf + 4 * i), shrink_val);
*(_BYTE *)(a1[6] + v4) = *(_BYTE *)(NXbuf + i);
*(_BYTE *)(a1[7] + v4) = *(_BYTE *)(NYbuf + i);
*(_BYTE *)(a1[8] + v4) = *(_BYTE *)(NZbuf + i);
*(_BYTE *)(a1[9] + v4) = *(_BYTE *)(SHbuf + i);
v10 = (_WORD *)(a1[5] + v6);
*v10 = true2high(*(unsigned int *)(img + 4 * i));
++v4;
}
if ( i == v12 )
break;
}
}
result = a2;
*a2 = v4;
return result;
}

canonical_decompiled_code:
unsigned int *__fastcall func0(_QWORD *a1, unsigned int *a2, __m128i a3, __m128i a4)
{
unsigned int v4; // er14
__int64 i; // rbx
__int64 v6; // r12
_WORD *v7; // r15
_WORD *v8; // r15
_WORD *v9; // r15
_WORD *v10; // r12
unsigned int *result; // rax
__int64 v12; // [rsp+0h] [rbp-48h]

v4 = *a2;
clear_zbuffer();
clear_img(3466633376LL);
yaw = _mm_cvtsi128_si32(a3);
pitch = _mm_cvtsi128_si32(a4);
compute_yp();
render_cloud(&cloud, 0LL, 0LL, 0LL, 1LL);
if ( HEIGHT * WIDTH )
{
v12 = (unsigned int)(HEIGHT * WIDTH - 1);
for ( i = 0LL; ; ++i )
{
if ( *(_DWORD *)(img + 4 * i) != -828333920 )
{
v6 = 2LL * v4;
v7 = (_WORD *)(a1[2] + v6);
*v7 = shrink(*(unsigned int *)(Xbuf + 4 * i), shrink_val);
v8 = (_WORD *)(a1[3] + v6);
*v8 = shrink(*(unsigned int *)(Ybuf + 4 * i), shrink_val);
v9 = (_WORD *)(a1[4] + v6);
*v9 = shrink(*(unsigned int *)(Zbuf + 4 * i), shrink_val);
*(_BYTE *)(a1[6] + v4) = *(_BYTE *)(NXbuf + i);
*(_BYTE *)(a1[7] + v4) = *(_BYTE *)(NYbuf + i);
*(_BYTE *)(a1[8] + v4) = *(_BYTE *)(NZbuf + i);
*(_BYTE *)(a1[9] + v4) = *(_BYTE *)(SHbuf + i);
v10 = (_WORD *)(a1[5] + v6);
*v10 = true2high(*(unsigned int *)(img + 4 * i));
++v4;
}
if ( i == v12 )
break;
}
}
result = a2;
*a2 = v4;
return result;
}

original_code:
void render_scene(float y, float p, Snapshot *snap, uint32_t *counter)
{
 uint32_t i;
 uint32_t cnt = *counter;
 clear_zbuffer();
 clear_img(0xCEA0A0A0);
 yaw = y;
 pitch = p;
 compute_yp();
 render_cloud(&cloud,0,0,0,1);
 for (i=0; i<WIDTH*HEIGHT; i++) {
  if (img[i] != 0xCEA0A0A0) {
  snap->x[cnt] = shrink(Xbuf[i], shrink_val);
  snap->y[cnt] = shrink(Ybuf[i], shrink_val);
  snap->z[cnt] = shrink(Zbuf[i], shrink_val);
  snap->nx[cnt] = NXbuf[i];
  snap->ny[cnt] = NYbuf[i];
  snap->nz[cnt] = NZbuf[i];
  snap->sh[cnt] = SHbuf[i];
  snap->c[cnt] = true2high(img[i]);
  cnt++; }
 }
 *counter = cnt;
}

canonical_original_code:
void render_scene(float y, float p, struct Snapshot *snap, unsigned int *counter)
{
 unsigned int i;
 unsigned int cnt = *counter;
 clear_zbuffer();
 clear_img(0xCEA0A0A0);
 yaw = y;
 pitch = p;
 compute_yp();
 render_cloud(&cloud,0,0,0,1);
 for (i=0; i<WIDTH*HEIGHT; i++) {
  if (img[i] != 0xCEA0A0A0) {
  snap->x[cnt] = shrink(Xbuf[i], shrink_val);
  snap->y[cnt] = shrink(Ybuf[i], shrink_val);
  snap->z[cnt] = shrink(Zbuf[i], shrink_val);
  snap->nx[cnt] = NXbuf[i];
  snap->ny[cnt] = NYbuf[i];
  snap->nz[cnt] = NZbuf[i];
  snap->sh[cnt] = SHbuf[i];
  snap->c[cnt] = true2high(img[i]);
  cnt++; }
 }
 *counter = cnt;
}

variable_types: y float

variable_types: p float

variable_types: struct Snapshot { unsigned int s; int cx; short *x; unsigned short *c; char *nx; unsigned char *sh; } *

variable_types:
counter
unsigned int *

variable_types:
i
unsigned int

variable_types:
cnt
unsigned int


decompiled_code:
__int64 __fastcall draw_snapshot(unsigned int *a1, int a2)
{
__int64 result; // rax
unsigned int v3; // er12
float v4; // xmm0_4
float v5; // xmm2_4
float v6; // xmm1_4
__int64 v7; // r15
__int64 v8; // r14
unsigned int v9; // er13
int v10; // eax
unsigned int v11; // [rsp+8h] [rbp-60h]
unsigned int v12; // [rsp+Ch] [rbp-5Ch]
unsigned int v13; // [rsp+10h] [rbp-58h]
unsigned int v14; // [rsp+14h] [rbp-54h]
unsigned int v15; // [rsp+18h] [rbp-50h]
unsigned int v16[15]; // [rsp+2Ch] [rbp-3Ch] BYREF

result = *a1;
v15 = result;
if ( (_DWORD)result )
{
v3 = 0;
do
{
v16[0] = high2true(*(unsigned __int16 *)(*((_QWORD *)a1 + 5) + 2LL * v3));
v4 = (double)*(char *)(*((_QWORD *)a1 + 6) + v3) * 0.0078125;
v5 = (double)*(char *)(*((_QWORD *)a1 + 8) + v3) * 0.0078125;
v6 = (double)*(char *)(*((_QWORD *)a1 + 7) + v3) * 0.0078125;
shade_spec(v16, *(unsigned __int8 *)(*((_QWORD *)a1 + 9) + v3), v4, v6, v5, lightx, lighty, lightz);
v7 = *(unsigned __int8 *)(*((_QWORD *)a1 + 9) + v3);
v8 = (unsigned int)*(char *)(*((_QWORD *)a1 + 8) + v3);
v9 = *(char *)(*((_QWORD *)a1 + 7) + v3);
v11 = *(char *)(*((_QWORD *)a1 + 6) + v3);
v12 = v16[0];
v13 = a1[3] + expand((unsigned int)*(__int16 *)(*((_QWORD *)a1 + 4) + 2LL * v3), shrink_val);
v14 = a1[2] + expand((unsigned int)*(__int16 *)(*((_QWORD *)a1 + 3) + 2LL * v3), shrink_val);
v10 = expand((unsigned int)*(__int16 *)(*((_QWORD *)a1 + 2) + 2LL * v3), shrink_val);
result = project(a1[1] + v10, v14, v13, v12, v11, v9, v8, v7);
v3 += a2;
}
while ( v15 > v3 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func3(unsigned int *a1, int a2)
{
__int64 result; // rax
unsigned int v3; // er12
float v4; // xmm0_4
float v5; // xmm2_4
float v6; // xmm1_4
__int64 v7; // r15
__int64 v8; // r14
unsigned int v9; // er13
int v10; // eax
unsigned int v11; // [rsp+8h] [rbp-60h]
unsigned int v12; // [rsp+Ch] [rbp-5Ch]
unsigned int v13; // [rsp+10h] [rbp-58h]
unsigned int v14; // [rsp+14h] [rbp-54h]
unsigned int v15; // [rsp+18h] [rbp-50h]
unsigned int v16[15]; // [rsp+2Ch] [rbp-3Ch] BYREF

result = *a1;
v15 = result;
if ( (_DWORD)result )
{
v3 = 0;
do
{
v16[0] = high2true(*(unsigned __int16 *)(*((_QWORD *)a1 + 5) + 2LL * v3));
v4 = (double)*(char *)(*((_QWORD *)a1 + 6) + v3) * 0.0078125;
v5 = (double)*(char *)(*((_QWORD *)a1 + 8) + v3) * 0.0078125;
v6 = (double)*(char *)(*((_QWORD *)a1 + 7) + v3) * 0.0078125;
shade_spec(v16, *(unsigned __int8 *)(*((_QWORD *)a1 + 9) + v3), v4, v6, v5, lightx, lighty, lightz);
v7 = *(unsigned __int8 *)(*((_QWORD *)a1 + 9) + v3);
v8 = (unsigned int)*(char *)(*((_QWORD *)a1 + 8) + v3);
v9 = *(char *)(*((_QWORD *)a1 + 7) + v3);
v11 = *(char *)(*((_QWORD *)a1 + 6) + v3);
v12 = v16[0];
v13 = a1[3] + expand((unsigned int)*(__int16 *)(*((_QWORD *)a1 + 4) + 2LL * v3), shrink_val);
v14 = a1[2] + expand((unsigned int)*(__int16 *)(*((_QWORD *)a1 + 3) + 2LL * v3), shrink_val);
v10 = expand((unsigned int)*(__int16 *)(*((_QWORD *)a1 + 2) + 2LL * v3), shrink_val);
result = project(a1[1] + v10, v14, v13, v12, v11, v9, v8, v7);
v3 += a2;
}
while ( v15 > v3 );
}
return result;
}

original_code:
void draw_snapshot(Snapshot *snap, const uint32_t skip)
{
 uint32_t i, len = snap->s, color; Color32 c32;
 for (i=0; i<len; i+=skip) {
  c32.col = high2true(snap->c[i]);
  shade_spec(&c32, snap->nx[i]/128.0,
       snap->ny[i]/128.0,
       snap->nz[i]/128.0,
       lightx, lighty, lightz,
       snap->sh[i]);
  project(expand(snap->x[i], shrink_val)+snap->cx,
    expand(snap->y[i], shrink_val)+snap->cy,
    expand(snap->z[i], shrink_val)+snap->cz,
    c32.col,
    snap->nx[i], snap->ny[i], snap->nz[i], snap->sh[i]);
 }
}

canonical_original_code:
void draw_snapshot(struct Snapshot *snap, unsigned int skip)
{
 unsigned int i; unsigned int len = snap->s; unsigned int color; union Color32 c32;
 for (i=0; i<len; i+=skip) {
  c32.col = high2true(snap->c[i]);
  shade_spec(&c32, snap->nx[i]/128.0,
       snap->ny[i]/128.0,
       snap->nz[i]/128.0,
       lightx, lighty, lightz,
       snap->sh[i]);
  project(expand(snap->x[i], shrink_val)+snap->cx,
    expand(snap->y[i], shrink_val)+snap->cy,
    expand(snap->z[i], shrink_val)+snap->cz,
    c32.col,
    snap->nx[i], snap->ny[i], snap->nz[i], snap->sh[i]);
 }
}

variable_types:
skip
unsigned int

variable_types:
len
unsigned int

variable_types:
color
unsigned int

variable_types: union Color32 { unsigned int col; unsigned char rgba[4]; }

user_defined_types: struct Snapshot { unsigned int s; int cx; short *x; unsigned short *c; char *nx; unsigned char *sh; }


decompiled_code:
void clear_zbuffer()
{
__int64 v0; // rcx
__int64 v1; // rax

if ( HEIGHT * WIDTH > 0 )
{
v0 = 4LL * (unsigned int)(HEIGHT * WIDTH);
v1 = 0LL;
do
{
*(_DWORD *)(zbuffer + v1) = LC0;
v1 += 4LL;
}
while ( v1 != v0 );
}
}

canonical_decompiled_code:
void func0()
{
__int64 v0; // rcx
__int64 v1; // rax

if ( HEIGHT * WIDTH > 0 )
{
v0 = 4LL * (unsigned int)(HEIGHT * WIDTH);
v1 = 0LL;
do
{
*(_DWORD *)(zbuffer + v1) = LC0;
v1 += 4LL;
}
while ( v1 != v0 );
}
}

original_code:
void clear_zbuffer()
{
 int x, len = WIDTH*HEIGHT;
 for (x=0;x<len;x++) {
  zbuffer[x] = 100000;
 }
}

canonical_original_code:
void clear_zbuffer()
{
 int x; int len = WIDTH*HEIGHT;
 for (x=0;x<len;x++) {
  zbuffer[x] = 100000;
 }
}

variable_types: x int

variable_types: len int


decompiled_code:
void __fastcall clear_img(int a1)
{
__int64 v1; // rcx
__int64 v2; // rax

if ( HEIGHT * WIDTH > 0 )
{
v1 = 4LL * (unsigned int)(HEIGHT * WIDTH);
v2 = 0LL;
do
{
*(_DWORD *)(img + v2) = a1;
v2 += 4LL;
}
while ( v2 != v1 );
}
}

canonical_decompiled_code:
void __fastcall func1(int a1)
{
__int64 v1; // rcx
__int64 v2; // rax

if ( HEIGHT * WIDTH > 0 )
{
v1 = 4LL * (unsigned int)(HEIGHT * WIDTH);
v2 = 0LL;
do
{
*(_DWORD *)(img + v2) = a1;
v2 += 4LL;
}
while ( v2 != v1 );
}
}

original_code:
void clear_img(const Uint32 color)
{
 int x, len = WIDTH*HEIGHT;
 for (x=0;x<len;x++) {
  img[x] = color;
 }
}

canonical_original_code:
void clear_img(unsigned int color)
{
 int x; int len = WIDTH*HEIGHT;
 for (x=0;x<len;x++) {
  img[x] = color;
 }
}


decompiled_code:
void compute_yp()
{
float v0; // xmm0_4
float v1; // xmm0_4
float v2; // xmm0_4
float v3; // xmm0_4
double v4; // [rsp+8h] [rbp-20h]
double cosx; // [rsp+10h] [rbp-18h] BYREF
double sinx[2]; // [rsp+18h] [rbp-10h] BYREF

sincos(yaw * DTR, sinx, &cosx);
v4 = sinx[0];
v0 = cosx;
cosyaw = LODWORD(v0);
sincos(pitch * DTR, sinx, &cosx);
v1 = cosx;
cospitch = LODWORD(v1);
v2 = v4;
sinyaw = LODWORD(v2);
v3 = sinx[0];
sinpitch = LODWORD(v3);
}

canonical_decompiled_code:
void func2()
{
float v0; // xmm0_4
float v1; // xmm0_4
float v2; // xmm0_4
float v3; // xmm0_4
double v4; // [rsp+8h] [rbp-20h]
double cosx; // [rsp+10h] [rbp-18h] BYREF
double sinx[2]; // [rsp+18h] [rbp-10h] BYREF

sincos(yaw * DTR, sinx, &cosx);
v4 = sinx[0];
v0 = cosx;
cosyaw = LODWORD(v0);
sincos(pitch * DTR, sinx, &cosx);
v1 = cosx;
cospitch = LODWORD(v1);
v2 = v4;
sinyaw = LODWORD(v2);
v3 = sinx[0];
sinpitch = LODWORD(v3);
}

original_code:
void compute_yp()
{
 cosyaw = cos(yaw*DTR);
 cospitch = cos(pitch*DTR);
 sinyaw = sin(yaw*DTR);
 sinpitch = sin(pitch*DTR);
}


decompiled_code:
void compute_viewdir()
{
double v0; // rbp
double v1; // rbx
float v2; // xmm1_4
float v3; // xmm1_4
float v4; // xmm0_4
double v5; // [rsp+0h] [rbp-28h] BYREF
double sinx[4]; // [rsp+8h] [rbp-20h] BYREF

sincos((float)(yaw + 90.0) * DTR, sinx, &v5);
v0 = v5;
v1 = sinx[0];
sincos(pitch * DTR, sinx, &v5);
v2 = v0 * v5;
viewx = LODWORD(v2);
v3 = sinx[0];
viewy = LODWORD(v3);
v4 = v1 * v5;
viewz = LODWORD(v4);
}

canonical_decompiled_code:
void func3()
{
double v0; // rbp
double v1; // rbx
float v2; // xmm1_4
float v3; // xmm1_4
float v4; // xmm0_4
double v5; // [rsp+0h] [rbp-28h] BYREF
double sinx[4]; // [rsp+8h] [rbp-20h] BYREF

sincos((float)(yaw + 90.0) * DTR, sinx, &v5);
v0 = v5;
v1 = sinx[0];
sincos(pitch * DTR, sinx, &v5);
v2 = v0 * v5;
viewx = LODWORD(v2);
v3 = sinx[0];
viewy = LODWORD(v3);
v4 = v1 * v5;
viewz = LODWORD(v4);
}

original_code:
void compute_viewdir()
{
 viewx = cos((yaw+90)*DTR) * cos(pitch*DTR);
 viewy = sin(pitch*DTR);
 viewz = sin((yaw+90)*DTR) * cos(pitch*DTR);
}


project

decompiled_code:
char __fastcall project(int a1, int a2, int a3, unsigned int a4, char a5, char a6, char a7, char a8)
{
float v11; // xmm0_4
float v12; // xmm2_4
float v13; // xmm1_4
float *v14; // rax
float v15; // xmm6_4
float v16; // xmm1_4
float v17; // xmm0_4
float v18; // xmm4_4
double v19; // xmm7_8
double v20; // xmm2_8
__int64 v21; // rdi
double v22; // xmm0_8
__int64 v23; // rsi
__int64 v24; // rdx

v11 = (double)a5 * 0.007874015748031496;
v12 = (double)a7 * 0.007874015748031496;
v13 = (double)a6 * 0.007874015748031496;
LOBYTE(v14) = is_back_culled(v11, v13, v12);
if ( (_BYTE)v14 )
{
LODWORD(v14) = (int)(float)((float)a1 - camx);
v15 = (float)(int)(float)((float)a3 - camz);
v16 = (float)((float)-(int)v14 * sinyaw) + (float)(cosyaw * v15);
v17 = (float)(int)(float)((float)a2 - camy);
v18 = (float)(v17 * sinpitch) + (float)(cospitch * v16);
if ( v18 <= 100000.0 && v18 >= 0.050000001 )
{
v19 = (float)(fov / v18);
v20 = (float)((float)(cosyaw * (float)(int)v14) + (float)(v15 * sinyaw)) * v19 + (double)(WIDTH / 2);
v21 = (unsigned int)(int)v20;
v22 = (float)((float)(v17 * cospitch) - (float)(v16 * sinpitch)) * v19 + (double)(HEIGHT / 2);
v23 = (unsigned int)(int)v22;
LOBYTE(v14) = (int)v22 < 0 || (int)v20 < 0 || WIDTH <= (int)v21;
if ( !(_BYTE)v14 && HEIGHT > (int)v23 )
{
v24 = (int)v21 + (int)v23 * WIDTH;
v14 = (float *)(zbuffer + 4 * v24);
if ( v18 < *v14 )
{
*v14 = v18;
*(_BYTE *)(NXbuf + v24) = a5;
*(_BYTE *)(NYbuf + v24) = a6;
*(_BYTE *)(NZbuf + v24) = a7;
*(_BYTE *)(SHbuf + v24) = a8;
LOBYTE(v14) = SDL_DrawPixel(v21, v23, a4);
}
}
}
}
return (char)v14;
}

canonical_decompiled_code:
char __fastcall func4(int a1, int a2, int a3, unsigned int a4, char a5, char a6, char a7, char a8)
{
float v11; // xmm0_4
float v12; // xmm2_4
float v13; // xmm1_4
float *v14; // rax
float v15; // xmm6_4
float v16; // xmm1_4
float v17; // xmm0_4
float v18; // xmm4_4
double v19; // xmm7_8
double v20; // xmm2_8
__int64 v21; // rdi
double v22; // xmm0_8
__int64 v23; // rsi
__int64 v24; // rdx

v11 = (double)a5 * 0.007874015748031496;
v12 = (double)a7 * 0.007874015748031496;
v13 = (double)a6 * 0.007874015748031496;
LOBYTE(v14) = is_back_culled(v11, v13, v12);
if ( (_BYTE)v14 )
{
LODWORD(v14) = (int)(float)((float)a1 - camx);
v15 = (float)(int)(float)((float)a3 - camz);
v16 = (float)((float)-(int)v14 * sinyaw) + (float)(cosyaw * v15);
v17 = (float)(int)(float)((float)a2 - camy);
v18 = (float)(v17 * sinpitch) + (float)(cospitch * v16);
if ( v18 <= 100000.0 && v18 >= 0.050000001 )
{
v19 = (float)(fov / v18);
v20 = (float)((float)(cosyaw * (float)(int)v14) + (float)(v15 * sinyaw)) * v19 + (double)(WIDTH / 2);
v21 = (unsigned int)(int)v20;
v22 = (float)((float)(v17 * cospitch) - (float)(v16 * sinpitch)) * v19 + (double)(HEIGHT / 2);
v23 = (unsigned int)(int)v22;
LOBYTE(v14) = (int)v22 < 0 || (int)v20 < 0 || WIDTH <= (int)v21;
if ( !(_BYTE)v14 && HEIGHT > (int)v23 )
{
v24 = (int)v21 + (int)v23 * WIDTH;
v14 = (float *)(zbuffer + 4 * v24);
if ( v18 < *v14 )
{
*v14 = v18;
*(_BYTE *)(NXbuf + v24) = a5;
*(_BYTE *)(NYbuf + v24) = a6;
*(_BYTE *)(NZbuf + v24) = a7;
*(_BYTE *)(SHbuf + v24) = a8;
LOBYTE(v14) = SDL_DrawPixel(v21, v23, a4);
}
}
}
}
return (char)v14;
}

original_code:
void project(int32_t x, int32_t y, int32_t z, uint32_t col,
    int8_t nx, int8_t ny, int8_t nz, uint8_t sh)
{
  float newx,newz0,newy,newz; int sx,sy;
  static const int marg=0; double nfov;
  const int32_t tx=x-camx, ty=y-camy, tz=z-camz;
  if (!is_back_culled(x,y,z,nx/127.0,ny/127.0,nz/127.0)) return;
  newx = tx * cosyaw + tz * sinyaw;
  newz0=-tx * sinyaw + tz * cosyaw;
  newy = ty * cospitch - newz0 * sinpitch;
  newz = ty * sinpitch + newz0 * cospitch;
  if (newz<0.05f || newz>100000) return;
  if (newz<0.05f) return; nfov = fov/newz;
  sx = WIDTH/2 + newx * nfov;
  sy = HEIGHT/2 + newy * nfov;
  if(sx<marg ||
      sx>WIDTH-marg-1 ||
      sy<marg ||
      sy>HEIGHT-marg-1) return;
  if(newz<zbuffer[sx+sy*WIDTH]) {
    zbuffer[sx+sy*WIDTH] = newz;
    NXbuf[sx+sy*WIDTH] = nx;
    NYbuf[sx+sy*WIDTH] = ny;
    NZbuf[sx+sy*WIDTH] = nz;
    SHbuf[sx+sy*WIDTH] = sh;
    SDL_DrawPixel(sx,sy,col); }
}

canonical_original_code:
void project(int x, int y, int z, unsigned int col, char nx, char ny, char nz, unsigned char sh)
{
  float newx; float newz0; float newy; float newz; int sx; int sy;
  static int marg = 0; double nfov;
  int tx = x-camx; int ty = y-camy; int tz = z-camz;
  if (!is_back_culled(x,y,z,nx/127.0,ny/127.0,nz/127.0)) return;
  newx = tx * cosyaw + tz * sinyaw;
  newz0=-tx * sinyaw + tz * cosyaw;
  newy = ty * cospitch - newz0 * sinpitch;
  newz = ty * sinpitch + newz0 * cospitch;
  if (newz<0.05f || newz>100000) return;
  if (newz<0.05f) return; nfov = fov/newz;
  sx = WIDTH/2 + newx * nfov;
  sy = HEIGHT/2 + newy * nfov;
  if(sx<marg ||
      sx>WIDTH-marg-1 ||
      sy<marg ||
      sy>HEIGHT-marg-1) return;
  if(newz<zbuffer[sx+sy*WIDTH]) {
    zbuffer[sx+sy*WIDTH] = newz;
    NXbuf[sx+sy*WIDTH] = nx;
    NYbuf[sx+sy*WIDTH] = ny;
    NZbuf[sx+sy*WIDTH] = nz;
    SHbuf[sx+sy*WIDTH] = sh;
    SDL_DrawPixel(sx,sy,col); }
}

variable_types: y int

variable_types: z int

variable_types:
col
unsigned int

variable_types: nx char

variable_types: ny char

variable_types: nz char

variable_types:
sh
unsigned char

variable_types: newx float

variable_types: newy float

variable_types: newz float

variable_types: sx int

variable_types: sy int

variable_types: marg int

variable_types: nfov double

variable_types: tx int

variable_types: ty int

variable_types: tz int


decompiled_code:
__int64 __fastcall project_render(int a1, int a2, int a3, int a4, char a5, char a6, char a7, char a8)
{
float v10; // xmm0_4
float v11; // xmm2_4
float v12; // xmm1_4
__int64 result; // rax
int v14; // edx
int v15; // esi
float v16; // xmm1_4
float v17; // xmm4_4
int v18; // er9
int v19; // er10
__int64 v20; // rcx
float *v21; // rdi

v10 = (double)a5 * 0.007874015748031496;
v11 = (double)a7 * 0.007874015748031496;
v12 = (double)a6 * 0.007874015748031496;
result = is_back_culled(v10, v12, v11);
if ( (_BYTE)result )
{
result = (unsigned int)(int)(float)((float)a1 - camx);
v14 = (int)(float)((float)a2 - camy);
v15 = (int)(float)((float)a3 - camz);
v16 = (float)((float)-(int)(float)((float)a1 - camx) * sinyaw) + (float)(cosyaw * (float)v15);
v17 = (float)((float)v14 * sinpitch) + (float)(cospitch * v16);
if ( v17 <= 100000.0 && v17 >= 0.050000001 )
{
v18 = (int)(float)((float)((float)((float)((float)(cosyaw * (float)(int)result) + (float)((float)v15 * sinyaw))
* fov)
/ v17)
+ (float)(WIDTH / 2));
v19 = (int)(float)((float)((float)((float)((float)((float)v14 * cospitch) - (float)(v16 * sinpitch)) * fov) / v17)
+ (float)(HEIGHT / 2));
if ( v19 >= 0 && v18 >= 0 && WIDTH > v18 && HEIGHT > v19 )
{
v20 = v18 + v19 * WIDTH;
v21 = (float *)(zbuffer + 4 * v20);
if ( v17 < *v21 )
{
*v21 = v17;
*(_DWORD *)(Xbuf + 4 * v20) = result;
*(_DWORD *)(Ybuf + 4 * v20) = v14;
*(_DWORD *)(Zbuf + 4 * v20) = v15;
*(_BYTE *)(NXbuf + v20) = a5;
*(_BYTE *)(NYbuf + v20) = a6;
*(_BYTE *)(NZbuf + v20) = a7;
*(_BYTE *)(SHbuf + v20) = a8;
result = img;
*(_DWORD *)(img + 4 * v20) = a4;
}
}
}
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func5(int a1, int a2, int a3, int a4, char a5, char a6, char a7, char a8)
{
float v10; // xmm0_4
float v11; // xmm2_4
float v12; // xmm1_4
__int64 result; // rax
int v14; // edx
int v15; // esi
float v16; // xmm1_4
float v17; // xmm4_4
int v18; // er9
int v19; // er10
__int64 v20; // rcx
float *v21; // rdi

v10 = (double)a5 * 0.007874015748031496;
v11 = (double)a7 * 0.007874015748031496;
v12 = (double)a6 * 0.007874015748031496;
result = is_back_culled(v10, v12, v11);
if ( (_BYTE)result )
{
result = (unsigned int)(int)(float)((float)a1 - camx);
v14 = (int)(float)((float)a2 - camy);
v15 = (int)(float)((float)a3 - camz);
v16 = (float)((float)-(int)(float)((float)a1 - camx) * sinyaw) + (float)(cosyaw * (float)v15);
v17 = (float)((float)v14 * sinpitch) + (float)(cospitch * v16);
if ( v17 <= 100000.0 && v17 >= 0.050000001 )
{
v18 = (int)(float)((float)((float)((float)((float)(cosyaw * (float)(int)result) + (float)((float)v15 * sinyaw))
* fov)
/ v17)
+ (float)(WIDTH / 2));
v19 = (int)(float)((float)((float)((float)((float)((float)v14 * cospitch) - (float)(v16 * sinpitch)) * fov) / v17)
+ (float)(HEIGHT / 2));
if ( v19 >= 0 && v18 >= 0 && WIDTH > v18 && HEIGHT > v19 )
{
v20 = v18 + v19 * WIDTH;
v21 = (float *)(zbuffer + 4 * v20);
if ( v17 < *v21 )
{
*v21 = v17;
*(_DWORD *)(Xbuf + 4 * v20) = result;
*(_DWORD *)(Ybuf + 4 * v20) = v14;
*(_DWORD *)(Zbuf + 4 * v20) = v15;
*(_BYTE *)(NXbuf + v20) = a5;
*(_BYTE *)(NYbuf + v20) = a6;
*(_BYTE *)(NZbuf + v20) = a7;
*(_BYTE *)(SHbuf + v20) = a8;
result = img;
*(_DWORD *)(img + 4 * v20) = a4;
}
}
}
}
return result;
}

original_code:
void project_render
 (const int32_t x, const int32_t y, const int32_t z, uint32_t col,
  int8_t nx, int8_t ny, int8_t nz, uint8_t sh)
{
  float newx,newz0,newy,newz; int sx,sy;
  static const int marg=0;
  const int32_t tx=x-camx, ty=y-camy, tz=z-camz;
  if (!is_back_culled(x,y,z,nx/127.0,ny/127.0,nz/127.0)) return;
  newx = tx * cosyaw + tz * sinyaw;
  newz0=-tx * sinyaw + tz * cosyaw;
  newy = ty * cospitch - newz0 * sinpitch;
  newz = ty * sinpitch + newz0 * cospitch;
  if (newz<0.05f || newz>100000) return;
  if (newz<0.05f) return;
  sx = WIDTH/2 + newx * fov/newz;
  sy = HEIGHT/2 + newy * fov/newz;
  if(sx<marg ||
      sx>WIDTH-marg-1 ||
      sy<marg ||
      sy>HEIGHT-marg-1) return;
  if(newz<zbuffer[sx+sy*WIDTH]) {
    zbuffer[sx+sy*WIDTH] = newz;
    Xbuf[sx+sy*WIDTH] = tx;
    Ybuf[sx+sy*WIDTH] = ty;
    Zbuf[sx+sy*WIDTH] = tz;
    NXbuf[sx+sy*WIDTH] = nx;
    NYbuf[sx+sy*WIDTH] = ny;
    NZbuf[sx+sy*WIDTH] = nz;
    SHbuf[sx+sy*WIDTH] = sh;
    img[sx+sy*WIDTH] = col;
 }
}

canonical_original_code:
void project_render(int x, int y, int z, unsigned int col, char nx, char ny, char nz, unsigned char sh)
{
  float newx; float newz0; float newy; float newz; int sx; int sy;
  static int marg = 0;
  int tx = x-camx; int ty = y-camy; int tz = z-camz;
  if (!is_back_culled(x,y,z,nx/127.0,ny/127.0,nz/127.0)) return;
  newx = tx * cosyaw + tz * sinyaw;
  newz0=-tx * sinyaw + tz * cosyaw;
  newy = ty * cospitch - newz0 * sinpitch;
  newz = ty * sinpitch + newz0 * cospitch;
  if (newz<0.05f || newz>100000) return;
  if (newz<0.05f) return;
  sx = WIDTH/2 + newx * fov/newz;
  sy = HEIGHT/2 + newy * fov/newz;
  if(sx<marg ||
      sx>WIDTH-marg-1 ||
      sy<marg ||
      sy>HEIGHT-marg-1) return;
  if(newz<zbuffer[sx+sy*WIDTH]) {
    zbuffer[sx+sy*WIDTH] = newz;
    Xbuf[sx+sy*WIDTH] = tx;
    Ybuf[sx+sy*WIDTH] = ty;
    Zbuf[sx+sy*WIDTH] = tz;
    NXbuf[sx+sy*WIDTH] = nx;
    NYbuf[sx+sy*WIDTH] = ny;
    NZbuf[sx+sy*WIDTH] = nz;
    SHbuf[sx+sy*WIDTH] = sh;
    img[sx+sy*WIDTH] = col;
 }
}

variable_types: x int

variable_types: y int


decompiled_code:
__int64 add_spec_to_img()
{
__int64 result; // rax
__int64 v1; // rbp
__int64 i; // rbx
float v3; // xmm0_4
float v4; // xmm2_4
float v5; // xmm1_4
int v6[7]; // [rsp+0h] [rbp-1Ch] BYREF

result = (unsigned int)(HEIGHT * WIDTH);
if ( (_DWORD)result )
{
v1 = (unsigned int)(result - 1);
for ( i = 0LL; ; ++i )
{
if ( *(_DWORD *)(img + 4 * i) != -828333920 )
{
v6[0] = *(_DWORD *)(img + 4 * i);
v3 = (double)*(char *)(NXbuf + i) * 0.007874015748031496;
v4 = (double)*(char *)(NZbuf + i) * 0.007874015748031496;
v5 = (double)*(char *)(NYbuf + i) * 0.007874015748031496;
shade_spec(v6, *(unsigned __int8 *)(SHbuf + i), v3, v5, v4, lightx, lighty, lightz);
*(_DWORD *)(img + 4 * i) = v6[0];
}
result = i + 1;
if ( i == v1 )
break;
}
}
return result;
}

canonical_decompiled_code:
__int64 func6()
{
__int64 result; // rax
__int64 v1; // rbp
__int64 i; // rbx
float v3; // xmm0_4
float v4; // xmm2_4
float v5; // xmm1_4
int v6[7]; // [rsp+0h] [rbp-1Ch] BYREF

result = (unsigned int)(HEIGHT * WIDTH);
if ( (_DWORD)result )
{
v1 = (unsigned int)(result - 1);
for ( i = 0LL; ; ++i )
{
if ( *(_DWORD *)(img + 4 * i) != -828333920 )
{
v6[0] = *(_DWORD *)(img + 4 * i);
v3 = (double)*(char *)(NXbuf + i) * 0.007874015748031496;
v4 = (double)*(char *)(NZbuf + i) * 0.007874015748031496;
v5 = (double)*(char *)(NYbuf + i) * 0.007874015748031496;
shade_spec(v6, *(unsigned __int8 *)(SHbuf + i), v3, v5, v4, lightx, lighty, lightz);
*(_DWORD *)(img + 4 * i) = v6[0];
}
result = i + 1;
if ( i == v1 )
break;
}
}
return result;
}

original_code:
void add_spec_to_img()
{
 uint32_t i, len = WIDTH*HEIGHT;
 Color32 c32;
 for (i=0;i<len;i++) {
  if (img[i]!=0xCEA0A0A0) {
   c32.col = img[i];
   shade_spec(&c32, NXbuf[i]/127.0, NYbuf[i]/127.0, NZbuf[i]/127.0,
        lightx, lighty, lightz, SHbuf[i]);
   img[i] = c32.col;
  }
 }
}

canonical_original_code:
void add_spec_to_img()
{
 unsigned int i; unsigned int len = WIDTH*HEIGHT;
 union Color32 c32;
 for (i=0;i<len;i++) {
  if (img[i]!=0xCEA0A0A0) {
   c32.col = img[i];
   shade_spec(&c32, NXbuf[i]/127.0, NYbuf[i]/127.0, NZbuf[i]/127.0,
        lightx, lighty, lightz, SHbuf[i]);
   img[i] = c32.col;
  }
 }
}

variable_types:
i
unsigned int

variable_types:
len
unsigned int

variable_types: union Color32 { unsigned int col; unsigned char rgba[4]; }


decompiled_code:
__int64 add_fog_to_img()
{
__int64 result; // rax
__int64 v1; // rdi
__int64 v2; // rdx
float v3; // xmm0_4
int v4; // ecx
float v5; // xmm0_4
float v6; // xmm0_4
float v7; // xmm1_4

result = (unsigned int)(HEIGHT * WIDTH);
if ( (_DWORD)result )
{
v1 = 4LL * (unsigned int)(result - 1) + 4;
v2 = 0LL;
do
{
result = *(unsigned int *)(img + v2);
if ( (_DWORD)result != -828333920 )
{
v5 = *(float *)(zbuffer + v2);
if ( v5 <= 0.02 )
{
v6 = v5 * v5;
v7 = *(float *)&LC4;
if ( v6 <= 0.0000024999999 )
v7 = v6 * 400000.0;
v3 = fmaxf(v7, 0.25);
HIWORD(v4) = HIWORD(*(_DWORD *)(img + v2));
LOBYTE(v4) = (int)(float)((float)(unsigned __int8)(int)(float)((float)(unsigned __int8)result * v3)
+ (float)((float)(1.0 - v3) * 136.0));
BYTE1(v4) = (int)(float)((float)(unsigned __int8)(int)(float)((float)BYTE1(result) * v3)
+ (float)((float)(1.0 - v3) * 221.0));
result = (unsigned __int8)(int)(float)((float)((float)(1.0 - v3) * 238.0)
+ (float)(unsigned __int8)(int)(float)(v3 * (float)BYTE2(result))) << 16;
*(_DWORD *)(img + v2) = result | v4 & 0xFF00FFFF;
}
}
v2 += 4LL;
}
while ( v2 != v1 );
}
return result;
}

canonical_decompiled_code:
__int64 func7()
{
__int64 result; // rax
__int64 v1; // rdi
__int64 v2; // rdx
float v3; // xmm0_4
int v4; // ecx
float v5; // xmm0_4
float v6; // xmm0_4
float v7; // xmm1_4

result = (unsigned int)(HEIGHT * WIDTH);
if ( (_DWORD)result )
{
v1 = 4LL * (unsigned int)(result - 1) + 4;
v2 = 0LL;
do
{
result = *(unsigned int *)(img + v2);
if ( (_DWORD)result != -828333920 )
{
v5 = *(float *)(zbuffer + v2);
if ( v5 <= 0.02 )
{
v6 = v5 * v5;
v7 = *(float *)&LC4;
if ( v6 <= 0.0000024999999 )
v7 = v6 * 400000.0;
v3 = fmaxf(v7, 0.25);
HIWORD(v4) = HIWORD(*(_DWORD *)(img + v2));
LOBYTE(v4) = (int)(float)((float)(unsigned __int8)(int)(float)((float)(unsigned __int8)result * v3)
+ (float)((float)(1.0 - v3) * 136.0));
BYTE1(v4) = (int)(float)((float)(unsigned __int8)(int)(float)((float)BYTE1(result) * v3)
+ (float)((float)(1.0 - v3) * 221.0));
result = (unsigned __int8)(int)(float)((float)((float)(1.0 - v3) * 238.0)
+ (float)(unsigned __int8)(int)(float)(v3 * (float)BYTE2(result))) << 16;
*(_DWORD *)(img + v2) = result | v4 & 0xFF00FFFF;
}
}
v2 += 4LL;
}
while ( v2 != v1 );
}
return result;
}

canonical_original_code:
void add_fog_to_img()
{
 unsigned int i; unsigned int len = WIDTH*HEIGHT;
 union Color32 c32; float z;
 for (i=0;i<len;i++) {
  if (img[i]!=0xCEA0A0A0) {
   z = zbuffer[i];
   if (z>0.02f) continue;
   z *= z * 100000 * 4;
   z > 1 ? z=1:0;
   z < 0.25f ? z=0.25f:0;
   c32.col = img[i];
   c32.rgba[0] *= z;
   c32.rgba[1] *= z;
   c32.rgba[2] *= z;
   c32.rgba[0] += 0x88 * (1-z);
   c32.rgba[1] += 0xDD * (1-z);
   c32.rgba[2] += 0xEE * (1-z);
   img[i] = c32.col;
  }
 }
}

variable_types: z float

user_defined_types: union Color32 { unsigned int col; unsigned char rgba[4]; }


decompiled_code:
__int64 __fastcall draw_cloud(_QWORD *a1, int a2, int a3, int a4, int a5)
{
__int64 result; // rax
unsigned int v6; // er12
__int64 v7; // r15
__int64 v8; // r14
unsigned int v9; // er13
unsigned int v10; // eax
unsigned int v11; // [rsp+8h] [rbp-50h]
unsigned int v12; // [rsp+Ch] [rbp-4Ch]

result = *(unsigned int *)a1;
v12 = result;
if ( (_DWORD)result )
{
v6 = 0;
do
{
v7 = *(unsigned __int8 *)(a1[8] + v6);
v8 = (unsigned int)*(char *)(a1[7] + v6);
v9 = *(char *)(a1[6] + v6);
v11 = *(char *)(a1[5] + v6);
v10 = high2true(*(unsigned __int16 *)(a1[4] + 2LL * v6));
result = project(
(unsigned int)(*(_DWORD *)(a1[1] + 4LL * v6) + a2),
(unsigned int)(*(_DWORD *)(a1[2] + 4LL * v6) + a3),
(unsigned int)(*(_DWORD *)(a1[3] + 4LL * v6) + a4),
v10,
v11,
v9,
v8,
v7);
v6 += a5;
}
while ( v12 > v6 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func0(_QWORD *a1, int a2, int a3, int a4, int a5)
{
__int64 result; // rax
unsigned int v6; // er12
__int64 v7; // r15
__int64 v8; // r14
unsigned int v9; // er13
unsigned int v10; // eax
unsigned int v11; // [rsp+8h] [rbp-50h]
unsigned int v12; // [rsp+Ch] [rbp-4Ch]

result = *(unsigned int *)a1;
v12 = result;
if ( (_DWORD)result )
{
v6 = 0;
do
{
v7 = *(unsigned __int8 *)(a1[8] + v6);
v8 = (unsigned int)*(char *)(a1[7] + v6);
v9 = *(char *)(a1[6] + v6);
v11 = *(char *)(a1[5] + v6);
v10 = high2true(*(unsigned __int16 *)(a1[4] + 2LL * v6));
result = project(
(unsigned int)(*(_DWORD *)(a1[1] + 4LL * v6) + a2),
(unsigned int)(*(_DWORD *)(a1[2] + 4LL * v6) + a3),
(unsigned int)(*(_DWORD *)(a1[3] + 4LL * v6) + a4),
v10,
v11,
v9,
v8,
v7);
v6 += a5;
}
while ( v12 > v6 );
}
return result;
}

original_code:
void draw_cloud
 (Cloud *cloud,
 const int32_t xo, const int32_t yo, const int32_t zo, const uint32_t skip)
{
 uint32_t i, len = cloud->s;
 for (i=0; i<len; i+=skip) {
  project(
   cloud->x[i]+xo, cloud->y[i]+yo, cloud->z[i]+zo,
   high2true(cloud->c[i]),
   cloud->nx[i], cloud->ny[i], cloud->nz[i], cloud->sh[i]
  );
 }
}

canonical_original_code:
void draw_cloud(struct Cloud *cloud, int xo, int yo, int zo, unsigned int skip)
{
 unsigned int i; unsigned int len = cloud->s;
 for (i=0; i<len; i+=skip) {
  project(
   cloud->x[i]+xo, cloud->y[i]+yo, cloud->z[i]+zo,
   high2true(cloud->c[i]),
   cloud->nx[i], cloud->ny[i], cloud->nz[i], cloud->sh[i]
  );
 }
}

variable_types: struct Cloud { unsigned int s; int *x; unsigned short *c; char *nx; unsigned char *sh; } *

variable_types: xo int

variable_types: yo int

variable_types: zo int

variable_types:
skip
unsigned int


decompiled_code:
__int64 __fastcall render_cloud(_QWORD *a1, int a2, int a3, int a4, int a5)
{
__int64 result; // rax
unsigned int v6; // er12
__int64 v7; // r15
__int64 v8; // r14
unsigned int v9; // er13
unsigned int v10; // eax
unsigned int v11; // [rsp+8h] [rbp-50h]
unsigned int v12; // [rsp+Ch] [rbp-4Ch]

result = *(unsigned int *)a1;
v12 = result;
if ( (_DWORD)result )
{
v6 = 0;
do
{
v7 = *(unsigned __int8 *)(a1[8] + v6);
v8 = (unsigned int)*(char *)(a1[7] + v6);
v9 = *(char *)(a1[6] + v6);
v11 = *(char *)(a1[5] + v6);
v10 = high2true(*(unsigned __int16 *)(a1[4] + 2LL * v6));
result = project_render(
(unsigned int)(*(_DWORD *)(a1[1] + 4LL * v6) + a2),
(unsigned int)(*(_DWORD *)(a1[2] + 4LL * v6) + a3),
(unsigned int)(*(_DWORD *)(a1[3] + 4LL * v6) + a4),
v10,
v11,
v9,
v8,
v7);
v6 += a5;
}
while ( v12 > v6 );
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(_QWORD *a1, int a2, int a3, int a4, int a5)
{
__int64 result; // rax
unsigned int v6; // er12
__int64 v7; // r15
__int64 v8; // r14
unsigned int v9; // er13
unsigned int v10; // eax
unsigned int v11; // [rsp+8h] [rbp-50h]
unsigned int v12; // [rsp+Ch] [rbp-4Ch]

result = *(unsigned int *)a1;
v12 = result;
if ( (_DWORD)result )
{
v6 = 0;
do
{
v7 = *(unsigned __int8 *)(a1[8] + v6);
v8 = (unsigned int)*(char *)(a1[7] + v6);
v9 = *(char *)(a1[6] + v6);
v11 = *(char *)(a1[5] + v6);
v10 = high2true(*(unsigned __int16 *)(a1[4] + 2LL * v6));
result = project_render(
(unsigned int)(*(_DWORD *)(a1[1] + 4LL * v6) + a2),
(unsigned int)(*(_DWORD *)(a1[2] + 4LL * v6) + a3),
(unsigned int)(*(_DWORD *)(a1[3] + 4LL * v6) + a4),
v10,
v11,
v9,
v8,
v7);
v6 += a5;
}
while ( v12 > v6 );
}
return result;
}

original_code:
void render_cloud
 (Cloud *cloud,
 const int32_t xo, const int32_t yo, const int32_t zo, const uint32_t skip)
{
 uint32_t i, len = cloud->s;
 for (i=0; i<len; i+=skip) {
  project_render(
   cloud->x[i]+xo, cloud->y[i]+yo, cloud->z[i]+zo,
   high2true(cloud->c[i]),
   cloud->nx[i], cloud->ny[i], cloud->nz[i], cloud->sh[i]
  );
 }
}

canonical_original_code:
void render_cloud(struct Cloud *cloud, int xo, int yo, int zo, unsigned int skip)
{
 unsigned int i; unsigned int len = cloud->s;
 for (i=0; i<len; i+=skip) {
  project_render(
   cloud->x[i]+xo, cloud->y[i]+yo, cloud->z[i]+zo,
   high2true(cloud->c[i]),
   cloud->nx[i], cloud->ny[i], cloud->nz[i], cloud->sh[i]
  );
 }
}

user_defined_types: struct Cloud { unsigned int s; int *x; unsigned short *c; char *nx; unsigned char *sh; }


decompiled_code:
void *SDL_Initialize()
{
int v0; // ebx
int v1; // ebp
void *result; // rax

v0 = HEIGHT;
v1 = WIDTH;
screen = SDL_SetVideoMode(WIDTH, HEIGHT, 32LL, 1LL);
result = malloc(4LL * v1 * v0);
img = result;
return result;
}

canonical_decompiled_code:
void *func0()
{
int v0; // ebx
int v1; // ebp
void *result; // rax

v0 = HEIGHT;
v1 = WIDTH;
screen = SDL_SetVideoMode(WIDTH, HEIGHT, 32LL, 1LL);
result = malloc(4LL * v1 * v0);
img = result;
return result;
}

original_code:
void SDL_Initialize()
{
 screen = SDL_SetVideoMode(WIDTH, HEIGHT, 32, 0x00000001);
 img = (Uint32*)malloc(WIDTH*HEIGHT*sizeof(Uint32));
}

canonical_original_code:
void SDL_Initialize()
{
 screen = SDL_SetVideoMode(WIDTH, HEIGHT, 32, 0x00000001);
 img = (unsigned int *)malloc(WIDTH*HEIGHT*sizeof(Uint32));
}


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

if ( !*(_DWORD *)(screen + 40LL) && (*screen & 0x4005) == 0 || (result = SDL_LockSurface(), (int)result >= 0) )
{
memcpy(*(void **)(screen + 32LL), img, 4LL * HEIGHT * WIDTH);
if ( *(_DWORD *)(screen + 40LL) || (*screen & 0x4005) != 0 )
SDL_UnlockSurface();
result = SDL_Flip(screen);
}
return result;
}

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

if ( !*(_DWORD *)(screen + 40LL) && (*screen & 0x4005) == 0 || (result = SDL_LockSurface(), (int)result >= 0) )
{
memcpy(*(void **)(screen + 32LL), img, 4LL * HEIGHT * WIDTH);
if ( *(_DWORD *)(screen + 40LL) || (*screen & 0x4005) != 0 )
SDL_UnlockSurface();
result = SDL_Flip(screen);
}
return result;
}

original_code:
void SDL_FlipScreen()
{
 if((screen->offset || ((screen->flags & (0x00000001|0x00000004|0x00004000)) != 0))) if(SDL_LockSurface(screen)<0) return;
 memcpy(screen->pixels, img, WIDTH*HEIGHT*sizeof(int));
 if((screen->offset || ((screen->flags & (0x00000001|0x00000004|0x00004000)) != 0))) SDL_UnlockSurface(screen);
 SDL_Flip(screen);
}


original_code:
void SDL_HandleEvents()
{
  while(SDL_PollEvent(&event)) {
    if(event.type==SDL_MOUSEMOTION) {
      MOUSEX=event.motion.x; MOUSEY=event.motion.y; }
    if(event.type==SDL_QUIT) {
      exit_flag=1;
      SDL_Quit();
      exit(1); }
    if(event.type==SDL_MOUSEBUTTONDOWN) {
      MOUSEX=event.motion.x; MOUSEY=event.motion.y;
      if(event.button.button==1)BUTTON[LB]=1;
      if(event.button.button==2)BUTTON[MB]=1;
      if(event.button.button==3)BUTTON[RB]=1;
      if(event.button.button==4)BUTTON[WUP]=1;
      if(event.button.button==5)BUTTON[WDOWN]=1; }
    if(event.type==SDL_MOUSEBUTTONUP) {
      MOUSEX=event.motion.x; MOUSEY=event.motion.y;
      if(event.button.button==1)BUTTON[LB]=0;
      if(event.button.button==2)BUTTON[MB]=0;
      if(event.button.button==3)BUTTON[RB]=0;
      if(event.button.button==4)BUTTON[WUP]=0;
      if(event.button.button==5)BUTTON[WDOWN]=0; }
    if(event.type==SDL_KEYDOWN) {
      int bset=1;
      if(event.key.keysym.sym==SDLK_BACKSPACE)KEY[BACKSPACE]=bset;
      if(event.key.keysym.sym==SDLK_TAB)KEY[TAB]=bset;
      if(event.key.keysym.sym==SDLK_CLEAR)KEY[CLEAR]=bset;
      if(event.key.keysym.sym==SDLK_RETURN)KEY[ENTER]=bset;
      if(event.key.keysym.sym==SDLK_PAUSE)KEY[PAUSE]=bset;
      if(event.key.keysym.sym==SDLK_ESCAPE)KEY[ESCAPE]=bset;
      if(event.key.keysym.sym==SDLK_SPACE)KEY[SPACE]=bset;
      if(event.key.keysym.sym==SDLK_EXCLAIM)KEY[EXCLAIM]=bset;
      if(event.key.keysym.sym==SDLK_QUOTEDBL)KEY[QUOTEDBL]=bset;
      if(event.key.keysym.sym==SDLK_HASH)KEY[HASH]=bset;
      if(event.key.keysym.sym==SDLK_DOLLAR)KEY[DOLLAR]=bset;
      if(event.key.keysym.sym==SDLK_AMPERSAND)KEY[AMPERSAND]=bset;
      if(event.key.keysym.sym==SDLK_QUOTE)KEY[QUOTE]=bset;
      if(event.key.keysym.sym==SDLK_LEFTPAREN)KEY[LEFTPAREN]=bset;
      if(event.key.keysym.sym==SDLK_RIGHTPAREN)KEY[RIGHTPAREN]=bset;
      if(event.key.keysym.sym==SDLK_ASTERISK)KEY[ASTERISK]=bset;
      if(event.key.keysym.sym==SDLK_PLUS)KEY[PLUS]=bset;
      if(event.key.keysym.sym==SDLK_COMMA)KEY[COMMA]=bset;
      if(event.key.keysym.sym==SDLK_MINUS)KEY[MINUS]=bset;
      if(event.key.keysym.sym==SDLK_PERIOD)KEY[PERIOD]=bset;
      if(event.key.keysym.sym==SDLK_SLASH)KEY[SLASH]=bset;
      if(event.key.keysym.sym==SDLK_0)KEY[key_0]=bset;
      if(event.key.keysym.sym==SDLK_1)KEY[key_1]=bset;
      if(event.key.keysym.sym==SDLK_2)KEY[key_2]=bset;
      if(event.key.keysym.sym==SDLK_3)KEY[key_3]=bset;
      if(event.key.keysym.sym==SDLK_4)KEY[key_4]=bset;
      if(event.key.keysym.sym==SDLK_5)KEY[key_5]=bset;
      if(event.key.keysym.sym==SDLK_6)KEY[key_6]=bset;
      if(event.key.keysym.sym==SDLK_7)KEY[key_7]=bset;
      if(event.key.keysym.sym==SDLK_8)KEY[key_8]=bset;
      if(event.key.keysym.sym==SDLK_9)KEY[key_9]=bset;
      if(event.key.keysym.sym==SDLK_COLON)KEY[COLON]=bset;
      if(event.key.keysym.sym==SDLK_SEMICOLON)KEY[SEMICOLON]=bset;
      if(event.key.keysym.sym==SDLK_LESS)KEY[LESS]=bset;
      if(event.key.keysym.sym==SDLK_EQUALS)KEY[EQUALS]=bset;
      if(event.key.keysym.sym==SDLK_GREATER)KEY[GREATER]=bset;
      if(event.key.keysym.sym==SDLK_QUESTION)KEY[QUESTION]=bset;
      if(event.key.keysym.sym==SDLK_AT)KEY[AT]=bset;
      if(event.key.keysym.sym==SDLK_LEFTBRACKET)KEY[LEFTBRACKET]=bset;
      if(event.key.keysym.sym==SDLK_BACKSLASH)KEY[BACKSLASH]=bset;
      if(event.key.keysym.sym==SDLK_RIGHTBRACKET)KEY[RIGHTBRACKET]=bset;
      if(event.key.keysym.sym==SDLK_CARET)KEY[CARET]=bset;
      if(event.key.keysym.sym==SDLK_UNDERSCORE)KEY[UNDERSCORE]=bset;
      if(event.key.keysym.sym==SDLK_BACKQUOTE)KEY[BACKQUOTE]=bset;
      if(event.key.keysym.sym==SDLK_a)KEY[key_a]=bset;
      if(event.key.keysym.sym==SDLK_b)KEY[key_b]=bset;
      if(event.key.keysym.sym==SDLK_c)KEY[key_c]=bset;
      if(event.key.keysym.sym==SDLK_d)KEY[key_d]=bset;
      if(event.key.keysym.sym==SDLK_e)KEY[key_e]=bset;
      if(event.key.keysym.sym==SDLK_f)KEY[key_f]=bset;
      if(event.key.keysym.sym==SDLK_g)KEY[key_g]=bset;
      if(event.key.keysym.sym==SDLK_h)KEY[key_h]=bset;
      if(event.key.keysym.sym==SDLK_i)KEY[key_i]=bset;
      if(event.key.keysym.sym==SDLK_j)KEY[key_j]=bset;
      if(event.key.keysym.sym==SDLK_k)KEY[key_k]=bset;
      if(event.key.keysym.sym==SDLK_l)KEY[key_l]=bset;
      if(event.key.keysym.sym==SDLK_m)KEY[key_m]=bset;
      if(event.key.keysym.sym==SDLK_n)KEY[key_n]=bset;
      if(event.key.keysym.sym==SDLK_o)KEY[key_o]=bset;
      if(event.key.keysym.sym==SDLK_p)KEY[key_p]=bset;
      if(event.key.keysym.sym==SDLK_q)KEY[key_q]=bset;
      if(event.key.keysym.sym==SDLK_r)KEY[key_r]=bset;
      if(event.key.keysym.sym==SDLK_s)KEY[key_s]=bset;
      if(event.key.keysym.sym==SDLK_t)KEY[key_t_]=bset;
      if(event.key.keysym.sym==SDLK_u)KEY[key_u]=bset;
      if(event.key.keysym.sym==SDLK_v)KEY[key_v]=bset;
      if(event.key.keysym.sym==SDLK_w)KEY[key_w]=bset;
      if(event.key.keysym.sym==SDLK_x)KEY[key_x]=bset;
      if(event.key.keysym.sym==SDLK_y)KEY[key_y]=bset;
      if(event.key.keysym.sym==SDLK_z)KEY[key_z]=bset;
      if(event.key.keysym.sym==SDLK_DELETE)KEY[DEL]=bset;
      if(event.key.keysym.sym==SDLK_KP0)KEY[KP0]=bset;
      if(event.key.keysym.sym==SDLK_KP1)KEY[KP1]=bset;
      if(event.key.keysym.sym==SDLK_KP2)KEY[KP2]=bset;
      if(event.key.keysym.sym==SDLK_KP3)KEY[KP3]=bset;
      if(event.key.keysym.sym==SDLK_KP4)KEY[KP4]=bset;
      if(event.key.keysym.sym==SDLK_KP5)KEY[KP5]=bset;
      if(event.key.keysym.sym==SDLK_KP6)KEY[KP6]=bset;
      if(event.key.keysym.sym==SDLK_KP7)KEY[KP7]=bset;
      if(event.key.keysym.sym==SDLK_KP8)KEY[KP8]=bset;
      if(event.key.keysym.sym==SDLK_KP9)KEY[KP9]=bset;
      if(event.key.keysym.sym==SDLK_KP_PERIOD)KEY[KP_PERIOD]=bset;
      if(event.key.keysym.sym==SDLK_KP_DIVIDE)KEY[KP_DIVIDE]=bset;
      if(event.key.keysym.sym==SDLK_KP_MULTIPLY)KEY[KP_MULTIPLY]=bset;
      if(event.key.keysym.sym==SDLK_KP_MINUS)KEY[KP_MINUS]=bset;
      if(event.key.keysym.sym==SDLK_KP_PLUS)KEY[KP_PLUS]=bset;
      if(event.key.keysym.sym==SDLK_KP_ENTER)KEY[KP_ENTER]=bset;
      if(event.key.keysym.sym==SDLK_KP_EQUALS)KEY[KP_EQUALS]=bset;
      if(event.key.keysym.sym==SDLK_UP)KEY[UP]=bset;
      if(event.key.keysym.sym==SDLK_DOWN)KEY[DOWN]=bset;
      if(event.key.keysym.sym==SDLK_RIGHT)KEY[RIGHT]=bset;
      if(event.key.keysym.sym==SDLK_LEFT)KEY[LEFT]=bset;
      if(event.key.keysym.sym==SDLK_INSERT)KEY[INSERT]=bset;
      if(event.key.keysym.sym==SDLK_HOME)KEY[HOME]=bset;
      if(event.key.keysym.sym==SDLK_END)KEY[END]=bset;
      if(event.key.keysym.sym==SDLK_PAGEUP)KEY[PAGEUP]=bset;
      if(event.key.keysym.sym==SDLK_PAGEDOWN)KEY[PAGEDOWN]=bset;
      if(event.key.keysym.sym==SDLK_F1)KEY[F1]=bset;
      if(event.key.keysym.sym==SDLK_F2)KEY[F2]=bset;
      if(event.key.keysym.sym==SDLK_F3)KEY[F3]=bset;
      if(event.key.keysym.sym==SDLK_F4)KEY[F4]=bset;
      if(event.key.keysym.sym==SDLK_F5)KEY[F5]=bset;
      if(event.key.keysym.sym==SDLK_F6)KEY[F6]=bset;
      if(event.key.keysym.sym==SDLK_F7)KEY[F7]=bset;
      if(event.key.keysym.sym==SDLK_F8)KEY[F8]=bset;
      if(event.key.keysym.sym==SDLK_F9)KEY[F9]=bset;
      if(event.key.keysym.sym==SDLK_F10)KEY[F10]=bset;
      if(event.key.keysym.sym==SDLK_F11)KEY[F11]=bset;
      if(event.key.keysym.sym==SDLK_F12)KEY[F12]=bset;
      if(event.key.keysym.sym==SDLK_F13)KEY[F13]=bset;
      if(event.key.keysym.sym==SDLK_F14)KEY[F14]=bset;
      if(event.key.keysym.sym==SDLK_F15)KEY[F15]=bset;
      if(event.key.keysym.sym==SDLK_NUMLOCK)KEY[NUMLOCK]=bset;
      if(event.key.keysym.sym==SDLK_CAPSLOCK)KEY[CAPSLOCK]=bset;
      if(event.key.keysym.sym==SDLK_SCROLLOCK)KEY[SCROLLOCK]=bset;
      if(event.key.keysym.sym==SDLK_RSHIFT)KEY[RSHIFT]=bset;
      if(event.key.keysym.sym==SDLK_LSHIFT)KEY[LSHIFT]=bset;
      if(event.key.keysym.sym==SDLK_RCTRL)KEY[RCTRL]=bset;
      if(event.key.keysym.sym==SDLK_LCTRL)KEY[LCTRL]=bset;
      if(event.key.keysym.sym==SDLK_RALT)KEY[RALT]=bset;
      if(event.key.keysym.sym==SDLK_LALT)KEY[LALT]=bset; }
    if(event.type==SDL_KEYUP) {
      int bset=0;
      if(event.key.keysym.sym==SDLK_BACKSPACE)KEY[BACKSPACE]=bset;
      if(event.key.keysym.sym==SDLK_TAB)KEY[TAB]=bset;
      if(event.key.keysym.sym==SDLK_CLEAR)KEY[CLEAR]=bset;
      if(event.key.keysym.sym==SDLK_RETURN)KEY[ENTER]=bset;
      if(event.key.keysym.sym==SDLK_PAUSE)KEY[PAUSE]=bset;
      if(event.key.keysym.sym==SDLK_ESCAPE)KEY[ESCAPE]=bset;
      if(event.key.keysym.sym==SDLK_SPACE)KEY[SPACE]=bset;
      if(event.key.keysym.sym==SDLK_EXCLAIM)KEY[EXCLAIM]=bset;
      if(event.key.keysym.sym==SDLK_QUOTEDBL)KEY[QUOTEDBL]=bset;
      if(event.key.keysym.sym==SDLK_HASH)KEY[HASH]=bset;
      if(event.key.keysym.sym==SDLK_DOLLAR)KEY[DOLLAR]=bset;
      if(event.key.keysym.sym==SDLK_AMPERSAND)KEY[AMPERSAND]=bset;
      if(event.key.keysym.sym==SDLK_QUOTE)KEY[QUOTE]=bset;
      if(event.key.keysym.sym==SDLK_LEFTPAREN)KEY[LEFTPAREN]=bset;
      if(event.key.keysym.sym==SDLK_RIGHTPAREN)KEY[RIGHTPAREN]=bset;
      if(event.key.keysym.sym==SDLK_ASTERISK)KEY[ASTERISK]=bset;
      if(event.key.keysym.sym==SDLK_PLUS)KEY[PLUS]=bset;
      if(event.key.keysym.sym==SDLK_COMMA)KEY[COMMA]=bset;
      if(event.key.keysym.sym==SDLK_MINUS)KEY[MINUS]=bset;
      if(event.key.keysym.sym==SDLK_PERIOD)KEY[PERIOD]=bset;
      if(event.key.keysym.sym==SDLK_SLASH)KEY[SLASH]=bset;
      if(event.key.keysym.sym==SDLK_0)KEY[key_0]=bset;
      if(event.key.keysym.sym==SDLK_1)KEY[key_1]=bset;
      if(event.key.keysym.sym==SDLK_2)KEY[key_2]=bset;
      if(event.key.keysym.sym==SDLK_3)KEY[key_3]=bset;
      if(event.key.keysym.sym==SDLK_4)KEY[key_4]=bset;
      if(event.key.keysym.sym==SDLK_5)KEY[key_5]=bset;
      if(event.key.keysym.sym==SDLK_6)KEY[key_6]=bset;
      if(event.key.keysym.sym==SDLK_7)KEY[key_7]=bset;
      if(event.key.keysym.sym==SDLK_8)KEY[key_8]=bset;
      if(event.key.keysym.sym==SDLK_9)KEY[key_9]=bset;
      if(event.key.keysym.sym==SDLK_COLON)KEY[COLON]=bset;
      if(event.key.keysym.sym==SDLK_SEMICOLON)KEY[SEMICOLON]=bset;
      if(event.key.keysym.sym==SDLK_LESS)KEY[LESS]=bset;
      if(event.key.keysym.sym==SDLK_EQUALS)KEY[EQUALS]=bset;
      if(event.key.keysym.sym==SDLK_GREATER)KEY[GREATER]=bset;
      if(event.key.keysym.sym==SDLK_QUESTION)KEY[QUESTION]=bset;
      if(event.key.keysym.sym==SDLK_AT)KEY[AT]=bset;
      if(event.key.keysym.sym==SDLK_LEFTBRACKET)KEY[LEFTBRACKET]=bset;
      if(event.key.keysym.sym==SDLK_BACKSLASH)KEY[BACKSLASH]=bset;
      if(event.key.keysym.sym==SDLK_RIGHTBRACKET)KEY[RIGHTBRACKET]=bset;
      if(event.key.keysym.sym==SDLK_CARET)KEY[CARET]=bset;
      if(event.key.keysym.sym==SDLK_UNDERSCORE)KEY[UNDERSCORE]=bset;
      if(event.key.keysym.sym==SDLK_BACKQUOTE)KEY[BACKQUOTE]=bset;
      if(event.key.keysym.sym==SDLK_a)KEY[key_a]=bset;
      if(event.key.keysym.sym==SDLK_b)KEY[key_b]=bset;
      if(event.key.keysym.sym==SDLK_c)KEY[key_c]=bset;
      if(event.key.keysym.sym==SDLK_d)KEY[key_d]=bset;
      if(event.key.keysym.sym==SDLK_e)KEY[key_e]=bset;
      if(event.key.keysym.sym==SDLK_f)KEY[key_f]=bset;
      if(event.key.keysym.sym==SDLK_g)KEY[key_g]=bset;
      if(event.key.keysym.sym==SDLK_h)KEY[key_h]=bset;
      if(event.key.keysym.sym==SDLK_i)KEY[key_i]=bset;
      if(event.key.keysym.sym==SDLK_j)KEY[key_j]=bset;
      if(event.key.keysym.sym==SDLK_k)KEY[key_k]=bset;
      if(event.key.keysym.sym==SDLK_l)KEY[key_l]=bset;
      if(event.key.keysym.sym==SDLK_m)KEY[key_m]=bset;
      if(event.key.keysym.sym==SDLK_n)KEY[key_n]=bset;
      if(event.key.keysym.sym==SDLK_o)KEY[key_o]=bset;
      if(event.key.keysym.sym==SDLK_p)KEY[key_p]=bset;
      if(event.key.keysym.sym==SDLK_q)KEY[key_q]=bset;
      if(event.key.keysym.sym==SDLK_r)KEY[key_r]=bset;
      if(event.key.keysym.sym==SDLK_s)KEY[key_s]=bset;
      if(event.key.keysym.sym==SDLK_t)KEY[key_t_]=bset;
      if(event.key.keysym.sym==SDLK_u)KEY[key_u]=bset;
      if(event.key.keysym.sym==SDLK_v)KEY[key_v]=bset;
      if(event.key.keysym.sym==SDLK_w)KEY[key_w]=bset;
      if(event.key.keysym.sym==SDLK_x)KEY[key_x]=bset;
      if(event.key.keysym.sym==SDLK_y)KEY[key_y]=bset;
      if(event.key.keysym.sym==SDLK_z)KEY[key_z]=bset;
      if(event.key.keysym.sym==SDLK_DELETE)KEY[DEL]=bset;
      if(event.key.keysym.sym==SDLK_KP0)KEY[KP0]=bset;
      if(event.key.keysym.sym==SDLK_KP1)KEY[KP1]=bset;
      if(event.key.keysym.sym==SDLK_KP2)KEY[KP2]=bset;
      if(event.key.keysym.sym==SDLK_KP3)KEY[KP3]=bset;
      if(event.key.keysym.sym==SDLK_KP4)KEY[KP4]=bset;
      if(event.key.keysym.sym==SDLK_KP5)KEY[KP5]=bset;
      if(event.key.keysym.sym==SDLK_KP6)KEY[KP6]=bset;
      if(event.key.keysym.sym==SDLK_KP7)KEY[KP7]=bset;
      if(event.key.keysym.sym==SDLK_KP8)KEY[KP8]=bset;
      if(event.key.keysym.sym==SDLK_KP9)KEY[KP9]=bset;
      if(event.key.keysym.sym==SDLK_KP_PERIOD)KEY[KP_PERIOD]=bset;
      if(event.key.keysym.sym==SDLK_KP_DIVIDE)KEY[KP_DIVIDE]=bset;
      if(event.key.keysym.sym==SDLK_KP_MULTIPLY)KEY[KP_MULTIPLY]=bset;
      if(event.key.keysym.sym==SDLK_KP_MINUS)KEY[KP_MINUS]=bset;
      if(event.key.keysym.sym==SDLK_KP_PLUS)KEY[KP_PLUS]=bset;
      if(event.key.keysym.sym==SDLK_KP_ENTER)KEY[KP_ENTER]=bset;
      if(event.key.keysym.sym==SDLK_KP_EQUALS)KEY[KP_EQUALS]=bset;
      if(event.key.keysym.sym==SDLK_UP)KEY[UP]=bset;
      if(event.key.keysym.sym==SDLK_DOWN)KEY[DOWN]=bset;
      if(event.key.keysym.sym==SDLK_RIGHT)KEY[RIGHT]=bset;
      if(event.key.keysym.sym==SDLK_LEFT)KEY[LEFT]=bset;
      if(event.key.keysym.sym==SDLK_INSERT)KEY[INSERT]=bset;
      if(event.key.keysym.sym==SDLK_HOME)KEY[HOME]=bset;
      if(event.key.keysym.sym==SDLK_END)KEY[END]=bset;
      if(event.key.keysym.sym==SDLK_PAGEUP)KEY[PAGEUP]=bset;
      if(event.key.keysym.sym==SDLK_PAGEDOWN)KEY[PAGEDOWN]=bset;
      if(event.key.keysym.sym==SDLK_F1)KEY[F1]=bset;
      if(event.key.keysym.sym==SDLK_F2)KEY[F2]=bset;
      if(event.key.keysym.sym==SDLK_F3)KEY[F3]=bset;
      if(event.key.keysym.sym==SDLK_F4)KEY[F4]=bset;
      if(event.key.keysym.sym==SDLK_F5)KEY[F5]=bset;
      if(event.key.keysym.sym==SDLK_F6)KEY[F6]=bset;
      if(event.key.keysym.sym==SDLK_F7)KEY[F7]=bset;
      if(event.key.keysym.sym==SDLK_F8)KEY[F8]=bset;
      if(event.key.keysym.sym==SDLK_F9)KEY[F9]=bset;
      if(event.key.keysym.sym==SDLK_F10)KEY[F10]=bset;
      if(event.key.keysym.sym==SDLK_F11)KEY[F11]=bset;
      if(event.key.keysym.sym==SDLK_F12)KEY[F12]=bset;
      if(event.key.keysym.sym==SDLK_F13)KEY[F13]=bset;
      if(event.key.keysym.sym==SDLK_F14)KEY[F14]=bset;
      if(event.key.keysym.sym==SDLK_F15)KEY[F15]=bset;
      if(event.key.keysym.sym==SDLK_NUMLOCK)KEY[NUMLOCK]=bset;
      if(event.key.keysym.sym==SDLK_CAPSLOCK)KEY[CAPSLOCK]=bset;
      if(event.key.keysym.sym==SDLK_SCROLLOCK)KEY[SCROLLOCK]=bset;
      if(event.key.keysym.sym==SDLK_RSHIFT)KEY[RSHIFT]=bset;
      if(event.key.keysym.sym==SDLK_LSHIFT)KEY[LSHIFT]=bset;
      if(event.key.keysym.sym==SDLK_RCTRL)KEY[RCTRL]=bset;
      if(event.key.keysym.sym==SDLK_LCTRL)KEY[LCTRL]=bset;
      if(event.key.keysym.sym==SDLK_RALT)KEY[RALT]=bset;
      if(event.key.keysym.sym==SDLK_LALT)KEY[LALT]=bset; } } }

canonical_original_code:
void SDL_HandleEvents()
{
  while(SDL_PollEvent(&event)) {
    if(event.type==SDL_MOUSEMOTION) {
      MOUSEX=event.motion.x; MOUSEY=event.motion.y; }
    if(event.type==SDL_QUIT) {
      exit_flag=1;
      SDL_Quit();
      exit(1); }
    if(event.type==SDL_MOUSEBUTTONDOWN) {
      MOUSEX=event.motion.x; MOUSEY=event.motion.y;
      if(event.button.button==1)BUTTON[LB]=1;
      if(event.button.button==2)BUTTON[MB]=1;
      if(event.button.button==3)BUTTON[RB]=1;
      if(event.button.button==4)BUTTON[WUP]=1;
      if(event.button.button==5)BUTTON[WDOWN]=1; }
    if(event.type==SDL_MOUSEBUTTONUP) {
      MOUSEX=event.motion.x; MOUSEY=event.motion.y;
      if(event.button.button==1)BUTTON[LB]=0;
      if(event.button.button==2)BUTTON[MB]=0;
      if(event.button.button==3)BUTTON[RB]=0;
      if(event.button.button==4)BUTTON[WUP]=0;
      if(event.button.button==5)BUTTON[WDOWN]=0; }
    if(event.type==SDL_KEYDOWN) {
      int bset = 1;
      if(event.key.keysym.sym==SDLK_BACKSPACE)KEY[BACKSPACE]=bset;
      if(event.key.keysym.sym==SDLK_TAB)KEY[TAB]=bset;
      if(event.key.keysym.sym==SDLK_CLEAR)KEY[CLEAR]=bset;
      if(event.key.keysym.sym==SDLK_RETURN)KEY[ENTER]=bset;
      if(event.key.keysym.sym==SDLK_PAUSE)KEY[PAUSE]=bset;
      if(event.key.keysym.sym==SDLK_ESCAPE)KEY[ESCAPE]=bset;
      if(event.key.keysym.sym==SDLK_SPACE)KEY[SPACE]=bset;
      if(event.key.keysym.sym==SDLK_EXCLAIM)KEY[EXCLAIM]=bset;
      if(event.key.keysym.sym==SDLK_QUOTEDBL)KEY[QUOTEDBL]=bset;
      if(event.key.keysym.sym==SDLK_HASH)KEY[HASH]=bset;
      if(event.key.keysym.sym==SDLK_DOLLAR)KEY[DOLLAR]=bset;
      if(event.key.keysym.sym==SDLK_AMPERSAND)KEY[AMPERSAND]=bset;
      if(event.key.keysym.sym==SDLK_QUOTE)KEY[QUOTE]=bset;
      if(event.key.keysym.sym==SDLK_LEFTPAREN)KEY[LEFTPAREN]=bset;
      if(event.key.keysym.sym==SDLK_RIGHTPAREN)KEY[RIGHTPAREN]=bset;
      if(event.key.keysym.sym==SDLK_ASTERISK)KEY[ASTERISK]=bset;
      if(event.key.keysym.sym==SDLK_PLUS)KEY[PLUS]=bset;
      if(event.key.keysym.sym==SDLK_COMMA)KEY[COMMA]=bset;
      if(event.key.keysym.sym==SDLK_MINUS)KEY[MINUS]=bset;
      if(event.key.keysym.sym==SDLK_PERIOD)KEY[PERIOD]=bset;
      if(event.key.keysym.sym==SDLK_SLASH)KEY[SLASH]=bset;
      if(event.key.keysym.sym==SDLK_0)KEY[key_0]=bset;
      if(event.key.keysym.sym==SDLK_1)KEY[key_1]=bset;
      if(event.key.keysym.sym==SDLK_2)KEY[key_2]=bset;
      if(event.key.keysym.sym==SDLK_3)KEY[key_3]=bset;
      if(event.key.keysym.sym==SDLK_4)KEY[key_4]=bset;
      if(event.key.keysym.sym==SDLK_5)KEY[key_5]=bset;
      if(event.key.keysym.sym==SDLK_6)KEY[key_6]=bset;
      if(event.key.keysym.sym==SDLK_7)KEY[key_7]=bset;
      if(event.key.keysym.sym==SDLK_8)KEY[key_8]=bset;
      if(event.key.keysym.sym==SDLK_9)KEY[key_9]=bset;
      if(event.key.keysym.sym==SDLK_COLON)KEY[COLON]=bset;
      if(event.key.keysym.sym==SDLK_SEMICOLON)KEY[SEMICOLON]=bset;
      if(event.key.keysym.sym==SDLK_LESS)KEY[LESS]=bset;
      if(event.key.keysym.sym==SDLK_EQUALS)KEY[EQUALS]=bset;
      if(event.key.keysym.sym==SDLK_GREATER)KEY[GREATER]=bset;
      if(event.key.keysym.sym==SDLK_QUESTION)KEY[QUESTION]=bset;
      if(event.key.keysym.sym==SDLK_AT)KEY[AT]=bset;
      if(event.key.keysym.sym==SDLK_LEFTBRACKET)KEY[LEFTBRACKET]=bset;
      if(event.key.keysym.sym==SDLK_BACKSLASH)KEY[BACKSLASH]=bset;
      if(event.key.keysym.sym==SDLK_RIGHTBRACKET)KEY[RIGHTBRACKET]=bset;
      if(event.key.keysym.sym==SDLK_CARET)KEY[CARET]=bset;
      if(event.key.keysym.sym==SDLK_UNDERSCORE)KEY[UNDERSCORE]=bset;
      if(event.key.keysym.sym==SDLK_BACKQUOTE)KEY[BACKQUOTE]=bset;
      if(event.key.keysym.sym==SDLK_a)KEY[key_a]=bset;
      if(event.key.keysym.sym==SDLK_b)KEY[key_b]=bset;
      if(event.key.keysym.sym==SDLK_c)KEY[key_c]=bset;
      if(event.key.keysym.sym==SDLK_d)KEY[key_d]=bset;
      if(event.key.keysym.sym==SDLK_e)KEY[key_e]=bset;
      if(event.key.keysym.sym==SDLK_f)KEY[key_f]=bset;
      if(event.key.keysym.sym==SDLK_g)KEY[key_g]=bset;
      if(event.key.keysym.sym==SDLK_h)KEY[key_h]=bset;
      if(event.key.keysym.sym==SDLK_i)KEY[key_i]=bset;
      if(event.key.keysym.sym==SDLK_j)KEY[key_j]=bset;
      if(event.key.keysym.sym==SDLK_k)KEY[key_k]=bset;
      if(event.key.keysym.sym==SDLK_l)KEY[key_l]=bset;
      if(event.key.keysym.sym==SDLK_m)KEY[key_m]=bset;
      if(event.key.keysym.sym==SDLK_n)KEY[key_n]=bset;
      if(event.key.keysym.sym==SDLK_o)KEY[key_o]=bset;
      if(event.key.keysym.sym==SDLK_p)KEY[key_p]=bset;
      if(event.key.keysym.sym==SDLK_q)KEY[key_q]=bset;
      if(event.key.keysym.sym==SDLK_r)KEY[key_r]=bset;
      if(event.key.keysym.sym==SDLK_s)KEY[key_s]=bset;
      if(event.key.keysym.sym==SDLK_t)KEY[key_t_]=bset;
      if(event.key.keysym.sym==SDLK_u)KEY[key_u]=bset;
      if(event.key.keysym.sym==SDLK_v)KEY[key_v]=bset;
      if(event.key.keysym.sym==SDLK_w)KEY[key_w]=bset;
      if(event.key.keysym.sym==SDLK_x)KEY[key_x]=bset;
      if(event.key.keysym.sym==SDLK_y)KEY[key_y]=bset;
      if(event.key.keysym.sym==SDLK_z)KEY[key_z]=bset;
      if(event.key.keysym.sym==SDLK_DELETE)KEY[DEL]=bset;
      if(event.key.keysym.sym==SDLK_KP0)KEY[KP0]=bset;
      if(event.key.keysym.sym==SDLK_KP1)KEY[KP1]=bset;
      if(event.key.keysym.sym==SDLK_KP2)KEY[KP2]=bset;
      if(event.key.keysym.sym==SDLK_KP3)KEY[KP3]=bset;
      if(event.key.keysym.sym==SDLK_KP4)KEY[KP4]=bset;
      if(event.key.keysym.sym==SDLK_KP5)KEY[KP5]=bset;
      if(event.key.keysym.sym==SDLK_KP6)KEY[KP6]=bset;
      if(event.key.keysym.sym==SDLK_KP7)KEY[KP7]=bset;
      if(event.key.keysym.sym==SDLK_KP8)KEY[KP8]=bset;
      if(event.key.keysym.sym==SDLK_KP9)KEY[KP9]=bset;
      if(event.key.keysym.sym==SDLK_KP_PERIOD)KEY[KP_PERIOD]=bset;
      if(event.key.keysym.sym==SDLK_KP_DIVIDE)KEY[KP_DIVIDE]=bset;
      if(event.key.keysym.sym==SDLK_KP_MULTIPLY)KEY[KP_MULTIPLY]=bset;
      if(event.key.keysym.sym==SDLK_KP_MINUS)KEY[KP_MINUS]=bset;
      if(event.key.keysym.sym==SDLK_KP_PLUS)KEY[KP_PLUS]=bset;
      if(event.key.keysym.sym==SDLK_KP_ENTER)KEY[KP_ENTER]=bset;
      if(event.key.keysym.sym==SDLK_KP_EQUALS)KEY[KP_EQUALS]=bset;
      if(event.key.keysym.sym==SDLK_UP)KEY[UP]=bset;
      if(event.key.keysym.sym==SDLK_DOWN)KEY[DOWN]=bset;
      if(event.key.keysym.sym==SDLK_RIGHT)KEY[RIGHT]=bset;
      if(event.key.keysym.sym==SDLK_LEFT)KEY[LEFT]=bset;
      if(event.key.keysym.sym==SDLK_INSERT)KEY[INSERT]=bset;
      if(event.key.keysym.sym==SDLK_HOME)KEY[HOME]=bset;
      if(event.key.keysym.sym==SDLK_END)KEY[END]=bset;
      if(event.key.keysym.sym==SDLK_PAGEUP)KEY[PAGEUP]=bset;
      if(event.key.keysym.sym==SDLK_PAGEDOWN)KEY[PAGEDOWN]=bset;
      if(event.key.keysym.sym==SDLK_F1)KEY[F1]=bset;
      if(event.key.keysym.sym==SDLK_F2)KEY[F2]=bset;
      if(event.key.keysym.sym==SDLK_F3)KEY[F3]=bset;
      if(event.key.keysym.sym==SDLK_F4)KEY[F4]=bset;
      if(event.key.keysym.sym==SDLK_F5)KEY[F5]=bset;
      if(event.key.keysym.sym==SDLK_F6)KEY[F6]=bset;
      if(event.key.keysym.sym==SDLK_F7)KEY[F7]=bset;
      if(event.key.keysym.sym==SDLK_F8)KEY[F8]=bset;
      if(event.key.keysym.sym==SDLK_F9)KEY[F9]=bset;
      if(event.key.keysym.sym==SDLK_F10)KEY[F10]=bset;
      if(event.key.keysym.sym==SDLK_F11)KEY[F11]=bset;
      if(event.key.keysym.sym==SDLK_F12)KEY[F12]=bset;
      if(event.key.keysym.sym==SDLK_F13)KEY[F13]=bset;
      if(event.key.keysym.sym==SDLK_F14)KEY[F14]=bset;
      if(event.key.keysym.sym==SDLK_F15)KEY[F15]=bset;
      if(event.key.keysym.sym==SDLK_NUMLOCK)KEY[NUMLOCK]=bset;
      if(event.key.keysym.sym==SDLK_CAPSLOCK)KEY[CAPSLOCK]=bset;
      if(event.key.keysym.sym==SDLK_SCROLLOCK)KEY[SCROLLOCK]=bset;
      if(event.key.keysym.sym==SDLK_RSHIFT)KEY[RSHIFT]=bset;
      if(event.key.keysym.sym==SDLK_LSHIFT)KEY[LSHIFT]=bset;
      if(event.key.keysym.sym==SDLK_RCTRL)KEY[RCTRL]=bset;
      if(event.key.keysym.sym==SDLK_LCTRL)KEY[LCTRL]=bset;
      if(event.key.keysym.sym==SDLK_RALT)KEY[RALT]=bset;
      if(event.key.keysym.sym==SDLK_LALT)KEY[LALT]=bset; }
    if(event.type==SDL_KEYUP) {
      int bset = 0;
      if(event.key.keysym.sym==SDLK_BACKSPACE)KEY[BACKSPACE]=bset;
      if(event.key.keysym.sym==SDLK_TAB)KEY[TAB]=bset;
      if(event.key.keysym.sym==SDLK_CLEAR)KEY[CLEAR]=bset;
      if(event.key.keysym.sym==SDLK_RETURN)KEY[ENTER]=bset;
      if(event.key.keysym.sym==SDLK_PAUSE)KEY[PAUSE]=bset;
      if(event.key.keysym.sym==SDLK_ESCAPE)KEY[ESCAPE]=bset;
      if(event.key.keysym.sym==SDLK_SPACE)KEY[SPACE]=bset;
      if(event.key.keysym.sym==SDLK_EXCLAIM)KEY[EXCLAIM]=bset;
      if(event.key.keysym.sym==SDLK_QUOTEDBL)KEY[QUOTEDBL]=bset;
      if(event.key.keysym.sym==SDLK_HASH)KEY[HASH]=bset;
      if(event.key.keysym.sym==SDLK_DOLLAR)KEY[DOLLAR]=bset;
      if(event.key.keysym.sym==SDLK_AMPERSAND)KEY[AMPERSAND]=bset;
      if(event.key.keysym.sym==SDLK_QUOTE)KEY[QUOTE]=bset;
      if(event.key.keysym.sym==SDLK_LEFTPAREN)KEY[LEFTPAREN]=bset;
      if(event.key.keysym.sym==SDLK_RIGHTPAREN)KEY[RIGHTPAREN]=bset;
      if(event.key.keysym.sym==SDLK_ASTERISK)KEY[ASTERISK]=bset;
      if(event.key.keysym.sym==SDLK_PLUS)KEY[PLUS]=bset;
      if(event.key.keysym.sym==SDLK_COMMA)KEY[COMMA]=bset;
      if(event.key.keysym.sym==SDLK_MINUS)KEY[MINUS]=bset;
      if(event.key.keysym.sym==SDLK_PERIOD)KEY[PERIOD]=bset;
      if(event.key.keysym.sym==SDLK_SLASH)KEY[SLASH]=bset;
      if(event.key.keysym.sym==SDLK_0)KEY[key_0]=bset;
      if(event.key.keysym.sym==SDLK_1)KEY[key_1]=bset;
      if(event.key.keysym.sym==SDLK_2)KEY[key_2]=bset;
      if(event.key.keysym.sym==SDLK_3)KEY[key_3]=bset;
      if(event.key.keysym.sym==SDLK_4)KEY[key_4]=bset;
      if(event.key.keysym.sym==SDLK_5)KEY[key_5]=bset;
      if(event.key.keysym.sym==SDLK_6)KEY[key_6]=bset;
      if(event.key.keysym.sym==SDLK_7)KEY[key_7]=bset;
      if(event.key.keysym.sym==SDLK_8)KEY[key_8]=bset;
      if(event.key.keysym.sym==SDLK_9)KEY[key_9]=bset;
      if(event.key.keysym.sym==SDLK_COLON)KEY[COLON]=bset;
      if(event.key.keysym.sym==SDLK_SEMICOLON)KEY[SEMICOLON]=bset;
      if(event.key.keysym.sym==SDLK_LESS)KEY[LESS]=bset;
      if(event.key.keysym.sym==SDLK_EQUALS)KEY[EQUALS]=bset;
      if(event.key.keysym.sym==SDLK_GREATER)KEY[GREATER]=bset;
      if(event.key.keysym.sym==SDLK_QUESTION)KEY[QUESTION]=bset;
      if(event.key.keysym.sym==SDLK_AT)KEY[AT]=bset;
      if(event.key.keysym.sym==SDLK_LEFTBRACKET)KEY[LEFTBRACKET]=bset;
      if(event.key.keysym.sym==SDLK_BACKSLASH)KEY[BACKSLASH]=bset;
      if(event.key.keysym.sym==SDLK_RIGHTBRACKET)KEY[RIGHTBRACKET]=bset;
      if(event.key.keysym.sym==SDLK_CARET)KEY[CARET]=bset;
      if(event.key.keysym.sym==SDLK_UNDERSCORE)KEY[UNDERSCORE]=bset;
      if(event.key.keysym.sym==SDLK_BACKQUOTE)KEY[BACKQUOTE]=bset;
      if(event.key.keysym.sym==SDLK_a)KEY[key_a]=bset;
      if(event.key.keysym.sym==SDLK_b)KEY[key_b]=bset;
      if(event.key.keysym.sym==SDLK_c)KEY[key_c]=bset;
      if(event.key.keysym.sym==SDLK_d)KEY[key_d]=bset;
      if(event.key.keysym.sym==SDLK_e)KEY[key_e]=bset;
      if(event.key.keysym.sym==SDLK_f)KEY[key_f]=bset;
      if(event.key.keysym.sym==SDLK_g)KEY[key_g]=bset;
      if(event.key.keysym.sym==SDLK_h)KEY[key_h]=bset;
      if(event.key.keysym.sym==SDLK_i)KEY[key_i]=bset;
      if(event.key.keysym.sym==SDLK_j)KEY[key_j]=bset;
      if(event.key.keysym.sym==SDLK_k)KEY[key_k]=bset;
      if(event.key.keysym.sym==SDLK_l)KEY[key_l]=bset;
      if(event.key.keysym.sym==SDLK_m)KEY[key_m]=bset;
      if(event.key.keysym.sym==SDLK_n)KEY[key_n]=bset;
      if(event.key.keysym.sym==SDLK_o)KEY[key_o]=bset;
      if(event.key.keysym.sym==SDLK_p)KEY[key_p]=bset;
      if(event.key.keysym.sym==SDLK_q)KEY[key_q]=bset;
      if(event.key.keysym.sym==SDLK_r)KEY[key_r]=bset;
      if(event.key.keysym.sym==SDLK_s)KEY[key_s]=bset;
      if(event.key.keysym.sym==SDLK_t)KEY[key_t_]=bset;
      if(event.key.keysym.sym==SDLK_u)KEY[key_u]=bset;
      if(event.key.keysym.sym==SDLK_v)KEY[key_v]=bset;
      if(event.key.keysym.sym==SDLK_w)KEY[key_w]=bset;
      if(event.key.keysym.sym==SDLK_x)KEY[key_x]=bset;
      if(event.key.keysym.sym==SDLK_y)KEY[key_y]=bset;
      if(event.key.keysym.sym==SDLK_z)KEY[key_z]=bset;
      if(event.key.keysym.sym==SDLK_DELETE)KEY[DEL]=bset;
      if(event.key.keysym.sym==SDLK_KP0)KEY[KP0]=bset;
      if(event.key.keysym.sym==SDLK_KP1)KEY[KP1]=bset;
      if(event.key.keysym.sym==SDLK_KP2)KEY[KP2]=bset;
      if(event.key.keysym.sym==SDLK_KP3)KEY[KP3]=bset;
      if(event.key.keysym.sym==SDLK_KP4)KEY[KP4]=bset;
      if(event.key.keysym.sym==SDLK_KP5)KEY[KP5]=bset;
      if(event.key.keysym.sym==SDLK_KP6)KEY[KP6]=bset;
      if(event.key.keysym.sym==SDLK_KP7)KEY[KP7]=bset;
      if(event.key.keysym.sym==SDLK_KP8)KEY[KP8]=bset;
      if(event.key.keysym.sym==SDLK_KP9)KEY[KP9]=bset;
      if(event.key.keysym.sym==SDLK_KP_PERIOD)KEY[KP_PERIOD]=bset;
      if(event.key.keysym.sym==SDLK_KP_DIVIDE)KEY[KP_DIVIDE]=bset;
      if(event.key.keysym.sym==SDLK_KP_MULTIPLY)KEY[KP_MULTIPLY]=bset;
      if(event.key.keysym.sym==SDLK_KP_MINUS)KEY[KP_MINUS]=bset;
      if(event.key.keysym.sym==SDLK_KP_PLUS)KEY[KP_PLUS]=bset;
      if(event.key.keysym.sym==SDLK_KP_ENTER)KEY[KP_ENTER]=bset;
      if(event.key.keysym.sym==SDLK_KP_EQUALS)KEY[KP_EQUALS]=bset;
      if(event.key.keysym.sym==SDLK_UP)KEY[UP]=bset;
      if(event.key.keysym.sym==SDLK_DOWN)KEY[DOWN]=bset;
      if(event.key.keysym.sym==SDLK_RIGHT)KEY[RIGHT]=bset;
      if(event.key.keysym.sym==SDLK_LEFT)KEY[LEFT]=bset;
      if(event.key.keysym.sym==SDLK_INSERT)KEY[INSERT]=bset;
      if(event.key.keysym.sym==SDLK_HOME)KEY[HOME]=bset;
      if(event.key.keysym.sym==SDLK_END)KEY[END]=bset;
      if(event.key.keysym.sym==SDLK_PAGEUP)KEY[PAGEUP]=bset;
      if(event.key.keysym.sym==SDLK_PAGEDOWN)KEY[PAGEDOWN]=bset;
      if(event.key.keysym.sym==SDLK_F1)KEY[F1]=bset;
      if(event.key.keysym.sym==SDLK_F2)KEY[F2]=bset;
      if(event.key.keysym.sym==SDLK_F3)KEY[F3]=bset;
      if(event.key.keysym.sym==SDLK_F4)KEY[F4]=bset;
      if(event.key.keysym.sym==SDLK_F5)KEY[F5]=bset;
      if(event.key.keysym.sym==SDLK_F6)KEY[F6]=bset;
      if(event.key.keysym.sym==SDLK_F7)KEY[F7]=bset;
      if(event.key.keysym.sym==SDLK_F8)KEY[F8]=bset;
      if(event.key.keysym.sym==SDLK_F9)KEY[F9]=bset;
      if(event.key.keysym.sym==SDLK_F10)KEY[F10]=bset;
      if(event.key.keysym.sym==SDLK_F11)KEY[F11]=bset;
      if(event.key.keysym.sym==SDLK_F12)KEY[F12]=bset;
      if(event.key.keysym.sym==SDLK_F13)KEY[F13]=bset;
      if(event.key.keysym.sym==SDLK_F14)KEY[F14]=bset;
      if(event.key.keysym.sym==SDLK_F15)KEY[F15]=bset;
      if(event.key.keysym.sym==SDLK_NUMLOCK)KEY[NUMLOCK]=bset;
      if(event.key.keysym.sym==SDLK_CAPSLOCK)KEY[CAPSLOCK]=bset;
      if(event.key.keysym.sym==SDLK_SCROLLOCK)KEY[SCROLLOCK]=bset;
      if(event.key.keysym.sym==SDLK_RSHIFT)KEY[RSHIFT]=bset;
      if(event.key.keysym.sym==SDLK_LSHIFT)KEY[LSHIFT]=bset;
      if(event.key.keysym.sym==SDLK_RCTRL)KEY[RCTRL]=bset;
      if(event.key.keysym.sym==SDLK_LCTRL)KEY[LCTRL]=bset;
      if(event.key.keysym.sym==SDLK_RALT)KEY[RALT]=bset;
      if(event.key.keysym.sym==SDLK_LALT)KEY[LALT]=bset; } } }

variable_types: bset int


decompiled_code:
__int64 mouse_look()
{
int v0; // ebx
int v1; // ebp
float v2; // xmm0_4
float v3; // xmm4_4
float v4; // xmm1_4
double v5; // xmm0_8
double v6; // xmm1_8
float v7; // xmm0_4
float v8; // xmm0_4
float v9; // xmm0_4
float v10; // xmm0_4
double v12; // [rsp+8h] [rbp-30h]
double cosx; // [rsp+10h] [rbp-28h] BYREF
double sinx[4]; // [rsp+18h] [rbp-20h] BYREF

v0 = WIDTH;
v1 = HEIGHT;
v2 = yaw - (float)(MOUSEX - WIDTH / 2) * 0.15;
yaw = LODWORD(v2);
v3 = pitch - (float)(MOUSEY - HEIGHT / 2) * 0.15;
pitch = LODWORD(v3);
if ( v2 > 360.0 )
{
do
{
v4 = v2;
v2 = v2 - 360.0;
}
while ( v4 > 720.0 );
yaw = LODWORD(v2);
}
*(_QWORD *)&v5 = yaw;
v6 = 0.0;
if ( yaw < 0.0 )
{
do
{
v6 = v5;
*(float *)&v5 = *(float *)&v5 + 360.0;
}
while ( *(float *)&v6 < -360.0 );
yaw = LODWORD(v5);
}
if ( v3 <= 90.0 )
{
*(_QWORD *)&v6 = (unsigned int)LC7;
if ( v3 < -90.0 )
pitch = -1028521984;
}
else
{
pitch = 1118961664;
}
sincos(*(float *)&v5 * DTR, sinx, &cosx);
v12 = sinx[0];
v7 = cosx;
cosyaw = LODWORD(v7);
sincos(pitch * DTR, sinx, &cosx);
v8 = cosx;
cospitch = LODWORD(v8);
v9 = v12;
sinyaw = LODWORD(v9);
v10 = sinx[0];
sinpitch = LODWORD(v10);
return SDL_WarpMouse(
(unsigned __int16)(v0 / 2),
(unsigned __int16)(v1 / 2),
v10,
v6,
COERCE_DOUBLE((unsigned __int64)LC4),
COERCE_DOUBLE((unsigned __int64)LC1));
}

canonical_decompiled_code:
__int64 func0()
{
int v0; // ebx
int v1; // ebp
float v2; // xmm0_4
float v3; // xmm4_4
float v4; // xmm1_4
double v5; // xmm0_8
double v6; // xmm1_8
float v7; // xmm0_4
float v8; // xmm0_4
float v9; // xmm0_4
float v10; // xmm0_4
double v12; // [rsp+8h] [rbp-30h]
double cosx; // [rsp+10h] [rbp-28h] BYREF
double sinx[4]; // [rsp+18h] [rbp-20h] BYREF

v0 = WIDTH;
v1 = HEIGHT;
v2 = yaw - (float)(MOUSEX - WIDTH / 2) * 0.15;
yaw = LODWORD(v2);
v3 = pitch - (float)(MOUSEY - HEIGHT / 2) * 0.15;
pitch = LODWORD(v3);
if ( v2 > 360.0 )
{
do
{
v4 = v2;
v2 = v2 - 360.0;
}
while ( v4 > 720.0 );
yaw = LODWORD(v2);
}
*(_QWORD *)&v5 = yaw;
v6 = 0.0;
if ( yaw < 0.0 )
{
do
{
v6 = v5;
*(float *)&v5 = *(float *)&v5 + 360.0;
}
while ( *(float *)&v6 < -360.0 );
yaw = LODWORD(v5);
}
if ( v3 <= 90.0 )
{
*(_QWORD *)&v6 = (unsigned int)LC7;
if ( v3 < -90.0 )
pitch = -1028521984;
}
else
{
pitch = 1118961664;
}
sincos(*(float *)&v5 * DTR, sinx, &cosx);
v12 = sinx[0];
v7 = cosx;
cosyaw = LODWORD(v7);
sincos(pitch * DTR, sinx, &cosx);
v8 = cosx;
cospitch = LODWORD(v8);
v9 = v12;
sinyaw = LODWORD(v9);
v10 = sinx[0];
sinpitch = LODWORD(v10);
return SDL_WarpMouse(
(unsigned __int16)(v0 / 2),
(unsigned __int16)(v1 / 2),
v10,
v6,
COERCE_DOUBLE((unsigned __int64)LC4),
COERCE_DOUBLE((unsigned __int64)LC1));
}

original_code:
void mouse_look()
{
 float dx = MOUSEX-WIDTH/2, dy = MOUSEY-HEIGHT/2;
 yaw -= dx*0.15;
 pitch -= dy*0.15;
 while (yaw>360) yaw-=360;
 while (yaw<0) yaw+=360;
 if (pitch>90) pitch=89;
 if (pitch<-90) pitch=-89;
 cosyaw = cos(yaw*DTR);
 cospitch = cos(pitch*DTR);
 sinyaw = sin(yaw*DTR);
 sinpitch = sin(pitch*DTR);
 SDL_WarpMouse(WIDTH/2, HEIGHT/2);
}

canonical_original_code:
void mouse_look()
{
 float dx = MOUSEX-WIDTH/2; float dy = MOUSEY-HEIGHT/2;
 yaw -= dx*0.15;
 pitch -= dy*0.15;
 while (yaw>360) yaw-=360;
 while (yaw<0) yaw+=360;
 if (pitch>90) pitch=89;
 if (pitch<-90) pitch=-89;
 cosyaw = cos(yaw*DTR);
 cospitch = cos(pitch*DTR);
 sinyaw = sin(yaw*DTR);
 sinpitch = sin(pitch*DTR);
 SDL_WarpMouse(WIDTH/2, HEIGHT/2);
}

variable_types: dx float

variable_types: dy float


decompiled_code:
void __fastcall fly_forward(float a1)
{
double v1; // rbp
double v2; // rbx
float v3; // xmm1_4
float v4; // xmm1_4
float v5; // xmm0_4
double v6; // [rsp+8h] [rbp-30h]
double cosx; // [rsp+10h] [rbp-28h] BYREF
double sinx[4]; // [rsp+18h] [rbp-20h] BYREF

v6 = (float)(a1 * 35.0);
sincos((float)(yaw + 90.0) * DTR, sinx, &cosx);
v1 = cosx;
v2 = sinx[0];
sincos(pitch * DTR, sinx, &cosx);
v3 = v1 * cosx * v6 + camx;
camx = LODWORD(v3);
v4 = camy + v6 * sinx[0];
camy = LODWORD(v4);
v5 = v2 * cosx * v6 + camz;
camz = LODWORD(v5);
}

canonical_decompiled_code:
void __fastcall func1(float a1)
{
double v1; // rbp
double v2; // rbx
float v3; // xmm1_4
float v4; // xmm1_4
float v5; // xmm0_4
double v6; // [rsp+8h] [rbp-30h]
double cosx; // [rsp+10h] [rbp-28h] BYREF
double sinx[4]; // [rsp+18h] [rbp-20h] BYREF

v6 = (float)(a1 * 35.0);
sincos((float)(yaw + 90.0) * DTR, sinx, &cosx);
v1 = cosx;
v2 = sinx[0];
sincos(pitch * DTR, sinx, &cosx);
v3 = v1 * cosx * v6 + camx;
camx = LODWORD(v3);
v4 = camy + v6 * sinx[0];
camy = LODWORD(v4);
v5 = v2 * cosx * v6 + camz;
camz = LODWORD(v5);
}

original_code:
void fly_forward(float speed)
{
 speed *= 35;
 camx += speed*cos((yaw+90)*DTR) * cos(pitch*DTR);
 camy += speed*sin(pitch*DTR);
 camz += speed*sin((yaw+90)*DTR) * cos(pitch*DTR);
}

variable_types: speed float


original_code:
void fill_holes()
{
 uint32_t x, y;
 static uint32_t *img2 = ((void *)0);
 if (img2 == ((void *)0)) {
  img2 = (uint32_t*) malloc (WIDTH*HEIGHT*sizeof(uint32_t));
 }
 memcpy(img2, img, WIDTH*HEIGHT*sizeof(Uint32));
 for (x=0;x<WIDTH-1;x++) {
  for (y=0;y<HEIGHT;y++) {
   const uint32_t addr = x + y*WIDTH;
   if (img2[addr] == 0xCEA0A0A0) {
    img2[addr] = img[addr+1];
   }
  }
 }
 for (x=1;x<WIDTH;x++) {
  for (y=0;y<HEIGHT;y++) {
   const uint32_t addr = x + y*WIDTH;
   if (img2[addr] == 0xCEA0A0A0) {
    img2[addr] = img[addr-1];
   }
  }
 }
 memcpy(img, img2, WIDTH*HEIGHT*sizeof(uint32_t));
 for (x=0;x<WIDTH;x++) {
  for (y=0;y<HEIGHT-1;y++) {
   const uint32_t addr = x + y*WIDTH;
   if (img2[addr] == 0xCEA0A0A0) {
    img2[addr] = img[addr+WIDTH];
   }
  }
 }
 for (x=0;x<WIDTH;x++) {
  for (y=1;y<HEIGHT;y++) {
   const uint32_t addr = x + y*WIDTH;
   if (img2[addr] == 0xCEA0A0A0) {
    img2[addr] = img[addr-WIDTH];
   }
  }
 }
 memcpy(img, img2, WIDTH*HEIGHT*sizeof(uint32_t));
}

canonical_original_code:
void fill_holes()
{
 unsigned int x; unsigned int y;
 static unsigned int *img2 = ((void *)0);
 if (img2 == ((void *)0)) {
  img2 = (unsigned int *) malloc (WIDTH*HEIGHT*sizeof(unsigned int));
 }
 memcpy(img2, img, WIDTH*HEIGHT*sizeof(Uint32));
 for (x=0;x<WIDTH-1;x++) {
  for (y=0;y<HEIGHT;y++) {
   unsigned int addr = x + y*WIDTH;
   if (img2[addr] == 0xCEA0A0A0) {
    img2[addr] = img[addr+1];
   }
  }
 }
 for (x=1;x<WIDTH;x++) {
  for (y=0;y<HEIGHT;y++) {
   unsigned int addr = x + y*WIDTH;
   if (img2[addr] == 0xCEA0A0A0) {
    img2[addr] = img[addr-1];
   }
  }
 }
 memcpy(img, img2, WIDTH*HEIGHT*sizeof(unsigned int));
 for (x=0;x<WIDTH;x++) {
  for (y=0;y<HEIGHT-1;y++) {
   unsigned int addr = x + y*WIDTH;
   if (img2[addr] == 0xCEA0A0A0) {
    img2[addr] = img[addr+WIDTH];
   }
  }
 }
 for (x=0;x<WIDTH;x++) {
  for (y=1;y<HEIGHT;y++) {
   unsigned int addr = x + y*WIDTH;
   if (img2[addr] == 0xCEA0A0A0) {
    img2[addr] = img[addr-WIDTH];
   }
  }
 }
 memcpy(img, img2, WIDTH*HEIGHT*sizeof(unsigned int));
}

variable_types:
x
unsigned int

variable_types:
y
unsigned int

variable_types:
addr
unsigned int