#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 */
int /*<<< orphan*/ snprintf(char *, int, char *, float);
const char *MemString(int bytes) {
  static char buf[20];
  if (bytes > 1024 * 1024 * 1024 / 2)
    snprintf(buf, 20, "%0.1fG", (float)bytes / (1024 * 1024 * 1024));
  else if (bytes > 1024 * 1024 / 2)
    snprintf(buf, 20, "%0.1fM", (float)bytes / (1024 * 1024));
  else if (bytes > 1024 / 2)
    snprintf(buf, 20, "%0.1fk", (float)bytes / 1024);
  else
    buf[0] = 0;
  return buf;
}


x86 assembly (clang, -O0):
<MemString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x20000000,-0x4(%rbp)
jle    1156 <MemString+0x46>
cvtsi2ssl -0x4(%rbp),%xmm0
movss  0xed3(%rip),%xmm1
divss  %xmm1,%xmm0
lea    0x2f00(%rip),%rdi
mov    $0x14,%esi
lea    0xec0(%rip),%rdx
call   1030 <snprintf@plt>
jmp    11dd <MemString+0xcd>
cmpl   $0x80000,-0x4(%rbp)
jle    1191 <MemString+0x81>
cvtsi2ssl -0x4(%rbp),%xmm0
movss  0xe94(%rip),%xmm1
divss  %xmm1,%xmm0
lea    0x2ec5(%rip),%rdi
mov    $0x14,%esi
lea    0xe8c(%rip),%rdx
call   1030 <snprintf@plt>
jmp    11d8 <MemString+0xc8>
cmpl   $0x200,-0x4(%rbp)
jle    11cc <MemString+0xbc>
cvtsi2ssl -0x4(%rbp),%xmm0
movss  0xe55(%rip),%xmm1
divss  %xmm1,%xmm0
lea    0x2e8a(%rip),%rdi
mov    $0x14,%esi
lea    0xe58(%rip),%rdx
call   1030 <snprintf@plt>
jmp    11d3 <MemString+0xc3>
movb   $0x0,0x2e6d(%rip)
jmp    11d8 <MemString+0xc8>
jmp    11dd <MemString+0xcd>
lea    0x2e5c(%rip),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MemString>:
push   %rax
cmp    $0x20000001,%edi
jl     1135 <MemString+0x25>
cvtsi2ss %edi,%xmm0
mulss  0xee3(%rip),%xmm0
lea    0x2f14(%rip),%rdi
lea    0xed9(%rip),%rdx
jmp    117b <MemString+0x6b>
cmp    $0x80001,%edi
jl     1159 <MemString+0x49>
cvtsi2ss %edi,%xmm0
mulss  0xebb(%rip),%xmm0
lea    0x2ef0(%rip),%rdi
lea    0xebc(%rip),%rdx
jmp    117b <MemString+0x6b>
cmp    $0x201,%edi
jl     118e <MemString+0x7e>
cvtsi2ss %edi,%xmm0
mulss  0xe93(%rip),%xmm0
lea    0x2ecc(%rip),%rdi
lea    0xe9f(%rip),%rdx
mov    $0x14,%esi
call   1030 <snprintf@plt>
lea    0x2eb4(%rip),%rax
pop    %rcx
ret
movb   $0x0,0x2eab(%rip)
jmp    1185 <MemString+0x75>

LLVM IR (-O0):
@MemString.buf = internal global [20 x i8] zeroinitializer
@.str = [7 x i8] c"%0.1fG\00"
@.str.1 = [7 x i8] c"%0.1fM\00"
@.str.2 = [7 x i8] c"%0.1fk\00"
define i8* @MemString(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp sgt i32 %3, 536870912
br i1 %4, label %5, label %10
5: ; preds = %1
%6 = load i32, i32* %2
%7 = sitofp i32 %6 to float
%8 = fdiv float %7, 0x41D0000000000000
%9 = call i32 @snprintf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @MemString.buf, i64 0, i64 0), i32 20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), float %8)
br label %29
10: ; preds = %1
%11 = load i32, i32* %2
%12 = icmp sgt i32 %11, 524288
br i1 %12, label %13, label %18
13: ; preds = %10
%14 = load i32, i32* %2
%15 = sitofp i32 %14 to float
%16 = fdiv float %15, 0x4130000000000000
%17 = call i32 @snprintf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @MemString.buf, i64 0, i64 0), i32 20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), float %16)
br label %28
18: ; preds = %10
%19 = load i32, i32* %2
%20 = icmp sgt i32 %19, 512
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load i32, i32* %2
%23 = sitofp i32 %22 to float
%24 = fdiv float %23, 1.024000e+03
%25 = call i32 @snprintf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @MemString.buf, i64 0, i64 0), i32 20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), float %24)
br label %27
26: ; preds = %18
store i8 0, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @MemString.buf, i64 0, i64 0)
br label %27
27: ; preds = %26, %21
br label %28
28: ; preds = %27, %13
br label %29
29: ; preds = %28, %5
ret i8* getelementptr inbounds ([20 x i8], [20 x i8]* @MemString.buf, i64 0, i64 0)
}

LLVM IR (-O2):
@MemString.buf = internal global [20 x i8] zeroinitializer
@.str = [7 x i8] c"%0.1fG\00"
@.str.1 = [7 x i8] c"%0.1fM\00"
@.str.2 = [7 x i8] c"%0.1fk\00"
define i8* @MemString(i32 %0) {
%2 = icmp sgt i32 %0, 536870912
br i1 %2, label %3, label %7
3: ; preds = %1
%4 = sitofp i32 %0 to float
%5 = fmul float %4, 0x3E10000000000000
%6 = tail call i32 @snprintf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @MemString.buf, i64 0, i64 0), i32 20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), float %5)
br label %20
7: ; preds = %1
%8 = icmp sgt i32 %0, 524288
br i1 %8, label %9, label %13
9: ; preds = %7
%10 = sitofp i32 %0 to float
%11 = fmul float %10, 0x3EB0000000000000
%12 = tail call i32 @snprintf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @MemString.buf, i64 0, i64 0), i32 20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), float %11)
br label %20
13: ; preds = %7
%14 = icmp sgt i32 %0, 512
br i1 %14, label %15, label %19
15: ; preds = %13
%16 = sitofp i32 %0 to float
%17 = fmul float %16, 0x3F50000000000000
%18 = tail call i32 @snprintf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @MemString.buf, i64 0, i64 0), i32 20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), float %17)
br label %20
19: ; preds = %13
store i8 0, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @MemString.buf, i64 0, i64 0)
br label %20
20: ; preds = %9, %19, %15, %3
ret i8* getelementptr inbounds ([20 x i8], [20 x i8]* @MemString.buf, i64 0, i64 0)
}