#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_longread(void *handle, unsigned short devid, unsigned short addr,
                        unsigned int *data) {
  unsigned short length = 4;
  unsigned char command = 0x80 | 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);
  *data |= (*(volatile unsigned char *)0x00) << 8;
  *data |= (*(volatile unsigned char *)0x00) << 16;
  *data |= (*(volatile unsigned char *)0x00) << 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    %rcx,-0x18(%rbp)
movw   $0x4,-0x1a(%rbp)
movb   $0xc0,-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),%al
movzbl %al,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
xor    %eax,%eax
mov    (%rax),%al
movzbl %al,%ecx
shl    $0x8,%ecx
mov    -0x18(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
xor    %eax,%eax
mov    (%rax),%al
movzbl %al,%ecx
shl    $0x10,%ecx
mov    -0x18(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%rax)
xor    %eax,%eax
mov    (%rax),%al
movzbl %al,%ecx
shl    $0x18,%ecx
mov    -0x18(%rbp),%rax
or     (%rax),%ecx
mov    %ecx,(%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   $0xc0,0x0
c0
movb   $0x4,0x0
04
movzbl 0x0,%eax
movzbl 0x0,%ecx
shl    $0x8,%ecx
or     %eax,%ecx
movzbl 0x0,%eax
shl    $0x10,%eax
or     %ecx,%eax
movzbl 0x0,%ecx
shl    $0x18,%ecx
or     %eax,%ecx
mov    %ecx,(%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_longread(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 -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 = zext i8 %26 to i32
%28 = load i32*, i32** %8
store i32 %27, i32* %28
%29 = load volatile i8, i8* null
%30 = zext i8 %29 to i32
%31 = shl i32 %30, 8
%32 = load i32*, i32** %8
%33 = load i32, i32* %32
%34 = or i32 %33, %31
store i32 %34, i32* %32
%35 = load volatile i8, i8* null
%36 = zext i8 %35 to i32
%37 = shl i32 %36, 16
%38 = load i32*, i32** %8
%39 = load i32, i32* %38
%40 = or i32 %39, %37
store i32 %40, i32* %38
%41 = load volatile i8, i8* null
%42 = zext i8 %41 to i32
%43 = shl i32 %42, 24
%44 = load i32*, i32** %8
%45 = load i32, i32* %44
%46 = or i32 %45, %43
store i32 %46, i32* %44
%47 = call i32 (...) @OAL_RELEASE_SEMAPHORE()
ret i32 0
}

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