// File: /workspace/github_cpp_makefile_star2_O3/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
xorps %xmm1, %xmm1
cvtsi2sd %ecx, %xmm1
mulsd %xmm0, %xmm1
xorps %xmm0, %xmm0
cvtsi2sdl (%rdi), %xmm0
ucomisd %xmm0, %xmm1
jbe 0xfa12
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 0xc120
cmpl $0x4, %eax
je 0xf83e
testl %eax, %eax
jne 0xfa04
movq %rbx, 0x8(%rsp)
incl (%r14)
movsd 0x10(%r14), %xmm0
mulsd 0x387ef(%rip), %xmm0    # 0x48058
cvttsd2si %xmm0, %ebp
movq 0x68724(%rip), %rdi     # 0x77f98
movl %ebp, %esi
callq 0xc9a0
movq %rax, %r15
leaq 0x38f95(%rip), %rsi     # 0x4881a
movl $0x1, %edx
movq %rax, %rdi
callq 0xc620
cmpl $0x64, %ebp
leaq 0x38f81(%rip), %rax     # 0x4881d
leaq 0x38f7b(%rip), %rcx     # 0x4881e
cmovbq %rax, %rcx
cmpl $0xa, %ebp
leaq 0x38f6b(%rip), %r12     # 0x4881c
cmovgeq %rcx, %r12
movq %r12, %rdi
callq 0xc250
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0xc620
movl 0x18(%r14), %eax
testl %eax, %eax
jle 0xf927
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x10(%r14), %xmm0
cvttsd2si %xmm0, %ebp
xorl %r12d, %r12d
leaq 0x39141(%rip), %rbx     # 0x48a2f
leaq 0x38e30(%rip), %r13     # 0x48725
movq 0x6869c(%rip), %r15     # 0x77f98
cmpl %r12d, %ebp
movq %rbx, %rsi
leaq 0x38e1a(%rip), %rax     # 0x48723
cmoveq %rax, %rsi
cmovgq %r13, %rsi
movl $0x1, %edx
movq %r15, %rdi
callq 0xc620
incl %r12d
cmpl 0x18(%r14), %r12d
jl 0xf8fc
leaq 0x18fee(%rip), %rdi     # 0x2891c
callq 0x28826
leaq 0x10(%rsp), %rdi
movq %rax, (%rdi)
leaq 0x20(%r14), %rsi
callq 0x20fc4
xorl %ebp, %ebp
cmpq $0xf423f, %rax          # imm = 0xF423F
jle 0xf979
movabsq $0x431bde82d7b634db, %rcx # imm = 0x431BDE82D7B634DB
mulq %rcx
shrq $0x12, %rdx
xorps %xmm0, %xmm0
cvtsi2sd %rdx, %xmm0
movapd %xmm0, %xmm1
divsd 0x10(%r14), %xmm1
subsd %xmm0, %xmm1
cvttsd2si %xmm1, %ebp
movq 0x68618(%rip), %r14     # 0x77f98
leaq 0x38e99(%rip), %rsi     # 0x48820
movl $0x6, %edx
movq %r14, %rdi
callq 0xc620
movq %r14, %rdi
movl %ebp, %esi
callq 0xc9a0
movq %rax, %r14
cmpl $0xa, %ebp
movq 0x8(%rsp), %rbx
jge 0xf9b4
leaq 0x38e75(%rip), %r15     # 0x48827
jmp 0xf9da
cmpl $0x64, %ebp
jae 0xf9c2
leaq 0x38e6d(%rip), %r15     # 0x4882d
jmp 0xf9da
cmpl $0x3e8, %ebp            # imm = 0x3E8
leaq 0x38e63(%rip), %rax     # 0x48832
leaq 0x38e60(%rip), %r15     # 0x48836
cmovbq %rax, %r15
movq %r15, %rdi
callq 0xc250
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0xc620
movq 0x685a1(%rip), %rdi     # 0x77f98
callq 0xc370
movq %rbx, %rdi
callq 0x1c43a
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq