#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 */
int /*<<< orphan*/ sprintf(char *, char *, double);
char *smart_sprint_time(double x) {
  static char buf[128];
  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
    sprintf(buf, "%f s", x);
  return buf;
}


x86 assembly (clang, -O0):
<smart_sprint_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xedb(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1155 <smart_sprint_time+0x45>
movsd  0xee0(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
lea    0x2efc(%rip),%rdi
lea    0xed5(%rip),%rsi
call   1030 <sprintf@plt>
jmp    11aa <smart_sprint_time+0x9a>
movsd  0xeab(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    118d <smart_sprint_time+0x7d>
movsd  0xea0(%rip),%xmm0
mulsd  -0x8(%rbp),%xmm0
lea    0x2ec4(%rip),%rdi
lea    0xea3(%rip),%rsi
call   1030 <sprintf@plt>
jmp    11a5 <smart_sprint_time+0x95>
movsd  -0x8(%rbp),%xmm0
lea    0x2ea7(%rip),%rdi
lea    0xe8c(%rip),%rsi
call   1030 <sprintf@plt>
jmp    11aa <smart_sprint_time+0x9a>
lea    0x2e8f(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<smart_sprint_time>:
push   %rax
movsd  0xee7(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1137 <smart_sprint_time+0x27>
mulsd  0xef1(%rip),%xmm0
lea    0x2f12(%rip),%rdi
lea    0xeeb(%rip),%rsi
jmp    116b <smart_sprint_time+0x5b>
movsd  0xec9(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    115d <smart_sprint_time+0x4d>
mulsd  0xec3(%rip),%xmm0
lea    0x2eec(%rip),%rdi
lea    0xecb(%rip),%rsi
jmp    116b <smart_sprint_time+0x5b>
lea    0x2edc(%rip),%rdi
lea    0xec1(%rip),%rsi
call   1030 <sprintf@plt>
lea    0x2ec9(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@smart_sprint_time.buf = internal global [128 x i8] zeroinitializer
@.str = [6 x i8] c"%f us\00"
@.str.1 = [6 x i8] c"%f ms\00"
@.str.2 = [5 x i8] c"%f 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, 1.000000e-03
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = load double, double* %2
%7 = fmul double %6, 1.000000e+06
%8 = call 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), double %7)
br label %20
9: ; preds = %1
%10 = load double, double* %2
%11 = fcmp olt double %10, 1.000000e+00
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = load double, double* %2
%14 = fmul double %13, 1.000000e+03
%15 = call 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), double %14)
br label %19
16: ; preds = %9
%17 = load double, double* %2
%18 = call 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.2, i64 0, i64 0), double %17)
br label %19
19: ; preds = %16, %12
br label %20
20: ; preds = %19, %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 us\00"
@.str.1 = [6 x i8] c"%f ms\00"
@.str.2 = [5 x i8] c"%f s\00"
define i8* @smart_sprint_time(double %0) {
%2 = fcmp olt double %0, 1.000000e-03
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = fmul double %0, 1.000000e+06
%5 = tail call 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), double %4)
br label %13
6: ; preds = %1
%7 = fcmp olt double %0, 1.000000e+00
br i1 %7, label %8, label %11
8: ; preds = %6
%9 = fmul double %0, 1.000000e+03
%10 = tail call 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), double %9)
br label %13
11: ; preds = %6
%12 = tail call 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.2, i64 0, i64 0), double %0)
br label %13
13: ; preds = %8, %11, %3
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @smart_sprint_time.buf, i64 0, i64 0)
}