#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);
void LPCChannelConfigMBSet(unsigned long ulBase, unsigned long ulChannel,
                           unsigned long ulConfig, unsigned long ulAddress,
                           unsigned long ulOffset) {
  DEBUG_ASSERT(ulBase == 0x40080000);
  DEBUG_ASSERT(LPCChannelValid(ulChannel));
  DEBUG_ASSERT(
      (ulConfig & ~(0x0F000000 | 0x0F000000 | 0x00F00000 | 0x00080000 |
                    0x00040000 | 0x00030000 | 0x00008000 | 0x0000001C)) == 0);
  DEBUG_ASSERT((ulOffset & 3) == 0);
  DEBUG_ASSERT(
      ulOffset <
      (((((*((volatile unsigned long *)(ulBase + 0x00000004))) & 0x00070000) >>
         16) *
        256) -
       4));
  ulConfig |= (((ulOffset >> 1) << 5) & 0x00003FE0);
  ulConfig |= 0x00000001;
  (*((volatile unsigned long *)(ulBase + 0x00000010 + (ulChannel * 0x10)))) =
      ulConfig;
  (*((volatile unsigned long *)(ulBase + 0x00000018 + (ulChannel * 0x10)))) =
      ulAddress;
}


x86 assembly (clang, -O0):
<LPCChannelConfigMBSet>:
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    -0x18(%rbp),%rax
and    $0xfffffffff0007fe3,%rax
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    -0x28(%rbp),%rax
and    $0x3,%rax
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    -0x28(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    0x4(%rcx),%rcx
and    $0x70000,%rcx
shr    $0x10,%rcx
shl    $0x8,%rcx
sub    $0x4,%rcx
cmp    %rcx,%rax
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    -0x28(%rbp),%rax
shr    $0x1,%rax
shl    $0x5,%rax
and    $0x3fe0,%rax
or     -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
or     $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
add    $0x10,%rax
mov    -0x10(%rbp),%rdx
shl    $0x4,%rdx
add    %rdx,%rax
mov    %rcx,(%rax)
mov    -0x20(%rbp),%rcx
mov    -0x8(%rbp),%rax
add    $0x18,%rax
mov    -0x10(%rbp),%rdx
shl    $0x4,%rdx
add    %rdx,%rax
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LPCChannelConfigMBSet>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %r8,%rbx
mov    %rcx,%r14
mov    %rdx,%r13
mov    %rsi,%r15
mov    %rdi,%r12
xor    %edi,%edi
cmp    $0x40080000,%r12
sete   %dil
call   1030 <DEBUG_ASSERT@plt>
mov    %r15,%rdi
call   1040 <LPCChannelValid@plt>
mov    %eax,%edi
call   1030 <DEBUG_ASSERT@plt>
xor    %edi,%edi
test   $0xfffffffff0007fe3,%r13
sete   %dil
call   1030 <DEBUG_ASSERT@plt>
xor    %edi,%edi
test   $0x3,%bl
sete   %dil
call   1030 <DEBUG_ASSERT@plt>
mov    0x4(%r12),%rax
shr    $0x8,%rax
and    $0x700,%eax
add    $0xfffffffffffffffc,%rax
xor    %edi,%edi
cmp    %rbx,%rax
seta   %dil
call   1030 <DEBUG_ASSERT@plt>
shl    $0x4,%ebx
and    $0x3fe0,%ebx
or     %r13,%rbx
or     $0x1,%rbx
shl    $0x4,%r15
mov    %rbx,0x10(%r15,%r12,1)
mov    %r14,0x18(%r15,%r12,1)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @LPCChannelConfigMBSet(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
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
%11 = load i64, i64* %6
%12 = icmp eq i64 %11, 1074266112
%13 = zext i1 %12 to i32
%14 = call i32 @DEBUG_ASSERT(i32 %13)
%15 = load i64, i64* %7
%16 = call i32 @LPCChannelValid(i64 %15)
%17 = call i32 @DEBUG_ASSERT(i32 %16)
%18 = load i64, i64* %8
%19 = and i64 %18, -268402717
%20 = icmp eq i64 %19, 0
%21 = zext i1 %20 to i32
%22 = call i32 @DEBUG_ASSERT(i32 %21)
%23 = load i64, i64* %10
%24 = and i64 %23, 3
%25 = icmp eq i64 %24, 0
%26 = zext i1 %25 to i32
%27 = call i32 @DEBUG_ASSERT(i32 %26)
%28 = load i64, i64* %10
%29 = load i64, i64* %6
%30 = add i64 %29, 4
%31 = inttoptr i64 %30 to i64*
%32 = load volatile i64, i64* %31
%33 = and i64 %32, 458752
%34 = lshr i64 %33, 16
%35 = mul i64 %34, 256
%36 = sub i64 %35, 4
%37 = icmp ult i64 %28, %36
%38 = zext i1 %37 to i32
%39 = call i32 @DEBUG_ASSERT(i32 %38)
%40 = load i64, i64* %10
%41 = lshr i64 %40, 1
%42 = shl i64 %41, 5
%43 = and i64 %42, 16352
%44 = load i64, i64* %8
%45 = or i64 %44, %43
store i64 %45, i64* %8
%46 = load i64, i64* %8
%47 = or i64 %46, 1
store i64 %47, i64* %8
%48 = load i64, i64* %8
%49 = load i64, i64* %6
%50 = add i64 %49, 16
%51 = load i64, i64* %7
%52 = mul i64 %51, 16
%53 = add i64 %50, %52
%54 = inttoptr i64 %53 to i64*
store volatile i64 %48, i64* %54
%55 = load i64, i64* %9
%56 = load i64, i64* %6
%57 = add i64 %56, 24
%58 = load i64, i64* %7
%59 = mul i64 %58, 16
%60 = add i64 %57, %59
%61 = inttoptr i64 %60 to i64*
store volatile i64 %55, i64* %61
ret void
}

LLVM IR (-O2):
define void @LPCChannelConfigMBSet(i64 %0, i64 %1, i64 %2, i64 %3, i64 %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 = and i64 %2, -268402717
%12 = icmp eq i64 %11, 0
%13 = zext i1 %12 to i32
%14 = tail call i32 @DEBUG_ASSERT(i32 %13)
%15 = and i64 %4, 3
%16 = icmp eq i64 %15, 0
%17 = zext i1 %16 to i32
%18 = tail call i32 @DEBUG_ASSERT(i32 %17)
%19 = add i64 %0, 4
%20 = inttoptr i64 %19 to i64*
%21 = load volatile i64, i64* %20
%22 = lshr i64 %21, 8
%23 = and i64 %22, 1792
%24 = add nsw i64 %23, -4
%25 = icmp ugt i64 %24, %4
%26 = zext i1 %25 to i32
%27 = tail call i32 @DEBUG_ASSERT(i32 %26)
%28 = shl i64 %4, 4
%29 = and i64 %28, 16352
%30 = or i64 %29, %2
%31 = or i64 %30, 1
%32 = shl i64 %1, 4
%33 = add i64 %32, %0
%34 = add i64 %33, 16
%35 = inttoptr i64 %34 to i64*
store volatile i64 %31, i64* %35
%36 = add i64 %33, 24
%37 = inttoptr i64 %36 to i64*
store volatile i64 %3, i64* %37
ret void
}