// File: tomfunkhouser[P]gaps/pkgs/png/crc32.c
// Function: crc32_big
local unsigned long crc32_big(crc, buf, len)
    unsigned long crc;
    const unsigned char FAR *buf;
    unsigned len;
{
    register u4 c;
    register const u4 FAR *buf4;

    c = REV((u4)crc);
    c = ~c;
    while (len && ((ptrdiff_t)buf & 3)) {
        c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
        len--;
    }

    buf4 = (const u4 FAR *)(const void FAR *)buf;
    buf4--;
    while (len >= 32) {
        DOBIG32;
        len -= 32;
    }
    while (len >= 4) {
        DOBIG4;
        len -= 4;
    }
    buf4++;
    buf = (const unsigned char FAR *)buf4;

    if (len) do {
        c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
    } while (--len);
    c = ~c;
    return (unsigned long)(REV(c));
}

// Assembly:
movq %rdi, -0x8(%rsp)
movq %rsi, -0x10(%rsp)
movl %edx, -0x14(%rsp)
movq -0x8(%rsp), %rax
shrl $0x18, %eax
andl $0xff, %eax
movq -0x8(%rsp), %rcx
shrl $0x8, %ecx
andl $0xff00, %ecx           # imm = 0xFF00
addl %ecx, %eax
movq -0x8(%rsp), %rcx
andl $0xff00, %ecx           # imm = 0xFF00
shll $0x8, %ecx
addl %ecx, %eax
movq -0x8(%rsp), %rcx
andl $0xff, %ecx
shll $0x18, %ecx
addl %ecx, %eax
movl %eax, -0x18(%rsp)
movl -0x18(%rsp), %eax
xorl $-0x1, %eax
movl %eax, -0x18(%rsp)
xorl %eax, %eax
cmpl $0x0, -0x14(%rsp)
movb %al, -0x21(%rsp)
je 0x1144fb
movq -0x10(%rsp), %rax
andq $0x3, %rax
cmpq $0x0, %rax
setne %al
movb %al, -0x21(%rsp)
movb -0x21(%rsp), %al
testb $0x1, %al
jne 0x114505
jmp 0x114552
movl -0x18(%rsp), %eax
shrl $0x18, %eax
movq -0x10(%rsp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rsp)
movzbl (%rcx), %ecx
xorl %ecx, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x25383(%rip), %rax     # 0x1398b0
movq 0x2000(%rax,%rcx,8), %rax
movl -0x18(%rsp), %ecx
shll $0x8, %ecx
movl %ecx, %ecx
xorq %rcx, %rax
movl %eax, -0x18(%rsp)
movl -0x14(%rsp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rsp)
jmp 0x1144da
movq -0x10(%rsp), %rax
movq %rax, -0x20(%rsp)
movq -0x20(%rsp), %rax
addq $-0x4, %rax
movq %rax, -0x20(%rsp)
cmpl $0x20, -0x14(%rsp)
jb 0x114a35
movq -0x20(%rsp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x20(%rsp)
movl 0x4(%rax), %eax
xorl -0x18(%rsp), %eax
movl %eax, -0x18(%rsp)
movl -0x18(%rsp), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x2530b(%rip), %rax     # 0x1398b0
movq 0x2000(%rax,%rcx,8), %rax
movl -0x18(%rsp), %ecx
shrl $0x8, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x252eb(%rip), %rcx     # 0x1398b0
xorq 0x2800(%rcx,%rdx,8), %rax
movl -0x18(%rsp), %ecx
shrl $0x10, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x252cb(%rip), %rcx     # 0x1398b0
xorq 0x3000(%rcx,%rdx,8), %rax
movl -0x18(%rsp), %ecx
shrl $0x18, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x252b1(%rip), %rcx     # 0x1398b0
xorq 0x3800(%rcx,%rdx,8), %rax
movl %eax, -0x18(%rsp)
movq -0x20(%rsp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x20(%rsp)
movl 0x4(%rax), %eax
xorl -0x18(%rsp), %eax
movl %eax, -0x18(%rsp)
movl -0x18(%rsp), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x25275(%rip), %rax     # 0x1398b0
movq 0x2000(%rax,%rcx,8), %rax
movl -0x18(%rsp), %ecx
shrl $0x8, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x25255(%rip), %rcx     # 0x1398b0
xorq 0x2800(%rcx,%rdx,8), %rax
movl -0x18(%rsp), %ecx
shrl $0x10, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x25235(%rip), %rcx     # 0x1398b0
xorq 0x3000(%rcx,%rdx,8), %rax
movl -0x18(%rsp), %ecx
shrl $0x18, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x2521b(%rip), %rcx     # 0x1398b0
xorq 0x3800(%rcx,%rdx,8), %rax
movl %eax, -0x18(%rsp)
movq -0x20(%rsp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x20(%rsp)
movl 0x4(%rax), %eax
xorl -0x18(%rsp), %eax
movl %eax, -0x18(%rsp)
movl -0x18(%rsp), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x251df(%rip), %rax     # 0x1398b0
movq 0x2000(%rax,%rcx,8), %rax
movl -0x18(%rsp), %ecx
shrl $0x8, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x251bf(%rip), %rcx     # 0x1398b0
xorq 0x2800(%rcx,%rdx,8), %rax
movl -0x18(%rsp), %ecx
shrl $0x10, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x2519f(%rip), %rcx     # 0x1398b0
xorq 0x3000(%rcx,%rdx,8), %rax
movl -0x18(%rsp), %ecx
shrl $0x18, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x25185(%rip), %rcx     # 0x1398b0
xorq 0x3800(%rcx,%rdx,8), %rax
movl %eax, -0x18(%rsp)
movq -0x20(%rsp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x20(%rsp)
movl 0x4(%rax), %eax
xorl -0x18(%rsp), %eax
movl %eax, -0x18(%rsp)
movl -0x18(%rsp), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x25149(%rip), %rax     # 0x1398b0
movq 0x2000(%rax,%rcx,8), %rax
movl -0x18(%rsp), %ecx
shrl $0x8, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x25129(%rip), %rcx     # 0x1398b0
xorq 0x2800(%rcx,%rdx,8), %rax
movl -0x18(%rsp), %ecx
shrl $0x10, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x25109(%rip), %rcx     # 0x1398b0
xorq 0x3000(%rcx,%rdx,8), %rax
movl -0x18(%rsp), %ecx
shrl $0x18, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x250ef(%rip), %rcx     # 0x1398b0
xorq 0x3800(%rcx,%rdx,8), %rax
movl %eax, -0x18(%rsp)
movq -0x20(%rsp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x20(%rsp)
movl 0x4(%rax), %eax
xorl -0x18(%rsp), %eax
movl %eax, -0x18(%rsp)
movl -0x18(%rsp), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x250b3(%rip), %rax     # 0x1398b0
movq 0x2000(%rax,%rcx,8), %rax
movl -0x18(%rsp), %ecx
shrl $0x8, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x25093(%rip), %rcx     # 0x1398b0
xorq 0x2800(%rcx,%rdx,8), %rax
movl -0x18(%rsp), %ecx
shrl $0x10, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x25073(%rip), %rcx     # 0x1398b0
xorq 0x3000(%rcx,%rdx,8), %rax
movl -0x18(%rsp), %ecx
shrl $0x18, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x25059(%rip), %rcx     # 0x1398b0
xorq 0x3800(%rcx,%rdx,8), %rax
movl %eax, -0x18(%rsp)
movq -0x20(%rsp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x20(%rsp)
movl 0x4(%rax), %eax
xorl -0x18(%rsp), %eax
movl %eax, -0x18(%rsp)
movl -0x18(%rsp), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x2501d(%rip), %rax     # 0x1398b0
movq 0x2000(%rax,%rcx,8), %rax
movl -0x18(%rsp), %ecx
shrl $0x8, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x24ffd(%rip), %rcx     # 0x1398b0
xorq 0x2800(%rcx,%rdx,8), %rax
movl -0x18(%rsp), %ecx
shrl $0x10, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x24fdd(%rip), %rcx     # 0x1398b0
xorq 0x3000(%rcx,%rdx,8), %rax
movl -0x18(%rsp), %ecx
shrl $0x18, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x24fc3(%rip), %rcx     # 0x1398b0
xorq 0x3800(%rcx,%rdx,8), %rax
movl %eax, -0x18(%rsp)
movq -0x20(%rsp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x20(%rsp)
movl 0x4(%rax), %eax
xorl -0x18(%rsp), %eax
movl %eax, -0x18(%rsp)
movl -0x18(%rsp), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x24f87(%rip), %rax     # 0x1398b0
movq 0x2000(%rax,%rcx,8), %rax
movl -0x18(%rsp), %ecx
shrl $0x8, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x24f67(%rip), %rcx     # 0x1398b0
xorq 0x2800(%rcx,%rdx,8), %rax
movl -0x18(%rsp), %ecx
shrl $0x10, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x24f47(%rip), %rcx     # 0x1398b0
xorq 0x3000(%rcx,%rdx,8), %rax
movl -0x18(%rsp), %ecx
shrl $0x18, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x24f2d(%rip), %rcx     # 0x1398b0
xorq 0x3800(%rcx,%rdx,8), %rax
movl %eax, -0x18(%rsp)
movq -0x20(%rsp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x20(%rsp)
movl 0x4(%rax), %eax
xorl -0x18(%rsp), %eax
movl %eax, -0x18(%rsp)
movl -0x18(%rsp), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x24ef1(%rip), %rax     # 0x1398b0
movq 0x2000(%rax,%rcx,8), %rax
movl -0x18(%rsp), %ecx
shrl $0x8, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x24ed1(%rip), %rcx     # 0x1398b0
xorq 0x2800(%rcx,%rdx,8), %rax
movl -0x18(%rsp), %ecx
shrl $0x10, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x24eb1(%rip), %rcx     # 0x1398b0
xorq 0x3000(%rcx,%rdx,8), %rax
movl -0x18(%rsp), %ecx
shrl $0x18, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x24e97(%rip), %rcx     # 0x1398b0
xorq 0x3800(%rcx,%rdx,8), %rax
movl %eax, -0x18(%rsp)
movl -0x14(%rsp), %eax
subl $0x20, %eax
movl %eax, -0x14(%rsp)
jmp 0x11456a
jmp 0x114a37
cmpl $0x4, -0x14(%rsp)
jb 0x114ae8
movq -0x20(%rsp), %rax
movq %rax, %rcx
addq $0x4, %rcx
movq %rcx, -0x20(%rsp)
movl 0x4(%rax), %eax
xorl -0x18(%rsp), %eax
movl %eax, -0x18(%rsp)
movl -0x18(%rsp), %eax
andl $0xff, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x24e3e(%rip), %rax     # 0x1398b0
movq 0x2000(%rax,%rcx,8), %rax
movl -0x18(%rsp), %ecx
shrl $0x8, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x24e1e(%rip), %rcx     # 0x1398b0
xorq 0x2800(%rcx,%rdx,8), %rax
movl -0x18(%rsp), %ecx
shrl $0x10, %ecx
andl $0xff, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x24dfe(%rip), %rcx     # 0x1398b0
xorq 0x3000(%rcx,%rdx,8), %rax
movl -0x18(%rsp), %ecx
shrl $0x18, %ecx
movl %ecx, %ecx
movl %ecx, %edx
leaq 0x24de4(%rip), %rcx     # 0x1398b0
xorq 0x3800(%rcx,%rdx,8), %rax
movl %eax, -0x18(%rsp)
movl -0x14(%rsp), %eax
subl $0x4, %eax
movl %eax, -0x14(%rsp)
jmp 0x114a37
movq -0x20(%rsp), %rax
addq $0x4, %rax
movq %rax, -0x20(%rsp)
movq -0x20(%rsp), %rax
movq %rax, -0x10(%rsp)
cmpl $0x0, -0x14(%rsp)
je 0x114b5b
jmp 0x114b09
movl -0x18(%rsp), %eax
shrl $0x18, %eax
movq -0x10(%rsp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x10(%rsp)
movzbl (%rcx), %ecx
xorl %ecx, %eax
movl %eax, %eax
movl %eax, %ecx
leaq 0x24d7f(%rip), %rax     # 0x1398b0
movq 0x2000(%rax,%rcx,8), %rax
movl -0x18(%rsp), %ecx
shll $0x8, %ecx
movl %ecx, %ecx
xorq %rcx, %rax
movl %eax, -0x18(%rsp)
movl -0x14(%rsp), %eax
addl $-0x1, %eax
movl %eax, -0x14(%rsp)
cmpl $0x0, %eax
jne 0x114b09
jmp 0x114b5b
movl -0x18(%rsp), %eax
xorl $-0x1, %eax
movl %eax, -0x18(%rsp)
movl -0x18(%rsp), %eax
shrl $0x18, %eax
andl $0xff, %eax
movl -0x18(%rsp), %ecx
shrl $0x8, %ecx
andl $0xff00, %ecx           # imm = 0xFF00
addl %ecx, %eax
movl -0x18(%rsp), %ecx
andl $0xff00, %ecx           # imm = 0xFF00
shll $0x8, %ecx
addl %ecx, %eax
movl -0x18(%rsp), %ecx
andl $0xff, %ecx
shll $0x18, %ecx
addl %ecx, %eax
movl %eax, %eax
retq
nopw %cs:(%rax,%rax)