#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 */
char i2c_check_ack();
int /*<<< orphan*/ i2c_send_raw_data(char);
int /*<<< orphan*/ i2c_send_slave_adrs(char, int /*<<< orphan*/);
int /*<<< orphan*/ i2c_start_cond();
int /*<<< orphan*/ i2c_stop_cond();
int i2c_send_byte_3(char slave_adrs, char ctrl_byte, char cmddat_byte1,
                    char cmddat_byte2) {
  char d;
  int status;
  i2c_start_cond();
  i2c_send_slave_adrs(slave_adrs, 0);
  d = i2c_check_ack();
  if (d != 0) {
    status = -1;
    goto I2C_SEND_BYTE_3_RETURN;
  }
  i2c_send_raw_data(ctrl_byte);
  d = i2c_check_ack();
  if (d != 0) {
    status = -2;
    goto I2C_SEND_BYTE_3_RETURN;
  }
  i2c_send_raw_data(cmddat_byte1);
  d = i2c_check_ack();
  if (d != 0) {
    status = -3;
    goto I2C_SEND_BYTE_3_RETURN;
  }
  i2c_send_raw_data(cmddat_byte2);
  d = i2c_check_ack();
  if (d != 0) {
    status = -4;
    goto I2C_SEND_BYTE_3_RETURN;
  }
  status = 0;
I2C_SEND_BYTE_3_RETURN:
  i2c_stop_cond();
  return status;
}


x86 assembly (clang, -O0):
<i2c_send_byte_3>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %cl,%al
mov    %dl,%cl
mov    %sil,%dl
mov    %dil,%sil
mov    %sil,-0x1(%rbp)
mov    %dl,-0x2(%rbp)
mov    %cl,-0x3(%rbp)
mov    %al,-0x4(%rbp)
mov    $0x0,%al
call   1030 <i2c_start_cond@plt>
xor    %esi,%esi
movsbl -0x1(%rbp),%edi
call   1050 <i2c_send_slave_adrs@plt>
mov    $0x0,%al
call   1060 <i2c_check_ack@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x0,%eax
je     11a4 <i2c_send_byte_3+0x54>
movl   $0xffffffff,-0xc(%rbp)
jmp    122f <i2c_send_byte_3+0xdf>
movsbl -0x2(%rbp),%edi
call   1070 <i2c_send_raw_data@plt>
mov    $0x0,%al
call   1060 <i2c_check_ack@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x0,%eax
je     11d0 <i2c_send_byte_3+0x80>
movl   $0xfffffffe,-0xc(%rbp)
jmp    122f <i2c_send_byte_3+0xdf>
movsbl -0x3(%rbp),%edi
call   1070 <i2c_send_raw_data@plt>
mov    $0x0,%al
call   1060 <i2c_check_ack@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x0,%eax
je     11fc <i2c_send_byte_3+0xac>
movl   $0xfffffffd,-0xc(%rbp)
jmp    122f <i2c_send_byte_3+0xdf>
movsbl -0x4(%rbp),%edi
call   1070 <i2c_send_raw_data@plt>
mov    $0x0,%al
call   1060 <i2c_check_ack@plt>
mov    %al,-0x5(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x0,%eax
je     1228 <i2c_send_byte_3+0xd8>
movl   $0xfffffffc,-0xc(%rbp)
jmp    122f <i2c_send_byte_3+0xdf>
movl   $0x0,-0xc(%rbp)
mov    $0x0,%al
call   1040 <i2c_stop_cond@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<i2c_send_byte_3>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %esi,%ebx
mov    %edi,%ebp
xor    %eax,%eax
call   1030 <i2c_start_cond@plt>
mov    %ebp,%edi
xor    %esi,%esi
call   1050 <i2c_send_slave_adrs@plt>
xor    %eax,%eax
call   1060 <i2c_check_ack@plt>
mov    $0xffffffff,%ebp
test   %al,%al
jne    11d0 <i2c_send_byte_3+0x80>
movsbl %bl,%edi
call   1070 <i2c_send_raw_data@plt>
xor    %eax,%eax
call   1060 <i2c_check_ack@plt>
mov    $0xfffffffe,%ebp
test   %al,%al
jne    11d0 <i2c_send_byte_3+0x80>
movsbl %r15b,%edi
call   1070 <i2c_send_raw_data@plt>
xor    %eax,%eax
call   1060 <i2c_check_ack@plt>
mov    $0xfffffffd,%ebp
test   %al,%al
jne    11d0 <i2c_send_byte_3+0x80>
movsbl %r14b,%edi
call   1070 <i2c_send_raw_data@plt>
xor    %eax,%eax
call   1060 <i2c_check_ack@plt>
xor    %ecx,%ecx
test   %al,%al
sete   %cl
lea    -0x4(,%rcx,4),%ebp
xor    %eax,%eax
call   1040 <i2c_stop_cond@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @i2c_send_byte_3(i8 signext %0, i8 signext %1, i8 signext %2, i8 signext %3) {
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
%10 = alloca i32
store i8 %0, i8* %5
store i8 %1, i8* %6
store i8 %2, i8* %7
store i8 %3, i8* %8
%11 = call i32 (...) @i2c_start_cond()
%12 = load i8, i8* %5
%13 = call i32 @i2c_send_slave_adrs(i8 signext %12, i32 0)
%14 = call signext i8 (...) @i2c_check_ack()
store i8 %14, i8* %9
%15 = load i8, i8* %9
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %4
store i32 -1, i32* %10
br label %44
19: ; preds = %4
%20 = load i8, i8* %6
%21 = call i32 @i2c_send_raw_data(i8 signext %20)
%22 = call signext i8 (...) @i2c_check_ack()
store i8 %22, i8* %9
%23 = load i8, i8* %9
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %19
store i32 -2, i32* %10
br label %44
27: ; preds = %19
%28 = load i8, i8* %7
%29 = call i32 @i2c_send_raw_data(i8 signext %28)
%30 = call signext i8 (...) @i2c_check_ack()
store i8 %30, i8* %9
%31 = load i8, i8* %9
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %35
34: ; preds = %27
store i32 -3, i32* %10
br label %44
35: ; preds = %27
%36 = load i8, i8* %8
%37 = call i32 @i2c_send_raw_data(i8 signext %36)
%38 = call signext i8 (...) @i2c_check_ack()
store i8 %38, i8* %9
%39 = load i8, i8* %9
%40 = sext i8 %39 to i32
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %35
store i32 -4, i32* %10
br label %44
43: ; preds = %35
store i32 0, i32* %10
br label %44
44: ; preds = %43, %42, %34, %26, %18
%45 = call i32 (...) @i2c_stop_cond()
%46 = load i32, i32* %10
ret i32 %46
}

LLVM IR (-O2):
define i32 @i2c_send_byte_3(i8 signext %0, i8 signext %1, i8 signext %2, i8 signext %3) {
%5 = tail call i32 (...) @i2c_start_cond()
%6 = tail call i32 @i2c_send_slave_adrs(i8 signext %0, i32 0)
%7 = tail call signext i8 (...) @i2c_check_ack()
%8 = icmp eq i8 %7, 0
br i1 %8, label %9, label %22
9: ; preds = %4
%10 = tail call i32 @i2c_send_raw_data(i8 signext %1)
%11 = tail call signext i8 (...) @i2c_check_ack()
%12 = icmp eq i8 %11, 0
br i1 %12, label %13, label %22
13: ; preds = %9
%14 = tail call i32 @i2c_send_raw_data(i8 signext %2)
%15 = tail call signext i8 (...) @i2c_check_ack()
%16 = icmp eq i8 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %13
%18 = tail call i32 @i2c_send_raw_data(i8 signext %3)
%19 = tail call signext i8 (...) @i2c_check_ack()
%20 = icmp eq i8 %19, 0
%21 = select i1 %20, i32 0, i32 -4
br label %22
22: ; preds = %17, %13, %9, %4
%23 = phi i32 [ -1, %4 ], [ -2, %9 ], [ -3, %13 ], [ %21, %17 ]
%24 = tail call i32 (...) @i2c_stop_cond()
ret i32 %23
}