#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 i2c_bulkread(void *, unsigned char, unsigned char, unsigned char *,
                 unsigned short);
int i2c_bulkwrite(void *, int, unsigned char, unsigned char *, unsigned char);
int fc8150_bypass_read(void *hDevice, unsigned char chip, unsigned char addr,
                       unsigned char *data, unsigned short length) {
  int res;
  unsigned char bypass_addr = 0x03;
  unsigned char bypass_data = 1;
  unsigned char bypass_len = 1;
  OAL_OBTAIN_SEMAPHORE();
  res = i2c_bulkwrite(hDevice, 0x58, bypass_addr, &bypass_data, bypass_len);
  res |= i2c_bulkread(hDevice, chip, addr, data, length);
  OAL_RELEASE_SEMAPHORE();
  return res;
}


x86 assembly (clang, -O0):
<fc8150_bypass_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %r8w,%ax
mov    %rdi,-0x8(%rbp)
mov    %sil,-0x9(%rbp)
mov    %dl,-0xa(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %ax,-0x1a(%rbp)
movb   $0x3,-0x21(%rbp)
movb   $0x1,-0x22(%rbp)
movb   $0x1,-0x23(%rbp)
mov    $0x0,%al
call   1060 <OAL_OBTAIN_SEMAPHORE@plt>
mov    -0x8(%rbp),%rdi
mov    -0x21(%rbp),%al
mov    $0x58,%esi
lea    -0x22(%rbp),%rcx
movzbl %al,%edx
movzbl -0x23(%rbp),%r8d
call   1050 <i2c_bulkwrite@plt>
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x9(%rbp),%dl
mov    -0xa(%rbp),%al
mov    -0x18(%rbp),%rcx
movzbl %dl,%esi
movzbl %al,%edx
movzwl -0x1a(%rbp),%r8d
call   1030 <i2c_bulkread@plt>
or     -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1040 <OAL_RELEASE_SEMAPHORE@plt>
mov    -0x20(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fc8150_bypass_read>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r14d
mov    %rcx,%r15
mov    %edx,%r12d
mov    %esi,%r13d
mov    %rdi,%rbp
movb   $0x1,0x7(%rsp)
xor    %eax,%eax
call   1060 <OAL_OBTAIN_SEMAPHORE@plt>
lea    0x7(%rsp),%rcx
mov    %rbp,%rdi
mov    $0x58,%esi
mov    $0x3,%edx
mov    $0x1,%r8d
call   1050 <i2c_bulkwrite@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
mov    %r13d,%esi
mov    %r12d,%edx
mov    %r15,%rcx
mov    %r14d,%r8d
call   1030 <i2c_bulkread@plt>
mov    %eax,%ebp
or     %ebx,%ebp
xor    %eax,%eax
call   1040 <OAL_RELEASE_SEMAPHORE@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @fc8150_bypass_read(i8* %0, i8 zeroext %1, i8 zeroext %2, i8* %3, i16 zeroext %4) {
%6 = alloca i8*
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8*
%10 = alloca i16
%11 = alloca i32
%12 = alloca i8
%13 = alloca i8
%14 = alloca i8
store i8* %0, i8** %6
store i8 %1, i8* %7
store i8 %2, i8* %8
store i8* %3, i8** %9
store i16 %4, i16* %10
store i8 3, i8* %12
store i8 1, i8* %13
store i8 1, i8* %14
%15 = call i32 (...) @OAL_OBTAIN_SEMAPHORE()
%16 = load i8*, i8** %6
%17 = load i8, i8* %12
%18 = load i8, i8* %14
%19 = call i32 @i2c_bulkwrite(i8* %16, i32 88, i8 zeroext %17, i8* %13, i8 zeroext %18)
store i32 %19, i32* %11
%20 = load i8*, i8** %6
%21 = load i8, i8* %7
%22 = load i8, i8* %8
%23 = load i8*, i8** %9
%24 = load i16, i16* %10
%25 = call i32 @i2c_bulkread(i8* %20, i8 zeroext %21, i8 zeroext %22, i8* %23, i16 zeroext %24)
%26 = load i32, i32* %11
%27 = or i32 %26, %25
store i32 %27, i32* %11
%28 = call i32 (...) @OAL_RELEASE_SEMAPHORE()
%29 = load i32, i32* %11
ret i32 %29
}

LLVM IR (-O2):
define i32 @fc8150_bypass_read(i8* %0, i8 zeroext %1, i8 zeroext %2, i8* %3, i16 zeroext %4) {
%6 = alloca i8
store i8 1, i8* %6
%7 = tail call i32 (...) @OAL_OBTAIN_SEMAPHORE()
%8 = call i32 @i2c_bulkwrite(i8* %0, i32 88, i8 zeroext 3, i8* %6, i8 zeroext 1)
%9 = call i32 @i2c_bulkread(i8* %0, i8 zeroext %1, i8 zeroext %2, i8* %3, i16 zeroext %4)
%10 = or i32 %9, %8
%11 = call i32 (...) @OAL_RELEASE_SEMAPHORE()
ret i32 %10
}