#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_byteread(void *handle, unsigned short devid, unsigned short addr,
                        unsigned char *data) {
  unsigned short length = 1;
  unsigned char command = 0x40;
  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;
  *data = (*(volatile unsigned char *)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    %rcx,-0x18(%rbp)
movw   $0x1,-0x1a(%rbp)
movb   $0x40,-0x1b(%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    -0x1b(%rbp),%cl
xor    %eax,%eax
mov    %cl,(%rax)
movzwl -0x1a(%rbp),%eax
and    $0xff,%eax
mov    %al,%cl
xor    %eax,%eax
mov    %cl,(%rax)
xor    %eax,%eax
mov    (%rax),%cl
mov    -0x18(%rbp),%rax
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   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %edx,%ebx
xor    %eax,%eax
call   1040 <OAL_OBTAIN_SEMAPHORE@plt>
mov    %bh,0x0
mov    %bl,0x0
movb   $0x40,0x0
40
movb   $0x1,0x0
01
mov    0x0,%al
mov    %al,(%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 @fc8300_ppi_byteread(i8* %0, i16 zeroext %1, i16 zeroext %2, i8* %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 64, 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 volatile i8, i8* null
%27 = load i8*, i8** %8
store i8 %26, i8* %27
%28 = call i32 (...) @OAL_RELEASE_SEMAPHORE()
ret i32 0
}

LLVM IR (-O2):
define i32 @fc8300_ppi_byteread(i8* nocapture readnone %0, i16 zeroext %1, i16 zeroext %2, i8* nocapture writeonly %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 64, i8* null
store volatile i8 1, i8* null
%9 = load volatile i8, i8* null
store i8 %9, i8* %3
%10 = tail call i32 (...) @OAL_RELEASE_SEMAPHORE()
ret i32 0
}