#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*/ gcspy_formatLargeNumber(unsigned int);
int /*<<< orphan*/ sprintf(char *, char *, double, int /*<<< orphan*/);
char *gcspy_formatSize(unsigned int size) {
  static char buffer[128];
  if (size < (1024 * 1024))
    sprintf(buffer, "%1.1lfKB (%s bytes)", ((double)size / ((double)1024)),
            gcspy_formatLargeNumber(size));
  else
    sprintf(buffer, "%1.1lfMB (%s bytes)",
            ((double)size / ((double)(1024 * 1024))),
            gcspy_formatLargeNumber(size));
  return buffer;
}


x86 assembly (clang, -O0):
<gcspy_formatSize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x100000,-0x4(%rbp)
jae    1178 <gcspy_formatSize+0x58>
mov    -0x4(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  0xec0(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <gcspy_formatLargeNumber@plt>
movsd  -0x10(%rbp),%xmm0
mov    %eax,%edx
lea    0x2ed9(%rip),%rdi
lea    0xea2(%rip),%rsi
call   1040 <sprintf@plt>
jmp    11b3 <gcspy_formatSize+0x93>
mov    -0x4(%rbp),%eax
cvtsi2sd %rax,%xmm0
movsd  0xe78(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <gcspy_formatLargeNumber@plt>
movsd  -0x18(%rbp),%xmm0
mov    %eax,%edx
lea    0x2e99(%rip),%rdi
lea    0xe76(%rip),%rsi
call   1040 <sprintf@plt>
lea    0x2e86(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gcspy_formatSize>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
cmp    $0x100000,%edi
mov    %edi,%ecx
cvtsi2sd %rcx,%xmm0
lea    0xed6(%rip),%rcx
lea    0xee3(%rip),%rbx
cmovb  %rcx,%rbx
setb   %al
lea    0xeb1(%rip),%rcx
mulsd  (%rcx,%rax,8),%xmm0
movsd  %xmm0,(%rsp)
call   1030 <gcspy_formatLargeNumber@plt>
lea    0x2edb(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
movsd  (%rsp),%xmm0
mov    %eax,%edx
call   1040 <sprintf@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@gcspy_formatSize.buffer = internal global [128 x i8] zeroinitializer
@.str = [20 x i8] c"%1.1lfKB (%s bytes)\00"
@.str.1 = [20 x i8] c"%1.1lfMB (%s bytes)\00"
define i8* @gcspy_formatSize(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp ult i32 %3, 1048576
br i1 %4, label %5, label %12
5: ; preds = %1
%6 = load i32, i32* %2
%7 = uitofp i32 %6 to double
%8 = fdiv double %7, 1.024000e+03
%9 = load i32, i32* %2
%10 = call i32 @gcspy_formatLargeNumber(i32 %9)
%11 = call i32 @sprintf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @gcspy_formatSize.buffer, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), double %8, i32 %10)
br label %19
12: ; preds = %1
%13 = load i32, i32* %2
%14 = uitofp i32 %13 to double
%15 = fdiv double %14, 0x4130000000000000
%16 = load i32, i32* %2
%17 = call i32 @gcspy_formatLargeNumber(i32 %16)
%18 = call i32 @sprintf(i8* getelementptr inbounds ([128 x i8], [128 x i8]* @gcspy_formatSize.buffer, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), double %15, i32 %17)
br label %19
19: ; preds = %12, %5
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @gcspy_formatSize.buffer, i64 0, i64 0)
}

LLVM IR (-O2):
@gcspy_formatSize.buffer = internal global [128 x i8] zeroinitializer
@.str = [20 x i8] c"%1.1lfKB (%s bytes)\00"
@.str.1 = [20 x i8] c"%1.1lfMB (%s bytes)\00"
define i8* @gcspy_formatSize(i32 %0) {
%2 = icmp ult i32 %0, 1048576
%3 = uitofp i32 %0 to double
%4 = select i1 %2, double 0x3F50000000000000, double 0x3EB0000000000000
%5 = select i1 %2, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0)
%6 = fmul double %4, %3
%7 = tail call i32 @gcspy_formatLargeNumber(i32 %0)
%8 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([128 x i8], [128 x i8]* @gcspy_formatSize.buffer, i64 0, i64 0), i8* dereferenceable(1) %5, double %6, i32 %7)
ret i8* getelementptr inbounds ([128 x i8], [128 x i8]* @gcspy_formatSize.buffer, i64 0, i64 0)
}