#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 scalar_t__ uint64_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, unsigned long long);
void pretty_print_number(FILE *stream, uint64_t num) {
  unsigned long long value = (unsigned long long)num;
  if (value > 1024ULL * 1024 * 1024 * 1024 * 1024 * 1024) {
    value /= 1024ULL * 1024 * 1024 * 1024 * 1024 * 1024;
    fprintf(stream, "%lldEB", value);
  } else if (value > 1024ULL * 1024 * 1024 * 1024 * 1024) {
    value /= 1024ULL * 1024 * 1024 * 1024 * 1024;
    fprintf(stream, "%lldPB", value);
  } else if (value > 1024ULL * 1024 * 1024 * 1024) {
    value /= 1024ULL * 1024 * 1024 * 1024;
    fprintf(stream, "%lldTB", value);
  } else if (value > 1024ULL * 1024 * 1024) {
    value /= 1024ULL * 1024 * 1024;
    fprintf(stream, "%lldGB", value);
  } else if (value > 1024ULL * 1024) {
    value /= 1024ULL * 1024;
    fprintf(stream, "%lldMB", value);
  } else if (value > 1024ULL) {
    value /= 1024ULL;
    fprintf(stream, "%lldKB", value);
  } else {
    fprintf(stream, "%lldB", value);
  }
}


x86 assembly (clang, -O0):
<pretty_print_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
movabs $0x1000000000000000,%rax
cmp    %rax,-0x18(%rbp)
jbe    1161 <pretty_print_number+0x51>
mov    -0x18(%rbp),%rax
shr    $0x3c,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xea9(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1299 <pretty_print_number+0x189>
movabs $0x4000000000000,%rax
cmp    %rax,-0x18(%rbp)
jbe    119a <pretty_print_number+0x8a>
mov    -0x18(%rbp),%rax
shr    $0x32,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe77(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1294 <pretty_print_number+0x184>
movabs $0x10000000000,%rax
cmp    %rax,-0x18(%rbp)
jbe    11d3 <pretty_print_number+0xc3>
mov    -0x18(%rbp),%rax
shr    $0x28,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe45(%rip),%rsi
call   1030 <fprintf@plt>
jmp    128f <pretty_print_number+0x17f>
cmpq   $0x40000000,-0x18(%rbp)
40
jbe    1206 <pretty_print_number+0xf6>
mov    -0x18(%rbp),%rax
shr    $0x1e,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe19(%rip),%rsi
call   1030 <fprintf@plt>
jmp    128a <pretty_print_number+0x17a>
cmpq   $0x100000,-0x18(%rbp)
jbe    1239 <pretty_print_number+0x129>
mov    -0x18(%rbp),%rax
shr    $0x14,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xded(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1285 <pretty_print_number+0x175>
cmpq   $0x400,-0x18(%rbp)
jbe    126c <pretty_print_number+0x15c>
mov    -0x18(%rbp),%rax
shr    $0xa,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xdc1(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1280 <pretty_print_number+0x170>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xdaf(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1285 <pretty_print_number+0x175>
jmp    128a <pretty_print_number+0x17a>
jmp    128f <pretty_print_number+0x17f>
jmp    1294 <pretty_print_number+0x184>
jmp    1299 <pretty_print_number+0x189>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pretty_print_number>:
mov    %rsi,%rdx
movabs $0x1000000000000001,%rax
cmp    %rax,%rsi
jb     1132 <pretty_print_number+0x22>
shr    $0x3c,%rdx
lea    0xed3(%rip),%rsi
jmp    1030 <fprintf@plt>
movabs $0x4000000000001,%rax
cmp    %rax,%rdx
jb     1151 <pretty_print_number+0x41>
shr    $0x32,%rdx
lea    0xebb(%rip),%rsi
jmp    1030 <fprintf@plt>
movabs $0x10000000001,%rax
cmp    %rax,%rdx
jb     1170 <pretty_print_number+0x60>
shr    $0x28,%rdx
lea    0xea3(%rip),%rsi
jmp    1030 <fprintf@plt>
cmp    $0x40000001,%rdx
jb     1189 <pretty_print_number+0x79>
shr    $0x1e,%rdx
lea    0xe91(%rip),%rsi
jmp    1030 <fprintf@plt>
cmp    $0x100001,%rdx
jb     11a2 <pretty_print_number+0x92>
shr    $0x14,%rdx
lea    0xe7f(%rip),%rsi
jmp    1030 <fprintf@plt>
cmp    $0x401,%rdx
jb     11bb <pretty_print_number+0xab>
shr    $0xa,%rdx
lea    0xe6d(%rip),%rsi
jmp    1030 <fprintf@plt>
lea    0xe68(%rip),%rsi
jmp    1030 <fprintf@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"%lldEB\00"
@.str.1 = [7 x i8] c"%lldPB\00"
@.str.2 = [7 x i8] c"%lldTB\00"
@.str.3 = [7 x i8] c"%lldGB\00"
@.str.4 = [7 x i8] c"%lldMB\00"
@.str.5 = [7 x i8] c"%lldKB\00"
@.str.6 = [6 x i8] c"%lldB\00"
define void @pretty_print_number(i32* %0, i64 %1) {
%3 = alloca i32*
%4 = alloca i64
%5 = alloca i64
store i32* %0, i32** %3
store i64 %1, i64* %4
%6 = load i64, i64* %4
store i64 %6, i64* %5
%7 = load i64, i64* %5
%8 = icmp ugt i64 %7, 1152921504606846976
br i1 %8, label %9, label %15
9: ; preds = %2
%10 = load i64, i64* %5
%11 = udiv i64 %10, 1152921504606846976
store i64 %11, i64* %5
%12 = load i32*, i32** %3
%13 = load i64, i64* %5
%14 = call i32 @fprintf(i32* %12, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i64 %13)
br label %69
15: ; preds = %2
%16 = load i64, i64* %5
%17 = icmp ugt i64 %16, 1125899906842624
br i1 %17, label %18, label %24
18: ; preds = %15
%19 = load i64, i64* %5
%20 = udiv i64 %19, 1125899906842624
store i64 %20, i64* %5
%21 = load i32*, i32** %3
%22 = load i64, i64* %5
%23 = call i32 @fprintf(i32* %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 %22)
br label %68
24: ; preds = %15
%25 = load i64, i64* %5
%26 = icmp ugt i64 %25, 1099511627776
br i1 %26, label %27, label %33
27: ; preds = %24
%28 = load i64, i64* %5
%29 = udiv i64 %28, 1099511627776
store i64 %29, i64* %5
%30 = load i32*, i32** %3
%31 = load i64, i64* %5
%32 = call i32 @fprintf(i32* %30, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64 %31)
br label %67
33: ; preds = %24
%34 = load i64, i64* %5
%35 = icmp ugt i64 %34, 1073741824
br i1 %35, label %36, label %42
36: ; preds = %33
%37 = load i64, i64* %5
%38 = udiv i64 %37, 1073741824
store i64 %38, i64* %5
%39 = load i32*, i32** %3
%40 = load i64, i64* %5
%41 = call i32 @fprintf(i32* %39, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i64 %40)
br label %66
42: ; preds = %33
%43 = load i64, i64* %5
%44 = icmp ugt i64 %43, 1048576
br i1 %44, label %45, label %51
45: ; preds = %42
%46 = load i64, i64* %5
%47 = udiv i64 %46, 1048576
store i64 %47, i64* %5
%48 = load i32*, i32** %3
%49 = load i64, i64* %5
%50 = call i32 @fprintf(i32* %48, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i64 %49)
br label %65
51: ; preds = %42
%52 = load i64, i64* %5
%53 = icmp ugt i64 %52, 1024
br i1 %53, label %54, label %60
54: ; preds = %51
%55 = load i64, i64* %5
%56 = udiv i64 %55, 1024
store i64 %56, i64* %5
%57 = load i32*, i32** %3
%58 = load i64, i64* %5
%59 = call i32 @fprintf(i32* %57, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i64 %58)
br label %64
60: ; preds = %51
%61 = load i32*, i32** %3
%62 = load i64, i64* %5
%63 = call i32 @fprintf(i32* %61, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i64 %62)
br label %64
64: ; preds = %60, %54
br label %65
65: ; preds = %64, %45
br label %66
66: ; preds = %65, %36
br label %67
67: ; preds = %66, %27
br label %68
68: ; preds = %67, %18
br label %69
69: ; preds = %68, %9
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%lldEB\00"
@.str.1 = [7 x i8] c"%lldPB\00"
@.str.2 = [7 x i8] c"%lldTB\00"
@.str.3 = [7 x i8] c"%lldGB\00"
@.str.4 = [7 x i8] c"%lldMB\00"
@.str.5 = [7 x i8] c"%lldKB\00"
@.str.6 = [6 x i8] c"%lldB\00"
define void @pretty_print_number(i32* nocapture %0, i64 %1) {
%3 = icmp ugt i64 %1, 1152921504606846976
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = lshr i64 %1, 60
%6 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i64 %5)
br label %34
7: ; preds = %2
%8 = icmp ugt i64 %1, 1125899906842624
br i1 %8, label %9, label %12
9: ; preds = %7
%10 = lshr i64 %1, 50
%11 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i64 %10)
br label %34
12: ; preds = %7
%13 = icmp ugt i64 %1, 1099511627776
br i1 %13, label %14, label %17
14: ; preds = %12
%15 = lshr i64 %1, 40
%16 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i64 %15)
br label %34
17: ; preds = %12
%18 = icmp ugt i64 %1, 1073741824
br i1 %18, label %19, label %22
19: ; preds = %17
%20 = lshr i64 %1, 30
%21 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i64 %20)
br label %34
22: ; preds = %17
%23 = icmp ugt i64 %1, 1048576
br i1 %23, label %24, label %27
24: ; preds = %22
%25 = lshr i64 %1, 20
%26 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i64 %25)
br label %34
27: ; preds = %22
%28 = icmp ugt i64 %1, 1024
br i1 %28, label %29, label %32
29: ; preds = %27
%30 = lshr i64 %1, 10
%31 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i64 %30)
br label %34
32: ; preds = %27
%33 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0), i64 %1)
br label %34
34: ; preds = %9, %19, %29, %32, %24, %14, %4
ret void
}