#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();
signed int fc8180_ppi_wordwrite(void *handle, unsigned short addr,
                                unsigned short data) {
  unsigned int length = 2;
  unsigned char cmd = 0x80 | 0x00 | ((length & 0x0f0000) >> 16);
  OAL_OBTAIN_SEMAPHORE();
  (*(volatile unsigned char *)(0x00)) = addr;
  (*(volatile unsigned char *)(0x00)) = addr >> 4;
  (*(volatile unsigned char *)(0x00)) = addr >> 8;
  (*(volatile unsigned char *)(0x00)) = addr >> 12;
  (*(volatile unsigned char *)(0x00)) = cmd >> 4;
  (*(volatile unsigned char *)(0x00)) = cmd;
  (*(volatile unsigned char *)(0x00)) = length >> 12;
  (*(volatile unsigned char *)(0x00)) = length >> 8;
  (*(volatile unsigned char *)(0x00)) = length >> 4;
  (*(volatile unsigned char *)(0x00)) = length;
  (*(volatile unsigned char *)(0x00)) = (data >> 4) & 0x0f;
  (*(volatile unsigned char *)(0x00)) = data & 0x0f;
  (*(volatile unsigned char *)(0x00)) = (data >> 12) & 0x0f;
  (*(volatile unsigned char *)(0x00)) = (data >> 8) & 0x0f;
  OAL_RELEASE_SEMAPHORE();
  return 0;
}


x86 assembly (clang, -O0):
<fc8180_ppi_wordwrite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dx,%ax
mov    %si,%cx
mov    %rdi,-0x8(%rbp)
mov    %cx,-0xa(%rbp)
mov    %ax,-0xc(%rbp)
movl   $0x2,-0x10(%rbp)
mov    -0x10(%rbp),%eax
and    $0xf0000,%eax
shr    $0x10,%eax
or     $0x80,%eax
mov    %al,-0x11(%rbp)
mov    $0x0,%al
call   1040 <OAL_OBTAIN_SEMAPHORE@plt>
mov    -0xa(%rbp),%ax
mov    %al,%cl
xor    %eax,%eax
mov    %cl,(%rax)
movzwl -0xa(%rbp),%eax
sar    $0x4,%eax
mov    %al,%cl
xor    %eax,%eax
mov    %cl,(%rax)
movzwl -0xa(%rbp),%eax
sar    $0x8,%eax
mov    %al,%cl
xor    %eax,%eax
mov    %cl,(%rax)
movzwl -0xa(%rbp),%eax
sar    $0xc,%eax
mov    %al,%cl
xor    %eax,%eax
mov    %cl,(%rax)
movzbl -0x11(%rbp),%eax
sar    $0x4,%eax
mov    %al,%cl
xor    %eax,%eax
mov    %cl,(%rax)
mov    -0x11(%rbp),%cl
xor    %eax,%eax
mov    %cl,(%rax)
mov    -0x10(%rbp),%eax
shr    $0xc,%eax
mov    %al,%cl
xor    %eax,%eax
mov    %cl,(%rax)
mov    -0x10(%rbp),%eax
shr    $0x8,%eax
mov    %al,%cl
xor    %eax,%eax
mov    %cl,(%rax)
mov    -0x10(%rbp),%eax
shr    $0x4,%eax
mov    %al,%cl
xor    %eax,%eax
mov    %cl,(%rax)
mov    -0x10(%rbp),%eax
mov    %al,%cl
xor    %eax,%eax
mov    %cl,(%rax)
movzwl -0xc(%rbp),%eax
sar    $0x4,%eax
and    $0xf,%eax
mov    %al,%cl
xor    %eax,%eax
mov    %cl,(%rax)
movzwl -0xc(%rbp),%eax
and    $0xf,%eax
mov    %al,%cl
xor    %eax,%eax
mov    %cl,(%rax)
movzwl -0xc(%rbp),%eax
sar    $0xc,%eax
and    $0xf,%eax
mov    %al,%cl
xor    %eax,%eax
mov    %cl,(%rax)
movzwl -0xc(%rbp),%eax
sar    $0x8,%eax
and    $0xf,%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):
<fc8180_ppi_wordwrite>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %esi,%ebx
xor    %eax,%eax
call   1040 <OAL_OBTAIN_SEMAPHORE@plt>
mov    %bl,0x0
mov    %ebx,%eax
shr    $0x4,%eax
mov    %al,0x0
mov    %bh,0x0
shr    $0xc,%ebx
mov    %bl,0x0
movb   $0x8,0x0
08
movb   $0x80,0x0
80
movb   $0x0,0x0
movb   $0x0,0x0
movb   $0x0,0x0
movb   $0x2,0x0
02
mov    %ebp,%eax
shr    $0x4,%al
mov    %al,0x0
mov    %ebp,%eax
and    $0xf,%al
mov    %al,0x0
mov    %ebp,%eax
shr    $0xc,%eax
mov    %al,0x0
shr    $0x8,%ebp
and    $0xf,%bpl
mov    %bpl,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 @fc8180_ppi_wordwrite(i8* %0, i16 zeroext %1, i16 zeroext %2) {
%4 = alloca i8*
%5 = alloca i16
%6 = alloca i16
%7 = alloca i32
%8 = alloca i8
store i8* %0, i8** %4
store i16 %1, i16* %5
store i16 %2, i16* %6
store i32 2, i32* %7
%9 = load i32, i32* %7
%10 = and i32 %9, 983040
%11 = lshr i32 %10, 16
%12 = or i32 128, %11
%13 = trunc i32 %12 to i8
store i8 %13, i8* %8
%14 = call i32 (...) @OAL_OBTAIN_SEMAPHORE()
%15 = load i16, i16* %5
%16 = trunc i16 %15 to i8
store volatile i8 %16, i8* null
%17 = load i16, i16* %5
%18 = zext i16 %17 to i32
%19 = ashr i32 %18, 4
%20 = trunc i32 %19 to i8
store volatile i8 %20, i8* null
%21 = load i16, i16* %5
%22 = zext i16 %21 to i32
%23 = ashr i32 %22, 8
%24 = trunc i32 %23 to i8
store volatile i8 %24, i8* null
%25 = load i16, i16* %5
%26 = zext i16 %25 to i32
%27 = ashr i32 %26, 12
%28 = trunc i32 %27 to i8
store volatile i8 %28, i8* null
%29 = load i8, i8* %8
%30 = zext i8 %29 to i32
%31 = ashr i32 %30, 4
%32 = trunc i32 %31 to i8
store volatile i8 %32, i8* null
%33 = load i8, i8* %8
store volatile i8 %33, i8* null
%34 = load i32, i32* %7
%35 = lshr i32 %34, 12
%36 = trunc i32 %35 to i8
store volatile i8 %36, i8* null
%37 = load i32, i32* %7
%38 = lshr i32 %37, 8
%39 = trunc i32 %38 to i8
store volatile i8 %39, i8* null
%40 = load i32, i32* %7
%41 = lshr i32 %40, 4
%42 = trunc i32 %41 to i8
store volatile i8 %42, i8* null
%43 = load i32, i32* %7
%44 = trunc i32 %43 to i8
store volatile i8 %44, i8* null
%45 = load i16, i16* %6
%46 = zext i16 %45 to i32
%47 = ashr i32 %46, 4
%48 = and i32 %47, 15
%49 = trunc i32 %48 to i8
store volatile i8 %49, i8* null
%50 = load i16, i16* %6
%51 = zext i16 %50 to i32
%52 = and i32 %51, 15
%53 = trunc i32 %52 to i8
store volatile i8 %53, i8* null
%54 = load i16, i16* %6
%55 = zext i16 %54 to i32
%56 = ashr i32 %55, 12
%57 = and i32 %56, 15
%58 = trunc i32 %57 to i8
store volatile i8 %58, i8* null
%59 = load i16, i16* %6
%60 = zext i16 %59 to i32
%61 = ashr i32 %60, 8
%62 = and i32 %61, 15
%63 = trunc i32 %62 to i8
store volatile i8 %63, i8* null
%64 = call i32 (...) @OAL_RELEASE_SEMAPHORE()
ret i32 0
}

LLVM IR (-O2):
define i32 @fc8180_ppi_wordwrite(i8* nocapture readnone %0, i16 zeroext %1, i16 zeroext %2) {
%4 = tail call i32 (...) @OAL_OBTAIN_SEMAPHORE()
%5 = trunc i16 %1 to i8
store volatile i8 %5, i8* null
%6 = lshr i16 %1, 4
%7 = trunc i16 %6 to i8
store volatile i8 %7, i8* null
%8 = lshr i16 %1, 8
%9 = trunc i16 %8 to i8
store volatile i8 %9, i8* null
%10 = lshr i16 %1, 12
%11 = trunc i16 %10 to i8
store volatile i8 %11, i8* null
store volatile i8 8, i8* null
store volatile i8 -128, i8* null
store volatile i8 0, i8* null
store volatile i8 0, i8* null
store volatile i8 0, i8* null
store volatile i8 2, i8* null
%12 = trunc i16 %2 to i8
%13 = lshr i8 %12, 4
store volatile i8 %13, i8* null
%14 = and i8 %12, 15
store volatile i8 %14, i8* null
%15 = lshr i16 %2, 12
%16 = trunc i16 %15 to i8
store volatile i8 %16, i8* null
%17 = lshr i16 %2, 8
%18 = trunc i16 %17 to i8
%19 = and i8 %18, 15
store volatile i8 %19, i8* null
%20 = tail call i32 (...) @OAL_RELEASE_SEMAPHORE()
ret i32 0
}