#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*/ sprintf(char *, char *, ...);
char *display_size(long long unsigned int number, char *buffer) {
  double tmp = number;
  char suffix[64];
  sprintf(suffix, "%s", " B ");
  ;
  if (tmp >= 1024) {
    tmp = tmp / 1024;
    sprintf(suffix, "%s", " KB");
    ;
  }
  if (tmp >= 1024) {
    tmp = tmp / 1024;
    sprintf(suffix, "%s", " MB");
    ;
  }
  if (tmp >= 1024) {
    tmp = tmp / 1024;
    sprintf(suffix, "%s", " GB");
    ;
  }
  if (tmp >= 1024) {
    tmp = tmp / 1024;
    sprintf(suffix, "%s", " TB");
    ;
  }
  if (tmp >= 1024) {
    tmp = tmp / 1024;
    sprintf(suffix, "%s", " PB");
    ;
  }
  sprintf(buffer, "%10.2f%s", tmp, suffix);
  return buffer;
}


x86 assembly (clang, -O0):
<display_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movaps 0xee9(%rip),%xmm1
movq   -0x8(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xee8(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xef7(%rip),%rsi
lea    0xed2(%rip),%rdx
mov    $0x0,%al
call   1030 <sprintf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  0xe8e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11ab <display_size+0x9b>
movsd  -0x18(%rbp),%xmm0
movsd  0xe77(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xeb1(%rip),%rsi
lea    0xe90(%rip),%rdx
mov    $0x0,%al
call   1030 <sprintf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  0xe48(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     11f1 <display_size+0xe1>
movsd  -0x18(%rbp),%xmm0
movsd  0xe31(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xe6b(%rip),%rsi
lea    0xe4e(%rip),%rdx
mov    $0x0,%al
call   1030 <sprintf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  0xe02(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     1237 <display_size+0x127>
movsd  -0x18(%rbp),%xmm0
movsd  0xdeb(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xe25(%rip),%rsi
lea    0xe0c(%rip),%rdx
mov    $0x0,%al
call   1030 <sprintf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  0xdbc(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     127d <display_size+0x16d>
movsd  -0x18(%rbp),%xmm0
movsd  0xda5(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xddf(%rip),%rsi
lea    0xdca(%rip),%rdx
mov    $0x0,%al
call   1030 <sprintf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  0xd76(%rip),%xmm1
ucomisd %xmm1,%xmm0
jb     12c3 <display_size+0x1b3>
movsd  -0x18(%rbp),%xmm0
movsd  0xd5f(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xd99(%rip),%rsi
lea    0xd88(%rip),%rdx
mov    $0x0,%al
call   1030 <sprintf@plt>
mov    -0x10(%rbp),%rdi
movsd  -0x18(%rbp),%xmm0
lea    -0x60(%rbp),%rdx
lea    0xd71(%rip),%rsi
mov    $0x1,%al
call   1030 <sprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_size>:
push   %rbx
sub    $0x40,%rsp
mov    %rsi,%rbx
movq   %rdi,%xmm0
punpckldq 0xedb(%rip),%xmm0
subpd  0xee3(%rip),%xmm0
movapd %xmm0,%xmm2
unpckhpd %xmm0,%xmm2
addsd  %xmm0,%xmm2
movsd  0xedf(%rip),%xmm1
cmp    $0x400,%rdi
jb     114e <display_size+0x3e>
mulsd  %xmm1,%xmm2
movsd  0xed2(%rip),%xmm3
xor    %eax,%eax
ucomisd %xmm3,%xmm2
setae  %al
movapd %xmm2,%xmm0
mulsd  %xmm1,%xmm0
movapd %xmm3,%xmm4
cmpnlesd %xmm2,%xmm4
movapd %xmm4,%xmm5
andpd  %xmm2,%xmm5
andnpd %xmm0,%xmm4
orpd   %xmm5,%xmm4
shl    $0x9,%eax
add    $0x424b20,%eax
ucomisd %xmm3,%xmm4
movapd %xmm4,%xmm0
mulsd  %xmm1,%xmm0
movapd %xmm3,%xmm5
cmpnlesd %xmm4,%xmm5
movapd %xmm5,%xmm6
andpd  %xmm4,%xmm6
andnpd %xmm0,%xmm5
orpd   %xmm6,%xmm5
mov    $0x424720,%ecx
cmovb  %eax,%ecx
ucomisd %xmm3,%xmm5
movapd %xmm5,%xmm0
jb     11c7 <display_size+0xb7>
movapd %xmm5,%xmm0
mulsd  %xmm1,%xmm0
mov    $0x425420,%eax
cmovb  %ecx,%eax
ucomisd %xmm3,%xmm0
mov    $0x425020,%ecx
cmovb  %eax,%ecx
mov    $0x204220,%eax
cmovae %ecx,%eax
ucomisd %xmm3,%xmm5
cmovae %ecx,%eax
ucomisd %xmm3,%xmm4
cmovae %ecx,%eax
ucomisd %xmm3,%xmm2
cmovae %ecx,%eax
cmp    $0x400,%rdi
cmovae %ecx,%eax
ucomisd %xmm3,%xmm0
mov    %eax,(%rsp)
jb     120f <display_size+0xff>
mulsd  %xmm1,%xmm0
lea    0xe1a(%rip),%rsi
mov    %rsp,%rdx
mov    %rbx,%rdi
mov    $0x1,%al
call   1030 <sprintf@plt>
mov    %rbx,%rax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [4 x i8] c" B \00"
@.str.2 = [4 x i8] c" KB\00"
@.str.3 = [4 x i8] c" MB\00"
@.str.4 = [4 x i8] c" GB\00"
@.str.5 = [4 x i8] c" TB\00"
@.str.6 = [4 x i8] c" PB\00"
@.str.7 = [9 x i8] c"%10.2f%s\00"
define i8* @display_size(i64 %0, i8* %1) {
%3 = alloca i64
%4 = alloca i8*
%5 = alloca double
%6 = alloca [64 x i8]
store i64 %0, i64* %3
store i8* %1, i8** %4
%7 = load i64, i64* %3
%8 = uitofp i64 %7 to double
store double %8, double* %5
%9 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%10 = call i32 (i8*, i8*, ...) @sprintf(i8* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%11 = load double, double* %5
%12 = fcmp oge double %11, 1.024000e+03
br i1 %12, label %13, label %18
13: ; preds = %2
%14 = load double, double* %5
%15 = fdiv double %14, 1.024000e+03
store double %15, double* %5
%16 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%17 = call i32 (i8*, i8*, ...) @sprintf(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %18
18: ; preds = %13, %2
%19 = load double, double* %5
%20 = fcmp oge double %19, 1.024000e+03
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load double, double* %5
%23 = fdiv double %22, 1.024000e+03
store double %23, double* %5
%24 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%25 = call i32 (i8*, i8*, ...) @sprintf(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %26
26: ; preds = %21, %18
%27 = load double, double* %5
%28 = fcmp oge double %27, 1.024000e+03
br i1 %28, label %29, label %34
29: ; preds = %26
%30 = load double, double* %5
%31 = fdiv double %30, 1.024000e+03
store double %31, double* %5
%32 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%33 = call i32 (i8*, i8*, ...) @sprintf(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
br label %34
34: ; preds = %29, %26
%35 = load double, double* %5
%36 = fcmp oge double %35, 1.024000e+03
br i1 %36, label %37, label %42
37: ; preds = %34
%38 = load double, double* %5
%39 = fdiv double %38, 1.024000e+03
store double %39, double* %5
%40 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%41 = call i32 (i8*, i8*, ...) @sprintf(i8* %40, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
br label %42
42: ; preds = %37, %34
%43 = load double, double* %5
%44 = fcmp oge double %43, 1.024000e+03
br i1 %44, label %45, label %50
45: ; preds = %42
%46 = load double, double* %5
%47 = fdiv double %46, 1.024000e+03
store double %47, double* %5
%48 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%49 = call i32 (i8*, i8*, ...) @sprintf(i8* %48, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
br label %50
50: ; preds = %45, %42
%51 = load i8*, i8** %4
%52 = load double, double* %5
%53 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%54 = call i32 (i8*, i8*, ...) @sprintf(i8* %51, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), double %52, i8* %53)
%55 = load i8*, i8** %4
ret i8* %55
}

LLVM IR (-O2):
@.str.7 = [9 x i8] c"%10.2f%s\00"
define i8* @display_size(i64 %0, i8* returned writeonly %1) {
%3 = alloca [64 x i8]
%4 = uitofp i64 %0 to double
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %3, i64 0, i64 0
%6 = icmp ugt i64 %0, 1023
%7 = fmul double %4, 0x3F50000000000000
%8 = select i1 %6, double %7, double %4
%9 = fcmp ult double %8, 1.024000e+03
%10 = fmul double %8, 0x3F50000000000000
%11 = select i1 %9, double %8, double %10
%12 = fcmp ult double %11, 1.024000e+03
%13 = fmul double %11, 0x3F50000000000000
%14 = select i1 %12, double %11, double %13
%15 = and i1 %9, %12
%16 = fcmp ult double %14, 1.024000e+03
%17 = fmul double %14, 0x3F50000000000000
%18 = select i1 %16, double %14, double %17
%19 = and i1 %15, %16
%20 = fcmp ult double %18, 1.024000e+03
%21 = and i1 %19, %20
%22 = xor i1 %21, true
%23 = or i1 %6, %22
%24 = select i1 %9, i32 4344608, i32 4345120
%25 = select i1 %12, i32 %24, i32 4343584
%26 = select i1 %16, i32 %25, i32 4346912
%27 = select i1 %20, i32 %26, i32 4345888
%28 = select i1 %23, i32 %27, i32 2114080
%29 = bitcast [64 x i8]* %3 to i32*
store i32 %28, i32* %29
%30 = fmul double %18, 0x3F50000000000000
%31 = select i1 %20, double %18, double %30
%32 = call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %1, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0), double %31, i8* %5)
ret i8* %1
}