#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*/ DEBUG_ASSERT(int);
int UARTBaseValid(unsigned long);
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;
  DEBUG_ASSERT(UARTBaseValid(ulBase));
  DEBUG_ASSERT(ulBaud != 0);
  DEBUG_ASSERT(
      ulUARTClk >=
      (ulBaud *
       ((((((*((volatile unsigned long *)(0x400FE000))) & 0x70000000) ==
           0x00000000) ||
          (((*((volatile unsigned long *)(0x400FE000))) &
            (0x70000000 | 0x00FF0000)) == (0x10000000 | 0x00000000))) ||
         ((((*((volatile unsigned long *)(0x400FE000))) &
            (0x70000000 | 0x00FF0000)) == (0x10000000 | 0x00010000)) &&
          (((*((volatile unsigned long *)(0x400FE000))) &
            (0x0000FF00 | 0x000000FF)) == (0x00000000 | 0x00000002))) ||
         ((((*((volatile unsigned long *)(0x400FE000))) &
            (0x70000000 | 0x00FF0000)) == (0x10000000 | 0x00030000)) &&
          (((*((volatile unsigned long *)(0x400FE000))) &
            (0x0000FF00 | 0x000000FF)) == (0x00000000 | 0x00000000))))
            ? 16
            : 8)));
  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    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <UARTBaseValid@plt>
mov    %eax,%edi
call   1040 <DEBUG_ASSERT@plt>
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <DEBUG_ASSERT@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    $0x400fe000,%eax
mov    (%rax),%rcx
and    $0x70000000,%rcx
mov    $0x1,%al
cmp    $0x0,%rcx
mov    %al,-0x29(%rbp)
je     1240 <UARTConfigSetExpClk+0x100>
mov    $0x400fe000,%eax
mov    (%rax),%rcx
and    $0x70ff0000,%rcx
mov    $0x1,%al
cmp    $0x10000000,%rcx
mov    %al,-0x29(%rbp)
je     1240 <UARTConfigSetExpClk+0x100>
mov    $0x400fe000,%eax
mov    (%rax),%rax
and    $0x70ff0000,%rax
cmp    $0x10010000,%rax
jne    1201 <UARTConfigSetExpClk+0xc1>
mov    $0x400fe000,%eax
mov    (%rax),%rcx
and    $0xffff,%rcx
mov    $0x1,%al
cmp    $0x2,%rcx
mov    %al,-0x29(%rbp)
je     1240 <UARTConfigSetExpClk+0x100>
mov    $0x400fe000,%eax
mov    (%rax),%rcx
and    $0x70ff0000,%rcx
xor    %eax,%eax
cmp    $0x10030000,%rcx
mov    %al,-0x41(%rbp)
jne    123a <UARTConfigSetExpClk+0xfa>
mov    $0x400fe000,%eax
mov    (%rax),%rax
and    $0xffff,%rax
cmp    $0x0,%rax
sete   %al
mov    %al,-0x41(%rbp)
mov    -0x41(%rbp),%al
mov    %al,-0x29(%rbp)
mov    -0x40(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    -0x29(%rbp),%dil
mov    $0x8,%edx
mov    $0x10,%esi
test   $0x1,%dil
cmovne %esi,%edx
movslq %edx,%rdx
imul   %rdx,%rcx
cmp    %rcx,%rax
setae  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <DEBUG_ASSERT@plt>
mov    -0x8(%rbp),%rdi
call   1030 <UARTDisable@plt>
mov    -0x18(%rbp),%rax
shl    $0x4,%rax
cmp    -0x10(%rbp),%rax
jbe    12b0 <UARTConfigSetExpClk+0x170>
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    12c0 <UARTConfigSetExpClk+0x180>
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   1060 <UARTEnable@plt>
add    $0x50,%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   1050 <UARTBaseValid@plt>
mov    %eax,%edi
call   1040 <DEBUG_ASSERT@plt>
xor    %edi,%edi
test   %r15,%r15
setne  %dil
call   1040 <DEBUG_ASSERT@plt>
mov    $0x10,%eax
testq  $0x70000000,0x400fe000
je     11ee <UARTConfigSetExpClk+0xae>
mov    0x400fe000,%rcx
40
and    $0x70ff0000,%ecx
cmp    $0x10000000,%ecx
je     11ee <UARTConfigSetExpClk+0xae>
mov    0x400fe000,%rcx
40
and    $0x70ff0000,%ecx
cmp    $0x10010000,%ecx
jne    11bb <UARTConfigSetExpClk+0x7b>
mov    0x400fe000,%rcx
40
cmp    $0x2,%cx
je     11ee <UARTConfigSetExpClk+0xae>
mov    0x400fe000,%rcx
40
and    $0x70ff0000,%ecx
mov    $0x8,%eax
cmp    $0x10030000,%ecx
jne    11ee <UARTConfigSetExpClk+0xae>
mov    0x400fe000,%rax
40
xor    %ecx,%ecx
test   %ax,%ax
sete   %cl
lea    0x8(,%rcx,8),%rax
imul   %r15,%rax
xor    %edi,%edi
cmp    %r12,%rax
setbe  %dil
call   1040 <DEBUG_ASSERT@plt>
mov    %rbx,%rdi
call   1030 <UARTDisable@plt>
mov    %r15,%rcx
shl    $0x4,%rcx
mov    0x30(%rbx),%rax
cmp    %r12,%rcx
jbe    1225 <UARTConfigSetExpClk+0xe5>
or     $0x20,%rax
mov    %rax,0x30(%rbx)
shr    %r15
jmp    122d <UARTConfigSetExpClk+0xed>
and    $0xffffffffffffffdf,%rax
mov    %rax,0x30(%rbx)
shl    $0x3,%r12
mov    %r12,%rax
or     %r15,%rax
shr    $0x20,%rax
je     1247 <UARTConfigSetExpClk+0x107>
mov    %r12,%rax
xor    %edx,%edx
div    %r15
jmp    124f <UARTConfigSetExpClk+0x10f>
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    1060 <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 @UARTBaseValid(i64 %10)
%12 = call i32 @DEBUG_ASSERT(i32 %11)
%13 = load i64, i64* %7
%14 = icmp ne i64 %13, 0
%15 = zext i1 %14 to i32
%16 = call i32 @DEBUG_ASSERT(i32 %15)
%17 = load i64, i64* %6
%18 = load i64, i64* %7
%19 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%20 = and i64 %19, 1879048192
%21 = icmp eq i64 %20, 0
br i1 %21, label %44, label %22
22: ; preds = %4
%23 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%24 = and i64 %23, 1895759872
%25 = icmp eq i64 %24, 268435456
br i1 %25, label %44, label %26
26: ; preds = %22
%27 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%28 = and i64 %27, 1895759872
%29 = icmp eq i64 %28, 268500992
br i1 %29, label %30, label %34
30: ; preds = %26
%31 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%32 = and i64 %31, 65535
%33 = icmp eq i64 %32, 2
br i1 %33, label %44, label %34
34: ; preds = %30, %26
%35 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%36 = and i64 %35, 1895759872
%37 = icmp eq i64 %36, 268632064
br i1 %37, label %38, label %42
38: ; preds = %34
%39 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%40 = and i64 %39, 65535
%41 = icmp eq i64 %40, 0
br label %42
42: ; preds = %38, %34
%43 = phi i1 [ false, %34 ], [ %41, %38 ]
br label %44
44: ; preds = %42, %30, %22, %4
%45 = phi i1 [ true, %30 ], [ true, %22 ], [ true, %4 ], [ %43, %42 ]
%46 = zext i1 %45 to i64
%47 = select i1 %45, i32 16, i32 8
%48 = sext i32 %47 to i64
%49 = mul i64 %18, %48
%50 = icmp uge i64 %17, %49
%51 = zext i1 %50 to i32
%52 = call i32 @DEBUG_ASSERT(i32 %51)
%53 = load i64, i64* %5
%54 = call i32 @UARTDisable(i64 %53)
%55 = load i64, i64* %7
%56 = mul i64 %55, 16
%57 = load i64, i64* %6
%58 = icmp ugt i64 %56, %57
br i1 %58, label %59, label %67
59: ; preds = %44
%60 = load i64, i64* %5
%61 = add i64 %60, 48
%62 = inttoptr i64 %61 to i64*
%63 = load volatile i64, i64* %62
%64 = or i64 %63, 32
store volatile i64 %64, i64* %62
%65 = load i64, i64* %7
%66 = udiv i64 %65, 2
store i64 %66, i64* %7
br label %73
67: ; preds = %44
%68 = load i64, i64* %5
%69 = add i64 %68, 48
%70 = inttoptr i64 %69 to i64*
%71 = load volatile i64, i64* %70
%72 = and i64 %71, -33
store volatile i64 %72, i64* %70
br label %73
73: ; preds = %67, %59
%74 = load i64, i64* %6
%75 = mul i64 %74, 8
%76 = load i64, i64* %7
%77 = udiv i64 %75, %76
%78 = add i64 %77, 1
%79 = udiv i64 %78, 2
store i64 %79, i64* %9
%80 = load i64, i64* %9
%81 = udiv i64 %80, 64
%82 = load i64, i64* %5
%83 = add i64 %82, 36
%84 = inttoptr i64 %83 to i64*
store volatile i64 %81, i64* %84
%85 = load i64, i64* %9
%86 = urem i64 %85, 64
%87 = load i64, i64* %5
%88 = add i64 %87, 40
%89 = inttoptr i64 %88 to i64*
store volatile i64 %86, i64* %89
%90 = load i64, i64* %8
%91 = load i64, i64* %5
%92 = add i64 %91, 44
%93 = inttoptr i64 %92 to i64*
store volatile i64 %90, i64* %93
%94 = load i64, i64* %5
%95 = add i64 %94, 24
%96 = inttoptr i64 %95 to i64*
store volatile i64 0, i64* %96
%97 = load i64, i64* %5
%98 = call i32 @UARTEnable(i64 %97)
ret void
}

LLVM IR (-O2):
define void @UARTConfigSetExpClk(i64 %0, i64 %1, i64 %2, i64 %3) {
%5 = tail call i32 @UARTBaseValid(i64 %0)
%6 = tail call i32 @DEBUG_ASSERT(i32 %5)
%7 = icmp ne i64 %2, 0
%8 = zext i1 %7 to i32
%9 = tail call i32 @DEBUG_ASSERT(i32 %8)
%10 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%11 = and i64 %10, 1879048192
%12 = icmp eq i64 %11, 0
br i1 %12, label %34, label %13
13: ; preds = %4
%14 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%15 = and i64 %14, 1895759872
%16 = icmp eq i64 %15, 268435456
br i1 %16, label %34, label %17
17: ; preds = %13
%18 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%19 = and i64 %18, 1895759872
%20 = icmp eq i64 %19, 268500992
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%23 = and i64 %22, 65535
%24 = icmp eq i64 %23, 2
br i1 %24, label %34, label %25
25: ; preds = %21, %17
%26 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%27 = and i64 %26, 1895759872
%28 = icmp eq i64 %27, 268632064
br i1 %28, label %29, label %34
29: ; preds = %25
%30 = load volatile i64, i64* inttoptr (i64 1074782208 to i64*)
%31 = and i64 %30, 65535
%32 = icmp eq i64 %31, 0
%33 = select i1 %32, i64 16, i64 8
br label %34
34: ; preds = %25, %29, %21, %13, %4
%35 = phi i64 [ 16, %21 ], [ 16, %13 ], [ 16, %4 ], [ 8, %25 ], [ %33, %29 ]
%36 = mul i64 %35, %2
%37 = icmp ule i64 %36, %1
%38 = zext i1 %37 to i32
%39 = tail call i32 @DEBUG_ASSERT(i32 %38)
%40 = tail call i32 @UARTDisable(i64 %0)
%41 = shl i64 %2, 4
%42 = icmp ugt i64 %41, %1
%43 = add i64 %0, 48
%44 = inttoptr i64 %43 to i64*
%45 = load volatile i64, i64* %44
br i1 %42, label %46, label %49
46: ; preds = %34
%47 = or i64 %45, 32
store volatile i64 %47, i64* %44
%48 = lshr i64 %2, 1
br label %51
49: ; preds = %34
%50 = and i64 %45, -33
store volatile i64 %50, i64* %44
br label %51
51: ; preds = %49, %46
%52 = phi i64 [ %48, %46 ], [ %2, %49 ]
%53 = shl i64 %1, 3
%54 = udiv i64 %53, %52
%55 = add nuw i64 %54, 1
%56 = lshr i64 %55, 1
%57 = lshr i64 %55, 7
%58 = add i64 %0, 36
%59 = inttoptr i64 %58 to i64*
store volatile i64 %57, i64* %59
%60 = and i64 %56, 63
%61 = add i64 %0, 40
%62 = inttoptr i64 %61 to i64*
store volatile i64 %60, i64* %62
%63 = add i64 %0, 44
%64 = inttoptr i64 %63 to i64*
store volatile i64 %3, i64* %64
%65 = add i64 %0, 24
%66 = inttoptr i64 %65 to i64*
store volatile i64 0, i64* %66
%67 = tail call i32 @UARTEnable(i64 %0)
ret void
}