#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*/ init_ddr3_ram();
int /*<<< orphan*/ init_led();
scalar_t__ ram_test(int /*<<< orphan*/);
int /*<<< orphan*/ usr_led_on(int);
void main() {
  unsigned int *p = (unsigned int *)0x80000000 + 512;
  init_led();
  init_ddr3_ram();
  if (ram_test(0))
    usr_led_on(1);
  else
    usr_led_on(3);
  *p = 3;
  *(p + 1) = 8;
  *(p + 2) = (*p) + (*(p + 1));
  if (*(p + 2) == 11)
    usr_led_on(2);
  else
    usr_led_on(3);
  while (1)
    ;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x80000000,%eax
add    $0x800,%rax
mov    %rax,-0x8(%rbp)
mov    $0x0,%al
call   1030 <init_led@plt>
mov    $0x0,%al
call   1040 <init_ddr3_ram@plt>
xor    %edi,%edi
call   1060 <ram_test@plt>
cmp    $0x0,%rax
je     1185 <main+0x45>
mov    $0x1,%edi
call   1050 <usr_led_on@plt>
jmp    118f <main+0x4f>
mov    $0x3,%edi
call   1050 <usr_led_on@plt>
mov    -0x8(%rbp),%rax
movl   $0x3,(%rax)
mov    -0x8(%rbp),%rax
movl   $0x8,0x4(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
add    0x4(%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x8(%rbp),%rax
cmpl   $0xb,0x8(%rax)
jne    11d5 <main+0x95>
mov    $0x2,%edi
call   1050 <usr_led_on@plt>
jmp    11df <main+0x9f>
mov    $0x3,%edi
call   1050 <usr_led_on@plt>
jmp    11e4 <main+0xa4>
jmp    11e4 <main+0xa4>

x86 assembly (clang, -O2):
<main>:
push   %rax
xor    %eax,%eax
call   1030 <init_led@plt>
xor    %eax,%eax
call   1040 <init_ddr3_ram@plt>
xor    %edi,%edi
call   1060 <ram_test@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
lea    (%rcx,%rcx,1),%edi
add    $0x1,%edi
call   1050 <usr_led_on@plt>
movabs $0x800000003,%rax
mov    $0x80000800,%ecx
mov    %rax,(%rcx)
movl   $0xb,0x8(%rcx)
mov    $0x2,%edi
call   1050 <usr_led_on@plt>
nopl   0x0(%rax)
jmp    1190 <main+0x50>

LLVM IR (-O0):
define void @main() {
%1 = alloca i32*
store i32* getelementptr inbounds (i32, i32* inttoptr (i64 2147483648 to i32*), i64 512), i32** %1
%2 = call i32 (...) @init_led()
%3 = call i32 (...) @init_ddr3_ram()
%4 = call i64 @ram_test(i32 0)
%5 = icmp ne i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = call i32 @usr_led_on(i32 1)
br label %10
8: ; preds = %0
%9 = call i32 @usr_led_on(i32 3)
br label %10
10: ; preds = %8, %6
%11 = load i32*, i32** %1
store i32 3, i32* %11
%12 = load i32*, i32** %1
%13 = getelementptr inbounds i32, i32* %12, i64 1
store i32 8, i32* %13
%14 = load i32*, i32** %1
%15 = load i32, i32* %14
%16 = load i32*, i32** %1
%17 = getelementptr inbounds i32, i32* %16, i64 1
%18 = load i32, i32* %17
%19 = add i32 %15, %18
%20 = load i32*, i32** %1
%21 = getelementptr inbounds i32, i32* %20, i64 2
store i32 %19, i32* %21
%22 = load i32*, i32** %1
%23 = getelementptr inbounds i32, i32* %22, i64 2
%24 = load i32, i32* %23
%25 = icmp eq i32 %24, 11
br i1 %25, label %26, label %28
26: ; preds = %10
%27 = call i32 @usr_led_on(i32 2)
br label %30
28: ; preds = %10
%29 = call i32 @usr_led_on(i32 3)
br label %30
30: ; preds = %28, %26
br label %31
31: ; preds = %30, %31
br label %31
}

LLVM IR (-O2):
define void @main() {
%1 = tail call i32 (...) @init_led()
%2 = tail call i32 (...) @init_ddr3_ram()
%3 = tail call i64 @ram_test(i32 0)
%4 = icmp eq i64 %3, 0
%5 = select i1 %4, i32 3, i32 1
%6 = tail call i32 @usr_led_on(i32 %5)
store i32 3, i32* inttoptr (i64 2147485696 to i32*)
store i32 8, i32* inttoptr (i64 2147485700 to i32*)
%7 = load i32, i32* inttoptr (i64 2147485696 to i32*)
%8 = add i32 %7, 8
store i32 %8, i32* inttoptr (i64 2147485704 to i32*)
%9 = icmp eq i32 %8, 11
%10 = select i1 %9, i32 2, i32 3
%11 = tail call i32 @usr_led_on(i32 %10)
br label %12
12: ; preds = %12, %0
br label %12
}