#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 fci_i2c_transfer(void *, int /*<<< orphan*/, unsigned char, unsigned char *,
                     unsigned char, unsigned char *, unsigned char);
int /*<<< orphan*/ print_log(void *, char *, int, unsigned char, unsigned char);
signed int fci_i2c_write(void *handle, unsigned char chip, unsigned char addr,
                         unsigned char alen, unsigned char *data,
                         unsigned char len) {
  signed int ret;
  unsigned char *paddr = &addr;
  ret = fci_i2c_transfer(handle, 0, chip << 1, paddr, alen, data, len);
  if (ret != 0)
    print_log(handle, "fci_i2c_write() result=%d, addr= %x, data=%x\n", ret,
              addr, *data);
  return ret;
}


x86 assembly (clang, -O0):
<fci_i2c_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %r9b,%al
mov    %rdi,-0x8(%rbp)
mov    %sil,-0x9(%rbp)
mov    %dl,-0xa(%rbp)
mov    %cl,-0xb(%rbp)
mov    %r8,-0x18(%rbp)
mov    %al,-0x19(%rbp)
lea    -0xa(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
movzbl -0x9(%rbp),%eax
shl    $0x1,%eax
mov    %al,%dl
mov    -0x28(%rbp),%rcx
mov    -0xb(%rbp),%al
mov    -0x18(%rbp),%r9
xor    %esi,%esi
movzbl %dl,%edx
movzbl %al,%r8d
movzbl -0x19(%rbp),%eax
mov    %eax,(%rsp)
call   1030 <fci_i2c_transfer@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
je     11a3 <fci_i2c_write+0x83>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%edx
mov    -0xa(%rbp),%cl
mov    -0x18(%rbp),%rax
lea    0xe69(%rip),%rsi
movzbl %cl,%ecx
movzbl (%rax),%r8d
call   1040 <print_log@plt>
mov    -0x20(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fci_i2c_write>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %r8,%r14
mov    %ecx,%r8d
mov    %rdi,%rbx
mov    %dl,0xf(%rsp)
add    %sil,%sil
mov    %r9d,(%rsp)
movzbl %sil,%edx
lea    0xf(%rsp),%rcx
xor    %esi,%esi
mov    %r14,%r9
call   1030 <fci_i2c_transfer@plt>
mov    %eax,%ebp
test   %eax,%eax
je     116f <fci_i2c_write+0x4f>
movzbl 0xf(%rsp),%ecx
movzbl (%r14),%r8d
lea    0xe9b(%rip),%rsi
mov    %rbx,%rdi
mov    %ebp,%edx
call   1040 <print_log@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [46 x i8] c"fci_i2c_write() result=%d, addr= %x, data=%x\0A\00"
define i32 @fci_i2c_write(i8* %0, i8 zeroext %1, i8 zeroext %2, i8 zeroext %3, i8* %4, i8 zeroext %5) {
%7 = alloca i8*
%8 = alloca i8
%9 = alloca i8
%10 = alloca i8
%11 = alloca i8*
%12 = alloca i8
%13 = alloca i32
%14 = alloca i8*
store i8* %0, i8** %7
store i8 %1, i8* %8
store i8 %2, i8* %9
store i8 %3, i8* %10
store i8* %4, i8** %11
store i8 %5, i8* %12
store i8* %9, i8** %14
%15 = load i8*, i8** %7
%16 = load i8, i8* %8
%17 = zext i8 %16 to i32
%18 = shl i32 %17, 1
%19 = trunc i32 %18 to i8
%20 = load i8*, i8** %14
%21 = load i8, i8* %10
%22 = load i8*, i8** %11
%23 = load i8, i8* %12
%24 = call i32 @fci_i2c_transfer(i8* %15, i32 0, i8 zeroext %19, i8* %20, i8 zeroext %21, i8* %22, i8 zeroext %23)
store i32 %24, i32* %13
%25 = load i32, i32* %13
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %34
27: ; preds = %6
%28 = load i8*, i8** %7
%29 = load i32, i32* %13
%30 = load i8, i8* %9
%31 = load i8*, i8** %11
%32 = load i8, i8* %31
%33 = call i32 @print_log(i8* %28, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 %29, i8 zeroext %30, i8 zeroext %32)
br label %34
34: ; preds = %27, %6
%35 = load i32, i32* %13
ret i32 %35
}

LLVM IR (-O2):
@.str = [46 x i8] c"fci_i2c_write() result=%d, addr= %x, data=%x\0A\00"
define i32 @fci_i2c_write(i8* %0, i8 zeroext %1, i8 zeroext %2, i8 zeroext %3, i8* %4, i8 zeroext %5) {
%7 = alloca i8
store i8 %2, i8* %7
%8 = shl i8 %1, 1
%9 = call i32 @fci_i2c_transfer(i8* %0, i32 0, i8 zeroext %8, i8* %7, i8 zeroext %3, i8* %4, i8 zeroext %5)
%10 = icmp eq i32 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %6
%12 = load i8, i8* %7
%13 = load i8, i8* %4
%14 = call i32 @print_log(i8* %0, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 %9, i8 zeroext %12, i8 zeroext %13)
br label %15
15: ; preds = %11, %6
ret i32 %9
}