#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 fmod(double, int);
int /*<<< orphan*/ sprintf(char *, char *, double, ...);
char *sprint_duration(char *string, double sec) {
  if (sec < 60.)
    sprintf(string, "%.0f sec", sec);
  else if (sec < 180.)
    sprintf(string, "%.1f min", sec / 60.);
  else if (sec < 3600.)
    sprintf(string, "%.0f min", sec / 60.);
  else if (sec < 86400.)
    sprintf(string, "%.1f hours", sec / 3600.);
  else if (sec < 2. * 86400.)
    sprintf(string, "1 day and %.1f hours", fmod(sec, 86400.) / 3600.);
  else if (sec < 90. * 86400.)
    sprintf(string, "%0.f days and %.1f hours", floor(sec / 86400.),
            fmod(sec, 86400.) / 3600.);
  else
    sprintf(string, "%.2f years", sec / (365.25 * 86400.));
  return string;
}


x86 assembly (clang, -O0):
<sprint_duration>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movsd  %xmm0,-0x10(%rbp)
movsd  0xeb7(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1170 <sprint_duration+0x40>
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
lea    0xed4(%rip),%rsi
mov    $0x1,%al
call   1040 <sprintf@plt>
jmp    131f <sprint_duration+0x1ef>
movsd  0xe90(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11ab <sprint_duration+0x7b>
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
movsd  0xe6c(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xea2(%rip),%rsi
mov    $0x1,%al
call   1040 <sprintf@plt>
jmp    131a <sprint_duration+0x1ea>
movsd  0xe5d(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11e6 <sprint_duration+0xb6>
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
movsd  0xe31(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe70(%rip),%rsi
mov    $0x1,%al
call   1040 <sprintf@plt>
jmp    1315 <sprint_duration+0x1e5>
movsd  0xe2a(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1221 <sprint_duration+0xf1>
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
movsd  0xe06(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe61(%rip),%rsi
mov    $0x1,%al
call   1040 <sprintf@plt>
jmp    1310 <sprint_duration+0x1e0>
movsd  0xdf7(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    1272 <sprint_duration+0x142>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    $0x15180,%edi
call   1030 <fmod@plt>
mov    -0x18(%rbp),%rdi
cvtsi2sd %eax,%xmm0
movsd  0xdb5(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xded(%rip),%rsi
mov    $0x1,%al
call   1040 <sprintf@plt>
jmp    130b <sprint_duration+0x1db>
movsd  0xdae(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    12e3 <sprint_duration+0x1b3>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xd7e(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1050 <floor@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x10(%rbp),%xmm0
mov    $0x15180,%edi
call   1030 <fmod@plt>
mov    -0x28(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
cvtsi2sd %eax,%xmm1
movsd  0xd44(%rip),%xmm2
divsd  %xmm2,%xmm1
lea    0xd91(%rip),%rsi
mov    $0x2,%al
call   1040 <sprintf@plt>
jmp    1306 <sprint_duration+0x1d6>
mov    -0x8(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
movsd  0xd3c(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xd82(%rip),%rsi
mov    $0x1,%al
call   1040 <sprintf@plt>
jmp    130b <sprint_duration+0x1db>
jmp    1310 <sprint_duration+0x1e0>
jmp    1315 <sprint_duration+0x1e5>
jmp    131a <sprint_duration+0x1ea>
jmp    131f <sprint_duration+0x1ef>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sprint_duration>:
push   %rbx
sub    $0x10,%rsp
movapd %xmm0,%xmm1
mov    %rdi,%rbx
movsd  0xebc(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1156 <sprint_duration+0x26>
lea    0xee7(%rip),%rsi
jmp    1263 <sprint_duration+0x133>
movsd  0xeaa(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1178 <sprint_duration+0x48>
divsd  0xe94(%rip),%xmm1
lea    0xece(%rip),%rsi
jmp    1263 <sprint_duration+0x133>
movsd  0xe90(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    119a <sprint_duration+0x6a>
divsd  0xe72(%rip),%xmm1
lea    0xeb5(%rip),%rsi
jmp    1263 <sprint_duration+0x133>
movsd  0xe76(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11bc <sprint_duration+0x8c>
divsd  0xe60(%rip),%xmm1
lea    0xebf(%rip),%rsi
jmp    1263 <sprint_duration+0x133>
movsd  0xe5c(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11f3 <sprint_duration+0xc3>
movapd %xmm1,%xmm0
mov    $0x15180,%edi
call   1030 <fmod@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
divsd  0xe29(%rip),%xmm0
lea    0xe65(%rip),%rsi
mov    %rbx,%rdi
jmp    126a <sprint_duration+0x13a>
movsd  0xe2d(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1254 <sprint_duration+0x124>
movapd %xmm1,%xmm0
divsd  0xe0b(%rip),%xmm0
movsd  %xmm1,(%rsp)
call   1050 <floor@plt>
movsd  %xmm0,0x8(%rsp)
movsd  (%rsp),%xmm0
mov    $0x15180,%edi
call   1030 <fmod@plt>
xorps  %xmm1,%xmm1
cvtsi2sd %eax,%xmm1
divsd  0xdd5(%rip),%xmm1
lea    0xe26(%rip),%rsi
mov    %rbx,%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x2,%al
call   1040 <sprintf@plt>
jmp    1271 <sprint_duration+0x141>
divsd  0xdd4(%rip),%xmm1
lea    0xe1e(%rip),%rsi
mov    %rbx,%rdi
movapd %xmm1,%xmm0
mov    $0x1,%al
call   1040 <sprintf@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [9 x i8] c"%.0f sec\00"
@.str.1 = [9 x i8] c"%.1f min\00"
@.str.2 = [9 x i8] c"%.0f min\00"
@.str.3 = [11 x i8] c"%.1f hours\00"
@.str.4 = [21 x i8] c"1 day and %.1f hours\00"
@.str.5 = [25 x i8] c"%0.f days and %.1f hours\00"
@.str.6 = [11 x i8] c"%.2f years\00"
define i8* @sprint_duration(i8* %0, double %1) {
%3 = alloca i8*
%4 = alloca double
store i8* %0, i8** %3
store double %1, double* %4
%5 = load double, double* %4
%6 = fcmp olt double %5, 6.000000e+01
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i8*, i8** %3
%9 = load double, double* %4
%10 = call i32 (i8*, i8*, double, ...) @sprintf(i8* %8, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), double %9)
br label %68
11: ; preds = %2
%12 = load double, double* %4
%13 = fcmp olt double %12, 1.800000e+02
br i1 %13, label %14, label %19
14: ; preds = %11
%15 = load i8*, i8** %3
%16 = load double, double* %4
%17 = fdiv double %16, 6.000000e+01
%18 = call i32 (i8*, i8*, double, ...) @sprintf(i8* %15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), double %17)
br label %67
19: ; preds = %11
%20 = load double, double* %4
%21 = fcmp olt double %20, 3.600000e+03
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = load i8*, i8** %3
%24 = load double, double* %4
%25 = fdiv double %24, 6.000000e+01
%26 = call i32 (i8*, i8*, double, ...) @sprintf(i8* %23, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), double %25)
br label %66
27: ; preds = %19
%28 = load double, double* %4
%29 = fcmp olt double %28, 8.640000e+04
br i1 %29, label %30, label %35
30: ; preds = %27
%31 = load i8*, i8** %3
%32 = load double, double* %4
%33 = fdiv double %32, 3.600000e+03
%34 = call i32 (i8*, i8*, double, ...) @sprintf(i8* %31, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), double %33)
br label %65
35: ; preds = %27
%36 = load double, double* %4
%37 = fcmp olt double %36, 1.728000e+05
br i1 %37, label %38, label %45
38: ; preds = %35
%39 = load i8*, i8** %3
%40 = load double, double* %4
%41 = call i32 @fmod(double %40, i32 86400)
%42 = sitofp i32 %41 to double
%43 = fdiv double %42, 3.600000e+03
%44 = call i32 (i8*, i8*, double, ...) @sprintf(i8* %39, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), double %43)
br label %64
45: ; preds = %35
%46 = load double, double* %4
%47 = fcmp olt double %46, 7.776000e+06
br i1 %47, label %48, label %58
48: ; preds = %45
%49 = load i8*, i8** %3
%50 = load double, double* %4
%51 = fdiv double %50, 8.640000e+04
%52 = call double @llvm.floor.f64(double %51)
%53 = load double, double* %4
%54 = call i32 @fmod(double %53, i32 86400)
%55 = sitofp i32 %54 to double
%56 = fdiv double %55, 3.600000e+03
%57 = call i32 (i8*, i8*, double, ...) @sprintf(i8* %49, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), double %52, double %56)
br label %63
58: ; preds = %45
%59 = load i8*, i8** %3
%60 = load double, double* %4
%61 = fdiv double %60, 3.155760e+07
%62 = call i32 (i8*, i8*, double, ...) @sprintf(i8* %59, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), double %61)
br label %63
63: ; preds = %58, %48
br label %64
64: ; preds = %63, %38
br label %65
65: ; preds = %64, %30
br label %66
66: ; preds = %65, %22
br label %67
67: ; preds = %66, %14
br label %68
68: ; preds = %67, %7
%69 = load i8*, i8** %3
ret i8* %69
}

LLVM IR (-O2):
@.str = [9 x i8] c"%.0f sec\00"
@.str.1 = [9 x i8] c"%.1f min\00"
@.str.2 = [9 x i8] c"%.0f min\00"
@.str.3 = [11 x i8] c"%.1f hours\00"
@.str.4 = [21 x i8] c"1 day and %.1f hours\00"
@.str.5 = [25 x i8] c"%0.f days and %.1f hours\00"
@.str.6 = [11 x i8] c"%.2f years\00"
define i8* @sprint_duration(i8* returned 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 ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), double %1)
br label %40
6: ; preds = %2
%7 = fcmp olt double %1, 1.800000e+02
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 ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), double %9)
br label %40
11: ; preds = %6
%12 = fcmp olt double %1, 3.600000e+03
br i1 %12, label %13, label %16
13: ; preds = %11
%14 = fdiv double %1, 6.000000e+01
%15 = tail call i32 (i8*, i8*, double, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), double %14)
br label %40
16: ; preds = %11
%17 = fcmp olt double %1, 8.640000e+04
br i1 %17, label %18, label %21
18: ; preds = %16
%19 = fdiv double %1, 3.600000e+03
%20 = tail call i32 (i8*, i8*, double, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), double %19)
br label %40
21: ; preds = %16
%22 = fcmp olt double %1, 1.728000e+05
br i1 %22, label %23, label %28
23: ; preds = %21
%24 = tail call i32 @fmod(double %1, i32 86400)
%25 = sitofp i32 %24 to double
%26 = fdiv double %25, 3.600000e+03
%27 = tail call i32 (i8*, i8*, double, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), double %26)
br label %40
28: ; preds = %21
%29 = fcmp olt double %1, 7.776000e+06
br i1 %29, label %30, label %37
30: ; preds = %28
%31 = fdiv double %1, 8.640000e+04
%32 = tail call double @llvm.floor.f64(double %31)
%33 = tail call i32 @fmod(double %1, i32 86400)
%34 = sitofp i32 %33 to double
%35 = fdiv double %34, 3.600000e+03
%36 = tail call i32 (i8*, i8*, double, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0), double %32, double %35)
br label %40
37: ; preds = %28
%38 = fdiv double %1, 3.155760e+07
%39 = tail call i32 (i8*, i8*, double, ...) @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), double %38)
br label %40
40: ; preds = %8, %18, %30, %37, %23, %13, %4
ret i8* %0
}