#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*/ snprintf(char *, int, char *, double, char *);
char *uireadablebyteslong(unsigned long bytes) {
  char *result = malloc(10);
  if (result == NULL) {
  }
  char *resultsufix = NULL;
  double resultnumber = 0;
  if (bytes > 1000.0) {
    if (bytes > 1000000.0) {
      if (bytes > 1000000000.0) {
        resultnumber = bytes / 1073741824.0;
        resultsufix = "GB";
      } else {
        resultnumber = bytes / 1048576.0;
        resultsufix = "MB";
      }
    } else {
      resultnumber = bytes / 1024.0;
      resultsufix = "KB";
    }
  } else {
    resultnumber = bytes;
    resultsufix = "  ";
  }
  snprintf(result, 10, "%3.3f%s", resultnumber, resultsufix);
  return result;
}


x86 assembly (clang, -O0):
<uireadablebyteslong>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0xa,%edi
call   1040 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    114a <uireadablebyteslong+0x2a>
jmp    114a <uireadablebyteslong+0x2a>
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movaps 0xecf(%rip),%xmm1
movq   -0x8(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xece(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe77(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12dd <uireadablebyteslong+0x1bd>
movaps 0xe96(%rip),%xmm1
movq   -0x8(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xe95(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe46(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1295 <uireadablebyteslong+0x175>
movaps 0xe5d(%rip),%xmm1
movq   -0x8(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xe5c(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xe1d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    124d <uireadablebyteslong+0x12d>
movaps 0xe24(%rip),%xmm1
movq   -0x8(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xe23(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xdf4(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
lea    0xe0c(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1290 <uireadablebyteslong+0x170>
movaps 0xddc(%rip),%xmm1
movq   -0x8(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xddb(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xda4(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
lea    0xdc7(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    12d8 <uireadablebyteslong+0x1b8>
movaps 0xd94(%rip),%xmm1
movq   -0x8(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xd93(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  0xd4c(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
lea    0xd82(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1314 <uireadablebyteslong+0x1f4>
movaps 0xd4c(%rip),%xmm1
movq   -0x8(%rbp),%xmm0
punpckldq %xmm1,%xmm0
movapd 0xd4b(%rip),%xmm1
subpd  %xmm1,%xmm0
movaps %xmm0,%xmm1
unpckhpd %xmm0,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x20(%rbp)
lea    0xd49(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
movsd  -0x20(%rbp),%xmm0
mov    -0x18(%rbp),%rcx
mov    $0xa,%esi
lea    0xd2f(%rip),%rdx
call   1030 <snprintf@plt>
mov    -0x10(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uireadablebyteslong>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0xa,%edi
call   1040 <malloc@plt>
movq   %rbx,%xmm1
punpckldq 0xec2(%rip),%xmm1
subpd  0xeca(%rip),%xmm1
mov    %rax,%r14
movapd %xmm1,%xmm0
unpckhpd %xmm1,%xmm0
addsd  %xmm1,%xmm0
cmp    $0x3e9,%rbx
jb     1181 <uireadablebyteslong+0x61>
cmp    $0xf4241,%rbx
jb     118a <uireadablebyteslong+0x6a>
cmp    $0x3b9aca01,%rbx
jb     119b <uireadablebyteslong+0x7b>
mulsd  0xeb8(%rip),%xmm0
lea    0xeb9(%rip),%rcx
jmp    11aa <uireadablebyteslong+0x8a>
lea    0xeb9(%rip),%rcx
jmp    11aa <uireadablebyteslong+0x8a>
mulsd  0xe8e(%rip),%xmm0
lea    0xea5(%rip),%rcx
jmp    11aa <uireadablebyteslong+0x8a>
mulsd  0xe85(%rip),%xmm0
lea    0xe91(%rip),%rcx
lea    0xe93(%rip),%rdx
mov    %r14,%rdi
mov    $0xa,%esi
call   1030 <snprintf@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"GB\00"
@.str.1 = [3 x i8] c"MB\00"
@.str.2 = [3 x i8] c"KB\00"
@.str.3 = [3 x i8] c" \00"
@.str.4 = [8 x i8] c"%3.3f%s\00"
define i8* @uireadablebyteslong(i64 %0) {
%2 = alloca i64
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca double
store i64 %0, i64* %2
%6 = call i8* @malloc(i32 10)
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %10
9: ; preds = %1
br label %10
10: ; preds = %9, %1
store i8* null, i8** %4
store double 0.000000e+00, double* %5
%11 = load i64, i64* %2
%12 = uitofp i64 %11 to double
%13 = fcmp ogt double %12, 1.000000e+03
br i1 %13, label %14, label %36
14: ; preds = %10
%15 = load i64, i64* %2
%16 = uitofp i64 %15 to double
%17 = fcmp ogt double %16, 1.000000e+06
br i1 %17, label %18, label %31
18: ; preds = %14
%19 = load i64, i64* %2
%20 = uitofp i64 %19 to double
%21 = fcmp ogt double %20, 1.000000e+09
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = load i64, i64* %2
%24 = uitofp i64 %23 to double
%25 = fdiv double %24, 0x41D0000000000000
store double %25, double* %5
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %4
br label %30
26: ; preds = %18
%27 = load i64, i64* %2
%28 = uitofp i64 %27 to double
%29 = fdiv double %28, 0x4130000000000000
store double %29, double* %5
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %4
br label %30
30: ; preds = %26, %22
br label %35
31: ; preds = %14
%32 = load i64, i64* %2
%33 = uitofp i64 %32 to double
%34 = fdiv double %33, 1.024000e+03
store double %34, double* %5
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %4
br label %35
35: ; preds = %31, %30
br label %39
36: ; preds = %10
%37 = load i64, i64* %2
%38 = uitofp i64 %37 to double
store double %38, double* %5
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8** %4
br label %39
39: ; preds = %36, %35
%40 = load i8*, i8** %3
%41 = load double, double* %5
%42 = load i8*, i8** %4
%43 = call i32 @snprintf(i8* %40, i32 10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), double %41, i8* %42)
%44 = load i8*, i8** %3
ret i8* %44
}

LLVM IR (-O2):
@.str = [3 x i8] c"GB\00"
@.str.1 = [3 x i8] c"MB\00"
@.str.2 = [3 x i8] c"KB\00"
@.str.3 = [3 x i8] c" \00"
@.str.4 = [8 x i8] c"%3.3f%s\00"
define i8* @uireadablebyteslong(i64 %0) {
%2 = tail call dereferenceable_or_null(10) i8* @malloc(i32 10)
%3 = uitofp i64 %0 to double
%4 = icmp ugt i64 %0, 1000
br i1 %4, label %5, label %15
5: ; preds = %1
%6 = icmp ugt i64 %0, 1000000
br i1 %6, label %7, label %13
7: ; preds = %5
%8 = icmp ugt i64 %0, 1000000000
br i1 %8, label %9, label %11
9: ; preds = %7
%10 = fmul double %3, 0x3E10000000000000
br label %15
11: ; preds = %7
%12 = fmul double %3, 0x3EB0000000000000
br label %15
13: ; preds = %5
%14 = fmul double %3, 0x3F50000000000000
br label %15
15: ; preds = %1, %13, %11, %9
%16 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %9 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %11 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %13 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), %1 ]
%17 = phi double [ %10, %9 ], [ %12, %11 ], [ %14, %13 ], [ %3, %1 ]
%18 = tail call i32 @snprintf(i8* %2, i32 10, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), double %17, i8* %16)
ret i8* %2
}