#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);
unsigned long LPCWordRead(unsigned long ulBase, unsigned long ulOffset) {
  DEBUG_ASSERT(ulBase == 0x40080000);
  DEBUG_ASSERT((ulOffset & 3) == 0);
  DEBUG_ASSERT(
      ulOffset <
      ((((*((volatile unsigned long *)(ulBase + 0x00000004))) & 0x00070000) >>
        16) *
       256));
  return ((*((volatile unsigned long *)(ulBase + 0x00000400 + ulOffset))));
}


x86 assembly (clang, -O0):
<LPCWordRead>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x40080000,-0x8(%rbp)
40
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    -0x10(%rbp),%rax
and    $0x3,%rax
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    0x4(%rcx),%rcx
and    $0x70000,%rcx
shr    $0x10,%rcx
shl    $0x8,%rcx
cmp    %rcx,%rax
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    -0x8(%rbp),%rax
add    $0x400,%rax
add    -0x10(%rbp),%rax
mov    (%rax),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LPCWordRead>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
cmp    $0x40080000,%rbx
sete   %dil
call   1030 <DEBUG_ASSERT@plt>
xor    %edi,%edi
test   $0x3,%r14b
sete   %dil
call   1030 <DEBUG_ASSERT@plt>
mov    0x4(%rbx),%rax
shr    $0x8,%rax
and    $0x700,%eax
xor    %edi,%edi
cmp    %r14,%rax
seta   %dil
call   1030 <DEBUG_ASSERT@plt>
mov    0x400(%rbx,%r14,1),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i64 @LPCWordRead(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%5 = load i64, i64* %3
%6 = icmp eq i64 %5, 1074266112
%7 = zext i1 %6 to i32
%8 = call i32 @DEBUG_ASSERT(i32 %7)
%9 = load i64, i64* %4
%10 = and i64 %9, 3
%11 = icmp eq i64 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @DEBUG_ASSERT(i32 %12)
%14 = load i64, i64* %4
%15 = load i64, i64* %3
%16 = add i64 %15, 4
%17 = inttoptr i64 %16 to i64*
%18 = load volatile i64, i64* %17
%19 = and i64 %18, 458752
%20 = lshr i64 %19, 16
%21 = mul i64 %20, 256
%22 = icmp ult i64 %14, %21
%23 = zext i1 %22 to i32
%24 = call i32 @DEBUG_ASSERT(i32 %23)
%25 = load i64, i64* %3
%26 = add i64 %25, 1024
%27 = load i64, i64* %4
%28 = add i64 %26, %27
%29 = inttoptr i64 %28 to i64*
%30 = load volatile i64, i64* %29
ret i64 %30
}

LLVM IR (-O2):
define i64 @LPCWordRead(i64 %0, i64 %1) {
%3 = icmp eq i64 %0, 1074266112
%4 = zext i1 %3 to i32
%5 = tail call i32 @DEBUG_ASSERT(i32 %4)
%6 = and i64 %1, 3
%7 = icmp eq i64 %6, 0
%8 = zext i1 %7 to i32
%9 = tail call i32 @DEBUG_ASSERT(i32 %8)
%10 = add i64 %0, 4
%11 = inttoptr i64 %10 to i64*
%12 = load volatile i64, i64* %11
%13 = lshr i64 %12, 8
%14 = and i64 %13, 1792
%15 = icmp ugt i64 %14, %1
%16 = zext i1 %15 to i32
%17 = tail call i32 @DEBUG_ASSERT(i32 %16)
%18 = add i64 %0, 1024
%19 = add i64 %18, %1
%20 = inttoptr i64 %19 to i64*
%21 = load volatile i64, i64* %20
ret i64 %21
}