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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, double);
void printSize(off_t size) {
  if (size < 1024)
    printf("%8ld", size);
  else if (size < 1024 * 1024)
    printf("%7.1lfK", (double)size / 1024);
  else if (size < 1024 * 1024 * 1024)
    printf("%7.1lfM", (double)size / (1024 * 1024));
  else
    printf("%7.1lfG", (double)size / (1024 * 1024 * 1024));
}


x86 assembly (clang, -O0):
<printSize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x400,-0x4(%rbp)
jge    113e <printSize+0x2e>
cvtsi2sdl -0x4(%rbp),%xmm0
lea    0xee4(%rip),%rdi
call   1030 <printf@plt>
jmp    11c3 <printSize+0xb3>
cmpl   $0x100000,-0x4(%rbp)
jge    116d <printSize+0x5d>
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xeb8(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xeba(%rip),%rdi
call   1030 <printf@plt>
jmp    11be <printSize+0xae>
cmpl   $0x40000000,-0x4(%rbp)
jge    119c <printSize+0x8c>
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xe81(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe93(%rip),%rdi
call   1030 <printf@plt>
jmp    11b9 <printSize+0xa9>
cvtsi2sdl -0x4(%rbp),%xmm0
movsd  0xe57(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0xe79(%rip),%rdi
call   1030 <printf@plt>
jmp    11be <printSize+0xae>
jmp    11c3 <printSize+0xb3>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printSize>:
cmp    $0x3ff,%edi
jg     1128 <printSize+0x18>
cvtsi2sd %edi,%xmm0
lea    0xef5(%rip),%rdi
jmp    1030 <printf@plt>
cmp    $0xfffff,%edi
ja     1148 <printSize+0x38>
cvtsi2sd %edi,%xmm0
mulsd  0xed4(%rip),%xmm0
lea    0xeda(%rip),%rdi
jmp    1030 <printf@plt>
cvtsi2sd %edi,%xmm0
cmp    $0x3fffffff,%edi
ja     1168 <printSize+0x58>
mulsd  0xeac(%rip),%xmm0
lea    0xec2(%rip),%rdi
jmp    1030 <printf@plt>
mulsd  0xe90(%rip),%xmm0
lea    0xeb6(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%8ld\00"
@.str.1 = [8 x i8] c"%7.1lfK\00"
@.str.2 = [8 x i8] c"%7.1lfM\00"
@.str.3 = [8 x i8] c"%7.1lfG\00"
define void @printSize(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 %9
5: ; preds = %1
%6 = load i32, i32* %2
%7 = sitofp i32 %6 to double
%8 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %7)
br label %32
9: ; preds = %1
%10 = load i32, i32* %2
%11 = icmp slt i32 %10, 1048576
br i1 %11, label %12, label %17
12: ; preds = %9
%13 = load i32, i32* %2
%14 = sitofp i32 %13 to double
%15 = fdiv double %14, 1.024000e+03
%16 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %15)
br label %31
17: ; preds = %9
%18 = load i32, i32* %2
%19 = icmp slt i32 %18, 1073741824
br i1 %19, label %20, label %25
20: ; preds = %17
%21 = load i32, i32* %2
%22 = sitofp i32 %21 to double
%23 = fdiv double %22, 0x4130000000000000
%24 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), double %23)
br label %30
25: ; preds = %17
%26 = load i32, i32* %2
%27 = sitofp i32 %26 to double
%28 = fdiv double %27, 0x41D0000000000000
%29 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), double %28)
br label %30
30: ; preds = %25, %20
br label %31
31: ; preds = %30, %12
br label %32
32: ; preds = %31, %5
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%8ld\00"
@.str.1 = [8 x i8] c"%7.1lfK\00"
@.str.2 = [8 x i8] c"%7.1lfM\00"
@.str.3 = [8 x i8] c"%7.1lfG\00"
define void @printSize(i32 %0) {
%2 = icmp slt i32 %0, 1024
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = sitofp i32 %0 to double
%5 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), double %4)
br label %21
6: ; preds = %1
%7 = icmp ult i32 %0, 1048576
br i1 %7, label %8, label %12
8: ; preds = %6
%9 = sitofp i32 %0 to double
%10 = fmul double %9, 0x3F50000000000000
%11 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), double %10)
br label %21
12: ; preds = %6
%13 = icmp ult i32 %0, 1073741824
%14 = sitofp i32 %0 to double
br i1 %13, label %15, label %18
15: ; preds = %12
%16 = fmul double %14, 0x3EB0000000000000
%17 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), double %16)
br label %21
18: ; preds = %12
%19 = fmul double %14, 0x3E10000000000000
%20 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), double %19)
br label %21
21: ; preds = %8, %18, %15, %3
ret void
}