#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 PECIDomainValid(unsigned long);
void PECIDomainConfigSet(unsigned long ulBase, unsigned long ulDomain,
                         unsigned long ulHigh, unsigned long ulLow) {
  DEBUG_ASSERT(ulBase == 0x400B0000);
  DEBUG_ASSERT(PECIDomainValid(ulDomain));
  DEBUG_ASSERT(ulHigh <= 0xFFFF);
  DEBUG_ASSERT(ulLow <= 0xFFFF);
  DEBUG_ASSERT(ulHigh > ulLow);
  (*((volatile unsigned long *)(ulBase + 0x00000010 + (ulDomain * 4)))) =
      (((ulHigh << 16) & 0xFFFF0000) | ((ulLow << 0) & 0x0000FFFF));
}


x86 assembly (clang, -O0):
<PECIDomainConfigSet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0x400b0000,-0x8(%rbp)
40
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    -0x10(%rbp),%rdi
call   1040 <PECIDomainValid@plt>
mov    %eax,%edi
call   1030 <DEBUG_ASSERT@plt>
cmpq   $0xffff,-0x18(%rbp)
setbe  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
cmpq   $0xffff,-0x20(%rbp)
setbe  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
seta   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    -0x18(%rbp),%rcx
shl    $0x10,%rcx
movabs $0xffff0000,%rax
and    %rax,%rcx
mov    -0x20(%rbp),%rax
shl    $0x0,%rax
and    $0xffff,%rax
or     %rax,%rcx
mov    -0x8(%rbp),%rax
add    $0x10,%rax
mov    -0x10(%rbp),%rdx
shl    $0x2,%rdx
add    %rdx,%rax
mov    %rcx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PECIDomainConfigSet>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r12
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
xor    %edi,%edi
cmp    $0x400b0000,%r15
sete   %dil
call   1030 <DEBUG_ASSERT@plt>
mov    %r14,%rdi
call   1040 <PECIDomainValid@plt>
mov    %eax,%edi
call   1030 <DEBUG_ASSERT@plt>
xor    %edi,%edi
cmp    $0x10000,%rbx
setb   %dil
call   1030 <DEBUG_ASSERT@plt>
xor    %edi,%edi
cmp    $0x10000,%r12
setb   %dil
call   1030 <DEBUG_ASSERT@plt>
xor    %edi,%edi
cmp    %r12,%rbx
seta   %dil
call   1030 <DEBUG_ASSERT@plt>
shl    $0x10,%ebx
movzwl %r12w,%eax
or     %rbx,%rax
mov    %rax,0x10(%r15,%r14,4)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @PECIDomainConfigSet(i64 %0, i64 %1, i64 %2, i64 %3) {
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i64 %0, i64* %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i64 %3, i64* %8
%9 = load i64, i64* %5
%10 = icmp eq i64 %9, 1074462720
%11 = zext i1 %10 to i32
%12 = call i32 @DEBUG_ASSERT(i32 %11)
%13 = load i64, i64* %6
%14 = call i32 @PECIDomainValid(i64 %13)
%15 = call i32 @DEBUG_ASSERT(i32 %14)
%16 = load i64, i64* %7
%17 = icmp ule i64 %16, 65535
%18 = zext i1 %17 to i32
%19 = call i32 @DEBUG_ASSERT(i32 %18)
%20 = load i64, i64* %8
%21 = icmp ule i64 %20, 65535
%22 = zext i1 %21 to i32
%23 = call i32 @DEBUG_ASSERT(i32 %22)
%24 = load i64, i64* %7
%25 = load i64, i64* %8
%26 = icmp ugt i64 %24, %25
%27 = zext i1 %26 to i32
%28 = call i32 @DEBUG_ASSERT(i32 %27)
%29 = load i64, i64* %7
%30 = shl i64 %29, 16
%31 = and i64 %30, 4294901760
%32 = load i64, i64* %8
%33 = shl i64 %32, 0
%34 = and i64 %33, 65535
%35 = or i64 %31, %34
%36 = load i64, i64* %5
%37 = add i64 %36, 16
%38 = load i64, i64* %6
%39 = mul i64 %38, 4
%40 = add i64 %37, %39
%41 = inttoptr i64 %40 to i64*
store volatile i64 %35, i64* %41
ret void
}

LLVM IR (-O2):
define void @PECIDomainConfigSet(i64 %0, i64 %1, i64 %2, i64 %3) {
%5 = icmp eq i64 %0, 1074462720
%6 = zext i1 %5 to i32
%7 = tail call i32 @DEBUG_ASSERT(i32 %6)
%8 = tail call i32 @PECIDomainValid(i64 %1)
%9 = tail call i32 @DEBUG_ASSERT(i32 %8)
%10 = icmp ult i64 %2, 65536
%11 = zext i1 %10 to i32
%12 = tail call i32 @DEBUG_ASSERT(i32 %11)
%13 = icmp ult i64 %3, 65536
%14 = zext i1 %13 to i32
%15 = tail call i32 @DEBUG_ASSERT(i32 %14)
%16 = icmp ugt i64 %2, %3
%17 = zext i1 %16 to i32
%18 = tail call i32 @DEBUG_ASSERT(i32 %17)
%19 = shl i64 %2, 16
%20 = and i64 %19, 4294901760
%21 = and i64 %3, 65535
%22 = or i64 %20, %21
%23 = add i64 %0, 16
%24 = shl i64 %1, 2
%25 = add i64 %23, %24
%26 = inttoptr i64 %25 to i64*
store volatile i64 %22, i64* %26
ret void
}