#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);
void MPURegionSet(unsigned long ulRegion, unsigned long ulAddr,
                  unsigned long ulFlags) {
  DEBUG_ASSERT(ulRegion < 8);
  DEBUG_ASSERT((ulAddr & ~0 << (((ulFlags & 0x0000003E) >> 1) + 1)) == ulAddr);
  (*((volatile unsigned long *)(0xE000ED9C))) = ulAddr | ulRegion | 0x00000010;
  (*((volatile unsigned long *)(0xE000EDA0))) =
      (ulFlags & ~(0x00380000 | 0x00020000)) | 0x00040000 | 0x00010000;
}


x86 assembly (clang, -O0):
<MPURegionSet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x8,-0x8(%rbp)
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
and    $0x3e,%rcx
shr    $0x1,%rcx
add    $0x1,%rcx
mov    $0xffffffff,%edx
shl    %cl,%edx
mov    %edx,%ecx
movslq %ecx,%rcx
and    %rcx,%rax
cmp    -0x10(%rbp),%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    -0x10(%rbp),%rcx
or     -0x8(%rbp),%rcx
or     $0x10,%rcx
mov    $0xe000ed9c,%eax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rcx
and    $0xffffffffffc5ffff,%rcx
or     $0x40000,%rcx
or     $0x10000,%rcx
mov    $0xe000eda0,%eax
mov    %rcx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MPURegionSet>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
xor    %edi,%edi
cmp    $0x8,%rbx
setb   %dil
call   1030 <DEBUG_ASSERT@plt>
mov    %r14d,%ecx
shr    %cl
mov    $0xfffffffe,%eax
shl    %cl,%eax
cltq
not    %rax
xor    %edi,%edi
test   %rax,%r15
sete   %dil
call   1030 <DEBUG_ASSERT@plt>
or     %r15,%rbx
or     $0x10,%rbx
mov    $0xe000ed9c,%eax
mov    %rbx,(%rax)
and    $0xffffffffffc0ffff,%r14
or     $0x50000,%r14
mov    %r14,0x4(%rax)
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @MPURegionSet(i64 %0, i64 %1, i64 %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
store i64 %0, i64* %4
store i64 %1, i64* %5
store i64 %2, i64* %6
%7 = load i64, i64* %4
%8 = icmp ult i64 %7, 8
%9 = zext i1 %8 to i32
%10 = call i32 @DEBUG_ASSERT(i32 %9)
%11 = load i64, i64* %5
%12 = load i64, i64* %6
%13 = and i64 %12, 62
%14 = lshr i64 %13, 1
%15 = add i64 %14, 1
%16 = trunc i64 %15 to i32
%17 = shl i32 -1, %16
%18 = sext i32 %17 to i64
%19 = and i64 %11, %18
%20 = load i64, i64* %5
%21 = icmp eq i64 %19, %20
%22 = zext i1 %21 to i32
%23 = call i32 @DEBUG_ASSERT(i32 %22)
%24 = load i64, i64* %5
%25 = load i64, i64* %4
%26 = or i64 %24, %25
%27 = or i64 %26, 16
store volatile i64 %27, i64* inttoptr (i64 3758157212 to i64*)
%28 = load i64, i64* %6
%29 = and i64 %28, -3801089
%30 = or i64 %29, 262144
%31 = or i64 %30, 65536
store volatile i64 %31, i64* inttoptr (i64 3758157216 to i64*)
ret void
}

LLVM IR (-O2):
define void @MPURegionSet(i64 %0, i64 %1, i64 %2) {
%4 = icmp ult i64 %0, 8
%5 = zext i1 %4 to i32
%6 = tail call i32 @DEBUG_ASSERT(i32 %5)
%7 = trunc i64 %2 to i32
%8 = lshr i32 %7, 1
%9 = and i32 %8, 31
%10 = shl i32 -2, %9
%11 = sext i32 %10 to i64
%12 = and i64 %11, %1
%13 = icmp eq i64 %12, %1
%14 = zext i1 %13 to i32
%15 = tail call i32 @DEBUG_ASSERT(i32 %14)
%16 = or i64 %0, %1
%17 = or i64 %16, 16
store volatile i64 %17, i64* inttoptr (i64 3758157212 to i64*)
%18 = and i64 %2, -4128769
%19 = or i64 %18, 327680
store volatile i64 %19, i64* inttoptr (i64 3758157216 to i64*)
ret void
}