#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_longwrite(void *handle, unsigned short devid,
                         unsigned short addr, unsigned int data) {
  unsigned short length = 4;
  unsigned char command = 0x80 | 0x00;
  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;
  (*(volatile unsigned char *)0x00) = data & 0x000000ff;
  (*(volatile unsigned char *)0x00) = (data & 0x0000ff00) >> 8;
  (*(volatile unsigned char *)0x00) = (data & 0x00ff0000) >> 16;
  (*(volatile unsigned char *)0x00) = (data & 0xff000000) >> 24;
  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   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    -0x13(%rbp),%cl
xor    %eax,%eax
mov    %cl,(%rax)
movzwl -0x12(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
xor    %eax,%eax
mov    %cl,(%rax)
mov    -0x10(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
xor    %eax,%eax
mov    %cl,(%rax)
mov    -0x10(%rbp),%eax
and    $0xff00,%eax
shr    $0x8,%eax
mov    %al,%cl
xor    %eax,%eax
mov    %cl,(%rax)
mov    -0x10(%rbp),%eax
and    $0xff0000,%eax
shr    $0x10,%eax
mov    %al,%cl
xor    %eax,%eax
mov    %cl,(%rax)
mov    -0x10(%rbp),%eax
and    $0xff000000,%eax
shr    $0x18,%eax
mov    %al,%cl
xor    %eax,%eax
mov    %cl,(%rax)
mov    $0x0,%al
call   1030 <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   1040 <OAL_OBTAIN_SEMAPHORE@plt>
mov    %ebp,%eax
mov    %ah,0x0
mov    %al,0x0
movb   $0x80,0x0
80
movb   $0x4,0x0
04
mov    %bl,0x0
mov    %bh,0x0
mov    %ebx,%eax
shr    $0x10,%eax
mov    %al,0x0
shr    $0x18,%ebx
mov    %bl,0x0
xor    %eax,%eax
call   1030 <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 = 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 i32, i32* %8
%27 = and i32 %26, 255
%28 = trunc i32 %27 to i8
store volatile i8 %28, i8* null
%29 = load i32, i32* %8
%30 = and i32 %29, 65280
%31 = lshr i32 %30, 8
%32 = trunc i32 %31 to i8
store volatile i8 %32, i8* null
%33 = load i32, i32* %8
%34 = and i32 %33, 16711680
%35 = lshr i32 %34, 16
%36 = trunc i32 %35 to i8
store volatile i8 %36, i8* null
%37 = load i32, i32* %8
%38 = and i32 %37, -16777216
%39 = lshr i32 %38, 24
%40 = trunc i32 %39 to i8
store volatile i8 %40, i8* null
%41 = 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 = 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 -128, i8* null
store volatile i8 4, i8* null
%9 = trunc i32 %3 to i8
store volatile i8 %9, i8* null
%10 = lshr i32 %3, 8
%11 = trunc i32 %10 to i8
store volatile i8 %11, i8* null
%12 = lshr i32 %3, 16
%13 = trunc i32 %12 to i8
store volatile i8 %13, i8* null
%14 = lshr i32 %3, 24
%15 = trunc i32 %14 to i8
store volatile i8 %15, i8* null
%16 = tail call i32 (...) @OAL_RELEASE_SEMAPHORE()
ret i32 0
}