// File: /workspace/github_cpp_makefile_star2_O1/Lut99[P]RayTracer/src/lib/ProgressBar.cpp
// Function: std::ProgressBar::draw() const
void ProgressBar::draw() const {
    // If needed, first get the width of the console
    size_t width = this->width;
    if (this->var_width) {
        width = this->resize_to_term_width();
    }
    // The inner width is the same minus to, to account for []
    size_t bar_inner_width = width - 8 - this->left.length() - this->right.length() - 2;
    // Check if this is possible
    if (bar_inner_width < 1) {
        throw runtime_error("Given width " + to_string(width) + " is too small for the progress bar.");
    }

    cout << '\r';
    cout << this->left;
    cout << " [";

    // Draw as many '=' as we have progress
    double ratio = ((double) (this->progress - this->min) / (double) (this->max) - this->min);
    size_t things_to_print = (size_t) (ratio * bar_inner_width);

    for (size_t i = 0; i < things_to_print; i++) {
        cout << '=';
    }
    for (size_t i = things_to_print; i < bar_inner_width; i++) {
        cout << ' ';
    }

    cout << "] ";
    // Draw percentage
    cout << ((int) (ratio * 100)) << "%";

    cout.flush();
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdi, %rbx
cmpb $0x1, 0x6c(%rdi)
jne 0x795d9
movq %rsp, %r14
movl $0x5413, %esi           # imm = 0x5413
movl $0x1, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3a5f0
movzwl 0x2(%r14), %r14d
jmp 0x795dd
movslq 0x60(%rbx), %r14
movq 0x28(%rbx), %rax
leaq -0xa(%r14), %r15
addq 0x48(%rbx), %rax
subq %rax, %r15
je 0x79753
movq %rsp, %rsi
movb $0xd, (%rsi)
movq 0x2b989(%rip), %r14     # 0xa4f88
movl $0x1, %edx
movq %r14, %rdi
callq 0x3a4f0
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
movq %r14, %rdi
callq 0x3a4f0
leaq 0x120c9(%rip), %rsi     # 0x8b6ec
movl $0x2, %edx
movq %r14, %rdi
callq 0x3a4f0
movq 0x8(%rbx), %rax
movq 0x10(%rbx), %rcx
subq %rcx, %rax
cvtsi2sd %rax, %xmm2
cvtsi2sdq 0x18(%rbx), %xmm0
divsd %xmm0, %xmm2
xorps %xmm0, %xmm0
cvtsi2sd %rcx, %xmm0
subsd %xmm0, %xmm2
movq %r15, %xmm0
punpckldq 0x11abd(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x11ac5(%rip), %xmm0    # 0x8b130
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd %xmm2, 0x20(%rsp)
mulsd %xmm2, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0x11c5b(%rip), %xmm1    # 0x8b2f0
cvttsd2si %xmm1, %r12
andq %rcx, %r12
orq %rax, %r12
je 0x796c8
movq 0x2b8df(%rip), %rbx     # 0xa4f88
movq %rsp, %r14
movq %r12, %r13
movb $0x3d, (%rsp)
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3a4f0
decq %r13
jne 0x796af
cmpq %r12, %r15
jbe 0x796f3
movq 0x2b8b4(%rip), %rbx     # 0xa4f88
movq %rsp, %r14
movb $0x20, (%rsp)
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3a4f0
incq %r12
cmpq %r15, %r12
jb 0x796d7
movq 0x2b88e(%rip), %rbx     # 0xa4f88
leaq 0xc480(%rip), %rsi      # 0x85b81
movl $0x2, %edx
movq %rbx, %rdi
callq 0x3a4f0
movsd 0x20(%rsp), %xmm0
mulsd 0xa91c(%rip), %xmm0     # 0x84038
cvttsd2si %xmm0, %esi
movq %rbx, %rdi
callq 0x3a760
leaq 0x11fc0(%rip), %rsi     # 0x8b6ef
movl $0x1, %edx
movq %rax, %rdi
callq 0x3a4f0
movq %rbx, %rdi
callq 0x3a300
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x3a210
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
callq 0x5d53b
leaq 0x11f47(%rip), %rsi     # 0x8b6bb
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x5d118
leaq 0x11f3e(%rip), %rsi     # 0x8b6c8
leaq 0x48(%rsp), %rdi
callq 0x3a800
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x797b5
movups (%rcx), %xmm0
movups %xmm0, (%r15)
jmp 0x797c1
movq %rdx, (%rsp)
movq (%rcx), %rdx
movq %rdx, 0x10(%rsp)
movq 0x8(%rax), %rdx
movq %rsp, %rsi
movq %rdx, 0x8(%rsi)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movb $0x1, %bpl
movq %rbx, %rdi
callq 0x3a6f0
xorl %ebp, %ebp
movq 0x2b801(%rip), %rsi     # 0xa4ff0
movq 0x2b77a(%rip), %rdx     # 0xa4f70
movq %rbx, %rdi
callq 0x3a750
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x7981f
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x7981f
movq %rax, %r14
movb $0x1, %bpl
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x79842
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x79842
movq %rax, %r14
movb $0x1, %bpl
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x79865
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3a470
jmp 0x79865
movq %rax, %r14
movb $0x1, %bpl
testb %bpl, %bpl
je 0x79872
movq %rbx, %rdi
callq 0x3a330
movq %r14, %rdi
callq 0x3a780