#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 /*<<< orphan*/ UARTDisable(unsigned long);
int /*<<< orphan*/ UARTEnable(unsigned long);
void UARTConfigSetExpClk(unsigned long ulBase, unsigned long ulUARTClk,
                         unsigned long ulBaud, unsigned long ulConfig) {
  unsigned long ulDiv;
  ;
  ;
  UARTDisable(ulBase);
  if ((ulBaud * 16) > ulUARTClk) {
    (*((volatile unsigned long *)(ulBase + 0x00000030))) |= 0x00000020;
    ulBaud /= 2;
  } else {
    (*((volatile unsigned long *)(ulBase + 0x00000030))) &= ~(0x00000020);
  }
  ulDiv = (((ulUARTClk * 8) / ulBaud) + 1) / 2;
  (*((volatile unsigned long *)(ulBase + 0x00000024))) = ulDiv / 64;
  (*((volatile unsigned long *)(ulBase + 0x00000028))) = ulDiv % 64;
  (*((volatile unsigned long *)(ulBase + 0x0000002C))) = ulConfig;
  (*((volatile unsigned long *)(ulBase + 0x00000018))) = 0;
  UARTEnable(ulBase);
}


x86 assembly (clang, -O0):
<UARTConfigSetExpClk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <UARTDisable@plt>
mov    -0x18(%rbp),%rax
shl    $0x4,%rax
cmp    -0x10(%rbp),%rax
jbe    1174 <UARTConfigSetExpClk+0x54>
mov    -0x8(%rbp),%rax
mov    0x30(%rax),%rcx
or     $0x20,%rcx
mov    %rcx,0x30(%rax)
mov    -0x18(%rbp),%rax
shr    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1184 <UARTConfigSetExpClk+0x64>
mov    -0x8(%rbp),%rax
mov    0x30(%rax),%rcx
and    $0xffffffffffffffdf,%rcx
mov    %rcx,0x30(%rax)
mov    -0x10(%rbp),%rax
shl    $0x3,%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x18(%rbp)
add    $0x1,%rax
shr    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rcx
shr    $0x6,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x24(%rax)
mov    -0x28(%rbp),%rcx
and    $0x3f,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x28(%rax)
mov    -0x20(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x2c(%rax)
mov    -0x8(%rbp),%rax
movq   $0x0,0x18(%rax)
mov    -0x8(%rbp),%rdi
call   1040 <UARTEnable@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UARTConfigSetExpClk>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%rbx
call   1030 <UARTDisable@plt>
mov    %r15,%rcx
shl    $0x4,%rcx
mov    0x30(%rbx),%rax
cmp    %r12,%rcx
jbe    1156 <UARTConfigSetExpClk+0x36>
or     $0x20,%rax
mov    %rax,0x30(%rbx)
shr    %r15
jmp    115e <UARTConfigSetExpClk+0x3e>
and    $0xffffffffffffffdf,%rax
mov    %rax,0x30(%rbx)
shl    $0x3,%r12
mov    %r12,%rax
or     %r15,%rax
shr    $0x20,%rax
je     1178 <UARTConfigSetExpClk+0x58>
mov    %r12,%rax
xor    %edx,%edx
div    %r15
jmp    1180 <UARTConfigSetExpClk+0x60>
mov    %r12d,%eax
xor    %edx,%edx
div    %r15d
add    $0x1,%rax
mov    %eax,%ecx
shr    %ecx
and    $0x3f,%ecx
shr    $0x7,%rax
mov    %rax,0x24(%rbx)
mov    %rcx,0x28(%rbx)
mov    %r14,0x2c(%rbx)
movq   $0x0,0x18(%rbx)
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1040 <UARTEnable@plt>

LLVM IR (-O0):
define void @UARTConfigSetExpClk(i64 %0, i64 %1, i64 %2, i64 %3) {
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
store i64 %0, i64* %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i64 %3, i64* %8
%10 = load i64, i64* %5
%11 = call i32 @UARTDisable(i64 %10)
%12 = load i64, i64* %7
%13 = mul i64 %12, 16
%14 = load i64, i64* %6
%15 = icmp ugt i64 %13, %14
br i1 %15, label %16, label %24
16: ; preds = %4
%17 = load i64, i64* %5
%18 = add i64 %17, 48
%19 = inttoptr i64 %18 to i64*
%20 = load volatile i64, i64* %19
%21 = or i64 %20, 32
store volatile i64 %21, i64* %19
%22 = load i64, i64* %7
%23 = udiv i64 %22, 2
store i64 %23, i64* %7
br label %30
24: ; preds = %4
%25 = load i64, i64* %5
%26 = add i64 %25, 48
%27 = inttoptr i64 %26 to i64*
%28 = load volatile i64, i64* %27
%29 = and i64 %28, -33
store volatile i64 %29, i64* %27
br label %30
30: ; preds = %24, %16
%31 = load i64, i64* %6
%32 = mul i64 %31, 8
%33 = load i64, i64* %7
%34 = udiv i64 %32, %33
%35 = add i64 %34, 1
%36 = udiv i64 %35, 2
store i64 %36, i64* %9
%37 = load i64, i64* %9
%38 = udiv i64 %37, 64
%39 = load i64, i64* %5
%40 = add i64 %39, 36
%41 = inttoptr i64 %40 to i64*
store volatile i64 %38, i64* %41
%42 = load i64, i64* %9
%43 = urem i64 %42, 64
%44 = load i64, i64* %5
%45 = add i64 %44, 40
%46 = inttoptr i64 %45 to i64*
store volatile i64 %43, i64* %46
%47 = load i64, i64* %8
%48 = load i64, i64* %5
%49 = add i64 %48, 44
%50 = inttoptr i64 %49 to i64*
store volatile i64 %47, i64* %50
%51 = load i64, i64* %5
%52 = add i64 %51, 24
%53 = inttoptr i64 %52 to i64*
store volatile i64 0, i64* %53
%54 = load i64, i64* %5
%55 = call i32 @UARTEnable(i64 %54)
ret void
}

LLVM IR (-O2):
define void @UARTConfigSetExpClk(i64 %0, i64 %1, i64 %2, i64 %3) {
%5 = tail call i32 @UARTDisable(i64 %0)
%6 = shl i64 %2, 4
%7 = icmp ugt i64 %6, %1
%8 = add i64 %0, 48
%9 = inttoptr i64 %8 to i64*
%10 = load volatile i64, i64* %9
br i1 %7, label %11, label %14
11: ; preds = %4
%12 = or i64 %10, 32
store volatile i64 %12, i64* %9
%13 = lshr i64 %2, 1
br label %16
14: ; preds = %4
%15 = and i64 %10, -33
store volatile i64 %15, i64* %9
br label %16
16: ; preds = %14, %11
%17 = phi i64 [ %13, %11 ], [ %2, %14 ]
%18 = shl i64 %1, 3
%19 = udiv i64 %18, %17
%20 = add nuw i64 %19, 1
%21 = lshr i64 %20, 1
%22 = lshr i64 %20, 7
%23 = add i64 %0, 36
%24 = inttoptr i64 %23 to i64*
store volatile i64 %22, i64* %24
%25 = and i64 %21, 63
%26 = add i64 %0, 40
%27 = inttoptr i64 %26 to i64*
store volatile i64 %25, i64* %27
%28 = add i64 %0, 44
%29 = inttoptr i64 %28 to i64*
store volatile i64 %3, i64* %29
%30 = add i64 %0, 24
%31 = inttoptr i64 %30 to i64*
store volatile i64 0, i64* %31
%32 = tail call i32 @UARTEnable(i64 %0)
ret void
}