#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_longwrite(void *hDevice, unsigned short addr,
                         unsigned int 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, 4);
  OAL_RELEASE_SEMAPHORE();
  return res;
}


x86 assembly (clang, -O0):
<fc8150_i2c_longwrite>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %si,%ax
mov    %rdi,-0x8(%rbp)
mov    %ax,-0xa(%rbp)
mov    %edx,-0x10(%rbp)
movb   $0x6,-0x15(%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,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x58,%esi
mov    $0x1,%r8d
lea    -0x15(%rbp),%rcx
mov    %r8d,%edx
call   1040 <i2c_bulkwrite@plt>
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rcx
mov    $0x58,%esi
mov    $0x2,%edx
mov    $0x4,%r8d
call   1040 <i2c_bulkwrite@plt>
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1030 <OAL_RELEASE_SEMAPHORE@plt>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fc8150_i2c_longwrite>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    %si,0xa(%rsp)
mov    %edx,0xc(%rsp)
movb   $0x6,0x9(%rsp)
xor    %eax,%eax
call   1050 <OAL_OBTAIN_SEMAPHORE@plt>
lea    0xa(%rsp),%rcx
mov    %rbx,%rdi
mov    $0x58,%esi
xor    %edx,%edx
mov    $0x2,%r8d
call   1040 <i2c_bulkwrite@plt>
mov    %eax,%r14d
lea    0x9(%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    $0x4,%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_longwrite(i8* %0, i16 zeroext %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i16
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
store i8* %0, i8** %4
store i16 %1, i16* %5
store i32 %2, i32* %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 i32* %6 to i8*
%19 = call i32 @i2c_bulkwrite(i8* %17, i32 88, i32 2, i8* %18, i32 4)
%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_longwrite(i8* %0, i16 zeroext %1, i32 %2) {
%4 = alloca i16
%5 = alloca i32
%6 = alloca i8
store i16 %1, i16* %4
store i32 %2, i32* %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 i32* %5 to i8*
%13 = call i32 @i2c_bulkwrite(i8* %0, i32 88, i32 2, i8* %12, i32 4)
%14 = or i32 %11, %13
%15 = call i32 (...) @OAL_RELEASE_SEMAPHORE()
ret i32 %14
}