// File: /workspace/github_c_makefile_star2_O0/leiradel[P]zx48k-libretro/src/kbd.h
// Function: kbd_test_columns
static uint16_t _kbd_test_columns(kbd_t* kbd, uint16_t line_mask) {
    CHIPS_ASSERT(kbd);
    uint16_t column_bits = 0;
    for (int key_index = 0; key_index < KBD_MAX_PRESSED_KEYS; key_index++) {
        const uint32_t key_mask = kbd->key_buffer[key_index].mask;
        if (key_mask) {
            const uint16_t key_line_mask = _kbd_lines(key_mask);
            if ((key_line_mask & line_mask) == key_line_mask) {
                column_bits |= _kbd_columns(key_mask);
            }
            const uint32_t key_mod_mask = _kbd_mod(key_mask);
            if (key_mod_mask) {
                for (int mod_index = 0; mod_index < KBD_MAX_MOD_KEYS; mod_index++) {
                    const uint32_t mod_mask = kbd->mod_masks[mod_index];
                    if (mod_mask & key_mod_mask) {
                        const uint16_t mod_line_mask = _kbd_lines(mod_mask);
                        if (mod_line_mask) {
                            if ((mod_line_mask & line_mask) == mod_line_mask) {
                                column_bits |= _kbd_columns(mod_mask);
                            }
                        }
                        else {
                            column_bits |= _kbd_columns(mod_mask);
                        }
                    }
                }
            }
        }
    }
    return column_bits;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movw %si, %ax
movq %rdi, -0x8(%rbp)
movw %ax, -0xa(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x22f1c
jmp 0x22f3b
leaq 0x1f16(%rip), %rdi      # 0x24e39
leaq 0x1f13(%rip), %rsi      # 0x24e3d
movl $0x10b, %edx            # imm = 0x10B
leaq 0x2625(%rip), %rcx      # 0x2555b
callq 0x3180
movw $0x0, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
cmpl $0x4, -0x10(%rbp)
jge 0x23064
movq -0x8(%rbp), %rax
addq $0x420, %rax            # imm = 0x420
movslq -0x10(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movl 0x4(%rax), %eax
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x23054
movl -0x14(%rbp), %edi
callq 0x231e0
movw %ax, -0x16(%rbp)
movzwl -0x16(%rbp), %eax
movzwl -0xa(%rbp), %ecx
andl %ecx, %eax
movzwl -0x16(%rbp), %ecx
cmpl %ecx, %eax
jne 0x22faa
movl -0x14(%rbp), %edi
callq 0x23200
movzwl %ax, %ecx
movzwl -0xc(%rbp), %eax
orl %ecx, %eax
movw %ax, -0xc(%rbp)
movl -0x14(%rbp), %edi
callq 0x23220
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x23052
movl $0x0, -0x20(%rbp)
cmpl $0x4, -0x20(%rbp)
jge 0x23050
movq -0x8(%rbp), %rax
movslq -0x20(%rbp), %rcx
movl 0x410(%rax,%rcx,4), %eax
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
andl -0x1c(%rbp), %eax
cmpl $0x0, %eax
je 0x23040
movl -0x24(%rbp), %edi
callq 0x231e0
movw %ax, -0x26(%rbp)
cmpw $0x0, -0x26(%rbp)
je 0x23029
movzwl -0x26(%rbp), %eax
movzwl -0xa(%rbp), %ecx
andl %ecx, %eax
movzwl -0x26(%rbp), %ecx
cmpl %ecx, %eax
jne 0x23027
movl -0x24(%rbp), %edi
callq 0x23200
movzwl %ax, %ecx
movzwl -0xc(%rbp), %eax
orl %ecx, %eax
movw %ax, -0xc(%rbp)
jmp 0x2303e
movl -0x24(%rbp), %edi
callq 0x23200
movzwl %ax, %ecx
movzwl -0xc(%rbp), %eax
orl %ecx, %eax
movw %ax, -0xc(%rbp)
jmp 0x23040
jmp 0x23042
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x22fc6
jmp 0x23052
jmp 0x23054
jmp 0x23056
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x22f48
movw -0xc(%rbp), %ax
addq $0x30, %rsp
popq %rbp
retq
nop