// File: /workspace/github_cpp_makefile_star2_O1/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 0x934e9
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 0x93331
xorl %ecx, %ecx
leaq -0x80(%rsp), %rdi
movq -0x80(%rsp,%rcx,8), %r9
xorl %r8d, %r8d
testq %r9, %r9
je 0x93375
movq %rdi, %r10
testb $0x1, %r9b
je 0x93362
xorq (%r10), %r8
movq %r9, %r11
shrq %r11
addq $0x8, %r10
cmpq $0x1, %r9
movq %r11, %r9
ja 0x93359
movq %r8, 0x80(%rsp,%rcx,8)
incq %rcx
cmpq $0x20, %rcx
jne 0x93349
xorl %ecx, %ecx
leaq 0x80(%rsp), %rdi
movq 0x80(%rsp,%rcx,8), %r9
xorl %r8d, %r8d
testq %r9, %r9
je 0x933bf
movq %rdi, %r10
testb $0x1, %r9b
je 0x933ac
xorq (%r10), %r8
movq %r9, %r11
shrq %r11
addq $0x8, %r10
cmpq $0x1, %r9
movq %r11, %r9
ja 0x933a3
movq %r8, -0x80(%rsp,%rcx,8)
incq %rcx
cmpq $0x20, %rcx
jne 0x93390
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 0x9340b
movq %rcx, %r11
testb $0x1, %r10b
je 0x933f8
xorq (%r11), %r9
movq %r10, %rbx
shrq %rbx
addq $0x8, %r11
cmpq $0x1, %r10
movq %rbx, %r10
ja 0x933ef
movq %r9, 0x80(%rsp,%rdx,8)
incq %rdx
cmpq $0x20, %rdx
jne 0x933df
testb $0x1, %r8b
jne 0x93427
movq %rax, %r9
jmp 0x9344c
xorl %r9d, %r9d
testq %rax, %rax
je 0x9344c
movq %rdi, %rdx
testb $0x1, %al
je 0x93439
xorq (%rdx), %r9
movq %rax, %r10
shrq %r10
addq $0x8, %rdx
cmpq $0x1, %rax
movq %r10, %rax
ja 0x93432
cmpq $0x2, %r8
jb 0x934d9
movq %r8, %rdx
shrq $0x2, %rdx
xorl %eax, %eax
movq 0x80(%rsp,%rax,8), %r11
xorl %r10d, %r10d
testq %r11, %r11
je 0x9348e
movq %rdi, %rbx
testb $0x1, %r11b
je 0x9347b
xorq (%rbx), %r10
movq %r11, %r14
shrq %r14
addq $0x8, %rbx
cmpq $0x1, %r11
movq %r14, %r11
ja 0x93472
movq %r10, -0x80(%rsp,%rax,8)
incq %rax
cmpq $0x20, %rax
jne 0x9345f
testb $0x2, %r8b
jne 0x934a7
movq %r9, %rax
jmp 0x934cd
xorl %eax, %eax
testq %r9, %r9
je 0x934cd
movq %rcx, %r10
testb $0x1, %r9b
je 0x934ba
xorq (%r10), %rax
movq %r9, %r11
shrq %r11
addq $0x8, %r10
cmpq $0x1, %r9
movq %r11, %r9
ja 0x934b1
cmpq $0x3, %r8
ja 0x933da
jmp 0x934dc
movq %r9, %rax
xorq %rsi, %rax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r14
retq