#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 nRF24L01P_getStatusRegister();
int /*<<< orphan*/ printf(char *, int);
int nRF24L01P_readable(int pipe) {
  int status;
  if ((pipe < 0) || (pipe > 5)) {
    printf("nRF24L01P: Invalid readable pipe number %d\r\n", pipe);
    return 0;
  }
  status = nRF24L01P_getStatusRegister();
  return ((status & (1 << 6)) &&
          (((status & (0x7 << 1)) >> 1) == (pipe & 0x7)));
}


x86 assembly (clang, -O0):
<nRF24L01P_readable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jl     113f <nRF24L01P_readable+0x1f>
cmpl   $0x5,-0x8(%rbp)
jle    115a <nRF24L01P_readable+0x3a>
mov    -0x8(%rbp),%esi
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    119a <nRF24L01P_readable+0x7a>
mov    $0x0,%al
call   1040 <nRF24L01P_getStatusRegister@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
and    $0x40,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0xd(%rbp)
je     118f <nRF24L01P_readable+0x6f>
mov    -0xc(%rbp),%eax
and    $0xe,%eax
sar    $0x1,%eax
mov    -0x8(%rbp),%ecx
and    $0x7,%ecx
cmp    %ecx,%eax
sete   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nRF24L01P_readable>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
cmp    $0x6,%edi
jb     113c <nRF24L01P_readable+0x1c>
lea    0xecf(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %ebp,%ebp
jmp    1155 <nRF24L01P_readable+0x35>
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <nRF24L01P_getStatusRegister@plt>
test   $0x40,%al
je     1155 <nRF24L01P_readable+0x35>
shr    %eax
xor    %ebx,%eax
xor    %ebp,%ebp
test   $0x7,%al
sete   %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [45 x i8] c"nRF24L01P: Invalid readable pipe number %d\0D\0A\00"
define i32 @nRF24L01P_readable(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %1
%8 = load i32, i32* %3
%9 = icmp sgt i32 %8, 5
br i1 %9, label %10, label %13
10: ; preds = %7, %1
%11 = load i32, i32* %3
%12 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 %11)
store i32 0, i32* %2
br label %28
13: ; preds = %7
%14 = call i32 (...) @nRF24L01P_getStatusRegister()
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = and i32 %15, 64
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %25
18: ; preds = %13
%19 = load i32, i32* %4
%20 = and i32 %19, 14
%21 = ashr i32 %20, 1
%22 = load i32, i32* %3
%23 = and i32 %22, 7
%24 = icmp eq i32 %21, %23
br label %25
25: ; preds = %18, %13
%26 = phi i1 [ false, %13 ], [ %24, %18 ]
%27 = zext i1 %26 to i32
store i32 %27, i32* %2
br label %28
28: ; preds = %25, %10
%29 = load i32, i32* %2
ret i32 %29
}

LLVM IR (-O2):
@.str = [45 x i8] c"nRF24L01P: Invalid readable pipe number %d\0D\0A\00"
define i32 @nRF24L01P_readable(i32 %0) {
%2 = icmp ugt i32 %0, 5
br i1 %2, label %3, label %5
3: ; preds = %1
%4 = tail call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %15
5: ; preds = %1
%6 = tail call i32 (...) @nRF24L01P_getStatusRegister()
%7 = and i32 %6, 64
%8 = icmp eq i32 %7, 0
br i1 %8, label %15, label %9
9: ; preds = %5
%10 = lshr i32 %6, 1
%11 = xor i32 %10, %0
%12 = and i32 %11, 7
%13 = icmp eq i32 %12, 0
%14 = zext i1 %13 to i32
br label %15
15: ; preds = %5, %9, %3
%16 = phi i32 [ 0, %3 ], [ 0, %5 ], [ %14, %9 ]
ret i32 %16
}