// File: /workspace/github_cpp_makefile_star2_O1/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 0x10a2c
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 0xd120
cmpl $0x4, %eax
je 0x10858
testl %eax, %eax
jne 0x10a1e
movq %rbx, 0x8(%rsp)
incl (%r14)
movsd 0x10(%r14), %xmm0
mulsd 0x387d5(%rip), %xmm0    # 0x49058
cvttsd2si %xmm0, %ebp
movq 0x6870a(%rip), %rdi     # 0x78f98
movl %ebp, %esi
callq 0xd9a0
movq %rax, %r15
leaq 0x38f4b(%rip), %rsi     # 0x497ea
movl $0x1, %edx
movq %rax, %rdi
callq 0xd620
cmpl $0x64, %ebp
leaq 0x38f37(%rip), %rax     # 0x497ed
leaq 0x38f31(%rip), %rcx     # 0x497ee
cmovlq %rax, %rcx
cmpl $0xa, %ebp
leaq 0x38f21(%rip), %r12     # 0x497ec
cmovgeq %rcx, %r12
movq %r12, %rdi
callq 0xd250
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0xd620
movl 0x18(%r14), %eax
testl %eax, %eax
jle 0x10941
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
mulsd 0x10(%r14), %xmm0
cvttsd2si %xmm0, %ebp
xorl %r12d, %r12d
leaq 0x390f7(%rip), %rbx     # 0x499ff
leaq 0x38de6(%rip), %r13     # 0x496f5
movq 0x68682(%rip), %r15     # 0x78f98
cmpl %r12d, %ebp
movq %rbx, %rsi
leaq 0x38dd0(%rip), %rax     # 0x496f3
cmoveq %rax, %rsi
cmovgq %r13, %rsi
movl $0x1, %edx
movq %r15, %rdi
callq 0xd620
incl %r12d
cmpl 0x18(%r14), %r12d
jl 0x10916
leaq 0x1950c(%rip), %rdi     # 0x29e54
callq 0x29d5e
leaq 0x10(%rsp), %rdi
movq %rax, (%rdi)
leaq 0x20(%r14), %rsi
callq 0x223a0
xorl %ebp, %ebp
cmpq $0xf423f, %rax          # imm = 0xF423F
jle 0x10993
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 0x685fe(%rip), %r14     # 0x78f98
leaq 0x38e4f(%rip), %rsi     # 0x497f0
movl $0x6, %edx
movq %r14, %rdi
callq 0xd620
movq %r14, %rdi
movl %ebp, %esi
callq 0xd9a0
movq %rax, %r14
cmpl $0xa, %ebp
movq 0x8(%rsp), %rbx
jge 0x109ce
leaq 0x38e2b(%rip), %r15     # 0x497f7
jmp 0x109f4
cmpl $0x64, %ebp
jge 0x109dc
leaq 0x38e23(%rip), %r15     # 0x497fd
jmp 0x109f4
cmpl $0x3e8, %ebp            # imm = 0x3E8
leaq 0x38e19(%rip), %rax     # 0x49802
leaq 0x38e16(%rip), %r15     # 0x49806
cmovlq %rax, %r15
movq %r15, %rdi
callq 0xd250
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0xd620
movq 0x68587(%rip), %rdi     # 0x78f98
callq 0xd370
movq %rbx, %rdi
callq 0x1d736
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq