#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 *, int, int, unsigned char *, int);
int fc8150_i2c_bytewrite(void *hDevice, unsigned short addr,
                         unsigned char data) {
  int res;
  unsigned char command = 0x02 | 0x00 | 0x00;
  OAL_OBTAIN_SEMAPHORE();
  res = i2c_bulkwrite(hDevice, 0x58, 0x00, (unsigned char *)&addr, 2);
  res |= i2c_bulkwrite(hDevice, 0x58, 0x01, &command, 1);
  res |= i2c_bulkwrite(hDevice, 0x58, 0x02, (unsigned char *)&data, 1);
  OAL_RELEASE_SEMAPHORE();
  return res;
}


x86 assembly (clang, -O0):
<fc8150_i2c_bytewrite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %si,%cx
mov    %rdi,-0x8(%rbp)
mov    %cx,-0xa(%rbp)
mov    %al,-0xb(%rbp)
movb   $0x2,-0x11(%rbp)
mov    $0x0,%al
call   1050 <OAL_OBTAIN_SEMAPHORE@plt>
mov    -0x8(%rbp),%rdi
lea    -0xa(%rbp),%rcx
mov    $0x58,%esi
xor    %edx,%edx
mov    $0x2,%r8d
call   1040 <i2c_bulkwrite@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x58,%esi
mov    $0x1,%r8d
lea    -0x11(%rbp),%rcx
mov    %r8d,%edx
call   1040 <i2c_bulkwrite@plt>
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x58,%esi
mov    $0x2,%edx
lea    -0xb(%rbp),%rcx
mov    $0x1,%r8d
call   1040 <i2c_bulkwrite@plt>
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <OAL_RELEASE_SEMAPHORE@plt>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fc8150_i2c_bytewrite>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    %si,0xe(%rsp)
mov    %dl,0xd(%rsp)
movb   $0x2,0xc(%rsp)
xor    %eax,%eax
call   1050 <OAL_OBTAIN_SEMAPHORE@plt>
lea    0xe(%rsp),%rcx
mov    %rbx,%rdi
mov    $0x58,%esi
xor    %edx,%edx
mov    $0x2,%r8d
call   1040 <i2c_bulkwrite@plt>
mov    %eax,%r14d
lea    0xc(%rsp),%rcx
mov    %rbx,%rdi
mov    $0x58,%esi
mov    $0x1,%edx
mov    $0x1,%r8d
call   1040 <i2c_bulkwrite@plt>
mov    %eax,%ebp
or     %r14d,%ebp
lea    0xd(%rsp),%rcx
mov    %rbx,%rdi
mov    $0x58,%esi
mov    $0x2,%edx
mov    $0x1,%r8d
call   1040 <i2c_bulkwrite@plt>
mov    %eax,%ebx
or     %ebp,%ebx
xor    %eax,%eax
call   1030 <OAL_RELEASE_SEMAPHORE@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @fc8150_i2c_bytewrite(i8* %0, i16 zeroext %1, i8 zeroext %2) {
%4 = alloca i8*
%5 = alloca i16
%6 = alloca i8
%7 = alloca i32
%8 = alloca i8
store i8* %0, i8** %4
store i16 %1, i16* %5
store i8 %2, i8* %6
store i8 2, i8* %8
%9 = call i32 (...) @OAL_OBTAIN_SEMAPHORE()
%10 = load i8*, i8** %4
%11 = bitcast i16* %5 to i8*
%12 = call i32 @i2c_bulkwrite(i8* %10, i32 88, i32 0, i8* %11, i32 2)
store i32 %12, i32* %7
%13 = load i8*, i8** %4
%14 = call i32 @i2c_bulkwrite(i8* %13, i32 88, i32 1, i8* %8, i32 1)
%15 = load i32, i32* %7
%16 = or i32 %15, %14
store i32 %16, i32* %7
%17 = load i8*, i8** %4
%18 = call i32 @i2c_bulkwrite(i8* %17, i32 88, i32 2, i8* %6, i32 1)
%19 = load i32, i32* %7
%20 = or i32 %19, %18
store i32 %20, i32* %7
%21 = call i32 (...) @OAL_RELEASE_SEMAPHORE()
%22 = load i32, i32* %7
ret i32 %22
}

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