#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*/ CalulateCRC(unsigned char *, int, unsigned char *);
unsigned char MFRC522_ToCard(int, unsigned char *, int, unsigned char *,
                             unsigned int *);
unsigned char MFRC522_Read(unsigned char blockAddr, unsigned char *recvData) {
  unsigned char status;
  unsigned int unLen;
  recvData[0] = 0x30;
  recvData[1] = blockAddr;
  CalulateCRC(recvData, 2, &recvData[2]);
  status = MFRC522_ToCard(0x0C, recvData, 4, recvData, &unLen);
  if ((status != 0) || (unLen != 0x90)) {
    status = 2;
  }
  return status;
}


x86 assembly (clang, -O0):
<MFRC522_Read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x30,(%rax)
mov    -0x1(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %cl,0x1(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x10(%rbp),%rdx
add    $0x2,%rdx
mov    $0x2,%esi
call   1040 <CalulateCRC@plt>
mov    -0x10(%rbp),%rsi
mov    -0x10(%rbp),%rcx
mov    $0xc,%edi
mov    $0x4,%edx
lea    -0x18(%rbp),%r8
call   1030 <MFRC522_ToCard@plt>
mov    %al,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
cmp    $0x0,%eax
jne    1191 <MFRC522_Read+0x71>
cmpl   $0x90,-0x18(%rbp)
je     1195 <MFRC522_Read+0x75>
movb   $0x2,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MFRC522_Read>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
movb   $0x30,(%rsi)
mov    %dil,0x1(%rsi)
lea    0x2(%rsi),%rdx
mov    $0x2,%ebp
mov    %rsi,%rdi
mov    $0x2,%esi
call   1040 <CalulateCRC@plt>
lea    0x4(%rsp),%r8
mov    $0xc,%edi
mov    %rbx,%rsi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1030 <MFRC522_ToCard@plt>
cmpl   $0x90,0x4(%rsp)
movzbl %al,%ecx
mov    %ecx,%eax
cmovne %ebp,%eax
test   %cl,%cl
cmovne %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define zeroext i8 @MFRC522_Read(i8 zeroext %0, i8* %1) {
%3 = alloca i8
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i32
store i8 %0, i8* %3
store i8* %1, i8** %4
%7 = load i8*, i8** %4
%8 = getelementptr inbounds i8, i8* %7, i64 0
store i8 48, i8* %8
%9 = load i8, i8* %3
%10 = load i8*, i8** %4
%11 = getelementptr inbounds i8, i8* %10, i64 1
store i8 %9, i8* %11
%12 = load i8*, i8** %4
%13 = load i8*, i8** %4
%14 = getelementptr inbounds i8, i8* %13, i64 2
%15 = call i32 @CalulateCRC(i8* %12, i32 2, i8* %14)
%16 = load i8*, i8** %4
%17 = load i8*, i8** %4
%18 = call zeroext i8 @MFRC522_ToCard(i32 12, i8* %16, i32 4, i8* %17, i32* %6)
store i8 %18, i8* %5
%19 = load i8, i8* %5
%20 = zext i8 %19 to i32
%21 = icmp ne i32 %20, 0
br i1 %21, label %25, label %22
22: ; preds = %2
%23 = load i32, i32* %6
%24 = icmp ne i32 %23, 144
br i1 %24, label %25, label %26
25: ; preds = %22, %2
store i8 2, i8* %5
br label %26
26: ; preds = %25, %22
%27 = load i8, i8* %5
ret i8 %27
}

LLVM IR (-O2):
define zeroext i8 @MFRC522_Read(i8 zeroext %0, i8* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i8 48, i8* %1
%5 = getelementptr inbounds i8, i8* %1, i64 1
store i8 %0, i8* %5
%6 = getelementptr inbounds i8, i8* %1, i64 2
%7 = tail call i32 @CalulateCRC(i8* %1, i32 2, i8* %6)
%8 = call zeroext i8 @MFRC522_ToCard(i32 12, i8* %1, i32 4, i8* %1, i32* %3)
%9 = icmp ne i8 %8, 0
%10 = load i32, i32* %3
%11 = icmp ne i32 %10, 144
%12 = select i1 %9, i1 true, i1 %11
%13 = select i1 %12, i8 2, i8 %8
ret i8 %13
}