#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*/ i2cgetack();
int /*<<< orphan*/ i2csendbyte(char);
int /*<<< orphan*/ i2cstart();
int /*<<< orphan*/ i2cstop();
char I2C_Send(char Address, char *Data, char Num) {
  i2cstart();
  i2csendbyte(Address & 0xFE);
  if (!i2cgetack()) {
    i2cstop();
    return (0);
  }
  while (Num--) {
    i2csendbyte(*Data);
    if (!i2cgetack()) {
      i2cstop();
      return (0);
    }
    Data++;
  }
  i2cstop();
  return (1);
}


x86 assembly (clang, -O0):
<I2C_Send>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %dil,%cl
mov    %cl,-0x2(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    $0x0,%al
call   1060 <i2cstart@plt>
movsbl -0x2(%rbp),%eax
and    $0xfe,%eax
movsbl %al,%edi
call   1040 <i2csendbyte@plt>
mov    $0x0,%al
call   1030 <i2cgetack@plt>
cmp    $0x0,%eax
jne    118f <I2C_Send+0x4f>
mov    $0x0,%al
call   1050 <i2cstop@plt>
movb   $0x0,-0x1(%rbp)
jmp    11ef <I2C_Send+0xaf>
jmp    1194 <I2C_Send+0x54>
mov    -0x11(%rbp),%al
mov    %al,%cl
add    $0xff,%cl
mov    %cl,-0x11(%rbp)
cmp    $0x0,%al
je     11e4 <I2C_Send+0xa4>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <i2csendbyte@plt>
mov    $0x0,%al
call   1030 <i2cgetack@plt>
cmp    $0x0,%eax
jne    11d3 <I2C_Send+0x93>
mov    $0x0,%al
call   1050 <i2cstop@plt>
movb   $0x0,-0x1(%rbp)
jmp    11ef <I2C_Send+0xaf>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1194 <I2C_Send+0x54>
mov    $0x0,%al
call   1050 <i2cstop@plt>
movb   $0x1,-0x1(%rbp)
movsbl -0x1(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<I2C_Send>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%r14d
mov    %rsi,%r15
mov    %edi,%ebx
xor    %ebp,%ebp
xor    %eax,%eax
call   1060 <i2cstart@plt>
and    $0xfe,%bl
movsbl %bl,%edi
call   1040 <i2csendbyte@plt>
xor    %eax,%eax
call   1030 <i2cgetack@plt>
test   %eax,%eax
je     11a1 <I2C_Send+0x61>
test   %r14b,%r14b
je     119e <I2C_Send+0x5e>
movzbl %r14b,%r14d
xor    %ebx,%ebx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
movsbl (%r15,%rbx,1),%edi
call   1040 <i2csendbyte@plt>
xor    %eax,%eax
call   1030 <i2cgetack@plt>
test   %eax,%eax
je     11a1 <I2C_Send+0x61>
add    $0x1,%rbx
cmp    %bl,%r14b
jne    1180 <I2C_Send+0x40>
mov    $0x1,%bpl
xor    %eax,%eax
call   1050 <i2cstop@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define signext i8 @I2C_Send(i8 signext %0, i8* %1, i8 signext %2) {
%4 = alloca i8
%5 = alloca i8
%6 = alloca i8*
%7 = alloca i8
store i8 %0, i8* %5
store i8* %1, i8** %6
store i8 %2, i8* %7
%8 = call i32 (...) @i2cstart()
%9 = load i8, i8* %5
%10 = sext i8 %9 to i32
%11 = and i32 %10, 254
%12 = trunc i32 %11 to i8
%13 = call i32 @i2csendbyte(i8 signext %12)
%14 = call i32 (...) @i2cgetack()
%15 = icmp ne i32 %14, 0
br i1 %15, label %18, label %16
16: ; preds = %3
%17 = call i32 (...) @i2cstop()
store i8 0, i8* %4
br label %36
18: ; preds = %3
br label %19
19: ; preds = %31, %18
%20 = load i8, i8* %7
%21 = add i8 %20, -1
store i8 %21, i8* %7
%22 = icmp ne i8 %20, 0
br i1 %22, label %23, label %34
23: ; preds = %19
%24 = load i8*, i8** %6
%25 = load i8, i8* %24
%26 = call i32 @i2csendbyte(i8 signext %25)
%27 = call i32 (...) @i2cgetack()
%28 = icmp ne i32 %27, 0
br i1 %28, label %31, label %29
29: ; preds = %23
%30 = call i32 (...) @i2cstop()
store i8 0, i8* %4
br label %36
31: ; preds = %23
%32 = load i8*, i8** %6
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %6
br label %19
34: ; preds = %19
%35 = call i32 (...) @i2cstop()
store i8 1, i8* %4
br label %36
36: ; preds = %34, %29, %16
%37 = load i8, i8* %4
ret i8 %37
}

LLVM IR (-O2):
define signext i8 @I2C_Send(i8 signext %0, i8* nocapture %1, i8 signext %2) {
%4 = tail call i32 (...) @i2cstart()
%5 = and i8 %0, -2
%6 = tail call i32 @i2csendbyte(i8 signext %5)
%7 = tail call i32 (...) @i2cgetack()
%8 = icmp eq i32 %7, 0
br i1 %8, label %22, label %9
9: ; preds = %3
%10 = icmp eq i8 %2, 0
br i1 %10, label %22, label %14
11: ; preds = %14
%12 = getelementptr inbounds i8, i8* %16, i64 1
%13 = icmp eq i8 %17, 0
br i1 %13, label %22, label %14
14: ; preds = %9, %11
%15 = phi i8 [ %17, %11 ], [ %2, %9 ]
%16 = phi i8* [ %12, %11 ], [ %1, %9 ]
%17 = add i8 %15, -1
%18 = load i8, i8* %16
%19 = tail call i32 @i2csendbyte(i8 signext %18)
%20 = tail call i32 (...) @i2cgetack()
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %11
22: ; preds = %11, %14, %9, %3
%23 = phi i8 [ 0, %3 ], [ 1, %9 ], [ 0, %14 ], [ 1, %11 ]
%24 = tail call i32 (...) @i2cstop()
ret i8 %23
}