// File: /workspace/github_cpp_makefile_star2_O3/tomfunkhouser[P]gaps/pkgs/png/crc32.c
// Function: crc32_combine_
local uLong crc32_combine_(crc1, crc2, len2)
    uLong crc1;
    uLong crc2;
    z_off64_t len2;
{
    int n;
    unsigned long row;
    unsigned long even[GF2_DIM];    /* even-power-of-two zeros operator */
    unsigned long odd[GF2_DIM];     /* odd-power-of-two zeros operator */

    /* degenerate case (also disallow negative lengths) */
    if (len2 <= 0)
        return crc1;

    /* put operator for one zero bit in odd */
    odd[0] = 0xedb88320UL;          /* CRC-32 polynomial */
    row = 1;
    for (n = 1; n < GF2_DIM; n++) {
        odd[n] = row;
        row <<= 1;
    }

    /* put operator for two zero bits in even */
    gf2_matrix_square(even, odd);

    /* put operator for four zero bits in odd */
    gf2_matrix_square(odd, even);

    /* apply len2 zeros to crc1 (first square will put the operator for one
       zero byte, eight zero bits, in even) */
    do {
        /* apply zeros operator for this bit of len2 */
        gf2_matrix_square(even, odd);
        if (len2 & 1)
            crc1 = gf2_matrix_times(even, crc1);
        len2 >>= 1;

        /* if no more bits set, then done */
        if (len2 == 0)
            break;

        /* another iteration of the loop with odd and even swapped */
        gf2_matrix_square(odd, even);
        if (len2 & 1)
            crc1 = gf2_matrix_times(odd, crc1);
        len2 >>= 1;

        /* if no more bits set, then done */
    } while (len2 != 0);

    /* return combined crc */
    crc1 ^= crc2;
    return crc1;
}

// Assembly:
movq %rdi, %rax
testq %rdx, %rdx
jle 0x927c5
pushq %r14
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movl $0xedb88320, %ecx       # imm = 0xEDB88320
movq %rcx, -0x80(%rsp)
movl $0x1, %ecx
movl $0x1, %edi
movq %rdi, -0x80(%rsp,%rcx,8)
addq %rdi, %rdi
incq %rcx
cmpq $0x20, %rcx
jne 0x9260d
xorl %ecx, %ecx
leaq -0x80(%rsp), %rdi
movq -0x80(%rsp,%rcx,8), %r9
xorl %r8d, %r8d
testq %r9, %r9
je 0x92651
movq %rdi, %r10
testb $0x1, %r9b
je 0x9263e
xorq (%r10), %r8
movq %r9, %r11
shrq %r11
addq $0x8, %r10
cmpq $0x1, %r9
movq %r11, %r9
ja 0x92635
movq %r8, 0x80(%rsp,%rcx,8)
incq %rcx
cmpq $0x20, %rcx
jne 0x92625
xorl %ecx, %ecx
leaq 0x80(%rsp), %rdi
movq 0x80(%rsp,%rcx,8), %r9
xorl %r8d, %r8d
testq %r9, %r9
je 0x9269b
movq %rdi, %r10
testb $0x1, %r9b
je 0x92688
xorq (%r10), %r8
movq %r9, %r11
shrq %r11
addq $0x8, %r10
cmpq $0x1, %r9
movq %r11, %r9
ja 0x9267f
movq %r8, -0x80(%rsp,%rcx,8)
incq %rcx
cmpq $0x20, %rcx
jne 0x9266c
leaq -0x80(%rsp), %rcx
leaq 0x80(%rsp), %rdi
movq %rdx, %r8
xorl %edx, %edx
movq -0x80(%rsp,%rdx,8), %r10
xorl %r9d, %r9d
testq %r10, %r10
je 0x926e7
movq %rcx, %r11
testb $0x1, %r10b
je 0x926d4
xorq (%r11), %r9
movq %r10, %rbx
shrq %rbx
addq $0x8, %r11
cmpq $0x1, %r10
movq %rbx, %r10
ja 0x926cb
movq %r9, 0x80(%rsp,%rdx,8)
incq %rdx
cmpq $0x20, %rdx
jne 0x926bb
testb $0x1, %r8b
jne 0x92703
movq %rax, %r9
jmp 0x92728
xorl %r9d, %r9d
testq %rax, %rax
je 0x92728
movq %rdi, %rdx
testb $0x1, %al
je 0x92715
xorq (%rdx), %r9
movq %rax, %r10
shrq %r10
addq $0x8, %rdx
cmpq $0x1, %rax
movq %r10, %rax
ja 0x9270e
cmpq $0x2, %r8
jb 0x927b5
movq %r8, %rdx
shrq $0x2, %rdx
xorl %eax, %eax
movq 0x80(%rsp,%rax,8), %r11
xorl %r10d, %r10d
testq %r11, %r11
je 0x9276a
movq %rdi, %rbx
testb $0x1, %r11b
je 0x92757
xorq (%rbx), %r10
movq %r11, %r14
shrq %r14
addq $0x8, %rbx
cmpq $0x1, %r11
movq %r14, %r11
ja 0x9274e
movq %r10, -0x80(%rsp,%rax,8)
incq %rax
cmpq $0x20, %rax
jne 0x9273b
testb $0x2, %r8b
jne 0x92783
movq %r9, %rax
jmp 0x927a9
xorl %eax, %eax
testq %r9, %r9
je 0x927a9
movq %rcx, %r10
testb $0x1, %r9b
je 0x92796
xorq (%r10), %rax
movq %r9, %r11
shrq %r11
addq $0x8, %r10
cmpq $0x1, %r9
movq %r11, %r9
ja 0x9278d
cmpq $0x3, %r8
ja 0x926b6
jmp 0x927b8
movq %r9, %rax
xorq %rsi, %rax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r14
retq