#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*/ delay(int);
int /*<<< orphan*/ init_uart();
int /*<<< orphan*/ mem_map();
int /*<<< orphan*/ mmu_init();
int /*<<< orphan*/ uart_send_hex(unsigned long);
int /*<<< orphan*/ uart_send_str(char *);
int dk_main(void) {
  unsigned long *ptr;
  init_uart();
  uart_send_str("\r\r\n>>In dk_main now!");
  ptr = (unsigned long *)0x30000000;
  uart_send_str("\r\nglobal_pages = ");
  uart_send_hex(*ptr);
  ++ptr;
  uart_send_str("\r\nglobal_i = ");
  uart_send_hex(*ptr);
  ++ptr;
  uart_send_str("\r\npages = ");
  uart_send_hex(*ptr);
  mem_map();
  mmu_init();
  uart_send_str("\r\n>>memory mapping succeed!");
  while (1) {
    (*(volatile unsigned long *)(0x56000000 + 0x14)) = 0x140;
    delay(300000);
    delay(300000);
    delay(300000);
    delay(300000);
    delay(300000);
    delay(300000);
    delay(300000);
    delay(300000);
    delay(300000);
    delay(300000);
    delay(300000);
    delay(300000);
    delay(300000);
    delay(300000);
    delay(300000);
    delay(300000);
    (*(volatile unsigned long *)(0x56000000 + 0x14)) = 0xa0;
    delay(300000);
    delay(300000);
    delay(300000);
    delay(300000);
    delay(300000);
    delay(300000);
    delay(300000);
    delay(300000);
    delay(300000);
    delay(300000);
    delay(300000);
    delay(300000);
    delay(300000);
    delay(300000);
    delay(300000);
    delay(300000);
  }
  return 0;
}


x86 assembly (clang, -O0):
<dk_main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1060 <init_uart@plt>
lea    0xe8a(%rip),%rdi
call   1040 <uart_send_str@plt>
mov    $0x30000000,%eax
mov    %rax,-0x8(%rbp)
lea    0xe8a(%rip),%rdi
call   1040 <uart_send_str@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1050 <uart_send_hex@plt>
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
lea    0xe78(%rip),%rdi
call   1040 <uart_send_str@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1050 <uart_send_hex@plt>
mov    -0x8(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
lea    0xe62(%rip),%rdi
call   1040 <uart_send_str@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1050 <uart_send_hex@plt>
mov    $0x0,%al
call   1080 <mem_map@plt>
mov    $0x0,%al
call   1070 <mmu_init@plt>
lea    0xe47(%rip),%rdi
call   1040 <uart_send_str@plt>
mov    $0x56000014,%eax
movq   $0x140,(%rax)
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x56000014,%eax
movq   $0xa0,(%rax)
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
jmp    11fe <dk_main+0x9e>

x86 assembly (clang, -O2):
<dk_main>:
push   %rax
xor    %eax,%eax
call   1060 <init_uart@plt>
lea    0xe91(%rip),%rdi
call   1040 <uart_send_str@plt>
lea    0xe9a(%rip),%rdi
call   1040 <uart_send_str@plt>
mov    0x30000000,%rdi
30
call   1050 <uart_send_hex@plt>
lea    0xe93(%rip),%rdi
call   1040 <uart_send_str@plt>
mov    0x30000008,%rdi
30
call   1050 <uart_send_hex@plt>
lea    0xe88(%rip),%rdi
call   1040 <uart_send_str@plt>
mov    0x30000010,%rdi
30
call   1050 <uart_send_hex@plt>
xor    %eax,%eax
call   1080 <mem_map@plt>
xor    %eax,%eax
call   1070 <mmu_init@plt>
lea    0xe6c(%rip),%rdi
call   1040 <uart_send_str@plt>
nopl   0x0(%rax)
movq   $0x140,0x56000014
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
movq   $0xa0,0x56000014
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
mov    $0x493e0,%edi
call   1030 <delay@plt>
jmp    11e0 <dk_main+0x80>

LLVM IR (-O0):
@.str = [21 x i8] c"\0D\0D\0A>>In dk_main now!\00"
@.str.1 = [18 x i8] c"\0D\0Aglobal_pages = \00"
@.str.2 = [14 x i8] c"\0D\0Aglobal_i = \00"
@.str.3 = [11 x i8] c"\0D\0Apages = \00"
@.str.4 = [28 x i8] c"\0D\0A>>memory mapping succeed!\00"
define i32 @dk_main() {
%1 = alloca i64*
%2 = call i32 (...) @init_uart()
%3 = call i32 @uart_send_str(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
store i64* inttoptr (i64 805306368 to i64*), i64** %1
%4 = call i32 @uart_send_str(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%5 = load i64*, i64** %1
%6 = load i64, i64* %5
%7 = call i32 @uart_send_hex(i64 %6)
%8 = load i64*, i64** %1
%9 = getelementptr inbounds i64, i64* %8, i32 1
store i64* %9, i64** %1
%10 = call i32 @uart_send_str(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%11 = load i64*, i64** %1
%12 = load i64, i64* %11
%13 = call i32 @uart_send_hex(i64 %12)
%14 = load i64*, i64** %1
%15 = getelementptr inbounds i64, i64* %14, i32 1
store i64* %15, i64** %1
%16 = call i32 @uart_send_str(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%17 = load i64*, i64** %1
%18 = load i64, i64* %17
%19 = call i32 @uart_send_hex(i64 %18)
%20 = call i32 (...) @mem_map()
%21 = call i32 (...) @mmu_init()
%22 = call i32 @uart_send_str(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
br label %23
23: ; preds = %0, %23
store volatile i64 320, i64* inttoptr (i64 1442840596 to i64*)
%24 = call i32 @delay(i32 300000)
%25 = call i32 @delay(i32 300000)
%26 = call i32 @delay(i32 300000)
%27 = call i32 @delay(i32 300000)
%28 = call i32 @delay(i32 300000)
%29 = call i32 @delay(i32 300000)
%30 = call i32 @delay(i32 300000)
%31 = call i32 @delay(i32 300000)
%32 = call i32 @delay(i32 300000)
%33 = call i32 @delay(i32 300000)
%34 = call i32 @delay(i32 300000)
%35 = call i32 @delay(i32 300000)
%36 = call i32 @delay(i32 300000)
%37 = call i32 @delay(i32 300000)
%38 = call i32 @delay(i32 300000)
%39 = call i32 @delay(i32 300000)
store volatile i64 160, i64* inttoptr (i64 1442840596 to i64*)
%40 = call i32 @delay(i32 300000)
%41 = call i32 @delay(i32 300000)
%42 = call i32 @delay(i32 300000)
%43 = call i32 @delay(i32 300000)
%44 = call i32 @delay(i32 300000)
%45 = call i32 @delay(i32 300000)
%46 = call i32 @delay(i32 300000)
%47 = call i32 @delay(i32 300000)
%48 = call i32 @delay(i32 300000)
%49 = call i32 @delay(i32 300000)
%50 = call i32 @delay(i32 300000)
%51 = call i32 @delay(i32 300000)
%52 = call i32 @delay(i32 300000)
%53 = call i32 @delay(i32 300000)
%54 = call i32 @delay(i32 300000)
%55 = call i32 @delay(i32 300000)
br label %23
}

LLVM IR (-O2):
@.str = [21 x i8] c"\0D\0D\0A>>In dk_main now!\00"
@.str.1 = [18 x i8] c"\0D\0Aglobal_pages = \00"
@.str.2 = [14 x i8] c"\0D\0Aglobal_i = \00"
@.str.3 = [11 x i8] c"\0D\0Apages = \00"
@.str.4 = [28 x i8] c"\0D\0A>>memory mapping succeed!\00"
define i32 @dk_main() {
%1 = tail call i32 (...) @init_uart()
%2 = tail call i32 @uart_send_str(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%3 = tail call i32 @uart_send_str(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%4 = load i64, i64* inttoptr (i64 805306368 to i64*)
%5 = tail call i32 @uart_send_hex(i64 %4)
%6 = tail call i32 @uart_send_str(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%7 = load i64, i64* inttoptr (i64 805306376 to i64*)
%8 = tail call i32 @uart_send_hex(i64 %7)
%9 = tail call i32 @uart_send_str(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%10 = load i64, i64* inttoptr (i64 805306384 to i64*)
%11 = tail call i32 @uart_send_hex(i64 %10)
%12 = tail call i32 (...) @mem_map()
%13 = tail call i32 (...) @mmu_init()
%14 = tail call i32 @uart_send_str(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
br label %15
15: ; preds = %15, %0
store volatile i64 320, i64* inttoptr (i64 1442840596 to i64*)
%16 = tail call i32 @delay(i32 300000)
%17 = tail call i32 @delay(i32 300000)
%18 = tail call i32 @delay(i32 300000)
%19 = tail call i32 @delay(i32 300000)
%20 = tail call i32 @delay(i32 300000)
%21 = tail call i32 @delay(i32 300000)
%22 = tail call i32 @delay(i32 300000)
%23 = tail call i32 @delay(i32 300000)
%24 = tail call i32 @delay(i32 300000)
%25 = tail call i32 @delay(i32 300000)
%26 = tail call i32 @delay(i32 300000)
%27 = tail call i32 @delay(i32 300000)
%28 = tail call i32 @delay(i32 300000)
%29 = tail call i32 @delay(i32 300000)
%30 = tail call i32 @delay(i32 300000)
%31 = tail call i32 @delay(i32 300000)
store volatile i64 160, i64* inttoptr (i64 1442840596 to i64*)
%32 = tail call i32 @delay(i32 300000)
%33 = tail call i32 @delay(i32 300000)
%34 = tail call i32 @delay(i32 300000)
%35 = tail call i32 @delay(i32 300000)
%36 = tail call i32 @delay(i32 300000)
%37 = tail call i32 @delay(i32 300000)
%38 = tail call i32 @delay(i32 300000)
%39 = tail call i32 @delay(i32 300000)
%40 = tail call i32 @delay(i32 300000)
%41 = tail call i32 @delay(i32 300000)
%42 = tail call i32 @delay(i32 300000)
%43 = tail call i32 @delay(i32 300000)
%44 = tail call i32 @delay(i32 300000)
%45 = tail call i32 @delay(i32 300000)
%46 = tail call i32 @delay(i32 300000)
%47 = tail call i32 @delay(i32 300000)
br label %15
}