// File: /workspace/github_c_makefile_star2_O1/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 0xd7961(%rip), %rax     # 0x152bd8
movq (%rax), %rcx
movq %rcx, 0xd7977(%rip)     # 0x152bf8
movq 0xd7958(%rip), %rax     # 0x152be0
movq 0x661f0(%rip), %xmm2    # 0xe1480
movapd 0x661f8(%rip), %xmm1    # 0xe1490
testq %rax, %rax
je 0x7b2d5
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 0x7b2dd
movsd 0x66613(%rip), %xmm3    # 0xe18f0
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x230, %rsp            # imm = 0x230
movslq 0xd790d(%rip), %rsi     # 0x152c00
movsd 0x704c5(%rip), %xmm0    # 0xeb7c0
movapd %xmm3, 0x10(%rsp)
mulsd %xmm3, %xmm0
cvttsd2si %xmm0, %ecx
leaq 0x76a8f(%rip), %rdx     # 0xf1d9f
leaq 0x20(%rsp), %rdi
xorl %eax, %eax
callq 0xba10
movslq 0xd78dd(%rip), %rbx     # 0x152c00
cmpq $0x18, %rbx
jl 0x7b383
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 0x7381e(%rip), %rax     # 0xeeb7f
movq %rax, (%rsp)
leaq 0x76a3b(%rip), %rdx     # 0xf1da7
leaq 0x76a3e(%rip), %r8      # 0xf1db1
movq %rbx, %rsi
movl %r14d, %ecx
movl %ebp, %r9d
xorl %eax, %eax
callq 0xba10
movq 0xd786e(%rip), %rax     # 0x152bf8
cmpq 0xd784f(%rip), %rax     # 0x152be0
jne 0x7b439
xorl %edi, %edi
callq 0x83728
movq %rax, %r15
subq 0xd7848(%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 0xd77ea(%rip), %rsi     # 0x152c00
subq %rax, %rsi
leaq (%rsp,%rax), %rdi
addq $0x20, %rdi
cmpq $0x1c1f, %r15           # imm = 0x1C1F
jae 0x7b46f
leaq 0x76b84(%rip), %rdx     # 0xf1fb5
movl %r14d, %ecx
jmp 0x7b5a0
testq %rax, %rax
je 0x7b5ac
cmpq %rax, 0xd779f(%rip)     # 0x152be8
jne 0x7b480
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x83728
subq 0xd77ac(%rip), %rax     # 0x152c08
movq 0xd77ad(%rip), %rbx     # 0x152c10
subq %rax, %rbx
cmovleq %r14, %rbx
jmp 0x7b50b
leaq 0x76b30(%rip), %rdx     # 0xf1fa6
movl %ebx, %ecx
movl %r14d, %r8d
jmp 0x7b5e5
movq %rax, 0xd7761(%rip)     # 0x152be8
xorl %edi, %edi
callq 0x83728
movq %rax, 0xd7773(%rip)     # 0x152c08
subq 0xd7754(%rip), %rax     # 0x152bf0
xorps %xmm0, %xmm0
cvtsi2sd %rax, %xmm0
movq 0xd774d(%rip), %rax     # 0x152bf8
movq %rax, %xmm1
movq 0x65fc8(%rip), %xmm4    # 0xe1480
punpckldq %xmm4, %xmm1    # xmm1 = xmm1[0],xmm4[0],xmm1[1],xmm4[1]
movapd 0x65fcc(%rip), %xmm3    # 0xe1490
subpd %xmm3, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
movq 0xd7701(%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, 0xd7705(%rip)     # 0x152c10
testq %rbx, %rbx
je 0x7b5ac
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 0xd767e(%rip), %rsi     # 0x152c00
subq %rax, %rsi
leaq (%rsp,%rax), %rdi
addq $0x20, %rdi
cmpq $0x1c1f, %rbx           # imm = 0x1C1F
jae 0x7b5d8
leaq 0x76a47(%rip), %rdx     # 0xf1fe4
movl %r15d, %ecx
movl %r12d, %r8d
xorl %eax, %eax
callq 0xba10
jmp 0x7b5ef
leaq 0x20(%rsp), %rdi
callq 0xb260
leaq (%rsp,%rax), %rdi
addq $0x20, %rdi
movslq 0xd763b(%rip), %rsi     # 0x152c00
subq %rax, %rsi
leaq 0x769f4(%rip), %rdx     # 0xf1fc3
xorl %eax, %eax
callq 0xba10
jmp 0x7b5ef
leaq 0x769f2(%rip), %rdx     # 0xf1fd1
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 0xd75f5(%rip), %rcx     # 0x152c00
movq %rcx, %rsi
subq %rax, %rsi
subl %eax, %ecx
leaq 0x769dc(%rip), %rdx     # 0xf1ff6
leaq 0x7355e(%rip), %r8      # 0xeeb7f
xorl %eax, %eax
callq 0xba10
movq %rbx, %rdi
callq 0xb260
movl $0x1, %edi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x83752
addq $0x230, %rsp            # imm = 0x230
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq