// File: /workspace/github_c_makefile_star2_O3/leiradel[P]zx48k-libretro/src/zx.h
// Function: zx_joystick
void zx_joystick(zx_t* sys, uint8_t mask) {
    CHIPS_ASSERT(sys && sys->valid);
    if (sys->joystick_type == ZX_JOYSTICKTYPE_SINCLAIR_1) {
        if (mask & ZX_JOYSTICK_RIGHT) { kbd_key_down(&sys->kbd, '5'); }
        else                          { kbd_key_up(&sys->kbd, '5'); }
        if (mask & ZX_JOYSTICK_LEFT)  { kbd_key_down(&sys->kbd, '1'); }
        else                          { kbd_key_up(&sys->kbd, '1'); }
        if (mask & ZX_JOYSTICK_RIGHT) { kbd_key_down(&sys->kbd, '2'); }
        else                          { kbd_key_up(&sys->kbd, '2'); }
        if (mask & ZX_JOYSTICK_DOWN)  { kbd_key_down(&sys->kbd, '3'); }
        else                          { kbd_key_up(&sys->kbd, '3'); }
        if (mask & ZX_JOYSTICK_UP)    { kbd_key_down(&sys->kbd, '4'); }
        else                          { kbd_key_up(&sys->kbd, '4'); }
    }
    else if (sys->joystick_type == ZX_JOYSTICKTYPE_SINCLAIR_2) {
        if (mask & ZX_JOYSTICK_RIGHT) { kbd_key_down(&sys->kbd, '0'); }
        else                          { kbd_key_up(&sys->kbd, '0'); }
        if (mask & ZX_JOYSTICK_LEFT)  { kbd_key_down(&sys->kbd, '6'); }
        else                          { kbd_key_up(&sys->kbd, '6'); }
        if (mask & ZX_JOYSTICK_RIGHT) { kbd_key_down(&sys->kbd, '7'); }
        else                          { kbd_key_up(&sys->kbd, '7'); }
        if (mask & ZX_JOYSTICK_DOWN)  { kbd_key_down(&sys->kbd, '8'); }
        else                          { kbd_key_up(&sys->kbd, '8'); }
        if (mask & ZX_JOYSTICK_UP)    { kbd_key_down(&sys->kbd, '9'); }
        else                          { kbd_key_up(&sys->kbd, '9'); }
    }
    else {
        sys->joy_joymask = mask;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
testq %rdi, %rdi
je 0x1193f
movq %rdi, %rbx
cmpb $0x0, 0x1110(%rdi)
je 0x1193f
movl %esi, %r14d
movl 0x1118(%rbx), %eax
cmpl $0x3, %eax
je 0x116ba
cmpl $0x2, %eax
jne 0x116f3
testb $0x1, %r14b
jne 0x116ff
xorl %eax, %eax
cmpl $0x35, 0x1578(%rbx,%rax)
jne 0x116a2
movb $0x1, 0x1588(%rbx,%rax)
addq $0x18, %rax
cmpq $0x60, %rax
jne 0x11690
leaq 0x1158(%rbx), %rdi
callq 0x3cff
jmp 0x11710
testb $0x1, %r14b
jne 0x11816
xorl %eax, %eax
cmpl $0x30, 0x1578(%rbx,%rax)
jne 0x116d8
movb $0x1, 0x1588(%rbx,%rax)
addq $0x18, %rax
cmpq $0x60, %rax
jne 0x116c6
leaq 0x1158(%rbx), %rdi
callq 0x3cff
jmp 0x11827
movb %r14b, 0x111e(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x1158(%rbx), %rdi
movl $0x35, %esi
callq 0x3060
testb $0x2, %r14b
jne 0x11742
xorl %eax, %eax
cmpl $0x31, 0x1578(%rbx,%rax)
jne 0x1172a
movb $0x1, 0x1588(%rbx,%rax)
addq $0x18, %rax
cmpq $0x60, %rax
jne 0x11718
leaq 0x1158(%rbx), %rdi
callq 0x3cff
jmp 0x11753
leaq 0x1158(%rbx), %rdi
movl $0x31, %esi
callq 0x3060
testb $0x1, %r14b
jne 0x11785
xorl %eax, %eax
cmpl $0x32, 0x1578(%rbx,%rax)
jne 0x1176d
movb $0x1, 0x1588(%rbx,%rax)
addq $0x18, %rax
cmpq $0x60, %rax
jne 0x1175b
leaq 0x1158(%rbx), %rdi
callq 0x3cff
jmp 0x11796
leaq 0x1158(%rbx), %rdi
movl $0x32, %esi
callq 0x3060
testb $0x4, %r14b
jne 0x117c8
xorl %eax, %eax
cmpl $0x33, 0x1578(%rbx,%rax)
jne 0x117b0
movb $0x1, 0x1588(%rbx,%rax)
addq $0x18, %rax
cmpq $0x60, %rax
jne 0x1179e
leaq 0x1158(%rbx), %rdi
callq 0x3cff
jmp 0x117d9
leaq 0x1158(%rbx), %rdi
movl $0x33, %esi
callq 0x3060
testb $0x8, %r14b
jne 0x11802
xorl %eax, %eax
cmpl $0x34, 0x1578(%rbx,%rax)
jne 0x117f3
movb $0x1, 0x1588(%rbx,%rax)
addq $0x18, %rax
cmpq $0x60, %rax
jne 0x117e1
jmp 0x11914
addq $0x1158, %rbx           # imm = 0x1158
movq %rbx, %rdi
movl $0x34, %esi
jmp 0x11936
leaq 0x1158(%rbx), %rdi
movl $0x30, %esi
callq 0x3060
testb $0x2, %r14b
jne 0x11859
xorl %eax, %eax
cmpl $0x36, 0x1578(%rbx,%rax)
jne 0x11841
movb $0x1, 0x1588(%rbx,%rax)
addq $0x18, %rax
cmpq $0x60, %rax
jne 0x1182f
leaq 0x1158(%rbx), %rdi
callq 0x3cff
jmp 0x1186a
leaq 0x1158(%rbx), %rdi
movl $0x36, %esi
callq 0x3060
testb $0x1, %r14b
jne 0x1189c
xorl %eax, %eax
cmpl $0x37, 0x1578(%rbx,%rax)
jne 0x11884
movb $0x1, 0x1588(%rbx,%rax)
addq $0x18, %rax
cmpq $0x60, %rax
jne 0x11872
leaq 0x1158(%rbx), %rdi
callq 0x3cff
jmp 0x118ad
leaq 0x1158(%rbx), %rdi
movl $0x37, %esi
callq 0x3060
testb $0x4, %r14b
jne 0x118df
xorl %eax, %eax
cmpl $0x38, 0x1578(%rbx,%rax)
jne 0x118c7
movb $0x1, 0x1588(%rbx,%rax)
addq $0x18, %rax
cmpq $0x60, %rax
jne 0x118b5
leaq 0x1158(%rbx), %rdi
callq 0x3cff
jmp 0x118f0
leaq 0x1158(%rbx), %rdi
movl $0x38, %esi
callq 0x3060
testb $0x8, %r14b
jne 0x11927
xorl %eax, %eax
cmpl $0x39, 0x1578(%rbx,%rax)
jne 0x1190a
movb $0x1, 0x1588(%rbx,%rax)
addq $0x18, %rax
cmpq $0x60, %rax
jne 0x118f8
addq $0x1158, %rbx           # imm = 0x1158
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x3cff
addq $0x1158, %rbx           # imm = 0x1158
movq %rbx, %rdi
movl $0x39, %esi
popq %rbx
popq %r14
popq %rbp
jmp 0x3060
leaq 0x2947(%rip), %rdi      # 0x1428d
leaq 0x280d(%rip), %rsi      # 0x1415a
leaq 0x2a34(%rip), %rcx      # 0x14388
movl $0x1b1, %edx            # imm = 0x1B1
callq 0x30b0