#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*/ i2cWrite(int, int, int);
uint8_t mag3110ReadRaw(uint8_t *data) {
  unsigned char status = 0;
  i2cWrite(0x0E, 0x11, 0x80);
  i2cWrite(0x0E, 0x10, 0x02);
  do {
    i2cRead(0x0E, 0x00, &status);
  } while (((status & (0x07)) != (0x07)));
  int ii;
  for (ii = 0; ii < 6; ii++) {
    i2cRead(0x0E, 0x01 + ii, &data[ii]);
  }
  return 1;
}


x86 assembly (clang, -O0):
<mag3110ReadRaw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movb   $0x0,-0x9(%rbp)
mov    $0xe,%edi
mov    $0x11,%esi
mov    $0x80,%edx
call   1040 <i2cWrite@plt>
mov    $0xe,%edi
mov    $0x10,%esi
mov    $0x2,%edx
call   1040 <i2cWrite@plt>
mov    $0xe,%edi
xor    %esi,%esi
lea    -0x9(%rbp),%rdx
mov    $0x0,%al
call   1030 <i2cRead@plt>
movzbl -0x9(%rbp),%eax
and    $0x7,%eax
cmp    $0x7,%eax
jne    1158 <mag3110ReadRaw+0x38>
movl   $0x0,-0x10(%rbp)
cmpl   $0x6,-0x10(%rbp)
jge    11ba <mag3110ReadRaw+0x9a>
mov    -0x10(%rbp),%esi
add    $0x1,%esi
mov    -0x8(%rbp),%rdx
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
mov    $0xe,%edi
mov    $0x0,%al
call   1030 <i2cRead@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1181 <mag3110ReadRaw+0x61>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mag3110ReadRaw>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
movb   $0x0,0x7(%rsp)
mov    $0xe,%edi
mov    $0x11,%esi
mov    $0x80,%edx
call   1040 <i2cWrite@plt>
mov    $0xe,%edi
mov    $0x10,%esi
mov    $0x2,%edx
call   1040 <i2cWrite@plt>
lea    0x7(%rsp),%rbx
nopl   0x0(%rax)
mov    $0xe,%edi
xor    %esi,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1030 <i2cRead@plt>
movzbl 0x7(%rsp),%eax
not    %al
test   $0x7,%al
jne    1160 <mag3110ReadRaw+0x40>
mov    $0xe,%edi
mov    $0x1,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <i2cRead@plt>
lea    0x4(%r14),%rdx
mov    $0xe,%edi
mov    $0x2,%esi
xor    %eax,%eax
call   1030 <i2cRead@plt>
lea    0x8(%r14),%rdx
mov    $0xe,%edi
mov    $0x3,%esi
xor    %eax,%eax
call   1030 <i2cRead@plt>
lea    0xc(%r14),%rdx
mov    $0xe,%edi
mov    $0x4,%esi
xor    %eax,%eax
call   1030 <i2cRead@plt>
lea    0x10(%r14),%rdx
mov    $0xe,%edi
mov    $0x5,%esi
xor    %eax,%eax
call   1030 <i2cRead@plt>
add    $0x14,%r14
mov    $0xe,%edi
mov    $0x6,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <i2cRead@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @mag3110ReadRaw(i32* %0) {
%2 = alloca i32*
%3 = alloca i8
%4 = alloca i32
store i32* %0, i32** %2
store i8 0, i8* %3
%5 = call i32 @i2cWrite(i32 14, i32 17, i32 128)
%6 = call i32 @i2cWrite(i32 14, i32 16, i32 2)
br label %7
7: ; preds = %9, %1
%8 = call i32 (i32, i32, ...) @i2cRead(i32 14, i32 0, i8* %3)
br label %9
9: ; preds = %7
%10 = load i8, i8* %3
%11 = zext i8 %10 to i32
%12 = and i32 %11, 7
%13 = icmp ne i32 %12, 7
br i1 %13, label %7, label %14
14: ; preds = %9
store i32 0, i32* %4
br label %15
15: ; preds = %26, %14
%16 = load i32, i32* %4
%17 = icmp slt i32 %16, 6
br i1 %17, label %18, label %29
18: ; preds = %15
%19 = load i32, i32* %4
%20 = add nsw i32 1, %19
%21 = load i32*, i32** %2
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
%25 = call i32 (i32, i32, ...) @i2cRead(i32 14, i32 %20, i32* %24)
br label %26
26: ; preds = %18
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 1
store i32 %28, i32* %4
br label %15
29: ; preds = %15
ret i32 1
}

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