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


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %cl,%al
mov    %dx,%cx
mov    %si,%dx
mov    %rdi,-0x8(%rbp)
mov    %dx,-0xa(%rbp)
mov    %cx,-0xc(%rbp)
mov    %al,-0xd(%rbp)
movw   $0x1,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
mov    $0x0,%al
call   1050 <OAL_OBTAIN_SEMAPHORE@plt>
movzwl -0xc(%rbp),%eax
and    $0xff00,%eax
sar    $0x8,%eax
xor    %esi,%esi
movzbl %al,%edi
call   1030 <outb@plt>
movzwl -0xc(%rbp),%eax
and    $0xff,%eax
xor    %esi,%esi
movzbl %al,%edi
call   1030 <outb@plt>
xor    %esi,%esi
movzbl -0x11(%rbp),%edi
call   1030 <outb@plt>
movzwl -0x10(%rbp),%eax
and    $0xff,%eax
xor    %esi,%esi
movzbl %al,%edi
call   1030 <outb@plt>
xor    %esi,%esi
movzbl -0xd(%rbp),%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>
xor    %edi,%edi
xor    %esi,%esi
call   1030 <outb@plt>
mov    $0x1,%edi
xor    %esi,%esi
call   1030 <outb@plt>
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_bytewrite(i8* %0, i16 zeroext %1, i16 zeroext %2, i8 zeroext %3) {
%5 = alloca i8*
%6 = alloca i16
%7 = alloca i16
%8 = alloca i8
%9 = alloca i16
%10 = alloca i8
store i8* %0, i8** %5
store i16 %1, i16* %6
store i16 %2, i16* %7
store i8 %3, i8* %8
store i16 1, i16* %9
store i8 0, 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
%17 = call i32 @outb(i8 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 i8
%22 = call i32 @outb(i8 zeroext %21, i32 0)
%23 = load i8, i8* %10
%24 = call i32 @outb(i8 zeroext %23, i32 0)
%25 = load i16, i16* %9
%26 = zext i16 %25 to i32
%27 = and i32 %26, 255
%28 = trunc i32 %27 to i8
%29 = call i32 @outb(i8 zeroext %28, i32 0)
%30 = load i8, i8* %8
%31 = call i32 @outb(i8 zeroext %30, i32 0)
%32 = call i32 (...) @OAL_RELEASE_SEMAPHORE()
ret i32 0
}

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