// File: /workspace/github_c_makefile_star2_O0/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
subq $0x10, %rsp
movb %sil, %al
movq %rdi, -0x8(%rbp)
movb %al, -0x9(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x21ac8
movq -0x8(%rbp), %rax
testb $0x1, 0x1110(%rax)
je 0x21ac8
jmp 0x21ae7
leaq 0x38ce(%rip), %rdi      # 0x2539d
leaq 0x3794(%rip), %rsi      # 0x2526a
movl $0x1b1, %edx            # imm = 0x1B1
leaq 0x39b6(%rip), %rcx      # 0x25498
callq 0x3180
movq -0x8(%rbp), %rax
cmpl $0x2, 0x1118(%rax)
jne 0x21c15
movzbl -0x9(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x21b1b
movq -0x8(%rbp), %rdi
addq $0x1158, %rdi           # imm = 0x1158
movl $0x35, %esi
callq 0x30b0
jmp 0x21b30
movq -0x8(%rbp), %rdi
addq $0x1158, %rdi           # imm = 0x1158
movl $0x35, %esi
callq 0x3090
movzbl -0x9(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x21b53
movq -0x8(%rbp), %rdi
addq $0x1158, %rdi           # imm = 0x1158
movl $0x31, %esi
callq 0x30b0
jmp 0x21b68
movq -0x8(%rbp), %rdi
addq $0x1158, %rdi           # imm = 0x1158
movl $0x31, %esi
callq 0x3090
movzbl -0x9(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x21b8b
movq -0x8(%rbp), %rdi
addq $0x1158, %rdi           # imm = 0x1158
movl $0x32, %esi
callq 0x30b0
jmp 0x21ba0
movq -0x8(%rbp), %rdi
addq $0x1158, %rdi           # imm = 0x1158
movl $0x32, %esi
callq 0x3090
movzbl -0x9(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x21bc3
movq -0x8(%rbp), %rdi
addq $0x1158, %rdi           # imm = 0x1158
movl $0x33, %esi
callq 0x30b0
jmp 0x21bd8
movq -0x8(%rbp), %rdi
addq $0x1158, %rdi           # imm = 0x1158
movl $0x33, %esi
callq 0x3090
movzbl -0x9(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x21bfb
movq -0x8(%rbp), %rdi
addq $0x1158, %rdi           # imm = 0x1158
movl $0x34, %esi
callq 0x30b0
jmp 0x21c10
movq -0x8(%rbp), %rdi
addq $0x1158, %rdi           # imm = 0x1158
movl $0x34, %esi
callq 0x3090
jmp 0x21d4f
movq -0x8(%rbp), %rax
cmpl $0x3, 0x1118(%rax)
jne 0x21d40
movzbl -0x9(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x21c49
movq -0x8(%rbp), %rdi
addq $0x1158, %rdi           # imm = 0x1158
movl $0x30, %esi
callq 0x30b0
jmp 0x21c5e
movq -0x8(%rbp), %rdi
addq $0x1158, %rdi           # imm = 0x1158
movl $0x30, %esi
callq 0x3090
movzbl -0x9(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x21c81
movq -0x8(%rbp), %rdi
addq $0x1158, %rdi           # imm = 0x1158
movl $0x36, %esi
callq 0x30b0
jmp 0x21c96
movq -0x8(%rbp), %rdi
addq $0x1158, %rdi           # imm = 0x1158
movl $0x36, %esi
callq 0x3090
movzbl -0x9(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x21cb9
movq -0x8(%rbp), %rdi
addq $0x1158, %rdi           # imm = 0x1158
movl $0x37, %esi
callq 0x30b0
jmp 0x21cce
movq -0x8(%rbp), %rdi
addq $0x1158, %rdi           # imm = 0x1158
movl $0x37, %esi
callq 0x3090
movzbl -0x9(%rbp), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x21cf1
movq -0x8(%rbp), %rdi
addq $0x1158, %rdi           # imm = 0x1158
movl $0x38, %esi
callq 0x30b0
jmp 0x21d06
movq -0x8(%rbp), %rdi
addq $0x1158, %rdi           # imm = 0x1158
movl $0x38, %esi
callq 0x3090
movzbl -0x9(%rbp), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x21d29
movq -0x8(%rbp), %rdi
addq $0x1158, %rdi           # imm = 0x1158
movl $0x39, %esi
callq 0x30b0
jmp 0x21d3e
movq -0x8(%rbp), %rdi
addq $0x1158, %rdi           # imm = 0x1158
movl $0x39, %esi
callq 0x3090
jmp 0x21d4d
movb -0x9(%rbp), %cl
movq -0x8(%rbp), %rax
movb %cl, 0x111e(%rax)
jmp 0x21d4f
addq $0x10, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)