#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 */
void EPIConfigHB8CSSet(uint32_t ui32Base, uint32_t ui32CS,
                       uint32_t ui32Config) {
  uint32_t ui32Offset, ui32Reg;
  ;
  ;
  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
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1128 <EPIConfigHB8CSSet+0x28>
mov    -0x8(%rbp),%eax
shl    $0x2,%eax
add    $0x10,%eax
mov    %eax,-0x10(%rbp)
jmp    1139 <EPIConfigHB8CSSet+0x39>
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)
pop    %rbp
ret

x86 assembly (clang, -O2):
<EPIConfigHB8CSSet>:
cmp    $0x2,%esi
lea    0x10(%rdi,%rsi,4),%eax
lea    0x300(%rdi,%rsi,4),%ecx
cmovl  %eax,%ecx
movslq %ecx,%rax
mov    $0xffc7ff0c,%ecx
and    (%rax),%ecx
or     %edx,%ecx
mov    %ecx,(%rax)
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* %5
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %15
11: ; preds = %3
%12 = load i32, i32* %5
%13 = shl i32 %12, 2
%14 = add nsw i32 16, %13
store i32 %14, i32* %7
br label %20
15: ; preds = %3
%16 = load i32, i32* %5
%17 = sub nsw i32 %16, 2
%18 = shl i32 %17, 2
%19 = add nsw i32 776, %18
store i32 %19, i32* %7
br label %20
20: ; preds = %15, %11
%21 = load i32, i32* %4
%22 = load i32, i32* %7
%23 = add nsw i32 %21, %22
%24 = sext i32 %23 to i64
%25 = inttoptr i64 %24 to i32*
%26 = load volatile i32, i32* %25
%27 = and i32 %26, -3670260
store i32 %27, i32* %8
%28 = load i32, i32* %8
%29 = load i32, i32* %6
%30 = or i32 %28, %29
%31 = load i32, i32* %4
%32 = load i32, i32* %7
%33 = add nsw i32 %31, %32
%34 = sext i32 %33 to i64
%35 = inttoptr i64 %34 to i32*
store volatile i32 %30, i32* %35
ret void
}

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