// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/core/progressbar.c
// Function: refresh_progressbar
static void refresh_progressbar(void)
{
  time_t seconds, minutes, hours, eta_diff;
  char buf[MAXIMUM_WINDOW_SIZE + 1];
  int bar_length, width;
  double percent;
  processed_counter = *computation_counter;
  /* percent */
  if (last_computation)
    percent = ((double) processed_counter / (double) last_computation);
  else
    percent = 1.0;
  (void) snprintf(buf, window_size, "\r%3d%% ", (int) (percent * 100.0));
  /* the bar */
  bar_length = window_size - 22; /* 5 + 2 + 14 + 1 (for '\0') */
  if (bar_length >= 2) { /* make sure the bar is at least 2 '*' wide */
    width = (int) (percent * bar_length);
    (void) snprintf(buf + strlen(buf), window_size - strlen(buf),
                    "|%.*s%*s|", width,
                    "**************************************************"
                    "**************************************************"
                    "**************************************************"
                    "**************************************************"
                    "**************************************************"
                    "**************************************************"
                    "**************************************************"
                    "**************************************************"
                    "**************************************************"
                    "**************************************************",
                    bar_length - width, "");
  }

#define SPLIT_SECONDS            \
        hours = seconds / 3600;  \
        seconds -= hours * 3600; \
        minutes = seconds / 60;  \
        seconds -= minutes * 60;

  /* ETA */
  if (processed_counter == last_computation) {
    /* computation is finished -> show elapsed time */
    seconds = gt_xtime(NULL) - computation_start;
    SPLIT_SECONDS;
    if (hours) {
      (void) snprintf(buf + strlen(buf), window_size - strlen(buf),
                      " %2u:%02u:%02u", (unsigned int) hours,
                      (unsigned int) minutes, (unsigned int) seconds);
    }
    else {
      (void) snprintf(buf + strlen(buf), window_size - strlen(buf),
                      "    %02u:%02u", (unsigned int) minutes,
                      (unsigned int) seconds);
    }
  }
  else if (processed_counter == 0) {
    (void) snprintf(buf + strlen(buf), window_size - strlen(buf),
                    "    --:-- ETA");
  }
  else {
    if (computed_eta != processed_counter) {
      /* compute new ETA */
      computed_eta = processed_counter;
      computed_eta_time = gt_xtime(NULL);
      eta = (time_t)
            (((double) (computed_eta_time - computation_start) /
              (double) (processed_counter)) *
             (last_computation - processed_counter));
      seconds = eta;
    }
    else {
      /* use previous ETA */
      eta_diff = gt_xtime(NULL) - computed_eta_time;
      if (eta_diff >= eta)
        seconds = 0;
      else
        seconds = eta - eta_diff;
    }
    if (seconds) {
      SPLIT_SECONDS;
      if (hours) {
        (void) snprintf(buf + strlen(buf), window_size - strlen(buf),
                        " %2u:%02u:%02u ETA", (unsigned int) hours,
                        (unsigned int) minutes, (unsigned int) seconds);
      }
      else {
        (void) snprintf(buf + strlen(buf), window_size - strlen(buf),
                        "    %02u:%02u ETA", (unsigned int) minutes,
                        (unsigned int) seconds);
      }
    }
    else {
      (void) snprintf(buf + strlen(buf), window_size - strlen(buf),
                      "    --:-- ETA");
    }
  }

  /* file line with blanks */
  (void) snprintf(buf + strlen(buf), window_size - strlen(buf), "%*s",
                  window_size - (int) strlen(buf), "");
  gt_xwrite(STDOUT_FILENO, buf, strlen(buf));
}

// Assembly:
movq 0xd7542(%rip), %rax     # 0x152bd8
movq (%rax), %rcx
movq %rcx, 0xd7558(%rip)     # 0x152bf8
movq 0xd7539(%rip), %rax     # 0x152be0
movq 0x65dd1(%rip), %xmm2    # 0xe1480
movapd 0x65dd9(%rip), %xmm1    # 0xe1490
testq %rax, %rax
je 0x7b6f4
movq %rcx, %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movapd %xmm0, %xmm3
unpckhpd %xmm0, %xmm3            # xmm3 = xmm3[1],xmm0[1]
addsd %xmm0, %xmm3
movq %rax, %xmm0
punpckldq %xmm2, %xmm0    # xmm0 = xmm0[0],xmm2[0],xmm0[1],xmm2[1]
subpd %xmm1, %xmm0
movapd %xmm0, %xmm1
unpckhpd %xmm0, %xmm1            # xmm1 = xmm1[1],xmm0[1]
addsd %xmm0, %xmm1
divsd %xmm1, %xmm3
jmp 0x7b6fc
movsd 0x661f4(%rip), %xmm3    # 0xe18f0
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x230, %rsp            # imm = 0x230
movslq 0xd74ee(%rip), %rsi     # 0x152c00
movsd 0x70056(%rip), %xmm0    # 0xeb770
movapd %xmm3, 0x10(%rsp)
mulsd %xmm3, %xmm0
cvttsd2si %xmm0, %ecx
leaq 0x76620(%rip), %rdx     # 0xf1d4f
leaq 0x20(%rsp), %rdi
xorl %eax, %eax
callq 0xba10
movslq 0xd74be(%rip), %rbx     # 0x152c00
cmpq $0x18, %rbx
jl 0x7b7a2
leal -0x16(%rbx), %ebp
xorps %xmm0, %xmm0
cvtsi2sd %ebp, %xmm0
movapd 0x10(%rsp), %xmm1
mulsd %xmm0, %xmm1
cvttsd2si %xmm1, %r14d
leaq 0x20(%rsp), %rdi
callq 0xb260
leaq (%rsp,%rax), %rdi
addq $0x20, %rdi
subq %rax, %rbx
subl %r14d, %ebp
leaq 0x733b7(%rip), %rax     # 0xeeb37
movq %rax, (%rsp)
leaq 0x765cc(%rip), %rdx     # 0xf1d57
leaq 0x765cf(%rip), %r8      # 0xf1d61
movq %rbx, %rsi
movl %r14d, %ecx
movl %ebp, %r9d
xorl %eax, %eax
callq 0xba10
movq 0xd744f(%rip), %rax     # 0x152bf8
cmpq 0xd7430(%rip), %rax     # 0x152be0
jne 0x7b858
xorl %edi, %edi
callq 0x83310
movq %rax, %r15
subq 0xd7429(%rip), %r15     # 0x152bf0
movabsq $0x48d159e26af37c05, %rcx # imm = 0x48D159E26AF37C05
movq %r15, %rax
imulq %rcx
movq %rdx, %rbx
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0xa, %rbx
addq %rax, %rbx
imulq $-0xe10, %rbx, %rcx     # imm = 0xF1F0
addq %r15, %rcx
movabsq $-0x7777777777777777, %rdx # imm = 0x8888888888888889
movq %rcx, %rax
imulq %rdx
movq %rdx, %r14
addq %rcx, %r14
movq %r14, %rax
shrq $0x3f, %rax
sarq $0x5, %r14
addq %rax, %r14
imulq $-0x3c, %r14, %r12
addq %rcx, %r12
addq $0xe0f, %r15            # imm = 0xE0F
leaq 0x20(%rsp), %rdi
callq 0xb260
movslq 0xd73cb(%rip), %rsi     # 0x152c00
subq %rax, %rsi
leaq (%rsp,%rax), %rdi
addq $0x20, %rdi
cmpq $0x1c1f, %r15           # imm = 0x1C1F
jae 0x7b88d
leaq 0x76715(%rip), %rdx     # 0xf1f65
movl %r14d, %ecx
jmp 0x7b9be
testq %rax, %rax
je 0x7b9ca
cmpq %rax, 0xd7380(%rip)     # 0x152be8
jne 0x7b89e
xorl %edi, %edi
callq 0x83310
subq 0xd7390(%rip), %rax     # 0x152c08
movq 0xd7391(%rip), %rbx     # 0x152c10
subq %rax, %rbx
jg 0x7b929
jmp 0x7b9ca
leaq 0x766c2(%rip), %rdx     # 0xf1f56
movl %ebx, %ecx
movl %r14d, %r8d
jmp 0x7ba03
movq %rax, 0xd7343(%rip)     # 0x152be8
xorl %edi, %edi
callq 0x83310
movq %rax, 0xd7355(%rip)     # 0x152c08
subq 0xd7336(%rip), %rax     # 0x152bf0
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movq 0xd732f(%rip), %rax     # 0x152bf8
movq %rax, %xmm1
movq 0x65baa(%rip), %xmm4    # 0xe1480
punpckldq %xmm4, %xmm1    # xmm1 = xmm1[0],xmm4[0],xmm1[1],xmm4[1]
movapd 0x65bae(%rip), %xmm3    # 0xe1490
subpd %xmm3, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
movq 0xd72e3(%rip), %rcx     # 0x152be0
subq %rax, %rcx
movq %rcx, %xmm1
punpckldq %xmm4, %xmm1    # xmm1 = xmm1[0],xmm4[0],xmm1[1],xmm4[1]
subpd %xmm3, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
mulsd %xmm0, %xmm2
cvttsd2si %xmm2, %rbx
movq %rbx, 0xd72e7(%rip)     # 0x152c10
testq %rbx, %rbx
je 0x7b9ca
movabsq $0x48d159e26af37c05, %rcx # imm = 0x48D159E26AF37C05
movq %rbx, %rax
imulq %rcx
movq %rdx, %r14
movq %rdx, %rax
shrq $0x3f, %rax
sarq $0xa, %r14
addq %rax, %r14
imulq $-0xe10, %r14, %rcx     # imm = 0xF1F0
addq %rbx, %rcx
movabsq $-0x7777777777777777, %rdx # imm = 0x8888888888888889
movq %rcx, %rax
imulq %rdx
movq %rdx, %r15
addq %rcx, %r15
movq %r15, %rax
shrq $0x3f, %rax
sarq $0x5, %r15
addq %rax, %r15
imulq $-0x3c, %r15, %r12
addq %rcx, %r12
addq $0xe0f, %rbx            # imm = 0xE0F
leaq 0x20(%rsp), %rdi
callq 0xb260
movslq 0xd7260(%rip), %rsi     # 0x152c00
subq %rax, %rsi
leaq (%rsp,%rax), %rdi
addq $0x20, %rdi
cmpq $0x1c1f, %rbx           # imm = 0x1C1F
jae 0x7b9f6
leaq 0x765d9(%rip), %rdx     # 0xf1f94
movl %r15d, %ecx
movl %r12d, %r8d
xorl %eax, %eax
callq 0xba10
jmp 0x7ba0d
leaq 0x20(%rsp), %rdi
callq 0xb260
leaq (%rsp,%rax), %rdi
addq $0x20, %rdi
movslq 0xd721d(%rip), %rsi     # 0x152c00
subq %rax, %rsi
leaq 0x76586(%rip), %rdx     # 0xf1f73
xorl %eax, %eax
callq 0xba10
jmp 0x7ba0d
leaq 0x76584(%rip), %rdx     # 0xf1f81
movl %r14d, %ecx
movl %r15d, %r8d
movl %r12d, %r9d
xorl %eax, %eax
callq 0xba10
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0xb260
leaq (%rsp,%rax), %rdi
addq $0x20, %rdi
movslq 0xd71d7(%rip), %rcx     # 0x152c00
movq %rcx, %rsi
subq %rax, %rsi
subl %eax, %ecx
leaq 0x7656e(%rip), %rdx     # 0xf1fa6
leaq 0x730f8(%rip), %r8      # 0xeeb37
xorl %eax, %eax
callq 0xba10
movq %rbx, %rdi
callq 0xb260
movl $0x1, %edi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x8333a
addq $0x230, %rsp            # imm = 0x230
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq