decompiled_code:
__int64 __fastcall sdl_key_to_az_key(int a1)
{
__int64 result; // rax

switch ( a1 )
{
case 8:
case 127:
result = 5LL;
break;
case 9:
result = 6LL;
break;
case 13:
result = 12LL;
break;
case 27:
result = 1LL;
break;
case 32:
result = 16LL;
break;
case 39:
result = 11LL;
break;
case 44:
result = 13LL;
break;
case 45:
result = 3LL;
break;
case 46:
result = 14LL;
break;
case 47:
result = 15LL;
break;
case 48:
result = 21LL;
break;
case 49:
result = 22LL;
break;
case 50:
result = 23LL;
break;
case 51:
result = 24LL;
break;
case 52:
result = 25LL;
break;
case 53:
result = 26LL;
break;
case 54:
result = 27LL;
break;
case 55:
result = 28LL;
break;
case 56:
result = 29LL;
break;
case 57:
result = 30LL;
break;
case 59:
result = 10LL;
break;
case 61:
result = 4LL;
break;
case 91:
result = 7LL;
break;
case 92:
result = 9LL;
break;
case 93:
result = 8LL;
break;
case 96:
result = 2LL;
break;
case 97:
result = 31LL;
break;
case 98:
result = 32LL;
break;
case 99:
result = 33LL;
break;
case 100:
result = 34LL;
break;
case 101:
result = 35LL;
break;
case 102:
result = 36LL;
break;
case 103:
result = 37LL;
break;
case 104:
result = 38LL;
break;
case 105:
result = 39LL;
break;
case 106:
result = 40LL;
break;
case 107:
result = 41LL;
break;
case 108:
result = 42LL;
break;
case 109:
result = 43LL;
break;
case 110:
result = 44LL;
break;
case 111:
result = 45LL;
break;
case 112:
result = 46LL;
break;
case 113:
result = 47LL;
break;
case 114:
result = 48LL;
break;
case 115:
result = 49LL;
break;
case 116:
result = 50LL;
break;
case 117:
result = 51LL;
break;
case 118:
result = 52LL;
break;
case 119:
result = 53LL;
break;
case 120:
result = 54LL;
break;
case 121:
result = 55LL;
break;
case 122:
result = 56LL;
break;
case 273:
result = 17LL;
break;
case 274:
result = 18LL;
break;
case 275:
result = 19LL;
break;
case 276:
result = 20LL;
break;
default:
result = 0LL;
break;
}
return result;
}

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

switch ( a1 )
{
case 8:
case 127:
result = 5LL;
break;
case 9:
result = 6LL;
break;
case 13:
result = 12LL;
break;
case 27:
result = 1LL;
break;
case 32:
result = 16LL;
break;
case 39:
result = 11LL;
break;
case 44:
result = 13LL;
break;
case 45:
result = 3LL;
break;
case 46:
result = 14LL;
break;
case 47:
result = 15LL;
break;
case 48:
result = 21LL;
break;
case 49:
result = 22LL;
break;
case 50:
result = 23LL;
break;
case 51:
result = 24LL;
break;
case 52:
result = 25LL;
break;
case 53:
result = 26LL;
break;
case 54:
result = 27LL;
break;
case 55:
result = 28LL;
break;
case 56:
result = 29LL;
break;
case 57:
result = 30LL;
break;
case 59:
result = 10LL;
break;
case 61:
result = 4LL;
break;
case 91:
result = 7LL;
break;
case 92:
result = 9LL;
break;
case 93:
result = 8LL;
break;
case 96:
result = 2LL;
break;
case 97:
result = 31LL;
break;
case 98:
result = 32LL;
break;
case 99:
result = 33LL;
break;
case 100:
result = 34LL;
break;
case 101:
result = 35LL;
break;
case 102:
result = 36LL;
break;
case 103:
result = 37LL;
break;
case 104:
result = 38LL;
break;
case 105:
result = 39LL;
break;
case 106:
result = 40LL;
break;
case 107:
result = 41LL;
break;
case 108:
result = 42LL;
break;
case 109:
result = 43LL;
break;
case 110:
result = 44LL;
break;
case 111:
result = 45LL;
break;
case 112:
result = 46LL;
break;
case 113:
result = 47LL;
break;
case 114:
result = 48LL;
break;
case 115:
result = 49LL;
break;
case 116:
result = 50LL;
break;
case 117:
result = 51LL;
break;
case 118:
result = 52LL;
break;
case 119:
result = 53LL;
break;
case 120:
result = 54LL;
break;
case 121:
result = 55LL;
break;
case 122:
result = 56LL;
break;
case 273:
result = 17LL;
break;
case 274:
result = 18LL;
break;
case 275:
result = 19LL;
break;
case 276:
result = 20LL;
break;
default:
result = 0LL;
break;
}
return result;
}

original_code:
static az_key_id_t sdl_key_to_az_key(SDLKey key) {
  switch (key) {
    case SDLK_BACKSPACE: return AZ_KEY_BACKSPACE;
    case SDLK_TAB: return AZ_KEY_TAB;
    case SDLK_RETURN: return AZ_KEY_RETURN;
    case SDLK_ESCAPE: return AZ_KEY_ESCAPE;
    case SDLK_SPACE: return AZ_KEY_SPACE;
    case SDLK_QUOTE: return AZ_KEY_QUOTE;
    case SDLK_COMMA: return AZ_KEY_COMMA;
    case SDLK_MINUS: return AZ_KEY_HYPHEN;
    case SDLK_PERIOD: return AZ_KEY_PERIOD;
    case SDLK_SLASH: return AZ_KEY_SLASH;
    case SDLK_0: return AZ_KEY_0;
    case SDLK_1: return AZ_KEY_1;
    case SDLK_2: return AZ_KEY_2;
    case SDLK_3: return AZ_KEY_3;
    case SDLK_4: return AZ_KEY_4;
    case SDLK_5: return AZ_KEY_5;
    case SDLK_6: return AZ_KEY_6;
    case SDLK_7: return AZ_KEY_7;
    case SDLK_8: return AZ_KEY_8;
    case SDLK_9: return AZ_KEY_9;
    case SDLK_SEMICOLON: return AZ_KEY_SEMICOLON;
    case SDLK_EQUALS: return AZ_KEY_EQUALS;
    case SDLK_LEFTBRACKET: return AZ_KEY_LEFT_BRACKET;
    case SDLK_BACKSLASH: return AZ_KEY_BACKSLASH;
    case SDLK_RIGHTBRACKET: return AZ_KEY_RIGHT_BRACKET;
    case SDLK_BACKQUOTE: return AZ_KEY_BACKTICK;
    case SDLK_a: return AZ_KEY_A;
    case SDLK_b: return AZ_KEY_B;
    case SDLK_c: return AZ_KEY_C;
    case SDLK_d: return AZ_KEY_D;
    case SDLK_e: return AZ_KEY_E;
    case SDLK_f: return AZ_KEY_F;
    case SDLK_g: return AZ_KEY_G;
    case SDLK_h: return AZ_KEY_H;
    case SDLK_i: return AZ_KEY_I;
    case SDLK_j: return AZ_KEY_J;
    case SDLK_k: return AZ_KEY_K;
    case SDLK_l: return AZ_KEY_L;
    case SDLK_m: return AZ_KEY_M;
    case SDLK_n: return AZ_KEY_N;
    case SDLK_o: return AZ_KEY_O;
    case SDLK_p: return AZ_KEY_P;
    case SDLK_q: return AZ_KEY_Q;
    case SDLK_r: return AZ_KEY_R;
    case SDLK_s: return AZ_KEY_S;
    case SDLK_t: return AZ_KEY_T;
    case SDLK_u: return AZ_KEY_U;
    case SDLK_v: return AZ_KEY_V;
    case SDLK_w: return AZ_KEY_W;
    case SDLK_x: return AZ_KEY_X;
    case SDLK_y: return AZ_KEY_Y;
    case SDLK_z: return AZ_KEY_Z;
    case SDLK_DELETE: return AZ_KEY_BACKSPACE;
    case SDLK_UP: return AZ_KEY_UP_ARROW;
    case SDLK_DOWN: return AZ_KEY_DOWN_ARROW;
    case SDLK_RIGHT: return AZ_KEY_RIGHT_ARROW;
    case SDLK_LEFT: return AZ_KEY_LEFT_ARROW;
    default: return AZ_KEY_UNKNOWN;
  }
}

canonical_original_code:
static enum az_key_id_t sdl_key_to_az_key(enum SDLKey key) {
  switch (key) {
    case SDLK_BACKSPACE: return AZ_KEY_BACKSPACE;
    case SDLK_TAB: return AZ_KEY_TAB;
    case SDLK_RETURN: return AZ_KEY_RETURN;
    case SDLK_ESCAPE: return AZ_KEY_ESCAPE;
    case SDLK_SPACE: return AZ_KEY_SPACE;
    case SDLK_QUOTE: return AZ_KEY_QUOTE;
    case SDLK_COMMA: return AZ_KEY_COMMA;
    case SDLK_MINUS: return AZ_KEY_HYPHEN;
    case SDLK_PERIOD: return AZ_KEY_PERIOD;
    case SDLK_SLASH: return AZ_KEY_SLASH;
    case SDLK_0: return AZ_KEY_0;
    case SDLK_1: return AZ_KEY_1;
    case SDLK_2: return AZ_KEY_2;
    case SDLK_3: return AZ_KEY_3;
    case SDLK_4: return AZ_KEY_4;
    case SDLK_5: return AZ_KEY_5;
    case SDLK_6: return AZ_KEY_6;
    case SDLK_7: return AZ_KEY_7;
    case SDLK_8: return AZ_KEY_8;
    case SDLK_9: return AZ_KEY_9;
    case SDLK_SEMICOLON: return AZ_KEY_SEMICOLON;
    case SDLK_EQUALS: return AZ_KEY_EQUALS;
    case SDLK_LEFTBRACKET: return AZ_KEY_LEFT_BRACKET;
    case SDLK_BACKSLASH: return AZ_KEY_BACKSLASH;
    case SDLK_RIGHTBRACKET: return AZ_KEY_RIGHT_BRACKET;
    case SDLK_BACKQUOTE: return AZ_KEY_BACKTICK;
    case SDLK_a: return AZ_KEY_A;
    case SDLK_b: return AZ_KEY_B;
    case SDLK_c: return AZ_KEY_C;
    case SDLK_d: return AZ_KEY_D;
    case SDLK_e: return AZ_KEY_E;
    case SDLK_f: return AZ_KEY_F;
    case SDLK_g: return AZ_KEY_G;
    case SDLK_h: return AZ_KEY_H;
    case SDLK_i: return AZ_KEY_I;
    case SDLK_j: return AZ_KEY_J;
    case SDLK_k: return AZ_KEY_K;
    case SDLK_l: return AZ_KEY_L;
    case SDLK_m: return AZ_KEY_M;
    case SDLK_n: return AZ_KEY_N;
    case SDLK_o: return AZ_KEY_O;
    case SDLK_p: return AZ_KEY_P;
    case SDLK_q: return AZ_KEY_Q;
    case SDLK_r: return AZ_KEY_R;
    case SDLK_s: return AZ_KEY_S;
    case SDLK_t: return AZ_KEY_T;
    case SDLK_u: return AZ_KEY_U;
    case SDLK_v: return AZ_KEY_V;
    case SDLK_w: return AZ_KEY_W;
    case SDLK_x: return AZ_KEY_X;
    case SDLK_y: return AZ_KEY_Y;
    case SDLK_z: return AZ_KEY_Z;
    case SDLK_DELETE: return AZ_KEY_BACKSPACE;
    case SDLK_UP: return AZ_KEY_UP_ARROW;
    case SDLK_DOWN: return AZ_KEY_DOWN_ARROW;
    case SDLK_RIGHT: return AZ_KEY_RIGHT_ARROW;
    case SDLK_LEFT: return AZ_KEY_LEFT_ARROW;
    default: return AZ_KEY_UNKNOWN;
  }
}

variable_types: enum SDLKey { SDLK_UNKNOWN=0, SDLK_FIRST=0, SDLK_BACKSPACE=8, SDLK_TAB=9, SDLK_CLEAR=12, SDLK_RETURN=13, SDLK_PAUSE=19, SDLK_ESCAPE=27, SDLK_SPACE=32, SDLK_EXCLAIM=33, SDLK_QUOTEDBL=34, SDLK_HASH=35, SDLK_DOLLAR=36, SDLK_AMPERSAND=38, SDLK_QUOTE=39, SDLK_LEFTPAREN=40, SDLK_RIGHTPAREN=41, SDLK_ASTERISK=42, SDLK_PLUS=43, SDLK_COMMA=44, SDLK_MINUS=45, SDLK_PERIOD=46, SDLK_SLASH=47, SDLK_0=48, SDLK_1=49, SDLK_2=50, SDLK_3=51, SDLK_4=52, SDLK_5=53, SDLK_6=54, SDLK_7=55, SDLK_8=56, SDLK_9=57, SDLK_COLON=58, SDLK_SEMICOLON=59, SDLK_LESS=60, SDLK_EQUALS=61, SDLK_GREATER=62, SDLK_QUESTION=63, SDLK_AT=64, SDLK_LEFTBRACKET=91, SDLK_BACKSLASH=92, SDLK_RIGHTBRACKET=93, SDLK_CARET=94, SDLK_UNDERSCORE=95, SDLK_BACKQUOTE=96, SDLK_a=97, SDLK_b=98, SDLK_c=99, SDLK_d=100, SDLK_e=101, SDLK_f=102, SDLK_g=103, SDLK_h=104, SDLK_i=105, SDLK_j=106, SDLK_k=107, SDLK_l=108, SDLK_m=109, SDLK_n=110, SDLK_o=111, SDLK_p=112, SDLK_q=113, SDLK_r=114, SDLK_s=115, SDLK_t=116, SDLK_u=117, SDLK_v=118, SDLK_w=119, SDLK_x=120, SDLK_y=121, SDLK_z=122, SDLK_DELETE=127, SDLK_WORLD_0=160, SDLK_WORLD_1=161, SDLK_WORLD_2=162, SDLK_WORLD_3=163, SDLK_WORLD_4=164, SDLK_WORLD_5=165, SDLK_WORLD_6=166, SDLK_WORLD_7=167, SDLK_WORLD_8=168, SDLK_WORLD_9=169, SDLK_WORLD_10=170, SDLK_WORLD_11=171, SDLK_WORLD_12=172, SDLK_WORLD_13=173, SDLK_WORLD_14=174, SDLK_WORLD_15=175, SDLK_WORLD_16=176, SDLK_WORLD_17=177, SDLK_WORLD_18=178, SDLK_WORLD_19=179, SDLK_WORLD_20=180, SDLK_WORLD_21=181, SDLK_WORLD_22=182, SDLK_WORLD_23=183, SDLK_WORLD_24=184, SDLK_WORLD_25=185, SDLK_WORLD_26=186, SDLK_WORLD_27=187, SDLK_WORLD_28=188, SDLK_WORLD_29=189, SDLK_WORLD_30=190, SDLK_WORLD_31=191, SDLK_WORLD_32=192, SDLK_WORLD_33=193, SDLK_WORLD_34=194, SDLK_WORLD_35=195, SDLK_WORLD_36=196, SDLK_WORLD_37=197, SDLK_WORLD_38=198, SDLK_WORLD_39=199, SDLK_WORLD_40=200, SDLK_WORLD_41=201, SDLK_WORLD_42=202, SDLK_WORLD_43=203, SDLK_WORLD_44=204, SDLK_WORLD_45=205, SDLK_WORLD_46=206, SDLK_WORLD_47=207, SDLK_WORLD_48=208, SDLK_WORLD_49=209, SDLK_WORLD_50=210, SDLK_WORLD_51=211, SDLK_WORLD_52=212, SDLK_WORLD_53=213, SDLK_WORLD_54=214, SDLK_WORLD_55=215, SDLK_WORLD_56=216, SDLK_WORLD_57=217, SDLK_WORLD_58=218, SDLK_WORLD_59=219, SDLK_WORLD_60=220, SDLK_WORLD_61=221, SDLK_WORLD_62=222, SDLK_WORLD_63=223, SDLK_WORLD_64=224, SDLK_WORLD_65=225, SDLK_WORLD_66=226, SDLK_WORLD_67=227, SDLK_WORLD_68=228, SDLK_WORLD_69=229, SDLK_WORLD_70=230, SDLK_WORLD_71=231, SDLK_WORLD_72=232, SDLK_WORLD_73=233, SDLK_WORLD_74=234, SDLK_WORLD_75=235, SDLK_WORLD_76=236, SDLK_WORLD_77=237, SDLK_WORLD_78=238, SDLK_WORLD_79=239, SDLK_WORLD_80=240, SDLK_WORLD_81=241, SDLK_WORLD_82=242, SDLK_WORLD_83=243, SDLK_WORLD_84=244, SDLK_WORLD_85=245, SDLK_WORLD_86=246, SDLK_WORLD_87=247, SDLK_WORLD_88=248, SDLK_WORLD_89=249, SDLK_WORLD_90=250, SDLK_WORLD_91=251, SDLK_WORLD_92=252, SDLK_WORLD_93=253, SDLK_WORLD_94=254, SDLK_WORLD_95=255, SDLK_KP0=256, SDLK_KP1=257, SDLK_KP2=258, SDLK_KP3=259, SDLK_KP4=260, SDLK_KP5=261, SDLK_KP6=262, SDLK_KP7=263, SDLK_KP8=264, SDLK_KP9=265, SDLK_KP_PERIOD=266, SDLK_KP_DIVIDE=267, SDLK_KP_MULTIPLY=268, SDLK_KP_MINUS=269, SDLK_KP_PLUS=270, SDLK_KP_ENTER=271, SDLK_KP_EQUALS=272, SDLK_UP=273, SDLK_DOWN=274, SDLK_RIGHT=275, SDLK_LEFT=276, SDLK_INSERT=277, SDLK_HOME=278, SDLK_END=279, SDLK_PAGEUP=280, SDLK_PAGEDOWN=281, SDLK_F1=282, SDLK_F2=283, SDLK_F3=284, SDLK_F4=285, SDLK_F5=286, SDLK_F6=287, SDLK_F7=288, SDLK_F8=289, SDLK_F9=290, SDLK_F10=291, SDLK_F11=292, SDLK_F12=293, SDLK_F13=294, SDLK_F14=295, SDLK_F15=296, SDLK_NUMLOCK=300, SDLK_CAPSLOCK=301, SDLK_SCROLLOCK=302, SDLK_RSHIFT=303, SDLK_LSHIFT=304, SDLK_RCTRL=305, SDLK_LCTRL=306, SDLK_RALT=307, SDLK_LALT=308, SDLK_RMETA=309, SDLK_LMETA=310, SDLK_LSUPER=311, SDLK_RSUPER=312, SDLK_MODE=313, SDLK_COMPOSE=314, SDLK_HELP=315, SDLK_PRINT=316, SDLK_SYSREQ=317, SDLK_BREAK=318, SDLK_MENU=319, SDLK_POWER=320, SDLK_EURO=321, SDLK_UNDO=322, SDLK_LAST=323 }

return_type: enum az_key_id_t { AZ_KEY_UNKNOWN=0, AZ_KEY_ESCAPE=1, AZ_KEY_BACKTICK=2, AZ_KEY_HYPHEN=3, AZ_KEY_EQUALS=4, AZ_KEY_BACKSPACE=5, AZ_KEY_TAB=6, AZ_KEY_LEFT_BRACKET=7, AZ_KEY_RIGHT_BRACKET=8, AZ_KEY_BACKSLASH=9, AZ_KEY_SEMICOLON=10, AZ_KEY_QUOTE=11, AZ_KEY_RETURN=12, AZ_KEY_COMMA=13, AZ_KEY_PERIOD=14, AZ_KEY_SLASH=15, AZ_KEY_SPACE=16, AZ_KEY_UP_ARROW=17, AZ_KEY_DOWN_ARROW=18, AZ_KEY_RIGHT_ARROW=19, AZ_KEY_LEFT_ARROW=20, AZ_KEY_0=21, AZ_KEY_1=22, AZ_KEY_2=23, AZ_KEY_3=24, AZ_KEY_4=25, AZ_KEY_5=26, AZ_KEY_6=27, AZ_KEY_7=28, AZ_KEY_8=29, AZ_KEY_9=30, AZ_KEY_A=31, AZ_KEY_B=32, AZ_KEY_C=33, AZ_KEY_D=34, AZ_KEY_E=35, AZ_KEY_F=36, AZ_KEY_G=37, AZ_KEY_H=38, AZ_KEY_I=39, AZ_KEY_J=40, AZ_KEY_K=41, AZ_KEY_L=42, AZ_KEY_M=43, AZ_KEY_N=44, AZ_KEY_O=45, AZ_KEY_P=46, AZ_KEY_Q=47, AZ_KEY_R=48, AZ_KEY_S=49, AZ_KEY_T=50, AZ_KEY_U=51, AZ_KEY_V=52, AZ_KEY_W=53, AZ_KEY_X=54, AZ_KEY_Y=55, AZ_KEY_Z=56 }


repo: mdsteele/milestone

decompiled_code:
__int64 __fastcall az_key_to_sdl_key(int a1)
{
if ( !a1 )
_assert_fail("key != AZ_KEY_UNKNOWN", "src/milestone/gui/event.c", 0x2Bu, "az_key_to_sdl_key");
switch ( a1 )
{
case 0:
az_fatal("az_key_to_sdl_key", "line %d: unreachable\n", 45LL);
return 61LL;
case 1:
return 27LL;
case 2:
return 96LL;
case 3:
return 45LL;
case 4:
return 61LL;
case 5:
return 8LL;
case 6:
return 9LL;
case 7:
return 91LL;
case 8:
return 93LL;
case 9:
return 92LL;
case 10:
return 59LL;
case 11:
return 39LL;
case 12:
return 13LL;
case 13:
return 44LL;
case 14:
return 46LL;
case 15:
return 47LL;
case 16:
return 32LL;
case 17:
return 273LL;
case 18:
return 274LL;
case 19:
return 275LL;
case 20:
return 276LL;
case 21:
return 48LL;
case 22:
return 49LL;
case 23:
return 50LL;
case 24:
return 51LL;
case 25:
return 52LL;
case 26:
return 53LL;
case 27:
return 54LL;
case 28:
return 55LL;
case 29:
return 56LL;
case 30:
return 57LL;
case 31:
return 97LL;
case 32:
return 98LL;
case 33:
return 99LL;
case 34:
return 100LL;
case 35:
return 101LL;
case 36:
return 102LL;
case 37:
return 103LL;
case 38:
return 104LL;
case 39:
return 105LL;
case 40:
return 106LL;
case 41:
return 107LL;
case 42:
return 108LL;
case 43:
return 109LL;
case 44:
return 110LL;
case 45:
return 111LL;
case 46:
return 112LL;
case 47:
return 113LL;
case 48:
return 114LL;
case 49:
return 115LL;
case 50:
return 116LL;
case 51:
return 117LL;
case 52:
return 118LL;
case 53:
return 119LL;
case 54:
return 120LL;
case 55:
return 121LL;
case 56:
return 122LL;
default:
az_fatal("az_key_to_sdl_key", "line %d: unreachable\n", 103LL);
return 27LL;
}
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1)
{
if ( !a1 )
_assert_fail("key != AZ_KEY_UNKNOWN", "src/milestone/gui/event.c", 0x2Bu, "az_key_to_sdl_key");
switch ( a1 )
{
case 0:
az_fatal("az_key_to_sdl_key", "line %d: unreachable\n", 45LL);
return 61LL;
case 1:
return 27LL;
case 2:
return 96LL;
case 3:
return 45LL;
case 4:
return 61LL;
case 5:
return 8LL;
case 6:
return 9LL;
case 7:
return 91LL;
case 8:
return 93LL;
case 9:
return 92LL;
case 10:
return 59LL;
case 11:
return 39LL;
case 12:
return 13LL;
case 13:
return 44LL;
case 14:
return 46LL;
case 15:
return 47LL;
case 16:
return 32LL;
case 17:
return 273LL;
case 18:
return 274LL;
case 19:
return 275LL;
case 20:
return 276LL;
case 21:
return 48LL;
case 22:
return 49LL;
case 23:
return 50LL;
case 24:
return 51LL;
case 25:
return 52LL;
case 26:
return 53LL;
case 27:
return 54LL;
case 28:
return 55LL;
case 29:
return 56LL;
case 30:
return 57LL;
case 31:
return 97LL;
case 32:
return 98LL;
case 33:
return 99LL;
case 34:
return 100LL;
case 35:
return 101LL;
case 36:
return 102LL;
case 37:
return 103LL;
case 38:
return 104LL;
case 39:
return 105LL;
case 40:
return 106LL;
case 41:
return 107LL;
case 42:
return 108LL;
case 43:
return 109LL;
case 44:
return 110LL;
case 45:
return 111LL;
case 46:
return 112LL;
case 47:
return 113LL;
case 48:
return 114LL;
case 49:
return 115LL;
case 50:
return 116LL;
case 51:
return 117LL;
case 52:
return 118LL;
case 53:
return 119LL;
case 54:
return 120LL;
case 55:
return 121LL;
case 56:
return 122LL;
default:
az_fatal("az_key_to_sdl_key", "line %d: unreachable\n", 103LL);
return 27LL;
}
}

original_code:
static SDLKey az_key_to_sdl_key(az_key_id_t key) {
  ((key != AZ_KEY_UNKNOWN) ? (void) (0) : __assert_fail ("key != AZ_KEY_UNKNOWN", "src/milestone/gui/event.c", 43, __extension__ __PRETTY_FUNCTION__));
  switch (key) {
    case AZ_KEY_UNKNOWN: _az_fatal(__func__, "line %d: unreachable\n", 45);
    case AZ_KEY_ESCAPE: return SDLK_ESCAPE;
    case AZ_KEY_BACKTICK: return SDLK_BACKQUOTE;
    case AZ_KEY_HYPHEN: return SDLK_MINUS;
    case AZ_KEY_EQUALS: return SDLK_EQUALS;
    case AZ_KEY_BACKSPACE: return SDLK_BACKSPACE;
    case AZ_KEY_TAB: return SDLK_TAB;
    case AZ_KEY_LEFT_BRACKET: return SDLK_LEFTBRACKET;
    case AZ_KEY_RIGHT_BRACKET: return SDLK_RIGHTBRACKET;
    case AZ_KEY_BACKSLASH: return SDLK_BACKSLASH;
    case AZ_KEY_SEMICOLON: return SDLK_SEMICOLON;
    case AZ_KEY_QUOTE: return SDLK_QUOTE;
    case AZ_KEY_RETURN: return SDLK_RETURN;
    case AZ_KEY_COMMA: return SDLK_COMMA;
    case AZ_KEY_PERIOD: return SDLK_PERIOD;
    case AZ_KEY_SLASH: return SDLK_SLASH;
    case AZ_KEY_SPACE: return SDLK_SPACE;
    case AZ_KEY_UP_ARROW: return SDLK_UP;
    case AZ_KEY_DOWN_ARROW: return SDLK_DOWN;
    case AZ_KEY_LEFT_ARROW: return SDLK_LEFT;
    case AZ_KEY_RIGHT_ARROW: return SDLK_RIGHT;
    case AZ_KEY_0: return SDLK_0;
    case AZ_KEY_1: return SDLK_1;
    case AZ_KEY_2: return SDLK_2;
    case AZ_KEY_3: return SDLK_3;
    case AZ_KEY_4: return SDLK_4;
    case AZ_KEY_5: return SDLK_5;
    case AZ_KEY_6: return SDLK_6;
    case AZ_KEY_7: return SDLK_7;
    case AZ_KEY_8: return SDLK_8;
    case AZ_KEY_9: return SDLK_9;
    case AZ_KEY_A: return SDLK_a;
    case AZ_KEY_B: return SDLK_b;
    case AZ_KEY_C: return SDLK_c;
    case AZ_KEY_D: return SDLK_d;
    case AZ_KEY_E: return SDLK_e;
    case AZ_KEY_F: return SDLK_f;
    case AZ_KEY_G: return SDLK_g;
    case AZ_KEY_H: return SDLK_h;
    case AZ_KEY_I: return SDLK_i;
    case AZ_KEY_J: return SDLK_j;
    case AZ_KEY_K: return SDLK_k;
    case AZ_KEY_L: return SDLK_l;
    case AZ_KEY_M: return SDLK_m;
    case AZ_KEY_N: return SDLK_n;
    case AZ_KEY_O: return SDLK_o;
    case AZ_KEY_P: return SDLK_p;
    case AZ_KEY_Q: return SDLK_q;
    case AZ_KEY_R: return SDLK_r;
    case AZ_KEY_S: return SDLK_s;
    case AZ_KEY_T: return SDLK_t;
    case AZ_KEY_U: return SDLK_u;
    case AZ_KEY_V: return SDLK_v;
    case AZ_KEY_W: return SDLK_w;
    case AZ_KEY_X: return SDLK_x;
    case AZ_KEY_Y: return SDLK_y;
    case AZ_KEY_Z: return SDLK_z;
  }
  _az_fatal(__func__, "line %d: unreachable\n", 103);
}

canonical_original_code:
static enum SDLKey az_key_to_sdl_key(enum az_key_id_t key) {
  ((key != AZ_KEY_UNKNOWN) ? (void) (0) : __assert_fail ("key != AZ_KEY_UNKNOWN", "src/milestone/gui/event.c", 43, __extension__ __PRETTY_FUNCTION__));
  switch (key) {
    case AZ_KEY_UNKNOWN: _az_fatal(__func__, "line %d: unreachable\n", 45);
    case AZ_KEY_ESCAPE: return SDLK_ESCAPE;
    case AZ_KEY_BACKTICK: return SDLK_BACKQUOTE;
    case AZ_KEY_HYPHEN: return SDLK_MINUS;
    case AZ_KEY_EQUALS: return SDLK_EQUALS;
    case AZ_KEY_BACKSPACE: return SDLK_BACKSPACE;
    case AZ_KEY_TAB: return SDLK_TAB;
    case AZ_KEY_LEFT_BRACKET: return SDLK_LEFTBRACKET;
    case AZ_KEY_RIGHT_BRACKET: return SDLK_RIGHTBRACKET;
    case AZ_KEY_BACKSLASH: return SDLK_BACKSLASH;
    case AZ_KEY_SEMICOLON: return SDLK_SEMICOLON;
    case AZ_KEY_QUOTE: return SDLK_QUOTE;
    case AZ_KEY_RETURN: return SDLK_RETURN;
    case AZ_KEY_COMMA: return SDLK_COMMA;
    case AZ_KEY_PERIOD: return SDLK_PERIOD;
    case AZ_KEY_SLASH: return SDLK_SLASH;
    case AZ_KEY_SPACE: return SDLK_SPACE;
    case AZ_KEY_UP_ARROW: return SDLK_UP;
    case AZ_KEY_DOWN_ARROW: return SDLK_DOWN;
    case AZ_KEY_LEFT_ARROW: return SDLK_LEFT;
    case AZ_KEY_RIGHT_ARROW: return SDLK_RIGHT;
    case AZ_KEY_0: return SDLK_0;
    case AZ_KEY_1: return SDLK_1;
    case AZ_KEY_2: return SDLK_2;
    case AZ_KEY_3: return SDLK_3;
    case AZ_KEY_4: return SDLK_4;
    case AZ_KEY_5: return SDLK_5;
    case AZ_KEY_6: return SDLK_6;
    case AZ_KEY_7: return SDLK_7;
    case AZ_KEY_8: return SDLK_8;
    case AZ_KEY_9: return SDLK_9;
    case AZ_KEY_A: return SDLK_a;
    case AZ_KEY_B: return SDLK_b;
    case AZ_KEY_C: return SDLK_c;
    case AZ_KEY_D: return SDLK_d;
    case AZ_KEY_E: return SDLK_e;
    case AZ_KEY_F: return SDLK_f;
    case AZ_KEY_G: return SDLK_g;
    case AZ_KEY_H: return SDLK_h;
    case AZ_KEY_I: return SDLK_i;
    case AZ_KEY_J: return SDLK_j;
    case AZ_KEY_K: return SDLK_k;
    case AZ_KEY_L: return SDLK_l;
    case AZ_KEY_M: return SDLK_m;
    case AZ_KEY_N: return SDLK_n;
    case AZ_KEY_O: return SDLK_o;
    case AZ_KEY_P: return SDLK_p;
    case AZ_KEY_Q: return SDLK_q;
    case AZ_KEY_R: return SDLK_r;
    case AZ_KEY_S: return SDLK_s;
    case AZ_KEY_T: return SDLK_t;
    case AZ_KEY_U: return SDLK_u;
    case AZ_KEY_V: return SDLK_v;
    case AZ_KEY_W: return SDLK_w;
    case AZ_KEY_X: return SDLK_x;
    case AZ_KEY_Y: return SDLK_y;
    case AZ_KEY_Z: return SDLK_z;
  }
  _az_fatal(__func__, "line %d: unreachable\n", 103);
}

variable_types: enum az_key_id_t { AZ_KEY_UNKNOWN=0, AZ_KEY_ESCAPE=1, AZ_KEY_BACKTICK=2, AZ_KEY_HYPHEN=3, AZ_KEY_EQUALS=4, AZ_KEY_BACKSPACE=5, AZ_KEY_TAB=6, AZ_KEY_LEFT_BRACKET=7, AZ_KEY_RIGHT_BRACKET=8, AZ_KEY_BACKSLASH=9, AZ_KEY_SEMICOLON=10, AZ_KEY_QUOTE=11, AZ_KEY_RETURN=12, AZ_KEY_COMMA=13, AZ_KEY_PERIOD=14, AZ_KEY_SLASH=15, AZ_KEY_SPACE=16, AZ_KEY_UP_ARROW=17, AZ_KEY_DOWN_ARROW=18, AZ_KEY_RIGHT_ARROW=19, AZ_KEY_LEFT_ARROW=20, AZ_KEY_0=21, AZ_KEY_1=22, AZ_KEY_2=23, AZ_KEY_3=24, AZ_KEY_4=25, AZ_KEY_5=26, AZ_KEY_6=27, AZ_KEY_7=28, AZ_KEY_8=29, AZ_KEY_9=30, AZ_KEY_A=31, AZ_KEY_B=32, AZ_KEY_C=33, AZ_KEY_D=34, AZ_KEY_E=35, AZ_KEY_F=36, AZ_KEY_G=37, AZ_KEY_H=38, AZ_KEY_I=39, AZ_KEY_J=40, AZ_KEY_K=41, AZ_KEY_L=42, AZ_KEY_M=43, AZ_KEY_N=44, AZ_KEY_O=45, AZ_KEY_P=46, AZ_KEY_Q=47, AZ_KEY_R=48, AZ_KEY_S=49, AZ_KEY_T=50, AZ_KEY_U=51, AZ_KEY_V=52, AZ_KEY_W=53, AZ_KEY_X=54, AZ_KEY_Y=55, AZ_KEY_Z=56 }

return_type: enum SDLKey { SDLK_UNKNOWN=0, SDLK_FIRST=0, SDLK_BACKSPACE=8, SDLK_TAB=9, SDLK_CLEAR=12, SDLK_RETURN=13, SDLK_PAUSE=19, SDLK_ESCAPE=27, SDLK_SPACE=32, SDLK_EXCLAIM=33, SDLK_QUOTEDBL=34, SDLK_HASH=35, SDLK_DOLLAR=36, SDLK_AMPERSAND=38, SDLK_QUOTE=39, SDLK_LEFTPAREN=40, SDLK_RIGHTPAREN=41, SDLK_ASTERISK=42, SDLK_PLUS=43, SDLK_COMMA=44, SDLK_MINUS=45, SDLK_PERIOD=46, SDLK_SLASH=47, SDLK_0=48, SDLK_1=49, SDLK_2=50, SDLK_3=51, SDLK_4=52, SDLK_5=53, SDLK_6=54, SDLK_7=55, SDLK_8=56, SDLK_9=57, SDLK_COLON=58, SDLK_SEMICOLON=59, SDLK_LESS=60, SDLK_EQUALS=61, SDLK_GREATER=62, SDLK_QUESTION=63, SDLK_AT=64, SDLK_LEFTBRACKET=91, SDLK_BACKSLASH=92, SDLK_RIGHTBRACKET=93, SDLK_CARET=94, SDLK_UNDERSCORE=95, SDLK_BACKQUOTE=96, SDLK_a=97, SDLK_b=98, SDLK_c=99, SDLK_d=100, SDLK_e=101, SDLK_f=102, SDLK_g=103, SDLK_h=104, SDLK_i=105, SDLK_j=106, SDLK_k=107, SDLK_l=108, SDLK_m=109, SDLK_n=110, SDLK_o=111, SDLK_p=112, SDLK_q=113, SDLK_r=114, SDLK_s=115, SDLK_t=116, SDLK_u=117, SDLK_v=118, SDLK_w=119, SDLK_x=120, SDLK_y=121, SDLK_z=122, SDLK_DELETE=127, SDLK_WORLD_0=160, SDLK_WORLD_1=161, SDLK_WORLD_2=162, SDLK_WORLD_3=163, SDLK_WORLD_4=164, SDLK_WORLD_5=165, SDLK_WORLD_6=166, SDLK_WORLD_7=167, SDLK_WORLD_8=168, SDLK_WORLD_9=169, SDLK_WORLD_10=170, SDLK_WORLD_11=171, SDLK_WORLD_12=172, SDLK_WORLD_13=173, SDLK_WORLD_14=174, SDLK_WORLD_15=175, SDLK_WORLD_16=176, SDLK_WORLD_17=177, SDLK_WORLD_18=178, SDLK_WORLD_19=179, SDLK_WORLD_20=180, SDLK_WORLD_21=181, SDLK_WORLD_22=182, SDLK_WORLD_23=183, SDLK_WORLD_24=184, SDLK_WORLD_25=185, SDLK_WORLD_26=186, SDLK_WORLD_27=187, SDLK_WORLD_28=188, SDLK_WORLD_29=189, SDLK_WORLD_30=190, SDLK_WORLD_31=191, SDLK_WORLD_32=192, SDLK_WORLD_33=193, SDLK_WORLD_34=194, SDLK_WORLD_35=195, SDLK_WORLD_36=196, SDLK_WORLD_37=197, SDLK_WORLD_38=198, SDLK_WORLD_39=199, SDLK_WORLD_40=200, SDLK_WORLD_41=201, SDLK_WORLD_42=202, SDLK_WORLD_43=203, SDLK_WORLD_44=204, SDLK_WORLD_45=205, SDLK_WORLD_46=206, SDLK_WORLD_47=207, SDLK_WORLD_48=208, SDLK_WORLD_49=209, SDLK_WORLD_50=210, SDLK_WORLD_51=211, SDLK_WORLD_52=212, SDLK_WORLD_53=213, SDLK_WORLD_54=214, SDLK_WORLD_55=215, SDLK_WORLD_56=216, SDLK_WORLD_57=217, SDLK_WORLD_58=218, SDLK_WORLD_59=219, SDLK_WORLD_60=220, SDLK_WORLD_61=221, SDLK_WORLD_62=222, SDLK_WORLD_63=223, SDLK_WORLD_64=224, SDLK_WORLD_65=225, SDLK_WORLD_66=226, SDLK_WORLD_67=227, SDLK_WORLD_68=228, SDLK_WORLD_69=229, SDLK_WORLD_70=230, SDLK_WORLD_71=231, SDLK_WORLD_72=232, SDLK_WORLD_73=233, SDLK_WORLD_74=234, SDLK_WORLD_75=235, SDLK_WORLD_76=236, SDLK_WORLD_77=237, SDLK_WORLD_78=238, SDLK_WORLD_79=239, SDLK_WORLD_80=240, SDLK_WORLD_81=241, SDLK_WORLD_82=242, SDLK_WORLD_83=243, SDLK_WORLD_84=244, SDLK_WORLD_85=245, SDLK_WORLD_86=246, SDLK_WORLD_87=247, SDLK_WORLD_88=248, SDLK_WORLD_89=249, SDLK_WORLD_90=250, SDLK_WORLD_91=251, SDLK_WORLD_92=252, SDLK_WORLD_93=253, SDLK_WORLD_94=254, SDLK_WORLD_95=255, SDLK_KP0=256, SDLK_KP1=257, SDLK_KP2=258, SDLK_KP3=259, SDLK_KP4=260, SDLK_KP5=261, SDLK_KP6=262, SDLK_KP7=263, SDLK_KP8=264, SDLK_KP9=265, SDLK_KP_PERIOD=266, SDLK_KP_DIVIDE=267, SDLK_KP_MULTIPLY=268, SDLK_KP_MINUS=269, SDLK_KP_PLUS=270, SDLK_KP_ENTER=271, SDLK_KP_EQUALS=272, SDLK_UP=273, SDLK_DOWN=274, SDLK_RIGHT=275, SDLK_LEFT=276, SDLK_INSERT=277, SDLK_HOME=278, SDLK_END=279, SDLK_PAGEUP=280, SDLK_PAGEDOWN=281, SDLK_F1=282, SDLK_F2=283, SDLK_F3=284, SDLK_F4=285, SDLK_F5=286, SDLK_F6=287, SDLK_F7=288, SDLK_F8=289, SDLK_F9=290, SDLK_F10=291, SDLK_F11=292, SDLK_F12=293, SDLK_F13=294, SDLK_F14=295, SDLK_F15=296, SDLK_NUMLOCK=300, SDLK_CAPSLOCK=301, SDLK_SCROLLOCK=302, SDLK_RSHIFT=303, SDLK_LSHIFT=304, SDLK_RCTRL=305, SDLK_LCTRL=306, SDLK_RALT=307, SDLK_LALT=308, SDLK_RMETA=309, SDLK_LMETA=310, SDLK_LSUPER=311, SDLK_RSUPER=312, SDLK_MODE=313, SDLK_COMPOSE=314, SDLK_HELP=315, SDLK_PRINT=316, SDLK_SYSREQ=317, SDLK_BREAK=318, SDLK_MENU=319, SDLK_POWER=320, SDLK_EURO=321, SDLK_UNDO=322, SDLK_LAST=323 }


decompiled_code:
__int64 __fastcall az_get_mouse_position(__int64 a1, __int64 a2)
{
char v2; // dl
__int64 result; // rax

v2 = SDL_GetAppState();
result = 0LL;
if ( (v2 & 1) != 0 )
{
SDL_GetMouseState(a1, a2);
result = 1LL;
}
return result;
}

canonical_decompiled_code:
__int64 __fastcall func4(__int64 a1, __int64 a2)
{
char v2; // dl
__int64 result; // rax

v2 = SDL_GetAppState();
result = 0LL;
if ( (v2 & 1) != 0 )
{
SDL_GetMouseState(a1, a2);
result = 1LL;
}
return result;
}

original_code:
_Bool az_get_mouse_position(int *x, int *y) {
  if (!(SDL_GetAppState() & 0x01)) return 0;
  SDL_GetMouseState(x, y);
  return 1;
}

variable_types:
x
int *

variable_types:
y
int *


decompiled_code:
__int64 __fastcall az_set_mouse_position(unsigned __int16 a1, unsigned __int16 a2)
{
return SDL_WarpMouse(a1, a2);
}

canonical_decompiled_code:
__int64 __fastcall func5(unsigned __int16 a1, unsigned __int16 a2)
{
return SDL_WarpMouse(a1, a2);
}

original_code:
void az_set_mouse_position(int x, int y) {
  SDL_WarpMouse(x, y);
}

variable_types: x int

variable_types: y int

return_type: void


decompiled_code:
__int64 az_is_mouse_held()
{
return SDL_GetMouseState(0LL, 0LL) & 1;
}

canonical_decompiled_code:
__int64 func6()
{
return SDL_GetMouseState(0LL, 0LL) & 1;
}

original_code:
_Bool az_is_mouse_held(void) {
  return (_Bool)(SDL_GetMouseState(((void *)0), ((void *)0)) & (1 << ((1)-1)));
}

canonical_original_code:
_Bool az_is_mouse_held() {
  return (_Bool)(SDL_GetMouseState(((void *)0), ((void *)0)) & (1 << ((1)-1)));
}


decompiled_code:
bool __fastcall az_is_key_held(int a1)
{
__int64 v1; // rbp

if ( !a1 )
_assert_fail("key != AZ_KEY_UNKNOWN", "src/milestone/gui/event.c", 0x116u, "az_is_key_held");
v1 = SDL_GetKeyState(0LL);
return *(_BYTE *)(v1 + (unsigned int)az_key_to_sdl_key(a1)) != 0;
}

canonical_decompiled_code:
bool __fastcall func7(int a1)
{
__int64 v1; // rbp

if ( !a1 )
_assert_fail("key != AZ_KEY_UNKNOWN", "src/milestone/gui/event.c", 0x116u, "az_is_key_held");
v1 = SDL_GetKeyState(0LL);
return *(_BYTE *)(v1 + (unsigned int)func2(a1)) != 0;
}

original_code:
_Bool az_is_key_held(az_key_id_t key) {
  ((key != AZ_KEY_UNKNOWN) ? (void) (0) : __assert_fail ("key != AZ_KEY_UNKNOWN", "src/milestone/gui/event.c", 278, __extension__ __PRETTY_FUNCTION__));
  return (_Bool)SDL_GetKeyState(((void *)0))[az_key_to_sdl_key(key)];
}

canonical_original_code:
_Bool az_is_key_held(enum az_key_id_t key) {
  ((key != AZ_KEY_UNKNOWN) ? (void) (0) : __assert_fail ("key != AZ_KEY_UNKNOWN", "src/milestone/gui/event.c", 278, __extension__ __PRETTY_FUNCTION__));
  return (_Bool)SDL_GetKeyState(((void *)0))[az_key_to_sdl_key(key)];
}

user_defined_types: enum az_key_id_t { AZ_KEY_UNKNOWN=0, AZ_KEY_ESCAPE=1, AZ_KEY_BACKTICK=2, AZ_KEY_HYPHEN=3, AZ_KEY_EQUALS=4, AZ_KEY_BACKSPACE=5, AZ_KEY_TAB=6, AZ_KEY_LEFT_BRACKET=7, AZ_KEY_RIGHT_BRACKET=8, AZ_KEY_BACKSLASH=9, AZ_KEY_SEMICOLON=10, AZ_KEY_QUOTE=11, AZ_KEY_RETURN=12, AZ_KEY_COMMA=13, AZ_KEY_PERIOD=14, AZ_KEY_SLASH=15, AZ_KEY_SPACE=16, AZ_KEY_UP_ARROW=17, AZ_KEY_DOWN_ARROW=18, AZ_KEY_RIGHT_ARROW=19, AZ_KEY_LEFT_ARROW=20, AZ_KEY_0=21, AZ_KEY_1=22, AZ_KEY_2=23, AZ_KEY_3=24, AZ_KEY_4=25, AZ_KEY_5=26, AZ_KEY_6=27, AZ_KEY_7=28, AZ_KEY_8=29, AZ_KEY_9=30, AZ_KEY_A=31, AZ_KEY_B=32, AZ_KEY_C=33, AZ_KEY_D=34, AZ_KEY_E=35, AZ_KEY_F=36, AZ_KEY_G=37, AZ_KEY_H=38, AZ_KEY_I=39, AZ_KEY_J=40, AZ_KEY_K=41, AZ_KEY_L=42, AZ_KEY_M=43, AZ_KEY_N=44, AZ_KEY_O=45, AZ_KEY_P=46, AZ_KEY_Q=47, AZ_KEY_R=48, AZ_KEY_S=49, AZ_KEY_T=50, AZ_KEY_U=51, AZ_KEY_V=52, AZ_KEY_W=53, AZ_KEY_X=54, AZ_KEY_Y=55, AZ_KEY_Z=56 }


decompiled_code:
__int64 __fastcall baddie_hitpoints(int a1)
{
if ( !a1 )
_assert_fail("kind != AZ_BAD_NOTHING", "src/milestone/state/baddie.c", 0x1Fu, "baddie_hitpoints");
switch ( a1 )
{
case 0:
az_fatal("baddie_hitpoints", "line %d: unreachable\n", 33LL);
return 4LL;
case 1:
case 3:
return 2LL;
case 2:
return 3LL;
case 4:
case 6:
return 1LL;
case 5:
return 4LL;
default:
az_fatal("baddie_hitpoints", "line %d: unreachable\n", 41LL);
return 2LL;
}
}

canonical_decompiled_code:
__int64 __fastcall func0(int a1)
{
if ( !a1 )
_assert_fail("kind != AZ_BAD_NOTHING", "src/milestone/state/baddie.c", 0x1Fu, "baddie_hitpoints");
switch ( a1 )
{
case 0:
az_fatal("baddie_hitpoints", "line %d: unreachable\n", 33LL);
return 4LL;
case 1:
case 3:
return 2LL;
case 2:
return 3LL;
case 4:
case 6:
return 1LL;
case 5:
return 4LL;
default:
az_fatal("baddie_hitpoints", "line %d: unreachable\n", 41LL);
return 2LL;
}
}

original_code:
static int baddie_hitpoints(az_baddie_kind_t kind) {
  ((kind != AZ_BAD_NOTHING) ? (void) (0) : __assert_fail ("kind != AZ_BAD_NOTHING", "src/milestone/state/baddie.c", 31, __extension__ __PRETTY_FUNCTION__));
  switch (kind) {
    case AZ_BAD_NOTHING: _az_fatal(__func__, "line %d: unreachable\n", 33);
    case AZ_BAD_BASILISK: return 2;
    case AZ_BAD_FAKER: return 3;
    case AZ_BAD_FORCER: return 2;
    case AZ_BAD_GHOST: return 1;
    case AZ_BAD_GUARD: return 4;
    case AZ_BAD_TANK: return 1;
  }
  _az_fatal(__func__, "line %d: unreachable\n", 41);
}

canonical_original_code:
static int baddie_hitpoints(enum az_baddie_kind_t kind) {
  ((kind != AZ_BAD_NOTHING) ? (void) (0) : __assert_fail ("kind != AZ_BAD_NOTHING", "src/milestone/state/baddie.c", 31, __extension__ __PRETTY_FUNCTION__));
  switch (kind) {
    case AZ_BAD_NOTHING: _az_fatal(__func__, "line %d: unreachable\n", 33);
    case AZ_BAD_BASILISK: return 2;
    case AZ_BAD_FAKER: return 3;
    case AZ_BAD_FORCER: return 2;
    case AZ_BAD_GHOST: return 1;
    case AZ_BAD_GUARD: return 4;
    case AZ_BAD_TANK: return 1;
  }
  _az_fatal(__func__, "line %d: unreachable\n", 41);
}

variable_types: enum az_baddie_kind_t { AZ_BAD_NOTHING=0, AZ_BAD_BASILISK=1, AZ_BAD_FAKER=2, AZ_BAD_FORCER=3, AZ_BAD_GHOST=4, AZ_BAD_GUARD=5, AZ_BAD_TANK=6 }

return_type: int


decompiled_code:
__int64 __fastcall az_init_baddie(__int64 a1, int a2, double a3, double a4)
{
__int64 result; // rax

if ( !a2 )
_assert_fail("kind != AZ_BAD_NOTHING", "src/milestone/state/baddie.c", 0x2Eu, "az_init_baddie");
*(_QWORD *)a1 = 0LL;
*(_QWORD *)(a1 + 24) = 0LL;
*(_QWORD *)(a1 + 32) = 0LL;
*(_QWORD *)(a1 + 48) = 0LL;
*(_QWORD *)(a1 + 56) = 0LL;
*(_QWORD *)(a1 + 64) = 0LL;
*(_DWORD *)a1 = a2;
*(double *)(a1 + 8) = a3;
*(double *)(a1 + 16) = a4;
*(_QWORD *)(a1 + 40) = LC3;
result = baddie_hitpoints(a2);
*(_DWORD *)(a1 + 64) = result;
return result;
}

canonical_decompiled_code:
__int64 __fastcall func1(__int64 a1, int a2, double a3, double a4)
{
__int64 result; // rax

if ( !a2 )
_assert_fail("kind != AZ_BAD_NOTHING", "src/milestone/state/baddie.c", 0x2Eu, "az_init_baddie");
*(_QWORD *)a1 = 0LL;
*(_QWORD *)(a1 + 24) = 0LL;
*(_QWORD *)(a1 + 32) = 0LL;
*(_QWORD *)(a1 + 48) = 0LL;
*(_QWORD *)(a1 + 56) = 0LL;
*(_QWORD *)(a1 + 64) = 0LL;
*(_DWORD *)a1 = a2;
*(double *)(a1 + 8) = a3;
*(double *)(a1 + 16) = a4;
*(_QWORD *)(a1 + 40) = LC3;
result = func0(a2);
*(_DWORD *)(a1 + 64) = result;
return result;
}

original_code:
void az_init_baddie(az_baddie_t *baddie, az_baddie_kind_t kind,
                    az_vector_t position) {
  ((kind != AZ_BAD_NOTHING) ? (void) (0) : __assert_fail ("kind != AZ_BAD_NOTHING", "src/milestone/state/baddie.c", 46, __extension__ __PRETTY_FUNCTION__));
  memset(baddie, 0, sizeof(*baddie));
  baddie->kind = kind;
  baddie->position = position;
  baddie->cooldown = 1.0;
  baddie->hitpoints = baddie_hitpoints(kind);
}

canonical_original_code:
void az_init_baddie(struct az_baddie_t *baddie, enum az_baddie_kind_t kind, struct az_vector_t position) {
  ((kind != AZ_BAD_NOTHING) ? (void) (0) : __assert_fail ("kind != AZ_BAD_NOTHING", "src/milestone/state/baddie.c", 46, __extension__ __PRETTY_FUNCTION__));
  memset(baddie, 0, sizeof(*baddie));
  baddie->kind = kind;
  baddie->position = position;
  baddie->cooldown = 1.0;
  baddie->hitpoints = baddie_hitpoints(kind);
}

variable_types: struct az_baddie_t { enum az_baddie_kind_t { AZ_BAD_NOTHING=0, AZ_BAD_BASILISK=1, AZ_BAD_FAKER=2, AZ_BAD_FORCER=3, AZ_BAD_GHOST=4, AZ_BAD_GUARD=5, AZ_BAD_TANK=6 } kind; struct az_vector_t { double x; } position; struct az_vector_t velocity; double cooldown; double stun; double flare; int hitpoints; } *

variable_types:
position
struct az_vector_t

user_defined_types: struct az_baddie_t { enum az_baddie_kind_t kind; struct az_vector_t position; struct az_vector_t velocity; double cooldown; double stun; double flare; int hitpoints; }


decompiled_code:
__int64 __fastcall az_baddie_point_value(int a1)
{
if ( !a1 )
_assert_fail("kind != AZ_BAD_NOTHING", "src/milestone/state/baddie.c", 0x37u, "az_baddie_point_value");
switch ( a1 )
{
case 0:
az_fatal("az_baddie_point_value", "line %d: unreachable\n", 57LL);
return 450LL;
case 1:
return 500LL;
case 2:
return 750LL;
case 3:
return 1000LL;
case 4:
return 450LL;
case 5:
return 400LL;
case 6:
return 300LL;
default:
az_fatal("az_baddie_point_value", "line %d: unreachable\n", 65LL);
return 500LL;
}
}

canonical_decompiled_code:
__int64 __fastcall func2(int a1)
{
if ( !a1 )
_assert_fail("kind != AZ_BAD_NOTHING", "src/milestone/state/baddie.c", 0x37u, "az_baddie_point_value");
switch ( a1 )
{
case 0:
az_fatal("az_baddie_point_value", "line %d: unreachable\n", 57LL);
return 450LL;
case 1:
return 500LL;
case 2:
return 750LL;
case 3:
return 1000LL;
case 4:
return 450LL;
case 5:
return 400LL;
case 6:
return 300LL;
default:
az_fatal("az_baddie_point_value", "line %d: unreachable\n", 65LL);
return 500LL;
}
}

original_code:
int64_t az_baddie_point_value(az_baddie_kind_t kind) {
  ((kind != AZ_BAD_NOTHING) ? (void) (0) : __assert_fail ("kind != AZ_BAD_NOTHING", "src/milestone/state/baddie.c", 55, __extension__ __PRETTY_FUNCTION__));
  switch (kind) {
    case AZ_BAD_NOTHING: _az_fatal(__func__, "line %d: unreachable\n", 57);
    case AZ_BAD_BASILISK: return 500;
    case AZ_BAD_FAKER: return 750;
    case AZ_BAD_FORCER: return 1000;
    case AZ_BAD_GHOST: return 450;
    case AZ_BAD_GUARD: return 400;
    case AZ_BAD_TANK: return 300;
  }
  _az_fatal(__func__, "line %d: unreachable\n", 65);
}

canonical_original_code:
long az_baddie_point_value(enum az_baddie_kind_t kind) {
  ((kind != AZ_BAD_NOTHING) ? (void) (0) : __assert_fail ("kind != AZ_BAD_NOTHING", "src/milestone/state/baddie.c", 55, __extension__ __PRETTY_FUNCTION__));
  switch (kind) {
    case AZ_BAD_NOTHING: _az_fatal(__func__, "line %d: unreachable\n", 57);
    case AZ_BAD_BASILISK: return 500;
    case AZ_BAD_FAKER: return 750;
    case AZ_BAD_FORCER: return 1000;
    case AZ_BAD_GHOST: return 450;
    case AZ_BAD_GUARD: return 400;
    case AZ_BAD_TANK: return 300;
  }
  _az_fatal(__func__, "line %d: unreachable\n", 65);
}

return_type: long

user_defined_types: enum az_baddie_kind_t { AZ_BAD_NOTHING=0, AZ_BAD_BASILISK=1, AZ_BAD_FAKER=2, AZ_BAD_FORCER=3, AZ_BAD_GHOST=4, AZ_BAD_GUARD=5, AZ_BAD_TANK=6 }


decompiled_code:
__int64 __fastcall az_draw_gameover_screen(__int64 a1)
{
glColor3f(0.0, 0.0, 1.0);
glBegin(2LL);
glVertex2f(1.5);
glVertex2f(798.5);
glVertex2f(798.5);
glVertex2f(1.5);
glEnd(1.5, 498.5);
glColor3f(COERCE_DOUBLE((unsigned __int64)LC0), 0.0, 0.0);
az_draw_string(1LL, "GAME OVER", 64.0, 400.0, 100.0);
az_draw_printf(1LL, "On wave %d, with a score of %ld,", *(unsigned int *)(a1 + 148), *(_QWORD *)(a1 + 152));
az_draw_string(1LL, "you finally fell too far behind.", 16.0, 400.0, 270.0);
if ( *(_BYTE *)(a1 + 160) )
{
glColor3f(COERCE_DOUBLE((unsigned __int64)LC14), COERCE_DOUBLE((unsigned __int64)LC14), 0.5);
az_draw_string(1LL, "Please type your name:", 16.0, 400.0, 370.0);
az_draw_string(1LL, "Press ENTER when done.", 16.0, 400.0, 450.0);
glColor3f(COERCE_DOUBLE((unsigned __int64)LC0), COERCE_DOUBLE((unsigned __int64)LC0), 1.0);
az_draw_string(1LL, a1 + 168, 24.0, 400.0, 400.0);
glBegin(2LL);
glColor3f(COERCE_DOUBLE((unsigned __int64)LC0), COERCE_DOUBLE((unsigned __int64)LC14), 0.0);
glVertex2f(644.5);
glVertex2f(155.5);
glVertex2f(155.5);
glVertex2f(644.5);
glEnd(644.5, 428.5);
}
else
{
glColor3f(COERCE_DOUBLE((unsigned __int64)LC14), COERCE_DOUBLE((unsigned __int64)LC14), 0.5);
az_draw_string(1LL, "Press ENTER to return to title.", 16.0, 400.0, 450.0);
}
return az_draw_cursor();
}

canonical_decompiled_code:
__int64 __fastcall func0(__int64 a1)
{
glColor3f(0.0, 0.0, 1.0);
glBegin(2LL);
glVertex2f(1.5);
glVertex2f(798.5);
glVertex2f(798.5);
glVertex2f(1.5);
glEnd(1.5, 498.5);
glColor3f(COERCE_DOUBLE((unsigned __int64)LC0), 0.0, 0.0);
az_draw_string(1LL, "GAME OVER", 64.0, 400.0, 100.0);
az_draw_printf(1LL, "On wave %d, with a score of %ld,", *(unsigned int *)(a1 + 148), *(_QWORD *)(a1 + 152));
az_draw_string(1LL, "you finally fell too far behind.", 16.0, 400.0, 270.0);
if ( *(_BYTE *)(a1 + 160) )
{
glColor3f(COERCE_DOUBLE((unsigned __int64)LC14), COERCE_DOUBLE((unsigned __int64)LC14), 0.5);
az_draw_string(1LL, "Please type your name:", 16.0, 400.0, 370.0);
az_draw_string(1LL, "Press ENTER when done.", 16.0, 400.0, 450.0);
glColor3f(COERCE_DOUBLE((unsigned __int64)LC0), COERCE_DOUBLE((unsigned __int64)LC0), 1.0);
az_draw_string(1LL, a1 + 168, 24.0, 400.0, 400.0);
glBegin(2LL);
glColor3f(COERCE_DOUBLE((unsigned __int64)LC0), COERCE_DOUBLE((unsigned __int64)LC14), 0.0);
glVertex2f(644.5);
glVertex2f(155.5);
glVertex2f(155.5);
glVertex2f(644.5);
glEnd(644.5, 428.5);
}
else
{
glColor3f(COERCE_DOUBLE((unsigned __int64)LC14), COERCE_DOUBLE((unsigned __int64)LC14), 0.5);
az_draw_string(1LL, "Press ENTER to return to title.", 16.0, 400.0, 450.0);
}
return az_draw_cursor();
}

original_code:
void az_draw_gameover_screen(const az_gameover_state_t *state) {
  glColor3f(0, 0, 1);
  glBegin(0x0002); {
    glVertex2f(1.5f, 1.5f);
    glVertex2f(800 - 1.5f, 1.5f);
    glVertex2f(800 - 1.5f, 500 - 1.5f);
    glVertex2f(1.5f, 500 - 1.5f);
  } glEnd();
  glColor3f(1, 0, 0);
  az_draw_string(64, AZ_ALIGN_CENTER, 800/2, 100, "GAME OVER");
  az_draw_printf(16, AZ_ALIGN_CENTER, 800/2, 250,
                 "On wave %d, with a score of %""l" "d"",",
                 state->last_wave, state->score);
  az_draw_string(16, AZ_ALIGN_CENTER, 800/2, 270,
                 "you finally fell too far behind.");
  if (state->is_high_score) {
    glColor3f(0.5, 0.5, 0.5);
    az_draw_string(16, AZ_ALIGN_CENTER, 800/2, 370,
                   "Please type your name:");
    az_draw_string(16, AZ_ALIGN_CENTER, 800/2, 450,
                   "Press ENTER when done.");
    glColor3f(1, 1, 1);
    az_draw_string(24, AZ_ALIGN_CENTER, 800/2, 400,
                   state->name_buffer);
    glBegin(0x0002); {
      glColor3f(1, 0.5, 0);
      glVertex2f(800/2 + 244.5, 393.5);
      glVertex2f(800/2 - 244.5, 393.5);
      glVertex2f(800/2 - 244.5, 428.5);
      glVertex2f(800/2 + 244.5, 428.5);
    } glEnd();
  } else {
    glColor3f(0.5, 0.5, 0.5);
    az_draw_string(16, AZ_ALIGN_CENTER, 800/2, 450,
                   "Press ENTER to return to title.");
  }
  az_draw_cursor();
}

canonical_original_code:
void az_draw_gameover_screen(struct az_gameover_state_t *state) {
  glColor3f(0, 0, 1);
  glBegin(0x0002); {
    glVertex2f(1.5f, 1.5f);
    glVertex2f(800 - 1.5f, 1.5f);
    glVertex2f(800 - 1.5f, 500 - 1.5f);
    glVertex2f(1.5f, 500 - 1.5f);
  } glEnd();
  glColor3f(1, 0, 0);
  az_draw_string(64, AZ_ALIGN_CENTER, 800/2, 100, "GAME OVER");
  az_draw_printf(16, AZ_ALIGN_CENTER, 800/2, 250,
                 "On wave %d, with a score of %""l" "d"",",
                 state->last_wave, state->score);
  az_draw_string(16, AZ_ALIGN_CENTER, 800/2, 270,
                 "you finally fell too far behind.");
  if (state->is_high_score) {
    glColor3f(0.5, 0.5, 0.5);
    az_draw_string(16, AZ_ALIGN_CENTER, 800/2, 370,
                   "Please type your name:");
    az_draw_string(16, AZ_ALIGN_CENTER, 800/2, 450,
                   "Press ENTER when done.");
    glColor3f(1, 1, 1);
    az_draw_string(24, AZ_ALIGN_CENTER, 800/2, 400,
                   state->name_buffer);
    glBegin(0x0002); {
      glColor3f(1, 0.5, 0);
      glVertex2f(800/2 + 244.5, 393.5);
      glVertex2f(800/2 - 244.5, 393.5);
      glVertex2f(800/2 - 244.5, 428.5);
      glVertex2f(800/2 + 244.5, 428.5);
    } glEnd();
  } else {
    glColor3f(0.5, 0.5, 0.5);
    az_draw_string(16, AZ_ALIGN_CENTER, 800/2, 450,
                   "Press ENTER to return to title.");
  }
  az_draw_cursor();
}

variable_types: struct az_gameover_state_t { unsigned long clock; struct az_soundboard_t { enum { AZ_MUSA_NOTHING=0, AZ_MUSA_CHANGE=1, AZ_MUSA_STOP=2 } music_action; enum az_music_key_t { AZ_MUS_NOTHING=0, AZ_MUS_TITLE=1, AZ_MUS_PLAY=2 } next_music; int music_fade_out_millis; int num_oneshots; enum az_sound_key_t { AZ_SND_BONUS_ROUND=0, AZ_SND_BREAK_BONUS_TARGET=1, AZ_SND_BREAK_FAKE_TARGET=2, AZ_SND_BREAK_NORMAL_TARGET=3, AZ_SND_DROP_FAKE_TARGET=4, AZ_SND_FIRE_BOMB=5, AZ_SND_FIRE_BULLET=6, AZ_SND_FIRE_STOPPER=7, AZ_SND_FIRE_TANK_SHELL=8, AZ_SND_FORCEFIELD=9, AZ_SND_GAIN_BOMB=10, AZ_SND_GAIN_LIFE=11, AZ_SND_HIT_TANK_SHELL=12, AZ_SND_HURT_BADDIE=13, AZ_SND_KILL_BASILISK=14, AZ_SND_KILL_GHOST=15, AZ_SND_KILL_GUARD=16, AZ_SND_KILL_TANK=17, AZ_SND_LOSE_LIFE=18, AZ_SND_NEXT_WAVE=19, AZ_SND_STUN_BADDIE=20 } oneshots[10]; int num_persists; struct { enum az_sound_key_t { AZ_SND_BONUS_ROUND=0, AZ_SND_BREAK_BONUS_TARGET=1, AZ_SND_BREAK_FAKE_TARGET=2, AZ_SND_BREAK_NORMAL_TARGET=3, AZ_SND_DROP_FAKE_TARGET=4, AZ_SND_FIRE_BOMB=5, AZ_SND_FIRE_BULLET=6, AZ_SND_FIRE_STOPPER=7, AZ_SND_FIRE_TANK_SHELL=8, AZ_SND_FORCEFIELD=9, AZ_SND_GAIN_BOMB=10, AZ_SND_GAIN_LIFE=11, AZ_SND_HIT_TANK_SHELL=12, AZ_SND_HURT_BADDIE=13, AZ_SND_KILL_BASILISK=14, AZ_SND_KILL_GHOST=15, AZ_SND_KILL_GUARD=16, AZ_SND_KILL_TANK=17, AZ_SND_LOSE_LIFE=18, AZ_SND_NEXT_WAVE=19, AZ_SND_STUN_BADDIE=20 } sound; _Bool play; _Bool loop; _Bool reset; } persists[10]; } soundboard; int last_wave; long score; _Bool is_high_score; int cursor; char name_buffer[21]; } *

user_defined_types: struct az_gameover_state_t { unsigned long clock; struct az_soundboard_t soundboard; int last_wave; long score; _Bool is_high_score; int cursor; char name_buffer[21]; }

user_defined_types: struct az_soundboard_t { enum { AZ_MUSA_NOTHING=0, AZ_MUSA_CHANGE=1, AZ_MUSA_STOP=2 } music_action; enum az_music_key_t next_music; int music_fade_out_millis; int num_oneshots; enum az_sound_key_t oneshots[10]; int num_persists; struct { enum az_sound_key_t sound; _Bool play; _Bool loop; _Bool reset; } persists[10]; }


decompiled_code:
__int64 __fastcall az_color_for_wave(int a1)
{
__int64 result; // rax

if ( a1 < 0 )
_assert_fail("wave >= 0", "src/milestone/util/color.c", 0x1Du, "az_color_for_wave");
switch ( a1 % 6 )
{
case 0:
result = 4294902015LL;
break;
case 1:
result = 4278255615LL;
break;
case 2:
result = 4294967040LL;
break;
case 3:
result = 4278190335LL;
break;
case 4:
result = 4294918208LL;
break;
case 5:
result = 4278239232LL;
break;
default:
az_fatal("az_color_for_wave", "line %d: unreachable\n", 38LL);
JUMPOUT(0x91LL);
}
return result;
}

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

if ( a1 < 0 )
_assert_fail("wave >= 0", "src/milestone/util/color.c", 0x1Du, "az_color_for_wave");
switch ( a1 % 6 )
{
case 0:
result = 4294902015LL;
break;
case 1:
result = 4278255615LL;
break;
case 2:
result = 4294967040LL;
break;
case 3:
result = 4278190335LL;
break;
case 4:
result = 4294918208LL;
break;
case 5:
result = 4278239232LL;
break;
default:
az_fatal("az_color_for_wave", "line %d: unreachable\n", 38LL);
JUMPOUT(0x91LL);
}
return result;
}

original_code:
az_color_t az_color_for_wave(int wave) {
  ((wave >= 0) ? (void) (0) : __assert_fail ("wave >= 0", "src/milestone/util/color.c", 29, __extension__ __PRETTY_FUNCTION__));
  switch (wave % 6) {
    case 0: return (az_color_t){255, 0, 255, 255};
    case 1: return (az_color_t){255, 255, 0, 255};
    case 2: return (az_color_t){ 0, 255, 255, 255};
    case 3: return (az_color_t){255, 0, 0, 255};
    case 4: return (az_color_t){ 64, 64, 255, 255};
    case 5: return (az_color_t){ 0, 192, 0, 255};
  }
  _az_fatal(__func__, "line %d: unreachable\n", 38);
}

canonical_original_code:
struct az_color_t az_color_for_wave(int wave) {
  ((wave >= 0) ? (void) (0) : __assert_fail ("wave >= 0", "src/milestone/util/color.c", 29, __extension__ __PRETTY_FUNCTION__));
  switch (wave % 6) {
    case 0: return (struct az_color_t){255, 0, 255, 255};
    case 1: return (struct az_color_t){255, 255, 0, 255};
    case 2: return (struct az_color_t){ 0, 255, 255, 255};
    case 3: return (struct az_color_t){255, 0, 0, 255};
    case 4: return (struct az_color_t){ 64, 64, 255, 255};
    case 5: return (struct az_color_t){ 0, 192, 0, 255};
  }
  _az_fatal(__func__, "line %d: unreachable\n", 38);
}

variable_types: wave int

return_type: struct az_color_t { unsigned char r; }


decompiled_code:
__int64 set_color_for_wave()
{
unsigned int v0; // eax

v0 = az_color_for_wave();
return glColor4ub((unsigned __int8)v0, BYTE1(v0), BYTE2(v0), HIBYTE(v0));
}

canonical_decompiled_code:
__int64 func1()
{
unsigned int v0; // eax

v0 = az_color_for_wave();
return glColor4ub((unsigned __int8)v0, BYTE1(v0), BYTE2(v0), HIBYTE(v0));
}

original_code:
static void set_color_for_wave(int wave) {
  const az_color_t color = az_color_for_wave(wave);
  glColor4ub(color.r, color.g, color.b, color.a);
}

canonical_original_code:
static void set_color_for_wave(int wave) {
  struct az_color_t color = az_color_for_wave(wave);
  glColor4ub(color.r, color.g, color.b, color.a);
}

variable_types:
color
struct az_color_t { unsigned char r; }


decompiled_code:
void __fastcall draw_message(double *a1, int a2, __int64 a3)
{
double v3; // xmm1_8
float v5; // xmm5_4
__m128i v6; // xmm6
unsigned int v7; // ebp
float v8; // xmm3_4
__m128i v9; // xmm4
unsigned int v10; // er14
double v11; // xmm0_8
float v12; // [rsp+0h] [rbp-2Ch]

v3 = a1[1];
if ( v3 > 0.0 )
{
v5 = fmin(1.0, v3);
v12 = v5;
glPushMatrix();
glTranslated(400.0, (double)a2, 0.0);
glBegin(5LL);
v6 = 0LL;
*(float *)v6.m128i_i32 = (float)(int)(8 * strlen(*(const char **)a1) + 4);
v7 = _mm_cvtsi128_si32(v6);
v8 = v12 * 0.6;
glColor4f(0.0, 0.0, 0.0, v8);
v9 = (__m128i)_mm_xor_ps((__m128)_mm_cvtsi32_si128(v7), (__m128)LC7);
v10 = _mm_cvtsi128_si32(v9);
glVertex2f(*(double *)v9.m128i_i64);
glVertex2f(*(double *)_mm_cvtsi32_si128(v7).m128i_i64);
glVertex2f(*(double *)_mm_cvtsi32_si128(v10).m128i_i64);
*(_QWORD *)&v11 = _mm_cvtsi32_si128(v7).m128i_u64[0];
glVertex2f(v11);
glEnd(*(float *)&v11, 20.0);
if ( *((_BYTE *)a1 + 16) && (unsigned int)az_clock_mod(2LL, 2LL, a3) )
glColor4f(COERCE_DOUBLE((unsigned __int64)LC9), COERCE_DOUBLE((unsigned __int64)LC9), 0.0, v12);
else
glColor4f(
COERCE_DOUBLE((unsigned __int64)LC9),
COERCE_DOUBLE((unsigned __int64)LC9),
COERCE_DOUBLE((unsigned __int64)LC9),
v12);
az_draw_string(1LL, *(_QWORD *)a1, 16.0, 0.0, 3.0);
glPopMatrix();
}
}

canonical_decompiled_code:
void __fastcall func2(double *a1, int a2, __int64 a3)
{
double v3; // xmm1_8
float v5; // xmm5_4
__m128i v6; // xmm6
unsigned int v7; // ebp
float v8; // xmm3_4
__m128i v9; // xmm4
unsigned int v10; // er14
double v11; // xmm0_8
float v12; // [rsp+0h] [rbp-2Ch]

v3 = a1[1];
if ( v3 > 0.0 )
{
v5 = fmin(1.0, v3);
v12 = v5;
glPushMatrix();
glTranslated(400.0, (double)a2, 0.0);
glBegin(5LL);
v6 = 0LL;
*(float *)v6.m128i_i32 = (float)(int)(8 * strlen(*(const char **)a1) + 4);
v7 = _mm_cvtsi128_si32(v6);
v8 = v12 * 0.6;
glColor4f(0.0, 0.0, 0.0, v8);
v9 = (__m128i)_mm_xor_ps((__m128)_mm_cvtsi32_si128(v7), (__m128)LC7);
v10 = _mm_cvtsi128_si32(v9);
glVertex2f(*(double *)v9.m128i_i64);
glVertex2f(*(double *)_mm_cvtsi32_si128(v7).m128i_i64);
glVertex2f(*(double *)_mm_cvtsi32_si128(v10).m128i_i64);
*(_QWORD *)&v11 = _mm_cvtsi32_si128(v7).m128i_u64[0];
glVertex2f(v11);
glEnd(*(float *)&v11, 20.0);
if ( *((_BYTE *)a1 + 16) && (unsigned int)az_clock_mod(2LL, 2LL, a3) )
glColor4f(COERCE_DOUBLE((unsigned __int64)LC9), COERCE_DOUBLE((unsigned __int64)LC9), 0.0, v12);
else
glColor4f(
COERCE_DOUBLE((unsigned __int64)LC9),
COERCE_DOUBLE((unsigned __int64)LC9),
COERCE_DOUBLE((unsigned __int64)LC9),
v12);
az_draw_string(1LL, *(_QWORD *)a1, 16.0, 0.0, 3.0);
glPopMatrix();
}
}

original_code:
static void draw_message(const az_message_t *message, int top,
                         az_clock_t clock) {
  if (message->time_remaining <= 0.0) return;
  const GLfloat alpha = fmin(1.0, message->time_remaining);
  glPushMatrix(); {
    glTranslated(800 / 2, top, 0);
    glBegin(0x0005); {
      const int length = strlen(message->text);
      const GLfloat semiwidth = 8 * length + 4;
      glColor4f(0, 0, 0, 0.6 * alpha);
      glVertex2f(-semiwidth, 0); glVertex2f(semiwidth, 0);
      glVertex2f(-semiwidth, 20); glVertex2f(semiwidth, 20);
    } glEnd();
    if (message->flash && az_clock_mod(2, 2, clock)) {
      glColor4f(1, 1, 0, alpha);
    } else glColor4f(1, 1, 1, alpha);
    az_draw_string(16, AZ_ALIGN_CENTER, 0, 3, message->text);
  } glPopMatrix();
}

canonical_original_code:
static void draw_message(struct az_message_t *message, int top, unsigned long clock) {
  if (message->time_remaining <= 0.0) return;
  float alpha = fmin(1.0, message->time_remaining);
  glPushMatrix(); {
    glTranslated(800 / 2, top, 0);
    glBegin(0x0005); {
      int length = strlen(message->text);
      float semiwidth = 8 * length + 4;
      glColor4f(0, 0, 0, 0.6 * alpha);
      glVertex2f(-semiwidth, 0); glVertex2f(semiwidth, 0);
      glVertex2f(-semiwidth, 20); glVertex2f(semiwidth, 20);
    } glEnd();
    if (message->flash && az_clock_mod(2, 2, clock)) {
      glColor4f(1, 1, 0, alpha);
    } else glColor4f(1, 1, 1, alpha);
    az_draw_string(16, AZ_ALIGN_CENTER, 0, 3, message->text);
  } glPopMatrix();
}

variable_types: struct az_message_t { char *text; double time_remaining; _Bool flash; } *

variable_types: top int

variable_types:
clock
unsigned long

variable_types: alpha float

variable_types: length int

variable_types: semiwidth float


decompiled_code:
void __fastcall draw_hud(_QWORD *a1)
{
double v1; // xmm2_8
__int64 v2; // xmm1_8
double v3; // xmm0_8
int i; // ebp
unsigned int v5; // eax
unsigned __int8 v6; // r13
unsigned __int8 v7; // dl
unsigned int v8; // er12
unsigned int v9; // eax
float v10; // xmm3_4
unsigned int v11; // ebp
unsigned int v12; // er15
unsigned int v13; // er14

if ( *((_BYTE *)a1 + 176) && (unsigned int)az_clock_mod(2LL, 2LL, *a1) )
glColor3f(1.0, 1.0);
else
set_color_for_wave(*((unsigned int *)a1 + 42));
az_draw_printf(0LL, "Wave %d", *((unsigned int *)a1 + 42));
glColor3f(1.0, 1.0);
v1 = *(double *)&LC10;
v2 = LC5;
v3 = *(double *)&LC11;
az_draw_printf(1LL, "%08ld", a1[20]);
if ( *((int *)a1 + 38) > 0 )
{
az_draw_bomb_icon(666LL, 2LL, 16.0, 400.0, 3.0);
if ( *((int *)a1 + 38) > 1 )
{
az_draw_bomb_icon(648LL, 2LL, 16.0, 400.0, 3.0);
if ( *((int *)a1 + 38) > 2 )
az_draw_bomb_icon(630LL, 2LL, 16.0, 400.0, 3.0);
}
}
if ( *((int *)a1 + 38) > 3 )
{
glColor3f(1.0, 1.0);
v1 = *(double *)&LC10;
v2 = LC16;
v3 = *(double *)&LC11;
az_draw_printf(2LL, "%d", *((unsigned int *)a1 + 38));
}
for ( i = 0;
i != 3;
az_draw_avatar_icon((unsigned int)(-18 * i + 800), 2LL, *((unsigned int *)a1 + 42), v3, *(double *)&v2, v1) )
{
if ( *((_DWORD *)a1 + 37) <= i )
break;
++i;
}
if ( *((int *)a1 + 37) > 3 )
{
glColor3f(1.0, 1.0);
v1 = *(double *)&LC10;
v2 = LC17;
v3 = *(double *)&LC11;
az_draw_printf(2LL, "%d", *((unsigned int *)a1 + 37));
}
glBegin(5LL);
if ( *((_BYTE *)a1 + 176) && !(unsigned int)az_clock_mod(2LL, 2LL, *a1) )
{
LOBYTE(v9) = -1;
LOBYTE(v8) = -1;
v7 = -1;
v6 = -1;
}
else
{
v5 = az_color_for_wave(*((unsigned int *)a1 + 42), v3, *(double *)&v2, v1);
v6 = v5;
v7 = BYTE1(v5);
v8 = HIWORD(v5);
v9 = HIBYTE(v5);
}
v10 = *((double *)a1 + 23) / 15.0 * 796.0 + 2.0;
v11 = (unsigned __int8)v9;
v12 = (unsigned __int8)(int)((double)(unsigned __int8)v9 * 0.5);
v13 = v7;
glColor4ub(v6, v7, (unsigned __int8)v8, (unsigned __int8)(int)((double)(unsigned __int8)v9 * 0.5));
glVertex2f(COERCE_DOUBLE((unsigned __int64)LC23));
glVertex2f(COERCE_DOUBLE((unsigned __int64)LODWORD(v10)));
glColor4ub(v6, v13, (unsigned __int8)v8, v11);
glVertex2f(COERCE_DOUBLE((unsigned __int64)LC23));
glVertex2f(COERCE_DOUBLE((unsigned __int64)LODWORD(v10)));
glColor4ub(v6, v13, (unsigned __int8)v8, v12);
glVertex2f(COERCE_DOUBLE((unsigned __int64)LC23));
glVertex2f(COERCE_DOUBLE((unsigned __int64)LODWORD(v10)));
glEnd(v10, 497.0);
set_color_for_wave(*((_DWORD *)a1 + 42) + (unsigned int)*((unsigned __int8 *)a1 + 176));
glBegin(2LL);
glVertex2f(COERCE_DOUBLE((unsigned __int64)LC27));
glVertex2f(COERCE_DOUBLE((unsigned __int64)LC28));
glVertex2f(COERCE_DOUBLE((unsigned __int64)LC28));
glVertex2f(COERCE_DOUBLE((unsigned __int64)LC27));
glEnd(1.5, 479.5);
draw_message((double *)a1 + 29, 24, *a1);
draw_message((double *)a1 + 32, 456, *a1);
}

canonical_decompiled_code:
void __fastcall func3(_QWORD *a1)
{
double v1; // xmm2_8
__int64 v2; // xmm1_8
double v3; // xmm0_8
int i; // ebp
unsigned int v5; // eax
unsigned __int8 v6; // r13
unsigned __int8 v7; // dl
unsigned int v8; // er12
unsigned int v9; // eax
float v10; // xmm3_4
unsigned int v11; // ebp
unsigned int v12; // er15
unsigned int v13; // er14

if ( *((_BYTE *)a1 + 176) && (unsigned int)az_clock_mod(2LL, 2LL, *a1) )
glColor3f(1.0, 1.0);
else
func1(*((unsigned int *)a1 + 42));
az_draw_printf(0LL, "Wave %d", *((unsigned int *)a1 + 42));
glColor3f(1.0, 1.0);
v1 = *(double *)&LC10;
v2 = LC5;
v3 = *(double *)&LC11;
az_draw_printf(1LL, "%08ld", a1[20]);
if ( *((int *)a1 + 38) > 0 )
{
az_draw_bomb_icon(666LL, 2LL, 16.0, 400.0, 3.0);
if ( *((int *)a1 + 38) > 1 )
{
az_draw_bomb_icon(648LL, 2LL, 16.0, 400.0, 3.0);
if ( *((int *)a1 + 38) > 2 )
az_draw_bomb_icon(630LL, 2LL, 16.0, 400.0, 3.0);
}
}
if ( *((int *)a1 + 38) > 3 )
{
glColor3f(1.0, 1.0);
v1 = *(double *)&LC10;
v2 = LC16;
v3 = *(double *)&LC11;
az_draw_printf(2LL, "%d", *((unsigned int *)a1 + 38));
}
for ( i = 0;
i != 3;
az_draw_avatar_icon((unsigned int)(-18 * i + 800), 2LL, *((unsigned int *)a1 + 42), v3, *(double *)&v2, v1) )
{
if ( *((_DWORD *)a1 + 37) <= i )
break;
++i;
}
if ( *((int *)a1 + 37) > 3 )
{
glColor3f(1.0, 1.0);
v1 = *(double *)&LC10;
v2 = LC17;
v3 = *(double *)&LC11;
az_draw_printf(2LL, "%d", *((unsigned int *)a1 + 37));
}
glBegin(5LL);
if ( *((_BYTE *)a1 + 176) && !(unsigned int)az_clock_mod(2LL, 2LL, *a1) )
{
LOBYTE(v9) = -1;
LOBYTE(v8) = -1;
v7 = -1;
v6 = -1;
}
else
{
v5 = az_color_for_wave(*((unsigned int *)a1 + 42), v3, *(double *)&v2, v1);
v6 = v5;
v7 = BYTE1(v5);
v8 = HIWORD(v5);
v9 = HIBYTE(v5);
}
v10 = *((double *)a1 + 23) / 15.0 * 796.0 + 2.0;
v11 = (unsigned __int8)v9;
v12 = (unsigned __int8)(int)((double)(unsigned __int8)v9 * 0.5);
v13 = v7;
glColor4ub(v6, v7, (unsigned __int8)v8, (unsigned __int8)(int)((double)(unsigned __int8)v9 * 0.5));
glVertex2f(COERCE_DOUBLE((unsigned __int64)LC23));
glVertex2f(COERCE_DOUBLE((unsigned __int64)LODWORD(v10)));
glColor4ub(v6, v13, (unsigned __int8)v8, v11);
glVertex2f(COERCE_DOUBLE((unsigned __int64)LC23));
glVertex2f(COERCE_DOUBLE((unsigned __int64)LODWORD(v10)));
glColor4ub(v6, v13, (unsigned __int8)v8, v12);
glVertex2f(COERCE_DOUBLE((unsigned __int64)LC23));
glVertex2f(COERCE_DOUBLE((unsigned __int64)LODWORD(v10)));
glEnd(v10, 497.0);
func1(*((_DWORD *)a1 + 42) + (unsigned int)*((unsigned __int8 *)a1 + 176));
glBegin(2LL);
glVertex2f(COERCE_DOUBLE((unsigned __int64)LC27));
glVertex2f(COERCE_DOUBLE((unsigned __int64)LC28));
glVertex2f(COERCE_DOUBLE((unsigned __int64)LC28));
glVertex2f(COERCE_DOUBLE((unsigned __int64)LC27));
glEnd(1.5, 479.5);
func2((double *)a1 + 29, 24, *a1);
func2((double *)a1 + 32, 456, *a1);
}

original_code:
static void draw_hud(const az_play_state_t *state) {
  if (state->bonus_round && az_clock_mod(2, 2, state->clock)) {
    glColor3f(1, 1, 1);
  } else set_color_for_wave(state->current_wave);
  az_draw_printf(16, AZ_ALIGN_LEFT, 10, 3, "Wave %d", state->current_wave);
  glColor3f(1, 1, 1);
  az_draw_printf(16, AZ_ALIGN_CENTER, 800/2, 3,
                 "%08""l" "d", state->score);
  for (int i = 0; i < 3 && i < state->num_bombs; ++i) {
    az_draw_bomb_icon(800 - 134 - 18 * i, 2);
  }
  if (state->num_bombs > 3) {
    glColor3f(1, 1, 1);
    az_draw_printf(16, AZ_ALIGN_RIGHT, 800 - 171, 3, "%d",
                   state->num_bombs);
  }
  for (int i = 0; i < 3 && i < state->num_lives; ++i) {
    az_draw_avatar_icon(800 - 18 * (i + 1), 2,
                        state->current_wave);
  }
  if (state->num_lives > 3) {
    glColor3f(1, 1, 1);
    az_draw_printf(16, AZ_ALIGN_RIGHT, 800 - 55, 3, "%d",
                   state->num_lives);
  }
  glBegin(0x0005); {
    az_color_t color = {255, 255, 255, 255};
    if (!state->bonus_round || az_clock_mod(2, 2, state->clock)) {
      color = az_color_for_wave(state->current_wave);
    }
    const GLfloat left = 2.0f;
    const GLfloat right = left + (800 - 2 * left) *
      (state->wave_time_remaining / 15.0);
    const GLfloat top = 500 - 20 + 3.0f;
    const GLfloat bottom = 500 - 3.0f;
    const GLfloat mid = (top + bottom) * 0.5f;
    glColor4ub(color.r, color.g, color.b, 0.5 * color.a);
    glVertex2f(left, top); glVertex2f(right, top);
    glColor4ub(color.r, color.g, color.b, color.a);
    glVertex2f(left, mid); glVertex2f(right, mid);
    glColor4ub(color.r, color.g, color.b, 0.5 * color.a);
    glVertex2f(left, bottom); glVertex2f(right, bottom);
  } glEnd();
  set_color_for_wave(state->current_wave + (state->bonus_round ? 1 : 0));
  glBegin(0x0002); {
    const GLfloat left = 1.5f;
    const GLfloat right = 800 - 1.5f;
    const GLfloat top = 20 + 0.5f;
    const GLfloat bottom = 500 - 20 - 0.5f;
    glVertex2f(left, top); glVertex2f(right, top);
    glVertex2f(right, bottom); glVertex2f(left, bottom);
  } glEnd();
  draw_message(&state->tutorial_message, 20 + 4, state->clock);
  draw_message(&state->status_message, 500 - 20 - 24,
               state->clock);
}

canonical_original_code:
static void draw_hud(struct az_play_state_t *state) {
  if (state->bonus_round && az_clock_mod(2, 2, state->clock)) {
    glColor3f(1, 1, 1);
  } else set_color_for_wave(state->current_wave);
  az_draw_printf(16, AZ_ALIGN_LEFT, 10, 3, "Wave %d", state->current_wave);
  glColor3f(1, 1, 1);
  az_draw_printf(16, AZ_ALIGN_CENTER, 800/2, 3,
                 "%08""l" "d", state->score);
  for (int i = 0; i < 3 && i < state->num_bombs; ++i) {
    az_draw_bomb_icon(800 - 134 - 18 * i, 2);
  }
  if (state->num_bombs > 3) {
    glColor3f(1, 1, 1);
    az_draw_printf(16, AZ_ALIGN_RIGHT, 800 - 171, 3, "%d",
                   state->num_bombs);
  }
  for (int i = 0; i < 3 && i < state->num_lives; ++i) {
    az_draw_avatar_icon(800 - 18 * (i + 1), 2,
                        state->current_wave);
  }
  if (state->num_lives > 3) {
    glColor3f(1, 1, 1);
    az_draw_printf(16, AZ_ALIGN_RIGHT, 800 - 55, 3, "%d",
                   state->num_lives);
  }
  glBegin(0x0005); {
    struct az_color_t color = {255, 255, 255, 255};
    if (!state->bonus_round || az_clock_mod(2, 2, state->clock)) {
      color = az_color_for_wave(state->current_wave);
    }
    float left = 2.0f;
    float right = left + (800 - 2 * left) *
      (state->wave_time_remaining / 15.0);
    float top = 500 - 20 + 3.0f;
    float bottom = 500 - 3.0f;
    float mid = (top + bottom) * 0.5f;
    glColor4ub(color.r, color.g, color.b, 0.5 * color.a);
    glVertex2f(left, top); glVertex2f(right, top);
    glColor4ub(color.r, color.g, color.b, color.a);
    glVertex2f(left, mid); glVertex2f(right, mid);
    glColor4ub(color.r, color.g, color.b, 0.5 * color.a);
    glVertex2f(left, bottom); glVertex2f(right, bottom);
  } glEnd();
  set_color_for_wave(state->current_wave + (state->bonus_round ? 1 : 0));
  glBegin(0x0002); {
    float left = 1.5f;
    float right = 800 - 1.5f;
    float top = 20 + 0.5f;
    float bottom = 500 - 20 - 0.5f;
    glVertex2f(left, top); glVertex2f(right, top);
    glVertex2f(right, bottom); glVertex2f(left, bottom);
  } glEnd();
  draw_message(&state->tutorial_message, 20 + 4, state->clock);
  draw_message(&state->status_message, 500 - 20 - 24,
               state->clock);
}

variable_types: struct az_play_state_t { unsigned long clock; struct az_soundboard_t { enum { AZ_MUSA_NOTHING=0, AZ_MUSA_CHANGE=1, AZ_MUSA_STOP=2 } music_action; enum az_music_key_t { AZ_MUS_NOTHING=0, AZ_MUS_TITLE=1, AZ_MUS_PLAY=2 } next_music; int music_fade_out_millis; int num_oneshots; enum az_sound_key_t { AZ_SND_BONUS_ROUND=0, AZ_SND_BREAK_BONUS_TARGET=1, AZ_SND_BREAK_FAKE_TARGET=2, AZ_SND_BREAK_NORMAL_TARGET=3, AZ_SND_DROP_FAKE_TARGET=4, AZ_SND_FIRE_BOMB=5, AZ_SND_FIRE_BULLET=6, AZ_SND_FIRE_STOPPER=7, AZ_SND_FIRE_TANK_SHELL=8, AZ_SND_FORCEFIELD=9, AZ_SND_GAIN_BOMB=10, AZ_SND_GAIN_LIFE=11, AZ_SND_HIT_TANK_SHELL=12, AZ_SND_HURT_BADDIE=13, AZ_SND_KILL_BASILISK=14, AZ_SND_KILL_GHOST=15, AZ_SND_KILL_GUARD=16, AZ_SND_KILL_TANK=17, AZ_SND_LOSE_LIFE=18, AZ_SND_NEXT_WAVE=19, AZ_SND_STUN_BADDIE=20 } oneshots[10]; int num_persists; struct { enum az_sound_key_t { AZ_SND_BONUS_ROUND=0, AZ_SND_BREAK_BONUS_TARGET=1, AZ_SND_BREAK_FAKE_TARGET=2, AZ_SND_BREAK_NORMAL_TARGET=3, AZ_SND_DROP_FAKE_TARGET=4, AZ_SND_FIRE_BOMB=5, AZ_SND_FIRE_BULLET=6, AZ_SND_FIRE_STOPPER=7, AZ_SND_FIRE_TANK_SHELL=8, AZ_SND_FORCEFIELD=9, AZ_SND_GAIN_BOMB=10, AZ_SND_GAIN_LIFE=11, AZ_SND_HIT_TANK_SHELL=12, AZ_SND_HURT_BADDIE=13, AZ_SND_KILL_BASILISK=14, AZ_SND_KILL_GHOST=15, AZ_SND_KILL_GUARD=16, AZ_SND_KILL_TANK=17, AZ_SND_LOSE_LIFE=18, AZ_SND_NEXT_WAVE=19, AZ_SND_STUN_BADDIE=20 } sound; _Bool play; _Bool loop; _Bool reset; } persists[10]; } soundboard; int num_lives; int num_bombs; long score; int current_wave; int max_wave_on_board; _Bool bonus_round; double wave_time_remaining; int total_baddies_to_spawn; int baddies_left_to_spawn; double spawn_cooldown; double bonus_flash; double gained_life_flash; double lost_life_flash; struct az_message_t { char *text; double time_remaining; _Bool flash; } tutorial_message; struct az_message_t status_message; struct az_vector_t { double x; } avatar_position; struct az_vector_t avatar_velocity; struct az_baddie_t { enum az_baddie_kind_t { AZ_BAD_NOTHING=0, AZ_BAD_BASILISK=1, AZ_BAD_FAKER=2, AZ_BAD_FORCER=3, AZ_BAD_GHOST=4, AZ_BAD_GUARD=5, AZ_BAD_TANK=6 } kind; struct az_vector_t position; struct az_vector_t velocity; double cooldown; double stun; double flare; int hitpoints; } baddies[100]; struct az_particle_t { enum az_particle_kind_t { AZ_PAR_NOTHING=0, AZ_PAR_NORMAL=1 } kind; struct az_color_t { unsigned char r; } color; struct az_vector_t position; struct az_vector_t velocity; double age; } particles[2000]; struct az_projectile_t { enum az_proj_kind_t { AZ_PROJ_NOTHING=0, AZ_PROJ_BULLET=1, AZ_PROJ_BOMB=2, AZ_PROJ_TANK_SHELL=3, AZ_PROJ_STOPPER=4 } kind; struct az_vector_t position; struct az_vector_t velocity; double age; } projectiles[200]; struct az_target_t { enum az_target_kind_t { AZ_TARG_NOTHING=0, AZ_TARG_BONUS=1, AZ_TARG_FAKE=2, AZ_TARG_NORMAL=3, AZ_TARG_REBEL=4, AZ_TARG_UNPLANNED=5 } kind; struct az_vector_t position; struct az_vector_t velocity; int wave; double presence; _Bool is_invisible; double invisibility; } targets[200]; } *

variable_types: i int

variable_types: left float

variable_types: right float

variable_types: top float

variable_types: bottom float

variable_types: mid float

user_defined_types: struct az_play_state_t { unsigned long clock; struct az_soundboard_t soundboard; int num_lives; int num_bombs; long score; int current_wave; int max_wave_on_board; _Bool bonus_round; double wave_time_remaining; int total_baddies_to_spawn; int baddies_left_to_spawn; double spawn_cooldown; double bonus_flash; double gained_life_flash; double lost_life_flash; struct az_message_t tutorial_message; struct az_message_t status_message; struct az_vector_t avatar_position; struct az_vector_t avatar_velocity; struct az_baddie_t baddies[100]; struct az_particle_t particles[2000]; struct az_projectile_t projectiles[200]; struct az_target_t targets[200]; }

user_defined_types: struct az_particle_t { enum az_particle_kind_t kind; struct az_color_t color; struct az_vector_t position; struct az_vector_t velocity; double age; }

user_defined_types: struct az_projectile_t { enum az_proj_kind_t kind; struct az_vector_t position; struct az_vector_t velocity; double age; }

user_defined_types: struct az_target_t { enum az_target_kind_t kind; struct az_vector_t position; struct az_vector_t velocity; int wave; double presence; _Bool is_invisible; double invisibility; }


decompiled_code:
void __fastcall az_draw_play_screen(__int64 a1)
{
double v1; // xmm0_8
double v2; // xmm0_8
double v3; // xmm0_8

az_draw_targets();
az_draw_baddies(a1);
az_draw_projectiles(a1);
az_draw_avatar(a1);
az_draw_particles(a1);
v1 = *(double *)(a1 + 216);
if ( v1 > 0.0 )
flash_screen(0x80FFFFFF, v1);
v2 = *(double *)(a1 + 224);
if ( v2 > 0.0 )
flash_screen(0x400000FFu, v2);
v3 = *(double *)(a1 + 208);
if ( v3 > 0.0 )
flash_screen(0x4080FFFFu, v3);
draw_hud((_QWORD *)a1);
}

canonical_decompiled_code:
void __fastcall func4(__int64 a1)
{
double v1; // xmm0_8
double v2; // xmm0_8
double v3; // xmm0_8

az_draw_targets();
az_draw_baddies(a1);
az_draw_projectiles(a1);
az_draw_avatar(a1);
az_draw_particles(a1);
v1 = *(double *)(a1 + 216);
if ( v1 > 0.0 )
func0(0x80FFFFFF, v1);
v2 = *(double *)(a1 + 224);
if ( v2 > 0.0 )
func0(0x400000FFu, v2);
v3 = *(double *)(a1 + 208);
if ( v3 > 0.0 )
func0(0x4080FFFFu, v3);
func3((_QWORD *)a1);
}

original_code:
void az_draw_play_screen(const az_play_state_t *state) {
  az_draw_targets(state);
  az_draw_baddies(state);
  az_draw_projectiles(state);
  az_draw_avatar(state);
  az_draw_particles(state);
  if (state->gained_life_flash > 0.0) {
    flash_screen((az_color_t){255, 255, 255, 128}, state->gained_life_flash);
  }
  if (state->lost_life_flash > 0.0) {
    flash_screen((az_color_t){255, 0, 0, 64}, state->lost_life_flash);
  }
  if (state->bonus_flash > 0.0) {
    flash_screen((az_color_t){255, 255, 128, 64}, state->bonus_flash);
  }
  draw_hud(state);
}

canonical_original_code:
void az_draw_play_screen(struct az_play_state_t *state) {
  az_draw_targets(state);
  az_draw_baddies(state);
  az_draw_projectiles(state);
  az_draw_avatar(state);
  az_draw_particles(state);
  if (state->gained_life_flash > 0.0) {
    flash_screen((struct az_color_t){255, 255, 255, 128}, state->gained_life_flash);
  }
  if (state->lost_life_flash > 0.0) {
    flash_screen((struct az_color_t){255, 0, 0, 64}, state->lost_life_flash);
  }
  if (state->bonus_flash > 0.0) {
    flash_screen((struct az_color_t){255, 255, 128, 64}, state->bonus_flash);
  }
  draw_hud(state);
}

user_defined_types: struct az_message_t { char *text; double time_remaining; _Bool flash; }

user_defined_types: enum az_music_key_t { AZ_MUS_NOTHING=0, AZ_MUS_TITLE=1, AZ_MUS_PLAY=2 }

user_defined_types: enum az_sound_key_t { AZ_SND_BONUS_ROUND=0, AZ_SND_BREAK_BONUS_TARGET=1, AZ_SND_BREAK_FAKE_TARGET=2, AZ_SND_BREAK_NORMAL_TARGET=3, AZ_SND_DROP_FAKE_TARGET=4, AZ_SND_FIRE_BOMB=5, AZ_SND_FIRE_BULLET=6, AZ_SND_FIRE_STOPPER=7, AZ_SND_FIRE_TANK_SHELL=8, AZ_SND_FORCEFIELD=9, AZ_SND_GAIN_BOMB=10, AZ_SND_GAIN_LIFE=11, AZ_SND_HIT_TANK_SHELL=12, AZ_SND_HURT_BADDIE=13, AZ_SND_KILL_BASILISK=14, AZ_SND_KILL_GHOST=15, AZ_SND_KILL_GUARD=16, AZ_SND_KILL_TANK=17, AZ_SND_LOSE_LIFE=18, AZ_SND_NEXT_WAVE=19, AZ_SND_STUN_BADDIE=20 }

user_defined_types: enum az_particle_kind_t { AZ_PAR_NOTHING=0, AZ_PAR_NORMAL=1 }

user_defined_types: enum az_proj_kind_t { AZ_PROJ_NOTHING=0, AZ_PROJ_BULLET=1, AZ_PROJ_BOMB=2, AZ_PROJ_TANK_SHELL=3, AZ_PROJ_STOPPER=4 }

user_defined_types: enum az_target_kind_t { AZ_TARG_NOTHING=0, AZ_TARG_BONUS=1, AZ_TARG_FAKE=2, AZ_TARG_NORMAL=3, AZ_TARG_REBEL=4, AZ_TARG_UNPLANNED=5 }


original_code:
void az_init_target(az_target_t *target, az_target_kind_t kind, int wave,
                    az_vector_t position) {
  memset(target, 0, sizeof(*target));
  target->kind = kind;
  target->wave = wave;
  target->position = position;
}

canonical_original_code:
void az_init_target(struct az_target_t *target, enum az_target_kind_t kind, int wave, struct az_vector_t position) {
  memset(target, 0, sizeof(*target));
  target->kind = kind;
  target->wave = wave;
  target->position = position;
}

variable_types: struct az_target_t { enum az_target_kind_t { AZ_TARG_NOTHING=0, AZ_TARG_BONUS=1, AZ_TARG_FAKE=2, AZ_TARG_NORMAL=3, AZ_TARG_REBEL=4, AZ_TARG_UNPLANNED=5 } kind; struct az_vector_t { double x; } position; struct az_vector_t velocity; int wave; double presence; _Bool is_invisible; double invisibility; } *

variable_types:
position
struct az_vector_t


decompiled_code:
void __fastcall az_init_target_at_random_position(__int64 a1, int a2, int a3)
{
double v4; // r13
double v5; // xmm1_8

v4 = az_random(11.0, 789.0);
v5 = az_random(31.0, 469.0);
az_init_target(a1, a2, a3, v4, v5);
}

original_code:
void az_init_target_at_random_position(
    az_target_t *target, az_target_kind_t kind, int wave) {
  const az_vector_t position = {
    az_random(1 + 10,
              (800 - 1) - 10),
    az_random(21 + 10,
              (500 - 21) - 10)
  };
  az_init_target(target, kind, wave, position);
}

canonical_original_code:
void az_init_target_at_random_position(struct az_target_t *target, enum az_target_kind_t kind, int wave) {
  struct az_vector_t position = {
    az_random(1 + 10,
              (800 - 1) - 10),
    az_random(21 + 10,
              (500 - 21) - 10)
  };
  az_init_target(target, kind, wave, position);
}

variable_types: enum az_target_kind_t { AZ_TARG_NOTHING=0, AZ_TARG_BONUS=1, AZ_TARG_FAKE=2, AZ_TARG_NORMAL=3, AZ_TARG_REBEL=4, AZ_TARG_UNPLANNED=5 }

variable_types: wave int

variable_types:
position
struct az_vector_t { double x; }


decompiled_code:
__int64 __fastcall az_target_color(_DWORD *a1)
{
__int64 result; // rax

if ( !*a1 )
_assert_fail("target->kind != AZ_TARG_NOTHING", "src/milestone/state/target.c", 0x33u, "az_target_color");
if ( *a1 == 1 )
result = 0xFFFFFFFFLL;
else
result = az_color_for_wave((unsigned int)a1[10]);
return result;
}

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

if ( !*a1 )
_assert_fail("target->kind != AZ_TARG_NOTHING", "src/milestone/state/target.c", 0x33u, "az_target_color");
if ( *a1 == 1 )
result = 0xFFFFFFFFLL;
else
result = az_color_for_wave((unsigned int)a1[10]);
return result;
}

original_code:
az_color_t az_target_color(const az_target_t *target) {
  ((target->kind != AZ_TARG_NOTHING) ? (void) (0) : __assert_fail ("target->kind != AZ_TARG_NOTHING", "src/milestone/state/target.c", 51, __extension__ __PRETTY_FUNCTION__));
  if (target->kind == AZ_TARG_BONUS) return (az_color_t){255, 255, 255, 255};
  return az_color_for_wave(target->wave);
}

canonical_original_code:
struct az_color_t az_target_color(struct az_target_t *target) {
  ((target->kind != AZ_TARG_NOTHING) ? (void) (0) : __assert_fail ("target->kind != AZ_TARG_NOTHING", "src/milestone/state/target.c", 51, __extension__ __PRETTY_FUNCTION__));
  if (target->kind == AZ_TARG_BONUS) return (struct az_color_t){255, 255, 255, 255};
  return az_color_for_wave(target->wave);
}


decompiled_code:
char *az_get_app_data_directory()
{
char *result; // rax
wordexp_t v1; // [rsp+0h] [rbp-B8h] BYREF
struct stat v2; // [rsp+20h] [rbp-98h] BYREF

result = &path_buffer_1;
if ( !path_buffer_1 )
{
wordexp("~/.milestone-game", &v1, 0);
if ( v1.we_wordc )
{
strncpy(&path_buffer_1, *(const char **)v1.we_wordv, 0xFFFuLL);
wordfree(&v1);
if ( stat(&path_buffer_1, &v2) )
{
if ( *_errno_location() == 2 && !mkdir(&path_buffer_1, 0x1C0u) )
return &path_buffer_1;
path_buffer_1 = 0;
}
else
{
if ( (v2.st_mode & 0xF000) == 0x4000 )
return &path_buffer_1;
path_buffer_1 = 0;
}
}
else
{
wordfree(&v1);
}
result = 0LL;
}
return result;
}

canonical_decompiled_code:
char *func0()
{
char *result; // rax
wordexp_t v1; // [rsp+0h] [rbp-B8h] BYREF
struct stat v2; // [rsp+20h] [rbp-98h] BYREF

result = &path_buffer_1;
if ( !path_buffer_1 )
{
wordexp("~/.milestone-game", &v1, 0);
if ( v1.we_wordc )
{
strncpy(&path_buffer_1, *(const char **)v1.we_wordv, 0xFFFuLL);
wordfree(&v1);
if ( stat(&path_buffer_1, &v2) )
{
if ( *_errno_location() == 2 && !mkdir(&path_buffer_1, 0x1C0u) )
return &path_buffer_1;
path_buffer_1 = 0;
}
else
{
if ( (v2.st_mode & 0xF000) == 0x4000 )
return &path_buffer_1;
path_buffer_1 = 0;
}
}
else
{
wordfree(&v1);
}
result = 0LL;
}
return result;
}

original_code:
const char *az_get_app_data_directory(void) {
  static char path_buffer[4096];
  if (path_buffer[0] == '\0') {
    wordexp_t words;
    wordexp("~/.milestone-game", &words, 0);
    if (words.we_wordc < 1) {
      wordfree(&words);
      return ((void *)0);
    }
    strncpy(path_buffer, words.we_wordv[0], sizeof(path_buffer) - 1);
    wordfree(&words);
    struct stat stat_buffer;
    if (stat(path_buffer, &stat_buffer) == 0) {
      if (!((((stat_buffer.st_mode)) & 0170000) == (0040000))) {
        path_buffer[0] = '\0';
        return ((void *)0);
      }
    }
    else if ((*__errno_location ()) != 2 || mkdir(path_buffer, 0700) != 0) {
      path_buffer[0] = '\0';
      return ((void *)0);
    }
  }
  return path_buffer;
}

canonical_original_code:
char *az_get_app_data_directory() {
  static char path_buffer[4096];
  if (path_buffer[0] == '\0') {
    struct wordexp_t words;
    wordexp("~/.milestone-game", &words, 0);
    if (words.we_wordc < 1) {
      wordfree(&words);
      return ((void *)0);
    }
    strncpy(path_buffer, words.we_wordv[0], sizeof(path_buffer) - 1);
    wordfree(&words);
    struct stat stat_buffer;
    if (stat(path_buffer, &stat_buffer) == 0) {
      if (!((((stat_buffer.st_mode)) & 0170000) == (0040000))) {
        path_buffer[0] = '\0';
        return ((void *)0);
      }
    }
    else if ((*__errno_location ()) != 2 || mkdir(path_buffer, 0700) != 0) {
      path_buffer[0] = '\0';
      return ((void *)0);
    }
  }
  return path_buffer;
}

variable_types: struct wordexp_t { unsigned long we_wordc; char **we_wordv; unsigned long we_offs; }

variable_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec { long tv_sec; long tv_nsec; } st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }

return_type: char *

user_defined_types: struct stat { unsigned long st_dev; unsigned long st_ino; unsigned long st_nlink; unsigned int st_mode; unsigned int st_uid; unsigned int st_gid; int __pad0; unsigned long st_rdev; long st_size; long st_blksize; long st_blocks; struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; long __glibc_reserved[3]; }


decompiled_code:
char *az_get_resource_directory()
{
char *result; // rax
int v1; // edx
__int64 v2; // rax
int v3; // edx

result = &path_buffer_0;
if ( !path_buffer_0 )
{
v1 = readlink("/proc/self/exe", &path_buffer_0, 0xFFFuLL);
v2 = v1 - 1;
if ( v1 < 0 )
{
path_buffer_0 = 0;
result = 0LL;
}
else
{
do
{
v3 = v2;
if ( (int)v2 <= 0 )
break;
--v2;
}
while ( byte_141[v2] != 47 );
*(&path_buffer_0 + v3) = 0;
result = &path_buffer_0;
}
}
return result;
}

canonical_decompiled_code:
char *func1()
{
char *result; // rax
int v1; // edx
__int64 v2; // rax
int v3; // edx

result = &path_buffer_0;
if ( !path_buffer_0 )
{
v1 = readlink("/proc/self/exe", &path_buffer_0, 0xFFFuLL);
v2 = v1 - 1;
if ( v1 < 0 )
{
path_buffer_0 = 0;
result = 0LL;
}
else
{
do
{
v3 = v2;
if ( (int)v2 <= 0 )
break;
--v2;
}
while ( byte_141[v2] != 47 );
*(&path_buffer_0 + v3) = 0;
result = &path_buffer_0;
}
}
return result;
}

original_code:
const char *az_get_resource_directory(void) {
  static char path_buffer[4096];
  if (path_buffer[0] == '\0') {
    int len = readlink("/proc/self/exe", path_buffer, sizeof(path_buffer) - 1);
    if (len < 0) {
      path_buffer[0] = '\0';
      return ((void *)0);
    }
    while (--len > 0 && path_buffer[len] != '/');
    path_buffer[len] = '\0';
  }
  return path_buffer;
}

canonical_original_code:
char *az_get_resource_directory() {
  static char path_buffer[4096];
  if (path_buffer[0] == '\0') {
    int len = readlink("/proc/self/exe", path_buffer, sizeof(path_buffer) - 1);
    if (len < 0) {
      path_buffer[0] = '\0';
      return ((void *)0);
    }
    while (--len > 0 && path_buffer[len] != '/');
    path_buffer[len] = '\0';
  }
  return path_buffer;
}

variable_types: len int


decompiled_code:
void az_init_random()
{
unsigned int v0; // eax

if ( random_initialized )
_assert_fail("!random_initialized", "src/milestone/util/random.c", 0x21u, "az_init_random");
v0 = time(0LL);
srand(v0);
random_initialized = 1;
}

canonical_decompiled_code:
void func0()
{
unsigned int v0; // eax

if ( random_initialized )
_assert_fail("!random_initialized", "src/milestone/util/random.c", 0x21u, "az_init_random");
v0 = time(0LL);
srand(v0);
random_initialized = 1;
}

original_code:
void az_init_random(void) {
  ((!random_initialized) ? (void) (0) : __assert_fail ("!random_initialized", "src/milestone/util/random.c", 33, __extension__ __PRETTY_FUNCTION__));
  srand(time(((void *)0)));
  random_initialized = 1;
}

canonical_original_code:
void az_init_random() {
  ((!random_initialized) ? (void) (0) : __assert_fail ("!random_initialized", "src/milestone/util/random.c", 33, __extension__ __PRETTY_FUNCTION__));
  srand(time(((void *)0)));
  random_initialized = 1;
}


decompiled_code:
double __fastcall az_random(double a1, double a2)
{
if ( !random_initialized )
_assert_fail("random_initialized", "src/milestone/util/random.c", 0x27u, "az_random");
if ( COERCE_DOUBLE(*(_QWORD *)&a1 & LC3) > 1.797693134862316e308 )
_assert_fail("isfinite(min)", "src/milestone/util/random.c", 0x28u, "az_random");
if ( COERCE_DOUBLE(*(_QWORD *)&a2 & LC3) > 1.797693134862316e308 )
_assert_fail("isfinite(max)", "src/milestone/util/random.c", 0x29u, "az_random");
if ( a2 <= a1 )
_assert_fail("min < max", "src/milestone/util/random.c", 0x2Au, "az_random");
return (double)rand() * (a2 - a1) * 4.656612873077393e-10 + a1;
}

canonical_decompiled_code:
double __fastcall func1(double a1, double a2)
{
if ( !random_initialized )
_assert_fail("random_initialized", "src/milestone/util/random.c", 0x27u, "az_random");
if ( COERCE_DOUBLE(*(_QWORD *)&a1 & LC3) > 1.797693134862316e308 )
_assert_fail("isfinite(min)", "src/milestone/util/random.c", 0x28u, "az_random");
if ( COERCE_DOUBLE(*(_QWORD *)&a2 & LC3) > 1.797693134862316e308 )
_assert_fail("isfinite(max)", "src/milestone/util/random.c", 0x29u, "az_random");
if ( a2 <= a1 )
_assert_fail("min < max", "src/milestone/util/random.c", 0x2Au, "az_random");
return (double)rand() * (a2 - a1) * 4.656612873077393e-10 + a1;
}

original_code:
double az_random(double min, double max) {
  ((random_initialized) ? (void) (0) : __assert_fail ("random_initialized", "src/milestone/util/random.c", 39, __extension__ __PRETTY_FUNCTION__));
  ((__builtin_isfinite (min)) ? (void) (0) : __assert_fail ("isfinite(min)", "src/milestone/util/random.c", 40, __extension__ __PRETTY_FUNCTION__));
  ((__builtin_isfinite (max)) ? (void) (0) : __assert_fail ("isfinite(max)", "src/milestone/util/random.c", 41, __extension__ __PRETTY_FUNCTION__));
  ((min < max) ? (void) (0) : __assert_fail ("min < max", "src/milestone/util/random.c", 42, __extension__ __PRETTY_FUNCTION__));
  return min + (max - min) * (double)rand() / (1.0 + (double)2147483647);
}

variable_types: min double

variable_types: max double

return_type: double


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

if ( !random_initialized )
_assert_fail("random_initialized", "src/milestone/util/random.c", 0x30u, "az_randint");
if ( a1 > (int)a2 )
_assert_fail("min <= max", "src/milestone/util/random.c", 0x31u, "az_randint");
result = a2;
if ( a1 != a2 )
result = (unsigned int)(rand() % (int)(a2 + 1 - a1) + a1);
return result;
}

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

if ( !random_initialized )
_assert_fail("random_initialized", "src/milestone/util/random.c", 0x30u, "az_randint");
if ( a1 > (int)a2 )
_assert_fail("min <= max", "src/milestone/util/random.c", 0x31u, "az_randint");
result = a2;
if ( a1 != a2 )
result = (unsigned int)(rand() % (int)(a2 + 1 - a1) + a1);
return result;
}

original_code:
int az_randint(int min, int max) {
  ((random_initialized) ? (void) (0) : __assert_fail ("random_initialized", "src/milestone/util/random.c", 48, __extension__ __PRETTY_FUNCTION__));
  ((min <= max) ? (void) (0) : __assert_fail ("min <= max", "src/milestone/util/random.c", 49, __extension__ __PRETTY_FUNCTION__));
  if (min == max) return min;
  return min + rand() % (1 + max - min);
}

variable_types: min int

variable_types: max int