#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 MPURegionSet(uint32_t ui32Region, uint32_t ui32Addr, uint32_t ui32Flags) {
  ASSERT(ui32Region < 8);
  ASSERT(ui32Addr == (ui32Addr & ~0 << (((ui32Flags & 0x0000003E) >> 1) + 1)));
  (*((volatile uint32_t *)(0xE000ED9C))) = ui32Addr | ui32Region | 0x00000010;
  (*((volatile uint32_t *)(0xE000EDA0))) =
      ((ui32Flags & ~(0x00380000 | 0x00020000)) | 0x00040000 | 0x00010000);
}


x86 assembly (clang, -O0):
<MPURegionSet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
cmpl   $0x8,-0x4(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
mov    -0x8(%rbp),%eax
mov    -0x8(%rbp),%ecx
mov    %ecx,-0x10(%rbp)
mov    -0xc(%rbp),%ecx
and    $0x3e,%ecx
sar    $0x1,%ecx
add    $0x1,%ecx
mov    $0xffffffff,%edx
shl    %cl,%edx
mov    -0x10(%rbp),%ecx
and    %edx,%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <ASSERT@plt>
mov    -0x8(%rbp),%ecx
or     -0x4(%rbp),%ecx
or     $0x10,%ecx
mov    $0xe000ed9c,%eax
mov    %ecx,(%rax)
mov    -0xc(%rbp),%ecx
and    $0xffc5ffff,%ecx
or     $0x40000,%ecx
or     $0x10000,%ecx
mov    $0xe000eda0,%eax
mov    %ecx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MPURegionSet>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebx
mov    %esi,%r14d
mov    %edi,%ebp
xor    %edi,%edi
cmp    $0x8,%ebp
setl   %dil
call   1030 <ASSERT@plt>
mov    %ebx,%ecx
shr    %cl
mov    $0xfffffffe,%eax
shl    %cl,%eax
not    %eax
xor    %edi,%edi
test   %eax,%r14d
sete   %dil
call   1030 <ASSERT@plt>
or     %r14d,%ebp
or     $0x10,%ebp
mov    $0xe000ed9c,%eax
mov    %ebp,(%rax)
and    $0xffc0ffff,%ebx
or     $0x50000,%ebx
mov    %ebx,0x4(%rax)
pop    %rbx
pop    %r14
pop    %rbp
ret

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

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