#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 LPCChannelValid(unsigned long);
unsigned long LPCChannelConfigGet(unsigned long ulBase, unsigned long ulChannel,
                                  unsigned long *pulAddress,
                                  unsigned long *pulOffset,
                                  unsigned long *pulCOMxMode) {
  unsigned long ulConfig;
  DEBUG_ASSERT(ulBase == 0x40080000);
  DEBUG_ASSERT(LPCChannelValid(ulChannel));
  ulConfig =
      (*((volatile unsigned long *)(ulBase + 0x00000010 + (ulChannel * 0x10))));
  if (pulOffset) {
    *pulOffset = ((ulConfig & 0x00003FE0) >> (5 - 1));
  }
  if (pulAddress) {
    *pulAddress = (*(
        (volatile unsigned long *)(ulBase + 0x00000018 + (ulChannel * 0x10))));
  }
  if (pulCOMxMode && (ulChannel == 7)) {
    *pulCOMxMode =
        ((*((volatile unsigned long *)(ulBase + 0x00000120))) & 0x00070000);
  }
  return (ulConfig);
}


x86 assembly (clang, -O0):
<LPCChannelConfigGet>:
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    %r8,-0x28(%rbp)
cmpq   $0x40080000,-0x8(%rbp)
40
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    -0x10(%rbp),%rdi
call   1040 <LPCChannelValid@plt>
mov    %eax,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    -0x8(%rbp),%rax
add    $0x10,%rax
mov    -0x10(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     119c <LPCChannelConfigGet+0x7c>
mov    -0x30(%rbp),%rcx
and    $0x3fe0,%rcx
shr    $0x4,%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x18(%rbp)
je     11c4 <LPCChannelConfigGet+0xa4>
mov    -0x8(%rbp),%rax
add    $0x18,%rax
mov    -0x10(%rbp),%rcx
shl    $0x4,%rcx
add    %rcx,%rax
mov    (%rax),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
cmpq   $0x0,-0x28(%rbp)
je     11f3 <LPCChannelConfigGet+0xd3>
cmpq   $0x7,-0x10(%rbp)
jne    11f3 <LPCChannelConfigGet+0xd3>
mov    -0x8(%rbp),%rax
mov    0x120(%rax),%rcx
and    $0x70000,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x30(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LPCChannelConfigGet>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %r8,%r14
mov    %rcx,%r13
mov    %rdx,%r12
mov    %rsi,%rbx
mov    %rdi,%r15
xor    %edi,%edi
cmp    $0x40080000,%r15
sete   %dil
call   1030 <DEBUG_ASSERT@plt>
mov    %rbx,%rdi
call   1040 <LPCChannelValid@plt>
mov    %eax,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    %rbx,%rcx
shl    $0x4,%rcx
mov    0x10(%rcx,%r15,1),%rax
test   %r13,%r13
je     117b <LPCChannelConfigGet+0x5b>
mov    %rax,%rdx
shr    $0x4,%rdx
and    $0x3fe,%edx
mov    %rdx,0x0(%r13)
test   %r12,%r12
je     1189 <LPCChannelConfigGet+0x69>
mov    0x18(%r15,%rcx,1),%rcx
mov    %rcx,(%r12)
cmp    $0x7,%rbx
jne    11a4 <LPCChannelConfigGet+0x84>
test   %r14,%r14
je     11a4 <LPCChannelConfigGet+0x84>
mov    0x120(%r15),%rcx
and    $0x70000,%ecx
mov    %rcx,(%r14)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i64 @LPCChannelConfigGet(i64 %0, i64 %1, i64* %2, i64* %3, i64* %4) {
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64*
%9 = alloca i64*
%10 = alloca i64*
%11 = alloca i64
store i64 %0, i64* %6
store i64 %1, i64* %7
store i64* %2, i64** %8
store i64* %3, i64** %9
store i64* %4, i64** %10
%12 = load i64, i64* %6
%13 = icmp eq i64 %12, 1074266112
%14 = zext i1 %13 to i32
%15 = call i32 @DEBUG_ASSERT(i32 %14)
%16 = load i64, i64* %7
%17 = call i32 @LPCChannelValid(i64 %16)
%18 = call i32 @DEBUG_ASSERT(i32 %17)
%19 = load i64, i64* %6
%20 = add i64 %19, 16
%21 = load i64, i64* %7
%22 = mul i64 %21, 16
%23 = add i64 %20, %22
%24 = inttoptr i64 %23 to i64*
%25 = load volatile i64, i64* %24
store i64 %25, i64* %11
%26 = load i64*, i64** %9
%27 = icmp ne i64* %26, null
br i1 %27, label %28, label %33
28: ; preds = %5
%29 = load i64, i64* %11
%30 = and i64 %29, 16352
%31 = lshr i64 %30, 4
%32 = load i64*, i64** %9
store i64 %31, i64* %32
br label %33
33: ; preds = %28, %5
%34 = load i64*, i64** %8
%35 = icmp ne i64* %34, null
br i1 %35, label %36, label %45
36: ; preds = %33
%37 = load i64, i64* %6
%38 = add i64 %37, 24
%39 = load i64, i64* %7
%40 = mul i64 %39, 16
%41 = add i64 %38, %40
%42 = inttoptr i64 %41 to i64*
%43 = load volatile i64, i64* %42
%44 = load i64*, i64** %8
store i64 %43, i64* %44
br label %45
45: ; preds = %36, %33
%46 = load i64*, i64** %10
%47 = icmp ne i64* %46, null
br i1 %47, label %48, label %58
48: ; preds = %45
%49 = load i64, i64* %7
%50 = icmp eq i64 %49, 7
br i1 %50, label %51, label %58
51: ; preds = %48
%52 = load i64, i64* %6
%53 = add i64 %52, 288
%54 = inttoptr i64 %53 to i64*
%55 = load volatile i64, i64* %54
%56 = and i64 %55, 458752
%57 = load i64*, i64** %10
store i64 %56, i64* %57
br label %58
58: ; preds = %51, %48, %45
%59 = load i64, i64* %11
ret i64 %59
}

LLVM IR (-O2):
define i64 @LPCChannelConfigGet(i64 %0, i64 %1, i64* writeonly %2, i64* writeonly %3, i64* writeonly %4) {
%6 = icmp eq i64 %0, 1074266112
%7 = zext i1 %6 to i32
%8 = tail call i32 @DEBUG_ASSERT(i32 %7)
%9 = tail call i32 @LPCChannelValid(i64 %1)
%10 = tail call i32 @DEBUG_ASSERT(i32 %9)
%11 = shl i64 %1, 4
%12 = add i64 %11, %0
%13 = add i64 %12, 16
%14 = inttoptr i64 %13 to i64*
%15 = load volatile i64, i64* %14
%16 = icmp eq i64* %3, null
br i1 %16, label %20, label %17
17: ; preds = %5
%18 = lshr i64 %15, 4
%19 = and i64 %18, 1022
store i64 %19, i64* %3
br label %20
20: ; preds = %17, %5
%21 = icmp eq i64* %2, null
br i1 %21, label %26, label %22
22: ; preds = %20
%23 = add i64 %12, 24
%24 = inttoptr i64 %23 to i64*
%25 = load volatile i64, i64* %24
store i64 %25, i64* %2
br label %26
26: ; preds = %22, %20
%27 = icmp ne i64* %4, null
%28 = icmp eq i64 %1, 7
%29 = and i1 %28, %27
br i1 %29, label %30, label %35
30: ; preds = %26
%31 = add i64 %0, 288
%32 = inttoptr i64 %31 to i64*
%33 = load volatile i64, i64* %32
%34 = and i64 %33, 458752
store i64 %34, i64* %4
br label %35
35: ; preds = %30, %26
ret i64 %15
}