#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*/ ComputeCrc14443(int, unsigned char const *, int,
                                   unsigned char *, unsigned char *);
int CheckCrc14443(int CrcType, const unsigned char *Data, int Length) {
  unsigned char b1;
  unsigned char b2;
  if (Length < 3)
    return 0;
  ComputeCrc14443(CrcType, Data, Length - 2, &b1, &b2);
  if ((b1 == Data[Length - 2]) && (b2 == Data[Length - 1]))
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<CheckCrc14443>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpl   $0x3,-0x14(%rbp)
jge    1138 <CheckCrc14443+0x28>
movl   $0x0,-0x4(%rbp)
jmp    119f <CheckCrc14443+0x8f>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
sub    $0x2,%edx
lea    -0x15(%rbp),%rcx
lea    -0x16(%rbp),%r8
call   1030 <ComputeCrc14443@plt>
movzbl -0x15(%rbp),%eax
mov    -0x10(%rbp),%rcx
mov    -0x14(%rbp),%edx
sub    $0x2,%edx
movslq %edx,%rdx
movzbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    1198 <CheckCrc14443+0x88>
movzbl -0x16(%rbp),%eax
mov    -0x10(%rbp),%rcx
mov    -0x14(%rbp),%edx
sub    $0x1,%edx
movslq %edx,%rdx
movzbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    1198 <CheckCrc14443+0x88>
movl   $0x1,-0x4(%rbp)
jmp    119f <CheckCrc14443+0x8f>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CheckCrc14443>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
cmp    $0x3,%edx
jl     1159 <CheckCrc14443+0x49>
mov    %edx,%ebx
mov    %rsi,%r14
lea    -0x2(%rbx),%r15d
lea    0xf(%rsp),%rcx
lea    0xe(%rsp),%r8
mov    %r15d,%edx
call   1030 <ComputeCrc14443@plt>
mov    0xf(%rsp),%al
cmp    (%r14,%r15,1),%al
jne    1157 <CheckCrc14443+0x47>
mov    0xe(%rsp),%cl
add    $0xffffffff,%ebx
mov    $0x1,%eax
cmp    (%r14,%rbx,1),%cl
je     1159 <CheckCrc14443+0x49>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i32 @CheckCrc14443(i32 %0, i8* %1, i32 %2) {
%4 = alloca i8
%5 = alloca i8
%6 = icmp slt i32 %2, 3
br i1 %6, label %23, label %7
7: ; preds = %3
%8 = add nsw i32 %2, -2
%9 = call i32 @ComputeCrc14443(i32 %0, i8* %1, i32 %8, i8* %4, i8* %5)
%10 = load i8, i8* %4
%11 = zext i32 %8 to i64
%12 = getelementptr inbounds i8, i8* %1, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %10, %13
br i1 %14, label %15, label %22
15: ; preds = %7
%16 = load i8, i8* %5
%17 = add nsw i32 %2, -1
%18 = zext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %1, i64 %18
%20 = load i8, i8* %19
%21 = icmp eq i8 %16, %20
br i1 %21, label %23, label %22
22: ; preds = %15, %7
br label %23
23: ; preds = %15, %3, %22
%24 = phi i32 [ 0, %22 ], [ 0, %3 ], [ 1, %15 ]
ret i32 %24
}