// File: /workspace/github_c_makefile_star2_O0/leiradel[P]zx48k-libretro/src/kbd.h
// Function: kbd_test_lines
static uint16_t _kbd_test_lines(kbd_t* kbd, uint16_t column_mask) {
    CHIPS_ASSERT(kbd);
    uint16_t line_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_col_mask = _kbd_columns(key_mask);
            if ((key_col_mask & column_mask) == key_col_mask) {
                line_bits |= _kbd_lines(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_col_mask = _kbd_columns(mod_mask);
                        if (mod_col_mask) {
                            if ((mod_col_mask & column_mask) == mod_col_mask) {
                                line_bits |= _kbd_lines(mod_mask);
                            }
                        }
                        else {
                            line_bits |= _kbd_lines(mod_mask);
                        }
                    }
                }
            }
        }
    }
    return line_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 0x2308c
jmp 0x230ab
leaq 0x1da6(%rip), %rdi      # 0x24e39
leaq 0x1da3(%rip), %rsi      # 0x24e3d
movl $0xea, %edx
leaq 0x24e3(%rip), %rcx      # 0x25589
callq 0x3180
movw $0x0, -0xc(%rbp)
movl $0x0, -0x10(%rbp)
cmpl $0x4, -0x10(%rbp)
jge 0x231d4
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 0x231c4
movl -0x14(%rbp), %edi
callq 0x23200
movw %ax, -0x16(%rbp)
movzwl -0x16(%rbp), %eax
movzwl -0xa(%rbp), %ecx
andl %ecx, %eax
movzwl -0x16(%rbp), %ecx
cmpl %ecx, %eax
jne 0x2311a
movl -0x14(%rbp), %edi
callq 0x231e0
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 0x231c2
movl $0x0, -0x20(%rbp)
cmpl $0x4, -0x20(%rbp)
jge 0x231c0
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 0x231b0
movl -0x24(%rbp), %edi
callq 0x23200
movw %ax, -0x26(%rbp)
cmpw $0x0, -0x26(%rbp)
je 0x23199
movzwl -0x26(%rbp), %eax
movzwl -0xa(%rbp), %ecx
andl %ecx, %eax
movzwl -0x26(%rbp), %ecx
cmpl %ecx, %eax
jne 0x23197
movl -0x24(%rbp), %edi
callq 0x231e0
movzwl %ax, %ecx
movzwl -0xc(%rbp), %eax
orl %ecx, %eax
movw %ax, -0xc(%rbp)
jmp 0x231ae
movl -0x24(%rbp), %edi
callq 0x231e0
movzwl %ax, %ecx
movzwl -0xc(%rbp), %eax
orl %ecx, %eax
movw %ax, -0xc(%rbp)
jmp 0x231b0
jmp 0x231b2
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x23136
jmp 0x231c2
jmp 0x231c4
jmp 0x231c6
movl -0x10(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x10(%rbp)
jmp 0x230b8
movw -0xc(%rbp), %ax
addq $0x30, %rsp
popq %rbp
retq
nop