#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*/ print(char *);
int /*<<< orphan*/ print_int(unsigned long);
void print_size(unsigned long size) {
  if (size < 1536) {
    print_int(size);
    print(" B");
  } else if (size < (1 << 20)) {
    print_int(size >> 10);
    print(" kB");
  } else {
    print_int(size >> 20);
    switch ((size >> 18) & 3) {
    case 1:
      print(".25");
      break;
    case 2:
      print(".5");
      break;
    case 3:
      print(".75");
      break;
    }
    print(" MB");
  }
}


x86 assembly (clang, -O0):
<print_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x600,-0x8(%rbp)
jae    1154 <print_size+0x34>
mov    -0x8(%rbp),%rdi
call   1040 <print_int@plt>
lea    0xeb6(%rip),%rdi
call   1030 <print@plt>
jmp    120f <print_size+0xef>
cmpq   $0x100000,-0x8(%rbp)
jae    1180 <print_size+0x60>
mov    -0x8(%rbp),%rdi
shr    $0xa,%rdi
call   1040 <print_int@plt>
lea    0xe8d(%rip),%rdi
call   1030 <print@plt>
jmp    120a <print_size+0xea>
mov    -0x8(%rbp),%rdi
shr    $0x14,%rdi
call   1040 <print_int@plt>
mov    -0x8(%rbp),%eax
shr    $0x12,%eax
and    $0x3,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x1,%eax
je     11d0 <print_size+0xb0>
jmp    11aa <print_size+0x8a>
mov    -0x10(%rbp),%rax
sub    $0x2,%rax
je     11e1 <print_size+0xc1>
jmp    11bd <print_size+0x9d>
mov    -0x10(%rbp),%rax
sub    $0x3,%rax
je     11f2 <print_size+0xd2>
jmp    11fe <print_size+0xde>
lea    0xe30(%rip),%rdi
call   1030 <print@plt>
jmp    11fe <print_size+0xde>
lea    0xe23(%rip),%rdi
call   1030 <print@plt>
jmp    11fe <print_size+0xde>
lea    0xe15(%rip),%rdi
call   1030 <print@plt>
lea    0xe0d(%rip),%rdi
call   1030 <print@plt>
jmp    120f <print_size+0xef>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_size>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
cmp    $0x5ff,%rdi
ja     1141 <print_size+0x21>
mov    %rbx,%rdi
call   1040 <print_int@plt>
lea    0xec1(%rip),%r14
jmp    1195 <print_size+0x75>
cmp    $0xfffff,%rbx
ja     115f <print_size+0x3f>
shr    $0xa,%rbx
mov    %rbx,%rdi
call   1040 <print_int@plt>
lea    0xea6(%rip),%r14
jmp    1195 <print_size+0x75>
mov    %rbx,%rdi
shr    $0x14,%rdi
call   1040 <print_int@plt>
shr    $0x12,%ebx
and    $0x3,%ebx
add    $0xffffffffffffffff,%rbx
lea    0xe96(%rip),%r14
cmp    $0x2,%rbx
ja     1195 <print_size+0x75>
lea    0xe8f(%rip),%rax
movslq (%rax,%rbx,4),%rdi
add    %rax,%rdi
call   1030 <print@plt>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <print@plt>

LLVM IR (-O0):
@.str = [3 x i8] c" B\00"
@.str.1 = [4 x i8] c" kB\00"
@.str.2 = [4 x i8] c".25\00"
@.str.3 = [3 x i8] c".5\00"
@.str.4 = [4 x i8] c".75\00"
@.str.5 = [4 x i8] c" MB\00"
define void @print_size(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
%4 = icmp ult i64 %3, 1536
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = load i64, i64* %2
%7 = call i32 @print_int(i64 %6)
%8 = call i32 @print(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %33
9: ; preds = %1
%10 = load i64, i64* %2
%11 = icmp ult i64 %10, 1048576
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = load i64, i64* %2
%14 = lshr i64 %13, 10
%15 = call i32 @print_int(i64 %14)
%16 = call i32 @print(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
br label %32
17: ; preds = %9
%18 = load i64, i64* %2
%19 = lshr i64 %18, 20
%20 = call i32 @print_int(i64 %19)
%21 = load i64, i64* %2
%22 = lshr i64 %21, 18
%23 = and i64 %22, 3
switch i64 %23, label %30 [
i64 1, label %24
i64 2, label %26
i64 3, label %28
]
24: ; preds = %17
%25 = call i32 @print(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %30
26: ; preds = %17
%27 = call i32 @print(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
br label %30
28: ; preds = %17
%29 = call i32 @print(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %30
30: ; preds = %17, %28, %26, %24
%31 = call i32 @print(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %32
32: ; preds = %30, %12
br label %33
33: ; preds = %32, %5
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c" B\00"
@.str.1 = [4 x i8] c" kB\00"
@.str.2 = [4 x i8] c".25\00"
@.str.3 = [3 x i8] c".5\00"
@.str.4 = [4 x i8] c".75\00"
@.str.5 = [4 x i8] c" MB\00"
@reltable.print_size = [3 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.2 to i64), i64 ptrtoint ([3 x i32]* @reltable.print_size to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.3 to i64), i64 ptrtoint ([3 x i32]* @reltable.print_size to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.4 to i64), i64 ptrtoint ([3 x i32]* @reltable.print_size to i64)) to i32)]
define void @print_size(i64 %0) {
%2 = icmp ult i64 %0, 1536
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @print_int(i64 %0)
br label %21
5: ; preds = %1
%6 = icmp ult i64 %0, 1048576
br i1 %6, label %7, label %10
7: ; preds = %5
%8 = lshr i64 %0, 10
%9 = tail call i32 @print_int(i64 %8)
br label %21
10: ; preds = %5
%11 = lshr i64 %0, 20
%12 = tail call i32 @print_int(i64 %11)
%13 = lshr i64 %0, 18
%14 = and i64 %13, 3
%15 = add nsw i64 %14, -1
%16 = icmp ult i64 %15, 3
br i1 %16, label %17, label %21
17: ; preds = %10
%18 = shl i64 %15, 2
%19 = call i8* @llvm.load.relative.i64(i8* bitcast ([3 x i32]* @reltable.print_size to i8*), i64 %18)
%20 = tail call i32 @print(i8* %19)
br label %21
21: ; preds = %10, %17, %7, %3
%22 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %7 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %3 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), %17 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), %10 ]
%23 = tail call i32 @print(i8* %22)
ret void
}