// File: /workspace/github_c_makefile_star2_O1/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 0x4ca08
movq %rcx, %r15
movq %rdx, %rbx
movq %rsi, %rbp
movq %rdi, %r12
testq %rsi, %rsi
leaq 0x9dc66(%rip), %rax     # 0xea45c
leaq 0x9dc60(%rip), %rdi     # 0xea45d
cmovsq %rax, %rdi
movq %rsi, %r13
negq %r13
cmovsq %rsi, %r13
callq 0x3c03d
movq %rax, %r14
cvtsi2sd %r13, %xmm0
movsd %xmm0, (%rsp)
callq 0xb2b0
callq 0xbac0
cvttsd2si %xmm0, %ecx
cmpq $0x3b9aca00, %r13       # imm = 0x3B9ACA00
jb 0x4c8a8
movsd (%rsp), %xmm0
divsd 0x9dbdf(%rip), %xmm0    # 0xea420
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 0x4c891
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 0x4c873
movslq %ecx, %rsi
movq %r14, %rdi
callq 0x3c1dc
leaq 0x9dbbd(%rip), %rsi     # 0xea460
jmp 0x4c999
movsd (%rsp), %xmm0
cmpq $0xf4240, %r13          # imm = 0xF4240
jb 0x4c922
divsd 0x9db5a(%rip), %xmm0    # 0xea418
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 0x4c90e
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 0x4c8f0
movslq %ecx, %rsi
movq %r14, %rdi
callq 0x3c1dc
leaq 0x9db45(%rip), %rsi     # 0xea465
jmp 0x4c999
cmpq $0x3e8, %r13            # imm = 0x3E8
jb 0x4c9d7
divsd 0x9dad9(%rip), %xmm0    # 0xea410
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 0x4c987
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 0x4c969
movslq %ecx, %rsi
movq %r14, %rdi
callq 0x3c1dc
leaq 0x9dad1(%rip), %rsi     # 0xea46a
movq %r14, %rdi
callq 0x3c067
movq %r14, %rdi
callq 0x3c40b
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 0x3d1eb
testq %rbp, %rbp
leaq 0xa138e(%rip), %rax     # 0xedd6f
leaq 0xa2197(%rip), %rcx     # 0xeeb7f
cmovsq %rax, %rcx
leaq 0x9da7c(%rip), %rdx     # 0xea46f
movq %r12, %rdi
movq %r15, %rsi
movq %r13, %r8
movq %rbx, %r9
xorl %eax, %eax
callq 0xba10
jmp 0x4c9c1
callq 0x154ec