#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 */
char *malloc(int);
int /*<<< orphan*/ sprintf(char *, char *, float);
char *_husize(int size) {
  char *s = malloc(9);
  if (size < 1024)
    sprintf(s, "%d B", size);
  else if (size < 1024 * 1024)
    sprintf(s, "%.1f k", (float)size / 1024);
  else if (size < 1024 * 1024 * 1024)
    sprintf(s, "%.1f M", (float)size / 1024 / 1024);
  else
    sprintf(s, "%.1f G", (float)size / 1024 / 1024 / 1024);
  return s;
}


x86 assembly (clang, -O0):
<_husize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x9,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpl   $0x400,-0x4(%rbp)
jge    1160 <_husize+0x40>
mov    -0x10(%rbp),%rdi
cvtsi2ssl -0x4(%rbp),%xmm0
lea    0xeae(%rip),%rsi
call   1040 <sprintf@plt>
jmp    1215 <_husize+0xf5>
cmpl   $0x100000,-0x4(%rbp)
jge    1193 <_husize+0x73>
mov    -0x10(%rbp),%rdi
cvtsi2ssl -0x4(%rbp),%xmm0
movss  0xe82(%rip),%xmm1
divss  %xmm1,%xmm0
lea    0xe80(%rip),%rsi
call   1040 <sprintf@plt>
jmp    1210 <_husize+0xf0>
cmpl   $0x40000000,-0x4(%rbp)
jge    11d2 <_husize+0xb2>
mov    -0x10(%rbp),%rdi
cvtsi2ssl -0x4(%rbp),%xmm0
movss  0xe4f(%rip),%xmm1
divss  %xmm1,%xmm0
movss  0xe43(%rip),%xmm1
divss  %xmm1,%xmm0
lea    0xe48(%rip),%rsi
call   1040 <sprintf@plt>
jmp    120b <_husize+0xeb>
mov    -0x10(%rbp),%rdi
cvtsi2ssl -0x4(%rbp),%xmm0
movss  0xe1d(%rip),%xmm1
divss  %xmm1,%xmm0
movss  0xe11(%rip),%xmm1
divss  %xmm1,%xmm0
movss  0xe05(%rip),%xmm1
divss  %xmm1,%xmm0
lea    0xe11(%rip),%rsi
call   1040 <sprintf@plt>
jmp    1210 <_husize+0xf0>
jmp    1215 <_husize+0xf5>
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_husize>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0x9,%edi
call   1030 <malloc@plt>
mov    %rax,%rbx
cmp    $0x3ff,%ebp
jg     1147 <_husize+0x27>
cvtsi2ss %ebp,%xmm0
lea    0xebf(%rip),%rsi
jmp    1198 <_husize+0x78>
cmp    $0xfffff,%ebp
ja     1164 <_husize+0x44>
cvtsi2ss %ebp,%xmm0
mulss  0xea5(%rip),%xmm0
lea    0xea7(%rip),%rsi
jmp    1198 <_husize+0x78>
cvtsi2ss %ebp,%xmm0
movss  0xe90(%rip),%xmm1
mulss  %xmm1,%xmm0
mulss  %xmm1,%xmm0
cmp    $0x3fffffff,%ebp
ja     1189 <_husize+0x69>
lea    0xe89(%rip),%rsi
jmp    1198 <_husize+0x78>
mulss  0xe6f(%rip),%xmm0
lea    0xe7f(%rip),%rsi
mov    %rbx,%rdi
call   1040 <sprintf@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%d B\00"
@.str.1 = [7 x i8] c"%.1f k\00"
@.str.2 = [7 x i8] c"%.1f M\00"
@.str.3 = [7 x i8] c"%.1f G\00"
define i8* @_husize(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
store i32 %0, i32* %2
%4 = call i8* @malloc(i32 9)
store i8* %4, i8** %3
%5 = load i32, i32* %2
%6 = icmp slt i32 %5, 1024
br i1 %6, label %7, label %12
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = load i32, i32* %2
%10 = sitofp i32 %9 to float
%11 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), float %10)
br label %41
12: ; preds = %1
%13 = load i32, i32* %2
%14 = icmp slt i32 %13, 1048576
br i1 %14, label %15, label %21
15: ; preds = %12
%16 = load i8*, i8** %3
%17 = load i32, i32* %2
%18 = sitofp i32 %17 to float
%19 = fdiv float %18, 1.024000e+03
%20 = call i32 @sprintf(i8* %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), float %19)
br label %40
21: ; preds = %12
%22 = load i32, i32* %2
%23 = icmp slt i32 %22, 1073741824
br i1 %23, label %24, label %31
24: ; preds = %21
%25 = load i8*, i8** %3
%26 = load i32, i32* %2
%27 = sitofp i32 %26 to float
%28 = fdiv float %27, 1.024000e+03
%29 = fdiv float %28, 1.024000e+03
%30 = call i32 @sprintf(i8* %25, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), float %29)
br label %39
31: ; preds = %21
%32 = load i8*, i8** %3
%33 = load i32, i32* %2
%34 = sitofp i32 %33 to float
%35 = fdiv float %34, 1.024000e+03
%36 = fdiv float %35, 1.024000e+03
%37 = fdiv float %36, 1.024000e+03
%38 = call i32 @sprintf(i8* %32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), float %37)
br label %39
39: ; preds = %31, %24
br label %40
40: ; preds = %39, %15
br label %41
41: ; preds = %40, %7
%42 = load i8*, i8** %3
ret i8* %42
}

LLVM IR (-O2):
@.str = [5 x i8] c"%d B\00"
@.str.1 = [7 x i8] c"%.1f k\00"
@.str.2 = [7 x i8] c"%.1f M\00"
@.str.3 = [7 x i8] c"%.1f G\00"
define noalias i8* @_husize(i32 %0) {
%2 = tail call dereferenceable_or_null(9) i8* @malloc(i32 9)
%3 = icmp slt i32 %0, 1024
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = sitofp i32 %0 to float
%6 = tail call i32 @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), float %5)
br label %23
7: ; preds = %1
%8 = icmp ult i32 %0, 1048576
br i1 %8, label %9, label %13
9: ; preds = %7
%10 = sitofp i32 %0 to float
%11 = fmul float %10, 0x3F50000000000000
%12 = tail call i32 @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), float %11)
br label %23
13: ; preds = %7
%14 = icmp ult i32 %0, 1073741824
%15 = sitofp i32 %0 to float
%16 = fmul float %15, 0x3F50000000000000
%17 = fmul float %16, 0x3F50000000000000
br i1 %14, label %18, label %20
18: ; preds = %13
%19 = tail call i32 @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), float %17)
br label %23
20: ; preds = %13
%21 = fmul float %17, 0x3F50000000000000
%22 = tail call i32 @sprintf(i8* dereferenceable(1) %2, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), float %21)
br label %23
23: ; preds = %9, %20, %18, %4
ret i8* %2
}