#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_bulkwrite(void *, unsigned char, unsigned char, unsigned char *,
                  unsigned short);
int fc8150_bypass_write(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_bulkwrite(hDevice, chip, addr, data, length);
  OAL_RELEASE_SEMAPHORE();
  return res;
}


x86 assembly (clang, -O0):
<fc8150_bypass_write>:
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   1050 <OAL_OBTAIN_SEMAPHORE@plt>
mov    -0x8(%rbp),%rdi
mov    -0x21(%rbp),%dl
movzbl -0x23(%rbp),%eax
mov    $0x58,%esi
lea    -0x22(%rbp),%rcx
movzbl %dl,%edx
movzwl %ax,%r8d
call   1040 <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   1040 <i2c_bulkwrite@plt>
or     -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    $0x0,%al
call   1030 <OAL_RELEASE_SEMAPHORE@plt>
mov    -0x20(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fc8150_bypass_write>:
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   1050 <OAL_OBTAIN_SEMAPHORE@plt>
lea    0x7(%rsp),%rcx
mov    %rbp,%rdi
mov    $0x58,%esi
mov    $0x3,%edx
mov    $0x1,%r8d
call   1040 <i2c_bulkwrite@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
mov    %r13d,%esi
mov    %r12d,%edx
mov    %r15,%rcx
mov    %r14d,%r8d
call   1040 <i2c_bulkwrite@plt>
mov    %eax,%ebp
or     %ebx,%ebp
xor    %eax,%eax
call   1030 <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_write(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 = zext i8 %18 to i16
%20 = call i32 @i2c_bulkwrite(i8* %16, i8 zeroext 88, i8 zeroext %17, i8* %13, i16 zeroext %19)
store i32 %20, i32* %11
%21 = load i8*, i8** %6
%22 = load i8, i8* %7
%23 = load i8, i8* %8
%24 = load i8*, i8** %9
%25 = load i16, i16* %10
%26 = call i32 @i2c_bulkwrite(i8* %21, i8 zeroext %22, i8 zeroext %23, i8* %24, i16 zeroext %25)
%27 = load i32, i32* %11
%28 = or i32 %27, %26
store i32 %28, i32* %11
%29 = call i32 (...) @OAL_RELEASE_SEMAPHORE()
%30 = load i32, i32* %11
ret i32 %30
}

LLVM IR (-O2):
define i32 @fc8150_bypass_write(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, i8 zeroext 88, i8 zeroext 3, i8* %6, i16 zeroext 1)
%9 = call i32 @i2c_bulkwrite(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
}