#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 */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ UARTDisable(int);
int /*<<< orphan*/ UARTEnable(int);
void UARTConfigSetExpClk(uint32_t ui32Base, uint32_t ui32UARTClk,
                         uint32_t ui32Baud, uint32_t ui32Config) {
  uint32_t ui32Div;
  ;
  ;
  ;
  UARTDisable(ui32Base);
  if ((ui32Baud * 16) > ui32UARTClk) {
    (*((volatile uint32_t *)(ui32Base + 0x00000030))) |= 0x00000020;
    ui32Baud /= 2;
  } else {
    (*((volatile uint32_t *)(ui32Base + 0x00000030))) &= ~(0x00000020);
  }
  ui32Div = (((ui32UARTClk * 8) / ui32Baud) + 1) / 2;
  (*((volatile uint32_t *)(ui32Base + 0x00000024))) = ui32Div / 64;
  (*((volatile uint32_t *)(ui32Base + 0x00000028))) = ui32Div % 64;
  (*((volatile uint32_t *)(ui32Base + 0x0000002C))) = ui32Config;
  (*((volatile uint32_t *)(ui32Base + 0x00000018))) = 0;
  UARTEnable(ui32Base);
}


x86 assembly (clang, -O0):
<UARTConfigSetExpClk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %ecx,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <UARTDisable@plt>
mov    -0xc(%rbp),%eax
shl    $0x4,%eax
cmp    -0x8(%rbp),%eax
jle    116d <UARTConfigSetExpClk+0x4d>
mov    -0x4(%rbp),%eax
add    $0x30,%eax
cltq
mov    (%rax),%ecx
or     $0x20,%ecx
mov    %ecx,(%rax)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
jmp    117c <UARTConfigSetExpClk+0x5c>
mov    -0x4(%rbp),%eax
add    $0x30,%eax
cltq
mov    (%rax),%ecx
and    $0xffffffdf,%ecx
mov    %ecx,(%rax)
mov    -0x8(%rbp),%eax
shl    $0x3,%eax
cltd
idivl  -0xc(%rbp)
add    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x4(%rbp),%eax
add    $0x24,%eax
cltq
mov    %ecx,(%rax)
mov    -0x14(%rbp),%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
mov    -0x4(%rbp),%eax
add    $0x28,%eax
cltq
mov    %edx,(%rax)
mov    -0x10(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    $0x2c,%eax
cltq
mov    %ecx,(%rax)
mov    -0x4(%rbp),%eax
add    $0x18,%eax
cltq
movl   $0x0,(%rax)
mov    -0x4(%rbp),%edi
call   1040 <UARTEnable@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UARTConfigSetExpClk>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%ebp
mov    %edi,%ebx
call   1030 <UARTDisable@plt>
mov    %r15d,%ecx
shl    $0x4,%ecx
movslq %ebx,%rdi
mov    0x30(%rdi),%eax
cmp    %ebp,%ecx
jle    115c <UARTConfigSetExpClk+0x3c>
or     $0x20,%eax
mov    %eax,0x30(%rdi)
mov    %r15d,%eax
shr    $0x1f,%eax
add    %r15d,%eax
sar    %eax
mov    %eax,%r15d
jmp    1162 <UARTConfigSetExpClk+0x42>
and    $0xffffffdf,%eax
mov    %eax,0x30(%rdi)
shl    $0x3,%ebp
mov    %ebp,%eax
cltd
idiv   %r15d
lea    0x1(%rax),%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
add    %eax,%edx
add    $0x1,%edx
sar    %edx
sub    $0xffffff80,%eax
test   %ecx,%ecx
cmovns %ecx,%eax
sar    $0x7,%eax
mov    %eax,0x24(%rdi)
lea    0x3f(%rdx),%eax
test   %edx,%edx
cmovns %edx,%eax
and    $0xffffffc0,%eax
sub    %eax,%edx
mov    %edx,0x28(%rdi)
mov    %r14d,0x2c(%rdi)
movl   $0x0,0x18(%rdi)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <UARTEnable@plt>

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

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