#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 */
char *bc_strdup_printf(char *, long long, ...);
char *blogc_rusage_format_cpu_time(long long time) {
  if (time >= 1000000)
    return bc_strdup_printf("%.3fs", ((float)time) / 1000000.0);
  if (time >= 1000)
    return bc_strdup_printf("%.*fms", time % 1000 ? 3 : 0,
                            ((float)time) / 1000.0);
  return bc_strdup_printf("%dus", time);
}


x86 assembly (clang, -O0):
<blogc_rusage_format_cpu_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0xf4240,-0x10(%rbp)
jl     115c <blogc_rusage_format_cpu_time+0x4c>
cvtsi2ssq -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xecc(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%rsi
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <bc_strdup_printf@plt>
mov    %rax,-0x8(%rbp)
jmp    11cc <blogc_rusage_format_cpu_time+0xbc>
cmpq   $0x3e8,-0x10(%rbp)
jl     11b6 <blogc_rusage_format_cpu_time+0xa6>
mov    -0x10(%rbp),%rax
mov    $0x3e8,%ecx
cqto
idiv   %rcx
xor    %eax,%eax
mov    $0x3,%ecx
cmp    $0x0,%rdx
cmovne %ecx,%eax
movslq %eax,%rsi
cvtsi2ssq -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xe65(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe70(%rip),%rdi
mov    $0x1,%al
call   1030 <bc_strdup_printf@plt>
mov    %rax,-0x8(%rbp)
jmp    11cc <blogc_rusage_format_cpu_time+0xbc>
mov    -0x10(%rbp),%rsi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <bc_strdup_printf@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<blogc_rusage_format_cpu_time>:
mov    %rdi,%rax
cmp    $0xf4240,%rdi
jl     1140 <blogc_rusage_format_cpu_time+0x30>
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
divsd  0xedb(%rip),%xmm0
cvttsd2si %xmm0,%rsi
lea    0xed7(%rip),%rdi
xor    %eax,%eax
jmp    1030 <bc_strdup_printf@plt>
cmp    $0x3e8,%rax
jl     117f <blogc_rusage_format_cpu_time+0x6f>
imul   $0x26e978d5,%eax,%ecx
ror    $0x3,%ecx
xor    %edx,%edx
cmp    $0x418938,%ecx
setae  %dl
lea    (%rdx,%rdx,2),%rsi
cvtsi2ss %rax,%xmm0
cvtss2sd %xmm0,%xmm0
divsd  0xe8f(%rip),%xmm0
lea    0xe9e(%rip),%rdi
mov    $0x1,%al
jmp    1030 <bc_strdup_printf@plt>
lea    0xe97(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
jmp    1030 <bc_strdup_printf@plt>

LLVM IR (-O0):
@.str = [6 x i8] c"%.3fs\00"
@.str.1 = [7 x i8] c"%.*fms\00"
@.str.2 = [5 x i8] c"%dus\00"
define i8* @blogc_rusage_format_cpu_time(i64 %0) {
%2 = alloca i8*
%3 = alloca i64
store i64 %0, i64* %3
%4 = load i64, i64* %3
%5 = icmp sge i64 %4, 1000000
br i1 %5, label %6, label %13
6: ; preds = %1
%7 = load i64, i64* %3
%8 = sitofp i64 %7 to float
%9 = fpext float %8 to double
%10 = fdiv double %9, 1.000000e+06
%11 = fptosi double %10 to i64
%12 = call i8* (i8*, i64, ...) @bc_strdup_printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %11)
store i8* %12, i8** %2
br label %31
13: ; preds = %1
%14 = load i64, i64* %3
%15 = icmp sge i64 %14, 1000
br i1 %15, label %16, label %28
16: ; preds = %13
%17 = load i64, i64* %3
%18 = srem i64 %17, 1000
%19 = icmp ne i64 %18, 0
%20 = zext i1 %19 to i64
%21 = select i1 %19, i32 3, i32 0
%22 = sext i32 %21 to i64
%23 = load i64, i64* %3
%24 = sitofp i64 %23 to float
%25 = fpext float %24 to double
%26 = fdiv double %25, 1.000000e+03
%27 = call i8* (i8*, i64, ...) @bc_strdup_printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 %22, double %26)
store i8* %27, i8** %2
br label %31
28: ; preds = %13
%29 = load i64, i64* %3
%30 = call i8* (i8*, i64, ...) @bc_strdup_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %29)
store i8* %30, i8** %2
br label %31
31: ; preds = %28, %16, %6
%32 = load i8*, i8** %2
ret i8* %32
}

LLVM IR (-O2):
@.str = [6 x i8] c"%.3fs\00"
@.str.1 = [7 x i8] c"%.*fms\00"
@.str.2 = [5 x i8] c"%dus\00"
define i8* @blogc_rusage_format_cpu_time(i64 %0) {
%2 = icmp sgt i64 %0, 999999
br i1 %2, label %3, label %9
3: ; preds = %1
%4 = sitofp i64 %0 to float
%5 = fpext float %4 to double
%6 = fdiv double %5, 1.000000e+06
%7 = fptosi double %6 to i64
%8 = tail call i8* (i8*, i64, ...) @bc_strdup_printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i64 %7)
br label %22
9: ; preds = %1
%10 = icmp sgt i64 %0, 999
br i1 %10, label %11, label %20
11: ; preds = %9
%12 = trunc i64 %0 to i32
%13 = urem i32 %12, 1000
%14 = icmp eq i32 %13, 0
%15 = select i1 %14, i64 0, i64 3
%16 = sitofp i64 %0 to float
%17 = fpext float %16 to double
%18 = fdiv double %17, 1.000000e+03
%19 = tail call i8* (i8*, i64, ...) @bc_strdup_printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 %15, double %18)
br label %22
20: ; preds = %9
%21 = tail call i8* (i8*, i64, ...) @bc_strdup_printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %0)
br label %22
22: ; preds = %20, %11, %3
%23 = phi i8* [ %8, %3 ], [ %19, %11 ], [ %21, %20 ]
ret i8* %23
}