#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 */
typedef int /*<<< orphan*/ off_t;

/* Variables and functions */
double size_in_units(int /*<<< orphan*/, int *);
int /*<<< orphan*/ snprintf(char *, int, char *, double, char *);
char *pretty_size(off_t sz) {
  static char buf[256];
  char *units[4] = {"B", "KB", "MB", "GB"};
  int i;
  double s = size_in_units(sz, &i);
  snprintf(buf, 255, "%.3f%s", s, units[i]);
  return buf;
}


x86 assembly (clang, -O0):
<pretty_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    0x2cce(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2ccb(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0x2cc8(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2cc5(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x34(%rbp),%rsi
call   1040 <size_in_units@plt>
movsd  %xmm0,-0x40(%rbp)
movsd  -0x40(%rbp),%xmm0
movslq -0x34(%rbp),%rax
mov    -0x30(%rbp,%rax,8),%rcx
lea    0x2ec3(%rip),%rdi
mov    $0xff,%esi
lea    0xe80(%rip),%rdx
call   1030 <snprintf@plt>
lea    0x2eab(%rip),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pretty_size>:
push   %rbx
sub    $0x10,%rsp
lea    0xc(%rsp),%rsi
call   1040 <size_in_units@plt>
movslq 0xc(%rsp),%rax
lea    0xed5(%rip),%rdx
movslq (%rdx,%rax,4),%rcx
add    %rdx,%rcx
lea    0x2ef7(%rip),%rbx
lea    0xeb9(%rip),%rdx
mov    %rbx,%rdi
mov    $0xff,%esi
call   1030 <snprintf@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@pretty_size.buf = internal global [256 x i8] zeroinitializer
@.str = [2 x i8] c"B\00"
@.str.1 = [3 x i8] c"KB\00"
@.str.2 = [3 x i8] c"MB\00"
@.str.3 = [3 x i8] c"GB\00"
@__const.pretty_size.units = [4 x i8*] [i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i32 0, i32 0)]
@.str.4 = [7 x i8] c"%.3f%s\00"
define i8* @pretty_size(i32 %0) {
%2 = alloca i32
%3 = alloca [4 x i8*]
%4 = alloca i32
%5 = alloca double
store i32 %0, i32* %2
%6 = bitcast [4 x i8*]* %3 to i8*
%7 = load i32, i32* %2
%8 = call double @size_in_units(i32 %7, i32* %4)
store double %8, double* %5
%9 = load double, double* %5
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [4 x i8*], [4 x i8*]* %3, i64 0, i64 %11
%13 = load i8*, i8** %12
%14 = call i32 @snprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @pretty_size.buf, i64 0, i64 0), i32 255, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), double %9, i8* %13)
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @pretty_size.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@pretty_size.buf = internal global [256 x i8] zeroinitializer
@.str = [2 x i8] c"B\00"
@.str.1 = [3 x i8] c"KB\00"
@.str.2 = [3 x i8] c"MB\00"
@.str.3 = [3 x i8] c"GB\00"
@reltable.pretty_size = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([2 x i8]* @.str to i64), i64 ptrtoint ([4 x i32]* @reltable.pretty_size to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.pretty_size to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.pretty_size to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([3 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.pretty_size to i64)) to i32)]
@.str.4 = [7 x i8] c"%.3f%s\00"
define i8* @pretty_size(i32 %0) {
%2 = alloca i32
%3 = bitcast i32* %2 to i8*
%4 = call double @size_in_units(i32 %0, i32* %2)
%5 = load i32, i32* %2
%6 = sext i32 %5 to i64
%7 = shl i64 %6, 2
%8 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.pretty_size to i8*), i64 %7)
%9 = call i32 @snprintf(i8* getelementptr inbounds ([256 x i8], [256 x i8]* @pretty_size.buf, i64 0, i64 0), i32 255, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), double %4, i8* %8)
ret i8* getelementptr inbounds ([256 x i8], [256 x i8]* @pretty_size.buf, i64 0, i64 0)
}