// File: /workspace/github_c_makefile_star2_O3/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 0x4bd72
movq %rcx, %r15
movq %rdx, %rbx
movq %rsi, %rbp
movq %rdi, %r12
testq %rsi, %rsi
leaq 0x9e89a(%rip), %rax     # 0xea40c
leaq 0x9e894(%rip), %rdi     # 0xea40d
cmovsq %rax, %rdi
movq %rsi, %r13
negq %r13
cmovsq %rsi, %r13
callq 0x3b785
movq %rax, %r14
cvtsi2sd %r13, %xmm0
movsd %xmm0, (%rsp)
callq 0xb2b0
callq 0xbac0
cvttsd2si %xmm0, %ecx
cmpq $0x3b9aca00, %r13       # imm = 0x3B9ACA00
jb 0x4bc24
movsd (%rsp), %xmm0
divsd 0x9e813(%rip), %xmm0    # 0xea3d0
movabsq $-0x3333333333333333, %rsi # imm = 0xCCCCCCCCCCCCCCCD
movq %r13, %rax
imulq %rsi, %rax
rorq %rax
movabsq $0x1999999999999999, %rdx # imm = 0x1999999999999999
cmpq %rdx, %rax
movsd %xmm0, (%rsp)
ja 0x4bc0d
movabsq $0x199999999999999a, %rdi # imm = 0x199999999999999A
movq %r13, %rax
mulq %rsi
movq %rdx, %r13
shrq $0x3, %r13
decl %ecx
movq %r13, %rax
imulq %rsi, %rax
rorq %rax
cmpq %rdi, %rax
jb 0x4bbef
movslq %ecx, %rsi
movq %r14, %rdi
callq 0x3b92e
leaq 0x9e7f1(%rip), %rsi     # 0xea410
jmp 0x4bd03
movsd (%rsp), %xmm0
cmpq $0xf4240, %r13          # imm = 0xF4240
jb 0x4bc95
divsd 0x9e78e(%rip), %xmm0    # 0xea3c8
imull $0xcccccccd, %r13d, %eax # imm = 0xCCCCCCCD
rorl %eax
cmpl $0x19999999, %eax       # imm = 0x19999999
movsd %xmm0, (%rsp)
ja 0x4bc81
movabsq $-0x3333333333333333, %rsi # imm = 0xCCCCCCCCCCCCCCCD
movabsq $0x199999999999999a, %rdi # imm = 0x199999999999999A
movq %r13, %rax
mulq %rsi
movq %rdx, %r13
shrq $0x3, %r13
decl %ecx
movq %r13, %rax
imulq %rsi, %rax
rorq %rax
cmpq %rdi, %rax
jb 0x4bc63
movslq %ecx, %rsi
movq %r14, %rdi
callq 0x3b92e
leaq 0x9e782(%rip), %rsi     # 0xea415
jmp 0x4bd03
cmpq $0x3e8, %r13            # imm = 0x3E8
jb 0x4bd41
divsd 0x9e716(%rip), %xmm0    # 0xea3c0
imull $0xcccccccd, %r13d, %eax # imm = 0xCCCCCCCD
rorl %eax
cmpl $0x19999999, %eax       # imm = 0x19999999
movsd %xmm0, (%rsp)
ja 0x4bcf1
movabsq $-0x3333333333333333, %rsi # imm = 0xCCCCCCCCCCCCCCCD
movabsq $0x199999999999999a, %rdi # imm = 0x199999999999999A
movq %r13, %rax
mulq %rsi
movq %rdx, %r13
shrq $0x3, %r13
decl %ecx
movq %r13, %rax
imulq %rsi, %rax
rorq %rax
cmpq %rdi, %rax
jb 0x4bcd3
movslq %ecx, %rsi
movq %r14, %rdi
callq 0x3b92e
leaq 0x9e717(%rip), %rsi     # 0xea41a
movq %r14, %rdi
callq 0x3b7af
movq %r14, %rdi
callq 0x3bb5d
movq %r12, %rdi
movq %r15, %rsi
movq %rax, %rdx
movsd (%rsp), %xmm0
movq %rbx, %rcx
movb $0x1, %al
callq 0xba10
movq %r14, %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3c87b
testq %rbp, %rbp
leaq 0xa1fdc(%rip), %rax     # 0xedd27
leaq 0xa2de5(%rip), %rcx     # 0xeeb37
cmovsq %rax, %rcx
leaq 0x9e6c2(%rip), %rdx     # 0xea41f
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %r8
movq %rbx, %r9
xorl %eax, %eax
callq 0xba10
jmp 0x4bd2b
callq 0x1539a