#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 int, int);
int fc8300_ppi_longwrite(void *handle, unsigned short devid,
                         unsigned short addr, unsigned int data) {
  unsigned short length = 4;
  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 & 0x000000ff, 0x00);
  outb((data & 0x0000ff00) >> 8, 0x00);
  outb((data & 0x00ff0000) >> 16, 0x00);
  outb((data & 0xff000000) >> 24, 0x00);
  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    %ecx,-0x10(%rbp)
movw   $0x4,-0x12(%rbp)
movb   $0x80,-0x13(%rbp)
mov    $0x0,%al
call   1050 <OAL_OBTAIN_SEMAPHORE@plt>
movzwl -0xc(%rbp),%edi
and    $0xff00,%edi
sar    $0x8,%edi
xor    %esi,%esi
call   1030 <outb@plt>
movzwl -0xc(%rbp),%edi
and    $0xff,%edi
xor    %esi,%esi
call   1030 <outb@plt>
movzbl -0x13(%rbp),%edi
xor    %esi,%esi
call   1030 <outb@plt>
movzwl -0x12(%rbp),%edi
and    $0xff,%edi
xor    %esi,%esi
call   1030 <outb@plt>
mov    -0x10(%rbp),%edi
and    $0xff,%edi
xor    %esi,%esi
call   1030 <outb@plt>
mov    -0x10(%rbp),%edi
and    $0xff00,%edi
shr    $0x8,%edi
xor    %esi,%esi
call   1030 <outb@plt>
mov    -0x10(%rbp),%edi
and    $0xff0000,%edi
shr    $0x10,%edi
xor    %esi,%esi
call   1030 <outb@plt>
mov    -0x10(%rbp),%edi
and    $0xff000000,%edi
shr    $0x18,%edi
xor    %esi,%esi
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    $0x4,%edi
xor    %esi,%esi
call   1030 <outb@plt>
movzbl %bl,%edi
xor    %esi,%esi
call   1030 <outb@plt>
movzbl %bh,%edi
xor    %esi,%esi
call   1030 <outb@plt>
mov    %ebx,%eax
shr    $0x10,%eax
movzbl %al,%edi
xor    %esi,%esi
call   1030 <outb@plt>
shr    $0x18,%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_longwrite(i8* %0, i16 zeroext %1, i16 zeroext %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i16
%7 = alloca i16
%8 = alloca i32
%9 = alloca i16
%10 = alloca i8
store i8* %0, i8** %5
store i16 %1, i16* %6
store i16 %2, i16* %7
store i32 %3, i32* %8
store i16 4, 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 = call i32 @outb(i32 %15, i32 0)
%17 = load i16, i16* %7
%18 = zext i16 %17 to i32
%19 = and i32 %18, 255
%20 = call i32 @outb(i32 %19, i32 0)
%21 = load i8, i8* %10
%22 = zext i8 %21 to i32
%23 = call i32 @outb(i32 %22, i32 0)
%24 = load i16, i16* %9
%25 = zext i16 %24 to i32
%26 = and i32 %25, 255
%27 = call i32 @outb(i32 %26, i32 0)
%28 = load i32, i32* %8
%29 = and i32 %28, 255
%30 = call i32 @outb(i32 %29, i32 0)
%31 = load i32, i32* %8
%32 = and i32 %31, 65280
%33 = lshr i32 %32, 8
%34 = call i32 @outb(i32 %33, i32 0)
%35 = load i32, i32* %8
%36 = and i32 %35, 16711680
%37 = lshr i32 %36, 16
%38 = call i32 @outb(i32 %37, i32 0)
%39 = load i32, i32* %8
%40 = and i32 %39, -16777216
%41 = lshr i32 %40, 24
%42 = call i32 @outb(i32 %41, i32 0)
%43 = call i32 (...) @OAL_RELEASE_SEMAPHORE()
ret i32 0
}

LLVM IR (-O2):
define i32 @fc8300_ppi_longwrite(i8* nocapture readnone %0, i16 zeroext %1, i16 zeroext %2, i32 %3) {
%5 = tail call i32 (...) @OAL_OBTAIN_SEMAPHORE()
%6 = zext i16 %2 to i32
%7 = lshr i32 %6, 8
%8 = tail call i32 @outb(i32 %7, i32 0)
%9 = and i32 %6, 255
%10 = tail call i32 @outb(i32 %9, i32 0)
%11 = tail call i32 @outb(i32 128, i32 0)
%12 = tail call i32 @outb(i32 4, i32 0)
%13 = and i32 %3, 255
%14 = tail call i32 @outb(i32 %13, i32 0)
%15 = lshr i32 %3, 8
%16 = and i32 %15, 255
%17 = tail call i32 @outb(i32 %16, i32 0)
%18 = lshr i32 %3, 16
%19 = and i32 %18, 255
%20 = tail call i32 @outb(i32 %19, i32 0)
%21 = lshr i32 %3, 24
%22 = tail call i32 @outb(i32 %21, i32 0)
%23 = tail call i32 (...) @OAL_RELEASE_SEMAPHORE()
ret i32 0
}