// File: /workspace/github_c_makefile_star2_O1/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 0x11969
movq %rdi, %rbx
cmpb $0x0, 0x1110(%rdi)
je 0x11969
movl %esi, %r14d
movl 0x1118(%rbx), %eax
cmpl $0x3, %eax
je 0x116e4
cmpl $0x2, %eax
jne 0x1171d
testb $0x1, %r14b
jne 0x11729
xorl %eax, %eax
cmpl $0x35, 0x1578(%rbx,%rax)
jne 0x116cc
movb $0x1, 0x1588(%rbx,%rax)
addq $0x18, %rax
cmpq $0x60, %rax
jne 0x116ba
leaq 0x1158(%rbx), %rdi
callq 0x3d18
jmp 0x1173a
testb $0x1, %r14b
jne 0x11840
xorl %eax, %eax
cmpl $0x30, 0x1578(%rbx,%rax)
jne 0x11702
movb $0x1, 0x1588(%rbx,%rax)
addq $0x18, %rax
cmpq $0x60, %rax
jne 0x116f0
leaq 0x1158(%rbx), %rdi
callq 0x3d18
jmp 0x11851
movb %r14b, 0x111e(%rbx)
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x1158(%rbx), %rdi
movl $0x35, %esi
callq 0x3060
testb $0x2, %r14b
jne 0x1176c
xorl %eax, %eax
cmpl $0x31, 0x1578(%rbx,%rax)
jne 0x11754
movb $0x1, 0x1588(%rbx,%rax)
addq $0x18, %rax
cmpq $0x60, %rax
jne 0x11742
leaq 0x1158(%rbx), %rdi
callq 0x3d18
jmp 0x1177d
leaq 0x1158(%rbx), %rdi
movl $0x31, %esi
callq 0x3060
testb $0x1, %r14b
jne 0x117af
xorl %eax, %eax
cmpl $0x32, 0x1578(%rbx,%rax)
jne 0x11797
movb $0x1, 0x1588(%rbx,%rax)
addq $0x18, %rax
cmpq $0x60, %rax
jne 0x11785
leaq 0x1158(%rbx), %rdi
callq 0x3d18
jmp 0x117c0
leaq 0x1158(%rbx), %rdi
movl $0x32, %esi
callq 0x3060
testb $0x4, %r14b
jne 0x117f2
xorl %eax, %eax
cmpl $0x33, 0x1578(%rbx,%rax)
jne 0x117da
movb $0x1, 0x1588(%rbx,%rax)
addq $0x18, %rax
cmpq $0x60, %rax
jne 0x117c8
leaq 0x1158(%rbx), %rdi
callq 0x3d18
jmp 0x11803
leaq 0x1158(%rbx), %rdi
movl $0x33, %esi
callq 0x3060
testb $0x8, %r14b
jne 0x1182c
xorl %eax, %eax
cmpl $0x34, 0x1578(%rbx,%rax)
jne 0x1181d
movb $0x1, 0x1588(%rbx,%rax)
addq $0x18, %rax
cmpq $0x60, %rax
jne 0x1180b
jmp 0x1193e
addq $0x1158, %rbx           # imm = 0x1158
movq %rbx, %rdi
movl $0x34, %esi
jmp 0x11960
leaq 0x1158(%rbx), %rdi
movl $0x30, %esi
callq 0x3060
testb $0x2, %r14b
jne 0x11883
xorl %eax, %eax
cmpl $0x36, 0x1578(%rbx,%rax)
jne 0x1186b
movb $0x1, 0x1588(%rbx,%rax)
addq $0x18, %rax
cmpq $0x60, %rax
jne 0x11859
leaq 0x1158(%rbx), %rdi
callq 0x3d18
jmp 0x11894
leaq 0x1158(%rbx), %rdi
movl $0x36, %esi
callq 0x3060
testb $0x1, %r14b
jne 0x118c6
xorl %eax, %eax
cmpl $0x37, 0x1578(%rbx,%rax)
jne 0x118ae
movb $0x1, 0x1588(%rbx,%rax)
addq $0x18, %rax
cmpq $0x60, %rax
jne 0x1189c
leaq 0x1158(%rbx), %rdi
callq 0x3d18
jmp 0x118d7
leaq 0x1158(%rbx), %rdi
movl $0x37, %esi
callq 0x3060
testb $0x4, %r14b
jne 0x11909
xorl %eax, %eax
cmpl $0x38, 0x1578(%rbx,%rax)
jne 0x118f1
movb $0x1, 0x1588(%rbx,%rax)
addq $0x18, %rax
cmpq $0x60, %rax
jne 0x118df
leaq 0x1158(%rbx), %rdi
callq 0x3d18
jmp 0x1191a
leaq 0x1158(%rbx), %rdi
movl $0x38, %esi
callq 0x3060
testb $0x8, %r14b
jne 0x11951
xorl %eax, %eax
cmpl $0x39, 0x1578(%rbx,%rax)
jne 0x11934
movb $0x1, 0x1588(%rbx,%rax)
addq $0x18, %rax
cmpq $0x60, %rax
jne 0x11922
addq $0x1158, %rbx           # imm = 0x1158
movq %rbx, %rdi
popq %rbx
popq %r14
popq %rbp
jmp 0x3d18
addq $0x1158, %rbx           # imm = 0x1158
movq %rbx, %rdi
movl $0x39, %esi
popq %rbx
popq %r14
popq %rbp
jmp 0x3060
leaq 0x292d(%rip), %rdi      # 0x1429d
leaq 0x27f3(%rip), %rsi      # 0x1416a
leaq 0x2a1a(%rip), %rcx      # 0x14398
movl $0x1b1, %edx            # imm = 0x1B1
callq 0x30b0