// File: trapexit[P]bbf/src/info.cpp
// Function: InfoPrinter::print(unsigned long)
void
InfoPrinter::print(const size_t current_block_)
{
  const double current_time      = Time::get_monotonic();
  const size_t badcount          = _badblocks->size();
  const size_t processed_blocks  = (current_block_ - _start_block);
  const size_t total_blocks      = (_end_block - _start_block);
  const size_t blocks_left       = (total_blocks - processed_blocks);
  const double percentage        = (((double)processed_blocks / total_blocks) * 100.0);
  const double time_passed       = (current_time - _start_time);
  const double blocks_per_second = ((double)processed_blocks / time_passed);
  const size_t time_left         = ((double)blocks_left / blocks_per_second);

  std::cout << "\x1B" << '8'
            << "\x1B[2K"
            << "Current: " << current_block_ << " ("
            << std::fixed
            << std::setprecision(2)
            << percentage
            << "%); bps: " << blocks_per_second
            << "; eta: "
            << std::setfill('0') << std::setw(2)
            << (time_left/(60*60)) << ':'
            << std::setfill('0') << std::setw(2)
            << ((time_left/60)%60)  << ':'
            << std::setfill('0') << std::setw(2)
            << (time_left%60)
            << "; bad: " << badcount;
  if(badcount)
    std::cout << "; last: " << (*_badblocks)[badcount-1];
  std::cout << std::endl << "\x1B[2K" << std::flush;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xb8(%rbp)
callq 0x221b0
movq -0xb8(%rbp), %rax
movsd %xmm0, -0x18(%rbp)
movq 0x18(%rax), %rdi
callq 0x58d0
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movq %rcx, -0x20(%rbp)
movq -0x10(%rbp), %rcx
movq 0x8(%rax), %rdx
subq %rdx, %rcx
movq %rcx, -0x28(%rbp)
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rcx
subq %rdx, %rcx
movq %rcx, -0x30(%rbp)
movq -0x30(%rbp), %rcx
movq -0x28(%rbp), %rdx
subq %rdx, %rcx
movq %rcx, -0x38(%rbp)
movq -0x28(%rbp), %xmm0
movaps 0xb041(%rip), %xmm2     # 0x23a70
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
movapd 0xb045(%rip), %xmm1     # 0x23a80
subpd %xmm1, %xmm0
movaps %xmm0, %xmm3
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm3, %xmm0
movq -0x30(%rbp), %xmm3
punpckldq %xmm2, %xmm3    # xmm3 = xmm3[0],xmm2[0],xmm3[1],xmm2[1]
subpd %xmm1, %xmm3
movaps %xmm3, %xmm4
unpckhpd %xmm3, %xmm3            # xmm3 = xmm3[1,1]
addsd %xmm4, %xmm3
divsd %xmm3, %xmm0
movsd 0xb022(%rip), %xmm3     # 0x23a90
mulsd %xmm3, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x18(%rbp), %xmm0
movsd (%rax), %xmm3
subsd %xmm3, %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0x28(%rbp), %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movaps %xmm0, %xmm3
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm3, %xmm0
movsd -0x48(%rbp), %xmm3
divsd %xmm3, %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0x38(%rbp), %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd -0x50(%rbp), %xmm1
divsd %xmm1, %xmm0
movaps %xmm0, %xmm1
cvttsd2si %xmm1, %rax
movq %rax, %rdx
sarq $0x3f, %rdx
movsd 0xafb1(%rip), %xmm1     # 0x23a98
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %rcx
andq %rdx, %rcx
orq %rcx, %rax
movq %rax, -0x58(%rbp)
movq 0x1e4af(%rip), %rdi     # 0x36fb0
leaq 0xaf9e(%rip), %rsi      # 0x23aa6
callq 0x4540
movq %rax, %rdi
movl $0x38, %esi
callq 0x4610
movq %rax, %rdi
leaq 0xaf7d(%rip), %rsi      # 0x23aa1
callq 0x4540
movq %rax, %rdi
leaq 0xaf75(%rip), %rsi      # 0x23aa8
callq 0x4540
movq %rax, %rdi
movq -0x10(%rbp), %rsi
callq 0x4100
movq %rax, %rdi
leaq 0xa792(%rip), %rsi      # 0x232e0
callq 0x4540
movq %rax, %rdi
leaq 0x243(%rip), %rsi       # 0x18da0
callq 0x41c0
movq %rax, -0xb0(%rbp)
movl $0x2, %edi
callq 0x18dd0
movq -0xb0(%rbp), %rdi
movl %eax, -0x5c(%rbp)
movl -0x5c(%rbp), %esi
callq 0x47c0
movq %rax, %rdi
movsd -0x40(%rbp), %xmm0
callq 0x4910
movq %rax, %rdi
leaq 0xaf16(%rip), %rsi      # 0x23ab2
callq 0x4540
movq %rax, %rdi
movsd -0x50(%rbp), %xmm0
callq 0x4910
movq %rax, %rdi
leaq 0xaf04(%rip), %rsi      # 0x23abc
callq 0x4540
movq %rax, -0xa8(%rbp)
movl $0x30, %edi
callq 0x18df0
movq -0xa8(%rbp), %rdi
movb %al, -0x5d(%rbp)
movzbl -0x5d(%rbp), %esi
callq 0x47b0
movq %rax, -0xa0(%rbp)
movl $0x2, %edi
callq 0x18e10
movq -0xa0(%rbp), %rdi
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %esi
callq 0x45f0
movq %rax, %rdi
movq -0x58(%rbp), %rax
movl $0xe10, %ecx            # imm = 0xE10
xorl %edx, %edx
divq %rcx
movq %rax, %rsi
callq 0x4100
movq %rax, %rdi
movl $0x3a, %esi
callq 0x4610
movq %rax, -0x98(%rbp)
movl $0x30, %edi
callq 0x18df0
movq -0x98(%rbp), %rdi
movb %al, -0x65(%rbp)
movzbl -0x65(%rbp), %esi
callq 0x47b0
movq %rax, -0x90(%rbp)
movl $0x2, %edi
callq 0x18e10
movq -0x90(%rbp), %rdi
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %esi
callq 0x45f0
movq %rax, %rdi
movq -0x58(%rbp), %rax
movl $0x3c, %ecx
xorl %edx, %edx
divq %rcx
movl $0x3c, %ecx
xorl %edx, %edx
divq %rcx
movq %rdx, %rsi
callq 0x4100
movq %rax, %rdi
movl $0x3a, %esi
callq 0x4610
movq %rax, -0x88(%rbp)
movl $0x30, %edi
callq 0x18df0
movq -0x88(%rbp), %rdi
movb %al, -0x6d(%rbp)
movzbl -0x6d(%rbp), %esi
callq 0x47b0
movq %rax, -0x80(%rbp)
movl $0x2, %edi
callq 0x18e10
movq -0x80(%rbp), %rdi
movl %eax, -0x74(%rbp)
movl -0x74(%rbp), %esi
callq 0x45f0
movq %rax, %rdi
movq -0x58(%rbp), %rax
movl $0x3c, %ecx
xorl %edx, %edx
divq %rcx
movq %rdx, %rsi
callq 0x4100
movq %rax, %rdi
leaq 0xadbf(%rip), %rsi      # 0x23ac4
callq 0x4540
movq %rax, %rdi
movq -0x20(%rbp), %rsi
callq 0x4100
cmpq $0x0, -0x20(%rbp)
je 0x18d61
movq 0x1e28c(%rip), %rdi     # 0x36fb0
leaq 0xada1(%rip), %rsi      # 0x23acc
callq 0x4540
movq %rax, %rcx
movq -0xb8(%rbp), %rax
movq %rcx, -0xc0(%rbp)
movq 0x18(%rax), %rdi
movq -0x20(%rbp), %rsi
subq $0x1, %rsi
callq 0xb5f0
movq -0xc0(%rbp), %rdi
movq (%rax), %rsi
callq 0x4100
movq 0x1e248(%rip), %rdi     # 0x36fb0
movq 0x1e229(%rip), %rsi     # 0x36f98
callq 0x4580
movq %rax, %rdi
leaq 0xad23(%rip), %rsi      # 0x23aa1
callq 0x4540
movq %rax, %rdi
movq 0x1e22b(%rip), %rsi     # 0x36fb8
callq 0x4580
addq $0xc0, %rsp
popq %rbp
retq
nopl (%rax,%rax)