#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*/ assert(int);
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) {
  assert(len2 < (1 << 29));
  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   $0x20000000,-0x10(%rbp)
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
cmpl   $0x0,-0x10(%rbp)
jg     116a <compute_crc32_combine+0x3a>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1273 <compute_crc32_combine+0x143>
cmpl   $0x0,0x2edf(%rip)
jne    121a <compute_crc32_combine+0xea>
movl   $0xedb88320,0x2edf(%rip)
83 b8 ed
movl   $0x0,-0x14(%rbp)
cmpl   $0x1f,-0x14(%rbp)
jge    11bd <compute_crc32_combine+0x8d>
mov    -0x14(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    -0x14(%rbp),%eax
add    $0x1,%eax
movslq %eax,%rcx
lea    0x2eb4(%rip),%rax
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1188 <compute_crc32_combine+0x58>
movl   $0x1,-0x14(%rbp)
cmpl   $0x20,-0x14(%rbp)
jge    1210 <compute_crc32_combine+0xe0>
mov    -0x14(%rbp),%eax
shl    $0x5,%eax
cltq
lea    0x2e83(%rip),%rdi
shl    $0x2,%rax
add    %rax,%rdi
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
shl    $0x5,%eax
cltq
lea    0x2e6a(%rip),%rsi
shl    $0x2,%rax
add    %rax,%rsi
call   1040 <gf32_matrix_square@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11c4 <compute_crc32_combine+0x94>
movl   $0x1,0x2e36(%rip)
lea    0x2e3f(%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     1257 <compute_crc32_combine+0x127>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <gf32_matrix_times@plt>
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    122b <compute_crc32_combine+0xfb>
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    %edx,%r12d
mov    %esi,%r14d
mov    %edi,%r15d
xor    %edi,%edi
cmp    $0x20000000,%edx
setl   %dil
call   1030 <assert@plt>
test   %r12d,%r12d
jle    122b <compute_crc32_combine+0xfb>
cmpb   $0x0,0x2eee(%rip)
jne    11ef <compute_crc32_combine+0xbf>
movl   $0xedb88320,0x2eee(%rip)
83 b8 ed
xor    %eax,%eax
lea    0x2ee5(%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     11c7 <compute_crc32_combine+0x97>
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,0x10(%rsi,%rax,4)
add    $0x1,%rcx
mov    %rcx,%rax
jmp    1180 <compute_crc32_combine+0x50>
mov    $0x1f,%ebp
nopl   0x0(%rax)
lea    0x80(%rsi),%rbx
mov    %rbx,%rdi
call   1040 <gf32_matrix_square@plt>
mov    %rbx,%rsi
add    $0xffffffffffffffff,%rbp
jne    11d0 <compute_crc32_combine+0xa0>
movb   $0x1,0x2e61(%rip)
lea    0x2fea(%rip),%rbx
jmp    1212 <compute_crc32_combine+0xe2>
nopl   0x0(%rax,%rax,1)
mov    %r12d,%eax
sar    %eax
sub    $0xffffffffffffff80,%rbx
cmp    $0x1,%r12d
mov    %eax,%r12d
jbe    1228 <compute_crc32_combine+0xf8>
test   $0x1,%r12b
je     1200 <compute_crc32_combine+0xd0>
mov    %rbx,%rdi
mov    %r15d,%esi
call   1050 <gf32_matrix_times@plt>
mov    %eax,%r15d
jmp    1200 <compute_crc32_combine+0xd0>
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 slt i32 %10, 536870912
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load i32, i32* %7
%15 = icmp sle i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %3
%17 = load i32, i32* %5
store i32 %17, i32* %4
br label %75
18: ; preds = %3
%19 = load i32, i32* @compute_crc32_combine.power_buf_initialized
%20 = icmp ne i32 %19, 0
br i1 %20, label %54, label %21
21: ; preds = %18
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 %22
22: ; preds = %32, %21
%23 = load i32, i32* %8
%24 = icmp slt i32 %23, 31
br i1 %24, label %25, label %35
25: ; preds = %22
%26 = load i32, i32* %8
%27 = shl i32 1, %26
%28 = load i32, i32* %8
%29 = add nsw i32 %28, 1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [1024 x i32], [1024 x i32]* @compute_crc32_combine.power_buf, i64 0, i64 %30
store i32 %27, i32* %31
br label %32
32: ; preds = %25
%33 = load i32, i32* %8
%34 = add nsw i32 %33, 1
store i32 %34, i32* %8
br label %22
35: ; preds = %22
store i32 1, i32* %8
br label %36
36: ; preds = %50, %35
%37 = load i32, i32* %8
%38 = icmp slt i32 %37, 32
br i1 %38, label %39, label %53
39: ; preds = %36
%40 = load i32, i32* %8
%41 = shl i32 %40, 5
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i32, i32* getelementptr inbounds ([1024 x i32], [1024 x i32]* @compute_crc32_combine.power_buf, i64 0, i64 0), i64 %42
%44 = load i32, i32* %8
%45 = sub nsw i32 %44, 1
%46 = shl i32 %45, 5
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i32, i32* getelementptr inbounds ([1024 x i32], [1024 x i32]* @compute_crc32_combine.power_buf, i64 0, i64 0), i64 %47
%49 = call i32 @gf32_matrix_square(i32* %43, i32* %48)
br label %50
50: ; preds = %39
%51 = load i32, i32* %8
%52 = add nsw i32 %51, 1
store i32 %52, i32* %8
br label %36
53: ; preds = %36
store i32 1, i32* @compute_crc32_combine.power_buf_initialized
br label %54
54: ; preds = %53, %18
store i32* getelementptr inbounds ([1024 x i32], [1024 x i32]* @compute_crc32_combine.power_buf, i64 0, i64 64), i32** %9
br label %55
55: ; preds = %68, %54
%56 = load i32*, i32** %9
%57 = getelementptr inbounds i32, i32* %56, i64 32
store i32* %57, i32** %9
%58 = load i32, i32* %7
%59 = and i32 %58, 1
%60 = icmp ne i32 %59, 0
br i1 %60, label %61, label %65
61: ; preds = %55
%62 = load i32*, i32** %9
%63 = load i32, i32* %5
%64 = call i32 @gf32_matrix_times(i32* %62, i32 %63)
store i32 %64, i32* %5
br label %65
65: ; preds = %61, %55
%66 = load i32, i32* %7
%67 = ashr i32 %66, 1
store i32 %67, i32* %7
br label %68
68: ; preds = %65
%69 = load i32, i32* %7
%70 = icmp ne i32 %69, 0
br i1 %70, label %55, label %71
71: ; preds = %68
%72 = load i32, i32* %5
%73 = load i32, i32* %6
%74 = xor i32 %72, %73
store i32 %74, i32* %4
br label %75
75: ; preds = %71, %16
%76 = load i32, i32* %4
ret i32 %76
}

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