#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*/ gf32_matrix_square(unsigned int *, unsigned int *);
unsigned int gf32_matrix_times(unsigned int *, unsigned int);
unsigned compute_crc32_combine(unsigned crc1, unsigned crc2, int len2) {
  static int power_buf_initialized = 0;
  static unsigned power_buf[1024];
  int n;
  if (len2 <= 0) {
    return crc1;
  }
  if (!power_buf_initialized) {
    power_buf[0] = 0xedb88320UL;
    for (n = 0; n < 31; n++) {
      power_buf[n + 1] = 1U << n;
    }
    for (n = 1; n < 32; n++) {
      gf32_matrix_square(power_buf + (n << 5), power_buf + ((n - 1) << 5));
    }
    power_buf_initialized = 1;
  }
  unsigned int *p = power_buf + 64;
  do {
    p += 32;
    if (len2 & 1) {
      crc1 = gf32_matrix_times(p, crc1);
    }
    len2 >>= 1;
  } while (len2);
  return crc1 ^ crc2;
}


x86 assembly (clang, -O0):
<compute_crc32_combine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jg     1146 <compute_crc32_combine+0x26>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    124f <compute_crc32_combine+0x12f>
cmpl   $0x0,0x2ef3(%rip)
jne    11f6 <compute_crc32_combine+0xd6>
movl   $0xedb88320,0x2ef3(%rip)
83 b8 ed
movl   $0x0,-0x14(%rbp)
cmpl   $0x1f,-0x14(%rbp)
jge    1199 <compute_crc32_combine+0x79>
mov    -0x14(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    -0x14(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rcx
lea    0x2ec8(%rip),%rax
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1164 <compute_crc32_combine+0x44>
movl   $0x1,-0x14(%rbp)
cmpl   $0x20,-0x14(%rbp)
jge    11ec <compute_crc32_combine+0xcc>
mov    -0x14(%rbp),%eax
shl    $0x5,%eax
cltq
lea    0x2e97(%rip),%rdi
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
shl    $0x5,%eax
cltq
lea    0x2e7e(%rip),%rsi
shl    $0x2,%rax
add    %rax,%rsi
call   1030 <gf32_matrix_square@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11a0 <compute_crc32_combine+0x80>
movl   $0x1,0x2e4a(%rip)
lea    0x2e53(%rip),%rax
add    $0x100,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x80,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     1233 <compute_crc32_combine+0x113>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1040 <gf32_matrix_times@plt>
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1207 <compute_crc32_combine+0xe7>
mov    -0x8(%rbp),%eax
xor    -0xc(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute_crc32_combine>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r15d
test   %edx,%edx
jle    1208 <compute_crc32_combine+0xe8>
mov    %edx,%ebp
mov    %esi,%r14d
cmpb   $0x0,0x2f01(%rip)
jne    11cf <compute_crc32_combine+0xaf>
movl   $0xedb88320,0x2f01(%rip)
83 b8 ed
xor    %eax,%eax
lea    0x2ef8(%rip),%rsi
nopl   0x0(%rax,%rax,1)
mov    $0x1,%edx
mov    %eax,%ecx
shl    %cl,%edx
mov    %edx,0x4(%rsi,%rax,4)
lea    0x1(%rax),%ecx
mov    $0x1,%edx
shl    %cl,%edx
lea    0x2(%rax),%ecx
mov    $0x1,%edi
shl    %cl,%edi
mov    %edx,0x8(%rsi,%rax,4)
mov    %edi,0xc(%rsi,%rax,4)
lea    0x3(%rax),%rcx
cmp    $0x1f,%rcx
je     11a7 <compute_crc32_combine+0x87>
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,0x10(%rsi,%rax,4)
add    $0x1,%rcx
mov    %rcx,%rax
jmp    1160 <compute_crc32_combine+0x40>
mov    $0x1f,%ebx
nopl   0x0(%rax)
lea    0x80(%rsi),%r12
mov    %r12,%rdi
call   1030 <gf32_matrix_square@plt>
mov    %r12,%rsi
add    $0xffffffffffffffff,%rbx
jne    11b0 <compute_crc32_combine+0x90>
movb   $0x1,0x2e71(%rip)
lea    0x2ffa(%rip),%rbx
jmp    11ef <compute_crc32_combine+0xcf>
nopl   0x0(%rax,%rax,1)
mov    %ebp,%eax
sar    %eax
sub    $0xffffffffffffff80,%rbx
cmp    $0x1,%ebp
mov    %eax,%ebp
jbe    1205 <compute_crc32_combine+0xe5>
test   $0x1,%bpl
je     11e0 <compute_crc32_combine+0xc0>
mov    %rbx,%rdi
mov    %r15d,%esi
call   1040 <gf32_matrix_times@plt>
mov    %eax,%r15d
jmp    11e0 <compute_crc32_combine+0xc0>
xor    %r14d,%r15d
mov    %r15d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@compute_crc32_combine.power_buf_initialized = internal global i32 0
@compute_crc32_combine.power_buf = internal global [1024 x i32] zeroinitializer
define i32 @compute_crc32_combine(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%10 = load i32, i32* %7
%11 = icmp sle i32 %10, 0
br i1 %11, label %12, label %14
12: ; preds = %3
%13 = load i32, i32* %5
store i32 %13, i32* %4
br label %71
14: ; preds = %3
%15 = load i32, i32* @compute_crc32_combine.power_buf_initialized
%16 = icmp ne i32 %15, 0
br i1 %16, label %50, label %17
17: ; preds = %14
store i32 -306674912, i32* getelementptr inbounds ([1024 x i32], [1024 x i32]* @compute_crc32_combine.power_buf, i64 0, i64 0)
store i32 0, i32* %8
br label %18
18: ; preds = %28, %17
%19 = load i32, i32* %8
%20 = icmp slt i32 %19, 31
br i1 %20, label %21, label %31
21: ; preds = %18
%22 = load i32, i32* %8
%23 = shl i32 1, %22
%24 = load i32, i32* %8
%25 = add nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds [1024 x i32], [1024 x i32]* @compute_crc32_combine.power_buf, i64 0, i64 %26
store i32 %23, i32* %27
br label %28
28: ; preds = %21
%29 = load i32, i32* %8
%30 = add nsw i32 %29, 1
store i32 %30, i32* %8
br label %18
31: ; preds = %18
store i32 1, i32* %8
br label %32
32: ; preds = %46, %31
%33 = load i32, i32* %8
%34 = icmp slt i32 %33, 32
br i1 %34, label %35, label %49
35: ; preds = %32
%36 = load i32, i32* %8
%37 = shl i32 %36, 5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* getelementptr inbounds ([1024 x i32], [1024 x i32]* @compute_crc32_combine.power_buf, i64 0, i64 0), i64 %38
%40 = load i32, i32* %8
%41 = sub nsw i32 %40, 1
%42 = shl i32 %41, 5
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i32, i32* getelementptr inbounds ([1024 x i32], [1024 x i32]* @compute_crc32_combine.power_buf, i64 0, i64 0), i64 %43
%45 = call i32 @gf32_matrix_square(i32* %39, i32* %44)
br label %46
46: ; preds = %35
%47 = load i32, i32* %8
%48 = add nsw i32 %47, 1
store i32 %48, i32* %8
br label %32
49: ; preds = %32
store i32 1, i32* @compute_crc32_combine.power_buf_initialized
br label %50
50: ; preds = %49, %14
store i32* getelementptr inbounds ([1024 x i32], [1024 x i32]* @compute_crc32_combine.power_buf, i64 0, i64 64), i32** %9
br label %51
51: ; preds = %64, %50
%52 = load i32*, i32** %9
%53 = getelementptr inbounds i32, i32* %52, i64 32
store i32* %53, i32** %9
%54 = load i32, i32* %7
%55 = and i32 %54, 1
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %61
57: ; preds = %51
%58 = load i32*, i32** %9
%59 = load i32, i32* %5
%60 = call i32 @gf32_matrix_times(i32* %58, i32 %59)
store i32 %60, i32* %5
br label %61
61: ; preds = %57, %51
%62 = load i32, i32* %7
%63 = ashr i32 %62, 1
store i32 %63, i32* %7
br label %64
64: ; preds = %61
%65 = load i32, i32* %7
%66 = icmp ne i32 %65, 0
br i1 %66, label %51, label %67
67: ; preds = %64
%68 = load i32, i32* %5
%69 = load i32, i32* %6
%70 = xor i32 %68, %69
store i32 %70, i32* %4
br label %71
71: ; preds = %67, %12
%72 = load i32, i32* %4
ret i32 %72
}

LLVM IR (-O2):
@compute_crc32_combine.power_buf_initialized = internal unnamed_addr global i1 false
@compute_crc32_combine.power_buf = internal global [1024 x i32] zeroinitializer
define i32 @compute_crc32_combine(i32 %0, i32 %1, i32 %2) {
%4 = icmp slt i32 %2, 1
br i1 %4, label %54, label %5
5: ; preds = %3
%6 = load i1, i1* @compute_crc32_combine.power_buf_initialized
br i1 %6, label %38, label %7
7: ; preds = %5
store i32 -306674912, i32* getelementptr inbounds ([1024 x i32], [1024 x i32]* @compute_crc32_combine.power_buf, i64 0, i64 0)
br label %8
8: ; preds = %23, %7
%9 = phi i64 [ 0, %7 ], [ %26, %23 ]
%10 = trunc i64 %9 to i32
%11 = shl nuw nsw i32 1, %10
%12 = or i64 %9, 1
%13 = getelementptr inbounds [1024 x i32], [1024 x i32]* @compute_crc32_combine.power_buf, i64 0, i64 %12
store i32 %11, i32* %13
%14 = trunc i64 %12 to i32
%15 = shl nuw nsw i32 1, %14
%16 = or i64 %9, 2
%17 = getelementptr inbounds [1024 x i32], [1024 x i32]* @compute_crc32_combine.power_buf, i64 0, i64 %16
store i32 %15, i32* %17
%18 = trunc i64 %16 to i32
%19 = shl nuw nsw i32 1, %18
%20 = or i64 %9, 3
%21 = getelementptr inbounds [1024 x i32], [1024 x i32]* @compute_crc32_combine.power_buf, i64 0, i64 %20
store i32 %19, i32* %21
%22 = icmp eq i64 %20, 31
br i1 %22, label %28, label %23
23: ; preds = %8
%24 = trunc i64 %20 to i32
%25 = shl nuw nsw i32 1, %24
%26 = add nuw nsw i64 %9, 4
%27 = getelementptr inbounds [1024 x i32], [1024 x i32]* @compute_crc32_combine.power_buf, i64 0, i64 %26
store i32 %25, i32* %27
br label %8
28: ; preds = %8, %28
%29 = phi i64 [ %35, %28 ], [ 1, %8 ]
%30 = shl nuw nsw i64 %29, 5
%31 = getelementptr inbounds [1024 x i32], [1024 x i32]* @compute_crc32_combine.power_buf, i64 0, i64 %30
%32 = add nsw i64 %30, -32
%33 = getelementptr inbounds [1024 x i32], [1024 x i32]* @compute_crc32_combine.power_buf, i64 0, i64 %32
%34 = tail call i32 @gf32_matrix_square(i32* %31, i32* %33)
%35 = add nuw nsw i64 %29, 1
%36 = icmp eq i64 %35, 32
br i1 %36, label %37, label %28
37: ; preds = %28
store i1 true, i1* @compute_crc32_combine.power_buf_initialized
br label %38
38: ; preds = %37, %5
br label %39
39: ; preds = %38, %48
%40 = phi i32 [ %49, %48 ], [ %0, %38 ]
%41 = phi i32 [ %50, %48 ], [ %2, %38 ]
%42 = phi i32* [ %43, %48 ], [ getelementptr inbounds ([1024 x i32], [1024 x i32]* @compute_crc32_combine.power_buf, i64 0, i64 64), %38 ]
%43 = getelementptr inbounds i32, i32* %42, i64 32
%44 = and i32 %41, 1
%45 = icmp eq i32 %44, 0
br i1 %45, label %48, label %46
46: ; preds = %39
%47 = tail call i32 @gf32_matrix_times(i32* %43, i32 %40)
br label %48
48: ; preds = %46, %39
%49 = phi i32 [ %47, %46 ], [ %40, %39 ]
%50 = ashr i32 %41, 1
%51 = icmp ult i32 %41, 2
br i1 %51, label %52, label %39
52: ; preds = %48
%53 = xor i32 %49, %1
br label %54
54: ; preds = %3, %52
%55 = phi i32 [ %53, %52 ], [ %0, %3 ]
ret i32 %55
}