// File: /workspace/github_cpp_makefile_star2_O3/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 0x78bf9
movq %rsp, %r14
movl $0x5413, %esi           # imm = 0x5413
movl $0x1, %edi
movq %r14, %rdx
xorl %eax, %eax
callq 0x3a600
movzwl 0x2(%r14), %r14d
jmp 0x78bfd
movslq 0x60(%rbx), %r14
movq 0x28(%rbx), %rax
leaq -0xa(%r14), %r15
addq 0x48(%rbx), %rax
subq %rax, %r15
je 0x78d73
movq %rsp, %rsi
movb $0xd, (%rsi)
movq 0x2b361(%rip), %r14     # 0xa3f80
movl $0x1, %edx
movq %r14, %rdi
callq 0x3a500
movq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rdx
movq %r14, %rdi
callq 0x3a500
leaq 0x11ac9(%rip), %rsi     # 0x8a70c
movl $0x2, %edx
movq %r14, %rdi
callq 0x3a500
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 0x114bd(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0x114c5(%rip), %xmm0    # 0x8a150
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 0x1165b(%rip), %xmm1    # 0x8a310
cvttsd2si %xmm1, %r12
andq %rcx, %r12
orq %rax, %r12
je 0x78ce8
movq 0x2b2b7(%rip), %rbx     # 0xa3f80
movq %rsp, %r14
movq %r12, %r13
movb $0x3d, (%rsp)
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3a500
decq %r13
jne 0x78ccf
cmpq %r12, %r15
jbe 0x78d13
movq 0x2b28c(%rip), %rbx     # 0xa3f80
movq %rsp, %r14
movb $0x20, (%rsp)
movl $0x1, %edx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3a500
incq %r12
cmpq %r15, %r12
jb 0x78cf7
movq 0x2b266(%rip), %rbx     # 0xa3f80
leaq 0xbe5d(%rip), %rsi      # 0x84b7e
movl $0x2, %edx
movq %rbx, %rdi
callq 0x3a500
movsd 0x20(%rsp), %xmm0
mulsd 0xa2fc(%rip), %xmm0     # 0x83038
cvttsd2si %xmm0, %esi
movq %rbx, %rdi
callq 0x3a770
leaq 0x119c0(%rip), %rsi     # 0x8a70f
movl $0x1, %edx
movq %rax, %rdi
callq 0x3a500
movq %rbx, %rdi
callq 0x3a310
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 0x5d137
leaq 0x11947(%rip), %rsi     # 0x8a6db
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x5cd14
leaq 0x1193e(%rip), %rsi     # 0x8a6e8
leaq 0x48(%rsp), %rdi
callq 0x3a810
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
jne 0x78dd5
movups (%rcx), %xmm0
movups %xmm0, (%r15)
jmp 0x78de1
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 0x3a700
xorl %ebp, %ebp
movq 0x2b1d9(%rip), %rsi     # 0xa3fe8
movq 0x2b152(%rip), %rdx     # 0xa3f68
movq %rbx, %rdi
callq 0x3a760
movq %rax, %r14
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x78e3f
movq 0x10(%rsp), %rsi
incq %rsi
callq 0x3a480
jmp 0x78e3f
movq %rax, %r14
movb $0x1, %bpl
leaq 0x58(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x78e5a
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x3a480
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x78e75
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3a480
testb %bpl, %bpl
jne 0x78e9f
jmp 0x78ea7
movq %rax, %r14
leaq 0x38(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x78e9f
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x3a480
jmp 0x78e9f
movq %rax, %r14
movq %rbx, %rdi
callq 0x3a340
movq %r14, %rdi
callq 0x3a790
nop