#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*/ snprintf(char *, int, char *, double);
scalar_t__ xmalloc(int);
char *usecs_to_str(unsigned long long usec) {
  char *size = (char *)xmalloc(sizeof(char) * 11);
  if (usec >= 3600000000ULL)
    snprintf(size, 11, "%.2f hr", (double)(usec) / 3600000000ULL);
  else if (usec >= 60000000ULL)
    snprintf(size, 11, "%.2f mn", (double)(usec) / 60000000ULL);
  else if (usec >= 1000000ULL)
    snprintf(size, 11, "%.2f  s", (double)(usec) / 1000000ULL);
  else if (usec >= 1000ULL)
    snprintf(size, 11, "%.2f ms", (double)(usec) / 1000ULL);
  else
    snprintf(size, 11, "%.2f us", (double)(usec));
  return size;
}


x86 assembly (clang, -O0):
<usecs_to_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0xb,%edi
call   1040 <xmalloc@plt>
mov    %rax,-0x10(%rbp)
mov    $0xd693a400,%eax
cmp    %rax,-0x8(%rbp)
jb     1196 <usecs_to_str+0x76>
mov    -0x10(%rbp),%rdi
movaps 0xeac(%rip),%xmm1
movq   -0x8(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xeab(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xebc(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    $0xb,%esi
lea    0xeb4(%rip),%rdx
call   1030 <snprintf@plt>
jmp    12f2 <usecs_to_str+0x1d2>
cmpq   $0x3938700,-0x8(%rbp)
03
jb     11f1 <usecs_to_str+0xd1>
mov    -0x10(%rbp),%rdi
movaps 0xe51(%rip),%xmm1
movq   -0x8(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xe50(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe59(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    $0xb,%esi
lea    0xe61(%rip),%rdx
call   1030 <snprintf@plt>
jmp    12ed <usecs_to_str+0x1cd>
cmpq   $0xf4240,-0x8(%rbp)
jb     124c <usecs_to_str+0x12c>
mov    -0x10(%rbp),%rdi
movaps 0xdf6(%rip),%xmm1
movq   -0x8(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xdf5(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xdf6(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    $0xb,%esi
lea    0xe0e(%rip),%rdx
call   1030 <snprintf@plt>
jmp    12e8 <usecs_to_str+0x1c8>
cmpq   $0x3e8,-0x8(%rbp)
jb     12a7 <usecs_to_str+0x187>
mov    -0x10(%rbp),%rdi
movaps 0xd9b(%rip),%xmm1
movq   -0x8(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xd9a(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xd93(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    $0xb,%esi
lea    0xdbb(%rip),%rdx
call   1030 <snprintf@plt>
jmp    12e3 <usecs_to_str+0x1c3>
mov    -0x10(%rbp),%rdi
movaps 0xd4e(%rip),%xmm1
movq   -0x8(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xd4d(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
mov    $0xb,%esi
lea    0xd82(%rip),%rdx
call   1030 <snprintf@plt>
jmp    12e8 <usecs_to_str+0x1c8>
jmp    12ed <usecs_to_str+0x1cd>
jmp    12f2 <usecs_to_str+0x1d2>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<usecs_to_str>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0xb,%edi
call   1040 <xmalloc@plt>
mov    %rax,%r14
mov    %rbx,%rax
shr    $0xa,%rax
cmp    $0x35a4e9,%rax
jb     1178 <usecs_to_str+0x58>
movq   %rbx,%xmm1
punpckldq 0xeb0(%rip),%xmm1
subpd  0xeb8(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
divsd  0xecc(%rip),%xmm0
lea    0xecd(%rip),%rdx
jmp    1230 <usecs_to_str+0x110>
cmp    $0x3938700,%rbx
jb     11b3 <usecs_to_str+0x93>
movq   %rbx,%xmm1
punpckldq 0xe72(%rip),%xmm1
subpd  0xe7a(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
divsd  0xe86(%rip),%xmm0
lea    0xe97(%rip),%rdx
jmp    1230 <usecs_to_str+0x110>
cmp    $0xf4240,%rbx
jb     11ee <usecs_to_str+0xce>
movq   %rbx,%xmm1
punpckldq 0xe37(%rip),%xmm1
subpd  0xe3f(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
divsd  0xe43(%rip),%xmm0
lea    0xe64(%rip),%rdx
jmp    1230 <usecs_to_str+0x110>
movq   %rbx,%xmm1
punpckldq 0xe05(%rip),%xmm1
subpd  0xe0d(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
cmp    $0x3e8,%rbx
jb     1229 <usecs_to_str+0x109>
divsd  0xe00(%rip),%xmm0
lea    0xe31(%rip),%rdx
jmp    1230 <usecs_to_str+0x110>
lea    0xe30(%rip),%rdx
mov    %r14,%rdi
mov    $0xb,%esi
call   1030 <snprintf@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [8 x i8] c"%.2f hr\00"
@.str.1 = [8 x i8] c"%.2f mn\00"
@.str.2 = [8 x i8] c"%.2f s\00"
@.str.3 = [8 x i8] c"%.2f ms\00"
@.str.4 = [8 x i8] c"%.2f us\00"
define i8* @usecs_to_str(i64 %0) {
%2 = alloca i64
%3 = alloca i8*
store i64 %0, i64* %2
%4 = call i64 @xmalloc(i32 11)
%5 = inttoptr i64 %4 to i8*
store i8* %5, i8** %3
%6 = load i64, i64* %2
%7 = icmp uge i64 %6, 3600000000
br i1 %7, label %8, label %14
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = load i64, i64* %2
%11 = uitofp i64 %10 to double
%12 = fdiv double %11, 3.600000e+09
%13 = call i32 @snprintf(i8* %9, i32 11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double %12)
br label %49
14: ; preds = %1
%15 = load i64, i64* %2
%16 = icmp uge i64 %15, 60000000
br i1 %16, label %17, label %23
17: ; preds = %14
%18 = load i8*, i8** %3
%19 = load i64, i64* %2
%20 = uitofp i64 %19 to double
%21 = fdiv double %20, 6.000000e+07
%22 = call i32 @snprintf(i8* %18, i32 11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %21)
br label %48
23: ; preds = %14
%24 = load i64, i64* %2
%25 = icmp uge i64 %24, 1000000
br i1 %25, label %26, label %32
26: ; preds = %23
%27 = load i8*, i8** %3
%28 = load i64, i64* %2
%29 = uitofp i64 %28 to double
%30 = fdiv double %29, 1.000000e+06
%31 = call i32 @snprintf(i8* %27, i32 11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), double %30)
br label %47
32: ; preds = %23
%33 = load i64, i64* %2
%34 = icmp uge i64 %33, 1000
br i1 %34, label %35, label %41
35: ; preds = %32
%36 = load i8*, i8** %3
%37 = load i64, i64* %2
%38 = uitofp i64 %37 to double
%39 = fdiv double %38, 1.000000e+03
%40 = call i32 @snprintf(i8* %36, i32 11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), double %39)
br label %46
41: ; preds = %32
%42 = load i8*, i8** %3
%43 = load i64, i64* %2
%44 = uitofp i64 %43 to double
%45 = call i32 @snprintf(i8* %42, i32 11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), double %44)
br label %46
46: ; preds = %41, %35
br label %47
47: ; preds = %46, %26
br label %48
48: ; preds = %47, %17
br label %49
49: ; preds = %48, %8
%50 = load i8*, i8** %3
ret i8* %50
}

LLVM IR (-O2):
@.str = [8 x i8] c"%.2f hr\00"
@.str.1 = [8 x i8] c"%.2f mn\00"
@.str.2 = [8 x i8] c"%.2f s\00"
@.str.3 = [8 x i8] c"%.2f ms\00"
@.str.4 = [8 x i8] c"%.2f us\00"
define i8* @usecs_to_str(i64 %0) {
%2 = tail call i64 @xmalloc(i32 11)
%3 = inttoptr i64 %2 to i8*
%4 = icmp ugt i64 %0, 3599999999
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = uitofp i64 %0 to double
%7 = fdiv double %6, 3.600000e+09
%8 = tail call i32 @snprintf(i8* %3, i32 11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double %7)
br label %29
9: ; preds = %1
%10 = icmp ugt i64 %0, 59999999
br i1 %10, label %11, label %15
11: ; preds = %9
%12 = uitofp i64 %0 to double
%13 = fdiv double %12, 6.000000e+07
%14 = tail call i32 @snprintf(i8* %3, i32 11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %13)
br label %29
15: ; preds = %9
%16 = icmp ugt i64 %0, 999999
br i1 %16, label %17, label %21
17: ; preds = %15
%18 = uitofp i64 %0 to double
%19 = fdiv double %18, 1.000000e+06
%20 = tail call i32 @snprintf(i8* %3, i32 11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), double %19)
br label %29
21: ; preds = %15
%22 = icmp ugt i64 %0, 999
%23 = uitofp i64 %0 to double
br i1 %22, label %24, label %27
24: ; preds = %21
%25 = fdiv double %23, 1.000000e+03
%26 = tail call i32 @snprintf(i8* %3, i32 11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), double %25)
br label %29
27: ; preds = %21
%28 = tail call i32 @snprintf(i8* %3, i32 11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), double %23)
br label %29
29: ; preds = %11, %24, %27, %17, %5
ret i8* %3
}