#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*/ OAL_OBTAIN_SEMAPHORE();
int /*<<< orphan*/ OAL_RELEASE_SEMAPHORE();
int fc8300_ppi_wordread(void *handle, unsigned short devid, unsigned short addr,
                        unsigned short *data) {
  unsigned short length = 2;
  unsigned char command = 0x80 | 0x40;
  OAL_OBTAIN_SEMAPHORE();
  (*(volatile unsigned char *)0x00) = (addr & 0xff00) >> 8;
  (*(volatile unsigned char *)0x00) = addr & 0xff;
  (*(volatile unsigned char *)0x00) = command;
  (*(volatile unsigned char *)0x00) = length & 0xff;
  *data = (*(volatile unsigned char *)0x00);
  *data |= (*(volatile unsigned char *)0x00) << 8;
  OAL_RELEASE_SEMAPHORE();
  return 0;
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dx,%ax
mov    %si,%dx
mov    %rdi,-0x8(%rbp)
mov    %dx,-0xa(%rbp)
mov    %ax,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
movw   $0x2,-0x1a(%rbp)
movb   $0xc0,-0x1b(%rbp)
mov    $0x0,%al
call   1040 <OAL_OBTAIN_SEMAPHORE@plt>
movzwl -0xc(%rbp),%eax
and    $0xff00,%eax
sar    $0x8,%eax
mov    %al,%cl
xor    %eax,%eax
mov    %cl,(%rax)
movzwl -0xc(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
xor    %eax,%eax
mov    %cl,(%rax)
mov    -0x1b(%rbp),%cl
xor    %eax,%eax
mov    %cl,(%rax)
movzwl -0x1a(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
xor    %eax,%eax
mov    %cl,(%rax)
xor    %eax,%eax
mov    (%rax),%al
movzbl %al,%eax
mov    %ax,%cx
mov    -0x18(%rbp),%rax
mov    %cx,(%rax)
xor    %eax,%eax
mov    (%rax),%al
movzbl %al,%edx
shl    $0x8,%edx
mov    -0x18(%rbp),%rax
movzwl (%rax),%ecx
or     %edx,%ecx
mov    %cx,(%rax)
mov    $0x0,%al
call   1030 <OAL_RELEASE_SEMAPHORE@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %edx,%ebx
xor    %eax,%eax
call   1040 <OAL_OBTAIN_SEMAPHORE@plt>
mov    %bh,0x0
mov    %bl,0x0
movb   $0xc0,0x0
c0
movb   $0x2,0x0
02
movzbl 0x0,%eax
movzbl 0x0,%ecx
shl    $0x8,%ecx
or     %eax,%ecx
mov    %cx,(%r14)
xor    %eax,%eax
call   1030 <OAL_RELEASE_SEMAPHORE@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @fc8300_ppi_wordread(i8* %0, i16 zeroext %1, i16 zeroext %2, i16* %3) {
%5 = alloca i8*
%6 = alloca i16
%7 = alloca i16
%8 = alloca i16*
%9 = alloca i16
%10 = alloca i8
store i8* %0, i8** %5
store i16 %1, i16* %6
store i16 %2, i16* %7
store i16* %3, i16** %8
store i16 2, i16* %9
store i8 -64, i8* %10
%11 = call i32 (...) @OAL_OBTAIN_SEMAPHORE()
%12 = load i16, i16* %7
%13 = zext i16 %12 to i32
%14 = and i32 %13, 65280
%15 = ashr i32 %14, 8
%16 = trunc i32 %15 to i8
store volatile i8 %16, i8* null
%17 = load i16, i16* %7
%18 = zext i16 %17 to i32
%19 = and i32 %18, 255
%20 = trunc i32 %19 to i8
store volatile i8 %20, i8* null
%21 = load i8, i8* %10
store volatile i8 %21, i8* null
%22 = load i16, i16* %9
%23 = zext i16 %22 to i32
%24 = and i32 %23, 255
%25 = trunc i32 %24 to i8
store volatile i8 %25, i8* null
%26 = load volatile i8, i8* null
%27 = zext i8 %26 to i16
%28 = load i16*, i16** %8
store i16 %27, i16* %28
%29 = load volatile i8, i8* null
%30 = zext i8 %29 to i32
%31 = shl i32 %30, 8
%32 = load i16*, i16** %8
%33 = load i16, i16* %32
%34 = zext i16 %33 to i32
%35 = or i32 %34, %31
%36 = trunc i32 %35 to i16
store i16 %36, i16* %32
%37 = call i32 (...) @OAL_RELEASE_SEMAPHORE()
ret i32 0
}

LLVM IR (-O2):
define i32 @fc8300_ppi_wordread(i8* nocapture readnone %0, i16 zeroext %1, i16 zeroext %2, i16* nocapture writeonly %3) {
%5 = tail call i32 (...) @OAL_OBTAIN_SEMAPHORE()
%6 = lshr i16 %2, 8
%7 = trunc i16 %6 to i8
store volatile i8 %7, i8* null
%8 = trunc i16 %2 to i8
store volatile i8 %8, i8* null
store volatile i8 -64, i8* null
store volatile i8 2, i8* null
%9 = load volatile i8, i8* null
%10 = zext i8 %9 to i16
%11 = load volatile i8, i8* null
%12 = zext i8 %11 to i16
%13 = shl nuw i16 %12, 8
%14 = or i16 %13, %10
store i16 %14, i16* %3
%15 = tail call i32 (...) @OAL_RELEASE_SEMAPHORE()
ret i32 0
}