#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 peripheralClockFrequency();
void UART1Initialize(unsigned int baud) {
  unsigned int divisor = peripheralClockFrequency() / (16 * baud);
  (*(volatile unsigned long *)(0xE0010000 + 0x0C)) = 0x83;
  (*(volatile unsigned long *)(0xE0010000 + 0x00)) = divisor & 0xFF;
  (*(volatile unsigned long *)(0xE0010000 + 0x04)) = (divisor >> 8) & 0xFF;
  (*(volatile unsigned long *)(0xE0010000 + 0x0C)) &= ~0x80;
  (*(volatile unsigned long *)(0xE0010000 + 0x08)) = 1;
}


x86 assembly (clang, -O0):
<UART1Initialize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1030 <peripheralClockFrequency@plt>
mov    -0x4(%rbp),%ecx
shl    $0x4,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x8(%rbp)
mov    $0xe001000c,%eax
movq   $0x83,(%rax)
mov    -0x8(%rbp),%eax
and    $0xff,%eax
mov    %eax,%eax
mov    %eax,%ecx
mov    $0xe0010000,%eax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%eax
shr    $0x8,%eax
and    $0xff,%eax
mov    %eax,%eax
mov    %eax,%ecx
mov    $0xe0010004,%eax
mov    %rcx,(%rax)
mov    $0xe001000c,%eax
mov    (%rax),%rcx
and    $0xffffffffffffff7f,%rcx
mov    $0xe001000c,%eax
mov    %rcx,(%rax)
mov    $0xe0010008,%eax
movq   $0x1,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UART1Initialize>:
push   %rbx
mov    %edi,%ebx
xor    %eax,%eax
call   1030 <peripheralClockFrequency@plt>
shl    $0x4,%ebx
xor    %edx,%edx
div    %ebx
mov    $0xe001000c,%ecx
movq   $0x83,(%rcx)
movzbl %al,%edx
mov    %rdx,-0xc(%rcx)
movzbl %ah,%eax
mov    %rax,-0x8(%rcx)
andq   $0xffffffffffffff7f,(%rcx)
movq   $0x1,-0x4(%rcx)
pop    %rbx
ret

LLVM IR (-O0):
define void @UART1Initialize(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = call i32 (...) @peripheralClockFrequency()
%5 = load i32, i32* %2
%6 = mul i32 16, %5
%7 = udiv i32 %4, %6
store i32 %7, i32* %3
store volatile i64 131, i64* inttoptr (i64 3758161932 to i64*)
%8 = load i32, i32* %3
%9 = and i32 %8, 255
%10 = zext i32 %9 to i64
store volatile i64 %10, i64* inttoptr (i64 3758161920 to i64*)
%11 = load i32, i32* %3
%12 = lshr i32 %11, 8
%13 = and i32 %12, 255
%14 = zext i32 %13 to i64
store volatile i64 %14, i64* inttoptr (i64 3758161924 to i64*)
%15 = load volatile i64, i64* inttoptr (i64 3758161932 to i64*)
%16 = and i64 %15, -129
store volatile i64 %16, i64* inttoptr (i64 3758161932 to i64*)
store volatile i64 1, i64* inttoptr (i64 3758161928 to i64*)
ret void
}

LLVM IR (-O2):
define void @UART1Initialize(i32 %0) {
%2 = tail call i32 (...) @peripheralClockFrequency()
%3 = shl i32 %0, 4
%4 = udiv i32 %2, %3
store volatile i64 131, i64* inttoptr (i64 3758161932 to i64*)
%5 = and i32 %4, 255
%6 = zext i32 %5 to i64
store volatile i64 %6, i64* inttoptr (i64 3758161920 to i64*)
%7 = lshr i32 %4, 8
%8 = and i32 %7, 255
%9 = zext i32 %8 to i64
store volatile i64 %9, i64* inttoptr (i64 3758161924 to i64*)
%10 = load volatile i64, i64* inttoptr (i64 3758161932 to i64*)
%11 = and i64 %10, -129
store volatile i64 %11, i64* inttoptr (i64 3758161932 to i64*)
store volatile i64 1, i64* inttoptr (i64 3758161928 to i64*)
ret void
}