char *byteCount(double *size) {
  if (*size > 1000000000.0) {
    *size /= 1000000000.0;
    return "GB";
  }
  if (*size > 1000000.0) {
    *size /= 1000000.0;
    return "MB";
  }
  if (*size > 1000.0) {
    *size /= 1000.0;
    return "KB";
  }
  return "B";
}


x86 assembly (clang, -O0):
<byteCount>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xee8(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    114a <byteCount+0x4a>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xece(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
lea    0xed7(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d9 <byteCount+0xd9>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xeae(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    118c <byteCount+0x8c>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe94(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
lea    0xe98(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d9 <byteCount+0xd9>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe74(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    11ce <byteCount+0xce>
mov    -0x10(%rbp),%rax
movsd  (%rax),%xmm0
movsd  0xe5a(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rax)
lea    0xe59(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d9 <byteCount+0xd9>
lea    0xe44(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<byteCount>:
movsd  (%rdi),%xmm0
movsd  0xef4(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    111b <byteCount+0x1b>
lea    0xeff(%rip),%rax
jmp    1147 <byteCount+0x47>
movsd  0xee5(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1132 <byteCount+0x32>
lea    0xeeb(%rip),%rax
jmp    1147 <byteCount+0x47>
movsd  0xed6(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1150 <byteCount+0x50>
lea    0xed7(%rip),%rax
divsd  %xmm1,%xmm0
movsd  %xmm0,(%rdi)
ret
lea    0xec2(%rip),%rax
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 = [2 x i8] c"B\00"
define i8* @byteCount(double* %0) {
%2 = alloca i8*
%3 = alloca double*
store double* %0, double** %3
%4 = load double*, double** %3
%5 = load double, double* %4
%6 = fcmp ogt double %5, 1.000000e+09
br i1 %6, label %7, label %11
7: ; preds = %1
%8 = load double*, double** %3
%9 = load double, double* %8
%10 = fdiv double %9, 1.000000e+09
store double %10, double* %8
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %2
br label %28
11: ; preds = %1
%12 = load double*, double** %3
%13 = load double, double* %12
%14 = fcmp ogt double %13, 1.000000e+06
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = load double*, double** %3
%17 = load double, double* %16
%18 = fdiv double %17, 1.000000e+06
store double %18, double* %16
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %2
br label %28
19: ; preds = %11
%20 = load double*, double** %3
%21 = load double, double* %20
%22 = fcmp ogt double %21, 1.000000e+03
br i1 %22, label %23, label %27
23: ; preds = %19
%24 = load double*, double** %3
%25 = load double, double* %24
%26 = fdiv double %25, 1.000000e+03
store double %26, double* %24
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %28
27: ; preds = %19
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8** %2
br label %28
28: ; preds = %27, %23, %15, %7
%29 = load i8*, i8** %2
ret i8* %29
}

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 = [2 x i8] c"B\00"
define i8* @byteCount(double* nocapture %0) {
%2 = load double, double* %0
%3 = fcmp ogt double %2, 1.000000e+09
br i1 %3, label %8, label %4
4: ; preds = %1
%5 = fcmp ogt double %2, 1.000000e+06
br i1 %5, label %8, label %6
6: ; preds = %4
%7 = fcmp ogt double %2, 1.000000e+03
br i1 %7, label %8, label %12
8: ; preds = %6, %4, %1
%9 = phi double [ 1.000000e+09, %1 ], [ 1.000000e+06, %4 ], [ 1.000000e+03, %6 ]
%10 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), %1 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %4 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %6 ]
%11 = fdiv double %2, %9
store double %11, double* %0
br label %12
12: ; preds = %8, %6
%13 = phi i8* [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), %6 ], [ %10, %8 ]
ret i8* %13
}