#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 */
double _gb(double);
double _kb(double);
double _mb(double);
int /*<<< orphan*/ sprintf(char *, char *, double);
char *_mbstr(double n) {
  static char str[100];
  if (n < 1024 * 1024 * 10)
    sprintf(str, "%.3fkb", _kb(n));
  else if (n < 1024 * 1024 * 1024)
    sprintf(str, "%.1fMB", _mb(n));
  else
    sprintf(str, "%.2fGB", _gb(n));
  return (str);
}


x86 assembly (clang, -O0):
<_mbstr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  0xeab(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    1182 <_mbstr+0x42>
movsd  -0x8(%rbp),%xmm0
call   1040 <_kb@plt>
lea    0x2edf(%rip),%rdi
lea    0xe98(%rip),%rsi
call   1050 <sprintf@plt>
jmp    11d9 <_mbstr+0x99>
movsd  0xe7e(%rip),%xmm0
ucomisd -0x8(%rbp),%xmm0
jbe    11b7 <_mbstr+0x77>
movsd  -0x8(%rbp),%xmm0
call   1030 <_mb@plt>
lea    0x2eaa(%rip),%rdi
lea    0xe6a(%rip),%rsi
call   1050 <sprintf@plt>
jmp    11d4 <_mbstr+0x94>
movsd  -0x8(%rbp),%xmm0
call   1060 <_gb@plt>
lea    0x2e88(%rip),%rdi
lea    0xe4f(%rip),%rsi
call   1050 <sprintf@plt>
jmp    11d9 <_mbstr+0x99>
lea    0x2e70(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_mbstr>:
push   %rax
movsd  0xeb7(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1164 <_mbstr+0x24>
call   1040 <_kb@plt>
lea    0x2ef5(%rip),%rdi
lea    0xeae(%rip),%rsi
jmp    119a <_mbstr+0x5a>
movsd  0xe9c(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1187 <_mbstr+0x47>
call   1030 <_mb@plt>
lea    0x2ed2(%rip),%rdi
lea    0xe92(%rip),%rsi
jmp    119a <_mbstr+0x5a>
call   1060 <_gb@plt>
lea    0x2ebd(%rip),%rdi
lea    0xe84(%rip),%rsi
call   1050 <sprintf@plt>
lea    0x2eaa(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
@_mbstr.str = internal global [100 x i8] zeroinitializer
@.str = [7 x i8] c"%.3fkb\00"
@.str.1 = [7 x i8] c"%.1fMB\00"
@.str.2 = [7 x i8] c"%.2fGB\00"
define i8* @_mbstr(double %0) {
%2 = alloca double
store double %0, double* %2
%3 = load double, double* %2
%4 = fcmp olt double %3, 0x4164000000000000
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = load double, double* %2
%7 = call double @_kb(double %6)
%8 = call i32 @sprintf(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @_mbstr.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %7)
br label %21
9: ; preds = %1
%10 = load double, double* %2
%11 = fcmp olt double %10, 0x41D0000000000000
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = load double, double* %2
%14 = call double @_mb(double %13)
%15 = call i32 @sprintf(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @_mbstr.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %14)
br label %20
16: ; preds = %9
%17 = load double, double* %2
%18 = call double @_gb(double %17)
%19 = call i32 @sprintf(i8* getelementptr inbounds ([100 x i8], [100 x i8]* @_mbstr.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %18)
br label %20
20: ; preds = %16, %12
br label %21
21: ; preds = %20, %5
ret i8* getelementptr inbounds ([100 x i8], [100 x i8]* @_mbstr.str, i64 0, i64 0)
}

LLVM IR (-O2):
@_mbstr.str = internal global [100 x i8] zeroinitializer
@.str = [7 x i8] c"%.3fkb\00"
@.str.1 = [7 x i8] c"%.1fMB\00"
@.str.2 = [7 x i8] c"%.2fGB\00"
define i8* @_mbstr(double %0) {
%2 = fcmp olt double %0, 0x4164000000000000
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = tail call double @_kb(double %0)
%5 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([100 x i8], [100 x i8]* @_mbstr.str, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), double %4)
br label %14
6: ; preds = %1
%7 = fcmp olt double %0, 0x41D0000000000000
br i1 %7, label %8, label %11
8: ; preds = %6
%9 = tail call double @_mb(double %0)
%10 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([100 x i8], [100 x i8]* @_mbstr.str, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %9)
br label %14
11: ; preds = %6
%12 = tail call double @_gb(double %0)
%13 = tail call i32 @sprintf(i8* dereferenceable(1) getelementptr inbounds ([100 x i8], [100 x i8]* @_mbstr.str, i64 0, i64 0), i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), double %12)
br label %14
14: ; preds = %8, %11, %3
ret i8* getelementptr inbounds ([100 x i8], [100 x i8]* @_mbstr.str, i64 0, i64 0)
}