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


x86 assembly (clang, -O0):
<LPCHalfWordWrite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dx,%ax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %ax,-0x12(%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    -0x12(%rbp),%cx
mov    -0x8(%rbp),%rax
add    $0x400,%rax
add    -0x10(%rbp),%rax
mov    %cx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define void @LPCHalfWordWrite(i64 %0, i64 %1, i16 zeroext %2) {
%4 = alloca i64
%5 = alloca i64
%6 = alloca i16
store i64 %0, i64* %4
store i64 %1, i64* %5
store i16 %2, i16* %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 i16, i16* %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 i16*
store volatile i16 %27, i16* %32
ret void
}

LLVM IR (-O2):
define void @LPCHalfWordWrite(i64 %0, i64 %1, i16 zeroext %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 i16*
store volatile i16 %2, i16* %21
ret void
}