#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 */
unsigned int GET32(int);
int /*<<< orphan*/ NOP();
int /*<<< orphan*/ PUT32(int, int);
void uart_init() {
  unsigned int ra;
  PUT32(0x20215004, 1);
  PUT32(0x20215044, 0);
  PUT32(0x20215060, 0);
  PUT32(0x2021504C, 3);
  PUT32(0x20215050, 0);
  PUT32(0x20215044, 0);
  PUT32(0x20215048, 0xC6);
  PUT32(0x20215068, 270);
  ra = GET32(((0x20000000 + 0x200000) + 4));
  ra &= ~(7 << 12);
  ra |= 2 << 12;
  ra &= ~(7 << 15);
  ra |= 2 << 15;
  PUT32(((0x20000000 + 0x200000) + 4), ra);
  PUT32(((0x20000000 + 0x200000) + 0x94), 0);
  for (int i = 0; i < 150; i++) {
    NOP();
  }
  PUT32(((0x20000000 + 0x200000) + 0x98), (1 << 14) | (1 << 15));
  for (int i = 0; i < 150; i++) {
    NOP();
  }
  PUT32(((0x20000000 + 0x200000) + 0x98), 0);
  PUT32(0x20215060, 3);
}


x86 assembly (clang, -O0):
<uart_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x20215004,%edi
mov    $0x1,%esi
call   1040 <PUT32@plt>
mov    $0x20215044,%edi
xor    %esi,%esi
call   1040 <PUT32@plt>
mov    $0x20215060,%edi
xor    %esi,%esi
call   1040 <PUT32@plt>
mov    $0x2021504c,%edi
mov    $0x3,%esi
call   1040 <PUT32@plt>
mov    $0x20215050,%edi
xor    %esi,%esi
call   1040 <PUT32@plt>
mov    $0x20215044,%edi
xor    %esi,%esi
call   1040 <PUT32@plt>
mov    $0x20215048,%edi
mov    $0xc6,%esi
call   1040 <PUT32@plt>
mov    $0x20215068,%edi
mov    $0x10e,%esi
call   1040 <PUT32@plt>
mov    $0x20200004,%edi
call   1050 <GET32@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xffff8fff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
or     $0x2000,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0xfffc7fff,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
or     $0x10000,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
mov    $0x20200004,%edi
call   1040 <PUT32@plt>
mov    $0x20200094,%edi
xor    %esi,%esi
call   1040 <PUT32@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x96,-0x8(%rbp)
jge    121f <uart_init+0xef>
mov    $0x0,%al
call   1030 <NOP@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11fd <uart_init+0xcd>
mov    $0x20200098,%edi
mov    $0xc000,%esi
call   1040 <PUT32@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x96,-0xc(%rbp)
jge    1257 <uart_init+0x127>
mov    $0x0,%al
call   1030 <NOP@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1235 <uart_init+0x105>
mov    $0x20200098,%edi
xor    %esi,%esi
call   1040 <PUT32@plt>
mov    $0x20215060,%edi
mov    $0x3,%esi
call   1040 <PUT32@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uart_init>:
push   %rbx
mov    $0x20215004,%edi
mov    $0x1,%esi
call   1040 <PUT32@plt>
mov    $0x20215044,%edi
xor    %esi,%esi
call   1040 <PUT32@plt>
mov    $0x20215060,%edi
xor    %esi,%esi
call   1040 <PUT32@plt>
mov    $0x2021504c,%edi
mov    $0x3,%esi
call   1040 <PUT32@plt>
mov    $0x20215050,%edi
xor    %esi,%esi
call   1040 <PUT32@plt>
mov    $0x20215044,%edi
xor    %esi,%esi
call   1040 <PUT32@plt>
mov    $0x20215048,%edi
mov    $0xc6,%esi
call   1040 <PUT32@plt>
mov    $0x20215068,%edi
mov    $0x10e,%esi
call   1040 <PUT32@plt>
mov    $0x20200004,%edi
call   1050 <GET32@plt>
and    $0xfffc0fff,%eax
lea    0x12000(%rax),%esi
mov    $0x20200004,%edi
call   1040 <PUT32@plt>
mov    $0x20200094,%edi
xor    %esi,%esi
call   1040 <PUT32@plt>
mov    $0x96,%ebx
nopl   (%rax)
xor    %eax,%eax
call   1030 <NOP@plt>
add    $0xffffffff,%ebx
jne    11d0 <uart_init+0xa0>
mov    $0x20200098,%edi
mov    $0xc000,%esi
call   1040 <PUT32@plt>
mov    $0x96,%ebx
xor    %eax,%eax
call   1030 <NOP@plt>
add    $0xffffffff,%ebx
jne    11f0 <uart_init+0xc0>
mov    $0x20200098,%edi
xor    %esi,%esi
call   1040 <PUT32@plt>
mov    $0x20215060,%edi
mov    $0x3,%esi
pop    %rbx
jmp    1040 <PUT32@plt>

LLVM IR (-O0):
define void @uart_init() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = call i32 @PUT32(i32 539054084, i32 1)
%5 = call i32 @PUT32(i32 539054148, i32 0)
%6 = call i32 @PUT32(i32 539054176, i32 0)
%7 = call i32 @PUT32(i32 539054156, i32 3)
%8 = call i32 @PUT32(i32 539054160, i32 0)
%9 = call i32 @PUT32(i32 539054148, i32 0)
%10 = call i32 @PUT32(i32 539054152, i32 198)
%11 = call i32 @PUT32(i32 539054184, i32 270)
%12 = call i32 @GET32(i32 538968068)
store i32 %12, i32* %1
%13 = load i32, i32* %1
%14 = and i32 %13, -28673
store i32 %14, i32* %1
%15 = load i32, i32* %1
%16 = or i32 %15, 8192
store i32 %16, i32* %1
%17 = load i32, i32* %1
%18 = and i32 %17, -229377
store i32 %18, i32* %1
%19 = load i32, i32* %1
%20 = or i32 %19, 65536
store i32 %20, i32* %1
%21 = load i32, i32* %1
%22 = call i32 @PUT32(i32 538968068, i32 %21)
%23 = call i32 @PUT32(i32 538968212, i32 0)
store i32 0, i32* %2
br label %24
24: ; preds = %29, %0
%25 = load i32, i32* %2
%26 = icmp slt i32 %25, 150
br i1 %26, label %27, label %32
27: ; preds = %24
%28 = call i32 (...) @NOP()
br label %29
29: ; preds = %27
%30 = load i32, i32* %2
%31 = add nsw i32 %30, 1
store i32 %31, i32* %2
br label %24
32: ; preds = %24
%33 = call i32 @PUT32(i32 538968216, i32 49152)
store i32 0, i32* %3
br label %34
34: ; preds = %39, %32
%35 = load i32, i32* %3
%36 = icmp slt i32 %35, 150
br i1 %36, label %37, label %42
37: ; preds = %34
%38 = call i32 (...) @NOP()
br label %39
39: ; preds = %37
%40 = load i32, i32* %3
%41 = add nsw i32 %40, 1
store i32 %41, i32* %3
br label %34
42: ; preds = %34
%43 = call i32 @PUT32(i32 538968216, i32 0)
%44 = call i32 @PUT32(i32 539054176, i32 3)
ret void
}

LLVM IR (-O2):
define void @uart_init() {
%1 = tail call i32 @PUT32(i32 539054084, i32 1)
%2 = tail call i32 @PUT32(i32 539054148, i32 0)
%3 = tail call i32 @PUT32(i32 539054176, i32 0)
%4 = tail call i32 @PUT32(i32 539054156, i32 3)
%5 = tail call i32 @PUT32(i32 539054160, i32 0)
%6 = tail call i32 @PUT32(i32 539054148, i32 0)
%7 = tail call i32 @PUT32(i32 539054152, i32 198)
%8 = tail call i32 @PUT32(i32 539054184, i32 270)
%9 = tail call i32 @GET32(i32 538968068)
%10 = and i32 %9, -258049
%11 = or i32 %10, 73728
%12 = tail call i32 @PUT32(i32 538968068, i32 %11)
%13 = tail call i32 @PUT32(i32 538968212, i32 0)
br label %16
14: ; preds = %16
%15 = tail call i32 @PUT32(i32 538968216, i32 49152)
br label %24
16: ; preds = %0, %16
%17 = phi i32 [ 0, %0 ], [ %19, %16 ]
%18 = tail call i32 (...) @NOP()
%19 = add nuw nsw i32 %17, 1
%20 = icmp eq i32 %19, 150
br i1 %20, label %14, label %16
21: ; preds = %24
%22 = tail call i32 @PUT32(i32 538968216, i32 0)
%23 = tail call i32 @PUT32(i32 539054176, i32 3)
ret void
24: ; preds = %14, %24
%25 = phi i32 [ 0, %14 ], [ %27, %24 ]
%26 = tail call i32 (...) @NOP()
%27 = add nuw nsw i32 %25, 1
%28 = icmp eq i32 %27, 150
br i1 %28, label %21, label %24
}