#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 */
typedef int uint8_t;

/* Variables and functions */
int /*<<< orphan*/ i2cRead(int, int, ...);
int /*<<< orphan*/ mma8491Disable();
int /*<<< orphan*/ mma8491Enable();
uint8_t mma8491ReadRaw(uint8_t *data) {
  unsigned char status = 0;
  mma8491Enable();
  do {
    i2cRead(0x55, 0x00, &status);
  } while (((status & (1 << 3)) != (1 << 3)) || (status > 0x0f));
  int ii;
  for (ii = 0; ii < 6; ii++) {
    i2cRead(0x55, 0x01 + ii, &data[ii]);
  }
  mma8491Disable();
  return 1;
}


x86 assembly (clang, -O0):
<mma8491ReadRaw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
movb   $0x0,-0x9(%rbp)
mov    $0x0,%al
call   1040 <mma8491Enable@plt>
mov    $0x55,%edi
xor    %esi,%esi
lea    -0x9(%rbp),%rdx
mov    $0x0,%al
call   1050 <i2cRead@plt>
movzbl -0x9(%rbp),%ecx
and    $0x8,%ecx
mov    $0x1,%al
cmp    $0x8,%ecx
mov    %al,-0x11(%rbp)
jne    117b <mma8491ReadRaw+0x4b>
movzbl -0x9(%rbp),%eax
cmp    $0xf,%eax
setg   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1147 <mma8491ReadRaw+0x17>
movl   $0x0,-0x10(%rbp)
cmpl   $0x6,-0x10(%rbp)
jge    11c6 <mma8491ReadRaw+0x96>
mov    -0x10(%rbp),%esi
add    $0x1,%esi
mov    -0x8(%rbp),%rdx
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
mov    $0x55,%edi
mov    $0x0,%al
call   1050 <i2cRead@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    118d <mma8491ReadRaw+0x5d>
mov    $0x0,%al
call   1030 <mma8491Disable@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mma8491ReadRaw>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
movb   $0x0,0x7(%rsp)
xor    %eax,%eax
call   1040 <mma8491Enable@plt>
lea    0x7(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    $0x55,%edi
xor    %esi,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <i2cRead@plt>
movzbl 0x7(%rsp),%eax
and    $0xf8,%al
cmp    $0x8,%al
jne    1150 <mma8491ReadRaw+0x20>
mov    $0x55,%edi
mov    $0x1,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <i2cRead@plt>
lea    0x4(%r14),%rdx
mov    $0x55,%edi
mov    $0x2,%esi
xor    %eax,%eax
call   1050 <i2cRead@plt>
lea    0x8(%r14),%rdx
mov    $0x55,%edi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <i2cRead@plt>
lea    0xc(%r14),%rdx
mov    $0x55,%edi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <i2cRead@plt>
lea    0x10(%r14),%rdx
mov    $0x55,%edi
mov    $0x5,%esi
xor    %eax,%eax
call   1050 <i2cRead@plt>
add    $0x14,%r14
mov    $0x55,%edi
mov    $0x6,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1050 <i2cRead@plt>
xor    %eax,%eax
call   1030 <mma8491Disable@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @mma8491ReadRaw(i32* %0) {
%2 = alloca i32*
%3 = alloca i8
%4 = alloca i32
store i32* %0, i32** %2
store i8 0, i8* %3
%5 = call i32 (...) @mma8491Enable()
br label %6
6: ; preds = %17, %1
%7 = call i32 (i32, i32, ...) @i2cRead(i32 85, i32 0, i8* %3)
br label %8
8: ; preds = %6
%9 = load i8, i8* %3
%10 = zext i8 %9 to i32
%11 = and i32 %10, 8
%12 = icmp ne i32 %11, 8
br i1 %12, label %17, label %13
13: ; preds = %8
%14 = load i8, i8* %3
%15 = zext i8 %14 to i32
%16 = icmp sgt i32 %15, 15
br label %17
17: ; preds = %13, %8
%18 = phi i1 [ true, %8 ], [ %16, %13 ]
br i1 %18, label %6, label %19
19: ; preds = %17
store i32 0, i32* %4
br label %20
20: ; preds = %31, %19
%21 = load i32, i32* %4
%22 = icmp slt i32 %21, 6
br i1 %22, label %23, label %34
23: ; preds = %20
%24 = load i32, i32* %4
%25 = add nsw i32 1, %24
%26 = load i32*, i32** %2
%27 = load i32, i32* %4
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i32, i32* %26, i64 %28
%30 = call i32 (i32, i32, ...) @i2cRead(i32 85, i32 %25, i32* %29)
br label %31
31: ; preds = %23
%32 = load i32, i32* %4
%33 = add nsw i32 %32, 1
store i32 %33, i32* %4
br label %20
34: ; preds = %20
%35 = call i32 (...) @mma8491Disable()
ret i32 1
}

LLVM IR (-O2):
define i32 @mma8491ReadRaw(i32* %0) {
%2 = alloca i8
store i8 0, i8* %2
%3 = tail call i32 (...) @mma8491Enable()
br label %4
4: ; preds = %4, %1
%5 = call i32 (i32, i32, ...) @i2cRead(i32 85, i32 0, i8* %2)
%6 = load i8, i8* %2
%7 = and i8 %6, -8
%8 = icmp eq i8 %7, 8
br i1 %8, label %9, label %4
9: ; preds = %4
%10 = call i32 (i32, i32, ...) @i2cRead(i32 85, i32 1, i32* %0)
%11 = getelementptr inbounds i32, i32* %0, i64 1
%12 = call i32 (i32, i32, ...) @i2cRead(i32 85, i32 2, i32* %11)
%13 = getelementptr inbounds i32, i32* %0, i64 2
%14 = call i32 (i32, i32, ...) @i2cRead(i32 85, i32 3, i32* %13)
%15 = getelementptr inbounds i32, i32* %0, i64 3
%16 = call i32 (i32, i32, ...) @i2cRead(i32 85, i32 4, i32* %15)
%17 = getelementptr inbounds i32, i32* %0, i64 4
%18 = call i32 (i32, i32, ...) @i2cRead(i32 85, i32 5, i32* %17)
%19 = getelementptr inbounds i32, i32* %0, i64 5
%20 = call i32 (i32, i32, ...) @i2cRead(i32 85, i32 6, i32* %19)
%21 = call i32 (...) @mma8491Disable()
ret i32 1
}