#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*/ printf(char *, float);
void PrintSpace(int spaceval) {
  if ((spaceval / 1000) == 0) {
    printf("%d B", spaceval);
    return;
  }
  spaceval /= 1000;
  if ((spaceval / 1000) == 0) {
    printf("%d KB", spaceval);
    return;
  }
  spaceval /= 1000;
  if ((spaceval / 1000) == 0) {
    printf("%d MB", spaceval);
    return;
  }
  printf("%.1f GB", ((float)spaceval) / ((float)1000));
}


x86 assembly (clang, -O0):
<PrintSpace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
jne    1145 <PrintSpace+0x35>
cvtsi2ssl -0x4(%rbp),%xmm0
lea    0xec9(%rip),%rdi
call   1030 <printf@plt>
jmp    11d2 <PrintSpace+0xc2>
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
jne    117d <PrintSpace+0x6d>
cvtsi2ssl -0x4(%rbp),%xmm0
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
jmp    11d2 <PrintSpace+0xc2>
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
jne    11b5 <PrintSpace+0xa5>
cvtsi2ssl -0x4(%rbp),%xmm0
lea    0xe64(%rip),%rdi
call   1030 <printf@plt>
jmp    11d2 <PrintSpace+0xc2>
cvtsi2ssl -0x4(%rbp),%xmm0
movss  0xe3e(%rip),%xmm1
divss  %xmm1,%xmm0
lea    0xe48(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PrintSpace>:
lea    0x3e7(%rdi),%eax
cmp    $0x7ce,%eax
ja     112d <PrintSpace+0x1d>
cvtsi2ss %edi,%xmm0
lea    0xedc(%rip),%rdi
jmp    1030 <printf@plt>
movslq %edi,%rax
lea    0xf423f(%rdi),%ecx
cmp    $0x1e847e,%ecx
ja     1162 <PrintSpace+0x52>
imul   $0x10624dd3,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x26,%rax
add    %ecx,%eax
cvtsi2ss %eax,%xmm0
lea    0xeac(%rip),%rdi
jmp    1030 <printf@plt>
imul   $0x431bde83,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x32,%rax
add    %ecx,%eax
add    $0x3b9ac9ff,%edi
cvtsi2ss %eax,%xmm0
cmp    $0x773593fe,%edi
ja     1194 <PrintSpace+0x84>
lea    0xe80(%rip),%rdi
jmp    1030 <printf@plt>
divss  0xe64(%rip),%xmm0
lea    0xe72(%rip),%rdi
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%d B\00"
@.str.1 = [6 x i8] c"%d KB\00"
@.str.2 = [6 x i8] c"%d MB\00"
@.str.3 = [8 x i8] c"%.1f GB\00"
define void @PrintSpace(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = sdiv i32 %3, 1000
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = load i32, i32* %2
%8 = sitofp i32 %7 to float
%9 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), float %8)
br label %35
10: ; preds = %1
%11 = load i32, i32* %2
%12 = sdiv i32 %11, 1000
store i32 %12, i32* %2
%13 = load i32, i32* %2
%14 = sdiv i32 %13, 1000
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %20
16: ; preds = %10
%17 = load i32, i32* %2
%18 = sitofp i32 %17 to float
%19 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), float %18)
br label %35
20: ; preds = %10
%21 = load i32, i32* %2
%22 = sdiv i32 %21, 1000
store i32 %22, i32* %2
%23 = load i32, i32* %2
%24 = sdiv i32 %23, 1000
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %30
26: ; preds = %20
%27 = load i32, i32* %2
%28 = sitofp i32 %27 to float
%29 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), float %28)
br label %35
30: ; preds = %20
%31 = load i32, i32* %2
%32 = sitofp i32 %31 to float
%33 = fdiv float %32, 1.000000e+03
%34 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), float %33)
br label %35
35: ; preds = %30, %26, %16, %6
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"%d B\00"
@.str.1 = [6 x i8] c"%d KB\00"
@.str.2 = [6 x i8] c"%d MB\00"
@.str.3 = [8 x i8] c"%.1f GB\00"
define void @PrintSpace(i32 %0) {
%2 = sdiv i32 %0, 1000
%3 = add i32 %0, 999
%4 = icmp ult i32 %3, 1999
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = sitofp i32 %0 to float
%7 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), float %6)
br label %24
8: ; preds = %1
%9 = add i32 %0, 999999
%10 = icmp ult i32 %9, 1999999
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = sitofp i32 %2 to float
%13 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), float %12)
br label %24
14: ; preds = %8
%15 = sdiv i32 %0, 1000000
%16 = add i32 %0, 999999999
%17 = icmp ult i32 %16, 1999999999
%18 = sitofp i32 %15 to float
br i1 %17, label %19, label %21
19: ; preds = %14
%20 = tail call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), float %18)
br label %24
21: ; preds = %14
%22 = fdiv float %18, 1.000000e+03
%23 = tail call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), float %22)
br label %24
24: ; preds = %21, %19, %11, %5
ret void
}