#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 */
char UART0_GetChar();
int /*<<< orphan*/ UART0_Port_Init();
int /*<<< orphan*/ UART0_PutChar(char);
int /*<<< orphan*/ UART0_SendString(char *);
int /*<<< orphan*/ UART0_Set_BaudRate();
int /*<<< orphan*/ UART0_Set_Format();
int /*<<< orphan*/ irq_disable();
int /*<<< orphan*/ irq_enable();
int /*<<< orphan*/ leds_OFF_all();
int /*<<< orphan*/ leds_init();
int /*<<< orphan*/ timer_init(int /*<<< orphan*/, int, int, int,
                              int /*<<< orphan*/);
int main() {
  char data;
  leds_init();
  leds_OFF_all();
  timer_init(0, 66, 4, 65000, 0);
  UART0_Port_Init();
  UART0_Set_BaudRate();
  UART0_Set_Format();
  UART0_SendString("\n\rHello World!\n\r");
  while (1) {
    data = UART0_GetChar();
    irq_disable();
    UART0_PutChar(data);
    irq_enable();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1080 <leds_init@plt>
mov    $0x0,%al
call   10b0 <leds_OFF_all@plt>
xor    %r8d,%r8d
mov    $0x42,%esi
mov    $0x4,%edx
mov    $0xfde8,%ecx
mov    %r8d,%edi
call   1090 <timer_init@plt>
mov    $0x0,%al
call   1050 <UART0_Port_Init@plt>
mov    $0x0,%al
call   10a0 <UART0_Set_BaudRate@plt>
mov    $0x0,%al
call   10c0 <UART0_Set_Format@plt>
lea    0xdfd(%rip),%rdi
call   1070 <UART0_SendString@plt>
mov    $0x0,%al
call   10d0 <UART0_GetChar@plt>
mov    %al,-0x5(%rbp)
mov    $0x0,%al
call   1060 <irq_disable@plt>
movsbl -0x5(%rbp),%edi
call   1040 <UART0_PutChar@plt>
mov    $0x0,%al
call   1030 <irq_enable@plt>
jmp    1208 <main+0x58>

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1080 <leds_init@plt>
xor    %eax,%eax
call   10b0 <leds_OFF_all@plt>
xor    %edi,%edi
mov    $0x42,%esi
mov    $0x4,%edx
mov    $0xfde8,%ecx
xor    %r8d,%r8d
call   1090 <timer_init@plt>
xor    %eax,%eax
call   1050 <UART0_Port_Init@plt>
xor    %eax,%eax
call   10a0 <UART0_Set_BaudRate@plt>
xor    %eax,%eax
call   10c0 <UART0_Set_Format@plt>
lea    0xe0c(%rip),%rdi
call   1070 <UART0_SendString@plt>
nopl   0x0(%rax)
xor    %eax,%eax
call   10d0 <UART0_GetChar@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1060 <irq_disable@plt>
movsbl %bl,%edi
call   1040 <UART0_PutChar@plt>
xor    %eax,%eax
call   1030 <irq_enable@plt>
jmp    1200 <main+0x50>

LLVM IR (-O0):
@.str = [17 x i8] c"\0A\0DHello World!\0A\0D\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
store i32 0, i32* %1
%3 = call i32 (...) @leds_init()
%4 = call i32 (...) @leds_OFF_all()
%5 = call i32 @timer_init(i32 0, i32 66, i32 4, i32 65000, i32 0)
%6 = call i32 (...) @UART0_Port_Init()
%7 = call i32 (...) @UART0_Set_BaudRate()
%8 = call i32 (...) @UART0_Set_Format()
%9 = call i32 @UART0_SendString(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %0, %10
%11 = call signext i8 (...) @UART0_GetChar()
store i8 %11, i8* %2
%12 = call i32 (...) @irq_disable()
%13 = load i8, i8* %2
%14 = call i32 @UART0_PutChar(i8 signext %13)
%15 = call i32 (...) @irq_enable()
br label %10
}

LLVM IR (-O2):
@.str = [17 x i8] c"\0A\0DHello World!\0A\0D\00"
define i32 @main() {
%1 = tail call i32 (...) @leds_init()
%2 = tail call i32 (...) @leds_OFF_all()
%3 = tail call i32 @timer_init(i32 0, i32 66, i32 4, i32 65000, i32 0)
%4 = tail call i32 (...) @UART0_Port_Init()
%5 = tail call i32 (...) @UART0_Set_BaudRate()
%6 = tail call i32 (...) @UART0_Set_Format()
%7 = tail call i32 @UART0_SendString(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %8, %0
%9 = tail call signext i8 (...) @UART0_GetChar()
%10 = tail call i32 (...) @irq_disable()
%11 = tail call i32 @UART0_PutChar(i8 signext %9)
%12 = tail call i32 (...) @irq_enable()
br label %8
}