#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 uintmax_t;
typedef int uint64_t;

/* Variables and functions */
int UINT64_C(int);
int /*<<< orphan*/ gf2_matrix_square(int *, int *);
int gf2_matrix_times(int *, int);
uint64_t crc64_combine(uint64_t crc1, uint64_t crc2, uintmax_t len2) {
  unsigned n;
  uint64_t row;
  uint64_t even[64];
  uint64_t odd[64];
  if (len2 == 0)
    return crc1;
  odd[0] = UINT64_C(0xc96c5795d7870f42);
  row = 1;
  for (n = 1; n < 64; n++) {
    odd[n] = row;
    row <<= 1;
  }
  gf2_matrix_square(even, odd);
  gf2_matrix_square(odd, even);
  do {
    gf2_matrix_square(even, odd);
    if (len2 & 1)
      crc1 = gf2_matrix_times(even, crc1);
    len2 >>= 1;
    if (len2 == 0)
      break;
    gf2_matrix_square(odd, even);
    if (len2 & 1)
      crc1 = gf2_matrix_times(odd, crc1);
    len2 >>= 1;
  } while (len2 != 0);
  crc1 ^= crc2;
  return crc1;
}


x86 assembly (clang, -O0):
<crc64_combine>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1159 <crc64_combine+0x29>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    126d <crc64_combine+0x13d>
mov    $0xd7870f42,%edi
call   1040 <UINT64_C@plt>
mov    %eax,-0x220(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x40,-0x14(%rbp)
jae    11a5 <crc64_combine+0x75>
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%eax
mov    %ecx,-0x220(%rbp,%rax,4)
mov    -0x18(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1177 <crc64_combine+0x47>
lea    -0x120(%rbp),%rdi
lea    -0x220(%rbp),%rsi
call   1030 <gf2_matrix_square@plt>
lea    -0x220(%rbp),%rdi
lea    -0x120(%rbp),%rsi
call   1030 <gf2_matrix_square@plt>
lea    -0x120(%rbp),%rdi
lea    -0x220(%rbp),%rsi
call   1030 <gf2_matrix_square@plt>
mov    -0x10(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11ff <crc64_combine+0xcf>
lea    -0x120(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <gf2_matrix_times@plt>
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    1217 <crc64_combine+0xe7>
jmp    125e <crc64_combine+0x12e>
lea    -0x220(%rbp),%rdi
lea    -0x120(%rbp),%rsi
call   1030 <gf2_matrix_square@plt>
mov    -0x10(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     124b <crc64_combine+0x11b>
lea    -0x220(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <gf2_matrix_times@plt>
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
sar    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    11cb <crc64_combine+0x9b>
mov    -0xc(%rbp),%eax
xor    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crc64_combine>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x200,%rsp
mov    %edi,%ebx
test   %edx,%edx
je     1210 <crc64_combine+0xe0>
mov    %edx,%ebp
mov    %esi,%r14d
mov    $0xd7870f42,%edi
call   1040 <UINT64_C@plt>
mov    %eax,(%rsp)
mov    $0x1,%eax
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %eax,0x4(%rsp,%rcx,4)
lea    (%rax,%rax,1),%edx
mov    %edx,0x8(%rsp,%rcx,4)
lea    0x0(,%rax,4),%edx
mov    %edx,0xc(%rsp,%rcx,4)
shl    $0x3,%eax
add    $0x3,%rcx
cmp    $0x3f,%rcx
jne    1170 <crc64_combine+0x40>
lea    0x100(%rsp),%r15
mov    %rsp,%r12
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <gf2_matrix_square@plt>
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <gf2_matrix_square@plt>
jmp    11cc <crc64_combine+0x9c>
cs nopw 0x0(%rax,%rax,1)
mov    %ebp,%eax
sar    $0x2,%eax
cmp    $0x3,%ebp
mov    %eax,%ebp
jbe    120d <crc64_combine+0xdd>
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <gf2_matrix_square@plt>
test   $0x1,%bpl
je     11e9 <crc64_combine+0xb9>
mov    %r15,%rdi
mov    %ebx,%esi
call   1050 <gf2_matrix_times@plt>
mov    %eax,%ebx
cmp    $0x2,%ebp
jb     120d <crc64_combine+0xdd>
mov    %r12,%rdi
mov    %r15,%rsi
call   1030 <gf2_matrix_square@plt>
test   $0x2,%bpl
je     11c0 <crc64_combine+0x90>
mov    %r12,%rdi
mov    %ebx,%esi
call   1050 <gf2_matrix_times@plt>
mov    %eax,%ebx
jmp    11c0 <crc64_combine+0x90>
xor    %r14d,%ebx
mov    %ebx,%eax
add    $0x200,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @crc64_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
%10 = alloca [64 x i32]
%11 = alloca [64 x i32]
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%12 = load i32, i32* %7
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %3
%15 = load i32, i32* %5
store i32 %15, i32* %4
br label %78
16: ; preds = %3
%17 = call i32 @UINT64_C(i32 -679014590)
%18 = getelementptr inbounds [64 x i32], [64 x i32]* %11, i64 0, i64 0
store i32 %17, i32* %18
store i32 1, i32* %9
store i32 1, i32* %8
br label %19
19: ; preds = %29, %16
%20 = load i32, i32* %8
%21 = icmp ult i32 %20, 64
br i1 %21, label %22, label %32
22: ; preds = %19
%23 = load i32, i32* %9
%24 = load i32, i32* %8
%25 = zext i32 %24 to i64
%26 = getelementptr inbounds [64 x i32], [64 x i32]* %11, i64 0, i64 %25
store i32 %23, i32* %26
%27 = load i32, i32* %9
%28 = shl i32 %27, 1
store i32 %28, i32* %9
br label %29
29: ; preds = %22
%30 = load i32, i32* %8
%31 = add i32 %30, 1
store i32 %31, i32* %8
br label %19
32: ; preds = %19
%33 = getelementptr inbounds [64 x i32], [64 x i32]* %10, i64 0, i64 0
%34 = getelementptr inbounds [64 x i32], [64 x i32]* %11, i64 0, i64 0
%35 = call i32 @gf2_matrix_square(i32* %33, i32* %34)
%36 = getelementptr inbounds [64 x i32], [64 x i32]* %11, i64 0, i64 0
%37 = getelementptr inbounds [64 x i32], [64 x i32]* %10, i64 0, i64 0
%38 = call i32 @gf2_matrix_square(i32* %36, i32* %37)
br label %39
39: ; preds = %70, %32
%40 = getelementptr inbounds [64 x i32], [64 x i32]* %10, i64 0, i64 0
%41 = getelementptr inbounds [64 x i32], [64 x i32]* %11, i64 0, i64 0
%42 = call i32 @gf2_matrix_square(i32* %40, i32* %41)
%43 = load i32, i32* %7
%44 = and i32 %43, 1
%45 = icmp ne i32 %44, 0
br i1 %45, label %46, label %50
46: ; preds = %39
%47 = getelementptr inbounds [64 x i32], [64 x i32]* %10, i64 0, i64 0
%48 = load i32, i32* %5
%49 = call i32 @gf2_matrix_times(i32* %47, i32 %48)
store i32 %49, i32* %5
br label %50
50: ; preds = %46, %39
%51 = load i32, i32* %7
%52 = ashr i32 %51, 1
store i32 %52, i32* %7
%53 = load i32, i32* %7
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %56
55: ; preds = %50
br label %73
56: ; preds = %50
%57 = getelementptr inbounds [64 x i32], [64 x i32]* %11, i64 0, i64 0
%58 = getelementptr inbounds [64 x i32], [64 x i32]* %10, i64 0, i64 0
%59 = call i32 @gf2_matrix_square(i32* %57, i32* %58)
%60 = load i32, i32* %7
%61 = and i32 %60, 1
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %67
63: ; preds = %56
%64 = getelementptr inbounds [64 x i32], [64 x i32]* %11, i64 0, i64 0
%65 = load i32, i32* %5
%66 = call i32 @gf2_matrix_times(i32* %64, i32 %65)
store i32 %66, i32* %5
br label %67
67: ; preds = %63, %56
%68 = load i32, i32* %7
%69 = ashr i32 %68, 1
store i32 %69, i32* %7
br label %70
70: ; preds = %67
%71 = load i32, i32* %7
%72 = icmp ne i32 %71, 0
br i1 %72, label %39, label %73
73: ; preds = %70, %55
%74 = load i32, i32* %6
%75 = load i32, i32* %5
%76 = xor i32 %75, %74
store i32 %76, i32* %5
%77 = load i32, i32* %5
store i32 %77, i32* %4
br label %78
78: ; preds = %73, %14
%79 = load i32, i32* %4
ret i32 %79
}

LLVM IR (-O2):
define i32 @crc64_combine(i32 %0, i32 %1, i32 %2) {
%4 = alloca [64 x i32]
%5 = alloca [64 x i32]
%6 = bitcast [64 x i32]* %4 to i8*
%7 = bitcast [64 x i32]* %5 to i8*
%8 = icmp eq i32 %2, 0
br i1 %8, label %53, label %9
9: ; preds = %3
%10 = tail call i32 @UINT64_C(i32 -679014590)
%11 = getelementptr inbounds [64 x i32], [64 x i32]* %5, i64 0, i64 0
store i32 %10, i32* %11
br label %12
12: ; preds = %12, %9
%13 = phi i64 [ 1, %9 ], [ %23, %12 ]
%14 = phi i32 [ 1, %9 ], [ %22, %12 ]
%15 = getelementptr inbounds [64 x i32], [64 x i32]* %5, i64 0, i64 %13
store i32 %14, i32* %15
%16 = shl i32 %14, 1
%17 = add nuw nsw i64 %13, 1
%18 = getelementptr inbounds [64 x i32], [64 x i32]* %5, i64 0, i64 %17
store i32 %16, i32* %18
%19 = shl i32 %14, 2
%20 = add nuw nsw i64 %13, 2
%21 = getelementptr inbounds [64 x i32], [64 x i32]* %5, i64 0, i64 %20
store i32 %19, i32* %21
%22 = shl i32 %14, 3
%23 = add nuw nsw i64 %13, 3
%24 = icmp eq i64 %23, 64
br i1 %24, label %25, label %12
25: ; preds = %12
%26 = getelementptr inbounds [64 x i32], [64 x i32]* %4, i64 0, i64 0
%27 = call i32 @gf2_matrix_square(i32* %26, i32* %11)
%28 = call i32 @gf2_matrix_square(i32* %11, i32* %26)
br label %29
29: ; preds = %46, %25
%30 = phi i32 [ %0, %25 ], [ %47, %46 ]
%31 = phi i32 [ %2, %25 ], [ %48, %46 ]
%32 = call i32 @gf2_matrix_square(i32* %26, i32* %11)
%33 = and i32 %31, 1
%34 = icmp eq i32 %33, 0
br i1 %34, label %37, label %35
35: ; preds = %29
%36 = call i32 @gf2_matrix_times(i32* %26, i32 %30)
br label %37
37: ; preds = %35, %29
%38 = phi i32 [ %36, %35 ], [ %30, %29 ]
%39 = icmp ult i32 %31, 2
br i1 %39, label %50, label %40
40: ; preds = %37
%41 = call i32 @gf2_matrix_square(i32* %11, i32* %26)
%42 = and i32 %31, 2
%43 = icmp eq i32 %42, 0
br i1 %43, label %46, label %44
44: ; preds = %40
%45 = call i32 @gf2_matrix_times(i32* %11, i32 %38)
br label %46
46: ; preds = %44, %40
%47 = phi i32 [ %45, %44 ], [ %38, %40 ]
%48 = ashr i32 %31, 2
%49 = icmp ult i32 %31, 4
br i1 %49, label %50, label %29
50: ; preds = %37, %46
%51 = phi i32 [ %38, %37 ], [ %47, %46 ]
%52 = xor i32 %51, %1
br label %53
53: ; preds = %3, %50
%54 = phi i32 [ %52, %50 ], [ %0, %3 ]
ret i32 %54
}