// File: fulhax[P]ncpamixer/src/ui/tab.cpp
// Function: Tab::handleDropDown(PaObject*)
void Tab::handleDropDown(PaObject* selected_pobj)
{
    uint32_t selected = 0;

    int BLOCK_SIZE = getBlockSize();

    if (selected_pobj != nullptr && toggle != nullptr) {
        selected = dropDown(
                       -1,
                       std::min(
                           selected_block * (BLOCK_SIZE),
                           (total_blocks - 1) * BLOCK_SIZE
                       ),
                       *toggle,
                       selected_pobj->getRelation()
                   );

        if (selected != static_cast<uint32_t>(-1)) {
            selected_pobj->move(selected);
        }
    } else if (selected_pobj != nullptr) {
        uint32_t w = 0;
        int x = 0;

        int y = std::min(
                    selected_block * (BLOCK_SIZE),
                    (total_blocks - 1) * BLOCK_SIZE
                );


        if (has_volume) {
            x = -1;
        } else {
            x = 1;
            w = ui.width - 3;
            y += 2;
        }

        selected = dropDown(
                       x,
                       y,
                       selected_pobj->attributes,
                       selected_pobj->getRelation(),
                       w
                   );

        if (selected != static_cast<uint32_t>(-1)) {
            selected_pobj->set_active_attribute(
                selected_pobj->attributes[selected]->name
            );
        }
    }
}

// Assembly:
subq $0xb8, %rsp
movq %rdi, 0xb0(%rsp)
movq %rsi, 0xa8(%rsp)
movq 0xb0(%rsp), %rdi
movq %rdi, 0x28(%rsp)
movl $0x0, 0xa4(%rsp)
callq 0x172e0
movl %eax, 0xa0(%rsp)
cmpq $0x0, 0xa8(%rsp)
je 0x1929b
movq 0x28(%rsp), %rax
cmpq $0x0, 0x18(%rax)
je 0x1929b
movq 0x28(%rsp), %rax
movl 0x20(%rax), %ecx
movl 0xa0(%rsp), %edx
imull %edx, %ecx
movl %ecx, 0x9c(%rsp)
movl 0x24(%rax), %eax
decl %eax
movl 0xa0(%rsp), %ecx
imull %ecx, %eax
movl %eax, 0x98(%rsp)
leaq 0x9c(%rsp), %rdi
leaq 0x98(%rsp), %rsi
callq 0x1b290
movq %rax, %rcx
movq 0x28(%rsp), %rax
movl (%rcx), %ecx
movl %ecx, 0x20(%rsp)
movq 0x18(%rax), %rsi
leaq 0x68(%rsp), %rdi
callq 0x1b110
movq 0xa8(%rsp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movl %eax, 0x24(%rsp)
jmp 0x19221
movl 0x24(%rsp), %ecx
movl 0x20(%rsp), %esi
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
leaq 0x68(%rsp), %rdx
xorl %r9d, %r9d
movl %r9d, %r8d
callq 0x19c10
movl %eax, 0x1c(%rsp)
jmp 0x19244
movl 0x1c(%rsp), %eax
movl %eax, 0xa4(%rsp)
leaq 0x68(%rsp), %rdi
callq 0xd070
cmpl $-0x1, 0xa4(%rsp)
je 0x19296
movq 0xa8(%rsp), %rdi
movl 0xa4(%rsp), %esi
callq 0x9060
jmp 0x19296
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x60(%rsp)
movl %eax, 0x5c(%rsp)
leaq 0x68(%rsp), %rdi
callq 0xd070
jmp 0x19415
jmp 0x1940d
cmpq $0x0, 0xa8(%rsp)
je 0x1940b
movq 0x28(%rsp), %rax
movl $0x0, 0x58(%rsp)
movl $0x0, 0x54(%rsp)
movl 0x20(%rax), %ecx
imull 0xa0(%rsp), %ecx
movl %ecx, 0x4c(%rsp)
movl 0x24(%rax), %eax
subl $0x1, %eax
imull 0xa0(%rsp), %eax
movl %eax, 0x48(%rsp)
leaq 0x4c(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x1b290
movq %rax, %rcx
movq 0x28(%rsp), %rax
movl (%rcx), %ecx
movl %ecx, 0x50(%rsp)
testb $0x1, 0x8(%rax)
je 0x1930d
movl $0xffffffff, 0x54(%rsp) # imm = 0xFFFFFFFF
jmp 0x19331
movl $0x1, 0x54(%rsp)
leaq 0x125dc(%rip), %rax     # 0x2b8f8
movl 0x8(%rax), %eax
subl $0x3, %eax
movl %eax, 0x58(%rsp)
movl 0x50(%rsp), %eax
addl $0x2, %eax
movl %eax, 0x50(%rsp)
movl 0x54(%rsp), %eax
movl %eax, 0x10(%rsp)
movl 0x50(%rsp), %eax
movl %eax, 0x14(%rsp)
movq 0xa8(%rsp), %rsi
addq $0x238, %rsi            # imm = 0x238
leaq 0x30(%rsp), %rdi
callq 0x1b2d0
movq 0xa8(%rsp), %rdi
movq (%rdi), %rax
movq 0x18(%rax), %rax
callq *%rax
movl %eax, 0x18(%rsp)
jmp 0x19371
movl 0x18(%rsp), %ecx
movl 0x14(%rsp), %esi
movl 0x10(%rsp), %edi
movl 0x58(%rsp), %r8d
leaq 0x30(%rsp), %rdx
xorl %r9d, %r9d
callq 0x19db0
movl %eax, 0xc(%rsp)
jmp 0x19395
movl 0xc(%rsp), %eax
movl %eax, 0xa4(%rsp)
leaq 0x30(%rsp), %rdi
callq 0x9260
cmpl $-0x1, 0xa4(%rsp)
je 0x19409
movq 0xa8(%rsp), %rax
movq %rax, (%rsp)
movq 0xa8(%rsp), %rdi
addq $0x238, %rdi            # imm = 0x238
movl 0xa4(%rsp), %eax
movl %eax, %esi
callq 0x92e0
movq (%rsp), %rdi
movq (%rax), %rsi
addq $0x8, %rsi
callq 0x90c0
jmp 0x19409
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x60(%rsp)
movl %eax, 0x5c(%rsp)
leaq 0x30(%rsp), %rdi
callq 0x9260
jmp 0x19415
jmp 0x1940b
jmp 0x1940d
addq $0xb8, %rsp
retq
movq 0x60(%rsp), %rdi
callq 0x7c40
nop