#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 */
scalar_t__ floor(double);
int /*<<< orphan*/ sprintf(char *, char *, int, ...);
char *smart_sprint_time(double x) {
  static char buf[128];
  if (x < 1.0E-6)
    sprintf(buf, "%f ns", x * 1.0E9);
  else if (x < 1.0E-3)
    sprintf(buf, "%f us", x * 1.0E6);
  else if (x < 1.0)
    sprintf(buf, "%f ms", x * 1.0E3);
  else if (x < 60.0)
    sprintf(buf, "%f s", x);
  else
    sprintf(buf, "%d h %d m %d s", (int)floor(x / 3600.0), ((int)x / 60 % 60),
            ((int)x % 60));
  return buf;
}


x86 assembly (clang, -O0):
<smart_sprint_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xecb(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    116b <smart_sprint_time+0x4b>
movsd  0xef0(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
cvttsd2si %xmm0,%edx
lea    0x2ee8(%rip),%rdi
lea    0xee1(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    1280 <smart_sprint_time+0x160>
movsd  0xe95(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    11a9 <smart_sprint_time+0x89>
movsd  0xeaa(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
cvttsd2si %xmm0,%edx
lea    0x2eaa(%rip),%rdi
lea    0xea9(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    127b <smart_sprint_time+0x15b>
movsd  0xe5f(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    11e7 <smart_sprint_time+0xc7>
movsd  0xe64(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
cvttsd2si %xmm0,%edx
lea    0x2e6c(%rip),%rdi
lea    0xe71(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    1276 <smart_sprint_time+0x156>
movsd  0xe29(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1219 <smart_sprint_time+0xf9>
cvttsd2si -0x8(%rbp),%edx
lea    0x2e3a(%rip),%rdi
lea    0xe45(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    1271 <smart_sprint_time+0x151>
movsd  -0x8(%rbp),%xmm0
movsd  0xdfa(%rip),%xmm1
divsd  %xmm1,%xmm0
call   1040 <floor@plt>
mov    %eax,-0xc(%rbp)
cvttsd2si -0x8(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
cvttsd2si -0x8(%rbp),%eax
mov    $0x3c,%esi
cltd
idiv   %esi
mov    %edx,%r8d
mov    -0xc(%rbp),%edx
lea    0x2ddd(%rip),%rdi
lea    0xded(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    1276 <smart_sprint_time+0x156>
jmp    127b <smart_sprint_time+0x15b>
jmp    1280 <smart_sprint_time+0x160>
lea    0x2db9(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<smart_sprint_time>:
push   %rax
movapd %xmm0,%xmm1
movsd  0xed3(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    114f <smart_sprint_time+0x2f>
mulsd  0xefd(%rip),%xmm1
cvttsd2si %xmm1,%edx
lea    0x2efa(%rip),%rdi
lea    0xef3(%rip),%rsi
jmp    11c3 <smart_sprint_time+0xa3>
movsd  0xeb1(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1179 <smart_sprint_time+0x59>
mulsd  0xecb(%rip),%xmm1
cvttsd2si %xmm1,%edx
lea    0x2ed0(%rip),%rdi
lea    0xecf(%rip),%rsi
jmp    11c3 <smart_sprint_time+0xa3>
movsd  0xe8f(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11a3 <smart_sprint_time+0x83>
mulsd  0xe99(%rip),%xmm1
cvttsd2si %xmm1,%edx
lea    0x2ea6(%rip),%rdi
lea    0xeab(%rip),%rsi
jmp    11c3 <smart_sprint_time+0xa3>
movsd  0xe6d(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11d3 <smart_sprint_time+0xb3>
cvttsd2si %xmm1,%edx
lea    0x2e84(%rip),%rdi
lea    0xe8f(%rip),%rsi
xor    %eax,%eax
call   1030 <sprintf@plt>
lea    0x2e6f(%rip),%rax
pop    %rcx
ret
movapd %xmm1,%xmm0
divsd  0xe41(%rip),%xmm0
movsd  %xmm1,(%rsp)
call   1040 <floor@plt>
cvttsd2si (%rsp),%ecx
movslq %ecx,%r8
imul   $0xffffffff88888889,%r8,%rcx
shr    $0x20,%rcx
add    %r8d,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x5,%ecx
add    %edx,%ecx
movslq %ecx,%rcx
imul   $0xffffffff88888889,%rcx,%rdx
shr    $0x20,%rdx
add    %ecx,%edx
mov    %edx,%esi
shr    $0x1f,%esi
sar    $0x5,%edx
add    %esi,%edx
imul   $0x3c,%edx,%edx
imul   $0x3c,%ecx,%esi
sub    %edx,%ecx
sub    %esi,%r8d
lea    0x2e0b(%rip),%rdi
lea    0xe1b(%rip),%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1030 <sprintf@plt>
jmp    11ca <smart_sprint_time+0xaa>

LLVM IR (-O0):
@smart_sprint_time.buf = internal global [128 x i8] zeroinitializer
@.str = [6 x i8] c"%f ns\00"
@.str.1 = [6 x i8] c"%f us\00"
@.str.2 = [6 x i8] c"%f ms\00"
@.str.3 = [5 x i8] c"%f s\00"
@.str.4 = [15 x i8] c"%d h %d m %d s\00"
define i8* @smart_sprint_time(double %0) {
%2 = alloca double
store double %0, double* %2
%3 = load double, double* %2
%4 = fcmp olt double %3, 0x3EB0C6F7A0B5ED8D
br i1 %4, label %5, label %10
5: ; preds = %1
%6 = load double, double* %2
%7 = fmul double %6, 1.000000e+09
%8 = fptosi double %7 to i32
%9 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @smart_sprint_time.buf, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %8)
br label %49
10: ; preds = %1
%11 = load double, double* %2
%12 = fcmp olt double %11, 1.000000e-03
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = load double, double* %2
%15 = fmul double %14, 1.000000e+06
%16 = fptosi double %15 to i32
%17 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @smart_sprint_time.buf, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %16)
br label %48
18: ; preds = %10
%19 = load double, double* %2
%20 = fcmp olt double %19, 1.000000e+00
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load double, double* %2
%23 = fmul double %22, 1.000000e+03
%24 = fptosi double %23 to i32
%25 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @smart_sprint_time.buf, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %24)
br label %47
26: ; preds = %18
%27 = load double, double* %2
%28 = fcmp olt double %27, 6.000000e+01
br i1 %28, label %29, label %33
29: ; preds = %26
%30 = load double, double* %2
%31 = fptosi double %30 to i32
%32 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @smart_sprint_time.buf, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %31)
br label %46
33: ; preds = %26
%34 = load double, double* %2
%35 = fdiv double %34, 3.600000e+03
%36 = call i64 @floor(double %35)
%37 = trunc i64 %36 to i32
%38 = load double, double* %2
%39 = fptosi double %38 to i32
%40 = sdiv i32 %39, 60
%41 = srem i32 %40, 60
%42 = load double, double* %2
%43 = fptosi double %42 to i32
%44 = srem i32 %43, 60
%45 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @smart_sprint_time.buf, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %37, i32 %41, i32 %44)
br label %46
46: ; preds = %33, %29
br label %47
47: ; preds = %46, %21
br label %48
48: ; preds = %47, %13
br label %49
49: ; preds = %48, %5
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @smart_sprint_time.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@smart_sprint_time.buf = internal global [128 x i8] zeroinitializer
@.str = [6 x i8] c"%f ns\00"
@.str.1 = [6 x i8] c"%f us\00"
@.str.2 = [6 x i8] c"%f ms\00"
@.str.3 = [5 x i8] c"%f s\00"
@.str.4 = [15 x i8] c"%d h %d m %d s\00"
define i8* @smart_sprint_time(double %0) {
%2 = fcmp olt double %0, 0x3EB0C6F7A0B5ED8D
br i1 %2, label %3, label %7
3: ; preds = %1
%4 = fmul double %0, 1.000000e+09
%5 = fptosi double %4 to i32
%6 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([128 x i8], [128 x i8]* @smart_sprint_time.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %33
7: ; preds = %1
%8 = fcmp olt double %0, 1.000000e-03
br i1 %8, label %9, label %13
9: ; preds = %7
%10 = fmul double %0, 1.000000e+06
%11 = fptosi double %10 to i32
%12 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([128 x i8], [128 x i8]* @smart_sprint_time.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %11)
br label %33
13: ; preds = %7
%14 = fcmp olt double %0, 1.000000e+00
br i1 %14, label %15, label %19
15: ; preds = %13
%16 = fmul double %0, 1.000000e+03
%17 = fptosi double %16 to i32
%18 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([128 x i8], [128 x i8]* @smart_sprint_time.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %17)
br label %33
19: ; preds = %13
%20 = fcmp olt double %0, 6.000000e+01
br i1 %20, label %21, label %24
21: ; preds = %19
%22 = fptosi double %0 to i32
%23 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([128 x i8], [128 x i8]* @smart_sprint_time.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %22)
br label %33
24: ; preds = %19
%25 = fdiv double %0, 3.600000e+03
%26 = tail call i64 @floor(double %25)
%27 = trunc i64 %26 to i32
%28 = fptosi double %0 to i32
%29 = sdiv i32 %28, 60
%30 = srem i32 %29, 60
%31 = srem i32 %28, 60
%32 = tail call i32 (i8*, i8*, i32, ...) @sprintf(i8* dereferenceable(1) getelementptr inbounds ([128 x i8], [128 x i8]* @smart_sprint_time.buf, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %27, i32 %30, i32 %31)
br label %33
33: ; preds = %9, %21, %24, %15, %3
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @smart_sprint_time.buf, i64 0, i64 0)
}