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


x86 assembly (clang, -O0):
<LPCWordWrite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x40080000,-0x8(%rbp)
40
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    -0x10(%rbp),%rax
and    $0x1,%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    -0x18(%rbp),%rcx
mov    -0x8(%rbp),%rax
add    $0x400,%rax
add    -0x10(%rbp),%rax
mov    %rcx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LPCWordWrite>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
xor    %edi,%edi
cmp    $0x40080000,%rbx
sete   %dil
call   1030 <DEBUG_ASSERT@plt>
mov    %r15d,%edi
not    %edi
and    $0x1,%edi
call   1030 <DEBUG_ASSERT@plt>
mov    0x4(%rbx),%rax
shr    $0x8,%rax
and    $0x700,%eax
xor    %edi,%edi
cmp    %r15,%rax
seta   %dil
call   1030 <DEBUG_ASSERT@plt>
mov    %r14,0x400(%rbx,%r15,1)
pop    %rbx
pop    %r14
pop    %r15
ret

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

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