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


x86 assembly (clang, -O0):
<fc8180_ppi_wordread>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %si,%ax
mov    %rdi,-0x8(%rbp)
mov    %ax,-0xa(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x2,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
and    $0xf0000,%eax
shr    $0x10,%eax
or     $0xc0,%eax
mov    %al,-0x1d(%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 -0x1d(%rbp),%eax
sar    $0x4,%eax
mov    %al,%cl
xor    %eax,%eax
mov    %cl,(%rax)
mov    -0x1d(%rbp),%cl
xor    %eax,%eax
mov    %cl,(%rax)
mov    -0x1c(%rbp),%eax
shr    $0xc,%eax
mov    %al,%cl
xor    %eax,%eax
mov    %cl,(%rax)
mov    -0x1c(%rbp),%eax
shr    $0x8,%eax
mov    %al,%cl
xor    %eax,%eax
mov    %cl,(%rax)
mov    -0x1c(%rbp),%eax
shr    $0x4,%eax
mov    %al,%cl
xor    %eax,%eax
mov    %cl,(%rax)
mov    -0x1c(%rbp),%eax
mov    %al,%cl
xor    %eax,%eax
mov    %cl,(%rax)
xor    %eax,%eax
mov    (%rax),%al
movzbl %al,%eax
and    $0xf,%eax
shl    $0x4,%eax
mov    %ax,%cx
mov    -0x18(%rbp),%rax
mov    %cx,(%rax)
xor    %eax,%eax
mov    (%rax),%al
movzbl %al,%edx
and    $0xf,%edx
mov    -0x18(%rbp),%rax
movzwl (%rax),%ecx
or     %edx,%ecx
mov    %cx,(%rax)
xor    %eax,%eax
mov    (%rax),%al
movzbl %al,%edx
and    $0xf,%edx
shl    $0xc,%edx
mov    -0x18(%rbp),%rax
movzwl (%rax),%ecx
or     %edx,%ecx
mov    %cx,(%rax)
xor    %eax,%eax
mov    (%rax),%al
movzbl %al,%edx
and    $0xf,%edx
shl    $0x8,%edx
mov    -0x18(%rbp),%rax
movzwl (%rax),%ecx
or     %edx,%ecx
mov    %cx,(%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_wordread>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
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   $0xc,0x0
0c
movb   $0xc0,0x0
c0
movb   $0x0,0x0
movb   $0x0,0x0
movb   $0x0,0x0
movb   $0x2,0x0
02
mov    0x0,%al
shl    $0x4,%al
movzbl 0x0,%ecx
and    $0xf,%ecx
movzbl %al,%eax
or     %ecx,%eax
movzbl 0x0,%ecx
shl    $0xc,%ecx
or     %eax,%ecx
movzbl 0x0,%eax
and    $0xf,%eax
shl    $0x8,%eax
or     %ecx,%eax
mov    %ax,(%r14)
xor    %eax,%eax
call   1030 <OAL_RELEASE_SEMAPHORE@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @fc8180_ppi_wordread(i8* %0, i16 zeroext %1, i16* %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 192, %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 volatile i8, i8* null
%46 = zext i8 %45 to i32
%47 = and i32 %46, 15
%48 = shl i32 %47, 4
%49 = trunc i32 %48 to i16
%50 = load i16*, i16** %6
store i16 %49, i16* %50
%51 = load volatile i8, i8* null
%52 = zext i8 %51 to i32
%53 = and i32 %52, 15
%54 = load i16*, i16** %6
%55 = load i16, i16* %54
%56 = zext i16 %55 to i32
%57 = or i32 %56, %53
%58 = trunc i32 %57 to i16
store i16 %58, i16* %54
%59 = load volatile i8, i8* null
%60 = zext i8 %59 to i32
%61 = and i32 %60, 15
%62 = shl i32 %61, 12
%63 = load i16*, i16** %6
%64 = load i16, i16* %63
%65 = zext i16 %64 to i32
%66 = or i32 %65, %62
%67 = trunc i32 %66 to i16
store i16 %67, i16* %63
%68 = load volatile i8, i8* null
%69 = zext i8 %68 to i32
%70 = and i32 %69, 15
%71 = shl i32 %70, 8
%72 = load i16*, i16** %6
%73 = load i16, i16* %72
%74 = zext i16 %73 to i32
%75 = or i32 %74, %71
%76 = trunc i32 %75 to i16
store i16 %76, i16* %72
%77 = call i32 (...) @OAL_RELEASE_SEMAPHORE()
ret i32 0
}

LLVM IR (-O2):
define i32 @fc8180_ppi_wordread(i8* nocapture readnone %0, i16 zeroext %1, i16* nocapture writeonly %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 12, i8* null
store volatile i8 -64, 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 = load volatile i8, i8* null
%13 = shl i8 %12, 4
%14 = load volatile i8, i8* null
%15 = and i8 %14, 15
%16 = or i8 %15, %13
%17 = zext i8 %16 to i16
%18 = load volatile i8, i8* null
%19 = zext i8 %18 to i16
%20 = shl i16 %19, 12
%21 = or i16 %20, %17
%22 = load volatile i8, i8* null
%23 = and i8 %22, 15
%24 = zext i8 %23 to i16
%25 = shl nuw nsw i16 %24, 8
%26 = or i16 %25, %21
store i16 %26, i16* %2
%27 = tail call i32 (...) @OAL_RELEASE_SEMAPHORE()
ret i32 0
}