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


x86 assembly (clang, -O0):
<LPCHalfWordRead>:
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    $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    -0x8(%rbp),%rax
add    $0x400,%rax
add    -0x10(%rbp),%rax
mov    (%rax),%ax
movzwl %ax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LPCHalfWordRead>:
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>
mov    %r14d,%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    %r14,%rax
seta   %dil
call   1030 <DEBUG_ASSERT@plt>
movzwl 0x400(%rbx,%r14,1),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define zeroext i16 @LPCHalfWordRead(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, 1
%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 i16*
%30 = load volatile i16, i16* %29
ret i16 %30
}

LLVM IR (-O2):
define zeroext i16 @LPCHalfWordRead(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 = trunc i64 %1 to i32
%7 = and i32 %6, 1
%8 = xor i32 %7, 1
%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 i16*
%21 = load volatile i16, i16* %20
ret i16 %21
}