#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 */
typedef unsigned char const crc;

/* Variables and functions */
unsigned long calc_crc_osdep(unsigned char const *, size_t);
int check_crc_buf_osdep(const unsigned char *buf, size_t len) {
  unsigned long crc;
  crc = calc_crc_osdep(buf, len);
  buf += len;
  if (((crc)&0xFF) == buf[0] && ((crc >> 8) & 0xFF) == buf[1] &&
      ((crc >> 16) & 0xFF) == buf[2] && ((crc >> 24) & 0xFF) == buf[3])
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<check_crc_buf_osdep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <calc_crc_osdep@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x20(%rbp),%rax
and    $0xff,%rax
mov    -0x10(%rbp),%rcx
movzbl (%rcx),%ecx
cmp    %rcx,%rax
jne    11c0 <check_crc_buf_osdep+0xb0>
mov    -0x20(%rbp),%rax
shr    $0x8,%rax
and    $0xff,%rax
mov    -0x10(%rbp),%rcx
movzbl 0x1(%rcx),%ecx
cmp    %rcx,%rax
jne    11c0 <check_crc_buf_osdep+0xb0>
mov    -0x20(%rbp),%rax
shr    $0x10,%rax
and    $0xff,%rax
mov    -0x10(%rbp),%rcx
movzbl 0x2(%rcx),%ecx
cmp    %rcx,%rax
jne    11c0 <check_crc_buf_osdep+0xb0>
mov    -0x20(%rbp),%rax
shr    $0x18,%rax
and    $0xff,%rax
mov    -0x10(%rbp),%rcx
movzbl 0x3(%rcx),%ecx
cmp    %rcx,%rax
jne    11c0 <check_crc_buf_osdep+0xb0>
movl   $0x0,-0x4(%rbp)
jmp    11c7 <check_crc_buf_osdep+0xb7>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_crc_buf_osdep>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <calc_crc_osdep@plt>
cmp    %al,(%rbx,%r14,1)
jne    114e <check_crc_buf_osdep+0x3e>
mov    %rax,%rcx
shr    $0x8,%rcx
cmp    %cl,0x1(%rbx,%r14,1)
jne    114e <check_crc_buf_osdep+0x3e>
mov    %rax,%rcx
shr    $0x10,%rcx
cmp    %cl,0x2(%rbx,%r14,1)
jne    114e <check_crc_buf_osdep+0x3e>
shr    $0x18,%rax
xor    %ecx,%ecx
cmp    %al,0x3(%rbx,%r14,1)
je     1153 <check_crc_buf_osdep+0x43>
mov    $0x1,%ecx
mov    %ecx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i32 @check_crc_buf_osdep(i8* %0, i64 %1) {
%3 = tail call i64 @calc_crc_osdep(i8* %0, i64 %1)
%4 = getelementptr inbounds i8, i8* %0, i64 %1
%5 = load i8, i8* %4
%6 = trunc i64 %3 to i8
%7 = icmp eq i8 %5, %6
br i1 %7, label %8, label %26
8: ; preds = %2
%9 = lshr i64 %3, 8
%10 = getelementptr inbounds i8, i8* %4, i64 1
%11 = load i8, i8* %10
%12 = trunc i64 %9 to i8
%13 = icmp eq i8 %11, %12
br i1 %13, label %14, label %26
14: ; preds = %8
%15 = lshr i64 %3, 16
%16 = getelementptr inbounds i8, i8* %4, i64 2
%17 = load i8, i8* %16
%18 = trunc i64 %15 to i8
%19 = icmp eq i8 %17, %18
br i1 %19, label %20, label %26
20: ; preds = %14
%21 = lshr i64 %3, 24
%22 = getelementptr inbounds i8, i8* %4, i64 3
%23 = load i8, i8* %22
%24 = trunc i64 %21 to i8
%25 = icmp eq i8 %23, %24
br i1 %25, label %27, label %26
26: ; preds = %20, %14, %8, %2
br label %27
27: ; preds = %20, %26
%28 = phi i32 [ 1, %26 ], [ 0, %20 ]
ret i32 %28
}