#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 BlockRead(int, unsigned char *, int);
int BMA222ReadNew(signed char *pcAccX, signed char *pcAccY,
                  signed char *pcAccZ) {
  char cAccX[6];
  {
    int iRetVal = (BlockRead((0x2), (unsigned char *)cAccX, 6));
    if (0 != iRetVal)
      return iRetVal;
  };
  if ((cAccX[0] & 0x1) && (cAccX[2] & 0x1) && (cAccX[4] & 0x1)) {
    *pcAccX = cAccX[1];
    *pcAccY = cAccX[3];
    *pcAccZ = cAccX[5];
    return 0;
  }
  return -1;
}


x86 assembly (clang, -O0):
<BMA222ReadNew>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    -0x26(%rbp),%rsi
mov    $0x2,%edi
mov    $0x6,%edx
call   1030 <BlockRead@plt>
mov    %eax,-0x2c(%rbp)
xor    %eax,%eax
cmp    -0x2c(%rbp),%eax
je     1150 <BMA222ReadNew+0x40>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ae <BMA222ReadNew+0x9e>
movsbl -0x26(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11a7 <BMA222ReadNew+0x97>
movsbl -0x24(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11a7 <BMA222ReadNew+0x97>
movsbl -0x22(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11a7 <BMA222ReadNew+0x97>
mov    -0x25(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x23(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x21(%rbp),%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
movl   $0x0,-0x4(%rbp)
jmp    11ae <BMA222ReadNew+0x9e>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BMA222ReadNew>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0xa(%rsp),%rsi
mov    $0x2,%edi
mov    $0x6,%edx
call   1030 <BlockRead@plt>
test   %eax,%eax
jne    116a <BMA222ReadNew+0x5a>
mov    $0xffffffff,%eax
testb  $0x1,0xa(%rsp)
je     116a <BMA222ReadNew+0x5a>
testb  $0x1,0xc(%rsp)
je     116a <BMA222ReadNew+0x5a>
testb  $0x1,0xe(%rsp)
je     116a <BMA222ReadNew+0x5a>
mov    0xb(%rsp),%al
mov    %al,(%rbx)
mov    0xd(%rsp),%al
mov    %al,(%r15)
mov    0xf(%rsp),%al
mov    %al,(%r14)
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @BMA222ReadNew(i8* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca [6 x i8]
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%10 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%11 = call i32 @BlockRead(i32 2, i8* %10, i32 6)
store i32 %11, i32* %9
%12 = load i32, i32* %9
%13 = icmp ne i32 0, %12
br i1 %13, label %14, label %16
14: ; preds = %3
%15 = load i32, i32* %9
store i32 %15, i32* %4
br label %45
16: ; preds = %3
%17 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = and i32 %19, 1
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %44
22: ; preds = %16
%23 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 2
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = and i32 %25, 1
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %44
28: ; preds = %22
%29 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 4
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = and i32 %31, 1
%33 = icmp ne i32 %32, 0
br i1 %33, label %34, label %44
34: ; preds = %28
%35 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 1
%36 = load i8, i8* %35
%37 = load i8*, i8** %5
store i8 %36, i8* %37
%38 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 3
%39 = load i8, i8* %38
%40 = load i8*, i8** %6
store i8 %39, i8* %40
%41 = getelementptr inbounds [6 x i8], [6 x i8]* %8, i64 0, i64 5
%42 = load i8, i8* %41
%43 = load i8*, i8** %7
store i8 %42, i8* %43
store i32 0, i32* %4
br label %45
44: ; preds = %28, %22, %16
store i32 -1, i32* %4
br label %45
45: ; preds = %44, %34, %14
%46 = load i32, i32* %4
ret i32 %46
}

LLVM IR (-O2):
define i32 @BMA222ReadNew(i8* nocapture writeonly %0, i8* nocapture writeonly %1, i8* nocapture writeonly %2) {
%4 = alloca [6 x i8]
%5 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 0
%6 = call i32 @BlockRead(i32 2, i8* %5, i32 6)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %29
8: ; preds = %3
%9 = load i8, i8* %5
%10 = and i8 %9, 1
%11 = icmp eq i8 %10, 0
br i1 %11, label %29, label %12
12: ; preds = %8
%13 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 2
%14 = load i8, i8* %13
%15 = and i8 %14, 1
%16 = icmp eq i8 %15, 0
br i1 %16, label %29, label %17
17: ; preds = %12
%18 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 4
%19 = load i8, i8* %18
%20 = and i8 %19, 1
%21 = icmp eq i8 %20, 0
br i1 %21, label %29, label %22
22: ; preds = %17
%23 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 1
%24 = load i8, i8* %23
store i8 %24, i8* %0
%25 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 3
%26 = load i8, i8* %25
store i8 %26, i8* %1
%27 = getelementptr inbounds [6 x i8], [6 x i8]* %4, i64 0, i64 5
%28 = load i8, i8* %27
store i8 %28, i8* %2
br label %29
29: ; preds = %8, %12, %17, %3, %22
%30 = phi i32 [ 0, %22 ], [ %6, %3 ], [ -1, %17 ], [ -1, %12 ], [ -1, %8 ]
ret i32 %30
}