// File: fulhax[P]ncpamixer/src/ui/tab.cpp
// Function: Tab::volumeBar(int, int, int, int, float, float)
void Tab::volumeBar(int w, int h, int px, int py, float vol, float peak)
{
    auto dw = static_cast<float>(w);

    int pw = static_cast<int>(dw * peak);
    int vw = static_cast<int>(dw * vol);
    int fw = w - pw;

    unsigned int color;

    if (!ui.hide_top) {
        fillW(w, h, 0, py - 1, ui.bar[BAR_TOP].c_str());
    } else {
        py -= 1;
    }

    for (int i = 0; i < pw; i++) {
        if (i >= vw) {
            color = COLOR_VOLUME_PEAK;
        } else {
            color = getVolumeColor(static_cast<int>(
                static_cast<float>(i) / w * 100.0f
            ));
        }

        wattron(ui.window, COLOR_PAIR(color));
        mvwaddstr(ui.window, py, i, ui.bar[BAR_FG].c_str());
        wattroff(ui.window, COLOR_PAIR(color));
    }

    for (int i = 0; i < fw; i++) {
        color = getBarColor(static_cast<int>(
            static_cast<float>(pw + i) / w * 100.0f
        ));

        wattron(ui.window, COLOR_PAIR(color));
        mvwaddstr(ui.window, py, pw + i, ui.bar[BAR_BG].c_str());
        wattroff(ui.window, COLOR_PAIR(color));
    }

    if (!ui.hide_bottom) {
        fillW(w, h, 0, py + 1, ui.bar[BAR_BOTTOM].c_str());
    }

    if (!ui.hide_indicator) {
        wattron(ui.window, COLOR_PAIR(COLOR_VOLUME_INDICATOR));

        mvwaddstr(
            ui.window,
            py,
            vw - 1,
            ui.bar[BAR_INDICATOR].c_str()
        ); // Mark volume

        wattroff(ui.window, COLOR_PAIR(COLOR_VOLUME_INDICATOR));
    }
}

// Assembly:
subq $0x68, %rsp
movl %edi, 0x64(%rsp)
movl %esi, 0x60(%rsp)
movl %edx, 0x5c(%rsp)
movl %ecx, 0x58(%rsp)
movss %xmm0, 0x54(%rsp)
movss %xmm1, 0x50(%rsp)
cvtsi2ssl 0x64(%rsp), %xmm0
movss %xmm0, 0x4c(%rsp)
movss 0x4c(%rsp), %xmm0
mulss 0x50(%rsp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, 0x48(%rsp)
movss 0x4c(%rsp), %xmm0
mulss 0x54(%rsp), %xmm0
cvttss2si %xmm0, %eax
movl %eax, 0x44(%rsp)
movl 0x64(%rsp), %eax
subl 0x48(%rsp), %eax
movl %eax, 0x40(%rsp)
leaq 0x13791(%rip), %rax     # 0x2b8f8
testb $0x1, 0x101(%rax)
jne 0x181b7
movl 0x64(%rsp), %eax
movl %eax, 0x28(%rsp)
movl 0x60(%rsp), %eax
movl %eax, 0x2c(%rsp)
movl 0x58(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x30(%rsp)
leaq 0x13766(%rip), %rdi     # 0x2b8f8
addq $0x20, %rdi
addq $0x60, %rdi
callq 0x72e0
movl 0x28(%rsp), %edi
movl 0x2c(%rsp), %esi
movl 0x30(%rsp), %ecx
movq %rax, %r8
xorl %edx, %edx
callq 0x1adb0
jmp 0x181c2
movl 0x58(%rsp), %eax
subl $0x1, %eax
movl %eax, 0x58(%rsp)
movl $0x0, 0x38(%rsp)
movl 0x38(%rsp), %eax
cmpl 0x48(%rsp), %eax
jge 0x182bc
movl 0x38(%rsp), %eax
cmpl 0x44(%rsp), %eax
jl 0x181ec
movl $0x7, 0x3c(%rsp)
jmp 0x18215
cvtsi2ssl 0x38(%rsp), %xmm0
cvtsi2ssl 0x64(%rsp), %xmm1
divss %xmm1, %xmm0
movss 0x9770(%rip), %xmm1     # 0x21974
mulss %xmm1, %xmm0
cvttss2si %xmm0, %edi
callq 0x1ae70
movl %eax, 0x3c(%rsp)
leaq 0x136dc(%rip), %rax     # 0x2b8f8
movq 0x10(%rax), %rdi
movl 0x3c(%rsp), %esi
shll $0x8, %esi
andl $0xff00, %esi           # imm = 0xFF00
xorl %eax, %eax
movl %eax, %edx
callq 0x7360
leaq 0x136bb(%rip), %rax     # 0x2b8f8
movq 0x10(%rax), %rdi
movl 0x58(%rsp), %esi
movl 0x38(%rsp), %edx
callq 0x76f0
cmpl $-0x1, %eax
jne 0x18255
jmp 0x1828b
leaq 0x1369c(%rip), %rax     # 0x2b8f8
movq 0x10(%rax), %rax
movq %rax, 0x20(%rsp)
leaq 0x1368c(%rip), %rdi     # 0x2b8f8
addq $0x20, %rdi
addq $0x20, %rdi
callq 0x72e0
movq 0x20(%rsp), %rdi
movq %rax, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x7220
leaq 0x13666(%rip), %rax     # 0x2b8f8
movq 0x10(%rax), %rdi
movl 0x3c(%rsp), %esi
shll $0x8, %esi
andl $0xff00, %esi           # imm = 0xFF00
xorl %eax, %eax
movl %eax, %edx
callq 0x78b0
movl 0x38(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x38(%rsp)
jmp 0x181ca
movl $0x0, 0x34(%rsp)
movl 0x34(%rsp), %eax
cmpl 0x40(%rsp), %eax
jge 0x183a8
movl 0x48(%rsp), %eax
addl 0x34(%rsp), %eax
cvtsi2ss %eax, %xmm0
cvtsi2ssl 0x64(%rsp), %xmm1
divss %xmm1, %xmm0
movss 0x9684(%rip), %xmm1     # 0x21974
mulss %xmm1, %xmm0
cvttss2si %xmm0, %edi
callq 0x1aeb0
movl %eax, 0x3c(%rsp)
leaq 0x135f0(%rip), %rax     # 0x2b8f8
movq 0x10(%rax), %rdi
movl 0x3c(%rsp), %esi
shll $0x8, %esi
andl $0xff00, %esi           # imm = 0xFF00
xorl %eax, %eax
movl %eax, %edx
callq 0x7360
leaq 0x135cf(%rip), %rax     # 0x2b8f8
movq 0x10(%rax), %rdi
movl 0x58(%rsp), %esi
movl 0x48(%rsp), %edx
addl 0x34(%rsp), %edx
callq 0x76f0
cmpl $-0x1, %eax
jne 0x18345
jmp 0x18377
leaq 0x135ac(%rip), %rax     # 0x2b8f8
movq 0x10(%rax), %rax
movq %rax, 0x18(%rsp)
leaq 0x1359c(%rip), %rdi     # 0x2b8f8
addq $0x20, %rdi
callq 0x72e0
movq 0x18(%rsp), %rdi
movq %rax, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x7220
leaq 0x1357a(%rip), %rax     # 0x2b8f8
movq 0x10(%rax), %rdi
movl 0x3c(%rsp), %esi
shll $0x8, %esi
andl $0xff00, %esi           # imm = 0xFF00
xorl %eax, %eax
movl %eax, %edx
callq 0x78b0
movl 0x34(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x34(%rsp)
jmp 0x182c4
leaq 0x13549(%rip), %rax     # 0x2b8f8
testb $0x1, 0x102(%rax)
jne 0x18400
movl 0x64(%rsp), %eax
movl %eax, 0xc(%rsp)
movl 0x60(%rsp), %eax
movl %eax, 0x10(%rsp)
movl 0x58(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
leaq 0x1351e(%rip), %rdi     # 0x2b8f8
addq $0x20, %rdi
addq $0x80, %rdi
callq 0x72e0
movl 0xc(%rsp), %edi
movl 0x10(%rsp), %esi
movl 0x14(%rsp), %ecx
movq %rax, %r8
xorl %edx, %edx
callq 0x1adb0
leaq 0x134f1(%rip), %rax     # 0x2b8f8
testb $0x1, 0x100(%rax)
jne 0x1849c
leaq 0x134dd(%rip), %rax     # 0x2b8f8
movq 0x10(%rax), %rdi
movl $0x800, %esi            # imm = 0x800
xorl %eax, %eax
movl %eax, %edx
callq 0x7360
leaq 0x134c4(%rip), %rax     # 0x2b8f8
movq 0x10(%rax), %rdi
movl 0x58(%rsp), %esi
movl 0x44(%rsp), %edx
subl $0x1, %edx
callq 0x76f0
cmpl $-0x1, %eax
jne 0x1844f
jmp 0x18483
leaq 0x134a2(%rip), %rax     # 0x2b8f8
movq 0x10(%rax), %rax
movq %rax, (%rsp)
leaq 0x13493(%rip), %rdi     # 0x2b8f8
addq $0x20, %rdi
addq $0x40, %rdi
callq 0x72e0
movq (%rsp), %rdi
movq %rax, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x7220
leaq 0x1346e(%rip), %rax     # 0x2b8f8
movq 0x10(%rax), %rdi
movl $0x800, %esi            # imm = 0x800
xorl %eax, %eax
movl %eax, %edx
callq 0x78b0
addq $0x68, %rsp
retq
nopw %cs:(%rax,%rax)