#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 *, double);
const char *sizenum(size_t s) {
  static char buffer[32];
  if (s < 1000)
    sprintf(buffer, "%uB", (unsigned)s);
  else if (s < 1000000)
    sprintf(buffer, "%.2fkB", (double)(s) / 1000);
  else
    sprintf(buffer, "%.2fMB", (double)(s) / 1000000);
  return buffer;
}


x86 assembly (clang, -O0):
<sizenum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x3e8,-0x8(%rbp)
jae    114a <sizenum+0x3a>
mov    -0x8(%rbp),%eax
cvtsi2sd %rax,%xmm0
lea    0x2f07(%rip),%rdi
lea    0xef0(%rip),%rsi
call   1030 <sprintf@plt>
jmp    11ee <sizenum+0xde>
cmpq   $0xf4240,-0x8(%rbp)
jae    11a3 <sizenum+0x93>
movaps 0xeb1(%rip),%xmm1
movq   -0x8(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xeb0(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe81(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0x2eae(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1030 <sprintf@plt>
jmp    11e9 <sizenum+0xd9>
movaps 0xe66(%rip),%xmm1
movq   -0x8(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xe65(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe2e(%rip),%xmm1
divsd  %xmm1,%xmm0
lea    0x2e63(%rip),%rdi
lea    0xe57(%rip),%rsi
call   1030 <sprintf@plt>
jmp    11ee <sizenum+0xde>
lea    0x2e4b(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sizenum>:
push   %rax
cmp    $0x3e7,%rdi
ja     1131 <sizenum+0x21>
mov    %edi,%eax
cvtsi2sd %rax,%xmm0
lea    0x2f18(%rip),%rdi
lea    0xf01(%rip),%rsi
jmp    1189 <sizenum+0x79>
movq   %rdi,%xmm1
punpckldq 0xec2(%rip),%xmm1
subpd  0xeca(%rip),%xmm1
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
cmp    $0xf423f,%rdi
ja     1173 <sizenum+0x63>
divsd  0xec5(%rip),%xmm0
lea    0x2ed6(%rip),%rdi
lea    0xec3(%rip),%rsi
jmp    1189 <sizenum+0x79>
divsd  0xea5(%rip),%xmm0
lea    0x2ebe(%rip),%rdi
lea    0xeb2(%rip),%rsi
call   1030 <sprintf@plt>
lea    0x2eab(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@sizenum.buffer = internal global [32 x i8] zeroinitializer
@.str = [4 x i8] c"%uB\00"
@.str.1 = [7 x i8] c"%.2fkB\00"
@.str.2 = [7 x i8] c"%.2fMB\00"
define i8* @sizenum(i64 %0) {
%2 = alloca i64
store i64 %0, i64* %2
%3 = load i64, i64* %2
%4 = icmp ult i64 %3, 1000
br i1 %4, label %5, label %10
5: ; preds = %1
%6 = load i64, i64* %2
%7 = trunc i64 %6 to i32
%8 = uitofp i32 %7 to double
%9 = call i32 @sprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @sizenum.buffer, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %8)
br label %24
10: ; preds = %1
%11 = load i64, i64* %2
%12 = icmp ult i64 %11, 1000000
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = load i64, i64* %2
%15 = uitofp i64 %14 to double
%16 = fdiv double %15, 1.000000e+03
%17 = call i32 @sprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @sizenum.buffer, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %16)
br label %23
18: ; preds = %10
%19 = load i64, i64* %2
%20 = uitofp i64 %19 to double
%21 = fdiv double %20, 1.000000e+06
%22 = call i32 @sprintf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @sizenum.buffer, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %21)
br label %23
23: ; preds = %18, %13
br label %24
24: ; preds = %23, %5
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @sizenum.buffer, i64 0, i64 0)
}

LLVM IR (-O2):
@sizenum.buffer = internal global [32 x i8] zeroinitializer
@.str = [4 x i8] c"%uB\00"
@.str.1 = [7 x i8] c"%.2fkB\00"
@.str.2 = [7 x i8] c"%.2fMB\00"
define i8* @sizenum(i64 %0) {
%2 = icmp ult i64 %0, 1000
br i1 %2, label %3, label %7
3: ; preds = %1
%4 = trunc i64 %0 to i32
%5 = uitofp i32 %4 to double
%6 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @sizenum.buffer, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), double %5)
br label %16
7: ; preds = %1
%8 = icmp ult i64 %0, 1000000
%9 = uitofp i64 %0 to double
br i1 %8, label %10, label %13
10: ; preds = %7
%11 = fdiv double %9, 1.000000e+03
%12 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @sizenum.buffer, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %11)
br label %16
13: ; preds = %7
%14 = fdiv double %9, 1.000000e+06
%15 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @sizenum.buffer, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %14)
br label %16
16: ; preds = %10, %13, %3
ret i8* getelementptr inbounds ([32 x i8], [32 x i8]* @sizenum.buffer, i64 0, i64 0)
}