// File: /workspace/github_cpp_makefile_star2_O2/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 %r12
pushq %rbx
subq $0x70, %rsp
movq %rdi, %r14
cmpb $0x1, 0x6c(%rdi)
jne 0x830c1
callq 0x832b8
movl %eax, %r15d
jmp 0x830c5
movslq 0x60(%r14), %r15
movq 0x28(%r14), %rax
leaq -0xa(%r15), %r12
addq 0x48(%r14), %rax
subq %rax, %r12
je 0x83200
leaq 0x20(%r14), %r15
movq 0x2eea3(%rip), %rbx     # 0xb1f88
pushq $0xd
popq %rsi
movq %rbx, %rdi
callq 0x52510
movq %rbx, %rdi
movq %r15, %rsi
callq 0x52400
leaq 0xf8f6(%rip), %rsi      # 0x929f8
movq %rbx, %rdi
callq 0x52450
movq 0x8(%r14), %rax
movq 0x10(%r14), %rcx
subq %rcx, %rax
cvtsi2sd %rax, %xmm2
cvtsi2sdq 0x18(%r14), %xmm0
divsd %xmm0, %xmm2
cvtsi2sd %rcx, %xmm0
subsd %xmm0, %xmm2
movq %r12, %xmm0
punpckldq 0xf0a6(%rip), %xmm0 # xmm0 = xmm0[0],mem[0],xmm0[1],mem[1]
subpd 0xf0ae(%rip), %xmm0     # 0x921f0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
movsd %xmm2, 0x8(%rsp)
mulsd %xmm2, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rcx
sarq $0x3f, %rcx
subsd 0xf454(%rip), %xmm1     # 0x925c0
cvttsd2si %xmm1, %r14
andq %rcx, %r14
orq %rax, %r14
pushq $0x3d
popq %rbp
movq %r14, %r15
subq $0x1, %r15
jb 0x8318f
movq %rbx, %rdi
movl %ebp, %esi
callq 0x52510
jmp 0x8317d
movq 0x2edf2(%rip), %rbx     # 0xb1f88
pushq $0x20
popq %rbp
cmpq %r12, %r14
jae 0x831ad
movq %rbx, %rdi
movl %ebp, %esi
callq 0x52510
incq %r14
jmp 0x83199
movq 0x2edd4(%rip), %rbx     # 0xb1f88
leaq 0x9b3f(%rip), %rsi      # 0x8ccfa
movq %rbx, %rdi
callq 0x52450
movsd 0x8(%rsp), %xmm0
mulsd 0x7e67(%rip), %xmm0     # 0x8b038
cvttsd2si %xmm0, %esi
movq %rbx, %rdi
callq 0x52770
leaq 0xf817(%rip), %rsi      # 0x929fb
movq %rax, %rdi
callq 0x52450
movq %rbx, %rdi
addq $0x70, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
jmp 0x52320
pushq $0x10
popq %rdi
callq 0x52220
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
movq %r15, %rsi
callq 0x6eaa7
leaq 0xf7a8(%rip), %rsi      # 0x929c7
leaq 0x30(%rsp), %rdi
leaq 0x10(%rsp), %rdx
callq 0x6e761
leaq 0xf79f(%rip), %rdx      # 0x929d4
leaq 0x50(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x5a4df
movb $0x1, %bpl
leaq 0x50(%rsp), %rsi
movq %rbx, %rdi
callq 0x52700
xorl %ebp, %ebp
movq 0x2ed93(%rip), %rsi     # 0xb1ff0
movq 0x2ed0c(%rip), %rdx     # 0xb1f70
movq %rbx, %rdi
callq 0x52760
movq %rax, %r14
leaq 0x50(%rsp), %rdi
callq 0x52888
jmp 0x83281
movq %rax, %r14
movb $0x1, %bpl
leaq 0x30(%rsp), %rdi
callq 0x52888
jmp 0x83293
movq %rax, %r14
movb $0x1, %bpl
leaq 0x10(%rsp), %rdi
callq 0x52888
testb %bpl, %bpl
jne 0x832a7
jmp 0x832af
movq %rax, %r14
movq %rbx, %rdi
callq 0x52350
movq %r14, %rdi
callq 0x527a0
nop