// File: /workspace/github_cpp_makefile_star2_O2/Kingsford-Group[P]ghost2/src/progressBar.hpp
// Function: ProgressBar::update()
void ProgressBar::update()
{
  count++;
  progress = (double)(count) / max;
  if(2*barWidth*progress > prev)
    if(mutex.try_lock())
    {
      prev++;
      int n = (int)(progress*100.0);
      std::cout << n << "%" << (n<10?"  [":n<100?" [":"[");
      int pos = barWidth * progress;
      for(int i=0;i<barWidth;i++)
      {
        if(i<pos) std::cout << "=";
        else if(i==pos) std::cout << ">";
        else std::cout << " ";
      }
      auto elapsed = (bclock::local_time() - time).total_seconds();
      int eta = elapsed>0?(int)(elapsed / progress - elapsed):0;
      std::cout << "] ETA " << eta << 
        (eta<10?"s   \r":eta<100?"s  \r":eta<1000?"s \r":"s\r");
      std::cout.flush();
      mutex.unlock();
    }
}

// Assembly:
movl 0x4(%rdi), %eax
movl 0x18(%rdi), %ecx
incl %eax
movl %eax, 0x4(%rdi)
cvtsi2sd %eax, %xmm0
cvtsi2sdl 0x8(%rdi), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rdi)
addl %ecx, %ecx
cvtsi2sd %ecx, %xmm1
mulsd %xmm0, %xmm1
cvtsi2sdl (%rdi), %xmm0
ucomisd %xmm0, %xmm1
jbe 0x1097f
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %r14
leaq 0x28(%rdi), %rbx
movq %rbx, %rdi
callq 0x18a4e
testb %al, %al
je 0x10971
movq %rbx, 0x8(%rsp)
incl (%r14)
movsd 0x10(%r14), %xmm0
mulsd 0x2f838(%rip), %xmm0    # 0x40058
cvttsd2si %xmm0, %ebp
movq 0x6c76d(%rip), %rdi     # 0x7cf98
movl %ebp, %esi
callq 0xe9d0
leaq 0x2ffc5(%rip), %rsi     # 0x407fe
movq %rax, %rdi
callq 0xe540
cmpl $0x64, %ebp
leaq 0x2ffb6(%rip), %rcx     # 0x40801
leaq 0x2ffb0(%rip), %rdx     # 0x40802
cmovbq %rcx, %rdx
cmpl $0xa, %ebp
leaq 0x2ffa0(%rip), %rsi     # 0x40800
cmovgeq %rdx, %rsi
movq %rax, %rdi
callq 0xe540
movl 0x18(%r14), %eax
cvtsi2sd %eax, %xmm0
mulsd 0x10(%r14), %xmm0
cvttsd2si %xmm0, %ebp
xorl %r12d, %r12d
leaq 0x2fe7f(%rip), %r13     # 0x40707
leaq 0x30184(%rip), %rbx     # 0x40a13
leaq 0x2fe73(%rip), %r15     # 0x40709
cmpl %eax, %r12d
jge 0x108be
cmpl %r12d, %ebp
movq %rbx, %rsi
cmoveq %r13, %rsi
cmovgq %r15, %rsi
movq 0x6c6e8(%rip), %rdi     # 0x7cf98
callq 0xe540
incl %r12d
movl 0x18(%r14), %eax
jmp 0x10896
callq 0x1889e
leaq 0x10(%rsp), %rdi
movq %rax, (%rdi)
leaq 0x20(%r14), %rsi
callq 0x1c4fa
xorl %ebp, %ebp
cmpq $0xf423f, %rax          # imm = 0xF423F
jle 0x108ff
movl $0xf4240, %ecx          # imm = 0xF4240
xorl %edx, %edx
divq %rcx
cvtsi2sd %rax, %xmm0
movapd %xmm0, %xmm1
divsd 0x10(%r14), %xmm1
subsd %xmm0, %xmm1
cvttsd2si %xmm1, %ebp
movq 0x6c692(%rip), %rdi     # 0x7cf98
leaq 0x2fef7(%rip), %rsi     # 0x40804
callq 0xe540
movq %rax, %rdi
movl %ebp, %esi
callq 0xe9d0
cmpl $0xa, %ebp
movq 0x8(%rsp), %rbx
jge 0x1092f
leaq 0x2fede(%rip), %rsi     # 0x4080b
jmp 0x10955
cmpl $0x64, %ebp
jae 0x1093d
leaq 0x2fed6(%rip), %rsi     # 0x40811
jmp 0x10955
cmpl $0x3e8, %ebp            # imm = 0x3E8
leaq 0x2fecc(%rip), %rcx     # 0x40816
leaq 0x2fec9(%rip), %rsi     # 0x4081a
cmovbq %rcx, %rsi
movq %rax, %rdi
callq 0xe540
movq 0x6c634(%rip), %rdi     # 0x7cf98
callq 0xe3b0
movq %rbx, %rdi
callq 0x18a66
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq