#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*/ serial_put_dec(unsigned int);
int /*<<< orphan*/ serial_puts(char *);
void print_ddr_size(unsigned int size) {
  unsigned int mem_size = size >> 20;
  (mem_size) >= 1024 ? serial_put_dec(mem_size >> 10)
                     : serial_put_dec(mem_size);
  (((mem_size >> 9) & 0x1) && ((mem_size) >= 1024)) ? serial_puts(".5") : 0;
  (mem_size) >= 1024 ? serial_puts("GB") : serial_puts("MB");
}


x86 assembly (clang, -O0):
<print_ddr_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
shr    $0x14,%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x400,-0x8(%rbp)
jb     1151 <print_ddr_size+0x31>
mov    -0x8(%rbp),%edi
shr    $0xa,%edi
call   1040 <serial_put_dec@plt>
jmp    1159 <print_ddr_size+0x39>
mov    -0x8(%rbp),%edi
call   1040 <serial_put_dec@plt>
mov    -0x8(%rbp),%eax
shr    $0x9,%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1189 <print_ddr_size+0x69>
cmpl   $0x400,-0x8(%rbp)
jb     1189 <print_ddr_size+0x69>
lea    0xe81(%rip),%rdi
call   1030 <serial_puts@plt>
jmp    118e <print_ddr_size+0x6e>
jmp    118e <print_ddr_size+0x6e>
cmpl   $0x400,-0x8(%rbp)
jb     11ac <print_ddr_size+0x8c>
lea    0xe61(%rip),%rdi
call   1030 <serial_puts@plt>
jmp    11b8 <print_ddr_size+0x98>
lea    0xe53(%rip),%rdi
call   1030 <serial_puts@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_ddr_size>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebp
cmp    $0x40000000,%edi
jb     1154 <print_ddr_size+0x34>
mov    %ebp,%edi
shr    $0x1e,%edi
call   1040 <serial_put_dec@plt>
lea    0xec5(%rip),%rbx
test   $0x20000000,%ebp
je     1165 <print_ddr_size+0x45>
lea    0xeb3(%rip),%rdi
call   1030 <serial_puts@plt>
jmp    1165 <print_ddr_size+0x45>
shr    $0x14,%ebp
mov    %ebp,%edi
call   1040 <serial_put_dec@plt>
lea    0xea1(%rip),%rbx
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <serial_puts@plt>

LLVM IR (-O0):
@.str = [3 x i8] c".5\00"
@.str.1 = [3 x i8] c"GB\00"
@.str.2 = [3 x i8] c"MB\00"
define void @print_ddr_size(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = lshr i32 %4, 20
store i32 %5, i32* %3
%6 = load i32, i32* %3
%7 = icmp uge i32 %6, 1024
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i32, i32* %3
%10 = lshr i32 %9, 10
%11 = call i32 @serial_put_dec(i32 %10)
br label %15
12: ; preds = %1
%13 = load i32, i32* %3
%14 = call i32 @serial_put_dec(i32 %13)
br label %15
15: ; preds = %12, %8
%16 = phi i32 [ %11, %8 ], [ %14, %12 ]
%17 = load i32, i32* %3
%18 = lshr i32 %17, 9
%19 = and i32 %18, 1
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %15
%22 = load i32, i32* %3
%23 = icmp uge i32 %22, 1024
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 @serial_puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %27
26: ; preds = %21, %15
br label %27
27: ; preds = %26, %24
%28 = phi i32 [ %25, %24 ], [ 0, %26 ]
%29 = load i32, i32* %3
%30 = icmp uge i32 %29, 1024
br i1 %30, label %31, label %33
31: ; preds = %27
%32 = call i32 @serial_puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %35
33: ; preds = %27
%34 = call i32 @serial_puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %35
35: ; preds = %33, %31
%36 = phi i32 [ %32, %31 ], [ %34, %33 ]
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c".5\00"
@.str.1 = [3 x i8] c"GB\00"
@.str.2 = [3 x i8] c"MB\00"
define void @print_ddr_size(i32 %0) {
%2 = icmp ugt i32 %0, 1073741823
br i1 %2, label %3, label %10
3: ; preds = %1
%4 = lshr i32 %0, 30
%5 = tail call i32 @serial_put_dec(i32 %4)
%6 = and i32 %0, 536870912
%7 = icmp eq i32 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %3
%9 = tail call i32 @serial_puts(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %13
10: ; preds = %1
%11 = lshr i32 %0, 20
%12 = tail call i32 @serial_put_dec(i32 %11)
br label %13
13: ; preds = %8, %3, %10
%14 = phi i8* [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), %10 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %3 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), %8 ]
%15 = tail call i32 @serial_puts(i8* %14)
ret void
}