// File: /workspace/github_c_makefile_star2_O2/genometools[P]genometools/src/annotationsketch/canvas.c
// Function: gt_format_ruler_label
void gt_format_ruler_label(char *txt, GtWord pos,
                           const char *unitstr, size_t buflen)
{
  double fpos;
  int logval;
  GtStr *formatstring;
  GtUword upos;
  gt_assert(txt);
  bool negative = false;

  if (pos < 0)
  {
    upos = (GtUword)-pos;
    negative = true;
    formatstring = gt_str_new_cstr("-%.");
  }
  else
  {
    upos = (GtUword)pos;
    formatstring = gt_str_new_cstr("%.");
  }
  logval = (int) floor(log10(upos));
  if (upos >= 1000000000)
  {
    fpos = (double) upos / 1000000000;
    while (upos % 10 == 0)
    {
      upos /= 10;
      logval--;
    }
    /*@ignore@*/
    gt_str_append_uword(formatstring, (GtUword) logval);
    gt_str_append_cstr(formatstring, "fG%s");
    (void) snprintf(txt, buflen, gt_str_get(formatstring), fpos, unitstr);
    /*@end@*/
  }
  else if (upos >= 1000000)
  {
    fpos = (double) upos / 1000000;
    while (upos % 10 == 0)
    {
      upos /= 10;
      logval--;
    }
    /*@ignore@*/
    gt_str_append_uword(formatstring, (GtUword) logval);
    gt_str_append_cstr(formatstring, "fM%s");
    (void) snprintf(txt, buflen, gt_str_get(formatstring), fpos, unitstr);
    /*@end@*/
  }
  else if (upos >= 1000)
  {
    fpos = (double) upos / 1000;
    while (upos % 10 == 0)
    {
      upos /= 10;
      logval--;
    }
    /*@ignore@*/
    gt_str_append_uword(formatstring, (GtUword) logval);
    gt_str_append_cstr(formatstring, "fk%s");
    (void) snprintf(txt, buflen, gt_str_get(formatstring), fpos, unitstr);
    /*@end@*/
  } else {
    /*@ignore@*/
    (void) snprintf(txt, buflen, " %s"GT_WU"%s", negative ? "-" : "", upos,
        unitstr);
    /*@end@*/
  }

  gt_str_delete(formatstring);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdi, %rdi
je 0x29dde
movq %rcx, %r15
movq %rdx, %rbx
movq %rsi, %rbp
movq %rdi, %r12
testq %rsi, %rsi
leaq 0xa9798(%rip), %rax     # 0xd33fc
leaq 0xa9792(%rip), %rdi     # 0xd33fd
cmovsq %rax, %rdi
movq %rsi, %r13
negq %r13
cmovsq %rsi, %r13
callq 0x13da9
movq %rax, %r14
cvtsi2sd %r13, %xmm0
movsd %xmm0, (%rsp)
callq 0xb2b0
callq 0xbab0
cvttsd2si %xmm0, %eax
cmpq $0x3b9aca00, %r13       # imm = 0x3B9ACA00
jb 0x29ce3
movslq %eax, %rsi
pushq $0xa
popq %rcx
movq %r13, %rax
xorl %edx, %edx
divq %rcx
testq %rdx, %rdx
jne 0x29cbd
movq %rax, %r13
decq %rsi
jmp 0x29ca8
movsd (%rsp), %xmm0
divsd 0xa96f6(%rip), %xmm0    # 0xd33c0
movsd %xmm0, (%rsp)
movq %r14, %rdi
callq 0x13ffe
leaq 0xa9722(%rip), %rsi     # 0xd3400
jmp 0x29d6f
cmpq $0xf4240, %r13          # imm = 0xF4240
jb 0x29d2a
movslq %eax, %rsi
pushq $0xa
popq %rcx
movq %r13, %rax
xorl %edx, %edx
divq %rcx
testq %rdx, %rdx
jne 0x29d07
movq %rax, %r13
decq %rsi
jmp 0x29cf2
movsd (%rsp), %xmm0
divsd 0xa96a4(%rip), %xmm0    # 0xd33b8
movsd %xmm0, (%rsp)
movq %r14, %rdi
callq 0x13ffe
leaq 0xa96dd(%rip), %rsi     # 0xd3405
jmp 0x29d6f
cmpq $0x3e8, %r13            # imm = 0x3E8
jb 0x29dad
movslq %eax, %rsi
pushq $0xa
popq %rcx
movq %r13, %rax
xorl %edx, %edx
divq %rcx
testq %rdx, %rdx
jne 0x29d4e
movq %rax, %r13
decq %rsi
jmp 0x29d39
movsd (%rsp), %xmm0
divsd 0xa9655(%rip), %xmm0    # 0xd33b0
movsd %xmm0, (%rsp)
movq %r14, %rdi
callq 0x13ffe
leaq 0xa969b(%rip), %rsi     # 0xd340a
movq %r14, %rdi
callq 0x13dd3
movq %r14, %rdi
callq 0x143d2
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
movsd (%rsp), %xmm0
movq %rbx, %rcx
movb $0x1, %al
callq 0xba00
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x152db
testq %rbp, %rbp
leaq 0xacf18(%rip), %rax     # 0xd6ccf
leaq 0xadd21(%rip), %rcx     # 0xd7adf
cmovsq %rax, %rcx
leaq 0xa9646(%rip), %rdx     # 0xd340f
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %r8
movq %rbx, %r9
xorl %eax, %eax
callq 0xba00
jmp 0x29d97
movq 0x1041d3(%rip), %rax    # 0x12dfb8
movq (%rax), %rdi
leaq 0xa0277(%rip), %rsi     # 0xca066
leaq 0xa9e10(%rip), %rdx     # 0xd3c06
leaq 0xa95cb(%rip), %rcx     # 0xd33c8
leaq 0xa95da(%rip), %r8      # 0xd33de
pushq $0x59
popq %r9
xorl %eax, %eax
callq 0xb8c0
callq 0xb300