#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 uint64_t;

/* Variables and functions */
int /*<<< orphan*/ snprintf(char *, int, char *, float);
char *geek_print(uint64_t n) {
  static char buf[1024];
  if (n < 1024)
    snprintf(buf, 1024, "%llu", (unsigned long long)n);
  else if (n < 1048576)
    snprintf(buf, 1024, "%.2fK", (float)n / (float)1024);
  else if (n < 1073741824)
    snprintf(buf, 1024, "%.2fM", (float)n / (float)1048576);
  else
    snprintf(buf, 1024, "%.2fG", (float)n / (float)1073741824);
  return buf;
}


x86 assembly (clang, -O0):
<geek_print>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x400,-0x4(%rbp)
jge    1188 <geek_print+0x78>
movslq -0x4(%rbp),%rax
mov    %rax,%rsi
shr    %rsi
mov    %eax,%ecx
mov    %ecx,%edx
and    $0x1,%edx
or     %rsi,%rdx
cvtsi2ss %rdx,%xmm0
addss  %xmm0,%xmm0
cvtsi2ss %ecx,%xmm1
movss  %xmm1,-0xc(%rbp)
test   %rax,%rax
movss  %xmm0,-0x8(%rbp)
js     1166 <geek_print+0x56>
movss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
movss  -0x8(%rbp),%xmm0
lea    0x2ece(%rip),%rdi
mov    $0x400,%esi
lea    0xe8e(%rip),%rdx
call   1030 <snprintf@plt>
jmp    1231 <geek_print+0x121>
cmpl   $0x100000,-0x4(%rbp)
jge    11c3 <geek_print+0xb3>
cvtsi2ssl -0x4(%rbp),%xmm0
movss  0xe66(%rip),%xmm1
divss  %xmm1,%xmm0
lea    0x2e93(%rip),%rdi
mov    $0x400,%esi
lea    0xe58(%rip),%rdx
call   1030 <snprintf@plt>
jmp    122c <geek_print+0x11c>
cmpl   $0x40000000,-0x4(%rbp)
jge    11fe <geek_print+0xee>
cvtsi2ssl -0x4(%rbp),%xmm0
movss  0xe27(%rip),%xmm1
divss  %xmm1,%xmm0
lea    0x2e58(%rip),%rdi
mov    $0x400,%esi
lea    0xe23(%rip),%rdx
call   1030 <snprintf@plt>
jmp    1227 <geek_print+0x117>
cvtsi2ssl -0x4(%rbp),%xmm0
movss  0xdf5(%rip),%xmm1
divss  %xmm1,%xmm0
lea    0x2e2a(%rip),%rdi
mov    $0x400,%esi
lea    0xdfb(%rip),%rdx
call   1030 <snprintf@plt>
jmp    122c <geek_print+0x11c>
jmp    1231 <geek_print+0x121>
lea    0x2e08(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<geek_print>:
push   %rax
cmp    $0x3ff,%edi
jg     1127 <geek_print+0x17>
movslq %edi,%rax
test   %rax,%rax
js     114b <geek_print+0x3b>
cvtsi2ss %edi,%xmm0
jmp    115d <geek_print+0x4d>
cmp    $0xfffff,%edi
ja     116d <geek_print+0x5d>
cvtsi2ss %edi,%xmm0
mulss  0xecd(%rip),%xmm0
lea    0x2efe(%rip),%rdi
lea    0xec8(%rip),%rdx
jmp    11a7 <geek_print+0x97>
shr    %rax
and    $0x1,%edi
or     %rax,%rdi
cvtsi2ss %rdi,%xmm0
addss  %xmm0,%xmm0
lea    0x2edc(%rip),%rdi
lea    0xea1(%rip),%rdx
jmp    11a7 <geek_print+0x97>
cvtsi2ss %edi,%xmm0
cmp    $0x3fffffff,%edi
ja     1191 <geek_print+0x81>
mulss  0xe83(%rip),%xmm0
lea    0x2eb8(%rip),%rdi
lea    0xe88(%rip),%rdx
jmp    11a7 <geek_print+0x97>
mulss  0xe67(%rip),%xmm0
lea    0x2ea0(%rip),%rdi
lea    0xe76(%rip),%rdx
mov    $0x400,%esi
call   1030 <snprintf@plt>
lea    0x2e88(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@geek_print.buf = internal global [1024 x i8] zeroinitializer
@.str = [5 x i8] c"%llu\00"
@.str.1 = [6 x i8] c"%.2fK\00"
@.str.2 = [6 x i8] c"%.2fM\00"
@.str.3 = [6 x i8] c"%.2fG\00"
define i8* @geek_print(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp slt i32 %3, 1024
br i1 %4, label %5, label %10
5: ; preds = %1
%6 = load i32, i32* %2
%7 = sext i32 %6 to i64
%8 = uitofp i64 %7 to float
%9 = call i32 @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @geek_print.buf, i64 0, i64 0), i32 1024, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), float %8)
br label %33
10: ; preds = %1
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 1048576
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = load i32, i32* %2
%15 = sitofp i32 %14 to float
%16 = fdiv float %15, 1.024000e+03
%17 = call i32 @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @geek_print.buf, i64 0, i64 0), i32 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), float %16)
br label %32
18: ; preds = %10
%19 = load i32, i32* %2
%20 = icmp slt i32 %19, 1073741824
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load i32, i32* %2
%23 = sitofp i32 %22 to float
%24 = fdiv float %23, 0x4130000000000000
%25 = call i32 @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @geek_print.buf, i64 0, i64 0), i32 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), float %24)
br label %31
26: ; preds = %18
%27 = load i32, i32* %2
%28 = sitofp i32 %27 to float
%29 = fdiv float %28, 0x41D0000000000000
%30 = call i32 @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @geek_print.buf, i64 0, i64 0), i32 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), float %29)
br label %31
31: ; preds = %26, %21
br label %32
32: ; preds = %31, %13
br label %33
33: ; preds = %32, %5
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @geek_print.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@geek_print.buf = internal global [1024 x i8] zeroinitializer
@.str = [5 x i8] c"%llu\00"
@.str.1 = [6 x i8] c"%.2fK\00"
@.str.2 = [6 x i8] c"%.2fM\00"
@.str.3 = [6 x i8] c"%.2fG\00"
define i8* @geek_print(i32 %0) {
%2 = icmp slt i32 %0, 1024
br i1 %2, label %3, label %7
3: ; preds = %1
%4 = sext i32 %0 to i64
%5 = uitofp i64 %4 to float
%6 = tail call i32 @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @geek_print.buf, i64 0, i64 0), i32 1024, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), float %5)
br label %22
7: ; preds = %1
%8 = icmp ult i32 %0, 1048576
br i1 %8, label %9, label %13
9: ; preds = %7
%10 = sitofp i32 %0 to float
%11 = fmul float %10, 0x3F50000000000000
%12 = tail call i32 @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @geek_print.buf, i64 0, i64 0), i32 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), float %11)
br label %22
13: ; preds = %7
%14 = icmp ult i32 %0, 1073741824
%15 = sitofp i32 %0 to float
br i1 %14, label %16, label %19
16: ; preds = %13
%17 = fmul float %15, 0x3EB0000000000000
%18 = tail call i32 @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @geek_print.buf, i64 0, i64 0), i32 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), float %17)
br label %22
19: ; preds = %13
%20 = fmul float %15, 0x3E10000000000000
%21 = tail call i32 @snprintf(i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @geek_print.buf, i64 0, i64 0), i32 1024, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), float %20)
br label %22
22: ; preds = %9, %19, %16, %3
ret i8* getelementptr inbounds ([1024 x i8], [1024 x i8]* @geek_print.buf, i64 0, i64 0)
}