#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*/ printf(char *, int);
int label(int i) {
  if (i < 1e3)
    printf("%1dB,", i);
  else if (i < 1e6)
    printf("%1dK,", i / 1024);
  else if (i < 1e9)
    printf("%1dM,", i / 1048576);
  else
    printf("%1dG,", i / 1073741824);
  return 0;
}


x86 assembly (clang, -O0):
<label>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xed8(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    1146 <label+0x36>
mov    -0x4(%rbp),%esi
lea    0xedc(%rip),%rdi
call   1030 <printf@plt>
jmp    11d3 <label+0xc3>
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xeb5(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    117b <label+0x6b>
mov    -0x4(%rbp),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xead(%rip),%rdi
call   1030 <printf@plt>
jmp    11ce <label+0xbe>
cvtsi2sdl -0x4(%rbp),%xmm1
movsd  0xe88(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    11b0 <label+0xa0>
mov    -0x4(%rbp),%eax
mov    $0x100000,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe7e(%rip),%rdi
call   1030 <printf@plt>
jmp    11c9 <label+0xb9>
mov    -0x4(%rbp),%eax
mov    $0x40000000,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe66(%rip),%rdi
call   1030 <printf@plt>
jmp    11ce <label+0xbe>
jmp    11d3 <label+0xc3>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<label>:
push   %rax
mov    %edi,%esi
cmp    $0x3e7,%edi
jg     1124 <label+0x14>
lea    0xede(%rip),%rdi
jmp    1156 <label+0x46>
cmp    $0xf423f,%esi
ja     1138 <label+0x28>
shr    $0xa,%esi
lea    0xed0(%rip),%rdi
jmp    1156 <label+0x46>
cmp    $0x3b9ac9ff,%esi
ja     114c <label+0x3c>
shr    $0x14,%esi
lea    0xec2(%rip),%rdi
jmp    1156 <label+0x46>
shr    $0x1e,%esi
lea    0xebc(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"%1dB,\00"
@.str.1 = [6 x i8] c"%1dK,\00"
@.str.2 = [6 x i8] c"%1dM,\00"
@.str.3 = [6 x i8] c"%1dG,\00"
define i32 @label(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 %9
6: ; preds = %1
%7 = load i32, i32* %2
%8 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %31
9: ; preds = %1
%10 = load i32, i32* %2
%11 = sitofp i32 %10 to double
%12 = fcmp olt double %11, 1.000000e+06
br i1 %12, label %13, label %17
13: ; preds = %9
%14 = load i32, i32* %2
%15 = sdiv i32 %14, 1024
%16 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %15)
br label %30
17: ; preds = %9
%18 = load i32, i32* %2
%19 = sitofp i32 %18 to double
%20 = fcmp olt double %19, 1.000000e+09
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load i32, i32* %2
%23 = sdiv i32 %22, 1048576
%24 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %23)
br label %29
25: ; preds = %17
%26 = load i32, i32* %2
%27 = sdiv i32 %26, 1073741824
%28 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %25, %21
br label %30
30: ; preds = %29, %13
br label %31
31: ; preds = %30, %6
ret i32 0
}

LLVM IR (-O2):
@.str = [6 x i8] c"%1dB,\00"
@.str.1 = [6 x i8] c"%1dK,\00"
@.str.2 = [6 x i8] c"%1dM,\00"
@.str.3 = [6 x i8] c"%1dG,\00"
define i32 @label(i32 %0) {
%2 = icmp slt i32 %0, 1000
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %18
5: ; preds = %1
%6 = icmp ult i32 %0, 1000000
br i1 %6, label %7, label %10
7: ; preds = %5
%8 = lshr i32 %0, 10
%9 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %8)
br label %18
10: ; preds = %5
%11 = icmp ult i32 %0, 1000000000
br i1 %11, label %12, label %15
12: ; preds = %10
%13 = lshr i32 %0, 20
%14 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %13)
br label %18
15: ; preds = %10
%16 = lshr i32 %0, 30
%17 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %16)
br label %18
18: ; preds = %7, %15, %12, %3
ret i32 0
}