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


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cx,%ax
mov    %dx,%cx
mov    %si,%dx
mov    %rdi,-0x8(%rbp)
mov    %dx,-0xa(%rbp)
mov    %cx,-0xc(%rbp)
mov    %ax,-0xe(%rbp)
movw   $0x2,-0x10(%rbp)
movb   $0x80,-0x11(%rbp)
mov    $0x0,%al
call   1050 <OAL_OBTAIN_SEMAPHORE@plt>
movzwl -0xc(%rbp),%eax
and    $0xff00,%eax
sar    $0x8,%eax
xor    %esi,%esi
movzwl %ax,%edi
call   1030 <outb@plt>
movzwl -0xc(%rbp),%eax
and    $0xff,%eax
xor    %esi,%esi
movzwl %ax,%edi
call   1030 <outb@plt>
movzbl -0x11(%rbp),%eax
xor    %esi,%esi
movzwl %ax,%edi
call   1030 <outb@plt>
movzwl -0x10(%rbp),%eax
and    $0xff,%eax
xor    %esi,%esi
movzwl %ax,%edi
call   1030 <outb@plt>
movzwl -0xe(%rbp),%eax
and    $0xff,%eax
xor    %esi,%esi
movzwl %ax,%edi
call   1030 <outb@plt>
movzwl -0xe(%rbp),%eax
and    $0xff00,%eax
sar    $0x8,%eax
xor    %esi,%esi
movzwl %ax,%edi
call   1030 <outb@plt>
mov    $0x0,%al
call   1040 <OAL_RELEASE_SEMAPHORE@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rbp
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %edx,%ebp
xor    %eax,%eax
call   1050 <OAL_OBTAIN_SEMAPHORE@plt>
mov    %ebp,%edi
shr    $0x8,%edi
xor    %esi,%esi
call   1030 <outb@plt>
movzbl %bpl,%edi
xor    %esi,%esi
call   1030 <outb@plt>
mov    $0x80,%edi
xor    %esi,%esi
call   1030 <outb@plt>
mov    $0x2,%edi
xor    %esi,%esi
call   1030 <outb@plt>
movzbl %bl,%edi
xor    %esi,%esi
call   1030 <outb@plt>
shr    $0x8,%ebx
mov    %ebx,%edi
xor    %esi,%esi
call   1030 <outb@plt>
xor    %eax,%eax
call   1040 <OAL_RELEASE_SEMAPHORE@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @fc8300_ppi_wordwrite(i8* %0, i16 zeroext %1, i16 zeroext %2, i16 zeroext %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 -128, 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 i16
%17 = call i32 @outb(i16 zeroext %16, i32 0)
%18 = load i16, i16* %7
%19 = zext i16 %18 to i32
%20 = and i32 %19, 255
%21 = trunc i32 %20 to i16
%22 = call i32 @outb(i16 zeroext %21, i32 0)
%23 = load i8, i8* %10
%24 = zext i8 %23 to i16
%25 = call i32 @outb(i16 zeroext %24, i32 0)
%26 = load i16, i16* %9
%27 = zext i16 %26 to i32
%28 = and i32 %27, 255
%29 = trunc i32 %28 to i16
%30 = call i32 @outb(i16 zeroext %29, i32 0)
%31 = load i16, i16* %8
%32 = zext i16 %31 to i32
%33 = and i32 %32, 255
%34 = trunc i32 %33 to i16
%35 = call i32 @outb(i16 zeroext %34, i32 0)
%36 = load i16, i16* %8
%37 = zext i16 %36 to i32
%38 = and i32 %37, 65280
%39 = ashr i32 %38, 8
%40 = trunc i32 %39 to i16
%41 = call i32 @outb(i16 zeroext %40, i32 0)
%42 = call i32 (...) @OAL_RELEASE_SEMAPHORE()
ret i32 0
}

LLVM IR (-O2):
define i32 @fc8300_ppi_wordwrite(i8* nocapture readnone %0, i16 zeroext %1, i16 zeroext %2, i16 zeroext %3) {
%5 = tail call i32 (...) @OAL_OBTAIN_SEMAPHORE()
%6 = lshr i16 %2, 8
%7 = tail call i32 @outb(i16 zeroext %6, i32 0)
%8 = and i16 %2, 255
%9 = tail call i32 @outb(i16 zeroext %8, i32 0)
%10 = tail call i32 @outb(i16 zeroext 128, i32 0)
%11 = tail call i32 @outb(i16 zeroext 2, i32 0)
%12 = and i16 %3, 255
%13 = tail call i32 @outb(i16 zeroext %12, i32 0)
%14 = lshr i16 %3, 8
%15 = tail call i32 @outb(i16 zeroext %14, i32 0)
%16 = tail call i32 (...) @OAL_RELEASE_SEMAPHORE()
ret i32 0
}