#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);
char *xmalloc(int);
char *usecs_to_str(unsigned long long usec) {
  char *size = xmalloc(sizeof(char) * 11);
  if (usec >= 86400000000ULL)
    snprintf(size, 11, "%.2f  d", (double)(usec) / 86400000000ULL);
  else 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)
movabs $0x141dd76000,%rax
cmp    %rax,-0x8(%rbp)
jb     119b <usecs_to_str+0x7b>
mov    -0x10(%rbp),%rdi
movaps 0xea7(%rip),%xmm1
movq   -0x8(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xea6(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xebf(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    $0xb,%esi
lea    0xeb7(%rip),%rdx
call   1030 <snprintf@plt>
jmp    1358 <usecs_to_str+0x238>
mov    $0xd693a400,%eax
cmp    %rax,-0x8(%rbp)
jb     11f7 <usecs_to_str+0xd7>
mov    -0x10(%rbp),%rdi
movaps 0xe4b(%rip),%xmm1
movq   -0x8(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xe4a(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe5b(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    $0xb,%esi
lea    0xe63(%rip),%rdx
call   1030 <snprintf@plt>
jmp    1353 <usecs_to_str+0x233>
cmpq   $0x3938700,-0x8(%rbp)
03
jb     1252 <usecs_to_str+0x132>
mov    -0x10(%rbp),%rdi
movaps 0xdf0(%rip),%xmm1
movq   -0x8(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xdef(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xdf8(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    $0xb,%esi
lea    0xe10(%rip),%rdx
call   1030 <snprintf@plt>
jmp    134e <usecs_to_str+0x22e>
cmpq   $0xf4240,-0x8(%rbp)
jb     12ad <usecs_to_str+0x18d>
mov    -0x10(%rbp),%rdi
movaps 0xd95(%rip),%xmm1
movq   -0x8(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xd94(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xd95(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    $0xb,%esi
lea    0xdbd(%rip),%rdx
call   1030 <snprintf@plt>
jmp    1349 <usecs_to_str+0x229>
cmpq   $0x3e8,-0x8(%rbp)
jb     1308 <usecs_to_str+0x1e8>
mov    -0x10(%rbp),%rdi
movaps 0xd3a(%rip),%xmm1
movq   -0x8(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xd39(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xd32(%rip),%xmm1
divsd  %xmm1,%xmm0
mov    $0xb,%esi
lea    0xd6a(%rip),%rdx
call   1030 <snprintf@plt>
jmp    1344 <usecs_to_str+0x224>
mov    -0x10(%rbp),%rdi
movaps 0xced(%rip),%xmm1
movq   -0x8(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xcec(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
mov    $0xb,%esi
lea    0xd31(%rip),%rdx
call   1030 <snprintf@plt>
jmp    1349 <usecs_to_str+0x229>
jmp    134e <usecs_to_str+0x22e>
jmp    1353 <usecs_to_str+0x233>
jmp    1358 <usecs_to_str+0x238>
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    $0xd,%rax
cmp    $0xa0eebb,%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  0xed4(%rip),%xmm0
lea    0xed5(%rip),%rdx
jmp    1274 <usecs_to_str+0x154>
mov    %rbx,%rax
shr    $0xa,%rax
cmp    $0x35a4e9,%rax
jb     11bc <usecs_to_str+0x9c>
movq   %rbx,%xmm1
punpckldq 0xe6c(%rip),%xmm1
subpd  0xe74(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
divsd  0xe88(%rip),%xmm0
lea    0xe99(%rip),%rdx
jmp    1274 <usecs_to_str+0x154>
cmp    $0x3938700,%rbx
jb     11f7 <usecs_to_str+0xd7>
movq   %rbx,%xmm1
punpckldq 0xe2e(%rip),%xmm1
subpd  0xe36(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
divsd  0xe42(%rip),%xmm0
lea    0xe63(%rip),%rdx
jmp    1274 <usecs_to_str+0x154>
cmp    $0xf4240,%rbx
jb     1232 <usecs_to_str+0x112>
movq   %rbx,%xmm1
punpckldq 0xdf3(%rip),%xmm1
subpd  0xdfb(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
divsd  0xdff(%rip),%xmm0
lea    0xe30(%rip),%rdx
jmp    1274 <usecs_to_str+0x154>
movq   %rbx,%xmm1
punpckldq 0xdc1(%rip),%xmm1
subpd  0xdc9(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
cmp    $0x3e8,%rbx
jb     126d <usecs_to_str+0x14d>
divsd  0xdbc(%rip),%xmm0
lea    0xdfd(%rip),%rdx
jmp    1274 <usecs_to_str+0x154>
lea    0xdfc(%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 d\00"
@.str.1 = [8 x i8] c"%.2f hr\00"
@.str.2 = [8 x i8] c"%.2f mn\00"
@.str.3 = [8 x i8] c"%.2f s\00"
@.str.4 = [8 x i8] c"%.2f ms\00"
@.str.5 = [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 i8* @xmalloc(i32 11)
store i8* %4, i8** %3
%5 = load i64, i64* %2
%6 = icmp uge i64 %5, 86400000000
br i1 %6, label %7, label %13
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = load i64, i64* %2
%10 = uitofp i64 %9 to double
%11 = fdiv double %10, 8.640000e+10
%12 = call i32 @snprintf(i8* %8, i32 11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), double %11)
br label %58
13: ; preds = %1
%14 = load i64, i64* %2
%15 = icmp uge i64 %14, 3600000000
br i1 %15, label %16, label %22
16: ; preds = %13
%17 = load i8*, i8** %3
%18 = load i64, i64* %2
%19 = uitofp i64 %18 to double
%20 = fdiv double %19, 3.600000e+09
%21 = call i32 @snprintf(i8* %17, i32 11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %20)
br label %57
22: ; preds = %13
%23 = load i64, i64* %2
%24 = icmp uge i64 %23, 60000000
br i1 %24, label %25, label %31
25: ; preds = %22
%26 = load i8*, i8** %3
%27 = load i64, i64* %2
%28 = uitofp i64 %27 to double
%29 = fdiv double %28, 6.000000e+07
%30 = call i32 @snprintf(i8* %26, i32 11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), double %29)
br label %56
31: ; preds = %22
%32 = load i64, i64* %2
%33 = icmp uge i64 %32, 1000000
br i1 %33, label %34, label %40
34: ; preds = %31
%35 = load i8*, i8** %3
%36 = load i64, i64* %2
%37 = uitofp i64 %36 to double
%38 = fdiv double %37, 1.000000e+06
%39 = call i32 @snprintf(i8* %35, i32 11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), double %38)
br label %55
40: ; preds = %31
%41 = load i64, i64* %2
%42 = icmp uge i64 %41, 1000
br i1 %42, label %43, label %49
43: ; preds = %40
%44 = load i8*, i8** %3
%45 = load i64, i64* %2
%46 = uitofp i64 %45 to double
%47 = fdiv double %46, 1.000000e+03
%48 = call i32 @snprintf(i8* %44, i32 11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), double %47)
br label %54
49: ; preds = %40
%50 = load i8*, i8** %3
%51 = load i64, i64* %2
%52 = uitofp i64 %51 to double
%53 = call i32 @snprintf(i8* %50, i32 11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), double %52)
br label %54
54: ; preds = %49, %43
br label %55
55: ; preds = %54, %34
br label %56
56: ; preds = %55, %25
br label %57
57: ; preds = %56, %16
br label %58
58: ; preds = %57, %7
%59 = load i8*, i8** %3
ret i8* %59
}

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