void format_time(double value, double *result, int *suffix) {
  if (value < 60) {
    *result = value;
    *suffix = 0;
  } else if (value < 3600) {
    *result = value / 60;
    *suffix = 1;
  } else if (value < 86400) {
    *result = value / 60 / 60;
    *suffix = 2;
  } else {
    *result = value / 60 / 60 / 24;
    *suffix = 3;
  }
}


x86 assembly (clang, -O0):
<format_time>:
push   %rbp
mov    %rsp,%rbp
movsd  %xmm0,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movsd  0xee7(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1140 <format_time+0x40>
movsd  -0x8(%rbp),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
jmp    1207 <format_time+0x107>
movsd  0xec0(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    117b <format_time+0x7b>
movsd  -0x8(%rbp),%xmm0
movsd  0xea0(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
jmp    1202 <format_time+0x102>
movsd  0xe8d(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    11c2 <format_time+0xc2>
movsd  -0x8(%rbp),%xmm0
movsd  0xe65(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe59(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x2,(%rax)
jmp    11fd <format_time+0xfd>
movsd  -0x8(%rbp),%xmm0
movsd  0xe31(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe25(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe31(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x3,(%rax)
jmp    1202 <format_time+0x102>
jmp    1207 <format_time+0x107>
pop    %rbp
ret

x86 assembly (clang, -O2):
<format_time>:
xor    %eax,%eax
movsd  0xef6(%rip),%xmm1
ucomisd %xmm0,%xmm1
ja     1155 <format_time+0x55>
movsd  0xef0(%rip),%xmm2
ucomisd %xmm0,%xmm2
jbe    112d <format_time+0x2d>
divsd  0xeda(%rip),%xmm0
mov    $0x1,%eax
jmp    1155 <format_time+0x55>
movsd  0xedb(%rip),%xmm2
ucomisd %xmm0,%xmm2
divsd  %xmm1,%xmm0
divsd  %xmm1,%xmm0
mov    $0x2,%eax
ja     1155 <format_time+0x55>
divsd  0xec8(%rip),%xmm0
mov    $0x3,%eax
movsd  %xmm0,(%rdi)
mov    %eax,(%rsi)
ret

LLVM IR (-O0):
define void @format_time(double %0, double* %1, i32* %2) {
%4 = alloca double
%5 = alloca double*
%6 = alloca i32*
store double %0, double* %4
store double* %1, double** %5
store i32* %2, i32** %6
%7 = load double, double* %4
%8 = fcmp olt double %7, 6.000000e+01
br i1 %8, label %9, label %13
9: ; preds = %3
%10 = load double, double* %4
%11 = load double*, double** %5
store double %10, double* %11
%12 = load i32*, i32** %6
store i32 0, i32* %12
br label %39
13: ; preds = %3
%14 = load double, double* %4
%15 = fcmp olt double %14, 3.600000e+03
br i1 %15, label %16, label %21
16: ; preds = %13
%17 = load double, double* %4
%18 = fdiv double %17, 6.000000e+01
%19 = load double*, double** %5
store double %18, double* %19
%20 = load i32*, i32** %6
store i32 1, i32* %20
br label %38
21: ; preds = %13
%22 = load double, double* %4
%23 = fcmp olt double %22, 8.640000e+04
br i1 %23, label %24, label %30
24: ; preds = %21
%25 = load double, double* %4
%26 = fdiv double %25, 6.000000e+01
%27 = fdiv double %26, 6.000000e+01
%28 = load double*, double** %5
store double %27, double* %28
%29 = load i32*, i32** %6
store i32 2, i32* %29
br label %37
30: ; preds = %21
%31 = load double, double* %4
%32 = fdiv double %31, 6.000000e+01
%33 = fdiv double %32, 6.000000e+01
%34 = fdiv double %33, 2.400000e+01
%35 = load double*, double** %5
store double %34, double* %35
%36 = load i32*, i32** %6
store i32 3, i32* %36
br label %37
37: ; preds = %30, %24
br label %38
38: ; preds = %37, %16
br label %39
39: ; preds = %38, %9
ret void
}

LLVM IR (-O2):
define void @format_time(double %0, double* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = fcmp olt double %0, 6.000000e+01
br i1 %4, label %15, label %5
5: ; preds = %3
%6 = fcmp olt double %0, 3.600000e+03
br i1 %6, label %7, label %9
7: ; preds = %5
%8 = fdiv double %0, 6.000000e+01
br label %15
9: ; preds = %5
%10 = fcmp olt double %0, 8.640000e+04
%11 = fdiv double %0, 6.000000e+01
%12 = fdiv double %11, 6.000000e+01
br i1 %10, label %15, label %13
13: ; preds = %9
%14 = fdiv double %12, 2.400000e+01
br label %15
15: ; preds = %9, %3, %7, %13
%16 = phi double [ %8, %7 ], [ %14, %13 ], [ %0, %3 ], [ %12, %9 ]
%17 = phi i32 [ 1, %7 ], [ 3, %13 ], [ 0, %3 ], [ 2, %9 ]
store double %16, double* %1
store i32 %17, i32* %2
ret void
}