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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int prettyprint(uint64_t size) {
  if (size < 1024) {
    printf("%dB", (uint32_t)size);
  } else if (size < 1024 * 1024) {
    printf("%dk", (uint32_t)(size / 1024));
  } else if (size < 1024 * 1024 * 1024) {
    printf("%dM", (uint32_t)(size / (1024 * 1024)));
  } else if (size < 1024ULL * 1024ULL * 1024ULL * 1024ULL) {
    printf("%dG", (uint32_t)(size / (1024 * 1024 * 1024)));
  } else if (size < 1024ULL * 1024ULL * 1024ULL * 1024ULL * 1024ULL) {
    printf("%dT", (uint32_t)(size / (1024ULL * 1024ULL * 1024ULL * 1024ULL)));
  } else
    printf("HUGE!\n");
  return 0;
}


x86 assembly (clang, -O0):
<prettyprint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x400,-0x4(%rbp)
jge    113e <prettyprint+0x2e>
mov    -0x4(%rbp),%esi
lea    0xece(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1225 <prettyprint+0x115>
cmpl   $0x100000,-0x4(%rbp)
jge    116b <prettyprint+0x5b>
mov    -0x4(%rbp),%eax
mov    $0x400,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1220 <prettyprint+0x110>
cmpl   $0x40000000,-0x4(%rbp)
jge    1198 <prettyprint+0x88>
mov    -0x4(%rbp),%eax
mov    $0x100000,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    121b <prettyprint+0x10b>
movslq -0x4(%rbp),%rax
movabs $0x10000000000,%rcx
cmp    %rcx,%rax
jae    11cf <prettyprint+0xbf>
mov    -0x4(%rbp),%eax
mov    $0x40000000,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1216 <prettyprint+0x106>
movslq -0x4(%rbp),%rax
movabs $0x4000000000000,%rcx
cmp    %rcx,%rax
jae    1203 <prettyprint+0xf3>
movslq -0x4(%rbp),%rax
shr    $0x28,%rax
mov    %eax,%esi
lea    0xe19(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1211 <prettyprint+0x101>
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1216 <prettyprint+0x106>
jmp    121b <prettyprint+0x10b>
jmp    1220 <prettyprint+0x110>
jmp    1225 <prettyprint+0x115>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prettyprint>:
push   %rax
mov    %edi,%esi
cmp    $0x3ff,%edi
jg     1124 <prettyprint+0x14>
lea    0xede(%rip),%rdi
jmp    1158 <prettyprint+0x48>
cmp    $0xfffff,%esi
ja     1138 <prettyprint+0x28>
shr    $0xa,%esi
lea    0xece(%rip),%rdi
jmp    1158 <prettyprint+0x48>
cmp    $0x3fffffff,%esi
ja     114c <prettyprint+0x3c>
shr    $0x14,%esi
lea    0xebe(%rip),%rdi
jmp    1158 <prettyprint+0x48>
lea    0xeb9(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%dB\00"
@.str.1 = [4 x i8] c"%dk\00"
@.str.2 = [4 x i8] c"%dM\00"
@.str.3 = [4 x i8] c"%dG\00"
@.str.4 = [4 x i8] c"%dT\00"
@.str.5 = [7 x i8] c"HUGE!\0A\00"
define i32 @prettyprint(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 %8
5: ; preds = %1
%6 = load i32, i32* %2
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %6)
br label %46
8: ; preds = %1
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 1048576
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = load i32, i32* %2
%13 = sdiv i32 %12, 1024
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %13)
br label %45
15: ; preds = %8
%16 = load i32, i32* %2
%17 = icmp slt i32 %16, 1073741824
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load i32, i32* %2
%20 = sdiv i32 %19, 1048576
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %20)
br label %44
22: ; preds = %15
%23 = load i32, i32* %2
%24 = sext i32 %23 to i64
%25 = icmp ult i64 %24, 1099511627776
br i1 %25, label %26, label %30
26: ; preds = %22
%27 = load i32, i32* %2
%28 = sdiv i32 %27, 1073741824
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %28)
br label %43
30: ; preds = %22
%31 = load i32, i32* %2
%32 = sext i32 %31 to i64
%33 = icmp ult i64 %32, 1125899906842624
br i1 %33, label %34, label %40
34: ; preds = %30
%35 = load i32, i32* %2
%36 = sext i32 %35 to i64
%37 = udiv i64 %36, 1099511627776
%38 = trunc i64 %37 to i32
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %38)
br label %42
40: ; preds = %30
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0))
br label %42
42: ; preds = %40, %34
br label %43
43: ; preds = %42, %26
br label %44
44: ; preds = %43, %18
br label %45
45: ; preds = %44, %11
br label %46
46: ; preds = %45, %5
ret i32 0
}

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