#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 Print(char *, double);
int PrintDataSize(long long size) {
  if (size < 1024) {
    return Print("%8lld B  ", size);
  }
  double kibSize = (double)size / 1024;
  if (kibSize < 1024) {
    return Print("% 8.3f KiB", kibSize);
  }
  double mibSize = kibSize / 1024;
  if (mibSize < 1024) {
    return Print("% 8.3f MiB", mibSize);
  }
  double gibSize = mibSize / 1024;
  if (gibSize < 1024) {
    return Print("% 8.3f GiB", gibSize);
  }
  double tibSize = gibSize / 1024;
  return Print("% 8.3f TiB", tibSize);
}


x86 assembly (clang, -O0):
<PrintDataSize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x400,-0x10(%rbp)
jge    1144 <PrintDataSize+0x34>
cvtsi2sdq -0x10(%rbp),%xmm0
lea    0xed1(%rip),%rdi
call   1030 <Print@plt>
mov    %eax,-0x4(%rbp)
jmp    1235 <PrintDataSize+0x125>
cvtsi2sdq -0x10(%rbp),%xmm0
movsd  0xeae(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  0xe9d(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    1187 <PrintDataSize+0x77>
movsd  -0x18(%rbp),%xmm0
lea    0xe98(%rip),%rdi
call   1030 <Print@plt>
mov    %eax,-0x4(%rbp)
jmp    1235 <PrintDataSize+0x125>
movsd  -0x18(%rbp),%xmm0
movsd  0xe6c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
movsd  0xe5b(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    11c9 <PrintDataSize+0xb9>
movsd  -0x20(%rbp),%xmm0
lea    0xe61(%rip),%rdi
call   1030 <Print@plt>
mov    %eax,-0x4(%rbp)
jmp    1235 <PrintDataSize+0x125>
movsd  -0x20(%rbp),%xmm0
movsd  0xe2a(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe19(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    120b <PrintDataSize+0xfb>
movsd  -0x28(%rbp),%xmm0
lea    0xe2a(%rip),%rdi
call   1030 <Print@plt>
mov    %eax,-0x4(%rbp)
jmp    1235 <PrintDataSize+0x125>
movsd  -0x28(%rbp),%xmm0
movsd  0xde8(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x30(%rbp),%xmm0
lea    0xe06(%rip),%rdi
call   1030 <Print@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintDataSize>:
cvtsi2sd %rdi,%xmm0
cmp    $0x3ff,%rdi
jg     112a <PrintDataSize+0x1a>
lea    0xeeb(%rip),%rdi
jmp    1030 <Print@plt>
mulsd  0xece(%rip),%xmm0
movsd  0xece(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    114c <PrintDataSize+0x3c>
lea    0xed3(%rip),%rdi
jmp    1030 <Print@plt>
mulsd  0xeac(%rip),%xmm0
ucomisd %xmm0,%xmm1
jbe    1166 <PrintDataSize+0x56>
lea    0xec4(%rip),%rdi
jmp    1030 <Print@plt>
mulsd  0xe92(%rip),%xmm0
ucomisd %xmm0,%xmm1
jbe    1180 <PrintDataSize+0x70>
lea    0xeb5(%rip),%rdi
jmp    1030 <Print@plt>
mulsd  0xe78(%rip),%xmm0
lea    0xeac(%rip),%rdi
jmp    1030 <Print@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"%8lld B \00"
@.str.1 = [11 x i8] c"% 8.3f KiB\00"
@.str.2 = [11 x i8] c"% 8.3f MiB\00"
@.str.3 = [11 x i8] c"% 8.3f GiB\00"
@.str.4 = [11 x i8] c"% 8.3f TiB\00"
define i32 @PrintDataSize(i64 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
store i64 %0, i64* %3
%8 = load i64, i64* %3
%9 = icmp slt i64 %8, 1024
br i1 %9, label %10, label %14
10: ; preds = %1
%11 = load i64, i64* %3
%12 = sitofp i64 %11 to double
%13 = call i32 @Print(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), double %12)
store i32 %13, i32* %2
br label %44
14: ; preds = %1
%15 = load i64, i64* %3
%16 = sitofp i64 %15 to double
%17 = fdiv double %16, 1.024000e+03
store double %17, double* %4
%18 = load double, double* %4
%19 = fcmp olt double %18, 1.024000e+03
br i1 %19, label %20, label %23
20: ; preds = %14
%21 = load double, double* %4
%22 = call i32 @Print(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), double %21)
store i32 %22, i32* %2
br label %44
23: ; preds = %14
%24 = load double, double* %4
%25 = fdiv double %24, 1.024000e+03
store double %25, double* %5
%26 = load double, double* %5
%27 = fcmp olt double %26, 1.024000e+03
br i1 %27, label %28, label %31
28: ; preds = %23
%29 = load double, double* %5
%30 = call i32 @Print(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double %29)
store i32 %30, i32* %2
br label %44
31: ; preds = %23
%32 = load double, double* %5
%33 = fdiv double %32, 1.024000e+03
store double %33, double* %6
%34 = load double, double* %6
%35 = fcmp olt double %34, 1.024000e+03
br i1 %35, label %36, label %39
36: ; preds = %31
%37 = load double, double* %6
%38 = call i32 @Print(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), double %37)
store i32 %38, i32* %2
br label %44
39: ; preds = %31
%40 = load double, double* %6
%41 = fdiv double %40, 1.024000e+03
store double %41, double* %7
%42 = load double, double* %7
%43 = call i32 @Print(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), double %42)
store i32 %43, i32* %2
br label %44
44: ; preds = %39, %36, %28, %20, %10
%45 = load i32, i32* %2
ret i32 %45
}

LLVM IR (-O2):
@.str = [10 x i8] c"%8lld B \00"
@.str.1 = [11 x i8] c"% 8.3f KiB\00"
@.str.2 = [11 x i8] c"% 8.3f MiB\00"
@.str.3 = [11 x i8] c"% 8.3f GiB\00"
@.str.4 = [11 x i8] c"% 8.3f TiB\00"
define i32 @PrintDataSize(i64 %0) {
%2 = icmp slt i64 %0, 1024
%3 = sitofp i64 %0 to double
br i1 %2, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @Print(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), double %3)
br label %24
6: ; preds = %1
%7 = fmul double %3, 0x3F50000000000000
%8 = fcmp olt double %7, 1.024000e+03
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = tail call i32 @Print(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), double %7)
br label %24
11: ; preds = %6
%12 = fmul double %7, 0x3F50000000000000
%13 = fcmp olt double %12, 1.024000e+03
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call i32 @Print(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double %12)
br label %24
16: ; preds = %11
%17 = fmul double %12, 0x3F50000000000000
%18 = fcmp olt double %17, 1.024000e+03
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = tail call i32 @Print(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0), double %17)
br label %24
21: ; preds = %16
%22 = fmul double %17, 0x3F50000000000000
%23 = tail call i32 @Print(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), double %22)
br label %24
24: ; preds = %9, %19, %21, %14, %4
%25 = phi i32 [ %5, %4 ], [ %10, %9 ], [ %15, %14 ], [ %20, %19 ], [ %23, %21 ]
ret i32 %25
}