#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 */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ uart_putf(char *, int);
void ddr_pll_config_x(void) {
  uint32_t clkmode, clksel, div_m2;
  uart_putf("DEBUG%i\n", (100));
  clkmode = *(uint32_t *)(0x44E00494);
  clksel = *(uint32_t *)(0x44E00440);
  div_m2 = *(uint32_t *)(0x44E004A0);
  clkmode = (clkmode & 0xfffffff8) | 0x00000004;
  *(uint32_t *)(0x44E00494) = (uint32_t)(clkmode);
  uart_putf("DEBUG%i\n", (101));
  while ((*(uint32_t *)(0x44E00434) & 0x00000100) != 0x00000100)
    ;
  uart_putf("DEBUG%i\n", (102));
  clksel = clksel & (~0x7ffff);
  clksel = clksel | ((400 << 0x8) | ((24000000 / 1000000) - 1));
  *(uint32_t *)(0x44E00440) = (uint32_t)(clksel);
  uart_putf("DEBUG%i\n", (103));
  div_m2 = div_m2 & 0xFFFFFFE0;
  div_m2 = div_m2 | 1;
  *(uint32_t *)(0x44E004A0) = (uint32_t)(div_m2);
  uart_putf("DEBUG%i\n", (104));
  clkmode = (clkmode & 0xfffffff8) | 0x00000007;
  *(uint32_t *)(0x44E00494) = (uint32_t)(clkmode);
  uart_putf("DEBUG%i\n", (105));
  while ((*(uint32_t *)(0x44E00434) & 0x00000001) != 0x00000001)
    ;
  uart_putf("DEBUG%i\n", (106));
}


x86 assembly (clang, -O0):
<ddr_pll_config_x>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xee1(%rip),%rdi
mov    $0x64,%esi
call   1030 <uart_putf@plt>
mov    $0x44e00494,%eax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    $0x44e00440,%eax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    $0x44e004a0,%eax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
and    $0xfffffff8,%eax
or     $0x4,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%ecx
mov    $0x44e00494,%eax
mov    %ecx,(%rax)
lea    0xe9c(%rip),%rdi
mov    $0x65,%esi
call   1030 <uart_putf@plt>
mov    $0x44e00434,%eax
mov    (%rax),%eax
and    $0x100,%eax
cmp    $0x100,%eax
je     118a <ddr_pll_config_x+0x7a>
jmp    116e <ddr_pll_config_x+0x5e>
lea    0xe6f(%rip),%rdi
mov    $0x66,%esi
call   1030 <uart_putf@plt>
mov    -0x8(%rbp),%eax
and    $0xfff80000,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
or     $0x19017,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%ecx
mov    $0x44e00440,%eax
mov    %ecx,(%rax)
lea    0xe3e(%rip),%rdi
mov    $0x67,%esi
call   1030 <uart_putf@plt>
mov    -0xc(%rbp),%eax
and    $0xffffffe0,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
mov    $0x44e004a0,%eax
mov    %ecx,(%rax)
lea    0xe11(%rip),%rdi
mov    $0x68,%esi
call   1030 <uart_putf@plt>
mov    -0x4(%rbp),%eax
and    $0xfffffff8,%eax
or     $0x7,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%ecx
mov    $0x44e00494,%eax
mov    %ecx,(%rax)
lea    0xdea(%rip),%rdi
mov    $0x69,%esi
call   1030 <uart_putf@plt>
mov    $0x44e00434,%eax
mov    (%rax),%eax
and    $0x1,%eax
cmp    $0x1,%eax
je     1238 <ddr_pll_config_x+0x128>
jmp    1220 <ddr_pll_config_x+0x110>
lea    0xdc1(%rip),%rdi
mov    $0x6a,%esi
call   1030 <uart_putf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ddr_pll_config_x>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xee2(%rip),%r14
mov    %r14,%rdi
mov    $0x64,%esi
call   1030 <uart_putf@plt>
mov    0x44e00440,%ebp
mov    0x44e00494,%r15d
44
mov    0x44e004a0,%ebx
mov    %r15d,%eax
and    $0xfffffff8,%eax
or     $0x4,%eax
mov    %eax,0x44e00494
mov    %r14,%rdi
mov    $0x65,%esi
call   1030 <uart_putf@plt>
testb  $0x1,0x44e00435
01
jne    1172 <ddr_pll_config_x+0x62>
nopl   0x0(%rax,%rax,1)
jmp    1170 <ddr_pll_config_x+0x60>
lea    0xe87(%rip),%r14
mov    %r14,%rdi
mov    $0x66,%esi
call   1030 <uart_putf@plt>
and    $0xfff80000,%ebp
or     $0x19017,%ebp
mov    %ebp,0x44e00440
mov    %r14,%rdi
mov    $0x67,%esi
call   1030 <uart_putf@plt>
and    $0xffffffe0,%ebx
or     $0x1,%ebx
mov    %ebx,0x44e004a0
mov    %r14,%rdi
mov    $0x68,%esi
call   1030 <uart_putf@plt>
or     $0x7,%r15d
mov    %r15d,0x44e00494
44
mov    %r14,%rdi
mov    $0x69,%esi
call   1030 <uart_putf@plt>
testb  $0x1,0x44e00434
01
jne    11f2 <ddr_pll_config_x+0xe2>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
jmp    11f0 <ddr_pll_config_x+0xe0>
lea    0xe07(%rip),%rdi
mov    $0x6a,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <uart_putf@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"DEBUG%i\0A\00"
define void @ddr_pll_config_x() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @uart_putf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 100)
%5 = load i32, i32* inttoptr (i64 1155531924 to i32*)
store i32 %5, i32* %1
%6 = load i32, i32* inttoptr (i64 1155531840 to i32*)
store i32 %6, i32* %2
%7 = load i32, i32* inttoptr (i64 1155531936 to i32*)
store i32 %7, i32* %3
%8 = load i32, i32* %1
%9 = and i32 %8, -8
%10 = or i32 %9, 4
store i32 %10, i32* %1
%11 = load i32, i32* %1
store i32 %11, i32* inttoptr (i64 1155531924 to i32*)
%12 = call i32 @uart_putf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 101)
br label %13
13: ; preds = %17, %0
%14 = load i32, i32* inttoptr (i64 1155531828 to i32*)
%15 = and i32 %14, 256
%16 = icmp ne i32 %15, 256
br i1 %16, label %17, label %18
17: ; preds = %13
br label %13
18: ; preds = %13
%19 = call i32 @uart_putf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 102)
%20 = load i32, i32* %2
%21 = and i32 %20, -524288
store i32 %21, i32* %2
%22 = load i32, i32* %2
%23 = or i32 %22, 102423
store i32 %23, i32* %2
%24 = load i32, i32* %2
store i32 %24, i32* inttoptr (i64 1155531840 to i32*)
%25 = call i32 @uart_putf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 103)
%26 = load i32, i32* %3
%27 = and i32 %26, -32
store i32 %27, i32* %3
%28 = load i32, i32* %3
%29 = or i32 %28, 1
store i32 %29, i32* %3
%30 = load i32, i32* %3
store i32 %30, i32* inttoptr (i64 1155531936 to i32*)
%31 = call i32 @uart_putf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 104)
%32 = load i32, i32* %1
%33 = and i32 %32, -8
%34 = or i32 %33, 7
store i32 %34, i32* %1
%35 = load i32, i32* %1
store i32 %35, i32* inttoptr (i64 1155531924 to i32*)
%36 = call i32 @uart_putf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 105)
br label %37
37: ; preds = %41, %18
%38 = load i32, i32* inttoptr (i64 1155531828 to i32*)
%39 = and i32 %38, 1
%40 = icmp ne i32 %39, 1
br i1 %40, label %41, label %42
41: ; preds = %37
br label %37
42: ; preds = %37
%43 = call i32 @uart_putf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 106)
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"DEBUG%i\0A\00"
define void @ddr_pll_config_x() {
%1 = tail call i32 @uart_putf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 100)
%2 = load i32, i32* inttoptr (i64 1155531924 to i32*)
%3 = load i32, i32* inttoptr (i64 1155531840 to i32*)
%4 = load i32, i32* inttoptr (i64 1155531936 to i32*)
%5 = and i32 %2, -8
%6 = or i32 %5, 4
store i32 %6, i32* inttoptr (i64 1155531924 to i32*)
%7 = tail call i32 @uart_putf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 101)
%8 = load i32, i32* inttoptr (i64 1155531828 to i32*)
%9 = and i32 %8, 256
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %0, %11
br label %11
12: ; preds = %0
%13 = tail call i32 @uart_putf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 102)
%14 = and i32 %3, -524288
%15 = or i32 %14, 102423
store i32 %15, i32* inttoptr (i64 1155531840 to i32*)
%16 = tail call i32 @uart_putf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 103)
%17 = and i32 %4, -32
%18 = or i32 %17, 1
store i32 %18, i32* inttoptr (i64 1155531936 to i32*)
%19 = tail call i32 @uart_putf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 104)
%20 = or i32 %2, 7
store i32 %20, i32* inttoptr (i64 1155531924 to i32*)
%21 = tail call i32 @uart_putf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 105)
%22 = load i32, i32* inttoptr (i64 1155531828 to i32*)
%23 = and i32 %22, 1
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %12, %25
br label %25
26: ; preds = %12
%27 = tail call i32 @uart_putf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 106)
ret void
}