#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 */
typedef scalar_t__ uint64_t;

/* Variables and functions */
int /*<<< orphan*/ sprintf(char *, char *, double);
void csperf_stats_calculate_time_delta(char *buf, uint64_t end,
                                       uint64_t start) {
  double delta = (double)end - (double)start;
  if (delta < 1000) {
    sprintf(buf, "%.3f ms", delta);
  } else if ((delta /= 1000) < 60) {
    sprintf(buf, "%.3f s", delta);
  } else if ((delta /= 60) < 60) {
    sprintf(buf, "%.3f mins", delta);
  } else if ((delta /= 60) < 24) {
    sprintf(buf, "%.3f hours", delta);
  } else {
    delta /= 24;
    sprintf(buf, "%.3f days", delta);
  }
}


x86 assembly (clang, -O0):
<csperf_stats_calculate_time_delta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cvtsi2sdq -0x10(%rbp),%xmm0
cvtsi2sdq -0x18(%rbp),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xebf(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1166 <csperf_stats_calculate_time_delta+0x56>
mov    -0x8(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
lea    0xebc(%rip),%rsi
call   1030 <sprintf@plt>
jmp    1266 <csperf_stats_calculate_time_delta+0x156>
movsd  -0x20(%rbp),%xmm1
movsd  0xe8d(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,-0x20(%rbp)
movsd  0xe84(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11a8 <csperf_stats_calculate_time_delta+0x98>
mov    -0x8(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
lea    0xe82(%rip),%rsi
call   1030 <sprintf@plt>
jmp    1261 <csperf_stats_calculate_time_delta+0x151>
movsd  -0x20(%rbp),%xmm1
movsd  0xe53(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,-0x20(%rbp)
movsd  0xe42(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11ea <csperf_stats_calculate_time_delta+0xda>
mov    -0x8(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
lea    0xe47(%rip),%rsi
call   1030 <sprintf@plt>
jmp    125c <csperf_stats_calculate_time_delta+0x14c>
movsd  -0x20(%rbp),%xmm1
movsd  0xe11(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,-0x20(%rbp)
movsd  0xe08(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    122c <csperf_stats_calculate_time_delta+0x11c>
mov    -0x8(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
lea    0xe0f(%rip),%rsi
call   1030 <sprintf@plt>
jmp    1257 <csperf_stats_calculate_time_delta+0x147>
movsd  -0x20(%rbp),%xmm0
movsd  0xdd7(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
lea    0xdea(%rip),%rsi
call   1030 <sprintf@plt>
jmp    125c <csperf_stats_calculate_time_delta+0x14c>
jmp    1261 <csperf_stats_calculate_time_delta+0x151>
jmp    1266 <csperf_stats_calculate_time_delta+0x156>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<csperf_stats_calculate_time_delta>:
cvtsi2sd %rsi,%xmm0
cvtsi2sd %rdx,%xmm1
subsd  %xmm1,%xmm0
movsd  0xeda(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1138 <csperf_stats_calculate_time_delta+0x28>
lea    0xee5(%rip),%rsi
jmp    1030 <sprintf@plt>
divsd  0xec0(%rip),%xmm0
movsd  0xec0(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    115a <csperf_stats_calculate_time_delta+0x4a>
lea    0xecb(%rip),%rsi
jmp    1030 <sprintf@plt>
divsd  %xmm1,%xmm0
ucomisd %xmm0,%xmm1
jbe    1170 <csperf_stats_calculate_time_delta+0x60>
lea    0xebc(%rip),%rsi
jmp    1030 <sprintf@plt>
divsd  0xe90(%rip),%xmm0
movsd  0xe90(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1192 <csperf_stats_calculate_time_delta+0x82>
lea    0xea4(%rip),%rsi
jmp    1030 <sprintf@plt>
divsd  0xe76(%rip),%xmm0
lea    0xe9b(%rip),%rsi
jmp    1030 <sprintf@plt>

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

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