#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*/ AssertFailure(char *, int);
int /*<<< orphan*/ UARTBaseValid(unsigned long);
void UARTConfigGetExpClk(unsigned long ulBase, unsigned long ulUARTClk,
                         unsigned long *pulBaud, unsigned long *pulConfig) {
  unsigned long ulInt, ulFrac;
  {
    if (!(UARTBaseValid(ulBase))) {
      AssertFailure(
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/AmesianX/OpenBLT/refs/heads/master/Target/"
          "Demo/ARMCM3_LM3S_EK_LM3S6965_Crossworks/Boot/lib/driverlib/"
          "uartlib.c",
          455);
    }
  };
  ulInt = (*((volatile unsigned long *)(ulBase + 0x00000024)));
  ulFrac = (*((volatile unsigned long *)(ulBase + 0x00000028)));
  *pulBaud = (ulUARTClk * 4) / ((64 * ulInt) + ulFrac);
  if ((*((volatile unsigned long *)(ulBase + 0x00000030))) & 0x00000020) {
    *pulBaud *= 2;
  }
  *pulConfig =
      ((*((volatile unsigned long *)(ulBase + 0x0000002C))) &
       (0x00000080 | 0x00000060 | 0x00000008 | 0x00000004 | 0x00000002));
}


x86 assembly (clang, -O0):
<UARTConfigGetExpClk>:
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   1040 <UARTBaseValid@plt>
cmp    $0x0,%eax
jne    115b <UARTConfigGetExpClk+0x3b>
lea    0xeaf(%rip),%rdi
mov    $0x1c7,%esi
call   1030 <AssertFailure@plt>
mov    -0x8(%rbp),%rax
mov    0x24(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    0x28(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
shl    $0x2,%rax
mov    -0x28(%rbp),%rcx
shl    $0x6,%rcx
add    -0x30(%rbp),%rcx
xor    %edx,%edx
div    %rcx
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    0x30(%rax),%rax
and    $0x20,%rax
cmp    $0x0,%rax
je     11ba <UARTConfigGetExpClk+0x9a>
mov    -0x18(%rbp),%rax
mov    (%rax),%rcx
shl    $0x1,%rcx
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    0x2c(%rax),%rcx
and    $0xee,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<UARTConfigGetExpClk>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r12
call   1040 <UARTBaseValid@plt>
test   %eax,%eax
jne    114e <UARTConfigGetExpClk+0x2e>
lea    0xebc(%rip),%rdi
mov    $0x1c7,%esi
call   1030 <AssertFailure@plt>
mov    0x24(%r12),%rcx
shl    $0x2,%rbx
shl    $0x6,%rcx
add    0x28(%r12),%rcx
mov    %rbx,%rax
or     %rcx,%rax
shr    $0x20,%rax
je     1176 <UARTConfigGetExpClk+0x56>
mov    %rbx,%rax
xor    %edx,%edx
div    %rcx
jmp    117c <UARTConfigGetExpClk+0x5c>
mov    %ebx,%eax
xor    %edx,%edx
div    %ecx
mov    %rax,(%r15)
testq  $0x20,0x30(%r12)
je     1190 <UARTConfigGetExpClk+0x70>
add    %rax,%rax
mov    %rax,(%r15)
mov    0x2c(%r12),%rax
and    $0xee,%eax
mov    %rax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [201 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AmesianX/OpenBLT/refs/heads/master/Target/Demo/ARMCM3_LM3S_EK_LM3S6965_Crossworks/Boot/lib/driverlib/uartlib.c\00"
define void @UARTConfigGetExpClk(i64 %0, i64 %1, i64* %2, i64* %3) {
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64*
%8 = alloca i64*
%9 = alloca i64
%10 = alloca i64
store i64 %0, i64* %5
store i64 %1, i64* %6
store i64* %2, i64** %7
store i64* %3, i64** %8
%11 = load i64, i64* %5
%12 = call i32 @UARTBaseValid(i64 %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %4
%15 = call i32 @AssertFailure(i8* getelementptr inbounds ([201 x i8], [201 x i8]* @.str, i64 0, i64 0), i32 455)
br label %16
16: ; preds = %14, %4
%17 = load i64, i64* %5
%18 = add i64 %17, 36
%19 = inttoptr i64 %18 to i64*
%20 = load volatile i64, i64* %19
store i64 %20, i64* %9
%21 = load i64, i64* %5
%22 = add i64 %21, 40
%23 = inttoptr i64 %22 to i64*
%24 = load volatile i64, i64* %23
store i64 %24, i64* %10
%25 = load i64, i64* %6
%26 = mul i64 %25, 4
%27 = load i64, i64* %9
%28 = mul i64 64, %27
%29 = load i64, i64* %10
%30 = add i64 %28, %29
%31 = udiv i64 %26, %30
%32 = load i64*, i64** %7
store i64 %31, i64* %32
%33 = load i64, i64* %5
%34 = add i64 %33, 48
%35 = inttoptr i64 %34 to i64*
%36 = load volatile i64, i64* %35
%37 = and i64 %36, 32
%38 = icmp ne i64 %37, 0
br i1 %38, label %39, label %43
39: ; preds = %16
%40 = load i64*, i64** %7
%41 = load i64, i64* %40
%42 = mul i64 %41, 2
store i64 %42, i64* %40
br label %43
43: ; preds = %39, %16
%44 = load i64, i64* %5
%45 = add i64 %44, 44
%46 = inttoptr i64 %45 to i64*
%47 = load volatile i64, i64* %46
%48 = and i64 %47, 238
%49 = load i64*, i64** %8
store i64 %48, i64* %49
ret void
}

LLVM IR (-O2):
@.str = [201 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/AmesianX/OpenBLT/refs/heads/master/Target/Demo/ARMCM3_LM3S_EK_LM3S6965_Crossworks/Boot/lib/driverlib/uartlib.c\00"
define void @UARTConfigGetExpClk(i64 %0, i64 %1, i64* nocapture %2, i64* nocapture writeonly %3) {
%5 = tail call i32 @UARTBaseValid(i64 %0)
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %4
%8 = tail call i32 @AssertFailure(i8* getelementptr inbounds ([201 x i8], [201 x i8]* @.str, i64 0, i64 0), i32 455)
br label %9
9: ; preds = %7, %4
%10 = add i64 %0, 36
%11 = inttoptr i64 %10 to i64*
%12 = load volatile i64, i64* %11
%13 = add i64 %0, 40
%14 = inttoptr i64 %13 to i64*
%15 = load volatile i64, i64* %14
%16 = shl i64 %1, 2
%17 = shl i64 %12, 6
%18 = add i64 %17, %15
%19 = udiv i64 %16, %18
store i64 %19, i64* %2
%20 = add i64 %0, 48
%21 = inttoptr i64 %20 to i64*
%22 = load volatile i64, i64* %21
%23 = and i64 %22, 32
%24 = icmp eq i64 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %9
%26 = shl i64 %19, 1
store i64 %26, i64* %2
br label %27
27: ; preds = %25, %9
%28 = add i64 %0, 44
%29 = inttoptr i64 %28 to i64*
%30 = load volatile i64, i64* %29
%31 = and i64 %30, 238
store i64 %31, i64* %3
ret void
}