// File: /workspace/github_cpp_makefile_star2_O1/fulhax[P]ncpamixer/src/ui/tab.cpp
// Function: Tab::draw()
void Tab::draw()
{
    if (object == nullptr) {
        return;
    }

    int baseY = 0;
    int current_block = 0;
    int BLOCK_SIZE = getBlockSize();

    total_blocks = (ui.height - 2) / BLOCK_SIZE;
    int blocks_drawn = 0;

    bool more_up = false;
    bool more_down = false;

    for (auto &i : *object) {
        if (current_block <= selected_block - total_blocks) {
            current_block++;
            more_up = true;
            continue;
        }

        if (blocks_drawn >= total_blocks) {
            more_down = true;
            break;
        }

        blocks_drawn++;

        float perc = static_cast<float>(i.second->volume) /
                     (PA_VOLUME_NORM * 1.5f);

        if (has_volume) {
            if (ui.static_bar) {
                volumeBar(ui.width, ui.height, 0, baseY + 3, perc, perc);
            } else {
                volumeBar(ui.width, ui.height, 0, baseY + 3, perc, i.second->peak);
            }
        } else { // Configuration
            if (i.first == selected_index) {
                wattron(ui.window, COLOR_PAIR(COLOR_SELECTED));
            } else {
                wattron(ui.window, COLOR_PAIR(COLOR_DEFAULT));
            }

            if (i.second->active_attribute != nullptr) {
                mvwaddstr(
                    ui.window,
                    baseY + 3,
                    3,
                    i.second->active_attribute->description
                );
                borderBox(ui.width - 2, 2, 1, baseY + 2);
            }

            if (i.first == selected_index) {
                wattroff(ui.window, COLOR_PAIR(COLOR_SELECTED));
            } else {
                wattroff(ui.window, COLOR_PAIR(COLOR_DEFAULT));
            }
        }

        if (current_block == selected_block) {
            wattron(ui.window, COLOR_PAIR(COLOR_SELECTED));
        } else {
            wattron(ui.window, COLOR_PAIR(COLOR_DEFAULT));
        }

        char label[255] = {0};
        std::string app = {0};

        int toggle_len = 0;

        if (toggle != nullptr) {
            auto rel = toggle->find(i.second->getRelation());

            if (rel != toggle->end()) {
                char *name = rel->second->name;

                if (name != nullptr) {
                    unsigned int len = strlen(name);
                    unsigned int sink_pos = ui.width - 1 - len;

                    mvwaddstr(
                        ui.window,
                        baseY + 1,
                        sink_pos,
                        name
                    );

                    toggle_len += strlen(name);
                }
            }
        } else {
            if (i.second->active_attribute != nullptr && has_volume) {
                unsigned int len = strlen(
                                       i.second->active_attribute->description
                                   );

                unsigned int sink_pos = ui.width - 1 - len;

                mvwaddstr(
                    ui.window,
                    baseY + 1,
                    sink_pos,
                    i.second->active_attribute->description
                );

                toggle_len += strlen(i.second->active_attribute->description);
            }
        }

        const char *app_name = i.second->getAppName();

        if (app_name != nullptr && strlen(i.second->getAppName()) > 0) {
            app = std::string(i.second->getAppName()) + ": " +
                  std::string(i.second->name);
        } else {
            app = i.second->name;
        }

        if (i.second->is_default) {
            app = ui.indicator + app;
        }

        bool dots = false;

        while (1) {
            if (has_volume) {
                if (i.second->mute) {
                    snprintf(
                        label,
                        sizeof(label),
                        "%s%s (muted)",
                        app.c_str(),
                        (dots) ? "..." : ""
                    );
                } else {
                    snprintf(
                        label,
                        sizeof(label),
                        "%s%s (%d%%)",
                        app.c_str(),
                        (dots) ? "..." : "",
                        static_cast<int>(perc * (1.5f * 100.f) + 0.1f)
                    );
                }
            } else {
                snprintf(
                    label,
                    sizeof(label),
                    "%s%s",
                    app.c_str(),
                    (dots) ? "..." : ""
                );
            }

            int output_len = strlen(label);
            int volume_len = (has_volume) ? 4 : 1;

            if ((output_len + toggle_len + volume_len) > ui.width) {
                if (app.length() > 0) {
                    app.resize(app.length() - 1);
                } else {
                    break;
                }

                dots = true;
            } else {
                break;
            }
        }

        mvwaddstr(ui.window, baseY + 1, 1, label);

        if (current_block == selected_block) {
            wattroff(ui.window, COLOR_PAIR(COLOR_SELECTED));
        } else {
            wattroff(ui.window, COLOR_PAIR(COLOR_DEFAULT));
        }

        baseY += BLOCK_SIZE;
        current_block++;
    }

    if (more_up) {
        mvwaddstr(
            ui.window,
            0,
            (ui.width / 2) - 4,
            "\u2191\u2191\u2191\u2191"
        );
    }

    if (more_down) {
        mvwaddstr(
            ui.window,
            ui.height - 2,
            (ui.width / 2) - 4,
            "\u2193\u2193\u2193\u2193"
        );
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1e8, %rsp            # imm = 0x1E8
movq 0x10(%rdi), %r12
testq %r12, %r12
je 0xdd3e
movq %rdi, %rbx
leaq 0xb302(%rip), %r13      # 0x187f8
movzbl 0x101(%r13), %eax
andl $0x1, %eax
xorl $0x5, %eax
movzbl 0x102(%r13), %ecx
subl %ecx, %eax
cmpb $0x0, 0x8(%rdi)
movl $0x5, %ecx
cmovnel %eax, %ecx
movl 0xc(%r13), %eax
addl $-0x2, %eax
cltd
movl %ecx, 0x5c(%rsp)
idivl %ecx
movl %eax, 0x24(%rdi)
movq 0x18(%r12), %r14
addq $0x8, %r12
cmpq %r12, %r14
je 0xdcc2
leaq 0x28(%rsp), %r15
leaq 0x90(%rsp), %rbp
movl $0xe0, %eax
addq 0xaa72(%rip), %rax      # 0x17fc8
movq %rax, 0xb0(%rsp)
movq $0x0, (%rsp)
xorl %edx, %edx
movl $0x0, 0x14(%rsp)
movq $0x0, 0xa8(%rsp)
movq $0x0, 0xa0(%rsp)
movq %r12, 0xb8(%rsp)
movl 0x20(%rbx), %ecx
movl 0x24(%rbx), %eax
subl %eax, %ecx
cmpl %ecx, %edx
jle 0xd5fc
cmpl %eax, 0x14(%rsp)
jge 0xd612
movq 0x28(%r14), %rax
movl 0x214(%rax), %ecx
cvtsi2ss %rcx, %xmm0
divss 0x533f(%rip), %xmm0     # 0x128f8
movss %xmm0, 0x8(%rsp)
cmpb $0x1, 0x8(%rbx)
movl %edx, 0xc(%rsp)
jne 0xd626
movl 0x8(%r13), %edi
movl 0xc(%r13), %esi
movq (%rsp), %rcx
addl $0x3, %ecx
cmpb $0x1, 0x103(%r13)
leaq 0xe0(%rsp), %r12
jne 0xd6c9
movss 0x8(%rsp), %xmm0
movaps %xmm0, %xmm1
jmp 0xd6d7
incl %edx
movb $0x1, %al
movq %rax, 0xa8(%rsp)
movl $0x3, %eax
jmp 0xdc8d
movb $0x1, %al
movq %rax, 0xa0(%rsp)
movl $0x2, %eax
jmp 0xdc8d
movl 0x20(%r14), %eax
xorl %esi, %esi
cmpl 0xc(%rbx), %eax
sete %sil
movq 0x10(%r13), %rdi
shll $0x8, %esi
addl $0x900, %esi            # imm = 0x900
xorl %edx, %edx
callq 0x62e0
movq 0x28(%r14), %rax
cmpq $0x0, 0x230(%rax)
leaq 0xe0(%rsp), %r12
je 0xd6b5
movq 0x10(%r13), %rdi
movq (%rsp), %rax
leal 0x3(%rax), %esi
movl $0x3, %edx
callq 0x65f0
cmpl $-0x1, %eax
je 0xd698
movq 0x10(%r13), %rdi
movq 0x28(%r14), %rax
movq 0x230(%rax), %rsi
movl $0x107, %eax            # imm = 0x107
addq %rax, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6200
movl 0x8(%r13), %edi
addl $-0x2, %edi
movq (%rsp), %rax
leal 0x2(%rax), %ecx
movl $0x2, %esi
movl $0x1, %edx
callq 0xe02a
movl 0x20(%r14), %eax
movq 0x10(%r13), %rdi
cmpl 0xc(%rbx), %eax
jne 0xd6de
movl $0xa00, %esi            # imm = 0xA00
jmp 0xd6e3
movss 0x228(%rax), %xmm1
movss 0x8(%rsp), %xmm0
callq 0xde00
jmp 0xd6ea
movl $0x900, %esi            # imm = 0x900
xorl %edx, %edx
callq 0x6750
xorl %esi, %esi
movl 0xc(%rsp), %eax
cmpl 0x20(%rbx), %eax
sete %sil
movq 0x10(%r13), %rdi
shll $0x8, %esi
addl $0x900, %esi            # imm = 0x900
xorl %edx, %edx
callq 0x62e0
movl $0xff, %edx
movq %r12, %rdi
xorl %esi, %esi
callq 0x6350
movq %r15, 0x18(%rsp)
movw $0x0, 0x28(%rsp)
movq $0x1, 0x20(%rsp)
movq 0x18(%rbx), %r12
movq 0x28(%r14), %rdi
testq %r12, %r12
je 0xd7d3
movq (%rdi), %rax
callq *0x18(%rax)
movq 0x10(%r12), %rdx
addq $0x8, %r12
movq %r12, %rcx
testq %rdx, %rdx
je 0xd771
movq %r12, %rcx
xorl %esi, %esi
cmpl %eax, 0x20(%rdx)
setb %sil
cmovaeq %rdx, %rcx
movq 0x10(%rdx,%rsi,8), %rdx
testq %rdx, %rdx
jne 0xd75a
cmpq %r12, %rcx
je 0xd77d
cmpl 0x20(%rcx), %eax
cmovaeq %rcx, %r12
movq 0x18(%rbx), %rax
addq $0x8, %rax
cmpq %rax, %r12
je 0xd859
movq 0x28(%r12), %r12
addq $0x10, %r12
movq %r12, %rdi
callq 0x62b0
notl %eax
addl 0x8(%r13), %eax
movq 0x10(%r13), %rdi
movq (%rsp), %rcx
leal 0x1(%rcx), %esi
movl %eax, %edx
callq 0x65f0
cmpl $-0x1, %eax
je 0xd84c
movq 0x10(%r13), %rdi
movq %r12, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6200
jmp 0xd84c
movq 0x230(%rdi), %rdi
xorl %r13d, %r13d
testq %rdi, %rdi
je 0xd85c
cmpb $0x1, 0x8(%rbx)
jne 0xd85c
addq $0x107, %rdi            # imm = 0x107
callq 0x62b0
notl %eax
leaq 0xaffb(%rip), %r15      # 0x187f8
addl 0x8(%r15), %eax
movq 0x10(%r15), %rdi
movq (%rsp), %rcx
leal 0x1(%rcx), %esi
movl %eax, %edx
callq 0x65f0
cmpl $-0x1, %eax
je 0xd839
movq 0x10(%r15), %rdi
movq 0x28(%r14), %rax
movq 0x230(%rax), %rsi
movl $0x107, %eax            # imm = 0x107
addq %rax, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6200
movq 0x28(%r14), %rax
movq 0x230(%rax), %r12
movl $0x107, %eax            # imm = 0x107
addq %rax, %r12
movq %r12, %rdi
callq 0x62b0
movq %rax, %r13
jmp 0xd85c
xorl %r13d, %r13d
movq 0x28(%r14), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
testq %rax, %rax
je 0xd8d7
movq 0x28(%r14), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
cmpb $0x0, (%rax)
je 0xd8d7
movq 0x28(%r14), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
leaq 0xc0(%rsp), %r15
movq %r15, %rdi
movq %rax, %rsi
leaq 0x13(%rsp), %rdx
callq 0xa912
movq %r15, %rdi
leaq 0x5086(%rip), %rsi      # 0x1292c
callq 0x6b30
movq %rbp, 0x80(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xd90b
movq %rdx, 0x80(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x90(%rsp)
jmp 0xd912
movq 0x28(%r14), %r12
addq $0x10, %r12
movq 0x20(%rsp), %rbp
movq %r12, %rdi
callq 0x62b0
leaq 0x18(%rsp), %rdi
xorl %esi, %esi
movq %rbp, %rdx
movq %r12, %rcx
leaq 0x48(%rsp), %r15
movq %rax, %r8
callq 0x68c0
jmp 0xda96
movups (%rcx), %xmm0
movups %xmm0, (%rbp)
movq 0x8(%rax), %rdx
movq %rdx, 0x88(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x28(%r14), %r15
leaq 0x10(%r15), %r12
leaq 0x70(%rsp), %rax
movq %rax, 0x60(%rsp)
movq %r12, %rdi
callq 0x62b0
leaq (%r15,%rax), %rdx
addq $0x10, %rdx
leaq 0x60(%rsp), %rdi
movq %r12, %rsi
callq 0x73f0
movq 0x80(%rsp), %rcx
movl $0xf, %esi
cmpq %rbp, %rcx
leaq 0x48(%rsp), %r15
je 0xd97b
movq 0x90(%rsp), %rsi
movq 0x88(%rsp), %r8
movq 0x68(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rsi, %rax
jbe 0xd9ac
movl $0xf, %esi
leaq 0x70(%rsp), %rdi
cmpq %rdi, 0x60(%rsp)
je 0xd9a7
movq 0x70(%rsp), %rsi
cmpq %rsi, %rax
jbe 0xd9c0
movq 0x60(%rsp), %rsi
leaq 0x80(%rsp), %rdi
callq 0x61e0
jmp 0xd9ce
leaq 0x60(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x6660
movq %r15, 0x38(%rsp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0xd9ee
movq %rdx, 0x38(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x48(%rsp)
jmp 0xd9f5
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x40(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x18(%rsp), %rdi
leaq 0x38(%rsp), %rsi
callq 0x6710
movq 0x38(%rsp), %rdi
cmpq %r15, %rdi
je 0xda38
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x65c0
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0xda54
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x65c0
movq 0x80(%rsp), %rdi
cmpq %rbp, %rdi
je 0xda71
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x65c0
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0xda96
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x65c0
movq 0x28(%r14), %rax
cmpb $0x1, 0x20e(%rax)
jne 0xdae2
leaq 0x38(%rsp), %rbp
movq %rbp, %rdi
movq 0xb0(%rsp), %rsi
leaq 0x18(%rsp), %r12
movq %r12, %rdx
callq 0xf9f3
movq %r12, %rdi
movq %rbp, %rsi
callq 0x6710
movq 0x38(%rsp), %rdi
cmpq %r15, %rdi
je 0xdae2
movq 0x48(%rsp), %rsi
incq %rsi
callq 0x65c0
incl 0x14(%rsp)
movss 0x8(%rsp), %xmm0
mulss 0x4e08(%rip), %xmm0     # 0x128fc
addss 0x4e04(%rip), %xmm0     # 0x12900
cvttss2si %xmm0, %r12d
xorl %ebp, %ebp
cmpb $0x1, 0x8(%rbx)
jne 0xdb4a
movq 0x28(%r14), %rax
movq 0x18(%rsp), %rcx
testb $0x1, %bpl
leaq 0x39c7(%rip), %r8       # 0x114e4
leaq 0x4e18(%rip), %rdx      # 0x1293c
cmovneq %rdx, %r8
cmpb $0x1, 0x218(%rax)
jne 0xdb85
movl $0xff, %esi
leaq 0xe0(%rsp), %r15
movq %r15, %rdi
leaq 0x4de7(%rip), %rdx      # 0x1292f
jmp 0xdb7c
movq 0x18(%rsp), %rcx
testb $0x1, %bpl
leaq 0x398a(%rip), %r8       # 0x114e4
leaq 0x4ddb(%rip), %rax      # 0x1293c
cmovneq %rax, %r8
movl $0xff, %esi
leaq 0xe0(%rsp), %r15
movq %r15, %rdi
leaq 0x4dd0(%rip), %rdx      # 0x1294c
xorl %eax, %eax
callq 0x6990
jmp 0xdba6
movl $0xff, %esi
leaq 0xe0(%rsp), %r15
movq %r15, %rdi
leaq 0x4da4(%rip), %rdx      # 0x12940
movl %r12d, %r9d
xorl %eax, %eax
callq 0x6990
movq %r15, %rdi
callq 0x62b0
movzbl 0x8(%rbx), %ecx
leal (%rcx,%rcx,2), %ecx
addl %r13d, %eax
addl %ecx, %eax
incl %eax
leaq 0xac35(%rip), %rcx      # 0x187f8
cmpl 0x8(%rcx), %eax
jle 0xdbe9
movq 0x20(%rsp), %rsi
testq %rsi, %rsi
je 0xdbe9
decq %rsi
movb $0x1, %r15b
leaq 0x18(%rsp), %rdi
xorl %edx, %edx
callq 0x61d0
movb $0x1, %bpl
jmp 0xdbec
xorl %r15d, %r15d
testb %r15b, %r15b
jne 0xdb03
leaq 0xabfc(%rip), %r13      # 0x187f8
movq 0x10(%r13), %rdi
movq (%rsp), %rax
leal 0x1(%rax), %esi
movl $0x1, %edx
callq 0x65f0
leaq 0x90(%rsp), %rbp
cmpl $-0x1, %eax
je 0xdc34
movq 0x10(%r13), %rdi
leaq 0xe0(%rsp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6200
xorl %esi, %esi
movl 0xc(%rsp), %eax
cmpl 0x20(%rbx), %eax
sete %sil
movq 0x10(%r13), %rdi
shll $0x8, %esi
addl $0x900, %esi            # imm = 0x900
xorl %edx, %edx
callq 0x6750
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %r15
cmpq %r15, %rdi
movq 0xb8(%rsp), %r12
je 0xdc79
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x65c0
movq (%rsp), %rax
addl 0x5c(%rsp), %eax
movq %rax, (%rsp)
movl 0xc(%rsp), %edx
incl %edx
xorl %eax, %eax
cmpl $0x3, %eax
je 0xdc96
testl %eax, %eax
jne 0xdcb0
movq %r14, %rdi
movl %edx, %r14d
callq 0x6440
movl %r14d, %edx
movq %rax, %r14
cmpq %r12, %rax
jne 0xd590
movq 0xa0(%rsp), %rbx
movq 0xa8(%rsp), %rax
jmp 0xdcc6
xorl %ebx, %ebx
xorl %eax, %eax
testb $0x1, %al
je 0xdcff
movq 0x10(%r13), %rdi
movl 0x8(%r13), %eax
movl %eax, %edx
shrl $0x1f, %edx
addl %eax, %edx
sarl %edx
addl $-0x4, %edx
xorl %esi, %esi
callq 0x65f0
cmpl $-0x1, %eax
je 0xdcff
movq 0x10(%r13), %rdi
leaq 0x4c5c(%rip), %rsi      # 0x12951
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6200
testb $0x1, %bl
je 0xdd3e
movq 0x10(%r13), %rdi
movl 0x8(%r13), %eax
movl 0xc(%r13), %esi
addl $-0x2, %esi
movl %eax, %edx
shrl $0x1f, %edx
addl %eax, %edx
sarl %edx
addl $-0x4, %edx
callq 0x65f0
cmpl $-0x1, %eax
je 0xdd3e
movq 0x10(%r13), %rdi
leaq 0x4c2a(%rip), %rsi      # 0x1295e
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6200
addq $0x1e8, %rsp            # imm = 0x1E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xddd8
movq %rax, %rbx
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0xdd79
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x65c0
jmp 0xdd79
movq %rax, %rbx
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0xdda3
movq 0x90(%rsp), %rsi
incq %rsi
callq 0x65c0
jmp 0xdda3
movq %rax, %rbx
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0xdddb
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x65c0
jmp 0xdddb
jmp 0xddd8
jmp 0xddd8
jmp 0xddd8
jmp 0xddd8
jmp 0xddd8
jmp 0xddd8
jmp 0xddd8
movq %rax, %rbx
movq 0x18(%rsp), %rdi
leaq 0x28(%rsp), %rax
cmpq %rax, %rdi
je 0xddf7
movq 0x28(%rsp), %rsi
incq %rsi
callq 0x65c0
movq %rbx, %rdi
callq 0x6a80
nop