#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*/ MFRC522_Clear_Bit(int, int);
char MFRC522_Rd(int);
int /*<<< orphan*/ MFRC522_Set_Bit(int, int);
int /*<<< orphan*/ MFRC522_Wr(int, int);
void MFRC522_CRC(char *dataIn, char length, char *dataOut) {
  char i, n;
  MFRC522_Clear_Bit(0x05, 0x04);
  MFRC522_Set_Bit(0x0A, 0x80);
  for (i = 0; i < length; i++) {
    MFRC522_Wr(0x09, *dataIn++);
  }
  MFRC522_Wr(0x01, 0x03);
  i = 0xFF;
  do {
    n = MFRC522_Rd(0x05);
    i--;
  } while (i && !(n & 0x04));
  dataOut[0] = MFRC522_Rd(0x22);
  dataOut[1] = MFRC522_Rd(0x21);
}


x86 assembly (clang, -O0):
<MFRC522_CRC>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x5,%edi
mov    $0x4,%esi
call   1040 <MFRC522_Clear_Bit@plt>
mov    $0xa,%edi
mov    $0x80,%esi
call   1030 <MFRC522_Set_Bit@plt>
movb   $0x0,-0x19(%rbp)
movsbl -0x19(%rbp),%eax
movsbl -0x9(%rbp),%ecx
cmp    %ecx,%eax
jge    11b1 <MFRC522_CRC+0x71>
mov    -0x8(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x8(%rbp)
movsbl (%rax),%esi
mov    $0x9,%edi
call   1050 <MFRC522_Wr@plt>
mov    -0x19(%rbp),%al
add    $0x1,%al
mov    %al,-0x19(%rbp)
jmp    1178 <MFRC522_CRC+0x38>
mov    $0x1,%edi
mov    $0x3,%esi
call   1050 <MFRC522_Wr@plt>
movb   $0xff,-0x19(%rbp)
mov    $0x5,%edi
call   1060 <MFRC522_Rd@plt>
mov    %al,-0x1a(%rbp)
mov    -0x19(%rbp),%al
add    $0xff,%al
mov    %al,-0x19(%rbp)
movsbl -0x19(%rbp),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1b(%rbp)
je     11fd <MFRC522_CRC+0xbd>
movsbl -0x1a(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
mov    %al,-0x1b(%rbp)
mov    -0x1b(%rbp),%al
test   $0x1,%al
jne    11c4 <MFRC522_CRC+0x84>
mov    $0x22,%edi
call   1060 <MFRC522_Rd@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    $0x21,%edi
call   1060 <MFRC522_Rd@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,0x1(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MFRC522_CRC>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %esi,%ebp
mov    %rdi,%r15
mov    $0x5,%edi
mov    $0x4,%esi
call   1040 <MFRC522_Clear_Bit@plt>
mov    $0xa,%edi
mov    $0x80,%esi
call   1030 <MFRC522_Set_Bit@plt>
test   %bpl,%bpl
jle    1198 <MFRC522_CRC+0x58>
movzbl %bpl,%ebp
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsbl (%r15,%rbx,1),%esi
mov    $0x9,%edi
call   1050 <MFRC522_Wr@plt>
add    $0x1,%rbx
cmp    %bl,%bpl
jne    1180 <MFRC522_CRC+0x40>
mov    $0x1,%edi
mov    $0x3,%esi
call   1050 <MFRC522_Wr@plt>
mov    $0x2,%bl
nopl   0x0(%rax)
mov    $0x5,%edi
call   1060 <MFRC522_Rd@plt>
test   %bl,%bl
je     11c7 <MFRC522_CRC+0x87>
and    $0x4,%al
add    $0x1,%bl
test   %al,%al
je     11b0 <MFRC522_CRC+0x70>
mov    $0x22,%edi
call   1060 <MFRC522_Rd@plt>
mov    %al,(%r14)
mov    $0x21,%edi
call   1060 <MFRC522_Rd@plt>
mov    %al,0x1(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @MFRC522_CRC(i8* nocapture %0, i8 signext %1, i8* nocapture writeonly %2) {
%4 = tail call i32 @MFRC522_Clear_Bit(i32 5, i32 4)
%5 = tail call i32 @MFRC522_Set_Bit(i32 10, i32 128)
%6 = icmp sgt i8 %1, 0
br i1 %6, label %7, label %16
7: ; preds = %3, %7
%8 = phi i8* [ %10, %7 ], [ %0, %3 ]
%9 = phi i8 [ %14, %7 ], [ 0, %3 ]
%10 = getelementptr inbounds i8, i8* %8, i64 1
%11 = load i8, i8* %8
%12 = sext i8 %11 to i32
%13 = tail call i32 @MFRC522_Wr(i32 9, i32 %12)
%14 = add nuw nsw i8 %9, 1
%15 = icmp eq i8 %14, %1
br i1 %15, label %16, label %7
16: ; preds = %7, %3
%17 = tail call i32 @MFRC522_Wr(i32 1, i32 3)
br label %18
18: ; preds = %18, %16
%19 = phi i8 [ -1, %16 ], [ %21, %18 ]
%20 = tail call signext i8 @MFRC522_Rd(i32 5)
%21 = add i8 %19, -1
%22 = icmp ne i8 %21, 0
%23 = and i8 %20, 4
%24 = icmp eq i8 %23, 0
%25 = select i1 %22, i1 %24, i1 false
br i1 %25, label %18, label %26
26: ; preds = %18
%27 = tail call signext i8 @MFRC522_Rd(i32 34)
store i8 %27, i8* %2
%28 = tail call signext i8 @MFRC522_Rd(i32 33)
%29 = getelementptr inbounds i8, i8* %2, i64 1
store i8 %28, i8* %29
ret void
}