#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 read_uart(int, unsigned int);
int /*<<< orphan*/ write_uart(int, int, unsigned int);
void pl011_uart_init(unsigned int uart_id) {
  int lcrh_reg;
  write_uart(0x30, 0x0, uart_id);
  lcrh_reg = read_uart(0x2C, uart_id);
  lcrh_reg &= ~(1 << 4);
  write_uart(0x2C, lcrh_reg, uart_id);
  write_uart(0x24, 13, uart_id);
  write_uart(0x2C, ((3 << 5) | (1 << 4)), uart_id);
  write_uart(0x30, ((1 << 0) | (1 << 8)), uart_id);
  return;
}


x86 assembly (clang, -O0):
<pl011_uart_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edx
mov    $0x30,%edi
xor    %esi,%esi
call   1040 <write_uart@plt>
mov    -0x4(%rbp),%esi
mov    $0x2c,%edi
call   1030 <read_uart@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0xffffffef,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x4(%rbp),%edx
mov    $0x2c,%edi
call   1040 <write_uart@plt>
mov    -0x4(%rbp),%edx
mov    $0x24,%edi
mov    $0xd,%esi
call   1040 <write_uart@plt>
mov    -0x4(%rbp),%edx
mov    $0x2c,%edi
mov    $0x70,%esi
call   1040 <write_uart@plt>
mov    -0x4(%rbp),%edx
mov    $0x30,%edi
mov    $0x101,%esi
call   1040 <write_uart@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pl011_uart_init>:
push   %rbx
mov    %edi,%ebx
mov    $0x30,%edi
xor    %esi,%esi
mov    %ebx,%edx
call   1040 <write_uart@plt>
mov    $0x2c,%edi
mov    %ebx,%esi
call   1030 <read_uart@plt>
and    $0xffffffef,%eax
mov    $0x2c,%edi
mov    %eax,%esi
mov    %ebx,%edx
call   1040 <write_uart@plt>
mov    $0x24,%edi
mov    $0xd,%esi
mov    %ebx,%edx
call   1040 <write_uart@plt>
mov    $0x2c,%edi
mov    $0x70,%esi
mov    %ebx,%edx
call   1040 <write_uart@plt>
mov    $0x30,%edi
mov    $0x101,%esi
mov    %ebx,%edx
pop    %rbx
jmp    1040 <write_uart@plt>

LLVM IR (-O0):
define void @pl011_uart_init(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = call i32 @write_uart(i32 48, i32 0, i32 %4)
%6 = load i32, i32* %2
%7 = call i32 @read_uart(i32 44, i32 %6)
store i32 %7, i32* %3
%8 = load i32, i32* %3
%9 = and i32 %8, -17
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = load i32, i32* %2
%12 = call i32 @write_uart(i32 44, i32 %10, i32 %11)
%13 = load i32, i32* %2
%14 = call i32 @write_uart(i32 36, i32 13, i32 %13)
%15 = load i32, i32* %2
%16 = call i32 @write_uart(i32 44, i32 112, i32 %15)
%17 = load i32, i32* %2
%18 = call i32 @write_uart(i32 48, i32 257, i32 %17)
ret void
}

LLVM IR (-O2):
define void @pl011_uart_init(i32 %0) {
%2 = tail call i32 @write_uart(i32 48, i32 0, i32 %0)
%3 = tail call i32 @read_uart(i32 44, i32 %0)
%4 = and i32 %3, -17
%5 = tail call i32 @write_uart(i32 44, i32 %4, i32 %0)
%6 = tail call i32 @write_uart(i32 36, i32 13, i32 %0)
%7 = tail call i32 @write_uart(i32 44, i32 112, i32 %0)
%8 = tail call i32 @write_uart(i32 48, i32 257, i32 %0)
ret void
}