// File: /workspace/github_cpp_makefile_star2_O3/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), %r13
testq %r13, %r13
je 0xdc8a
movq %rdi, %rbx
leaq 0xb38a(%rip), %rdx      # 0x187f8
movzbl 0x101(%rdx), %eax
andl $0x1, %eax
xorl $0x5, %eax
movzbl 0x102(%rdx), %ecx
subl %ecx, %eax
cmpb $0x0, 0x8(%rdi)
movl $0x5, %ecx
cmovnel %eax, %ecx
movl 0xc(%rdx), %eax
addl $-0x2, %eax
cltd
movl %ecx, 0x84(%rsp)
idivl %ecx
movl %eax, 0x24(%rdi)
movq 0x18(%r13), %r14
addq $0x8, %r13
cmpq %r13, %r14
je 0xdc8a
leaq 0x50(%rsp), %r12
movl $0xe0, %eax
addq 0xab03(%rip), %rax      # 0x17fc8
movq %rax, 0xb0(%rsp)
movq $0x0, 0x8(%rsp)
xorl %r15d, %r15d
movl $0x0, 0x18(%rsp)
movq $0x0, 0xa8(%rsp)
movq %r13, 0xb8(%rsp)
movl 0x20(%rbx), %ecx
movl 0x24(%rbx), %eax
subl %eax, %ecx
movb $0x1, %bpl
cmpl %ecx, %r15d
jle 0xd56f
cmpl %eax, 0x18(%rsp)
jge 0xdc06
movl %r15d, 0x1c(%rsp)
movq 0x28(%r14), %rax
movl 0x214(%rax), %ecx
cvtsi2ss %rcx, %xmm0
divss 0x53cd(%rip), %xmm0     # 0x128f8
movss %xmm0, 0x10(%rsp)
cmpb $0x1, 0x8(%rbx)
jne 0xd57e
leaq 0xb2ba(%rip), %rdx      # 0x187f8
movl 0x8(%rdx), %edi
movl 0xc(%rdx), %esi
movq 0x8(%rsp), %rcx
addl $0x3, %ecx
cmpb $0x1, 0x103(%rdx)
leaq 0xe0(%rsp), %r15
jne 0xd62a
movss 0x10(%rsp), %xmm0
movaps %xmm0, %xmm1
jmp 0xd638
movb $0x1, %al
movq %rax, 0xa8(%rsp)
jmp 0xdbed
movl 0x20(%r14), %eax
xorl %esi, %esi
cmpl 0xc(%rbx), %eax
sete %sil
leaq 0xb266(%rip), %r13      # 0x187f8
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), %r15
je 0xd616
movq 0x10(%r13), %rdi
movq 0x8(%rsp), %rax
leal 0x3(%rax), %esi
movl $0x3, %edx
callq 0x65f0
cmpl $-0x1, %eax
je 0xd5f8
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 0x8(%rsp), %rax
leal 0x2(%rax), %ecx
movl $0x2, %esi
movl $0x1, %edx
callq 0xdf76
movl 0x20(%r14), %eax
movq 0x10(%r13), %rdi
cmpl 0xc(%rbx), %eax
jne 0xd63f
movl $0xa00, %esi            # imm = 0xA00
jmp 0xd644
movss 0x228(%rax), %xmm1
movss 0x10(%rsp), %xmm0
callq 0xdd4c
jmp 0xd64b
movl $0x900, %esi            # imm = 0x900
xorl %edx, %edx
callq 0x6750
xorl %esi, %esi
movl 0x1c(%rsp), %eax
cmpl 0x20(%rbx), %eax
sete %sil
leaq 0xb199(%rip), %rax      # 0x187f8
movq 0x10(%rax), %rdi
shll $0x8, %esi
addl $0x900, %esi            # imm = 0x900
xorl %edx, %edx
callq 0x62e0
movl $0xff, %edx
movq %r15, %rdi
xorl %esi, %esi
callq 0x6350
movq %r12, 0x40(%rsp)
movw $0x0, 0x50(%rsp)
movq $0x1, 0x48(%rsp)
movq 0x18(%rbx), %r12
movq 0x28(%r14), %rdi
testq %r12, %r12
je 0xd743
movq (%rdi), %rax
callq *0x18(%rax)
movq 0x10(%r12), %rcx
addq $0x8, %r12
testq %rcx, %rcx
je 0xd6e2
movq %r12, %rdx
xorl %esi, %esi
cmpl %eax, 0x20(%rcx)
setb %sil
cmovaeq %rcx, %rdx
movq 0x10(%rcx,%rsi,8), %rcx
testq %rcx, %rcx
jne 0xd6bf
cmpq %r12, %rdx
je 0xd6e2
cmpl 0x20(%rdx), %eax
cmovaeq %rdx, %r12
movq 0x18(%rbx), %rax
addq $0x8, %rax
cmpq %rax, %r12
je 0xd7cd
movq 0x28(%r12), %r13
addq $0x10, %r13
movq %r13, %rdi
callq 0x62b0
notl %eax
leaq 0xb0eb(%rip), %r12      # 0x187f8
addl 0x8(%r12), %eax
movq 0x10(%r12), %rdi
movq 0x8(%rsp), %rcx
leal 0x1(%rcx), %esi
movl %eax, %edx
callq 0x65f0
cmpl $-0x1, %eax
je 0xd7c0
movq 0x10(%r12), %rdi
movq %r13, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6200
jmp 0xd7c0
movq 0x230(%rdi), %rdi
xorl %r13d, %r13d
testq %rdi, %rdi
je 0xd7d0
cmpb $0x1, 0x8(%rbx)
leaq 0xb09b(%rip), %r12      # 0x187f8
jne 0xd7d0
addq $0x107, %rdi            # imm = 0x107
callq 0x62b0
notl %eax
addl 0x8(%r12), %eax
movq 0x10(%r12), %rdi
movq 0x8(%rsp), %rcx
leal 0x1(%rcx), %esi
movl %eax, %edx
callq 0x65f0
cmpl $-0x1, %eax
je 0xd7ad
movq 0x10(%r12), %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), %r13
movl $0x107, %eax            # imm = 0x107
addq %rax, %r13
movq %r13, %rdi
callq 0x62b0
movq %rax, %r13
jmp 0xd7d0
xorl %r13d, %r13d
movq 0x28(%r14), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
testq %rax, %rax
je 0xd847
movq 0x28(%r14), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
cmpb $0x0, (%rax)
je 0xd847
movq 0x28(%r14), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
leaq 0xc0(%rsp), %r15
movq %r15, %rdi
movq %rax, %rsi
leaq 0x17(%rsp), %rdx
callq 0xa8ae
leaq 0x70(%rsp), %r12
movq %r15, %rdi
leaq 0x510d(%rip), %rsi      # 0x1292c
callq 0x6b30
movq %r12, 0x60(%rsp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0xd882
movq %rdx, 0x60(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x70(%rsp)
jmp 0xd88a
movq 0x28(%r14), %rbp
addq $0x10, %rbp
movq 0x48(%rsp), %r12
movq %rbp, %rdi
callq 0x62b0
leaq 0x40(%rsp), %rdi
xorl %esi, %esi
movq %r12, %rdx
leaq 0xaf8b(%rip), %r12      # 0x187f8
movq %rbp, %rcx
leaq 0x20(%rsp), %rbp
movq %rax, %r8
callq 0x68c0
jmp 0xda31
movups (%rcx), %xmm0
movups %xmm0, (%r12)
movq 0x8(%rax), %rdx
movq %rdx, 0x68(%rsp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq 0x28(%r14), %r12
leaq 0x10(%r12), %rbp
leaq 0x98(%rsp), %rax
movq %rax, 0x88(%rsp)
movq %rbp, %rdi
callq 0x62b0
leaq (%r12,%rax), %rdx
addq $0x10, %rdx
leaq 0x88(%rsp), %rdi
movq %rbp, %rsi
callq 0x73f0
movq 0x60(%rsp), %rcx
movl $0xf, %edi
leaq 0x70(%rsp), %rax
cmpq %rax, %rcx
je 0xd8f4
movq 0x70(%rsp), %rdi
movq 0x68(%rsp), %r8
movq 0x88(%rsp), %rsi
movq 0x90(%rsp), %rdx
leaq (%rdx,%r8), %rax
cmpq %rdi, %rax
leaq 0xaee1(%rip), %r12      # 0x187f8
leaq 0x20(%rsp), %rbp
jbe 0xd93d
movl $0xf, %edi
leaq 0x98(%rsp), %r9
cmpq %r9, %rsi
je 0xd938
movq 0x98(%rsp), %rdi
cmpq %rdi, %rax
jbe 0xd949
leaq 0x60(%rsp), %rdi
callq 0x61e0
jmp 0xd95a
leaq 0x88(%rsp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x6660
leaq 0x30(%rsp), %rsi
movq %rsi, 0x20(%rsp)
movq (%rax), %rdx
leaq 0x10(%rax), %rcx
cmpq %rcx, %rdx
je 0xd97f
movq %rdx, 0x20(%rsp)
movq (%rcx), %rdx
movq %rdx, 0x30(%rsp)
jmp 0xd985
movups (%rcx), %xmm0
movups %xmm0, (%rsi)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, 0x28(%rsp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x40(%rsp), %rdi
movq %rbp, %rsi
callq 0x6710
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0xd9cb
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x65c0
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0xd9f0
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x65c0
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0xda0c
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x65c0
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0xda31
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x65c0
movq 0x28(%r14), %rax
cmpb $0x1, 0x20e(%rax)
jne 0xda80
movq %rbp, %rdi
movq 0xb0(%rsp), %rsi
movq %rbp, %r15
leaq 0x40(%rsp), %rbp
movq %rbp, %rdx
callq 0xf89b
movq %rbp, %rdi
movq %r15, %rsi
callq 0x6710
movq 0x20(%rsp), %rdi
leaq 0x30(%rsp), %rax
cmpq %rax, %rdi
je 0xda80
movq 0x30(%rsp), %rsi
incq %rsi
callq 0x65c0
incl 0x18(%rsp)
movss 0x10(%rsp), %xmm0
mulss 0x4e6a(%rip), %xmm0     # 0x128fc
addss 0x4e66(%rip), %xmm0     # 0x12900
cvttss2si %xmm0, %ebp
leaq 0x3a3f(%rip), %r8       # 0x114e4
cmpb $0x1, 0x8(%rbx)
jne 0xdad6
movq 0x28(%r14), %rax
movq 0x40(%rsp), %rcx
cmpb $0x1, 0x218(%rax)
jne 0xdafb
movl $0xff, %esi
leaq 0xe0(%rsp), %r15
movq %r15, %rdi
leaq 0x4e5b(%rip), %rdx      # 0x1292f
jmp 0xdaf2
movq 0x40(%rsp), %rcx
movl $0xff, %esi
leaq 0xe0(%rsp), %r15
movq %r15, %rdi
leaq 0x4e5a(%rip), %rdx      # 0x1294c
xorl %eax, %eax
callq 0x6990
jmp 0xdb1c
movl $0xff, %esi
leaq 0xe0(%rsp), %r15
movq %r15, %rdi
leaq 0x4e2e(%rip), %rdx      # 0x12940
movl %ebp, %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
cmpl 0x8(%r12), %eax
jle 0xdb5e
movq 0x48(%rsp), %rsi
testq %rsi, %rsi
je 0xdb5e
decq %rsi
leaq 0x40(%rsp), %rdi
xorl %edx, %edx
callq 0x61d0
leaq 0x4de3(%rip), %r8       # 0x1293c
jmp 0xdaa5
movq 0x10(%r12), %rdi
movq 0x8(%rsp), %rax
leal 0x1(%rax), %esi
movl $0x1, %edx
callq 0x65f0
movl 0x1c(%rsp), %r15d
cmpl $-0x1, %eax
je 0xdb96
movq 0x10(%r12), %rdi
leaq 0xe0(%rsp), %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6200
xorl %esi, %esi
cmpl 0x20(%rbx), %r15d
sete %sil
movq 0x10(%r12), %rdi
shll $0x8, %esi
addl $0x900, %esi            # imm = 0x900
xorl %edx, %edx
callq 0x6750
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %r12
cmpq %r12, %rdi
movq 0xb8(%rsp), %r13
movb $0x1, %bpl
je 0xdbdc
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x65c0
movq 0x8(%rsp), %rax
addl 0x84(%rsp), %eax
movq %rax, 0x8(%rsp)
incl %r15d
movq %r14, %rdi
callq 0x6440
movq %rax, %r14
cmpq %r13, %rax
jne 0xd4f5
jmp 0xdc08
xorl %ebp, %ebp
testb $0x1, 0xa8(%rsp)
leaq 0xabe1(%rip), %rbx      # 0x187f8
je 0xdc4d
movq 0x10(%rbx), %rdi
movl 0x8(%rbx), %eax
movl %eax, %edx
shrl $0x1f, %edx
addl %eax, %edx
sarl %edx
addl $-0x4, %edx
xorl %esi, %esi
callq 0x65f0
cmpl $-0x1, %eax
je 0xdc4d
movq 0x10(%rbx), %rdi
leaq 0x4d0e(%rip), %rsi      # 0x12951
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6200
testb %bpl, %bpl
jne 0xdc8a
movq 0x10(%rbx), %rdi
movl 0x8(%rbx), %eax
movl 0xc(%rbx), %esi
addl $-0x2, %esi
movl %eax, %edx
shrl $0x1f, %edx
addl %eax, %edx
sarl %edx
addl $-0x4, %edx
callq 0x65f0
cmpl $-0x1, %eax
je 0xdc8a
movq 0x10(%rbx), %rdi
leaq 0x4cde(%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 0xdd24
movq %rax, %rbx
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0xdcce
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x65c0
jmp 0xdcce
movq %rax, %rbx
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0xdcef
movq 0x70(%rsp), %rsi
incq %rsi
callq 0x65c0
jmp 0xdcef
movq %rax, %rbx
movq 0xc0(%rsp), %rdi
leaq 0xd0(%rsp), %rax
cmpq %rax, %rdi
je 0xdd27
movq 0xd0(%rsp), %rsi
incq %rsi
callq 0x65c0
jmp 0xdd27
jmp 0xdd24
jmp 0xdd24
jmp 0xdd24
jmp 0xdd24
jmp 0xdd24
jmp 0xdd24
jmp 0xdd24
movq %rax, %rbx
movq 0x40(%rsp), %rdi
leaq 0x50(%rsp), %rax
cmpq %rax, %rdi
je 0xdd43
movq 0x50(%rsp), %rsi
incq %rsi
callq 0x65c0
movq %rbx, %rdi
callq 0x6a80
nop