#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 char *)0xE001000C)) = 0x83;
  (*((volatile unsigned char *)0xE0010000)) = divisor & 0xFF;
  (*((volatile unsigned char *)0xE0010004)) = (divisor >> 8) & 0xFF;
  (*((volatile unsigned char *)0xE001000C)) &= ~0x80;
  (*((volatile unsigned long *)0xE002C000)) |= 0x00010000;
  (*((volatile unsigned long *)0xE002C000)) &= ~0x00020000;
}


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
movb   $0x83,(%rax)
mov    -0x8(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
mov    $0xe0010000,%eax
mov    %cl,(%rax)
mov    -0x8(%rbp),%eax
shr    $0x8,%eax
and    $0xff,%eax
mov    %al,%cl
mov    $0xe0010004,%eax
mov    %cl,(%rax)
mov    $0xe001000c,%eax
mov    (%rax),%al
movzbl %al,%eax
and    $0xffffff7f,%eax
mov    %al,%cl
mov    $0xe001000c,%eax
mov    %cl,(%rax)
mov    $0xe002c000,%eax
mov    (%rax),%rcx
or     $0x10000,%rcx
mov    $0xe002c000,%eax
mov    %rcx,(%rax)
mov    $0xe002c000,%eax
mov    (%rax),%rcx
and    $0xfffffffffffdffff,%rcx
mov    $0xe002c000,%eax
mov    %rcx,(%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    $0xe002c000,%ecx
movb   $0x83,-0x1bff4(%rcx)
mov    %al,-0x1c000(%rcx)
mov    %ah,-0x1bffc(%rcx)
andb   $0x7f,-0x1bff4(%rcx)
orq    $0x10000,(%rcx)
andq   $0xfffffffffffdffff,(%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 i8 -125, i8* inttoptr (i64 3758161932 to i8*)
%8 = load i32, i32* %3
%9 = and i32 %8, 255
%10 = trunc i32 %9 to i8
store volatile i8 %10, i8* inttoptr (i64 3758161920 to i8*)
%11 = load i32, i32* %3
%12 = lshr i32 %11, 8
%13 = and i32 %12, 255
%14 = trunc i32 %13 to i8
store volatile i8 %14, i8* inttoptr (i64 3758161924 to i8*)
%15 = load volatile i8, i8* inttoptr (i64 3758161932 to i8*)
%16 = zext i8 %15 to i32
%17 = and i32 %16, -129
%18 = trunc i32 %17 to i8
store volatile i8 %18, i8* inttoptr (i64 3758161932 to i8*)
%19 = load volatile i64, i64* inttoptr (i64 3758276608 to i64*)
%20 = or i64 %19, 65536
store volatile i64 %20, i64* inttoptr (i64 3758276608 to i64*)
%21 = load volatile i64, i64* inttoptr (i64 3758276608 to i64*)
%22 = and i64 %21, -131073
store volatile i64 %22, i64* inttoptr (i64 3758276608 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 i8 -125, i8* inttoptr (i64 3758161932 to i8*)
%5 = trunc i32 %4 to i8
store volatile i8 %5, i8* inttoptr (i64 3758161920 to i8*)
%6 = lshr i32 %4, 8
%7 = trunc i32 %6 to i8
store volatile i8 %7, i8* inttoptr (i64 3758161924 to i8*)
%8 = load volatile i8, i8* inttoptr (i64 3758161932 to i8*)
%9 = and i8 %8, 127
store volatile i8 %9, i8* inttoptr (i64 3758161932 to i8*)
%10 = load volatile i64, i64* inttoptr (i64 3758276608 to i64*)
%11 = or i64 %10, 65536
store volatile i64 %11, i64* inttoptr (i64 3758276608 to i64*)
%12 = load volatile i64, i64* inttoptr (i64 3758276608 to i64*)
%13 = and i64 %12, -131073
store volatile i64 %13, i64* inttoptr (i64 3758276608 to i64*)
ret void
}