#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*/ snprintf(char *, int, char *, double, char);
char *sizerepr(size_t size) {
  static char buf[64] = {0};
  size_t div = 0;
  size_t rem = 0;
  while (size >= 1024 && div < sizeof("BKMGT")) {
    rem = size % 1024;
    size /= 1024;
    ++div;
  }
  snprintf(buf, 64, "%.1f%c", (double)size + (double)rem / 1024.0,
           "BKMGT"[div]);
  return buf;
}


x86 assembly (clang, -O0):
<sizerepr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
xor    %eax,%eax
cmpq   $0x400,-0x8(%rbp)
mov    %al,-0x19(%rbp)
jb     114a <sizerepr+0x3a>
cmpq   $0x6,-0x10(%rbp)
setb   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    115a <sizerepr+0x4a>
jmp    1185 <sizerepr+0x75>
mov    -0x8(%rbp),%rax
and    $0x3ff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
shr    $0xa,%rax
mov    %rax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    112c <sizerepr+0x1c>
movq   -0x8(%rbp),%xmm0
movaps 0xe7f(%rip),%xmm3
punpckldq %xmm3,%xmm0
movapd 0xe83(%rip),%xmm2
subpd  %xmm2,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movq   -0x18(%rbp),%xmm1
punpckldq %xmm3,%xmm1
subpd  %xmm2,%xmm1
movaps %xmm1,%xmm2
unpckhpd %xmm1,%xmm1
addsd  %xmm2,%xmm1
movsd  0xe34(%rip),%xmm2
divsd  %xmm2,%xmm1
addsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rcx
lea    0x2e61(%rip),%rdi
mov    $0x40,%esi
lea    0xe45(%rip),%rdx
lea    0xe45(%rip),%rax
movsbl (%rax,%rcx,1),%ecx
call   1030 <snprintf@plt>
lea    0x2e3e(%rip),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sizerepr>:
push   %rbx
cmp    $0x400,%rdi
jb     1180 <sizerepr+0x70>
mov    %rdi,%rdx
shr    $0xa,%rdx
mov    $0x1,%eax
cmp    $0x100000,%rdi
jb     1188 <sizerepr+0x78>
mov    %rdi,%rsi
shr    $0x14,%rsi
mov    $0x2,%eax
cmp    $0x40000000,%rdi
jb     1190 <sizerepr+0x80>
mov    %rdi,%rbx
shr    $0x1e,%rbx
mov    %rdi,%rdx
shr    $0x28,%rdx
mov    $0x3,%eax
je     1198 <sizerepr+0x88>
mov    %rdi,%rsi
shr    $0x32,%rsi
mov    $0x4,%eax
je     1200 <sizerepr+0xf0>
shr    $0x3c,%rdi
mov    $0x5,%eax
je     1190 <sizerepr+0x80>
mov    $0x6,%eax
mov    %rsi,%rcx
jmp    119e <sizerepr+0x8e>
xorpd  %xmm1,%xmm1
xor    %eax,%eax
jmp    11b0 <sizerepr+0xa0>
mov    %rdi,%rcx
mov    %rdx,%rdi
jmp    119e <sizerepr+0x8e>
mov    %rdx,%rcx
mov    %rsi,%rdi
jmp    119e <sizerepr+0x8e>
mov    %rsi,%rcx
mov    %rbx,%rdi
and    $0x3ff,%ecx
cvtsi2sd %ecx,%xmm1
mulsd  0xe50(%rip),%xmm1
movq   %rdi,%xmm2
punpckldq 0xe53(%rip),%xmm2
subpd  0xe5b(%rip),%xmm2
movapd %xmm2,%xmm0
unpckhpd %xmm2,%xmm0
addsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
lea    0xe5b(%rip),%rcx
movsbl (%rax,%rcx,1),%ecx
lea    0x2e59(%rip),%rbx
lea    0xe42(%rip),%rdx
mov    %rbx,%rdi
mov    $0x40,%esi
call   1030 <snprintf@plt>
mov    %rbx,%rax
pop    %rbx
ret
mov    %rbx,%rcx
jmp    118b <sizerepr+0x7b>

LLVM IR (-O0):
@sizerepr.buf = internal global [64 x i8] zeroinitializer
@.str = [7 x i8] c"%.1f%c\00"
@.str.1 = [6 x i8] c"BKMGT\00"
define i8* @sizerepr(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
store i64 %0, i64* %2
store i64 0, i64* %3
store i64 0, i64* %4
br label %5
5: ; preds = %13, %1
%6 = load i64, i64* %2
%7 = icmp uge i64 %6, 1024
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = load i64, i64* %3
%10 = icmp ult i64 %9, 6
br label %11
11: ; preds = %8, %5
%12 = phi i1 [ false, %5 ], [ %10, %8 ]
br i1 %12, label %13, label %20
13: ; preds = %11
%14 = load i64, i64* %2
%15 = urem i64 %14, 1024
store i64 %15, i64* %4
%16 = load i64, i64* %2
%17 = udiv i64 %16, 1024
store i64 %17, i64* %2
%18 = load i64, i64* %3
%19 = add i64 %18, 1
store i64 %19, i64* %3
br label %5
20: ; preds = %11
%21 = load i64, i64* %2
%22 = uitofp i64 %21 to double
%23 = load i64, i64* %4
%24 = uitofp i64 %23 to double
%25 = fdiv double %24, 1.024000e+03
%26 = fadd double %22, %25
%27 = load i64, i64* %3
%28 = getelementptr inbounds [6 x i8], [6 x i8]* @.str.1, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = call i32 @snprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @sizerepr.buf, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %26, i8 signext %29)
ret i8* getelementptr inbounds ([64 x i8], [64 x i8]* @sizerepr.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@sizerepr.buf = internal global [64 x i8] zeroinitializer
@.str = [7 x i8] c"%.1f%c\00"
@.str.1 = [6 x i8] c"BKMGT\00"
define i8* @sizerepr(i64 %0) {
%2 = icmp ugt i64 %0, 1023
br i1 %2, label %3, label %27
3: ; preds = %1
%4 = lshr i64 %0, 10
%5 = icmp ugt i64 %0, 1048575
br i1 %5, label %6, label %20
6: ; preds = %3
%7 = lshr i64 %0, 20
%8 = icmp ugt i64 %0, 1073741823
br i1 %8, label %9, label %20
9: ; preds = %6
%10 = lshr i64 %0, 30
%11 = icmp ugt i64 %0, 1099511627775
br i1 %11, label %12, label %20
12: ; preds = %9
%13 = lshr i64 %0, 40
%14 = icmp ugt i64 %0, 1125899906842623
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = lshr i64 %0, 50
%17 = icmp ugt i64 %0, 1152921504606846975
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = lshr i64 %0, 60
br label %20
20: ; preds = %18, %15, %12, %9, %6, %3
%21 = phi i64 [ %0, %3 ], [ %4, %6 ], [ %7, %9 ], [ %10, %12 ], [ %13, %15 ], [ %16, %18 ]
%22 = phi i64 [ %4, %3 ], [ %7, %6 ], [ %10, %9 ], [ %13, %12 ], [ %16, %15 ], [ %19, %18 ]
%23 = phi i64 [ 1, %3 ], [ 2, %6 ], [ 3, %9 ], [ 4, %12 ], [ 5, %15 ], [ 6, %18 ]
%24 = and i64 %21, 1023
%25 = uitofp i64 %24 to double
%26 = fmul double %25, 0x3F50000000000000
br label %27
27: ; preds = %20, %1
%28 = phi i64 [ %22, %20 ], [ %0, %1 ]
%29 = phi i64 [ %23, %20 ], [ 0, %1 ]
%30 = phi double [ %26, %20 ], [ 0.000000e+00, %1 ]
%31 = uitofp i64 %28 to double
%32 = fadd double %30, %31
%33 = getelementptr inbounds [6 x i8], [6 x i8]* @.str.1, i64 0, i64 %29
%34 = load i8, i8* %33
%35 = tail call i32 @snprintf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @sizerepr.buf, i64 0, i64 0), i32 64, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %32, i8 signext %34)
ret i8* getelementptr inbounds ([64 x i8], [64 x i8]* @sizerepr.buf, i64 0, i64 0)
}