// File: /workspace/github_c_makefile_star2_O3/leiradel[P]zx48k-libretro/src/zx.h
// Function: zx_key_down
void zx_key_down(zx_t* sys, int key_code) {
    CHIPS_ASSERT(sys && sys->valid);
    switch (sys->joystick_type) {
        case ZX_JOYSTICKTYPE_NONE:
            kbd_key_down(&sys->kbd, key_code);
            break;
        case ZX_JOYSTICKTYPE_KEMPSTON:
            switch (key_code) {
                case 0x20:  sys->kbd_joymask |= ZX_JOYSTICK_BTN; break;
                case 0x08:  sys->kbd_joymask |= ZX_JOYSTICK_LEFT; break;
                case 0x09:  sys->kbd_joymask |= ZX_JOYSTICK_RIGHT; break;
                case 0x0A:  sys->kbd_joymask |= ZX_JOYSTICK_DOWN; break;
                case 0x0B:  sys->kbd_joymask |= ZX_JOYSTICK_UP; break;
                default:    kbd_key_down(&sys->kbd, key_code); break;
            }
            break;
        /* the Sinclair joystick ports work as normal keys */
        case ZX_JOYSTICKTYPE_SINCLAIR_1:
            switch (key_code) {
                case 0x20:  key_code = '5'; break;    /* fire */
                case 0x08:  key_code = '1'; break;    /* left */
                case 0x09:  key_code = '2'; break;    /* right */
                case 0x0A:  key_code = '3'; break;    /* down */
                case 0x0B:  key_code = '4'; break;    /* up */
                default: break;
            }
            kbd_key_down(&sys->kbd, key_code);
            break;
        case ZX_JOYSTICKTYPE_SINCLAIR_2:
            switch (key_code) {
                case 0x20:  key_code = '0'; break;    /* fire */
                case 0x08:  key_code = '6'; break;    /* left */
                case 0x09:  key_code = '7'; break;    /* right */
                case 0x0A:  key_code = '8'; break;    /* down */
                case 0x0B:  key_code = '9'; break;    /* up */
                default: break;
            }
            kbd_key_down(&sys->kbd, key_code);
            break;
    }
}

// Assembly:
testq %rdi, %rdi
je 0x11483
cmpb $0x0, 0x1110(%rdi)
je 0x11483
movl 0x1118(%rdi), %eax
cmpq $0x3, %rax
ja 0x11402
leaq 0x22b0(%rip), %rcx      # 0x13640
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
addq $0x1158, %rdi           # imm = 0x1158
jmp 0x3060
leal -0x8(%rsi), %eax
cmpl $0x3, %eax
ja 0x11403
leaq 0x22ac(%rip), %rcx      # 0x13660
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x31, %esi
jmp 0x11399
leal -0x8(%rsi), %eax
cmpl $0x3, %eax
ja 0x1140f
leaq 0x227d(%rip), %rcx      # 0x13650
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x36, %esi
jmp 0x11399
leal -0x8(%rsi), %eax
cmpl $0x3, %eax
ja 0x1141e
leaq 0x227e(%rip), %rcx      # 0x13670
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
orb $0x2, 0x111d(%rdi)
retq
cmpl $0x20, %esi
jne 0x11399
movl $0x35, %esi
jmp 0x11399
cmpl $0x20, %esi
jne 0x11399
movl $0x30, %esi
jmp 0x11399
cmpl $0x20, %esi
jne 0x11399
orb $0x10, 0x111d(%rdi)
retq
movl $0x33, %esi
jmp 0x11399
movl $0x34, %esi
jmp 0x11399
movl $0x38, %esi
jmp 0x11399
movl $0x32, %esi
jmp 0x11399
orb $0x4, 0x111d(%rdi)
retq
movl $0x39, %esi
jmp 0x11399
movl $0x37, %esi
jmp 0x11399
orb $0x8, 0x111d(%rdi)
retq
orb $0x1, 0x111d(%rdi)
retq
pushq %rbp
movq %rsp, %rbp
leaq 0x2dff(%rip), %rdi      # 0x1428d
leaq 0x2cc5(%rip), %rsi      # 0x1415a
leaq 0x2e50(%rip), %rcx      # 0x142ec
movl $0x153, %edx            # imm = 0x153
callq 0x30b0