#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 */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ sprintf(char *, char *, double);
char *int_counts(uint32_t count) {
  static char result[0x10];
  if (count < 1e3)
    sprintf(result, "%u", count);
  else if (count < 1e9)
    sprintf(result, "%.0fk", count / 1e3);
  else
    sprintf(result, "%.1G", (double)count);
  return result;
}


x86 assembly (clang, -O0):
<int_counts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xed8(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    114f <int_counts+0x3f>
cvtsi2sdl -0x4(%rbp),%xmm0
lea    0x2f02(%rip),%rdi
lea    0xecb(%rip),%rsi
call   1030 <sprintf@plt>
jmp    11ac <int_counts+0x9c>
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xeac(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    118f <int_counts+0x7f>
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xe8d(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0x2ec2(%rip),%rdi
lea    0xe8e(%rip),%rsi
call   1030 <sprintf@plt>
jmp    11a7 <int_counts+0x97>
cvtsi2sdl -0x4(%rbp),%xmm0
lea    0x2ea5(%rip),%rdi
lea    0xe77(%rip),%rsi
call   1030 <sprintf@plt>
jmp    11ac <int_counts+0x9c>
lea    0x2e8d(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<int_counts>:
push   %rax
cvtsi2sd %edi,%xmm0
cmp    $0x3e7,%edi
jg     112d <int_counts+0x1d>
lea    0x2f1c(%rip),%rdi
lea    0xedd(%rip),%rsi
jmp    115b <int_counts+0x4b>
cmp    $0x3b9ac9ff,%edi
ja     114d <int_counts+0x3d>
divsd  0xec3(%rip),%xmm0
lea    0x2efc(%rip),%rdi
lea    0xec0(%rip),%rsi
jmp    115b <int_counts+0x4b>
lea    0x2eec(%rip),%rdi
lea    0xeb6(%rip),%rsi
call   1030 <sprintf@plt>
lea    0x2ed9(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@int_counts.result = internal global [16 x i8] zeroinitializer
@.str = [3 x i8] c"%u\00"
@.str.1 = [6 x i8] c"%.0fk\00"
@.str.2 = [5 x i8] c"%.1G\00"
define i8* @int_counts(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = sitofp i32 %3 to double
%5 = fcmp olt double %4, 1.000000e+03
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = load i32, i32* %2
%8 = sitofp i32 %7 to double
%9 = call i32 @sprintf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @int_counts.result, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), double %8)
br label %24
10: ; preds = %1
%11 = load i32, i32* %2
%12 = sitofp i32 %11 to double
%13 = fcmp olt double %12, 1.000000e+09
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = load i32, i32* %2
%16 = sitofp i32 %15 to double
%17 = fdiv double %16, 1.000000e+03
%18 = call i32 @sprintf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @int_counts.result, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), double %17)
br label %23
19: ; preds = %10
%20 = load i32, i32* %2
%21 = sitofp i32 %20 to double
%22 = call i32 @sprintf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @int_counts.result, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %21)
br label %23
23: ; preds = %19, %14
br label %24
24: ; preds = %23, %6
ret i8* getelementptr inbounds ([16 x i8], [16 x i8]* @int_counts.result, i64 0, i64 0)
}

LLVM IR (-O2):
@int_counts.result = internal global [16 x i8] zeroinitializer
@.str = [3 x i8] c"%u\00"
@.str.1 = [6 x i8] c"%.0fk\00"
@.str.2 = [5 x i8] c"%.1G\00"
define i8* @int_counts(i32 %0) {
%2 = sitofp i32 %0 to double
%3 = icmp slt i32 %0, 1000
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @int_counts.result, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), double %2)
br label %13
6: ; preds = %1
%7 = icmp ult i32 %0, 1000000000
br i1 %7, label %8, label %11
8: ; preds = %6
%9 = fdiv double %2, 1.000000e+03
%10 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @int_counts.result, 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 ([16 x i8], [16 x i8]* @int_counts.result, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), double %2)
br label %13
13: ; preds = %8, %11, %4
ret i8* getelementptr inbounds ([16 x i8], [16 x i8]* @int_counts.result, i64 0, i64 0)
}