#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*/ I2C2_Start();
int /*<<< orphan*/ I2C2_Stop();
int /*<<< orphan*/ I2C2_Write(unsigned char volatile);
void MPU_I2C_Write(unsigned char s_addr, unsigned char r_addr,
                   unsigned char len, unsigned char *dat) {
  volatile unsigned int i;
  volatile unsigned char s_addr_internW, s_addr_internR;
  s_addr_internW = (s_addr << 1) & 0xFE;
  I2C2_Start();
  I2C2_Write(s_addr_internW);
  I2C2_Write(r_addr);
  for (i = 0; i < len; i++) {
    I2C2_Write(*dat++);
  }
  I2C2_Stop();
}


x86 assembly (clang, -O0):
<MPU_I2C_Write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %sil,%dl
mov    %dil,%sil
mov    %sil,-0x1(%rbp)
mov    %dl,-0x2(%rbp)
mov    %al,-0x3(%rbp)
mov    %rcx,-0x10(%rbp)
movzbl -0x1(%rbp),%eax
shl    $0x1,%eax
and    $0xfe,%eax
mov    %al,-0x15(%rbp)
mov    $0x0,%al
call   1050 <I2C2_Start@plt>
mov    -0x15(%rbp),%al
movzbl %al,%edi
call   1040 <I2C2_Write@plt>
movzbl -0x2(%rbp),%edi
call   1040 <I2C2_Write@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
movzbl -0x3(%rbp),%ecx
cmp    %ecx,%eax
jae    11b3 <MPU_I2C_Write+0x83>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movzbl (%rax),%edi
call   1040 <I2C2_Write@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    117f <MPU_I2C_Write+0x4f>
mov    $0x0,%al
call   1030 <I2C2_Stop@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MPU_I2C_Write>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%rbx
mov    %edx,%ebp
mov    %esi,%r14d
add    %dil,%dil
mov    %dil,0xb(%rsp)
xor    %eax,%eax
call   1050 <I2C2_Start@plt>
movzbl 0xb(%rsp),%edi
call   1040 <I2C2_Write@plt>
mov    %r14d,%edi
call   1040 <I2C2_Write@plt>
movl   $0x0,0xc(%rsp)
nopl   0x0(%rax)
mov    0xc(%rsp),%eax
cmp    %ebp,%eax
jae    118b <MPU_I2C_Write+0x5b>
movzbl (%rbx),%edi
add    $0x1,%rbx
call   1040 <I2C2_Write@plt>
addl   $0x1,0xc(%rsp)
jmp    1170 <MPU_I2C_Write+0x40>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <I2C2_Stop@plt>

LLVM IR (-O0):
define void @MPU_I2C_Write(i8 zeroext %0, i8 zeroext %1, i8 zeroext %2, i8* %3) {
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8
%11 = alloca i8
store i8 %0, i8* %5
store i8 %1, i8* %6
store i8 %2, i8* %7
store i8* %3, i8** %8
%12 = load i8, i8* %5
%13 = zext i8 %12 to i32
%14 = shl i32 %13, 1
%15 = and i32 %14, 254
%16 = trunc i32 %15 to i8
store volatile i8 %16, i8* %10
%17 = call i32 (...) @I2C2_Start()
%18 = load volatile i8, i8* %10
%19 = call i32 @I2C2_Write(i8 zeroext %18)
%20 = load i8, i8* %6
%21 = call i32 @I2C2_Write(i8 zeroext %20)
store volatile i32 0, i32* %9
br label %22
22: ; preds = %32, %4
%23 = load volatile i32, i32* %9
%24 = load i8, i8* %7
%25 = zext i8 %24 to i32
%26 = icmp ult i32 %23, %25
br i1 %26, label %27, label %35
27: ; preds = %22
%28 = load i8*, i8** %8
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %8
%30 = load i8, i8* %28
%31 = call i32 @I2C2_Write(i8 zeroext %30)
br label %32
32: ; preds = %27
%33 = load volatile i32, i32* %9
%34 = add i32 %33, 1
store volatile i32 %34, i32* %9
br label %22
35: ; preds = %22
%36 = call i32 (...) @I2C2_Stop()
ret void
}

LLVM IR (-O2):
define void @MPU_I2C_Write(i8 zeroext %0, i8 zeroext %1, i8 zeroext %2, i8* nocapture %3) {
%5 = alloca i32
%6 = alloca i8
%7 = bitcast i32* %5 to i8*
%8 = shl i8 %0, 1
store volatile i8 %8, i8* %6
%9 = tail call i32 (...) @I2C2_Start()
%10 = load volatile i8, i8* %6
%11 = tail call i32 @I2C2_Write(i8 zeroext %10)
%12 = tail call i32 @I2C2_Write(i8 zeroext %1)
store volatile i32 0, i32* %5
%13 = zext i8 %2 to i32
%14 = load volatile i32, i32* %5
%15 = icmp ult i32 %14, %13
br i1 %15, label %16, label %25
16: ; preds = %4, %16
%17 = phi i8* [ %18, %16 ], [ %3, %4 ]
%18 = getelementptr inbounds i8, i8* %17, i64 1
%19 = load i8, i8* %17
%20 = tail call i32 @I2C2_Write(i8 zeroext %19)
%21 = load volatile i32, i32* %5
%22 = add i32 %21, 1
store volatile i32 %22, i32* %5
%23 = load volatile i32, i32* %5
%24 = icmp ult i32 %23, %13
br i1 %24, label %16, label %25
25: ; preds = %16, %4
%26 = tail call i32 (...) @I2C2_Stop()
ret void
}