#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 I2C_PutByte(unsigned char);
int /*<<< orphan*/ I2C_START();
int /*<<< orphan*/ I2C_STOP();
unsigned int SynaWriteRegister(unsigned short uRmiAddress,
                               unsigned char Buffer[],
                               unsigned int BytesToSend) {
  unsigned char Count = 0;
  I2C_START();
  if (I2C_PutByte(0x20 << 1) == 0x01) {
    I2C_STOP();
    return 0x01;
  }
  if (I2C_PutByte((unsigned char)uRmiAddress) == 0x01) {
    I2C_STOP();
    return 0x01;
  }
  while (Count < BytesToSend) {
    if (I2C_PutByte(Buffer[Count++]) == 0x01) {
      I2C_STOP();
      return 0x01;
    }
  }
  I2C_STOP();
  return 0x00;
}


x86 assembly (clang, -O0):
<SynaWriteRegister>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %di,%ax
mov    %ax,-0x6(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movb   $0x0,-0x15(%rbp)
mov    $0x0,%al
call   1050 <I2C_START@plt>
mov    $0x40,%edi
call   1030 <I2C_PutByte@plt>
cmp    $0x1,%eax
jne    1177 <SynaWriteRegister+0x47>
mov    $0x0,%al
call   1040 <I2C_STOP@plt>
movl   $0x1,-0x4(%rbp)
jmp    11fb <SynaWriteRegister+0xcb>
mov    -0x6(%rbp),%ax
movzbl %al,%edi
call   1030 <I2C_PutByte@plt>
cmp    $0x1,%eax
jne    119f <SynaWriteRegister+0x6f>
mov    $0x0,%al
call   1040 <I2C_STOP@plt>
movl   $0x1,-0x4(%rbp)
jmp    11fb <SynaWriteRegister+0xcb>
jmp    11a4 <SynaWriteRegister+0x74>
movzbl -0x15(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    11ed <SynaWriteRegister+0xbd>
mov    -0x10(%rbp),%rax
mov    -0x15(%rbp),%cl
mov    %cl,%dl
add    $0x1,%dl
mov    %dl,-0x15(%rbp)
movzbl %cl,%ecx
movzbl (%rax,%rcx,1),%edi
call   1030 <I2C_PutByte@plt>
cmp    $0x1,%eax
jne    11e8 <SynaWriteRegister+0xb8>
mov    $0x0,%al
call   1040 <I2C_STOP@plt>
movl   $0x1,-0x4(%rbp)
jmp    11fb <SynaWriteRegister+0xcb>
jmp    11a4 <SynaWriteRegister+0x74>
mov    $0x0,%al
call   1040 <I2C_STOP@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SynaWriteRegister>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%ebp
mov    %rsi,%r12
mov    %edi,%r15d
xor    %eax,%eax
call   1050 <I2C_START@plt>
mov    $0x40,%edi
call   1030 <I2C_PutByte@plt>
mov    $0x1,%r14d
cmp    $0x1,%eax
je     118e <SynaWriteRegister+0x5e>
movzbl %r15b,%edi
call   1030 <I2C_PutByte@plt>
cmp    $0x1,%eax
je     118e <SynaWriteRegister+0x5e>
xor    %ebx,%ebx
nopl   0x0(%rax)
movzbl %bl,%eax
cmp    %ebp,%eax
jae    118b <SynaWriteRegister+0x5b>
lea    0x1(%rax),%ebx
movzbl (%r12,%rax,1),%edi
call   1030 <I2C_PutByte@plt>
cmp    $0x1,%eax
jne    1170 <SynaWriteRegister+0x40>
jmp    118e <SynaWriteRegister+0x5e>
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <I2C_STOP@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @SynaWriteRegister(i16 zeroext %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i16
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8
store i16 %0, i16* %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i8 0, i8* %8
%9 = call i32 (...) @I2C_START()
%10 = call i32 @I2C_PutByte(i8 zeroext 64)
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %14
12: ; preds = %3
%13 = call i32 (...) @I2C_STOP()
store i32 1, i32* %4
br label %41
14: ; preds = %3
%15 = load i16, i16* %5
%16 = trunc i16 %15 to i8
%17 = call i32 @I2C_PutByte(i8 zeroext %16)
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %21
19: ; preds = %14
%20 = call i32 (...) @I2C_STOP()
store i32 1, i32* %4
br label %41
21: ; preds = %14
br label %22
22: ; preds = %38, %21
%23 = load i8, i8* %8
%24 = zext i8 %23 to i32
%25 = load i32, i32* %7
%26 = icmp ult i32 %24, %25
br i1 %26, label %27, label %39
27: ; preds = %22
%28 = load i8*, i8** %6
%29 = load i8, i8* %8
%30 = add i8 %29, 1
store i8 %30, i8* %8
%31 = zext i8 %29 to i64
%32 = getelementptr inbounds i8, i8* %28, i64 %31
%33 = load i8, i8* %32
%34 = call i32 @I2C_PutByte(i8 zeroext %33)
%35 = icmp eq i32 %34, 1
br i1 %35, label %36, label %38
36: ; preds = %27
%37 = call i32 (...) @I2C_STOP()
store i32 1, i32* %4
br label %41
38: ; preds = %27
br label %22
39: ; preds = %22
%40 = call i32 (...) @I2C_STOP()
store i32 0, i32* %4
br label %41
41: ; preds = %39, %36, %19, %12
%42 = load i32, i32* %4
ret i32 %42
}

LLVM IR (-O2):
define i32 @SynaWriteRegister(i16 zeroext %0, i8* nocapture %1, i32 %2) {
%4 = tail call i32 (...) @I2C_START()
%5 = tail call i32 @I2C_PutByte(i8 zeroext 64)
%6 = icmp eq i32 %5, 1
br i1 %6, label %22, label %7
7: ; preds = %3
%8 = trunc i16 %0 to i8
%9 = tail call i32 @I2C_PutByte(i8 zeroext %8)
%10 = icmp eq i32 %9, 1
br i1 %10, label %22, label %11
11: ; preds = %7, %15
%12 = phi i8 [ %16, %15 ], [ 0, %7 ]
%13 = zext i8 %12 to i32
%14 = icmp ult i32 %13, %2
br i1 %14, label %15, label %22
15: ; preds = %11
%16 = add i8 %12, 1
%17 = zext i8 %12 to i64
%18 = getelementptr inbounds i8, i8* %1, i64 %17
%19 = load i8, i8* %18
%20 = tail call i32 @I2C_PutByte(i8 zeroext %19)
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %11
22: ; preds = %11, %15, %7, %3
%23 = phi i32 [ 1, %3 ], [ 1, %7 ], [ 1, %15 ], [ 0, %11 ]
%24 = tail call i32 (...) @I2C_STOP()
ret i32 %23
}