#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_wordwrite(void *hDevice, unsigned short addr,
                         unsigned short data) {
  int res;
  unsigned char command = 0x02 | 0x04 | 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, 2);
  OAL_RELEASE_SEMAPHORE();
  return res;
}


x86 assembly (clang, -O0):
<fc8150_i2c_wordwrite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dx,%ax
mov    %si,%cx
mov    %rdi,-0x8(%rbp)
mov    %cx,-0xa(%rbp)
mov    %ax,-0xc(%rbp)
movb   $0x6,-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
lea    -0xc(%rbp),%rcx
mov    $0x58,%esi
mov    $0x2,%r8d
mov    %r8d,%edx
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_wordwrite>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    %si,0xe(%rsp)
mov    %dx,0xc(%rsp)
movb   $0x6,0xb(%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    0xb(%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    0xc(%rsp),%rcx
mov    %rbx,%rdi
mov    $0x58,%esi
mov    $0x2,%edx
mov    $0x2,%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_wordwrite(i8* %0, i16 zeroext %1, i16 zeroext %2) {
%4 = alloca i8*
%5 = alloca i16
%6 = alloca i16
%7 = alloca i32
%8 = alloca i8
store i8* %0, i8** %4
store i16 %1, i16* %5
store i16 %2, i16* %6
store i8 6, 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 = bitcast i16* %6 to i8*
%19 = call i32 @i2c_bulkwrite(i8* %17, i32 88, i32 2, i8* %18, i32 2)
%20 = load i32, i32* %7
%21 = or i32 %20, %19
store i32 %21, i32* %7
%22 = call i32 (...) @OAL_RELEASE_SEMAPHORE()
%23 = load i32, i32* %7
ret i32 %23
}

LLVM IR (-O2):
define i32 @fc8150_i2c_wordwrite(i8* %0, i16 zeroext %1, i16 zeroext %2) {
%4 = alloca i16
%5 = alloca i16
%6 = alloca i8
store i16 %1, i16* %4
store i16 %2, i16* %5
store i8 6, 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 = bitcast i16* %5 to i8*
%13 = call i32 @i2c_bulkwrite(i8* %0, i32 88, i32 2, i8* %12, i32 2)
%14 = or i32 %11, %13
%15 = call i32 (...) @OAL_RELEASE_SEMAPHORE()
ret i32 %14
}