const char *sim_fmt_secs(double seconds) {
  static char buf[60];
  char frac[16] = "";
  const char *sign = "";
  double val = seconds;
  double days, hours, mins, secs, msecs, usecs;
  if (val == 0.0)
    return "";
  if (val < 0.0) {
    sign = "-";
    val = -val;
  }
  days = floor(val / (24.0 * 60.0 * 60.0));
  val -= (days * 24.0 * 60.0 * 60.0);
  hours = floor(val / (60.0 * 60.0));
  val -= (hours * 60.0 * 60.0);
  mins = floor(val / 60.0);
  val -= (mins * 60.0);
  secs = floor(val);
  val -= secs;
  val *= 1000.0;
  msecs = floor(val);
  val -= msecs;
  val *= 1000.0;
  usecs = floor(val + 0.5);
  if (usecs == 1000.0) {
    usecs = 0.0;
    msecs += 1;
  }
  if ((msecs > 0.0) || (usecs > 0.0)) {
    sprintf(frac, ".%03.0f%03.0f", msecs, usecs);
    while (frac[strlen(frac) - 1] == '0')
      frac[strlen(frac) - 1] = '\0';
    if (strlen(frac) == 1)
      frac[0] = '\0';
  }
  if (days > 0)
    sprintf(buf, "%s%.0f day%s %02.0f:%02.0f:%02.0f%s hour%s", sign, days,
            (days != 1) ? "s" : "", hours, mins, secs, frac,
            (days == 1) ? "s" : "");
  else if (hours > 0)
    sprintf(buf, "%s%.0f:%02.0f:%02.0f%s hour", sign, hours, mins, secs, frac);
  else if (mins > 0)
    sprintf(buf, "%s%.0f:%02.0f%s minute", sign, mins, secs, frac);
  else if (secs > 0)
    sprintf(buf, "%s%.0f%s second", sign, secs, frac);
  else if (msecs > 0) {
    if (usecs > 0)
      sprintf(buf, "%s%.0f.%s msec", sign, msecs, frac + 4);
    else
      sprintf(buf, "%s%.0f msec", sign, msecs);
  } else
    sprintf(buf, "%s%.0f usec", sign, usecs);
  if (0 != strncmp("1 ", buf, 2))
    strcpy(&buf[strlen(buf)], "s");
  return buf;
}


x86 assembly (clang, -O0):
<sim_fmt_secs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movsd  %xmm0,-0x10(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <memset@plt>
lea    0xf5b(%rip),%rax
mov    %rax,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11ba <sim_fmt_secs+0x5a>
jp     11ba <sim_fmt_secs+0x5a>
lea    0xf2e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    169a <sim_fmt_secs+0x53a>
xorps  %xmm0,%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    11f4 <sim_fmt_secs+0x94>
lea    0xe69(%rip),%rax
mov    %rax,-0x28(%rbp)
movsd  -0x30(%rbp),%xmm0
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xe27(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1080 <floor@plt>
movsd  %xmm0,-0x38(%rbp)
movsd  0xe09(%rip),%xmm0
mulsd  -0x38(%rbp),%xmm0
movsd  0xdec(%rip),%xmm1
mulsd  %xmm1,%xmm0
movsd  -0x30(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xdc4(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xdb2(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1080 <floor@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  0xd94(%rip),%xmm0
mulsd  -0x40(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xd6b(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
movsd  0xd51(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1080 <floor@plt>
movsd  %xmm0,-0x48(%rbp)
movsd  -0x48(%rbp),%xmm0
movsd  -0x30(%rbp),%xmm1
movq   %xmm0,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm0
movsd  0xd1a(%rip),%xmm2
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1080 <floor@plt>
movsd  %xmm0,-0x50(%rbp)
movsd  -0x50(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xcd3(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
call   1080 <floor@plt>
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm1
movsd  -0x30(%rbp),%xmm0
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xc9f(%rip),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xc95(%rip),%xmm0
addsd  -0x30(%rbp),%xmm0
call   1080 <floor@plt>
movsd  %xmm0,-0x60(%rbp)
movsd  -0x60(%rbp),%xmm0
movsd  0xc71(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    13b9 <sim_fmt_secs+0x259>
jp     13b9 <sim_fmt_secs+0x259>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x60(%rbp)
movsd  0xc81(%rip),%xmm0
addsd  -0x58(%rbp),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  -0x58(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
ja     13dd <sim_fmt_secs+0x27d>
movsd  -0x60(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1447 <sim_fmt_secs+0x2e7>
lea    -0x20(%rbp),%rdi
movsd  -0x58(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
lea    0xc48(%rip),%rsi
mov    $0x2,%al
call   1070 <sprintf@plt>
lea    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%rax
movsbl -0x20(%rbp,%rax,1),%eax
cmp    $0x30,%eax
jne    142b <sim_fmt_secs+0x2cb>
lea    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
sub    $0x1,%rax
movb   $0x0,-0x20(%rbp,%rax,1)
jmp    13f9 <sim_fmt_secs+0x299>
lea    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x1,%rax
jne    1442 <sim_fmt_secs+0x2e2>
movb   $0x0,-0x20(%rbp)
jmp    1447 <sim_fmt_secs+0x2e7>
movsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    14eb <sim_fmt_secs+0x38b>
mov    -0x28(%rbp),%rdx
movsd  -0x38(%rbp),%xmm0
movsd  -0x38(%rbp),%xmm1
movsd  0xbc1(%rip),%xmm2
lea    0xc69(%rip),%rcx
lea    0xbf4(%rip),%rax
ucomisd %xmm2,%xmm1
setp   %dil
setne  %sil
or     %dil,%sil
cmovne %rax,%rcx
movsd  -0x40(%rbp),%xmm1
movsd  -0x48(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm3
lea    -0x20(%rbp),%r8
movsd  -0x38(%rbp),%xmm4
movsd  0xb80(%rip),%xmm5
lea    0xc28(%rip),%r9
lea    0xbb3(%rip),%rax
ucomisd %xmm5,%xmm4
setnp  %dil
sete   %sil
test   %dil,%sil
cmovne %rax,%r9
lea    0x2b88(%rip),%rdi
lea    0xb69(%rip),%rsi
mov    $0x4,%al
call   1070 <sprintf@plt>
jmp    1649 <sim_fmt_secs+0x4e9>
movsd  -0x40(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    152e <sim_fmt_secs+0x3ce>
mov    -0x28(%rbp),%rdx
movsd  -0x40(%rbp),%xmm0
movsd  -0x48(%rbp),%xmm1
movsd  -0x50(%rbp),%xmm2
lea    -0x20(%rbp),%rcx
lea    0x2b45(%rip),%rdi
lea    0xb51(%rip),%rsi
mov    $0x3,%al
call   1070 <sprintf@plt>
jmp    1644 <sim_fmt_secs+0x4e4>
movsd  -0x48(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    156c <sim_fmt_secs+0x40c>
mov    -0x28(%rbp),%rdx
movsd  -0x48(%rbp),%xmm0
movsd  -0x50(%rbp),%xmm1
lea    -0x20(%rbp),%rcx
lea    0x2b07(%rip),%rdi
lea    0xb2f(%rip),%rsi
mov    $0x2,%al
call   1070 <sprintf@plt>
jmp    163f <sim_fmt_secs+0x4df>
movsd  -0x50(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    15a5 <sim_fmt_secs+0x445>
mov    -0x28(%rbp),%rdx
movsd  -0x50(%rbp),%xmm0
lea    -0x20(%rbp),%rcx
lea    0x2ace(%rip),%rdi
lea    0xb0d(%rip),%rsi
mov    $0x1,%al
call   1070 <sprintf@plt>
jmp    163a <sim_fmt_secs+0x4da>
movsd  -0x58(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1617 <sim_fmt_secs+0x4b7>
movsd  -0x60(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    15f4 <sim_fmt_secs+0x494>
mov    -0x28(%rbp),%rdx
movsd  -0x58(%rbp),%xmm0
lea    -0x20(%rbp),%rcx
add    $0x4,%rcx
lea    0x2a7f(%rip),%rdi
lea    0xace(%rip),%rsi
mov    $0x1,%al
call   1070 <sprintf@plt>
jmp    1612 <sim_fmt_secs+0x4b2>
mov    -0x28(%rbp),%rdx
movsd  -0x58(%rbp),%xmm0
lea    0x2a5c(%rip),%rdi
lea    0xaba(%rip),%rsi
mov    $0x1,%al
call   1070 <sprintf@plt>
jmp    1635 <sim_fmt_secs+0x4d5>
mov    -0x28(%rbp),%rdx
movsd  -0x60(%rbp),%xmm0
lea    0x2a39(%rip),%rdi
lea    0xaa3(%rip),%rsi
mov    $0x1,%al
call   1070 <sprintf@plt>
jmp    163a <sim_fmt_secs+0x4da>
jmp    163f <sim_fmt_secs+0x4df>
jmp    1644 <sim_fmt_secs+0x4e4>
jmp    1649 <sim_fmt_secs+0x4e9>
lea    0xa8d(%rip),%rdi
lea    0x2a09(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %ecx,%eax
je     168f <sim_fmt_secs+0x52f>
lea    0x29ec(%rip),%rdi
call   1050 <strlen@plt>
lea    0x29e0(%rip),%rdi
add    %rax,%rdi
lea    0x9e7(%rip),%rsi
call   1040 <strcpy@plt>
lea    0x29ca(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sim_fmt_secs>:
push   %r15
push   %r14
push   %rbx
sub    $0x50,%rsp
xorpd  %xmm1,%xmm1
movapd %xmm1,0x30(%rsp)
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    115b <sim_fmt_secs+0x2b>
jp     115b <sim_fmt_secs+0x2b>
lea    0xefb(%rip),%rbx
jmp    14b9 <sim_fmt_secs+0x389>
ucomisd %xmm0,%xmm1
jbe    1169 <sim_fmt_secs+0x39>
xorpd  0xe97(%rip),%xmm0
movapd %xmm0,(%rsp)
lea    0xedb(%rip),%r14
lea    0xed5(%rip),%r15
cmovbe %r15,%r14
divsd  0xe88(%rip),%xmm0
call   1050 <floor@plt>
movsd  0xe83(%rip),%xmm1
movsd  %xmm0,0x28(%rsp)
mulsd  %xmm0,%xmm1
mulsd  0xe79(%rip),%xmm1
mulsd  0xe79(%rip),%xmm1
addsd  (%rsp),%xmm1
movsd  %xmm1,(%rsp)
movapd %xmm1,%xmm0
divsd  0xe6b(%rip),%xmm0
call   1050 <floor@plt>
movsd  %xmm0,0x48(%rsp)
mulsd  0xe48(%rip),%xmm0
movsd  0xe48(%rip),%xmm1
mulsd  %xmm1,%xmm0
addsd  (%rsp),%xmm0
movsd  %xmm0,(%rsp)
divsd  %xmm1,%xmm0
call   1050 <floor@plt>
movsd  %xmm0,0x40(%rsp)
movsd  0xe1b(%rip),%xmm1
mulsd  %xmm0,%xmm1
addsd  (%rsp),%xmm1
movsd  %xmm1,(%rsp)
movapd %xmm1,%xmm0
call   1050 <floor@plt>
movsd  %xmm0,0x20(%rsp)
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
mulsd  0xe05(%rip),%xmm1
movsd  %xmm1,(%rsp)
movapd %xmm1,%xmm0
call   1050 <floor@plt>
movsd  %xmm0,0x18(%rsp)
movsd  (%rsp),%xmm1
subsd  %xmm0,%xmm1
mulsd  0xde0(%rip),%xmm1
addsd  0xde0(%rip),%xmm1
movapd %xmm1,%xmm0
call   1050 <floor@plt>
movapd %xmm0,%xmm4
ucomisd 0xdc3(%rip),%xmm0
jne    1295 <sim_fmt_secs+0x165>
jp     1295 <sim_fmt_secs+0x165>
movsd  0x18(%rsp),%xmm3
addsd  0xdc1(%rip),%xmm3
movsd  0x28(%rsp),%xmm0
xorpd  %xmm1,%xmm1
je     12a7 <sim_fmt_secs+0x177>
jmp    12ad <sim_fmt_secs+0x17d>
movsd  0x28(%rsp),%xmm0
movsd  0x18(%rsp),%xmm3
xorpd  %xmm1,%xmm1
jne    12ad <sim_fmt_secs+0x17d>
jp     12ad <sim_fmt_secs+0x17d>
xorpd  %xmm4,%xmm4
ucomisd %xmm1,%xmm3
ja     12bd <sim_fmt_secs+0x18d>
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm4
jbe    1336 <sim_fmt_secs+0x206>
lea    0xd8e(%rip),%rsi
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
movsd  %xmm3,0x18(%rsp)
movapd %xmm3,%xmm0
movsd  %xmm4,(%rsp)
movapd %xmm4,%xmm1
mov    $0x2,%al
call   1040 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cmpb   $0x30,-0x1(%rax,%rbx,1)
jne    131a <sim_fmt_secs+0x1ea>
lea    (%rax,%rbx,1),%rcx
add    $0xffffffffffffffff,%rcx
nopl   (%rax)
movb   $0x0,(%rcx)
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    (%rax,%rbx,1),%rcx
add    $0xffffffffffffffff,%rcx
cmpb   $0x30,-0x1(%rax,%rbx,1)
je     1300 <sim_fmt_secs+0x1d0>
cmp    $0x1,%rax
movsd  0x28(%rsp),%xmm0
movsd  0x18(%rsp),%xmm3
movsd  (%rsp),%xmm4
jne    1336 <sim_fmt_secs+0x206>
movb   $0x0,0x30(%rsp)
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    1396 <sim_fmt_secs+0x266>
lea    0xd42(%rip),%r9
ucomisd 0xcf9(%rip),%xmm0
mov    %r15,%rcx
cmovne %r9,%rcx
cmovp  %r9,%rcx
cmovne %r15,%r9
cmovp  %r15,%r9
lea    0x2ce7(%rip),%rdi
lea    0xcf0(%rip),%rsi
lea    0x30(%rsp),%r8
mov    %r14,%rdx
movsd  0x48(%rsp),%xmm1
movsd  0x40(%rsp),%xmm2
movsd  0x20(%rsp),%xmm3
mov    $0x4,%al
call   1040 <sprintf@plt>
jmp    1496 <sim_fmt_secs+0x366>
movsd  0x48(%rsp),%xmm0
ucomisd %xmm1,%xmm0
jbe    13d0 <sim_fmt_secs+0x2a0>
lea    0x2ca7(%rip),%rdi
lea    0xcdb(%rip),%rsi
lea    0x30(%rsp),%rcx
mov    %r14,%rdx
movsd  0x40(%rsp),%xmm1
movsd  0x20(%rsp),%xmm2
mov    $0x3,%al
call   1040 <sprintf@plt>
jmp    1496 <sim_fmt_secs+0x366>
xorpd  %xmm2,%xmm2
movsd  0x40(%rsp),%xmm0
ucomisd %xmm2,%xmm0
jbe    1408 <sim_fmt_secs+0x2d8>
lea    0x2c69(%rip),%rdi
lea    0xcb9(%rip),%rsi
lea    0x30(%rsp),%rcx
mov    %r14,%rdx
movsd  0x20(%rsp),%xmm1
mov    $0x2,%al
call   1040 <sprintf@plt>
jmp    1496 <sim_fmt_secs+0x366>
movsd  0x20(%rsp),%xmm1
ucomisd %xmm2,%xmm1
jbe    1430 <sim_fmt_secs+0x300>
movapd %xmm1,%xmm0
lea    0x2c31(%rip),%rdi
lea    0xc98(%rip),%rsi
lea    0x30(%rsp),%rcx
mov    %r14,%rdx
jmp    145a <sim_fmt_secs+0x32a>
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm3
jbe    1463 <sim_fmt_secs+0x333>
ucomisd %xmm0,%xmm4
jbe    147a <sim_fmt_secs+0x34a>
lea    0x34(%rsp),%rcx
lea    0x2c04(%rip),%rdi
lea    0xc7b(%rip),%rsi
mov    %r14,%rdx
movapd %xmm3,%xmm0
mov    $0x1,%al
call   1040 <sprintf@plt>
jmp    1496 <sim_fmt_secs+0x366>
lea    0x2be6(%rip),%rdi
lea    0xc78(%rip),%rsi
mov    %r14,%rdx
movapd %xmm4,%xmm0
jmp    148f <sim_fmt_secs+0x35f>
lea    0x2bcf(%rip),%rdi
lea    0xc55(%rip),%rsi
mov    %r14,%rdx
movapd %xmm3,%xmm0
mov    $0x1,%al
call   1040 <sprintf@plt>
movzwl 0x2bb3(%rip),%eax
lea    0x2bac(%rip),%rbx
cmp    $0x2031,%eax
je     14b9 <sim_fmt_secs+0x389>
mov    %rbx,%rdi
call   1030 <strlen@plt>
movw   $0x73,(%rax,%rbx,1)
mov    %rbx,%rax
add    $0x50,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@sim_fmt_secs.buf = internal global [60 x i8] zeroinitializer
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [14 x i8] c".%03.0f%03.0f\00"
@.str.3 = [43 x i8] c"%s%.0f day%s %02.0f:%02.0f:%02.0f%s hour%s\00"
@.str.4 = [2 x i8] c"s\00"
@.str.5 = [28 x i8] c"%s%.0f:%02.0f:%02.0f%s hour\00"
@.str.6 = [23 x i8] c"%s%.0f:%02.0f%s minute\00"
@.str.7 = [16 x i8] c"%s%.0f%s second\00"
@.str.8 = [15 x i8] c"%s%.0f.%s msec\00"
@.str.9 = [12 x i8] c"%s%.0f msec\00"
@.str.10 = [12 x i8] c"%s%.0f usec\00"
@.str.11 = [3 x i8] c"1 \00"
define i8* @sim_fmt_secs(double %0) {
%2 = alloca i8*
%3 = alloca double
%4 = alloca [16 x i8]
%5 = alloca i8*
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca double
%12 = alloca double
store double %0, double* %3
%13 = bitcast [16 x i8]* %4 to i8*
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %5
%14 = load double, double* %3
store double %14, double* %6
%15 = load double, double* %6
%16 = fcmp oeq double %15, 0.000000e+00
br i1 %16, label %17, label %18
17: ; preds = %1
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %2
br label %181
18: ; preds = %1
%19 = load double, double* %6
%20 = fcmp olt double %19, 0.000000e+00
br i1 %20, label %21, label %24
21: ; preds = %18
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8** %5
%22 = load double, double* %6
%23 = fneg double %22
store double %23, double* %6
br label %24
24: ; preds = %21, %18
%25 = load double, double* %6
%26 = fdiv double %25, 8.640000e+04
%27 = call double @llvm.floor.f64(double %26)
store double %27, double* %7
%28 = load double, double* %7
%29 = fmul double %28, 2.400000e+01
%30 = fmul double %29, 6.000000e+01
%31 = load double, double* %6
%32 = fneg double %30
%33 = call double @llvm.fmuladd.f64(double %32, double 6.000000e+01, double %31)
store double %33, double* %6
%34 = load double, double* %6
%35 = fdiv double %34, 3.600000e+03
%36 = call double @llvm.floor.f64(double %35)
store double %36, double* %8
%37 = load double, double* %8
%38 = fmul double %37, 6.000000e+01
%39 = load double, double* %6
%40 = fneg double %38
%41 = call double @llvm.fmuladd.f64(double %40, double 6.000000e+01, double %39)
store double %41, double* %6
%42 = load double, double* %6
%43 = fdiv double %42, 6.000000e+01
%44 = call double @llvm.floor.f64(double %43)
store double %44, double* %9
%45 = load double, double* %9
%46 = load double, double* %6
%47 = fneg double %45
%48 = call double @llvm.fmuladd.f64(double %47, double 6.000000e+01, double %46)
store double %48, double* %6
%49 = load double, double* %6
%50 = call double @llvm.floor.f64(double %49)
store double %50, double* %10
%51 = load double, double* %10
%52 = load double, double* %6
%53 = fsub double %52, %51
store double %53, double* %6
%54 = load double, double* %6
%55 = fmul double %54, 1.000000e+03
store double %55, double* %6
%56 = load double, double* %6
%57 = call double @llvm.floor.f64(double %56)
store double %57, double* %11
%58 = load double, double* %11
%59 = load double, double* %6
%60 = fsub double %59, %58
store double %60, double* %6
%61 = load double, double* %6
%62 = fmul double %61, 1.000000e+03
store double %62, double* %6
%63 = load double, double* %6
%64 = fadd double %63, 5.000000e-01
%65 = call double @llvm.floor.f64(double %64)
store double %65, double* %12
%66 = load double, double* %12
%67 = fcmp oeq double %66, 1.000000e+03
br i1 %67, label %68, label %71
68: ; preds = %24
store double 0.000000e+00, double* %12
%69 = load double, double* %11
%70 = fadd double %69, 1.000000e+00
store double %70, double* %11
br label %71
71: ; preds = %68, %24
%72 = load double, double* %11
%73 = fcmp ogt double %72, 0.000000e+00
br i1 %73, label %77, label %74
74: ; preds = %71
%75 = load double, double* %12
%76 = fcmp ogt double %75, 0.000000e+00
br i1 %76, label %77, label %102
77: ; preds = %74, %71
%78 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%79 = load double, double* %11
%80 = load double, double* %12
%81 = call i32 (i8*, i8*, ...) @sprintf(i8* %78, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), double %79, double %80)
br label %82
82: ; preds = %90, %77
%83 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%84 = call i64 @strlen(i8* %83)
%85 = sub i64 %84, 1
%86 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 %85
%87 = load i8, i8* %86
%88 = sext i8 %87 to i32
%89 = icmp eq i32 %88, 48
br i1 %89, label %90, label %95
90: ; preds = %82
%91 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%92 = call i64 @strlen(i8* %91)
%93 = sub i64 %92, 1
%94 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 %93
store i8 0, i8* %94
br label %82
95: ; preds = %82
%96 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%97 = call i64 @strlen(i8* %96)
%98 = icmp eq i64 %97, 1
br i1 %98, label %99, label %101
99: ; preds = %95
%100 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
store i8 0, i8* %100
br label %101
101: ; preds = %99, %95
br label %102
102: ; preds = %101, %74
%103 = load double, double* %7
%104 = fcmp ogt double %103, 0.000000e+00
br i1 %104, label %105, label %121
105: ; preds = %102
%106 = load i8*, i8** %5
%107 = load double, double* %7
%108 = load double, double* %7
%109 = fcmp une double %108, 1.000000e+00
%110 = zext i1 %109 to i64
%111 = select i1 %109, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0)
%112 = load double, double* %8
%113 = load double, double* %9
%114 = load double, double* %10
%115 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%116 = load double, double* %7
%117 = fcmp oeq double %116, 1.000000e+00
%118 = zext i1 %117 to i64
%119 = select i1 %117, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0)
%120 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @sim_fmt_secs.buf, i64 0, i64 0), i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i8* %106, double %107, i8* %111, double %112, double %113, double %114, i8* %115, i8* %119)
br label %173
121: ; preds = %102
%122 = load double, double* %8
%123 = fcmp ogt double %122, 0.000000e+00
br i1 %123, label %124, label %131
124: ; preds = %121
%125 = load i8*, i8** %5
%126 = load double, double* %8
%127 = load double, double* %9
%128 = load double, double* %10
%129 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%130 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @sim_fmt_secs.buf, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i8* %125, double %126, double %127, double %128, i8* %129)
br label %172
131: ; preds = %121
%132 = load double, double* %9
%133 = fcmp ogt double %132, 0.000000e+00
br i1 %133, label %134, label %140
134: ; preds = %131
%135 = load i8*, i8** %5
%136 = load double, double* %9
%137 = load double, double* %10
%138 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%139 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @sim_fmt_secs.buf, i64 0, i64 0), i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %135, double %136, double %137, i8* %138)
br label %171
140: ; preds = %131
%141 = load double, double* %10
%142 = fcmp ogt double %141, 0.000000e+00
br i1 %142, label %143, label %148
143: ; preds = %140
%144 = load i8*, i8** %5
%145 = load double, double* %10
%146 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%147 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @sim_fmt_secs.buf, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* %144, double %145, i8* %146)
br label %170
148: ; preds = %140
%149 = load double, double* %11
%150 = fcmp ogt double %149, 0.000000e+00
br i1 %150, label %151, label %165
151: ; preds = %148
%152 = load double, double* %12
%153 = fcmp ogt double %152, 0.000000e+00
br i1 %153, label %154, label %160
154: ; preds = %151
%155 = load i8*, i8** %5
%156 = load double, double* %11
%157 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%158 = getelementptr inbounds i8, i8* %157, i64 4
%159 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @sim_fmt_secs.buf, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* %155, double %156, i8* %158)
br label %164
160: ; preds = %151
%161 = load i8*, i8** %5
%162 = load double, double* %11
%163 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @sim_fmt_secs.buf, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i8* %161, double %162)
br label %164
164: ; preds = %160, %154
br label %169
165: ; preds = %148
%166 = load i8*, i8** %5
%167 = load double, double* %12
%168 = call i32 (i8*, i8*, ...) @sprintf(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @sim_fmt_secs.buf, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i8* %166, double %167)
br label %169
169: ; preds = %165, %164
br label %170
170: ; preds = %169, %143
br label %171
171: ; preds = %170, %134
br label %172
172: ; preds = %171, %124
br label %173
173: ; preds = %172, %105
%174 = call i32 @strncmp(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([60 x i8], [60 x i8]* @sim_fmt_secs.buf, i64 0, i64 0), i64 2)
%175 = icmp ne i32 0, %174
br i1 %175, label %176, label %180
176: ; preds = %173
%177 = call i64 @strlen(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @sim_fmt_secs.buf, i64 0, i64 0))
%178 = getelementptr inbounds [60 x i8], [60 x i8]* @sim_fmt_secs.buf, i64 0, i64 %177
%179 = call i8* @strcpy(i8* %178, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %180
180: ; preds = %176, %173
store i8* getelementptr inbounds ([60 x i8], [60 x i8]* @sim_fmt_secs.buf, i64 0, i64 0), i8** %2
br label %181
181: ; preds = %180, %17
%182 = load i8*, i8** %2
ret i8* %182
}

LLVM IR (-O2):
@sim_fmt_secs.buf = internal global [60 x i8] zeroinitializer
@.str = [1 x i8] zeroinitializer
@.str.1 = [2 x i8] c"-\00"
@.str.2 = [14 x i8] c".%03.0f%03.0f\00"
@.str.3 = [43 x i8] c"%s%.0f day%s %02.0f:%02.0f:%02.0f%s hour%s\00"
@.str.4 = [2 x i8] c"s\00"
@.str.5 = [28 x i8] c"%s%.0f:%02.0f:%02.0f%s hour\00"
@.str.6 = [23 x i8] c"%s%.0f:%02.0f%s minute\00"
@.str.7 = [16 x i8] c"%s%.0f%s second\00"
@.str.8 = [15 x i8] c"%s%.0f.%s msec\00"
@.str.9 = [12 x i8] c"%s%.0f msec\00"
@.str.10 = [12 x i8] c"%s%.0f usec\00"
define i8* @sim_fmt_secs(double %0) {
%2 = alloca [16 x i8]
%3 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 0
%4 = fcmp oeq double %0, 0.000000e+00
br i1 %4, label %92, label %5
5: ; preds = %1
%6 = fcmp olt double %0, 0.000000e+00
%7 = fneg double %0
%8 = select i1 %6, double %7, double %0
%9 = select i1 %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0)
%10 = fdiv double %8, 8.640000e+04
%11 = tail call double @llvm.floor.f64(double %10)
%12 = fmul double %11, 2.400000e+01
%13 = fmul double %12, -6.000000e+01
%14 = tail call double @llvm.fmuladd.f64(double %13, double 6.000000e+01, double %8)
%15 = fdiv double %14, 3.600000e+03
%16 = tail call double @llvm.floor.f64(double %15)
%17 = fmul double %16, -6.000000e+01
%18 = tail call double @llvm.fmuladd.f64(double %17, double 6.000000e+01, double %14)
%19 = fdiv double %18, 6.000000e+01
%20 = tail call double @llvm.floor.f64(double %19)
%21 = fneg double %20
%22 = tail call double @llvm.fmuladd.f64(double %21, double 6.000000e+01, double %18)
%23 = tail call double @llvm.floor.f64(double %22)
%24 = fsub double %22, %23
%25 = fmul double %24, 1.000000e+03
%26 = tail call double @llvm.floor.f64(double %25)
%27 = fsub double %25, %26
%28 = fmul double %27, 1.000000e+03
%29 = fadd double %28, 5.000000e-01
%30 = tail call double @llvm.floor.f64(double %29)
%31 = fcmp oeq double %30, 1.000000e+03
%32 = fadd double %26, 1.000000e+00
%33 = select i1 %31, double %32, double %26
%34 = select i1 %31, double 0.000000e+00, double %30
%35 = fcmp ogt double %33, 0.000000e+00
%36 = fcmp ogt double %34, 0.000000e+00
%37 = select i1 %35, i1 true, i1 %36
br i1 %37, label %38, label %56
38: ; preds = %5
%39 = call i32 (i8*, i8*, ...) @sprintf(i8* %3, i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), double %33, double %34)
%40 = call i64 @strlen(i8* %3)
%41 = add i64 %40, -1
%42 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 %41
%43 = load i8, i8* %42
%44 = icmp eq i8 %43, 48
br i1 %44, label %45, label %52
45: ; preds = %38, %45
%46 = phi i8* [ %49, %45 ], [ %42, %38 ]
store i8 0, i8* %46
%47 = call i64 @strlen(i8* %3)
%48 = add i64 %47, -1
%49 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 %48
%50 = load i8, i8* %49
%51 = icmp eq i8 %50, 48
br i1 %51, label %45, label %52
52: ; preds = %45, %38
%53 = phi i64 [ %40, %38 ], [ %47, %45 ]
%54 = icmp eq i64 %53, 1
br i1 %54, label %55, label %56
55: ; preds = %52
store i8 0, i8* %3
br label %56
56: ; preds = %52, %55, %5
%57 = fcmp ogt double %11, 0.000000e+00
br i1 %57, label %58, label %64
58: ; preds = %56
%59 = fcmp une double %11, 1.000000e+00
%60 = select i1 %59, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0)
%61 = fcmp oeq double %11, 1.000000e+00
%62 = select i1 %61, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0)
%63 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @sim_fmt_secs.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i8* %9, double %11, i8* %60, double %16, double %20, double %23, i8* %3, i8* %62)
br label %85
64: ; preds = %56
%65 = fcmp ogt double %16, 0.000000e+00
br i1 %65, label %66, label %68
66: ; preds = %64
%67 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @sim_fmt_secs.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i8* %9, double %16, double %20, double %23, i8* %3)
br label %85
68: ; preds = %64
%69 = fcmp ogt double %20, 0.000000e+00
br i1 %69, label %70, label %72
70: ; preds = %68
%71 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @sim_fmt_secs.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %9, double %20, double %23, i8* %3)
br label %85
72: ; preds = %68
%73 = fcmp ogt double %23, 0.000000e+00
br i1 %73, label %74, label %76
74: ; preds = %72
%75 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @sim_fmt_secs.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0), i8* %9, double %23, i8* %3)
br label %85
76: ; preds = %72
br i1 %35, label %77, label %83
77: ; preds = %76
br i1 %36, label %78, label %81
78: ; preds = %77
%79 = getelementptr inbounds [16 x i8], [16 x i8]* %2, i64 0, i64 4
%80 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @sim_fmt_secs.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.8, i64 0, i64 0), i8* %9, double %33, i8* %79)
br label %85
81: ; preds = %77
%82 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @sim_fmt_secs.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.9, i64 0, i64 0), i8* %9, double %33)
br label %85
83: ; preds = %76
%84 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @sim_fmt_secs.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.10, i64 0, i64 0), i8* %9, double %34)
br label %85
85: ; preds = %66, %74, %78, %81, %83, %70, %58
%86 = load i16, i16* bitcast ([60 x i8]* @sim_fmt_secs.buf to i16*)
%87 = icmp eq i16 %86, 8241
br i1 %87, label %92, label %88
88: ; preds = %85
%89 = call i64 @strlen(i8* dereferenceable(1) getelementptr inbounds ([60 x i8], [60 x i8]* @sim_fmt_secs.buf, i64 0, i64 0))
%90 = getelementptr inbounds [60 x i8], [60 x i8]* @sim_fmt_secs.buf, i64 0, i64 %89
%91 = bitcast i8* %90 to i16*
store i16 115, i16* %91
br label %92
92: ; preds = %85, %88, %1
%93 = phi i8* [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([60 x i8], [60 x i8]* @sim_fmt_secs.buf, i64 0, i64 0), %88 ], [ getelementptr inbounds ([60 x i8], [60 x i8]* @sim_fmt_secs.buf, i64 0, i64 0), %85 ]
ret i8* %93
}