#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);
  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    -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,%rbx
mov    %rdi,%r12
call   1030 <UARTDisable@plt>
shl    $0x3,%rbx
mov    %rbx,%rax
or     %r15,%rax
shr    $0x20,%rax
je     1153 <UARTConfigSetExpClk+0x33>
mov    %rbx,%rax
xor    %edx,%edx
div    %r15
jmp    115a <UARTConfigSetExpClk+0x3a>
mov    %ebx,%eax
xor    %edx,%edx
div    %r15d
add    $0x1,%rax
mov    %eax,%ecx
shr    %ecx
and    $0x3f,%ecx
shr    $0x7,%rax
mov    %rax,0x24(%r12)
mov    %rcx,0x28(%r12)
mov    %r14,0x2c(%r12)
movq   $0x0,0x18(%r12)
mov    %r12,%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* %6
%13 = mul i64 %12, 8
%14 = load i64, i64* %7
%15 = udiv i64 %13, %14
%16 = add i64 %15, 1
%17 = udiv i64 %16, 2
store i64 %17, i64* %9
%18 = load i64, i64* %9
%19 = udiv i64 %18, 64
%20 = load i64, i64* %5
%21 = add i64 %20, 36
%22 = inttoptr i64 %21 to i64*
store volatile i64 %19, i64* %22
%23 = load i64, i64* %9
%24 = urem i64 %23, 64
%25 = load i64, i64* %5
%26 = add i64 %25, 40
%27 = inttoptr i64 %26 to i64*
store volatile i64 %24, i64* %27
%28 = load i64, i64* %8
%29 = load i64, i64* %5
%30 = add i64 %29, 44
%31 = inttoptr i64 %30 to i64*
store volatile i64 %28, i64* %31
%32 = load i64, i64* %5
%33 = add i64 %32, 24
%34 = inttoptr i64 %33 to i64*
store volatile i64 0, i64* %34
%35 = load i64, i64* %5
%36 = call i32 @UARTEnable(i64 %35)
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 %1, 3
%7 = udiv i64 %6, %2
%8 = add nuw i64 %7, 1
%9 = lshr i64 %8, 1
%10 = lshr i64 %8, 7
%11 = add i64 %0, 36
%12 = inttoptr i64 %11 to i64*
store volatile i64 %10, i64* %12
%13 = and i64 %9, 63
%14 = add i64 %0, 40
%15 = inttoptr i64 %14 to i64*
store volatile i64 %13, i64* %15
%16 = add i64 %0, 44
%17 = inttoptr i64 %16 to i64*
store volatile i64 %3, i64* %17
%18 = add i64 %0, 24
%19 = inttoptr i64 %18 to i64*
store volatile i64 0, i64* %19
%20 = tail call i32 @UARTEnable(i64 %0)
ret void
}