// File: 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:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x40(%rbp)
movl 0x4(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x4(%rax)
cvtsi2sdl 0x4(%rax), %xmm0
cvtsi2sdl 0x8(%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, 0x10(%rax)
movl 0x18(%rax), %ecx
shll %ecx
cvtsi2sd %ecx, %xmm0
mulsd 0x10(%rax), %xmm0
cvtsi2sdl (%rax), %xmm1
ucomisd %xmm1, %xmm0
jbe 0x145bb
movq -0x40(%rbp), %rdi
addq $0x28, %rdi
callq 0x24420
testb $0x1, %al
jne 0x143c2
jmp 0x145b9
movq -0x40(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movsd 0xa7c83(%rip), %xmm0    # 0xbc058
mulsd 0x10(%rax), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %esi
movq 0x11cbad(%rip), %rdi    # 0x130f98
callq 0x10ca0
movq %rax, %rdi
leaq 0xa83d4(%rip), %rsi     # 0xbc7ce
callq 0x106c0
movq %rax, -0x48(%rbp)
cmpl $0xa, -0xc(%rbp)
jge 0x14416
leaq 0xa83c0(%rip), %rax     # 0xbc7d0
movq %rax, -0x50(%rbp)
jmp 0x14432
movl -0xc(%rbp), %edx
leaq 0xa83b2(%rip), %rax     # 0xbc7d2
leaq 0xa83aa(%rip), %rcx     # 0xbc7d1
cmpl $0x64, %edx
cmovlq %rcx, %rax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rdi
movq -0x50(%rbp), %rsi
callq 0x106c0
movq -0x40(%rbp), %rax
cvtsi2sdl 0x18(%rax), %xmm0
mulsd 0x10(%rax), %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x40(%rbp), %rcx
movl -0x14(%rbp), %eax
cmpl 0x18(%rcx), %eax
jge 0x144c3
movl -0x14(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x14484
movq 0x11cb22(%rip), %rdi    # 0x130f98
leaq 0xa825c(%rip), %rsi     # 0xbc6d9
callq 0x106c0
jmp 0x144b6
movl -0x14(%rbp), %eax
cmpl -0x10(%rbp), %eax
jne 0x144a1
movq 0x11cb05(%rip), %rdi    # 0x130f98
leaq 0xa823d(%rip), %rsi     # 0xbc6d7
callq 0x106c0
jmp 0x144b4
movq 0x11caf0(%rip), %rdi    # 0x130f98
leaq 0xa8528(%rip), %rsi     # 0xbc9d7
callq 0x106c0
jmp 0x144b6
jmp 0x144b8
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x14(%rbp)
jmp 0x1445b
callq 0x23b20
movq -0x40(%rbp), %rsi
movq %rax, -0x30(%rbp)
addq $0x20, %rsi
leaq -0x30(%rbp), %rdi
callq 0x23cc0
movq %rax, -0x28(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x24480
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jle 0x14517
movq -0x40(%rbp), %rax
cvtsi2sdq -0x20(%rbp), %xmm0
divsd 0x10(%rax), %xmm0
cvtsi2sdq -0x20(%rbp), %xmm1
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0x54(%rbp)
jmp 0x1451e
xorl %eax, %eax
movl %eax, -0x54(%rbp)
jmp 0x1451e
movl -0x54(%rbp), %eax
movl %eax, -0x34(%rbp)
movq 0x11ca6d(%rip), %rdi    # 0x130f98
leaq 0xa82a2(%rip), %rsi     # 0xbc7d4
callq 0x106c0
movq %rax, %rdi
movl -0x34(%rbp), %esi
callq 0x10ca0
movq %rax, -0x60(%rbp)
cmpl $0xa, -0x34(%rbp)
jge 0x14559
leaq 0xa8288(%rip), %rax     # 0xbc7db
movq %rax, -0x68(%rbp)
jmp 0x14593
cmpl $0x64, -0x34(%rbp)
jge 0x1456c
leaq 0xa827b(%rip), %rax     # 0xbc7e1
movq %rax, -0x70(%rbp)
jmp 0x1458b
movl -0x34(%rbp), %edx
leaq 0xa8274(%rip), %rax     # 0xbc7ea
leaq 0xa8269(%rip), %rcx     # 0xbc7e6
cmpl $0x3e8, %edx            # imm = 0x3E8
cmovlq %rcx, %rax
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rdi
movq -0x68(%rbp), %rsi
callq 0x106c0
movq 0x11c9f1(%rip), %rdi    # 0x130f98
callq 0x104c0
movq -0x40(%rbp), %rdi
addq $0x28, %rdi
callq 0x244b0
jmp 0x145bb
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)