#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*/ ASSERT(int);
void EPIConfigHB8CSSet(uint32_t ui32Base, uint32_t ui32CS,
                       uint32_t ui32Config) {
  uint32_t ui32Offset, ui32Reg;
  ASSERT(ui32Base == 0x400D0000);
  ASSERT(ui32CS < 4);
  if (ui32CS < 2) {
    ui32Offset = 0x00000010 + (ui32CS << 2);
  } else {
    ui32Offset = 0x00000308 + ((ui32CS - 2) << 2);
  }
  ui32Reg = (*((volatile uint32_t *)(ui32Base + ui32Offset))) &
            ~(0x00000003 | 0x00000030 | 0x000000C0 | 0x00100000 | 0x00200000 |
              0x00080000);
  (*((volatile uint32_t *)(ui32Base + ui32Offset))) = (ui32Reg | ui32Config);
}


x86 assembly (clang, -O0):
<EPIConfigHB8CSSet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
cmpl   $0x400d0000,-0x4(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
cmpl   $0x4,-0x8(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
cmpl   $0x2,-0x8(%rbp)
jge    1161 <EPIConfigHB8CSSet+0x51>
mov    -0x8(%rbp),%eax
shl    $0x2,%eax
add    $0x10,%eax
mov    %eax,-0x10(%rbp)
jmp    1172 <EPIConfigHB8CSSet+0x62>
mov    -0x8(%rbp),%eax
sub    $0x2,%eax
shl    $0x2,%eax
add    $0x308,%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
add    -0x10(%rbp),%eax
cltq
mov    (%rax),%eax
and    $0xffc7ff0c,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
or     -0xc(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    -0x10(%rbp),%eax
cltq
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EPIConfigHB8CSSet>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebx
mov    %edi,%ebp
xor    %edi,%edi
cmp    $0x400d0000,%ebp
sete   %dil
call   1030 <ASSERT@plt>
xor    %edi,%edi
cmp    $0x4,%ebx
setl   %dil
call   1030 <ASSERT@plt>
cmp    $0x2,%ebx
lea    0x10(%rbp,%rbx,4),%eax
lea    0x300(%rbp,%rbx,4),%ecx
cmovl  %eax,%ecx
movslq %ecx,%rax
mov    $0xffc7ff0c,%ecx
and    (%rax),%ecx
or     %r14d,%ecx
mov    %ecx,(%rax)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @EPIConfigHB8CSSet(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load i32, i32* %4
%10 = icmp eq i32 %9, 1074593792
%11 = zext i1 %10 to i32
%12 = call i32 @ASSERT(i32 %11)
%13 = load i32, i32* %5
%14 = icmp slt i32 %13, 4
%15 = zext i1 %14 to i32
%16 = call i32 @ASSERT(i32 %15)
%17 = load i32, i32* %5
%18 = icmp slt i32 %17, 2
br i1 %18, label %19, label %23
19: ; preds = %3
%20 = load i32, i32* %5
%21 = shl i32 %20, 2
%22 = add nsw i32 16, %21
store i32 %22, i32* %7
br label %28
23: ; preds = %3
%24 = load i32, i32* %5
%25 = sub nsw i32 %24, 2
%26 = shl i32 %25, 2
%27 = add nsw i32 776, %26
store i32 %27, i32* %7
br label %28
28: ; preds = %23, %19
%29 = load i32, i32* %4
%30 = load i32, i32* %7
%31 = add nsw i32 %29, %30
%32 = sext i32 %31 to i64
%33 = inttoptr i64 %32 to i32*
%34 = load volatile i32, i32* %33
%35 = and i32 %34, -3670260
store i32 %35, i32* %8
%36 = load i32, i32* %8
%37 = load i32, i32* %6
%38 = or i32 %36, %37
%39 = load i32, i32* %4
%40 = load i32, i32* %7
%41 = add nsw i32 %39, %40
%42 = sext i32 %41 to i64
%43 = inttoptr i64 %42 to i32*
store volatile i32 %38, i32* %43
ret void
}

LLVM IR (-O2):
define void @EPIConfigHB8CSSet(i32 %0, i32 %1, i32 %2) {
%4 = icmp eq i32 %0, 1074593792
%5 = zext i1 %4 to i32
%6 = tail call i32 @ASSERT(i32 %5)
%7 = icmp slt i32 %1, 4
%8 = zext i1 %7 to i32
%9 = tail call i32 @ASSERT(i32 %8)
%10 = icmp slt i32 %1, 2
%11 = shl i32 %1, 2
%12 = select i1 %10, i32 16, i32 768
%13 = add i32 %11, %0
%14 = add i32 %13, %12
%15 = sext i32 %14 to i64
%16 = inttoptr i64 %15 to i32*
%17 = load volatile i32, i32* %16
%18 = and i32 %17, -3670260
%19 = or i32 %18, %2
store volatile i32 %19, i32* %16
ret void
}