#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 */
unsigned char MFRC522_ToCard(int, unsigned char *, int, unsigned char *,
                             unsigned int *);
int /*<<< orphan*/ Write_MFRC522(int, int);
unsigned char MFRC522_Request(unsigned char reqMode, unsigned char *TagType) {
  unsigned char status;
  unsigned int backBits;
  Write_MFRC522(0x0D, 0x07);
  TagType[0] = reqMode;
  status = MFRC522_ToCard(0x0C, TagType, 1, TagType, &backBits);
  if ((status != 0) || (backBits != 0x10)) {
    status = 2;
  }
  return status;
}


x86 assembly (clang, -O0):
<MFRC522_Request>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0xd,%edi
mov    $0x7,%esi
call   1040 <Write_MFRC522@plt>
mov    -0x1(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x10(%rbp),%rsi
mov    -0x10(%rbp),%rcx
mov    $0xc,%edi
mov    $0x1,%edx
lea    -0x18(%rbp),%r8
call   1030 <MFRC522_ToCard@plt>
mov    %al,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
cmp    $0x0,%eax
jne    117f <MFRC522_Request+0x5f>
cmpl   $0x10,-0x18(%rbp)
je     1183 <MFRC522_Request+0x63>
movb   $0x2,-0x11(%rbp)
movzbl -0x11(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MFRC522_Request>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0xd,%edi
mov    $0x7,%esi
call   1040 <Write_MFRC522@plt>
mov    %bpl,(%rbx)
lea    0x4(%rsp),%r8
mov    $0xc,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1030 <MFRC522_ToCard@plt>
cmpl   $0x10,0x4(%rsp)
movzbl %al,%ecx
mov    $0x2,%edx
mov    %ecx,%eax
cmovne %edx,%eax
test   %cl,%cl
cmovne %edx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define zeroext i8 @MFRC522_Request(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 = call i32 @Write_MFRC522(i32 13, i32 7)
%8 = load i8, i8* %3
%9 = load i8*, i8** %4
%10 = getelementptr inbounds i8, i8* %9, i64 0
store i8 %8, i8* %10
%11 = load i8*, i8** %4
%12 = load i8*, i8** %4
%13 = call zeroext i8 @MFRC522_ToCard(i32 12, i8* %11, i32 1, i8* %12, i32* %6)
store i8 %13, i8* %5
%14 = load i8, i8* %5
%15 = zext i8 %14 to i32
%16 = icmp ne i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %2
%18 = load i32, i32* %6
%19 = icmp ne i32 %18, 16
br i1 %19, label %20, label %21
20: ; preds = %17, %2
store i8 2, i8* %5
br label %21
21: ; preds = %20, %17
%22 = load i8, i8* %5
ret i8 %22
}

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