#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 int /*<<< orphan*/ test;

/* Variables and functions */
int crc32(unsigned char const *, int);
int test_crc32() {
  unsigned long test[256], i;
  for (i = 0; i < 256; i++)
    test[i] = i;
  if (crc32((const unsigned char *)test, sizeof(test)) != 0xf0e359bb)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<test_crc32>:
push   %rbp
mov    %rsp,%rbp
sub    $0x820,%rsp
movq   $0x0,-0x818(%rbp)
cmpq   $0x100,-0x818(%rbp)
jae    1164 <test_crc32+0x54>
mov    -0x818(%rbp),%rcx
mov    -0x818(%rbp),%rax
mov    %rcx,-0x810(%rbp,%rax,8)
ff
mov    -0x818(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x818(%rbp)
jmp    1126 <test_crc32+0x16>
lea    -0x810(%rbp),%rdi
mov    $0x800,%esi
call   1030 <crc32@plt>
cmp    $0xf0e359bb,%eax
je     118c <test_crc32+0x7c>
movl   $0x0,-0x4(%rbp)
jmp    1193 <test_crc32+0x83>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x820,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_crc32>:
sub    $0x808,%rsp
movdqa 0xee1(%rip),%xmm0
xor    %eax,%eax
movdqa 0xee6(%rip),%xmm8
movdqa 0xeed(%rip),%xmm9
movdqa 0xef4(%rip),%xmm10
movdqa 0xefc(%rip),%xmm4
movdqa 0xf04(%rip),%xmm5
movdqa 0xf0c(%rip),%xmm6
movdqa 0xf14(%rip),%xmm7
movdqa 0xf1c(%rip),%xmm1
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movdqa %xmm0,%xmm2
paddq  %xmm8,%xmm2
movdqa %xmm0,(%rsp,%rax,8)
movdqa %xmm2,0x10(%rsp,%rax,8)
movdqa %xmm0,%xmm2
paddq  %xmm9,%xmm2
movdqa %xmm0,%xmm3
paddq  %xmm10,%xmm3
movdqa %xmm2,0x20(%rsp,%rax,8)
movdqa %xmm3,0x30(%rsp,%rax,8)
movdqa %xmm0,%xmm2
paddq  %xmm4,%xmm2
movdqa %xmm0,%xmm3
paddq  %xmm5,%xmm3
movdqa %xmm2,0x40(%rsp,%rax,8)
movdqa %xmm3,0x50(%rsp,%rax,8)
movdqa %xmm0,%xmm2
paddq  %xmm6,%xmm2
movdqa %xmm0,%xmm3
paddq  %xmm7,%xmm3
movdqa %xmm2,0x60(%rsp,%rax,8)
movdqa %xmm3,0x70(%rsp,%rax,8)
add    $0x10,%rax
paddq  %xmm1,%xmm0
cmp    $0x100,%rax
jne    1170 <test_crc32+0x60>
mov    %rsp,%rdi
mov    $0x800,%esi
call   1030 <crc32@plt>
xor    %ecx,%ecx
cmp    $0xf0e359bb,%eax
sete   %cl
mov    %ecx,%eax
add    $0x808,%rsp
ret

LLVM IR (-O0):
define i32 @test_crc32() {
%1 = alloca i32
%2 = alloca [256 x i64]
%3 = alloca i64
store i64 0, i64* %3
br label %4
4: ; preds = %11, %0
%5 = load i64, i64* %3
%6 = icmp ult i64 %5, 256
br i1 %6, label %7, label %14
7: ; preds = %4
%8 = load i64, i64* %3
%9 = load i64, i64* %3
%10 = getelementptr inbounds [256 x i64], [256 x i64]* %2, i64 0, i64 %9
store i64 %8, i64* %10
br label %11
11: ; preds = %7
%12 = load i64, i64* %3
%13 = add i64 %12, 1
store i64 %13, i64* %3
br label %4
14: ; preds = %4
%15 = getelementptr inbounds [256 x i64], [256 x i64]* %2, i64 0, i64 0
%16 = bitcast i64* %15 to i8*
%17 = call i32 @crc32(i8* %16, i32 2048)
%18 = icmp ne i32 %17, -253535813
br i1 %18, label %19, label %20
19: ; preds = %14
store i32 0, i32* %1
br label %21
20: ; preds = %14
store i32 1, i32* %1
br label %21
21: ; preds = %20, %19
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
define i32 @test_crc32() {
%1 = alloca [256 x i64]
%2 = bitcast [256 x i64]* %1 to i8*
br label %3
3: ; preds = %3, %0
%4 = phi i64 [ 0, %0 ], [ %32, %3 ]
%5 = phi <2 x i64> [ <i64 0, i64 1>, %0 ], [ %33, %3 ]
%6 = add <2 x i64> %5, <i64 2, i64 2>
%7 = getelementptr inbounds [256 x i64], [256 x i64]* %1, i64 0, i64 %4
%8 = bitcast i64* %7 to <2 x i64>*
store <2 x i64> %5, <2 x i64>* %8
%9 = getelementptr inbounds i64, i64* %7, i64 2
%10 = bitcast i64* %9 to <2 x i64>*
store <2 x i64> %6, <2 x i64>* %10
%11 = or i64 %4, 4
%12 = add <2 x i64> %5, <i64 4, i64 4>
%13 = add <2 x i64> %5, <i64 6, i64 6>
%14 = getelementptr inbounds [256 x i64], [256 x i64]* %1, i64 0, i64 %11
%15 = bitcast i64* %14 to <2 x i64>*
store <2 x i64> %12, <2 x i64>* %15
%16 = getelementptr inbounds i64, i64* %14, i64 2
%17 = bitcast i64* %16 to <2 x i64>*
store <2 x i64> %13, <2 x i64>* %17
%18 = or i64 %4, 8
%19 = add <2 x i64> %5, <i64 8, i64 8>
%20 = add <2 x i64> %5, <i64 10, i64 10>
%21 = getelementptr inbounds [256 x i64], [256 x i64]* %1, i64 0, i64 %18
%22 = bitcast i64* %21 to <2 x i64>*
store <2 x i64> %19, <2 x i64>* %22
%23 = getelementptr inbounds i64, i64* %21, i64 2
%24 = bitcast i64* %23 to <2 x i64>*
store <2 x i64> %20, <2 x i64>* %24
%25 = or i64 %4, 12
%26 = add <2 x i64> %5, <i64 12, i64 12>
%27 = add <2 x i64> %5, <i64 14, i64 14>
%28 = getelementptr inbounds [256 x i64], [256 x i64]* %1, i64 0, i64 %25
%29 = bitcast i64* %28 to <2 x i64>*
store <2 x i64> %26, <2 x i64>* %29
%30 = getelementptr inbounds i64, i64* %28, i64 2
%31 = bitcast i64* %30 to <2 x i64>*
store <2 x i64> %27, <2 x i64>* %31
%32 = add nuw nsw i64 %4, 16
%33 = add <2 x i64> %5, <i64 16, i64 16>
%34 = icmp eq i64 %32, 256
br i1 %34, label %35, label %3
35: ; preds = %3
%36 = call i32 @crc32(i8* %2, i32 2048)
%37 = icmp eq i32 %36, -253535813
%38 = zext i1 %37 to i32
ret i32 %38
}