#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
double floor(double);
int /*<<< orphan*/ sprintf(char *, char *, double, ...);
void print_diff(char buf[64], double dt) {
  double days;
  if (dt < 60.)
    sprintf(buf, "%.0f seconds", dt);
  else if (dt < 3600.)
    sprintf(buf, "%.0f minutes", dt / 60.);
  else if (dt < 3600. * 24.)
    sprintf(buf, "%.0f hours", dt / 3600.);
  else if (dt < 3600. * 24. * 7.) {
    days = floor(dt / (3600. * 24.));
    sprintf(buf, "%.0f days %.0f hours", days, floor(dt / 3600.) - days * 24.);
  } else
    sprintf(buf, "%.0f days", dt / (3600. * 24.));
}


x86 assembly (clang, -O0):
<print_diff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  0xec7(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1160 <print_diff+0x40>
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
lea    0xed4(%rip),%rsi
mov    $0x1,%al
call   1030 <sprintf@plt>
jmp    12a9 <print_diff+0x189>
movsd  0xea0(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    119b <print_diff+0x7b>
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
movsd  0xe7c(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xea6(%rip),%rsi
mov    $0x1,%al
call   1030 <sprintf@plt>
jmp    12a4 <print_diff+0x184>
movsd  0xe6d(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11d6 <print_diff+0xb6>
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
movsd  0xe49(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe82(%rip),%rsi
mov    $0x1,%al
call   1030 <sprintf@plt>
jmp    129f <print_diff+0x17f>
movsd  0xe3a(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1277 <print_diff+0x157>
movsd  -0x10(%rbp),%xmm0
movsd  0xe1a(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <floor@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xde5(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <floor@plt>
mov    -0x28(%rbp),%rdi
movaps %xmm0,%xmm2
movsd  -0x20(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
movq   %xmm1,%rax
movabs $0x8000000000000000,%rcx
xor    %rcx,%rax
movq   %rax,%xmm1
movsd  0xdc4(%rip),%xmm3
mulsd  %xmm3,%xmm1
addsd  %xmm2,%xmm1
lea    0xdd7(%rip),%rsi
mov    $0x2,%al
call   1030 <sprintf@plt>
jmp    129a <print_diff+0x17a>
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
movsd  0xd88(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xdc4(%rip),%rsi
mov    $0x1,%al
call   1030 <sprintf@plt>
jmp    129f <print_diff+0x17f>
jmp    12a4 <print_diff+0x184>
jmp    12a9 <print_diff+0x189>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_diff>:
push   %rbx
sub    $0x10,%rsp
movapd %xmm0,%xmm1
mov    %rdi,%rbx
movsd  0xecc(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1143 <print_diff+0x23>
lea    0xee7(%rip),%rsi
jmp    117f <print_diff+0x5f>
movsd  0xebd(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1162 <print_diff+0x42>
divsd  0xea7(%rip),%xmm1
lea    0xed5(%rip),%rsi
jmp    117f <print_diff+0x5f>
movsd  0xea6(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1192 <print_diff+0x72>
divsd  0xe90(%rip),%xmm1
lea    0xecd(%rip),%rsi
mov    %rbx,%rdi
movapd %xmm1,%xmm0
mov    $0x1,%al
add    $0x10,%rsp
pop    %rbx
jmp    1030 <sprintf@plt>
movsd  0xe7e(%rip),%xmm0
ucomisd %xmm1,%xmm0
movapd %xmm1,%xmm0
divsd  0xe66(%rip),%xmm0
jbe    11fe <print_diff+0xde>
movsd  %xmm1,(%rsp)
call   1040 <floor@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
divsd  0xe3f(%rip),%xmm0
call   1040 <floor@plt>
movsd  0xe4a(%rip),%xmm1
movsd  0x8(%rsp),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
lea    0xe57(%rip),%rsi
mov    %rbx,%rdi
movapd %xmm2,%xmm0
mov    $0x2,%al
add    $0x10,%rsp
pop    %rbx
jmp    1030 <sprintf@plt>
lea    0xe52(%rip),%rsi
mov    %rbx,%rdi
jmp    1186 <print_diff+0x66>

LLVM IR (-O0):
@.str = [13 x i8] c"%.0f seconds\00"
@.str.1 = [13 x i8] c"%.0f minutes\00"
@.str.2 = [11 x i8] c"%.0f hours\00"
@.str.3 = [21 x i8] c"%.0f days %.0f hours\00"
@.str.4 = [10 x i8] c"%.0f days\00"
define void @print_diff(i8* %0, double %1) {
%3 = alloca i8*
%4 = alloca double
%5 = alloca double
store i8* %0, i8** %3
store double %1, double* %4
%6 = load double, double* %4
%7 = fcmp olt double %6, 6.000000e+01
br i1 %7, label %8, label %12
8: ; preds = %2
%9 = load i8*, i8** %3
%10 = load double, double* %4
%11 = call i32 (i8*, i8*, double, ...) @sprintf(i8* %9, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double %10)
br label %52
12: ; preds = %2
%13 = load double, double* %4
%14 = fcmp olt double %13, 3.600000e+03
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = load i8*, i8** %3
%17 = load double, double* %4
%18 = fdiv double %17, 6.000000e+01
%19 = call i32 (i8*, i8*, double, ...) @sprintf(i8* %16, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %18)
br label %51
20: ; preds = %12
%21 = load double, double* %4
%22 = fcmp olt double %21, 8.640000e+04
br i1 %22, label %23, label %28
23: ; preds = %20
%24 = load i8*, i8** %3
%25 = load double, double* %4
%26 = fdiv double %25, 3.600000e+03
%27 = call i32 (i8*, i8*, double, ...) @sprintf(i8* %24, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double %26)
br label %50
28: ; preds = %20
%29 = load double, double* %4
%30 = fcmp olt double %29, 6.048000e+05
br i1 %30, label %31, label %44
31: ; preds = %28
%32 = load double, double* %4
%33 = fdiv double %32, 8.640000e+04
%34 = call double @llvm.floor.f64(double %33)
store double %34, double* %5
%35 = load i8*, i8** %3
%36 = load double, double* %5
%37 = load double, double* %4
%38 = fdiv double %37, 3.600000e+03
%39 = call double @llvm.floor.f64(double %38)
%40 = load double, double* %5
%41 = fneg double %40
%42 = call double @llvm.fmuladd.f64(double %41, double 2.400000e+01, double %39)
%43 = call i32 (i8*, i8*, double, ...) @sprintf(i8* %35, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), double %36, double %42)
br label %49
44: ; preds = %28
%45 = load i8*, i8** %3
%46 = load double, double* %4
%47 = fdiv double %46, 8.640000e+04
%48 = call i32 (i8*, i8*, double, ...) @sprintf(i8* %45, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), double %47)
br label %49
49: ; preds = %44, %31
br label %50
50: ; preds = %49, %23
br label %51
51: ; preds = %50, %15
br label %52
52: ; preds = %51, %8
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"%.0f seconds\00"
@.str.1 = [13 x i8] c"%.0f minutes\00"
@.str.2 = [11 x i8] c"%.0f hours\00"
@.str.3 = [21 x i8] c"%.0f days %.0f hours\00"
@.str.4 = [10 x i8] c"%.0f days\00"
define void @print_diff(i8* nocapture writeonly %0, double %1) {
%3 = fcmp olt double %1, 6.000000e+01
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 (i8*, i8*, double, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), double %1)
br label %28
6: ; preds = %2
%7 = fcmp olt double %1, 3.600000e+03
br i1 %7, label %8, label %11
8: ; preds = %6
%9 = fdiv double %1, 6.000000e+01
%10 = tail call i32 (i8*, i8*, double, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), double %9)
br label %28
11: ; preds = %6
%12 = fcmp olt double %1, 8.640000e+04
br i1 %12, label %13, label %16
13: ; preds = %11
%14 = fdiv double %1, 3.600000e+03
%15 = tail call i32 (i8*, i8*, double, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double %14)
br label %28
16: ; preds = %11
%17 = fcmp olt double %1, 6.048000e+05
%18 = fdiv double %1, 8.640000e+04
br i1 %17, label %19, label %26
19: ; preds = %16
%20 = tail call double @llvm.floor.f64(double %18)
%21 = fdiv double %1, 3.600000e+03
%22 = tail call double @llvm.floor.f64(double %21)
%23 = fneg double %20
%24 = tail call double @llvm.fmuladd.f64(double %23, double 2.400000e+01, double %22)
%25 = tail call i32 (i8*, i8*, double, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0), double %20, double %24)
br label %28
26: ; preds = %16
%27 = tail call i32 (i8*, i8*, double, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0), double %18)
br label %28
28: ; preds = %8, %19, %26, %13, %4
ret void
}