// File: /workspace/github_c_makefile_star2_O2/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 0xd5576(%rip), %rax     # 0x12fbc8
movq (%rax), %rcx
movq %rcx, 0xd558c(%rip)     # 0x12fbe8
movq 0xd556d(%rip), %rax     # 0x12fbd0
movq 0x6fe15(%rip), %xmm2    # 0xca480
movapd 0x6fe1d(%rip), %xmm1    # 0xca490
testq %rax, %rax
je 0x5a6b0
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 0x5a6b8
movsd 0x70238(%rip), %xmm3    # 0xca8f0
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x230, %rsp            # imm = 0x230
movslq 0xd5522(%rip), %rsi     # 0x12fbf0
movsd 0x7a08a(%rip), %xmm0    # 0xd4760
movapd %xmm3, 0x10(%rsp)
mulsd %xmm3, %xmm0
cvttsd2si %xmm0, %ecx
leaq 0x809c9(%rip), %rdx     # 0xdb0b4
leaq 0x20(%rsp), %rdi
xorl %eax, %eax
callq 0xba00
movslq 0xd54f2(%rip), %rbx     # 0x12fbf0
cmpq $0x18, %rbx
jl 0x5a75b
leal -0x16(%rbx), %ebp
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 0x7d3a6(%rip), %rax     # 0xd7adf
movq %rax, (%rsp)
leaq 0x80978(%rip), %rdx     # 0xdb0bc
leaq 0x8097b(%rip), %r8      # 0xdb0c6
movq %rbx, %rsi
movl %r14d, %ecx
movl %ebp, %r9d
xorl %eax, %eax
callq 0xba00
movq 0xd5486(%rip), %rax     # 0x12fbe8
cmpq 0xd5467(%rip), %rax     # 0x12fbd0
jne 0x5a7e8
xorl %edi, %edi
callq 0x62606
movq %rax, %r12
subq 0xd5464(%rip), %r12     # 0x12fbe0
movl $0xe10, %ecx            # imm = 0xE10
movq %r12, %rax
cqto
idivq %rcx
movq %rax, %r15
imulq $-0xe10, %rax, %rcx     # imm = 0xF1F0
addq %r12, %rcx
pushq $0x3c
popq %rsi
movq %rcx, %rax
cqto
idivq %rsi
movq %rax, %rbx
imulq $-0x3c, %rax, %r14
addq %rcx, %r14
addq $0xe0f, %r12            # imm = 0xE0F
leaq 0x20(%rsp), %rdi
callq 0xb260
movslq 0xd542d(%rip), %rsi     # 0x12fbf0
subq %rax, %rsi
leaq (%rsp,%rax), %rdi
addq $0x20, %rdi
cmpq $0x1c1f, %r12           # imm = 0x1C1F
jae 0x5a81d
leaq 0x80aec(%rip), %rdx     # 0xdb2ca
movl %ebx, %ecx
movl %r14d, %r8d
jmp 0x5a927
testq %rax, %rax
je 0x5a930
cmpq %rax, 0xd53e0(%rip)     # 0x12fbd8
jne 0x5a832
xorl %edi, %edi
callq 0x62606
subq 0xd53f0(%rip), %rax     # 0x12fbf8
movq 0xd53f1(%rip), %rbx     # 0x12fc00
subq %rax, %rbx
jg 0x5a8ba
jmp 0x5a930
leaq 0x80a97(%rip), %rdx     # 0xdb2bb
movl %r15d, %ecx
movl %ebx, %r8d
movl %r14d, %r9d
jmp 0x5a96c
movq %rax, 0xd539f(%rip)     # 0x12fbd8
xorl %edi, %edi
callq 0x62606
movq %rax, 0xd53b1(%rip)     # 0x12fbf8
subq 0xd5392(%rip), %rax     # 0x12fbe0
cvtsi2sd %rax, %xmm0
movq 0xd538e(%rip), %rax     # 0x12fbe8
movq %rax, %xmm1
movq 0x6fc19(%rip), %xmm4    # 0xca480
punpckldq %xmm4, %xmm1    # xmm1 = xmm1[0],xmm4[0],xmm1[1],xmm4[1]
movapd 0x6fc1d(%rip), %xmm3    # 0xca490
subpd %xmm3, %xmm1
movapd %xmm1, %xmm2
unpckhpd %xmm1, %xmm2            # xmm2 = xmm2[1],xmm1[1]
addsd %xmm1, %xmm2
divsd %xmm2, %xmm0
movq 0xd5342(%rip), %rcx     # 0x12fbd0
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, 0xd5346(%rip)     # 0x12fc00
testq %rbx, %rbx
je 0x5a930
movl $0xe10, %ecx            # imm = 0xE10
movq %rbx, %rax
cqto
idivq %rcx
movq %rax, %r12
imulq $-0xe10, %rax, %rcx     # imm = 0xF1F0
addq %rbx, %rcx
pushq $0x3c
popq %rsi
movq %rcx, %rax
cqto
idivq %rsi
movq %rax, %r14
imulq $-0x3c, %rax, %r15
addq %rcx, %r15
addq $0xe0f, %rbx            # imm = 0xE0F
leaq 0x20(%rsp), %rdi
callq 0xb260
movslq 0xd52ea(%rip), %rsi     # 0x12fbf0
subq %rax, %rsi
leaq (%rsp,%rax), %rdi
addq $0x20, %rdi
cmpq $0x1c1f, %rbx           # imm = 0x1C1F
jae 0x5a95c
leaq 0x809d8(%rip), %rdx     # 0xdb2f9
movl %r14d, %ecx
movl %r15d, %r8d
xorl %eax, %eax
callq 0xba00
jmp 0x5a973
leaq 0x20(%rsp), %rdi
callq 0xb260
leaq (%rsp,%rax), %rdi
addq $0x20, %rdi
movslq 0xd52a7(%rip), %rsi     # 0x12fbf0
subq %rax, %rsi
leaq 0x80985(%rip), %rdx     # 0xdb2d8
xorl %eax, %eax
callq 0xba00
jmp 0x5a973
leaq 0x80983(%rip), %rdx     # 0xdb2e6
movl %r12d, %ecx
movl %r14d, %r8d
movl %r15d, %r9d
xorl %eax, %eax
callq 0xba00
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
callq 0xb260
leaq (%rsp,%rax), %rdi
addq $0x20, %rdi
movslq 0xd5261(%rip), %rcx     # 0x12fbf0
movq %rcx, %rsi
subq %rax, %rsi
subl %eax, %ecx
leaq 0x8096d(%rip), %rdx     # 0xdb30b
leaq 0x7d13a(%rip), %r8      # 0xd7adf
xorl %eax, %eax
callq 0xba00
movq %rbx, %rdi
callq 0xb260
pushq $0x1
popq %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x62675
addq $0x230, %rsp            # imm = 0x230
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq