// File: /workspace/github_c_makefile_star2_O1/nkanaev[P]tipsy/src/tigr.c
// Function: unfilter
static int unfilter(int w, int h, int bipp, unsigned char* raw) {
    int len = rowBytes(w, bipp);
    int bpp = rowBytes(1, bipp);
    int x, y;
    unsigned char* first = (unsigned char*)malloc(len + 1);
    memset(first, 0, len + 1);
    unsigned char* prev = first;
    for (y = 0; y < h; y++, prev = raw, raw += len) {
#define LOOP(A, B)            \
    for (x = 0; x < bpp; x++) \
        raw[x] += A;          \
    for (; x < len; x++)      \
        raw[x] += B;          \
    break
        switch (*raw++) {
            case 0:
                break;
            case 1:
                LOOP(0, raw[x - bpp]);
            case 2:
                LOOP(prev[x], prev[x]);
            case 3:
                LOOP(prev[x] / 2, (raw[x - bpp] + prev[x]) / 2);
            case 4:
                LOOP(prev[x], paeth(raw[x - bpp], prev[x], prev[x - bpp]));
            default:
                return 0;
        }
#undef LOOP
    }
    free(first);
    return 1;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, %rbx
movl %edi, %r15d
imull %edx, %r15d
leal 0x7(%r15), %r13d
testl %r15d, %r15d
cmovnsl %r15d, %r13d
sarl $0x3, %r13d
andl $0x7, %r15d
cmpl $0x1, %r15d
movl %r13d, %eax
sbbl $-0x1, %eax
leal 0x7(%rdx), %ecx
testl %edx, %edx
cmovnsl %edx, %ecx
movl %esi, %ebp
sarl $0x3, %ecx
andl $0x7, %edx
cmpl $0x1, %edx
sbbl $-0x1, %ecx
movl %ecx, 0xc(%rsp)
movq %rax, 0x10(%rsp)
incl %eax
movslq %eax, %r12
movq %r12, %rdi
callq 0x34f0
xorl %r14d, %r14d
movq %rax, 0x20(%rsp)
movq %rax, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0x31d0
movl %ebp, 0x1c(%rsp)
testl %ebp, %ebp
jle 0x7ae8
movq 0x10(%rsp), %rax
movslq %eax, %rcx
movq %rcx, 0x40(%rsp)
movl 0xc(%rsp), %ecx
movslq %ecx, %rdx
testl %edx, %edx
movl $0x0, %esi
cmovgl %ecx, %esi
movq %rsi, 0x28(%rsp)
movl %edx, %esi
movl %eax, %edi
movq %rbx, %r8
subq %rdx, %r8
incq %r8
movslq %r13d, %rax
cmpl $0x1, %r15d
sbbq $-0x1, %rax
incq %rax
movq %rax, 0x38(%rsp)
negq %rdx
movq %rdx, 0x30(%rsp)
movq 0x20(%rsp), %r11
movzbl (%rbx), %eax
cmpq $0x4, %rax
ja 0x7b06
leaq 0x38b6(%rip), %rcx      # 0xb230
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x28(%rsp), %rax
cmpl 0x10(%rsp), %eax
jge 0x7ac7
movq 0x28(%rsp), %rax
movb (%r8,%rax), %cl
addb %cl, 0x1(%rbx,%rax)
incq %rax
cmpq %rax, %rdi
jne 0x7997
jmp 0x7ac7
cmpl $0x0, 0xc(%rsp)
jle 0x7a0d
xorl %ecx, %ecx
movb (%r11,%rcx), %al
addb %al, 0x1(%rbx,%rcx)
incq %rcx
cmpq %rcx, %rsi
jne 0x79b5
jmp 0x7a0f
cmpl $0x0, 0xc(%rsp)
jle 0x7a87
xorl %ecx, %ecx
movb (%r11,%rcx), %al
addb %al, 0x1(%rbx,%rcx)
incq %rcx
cmpq %rcx, %rsi
jne 0x79d4
jmp 0x7a89
cmpl $0x0, 0xc(%rsp)
jle 0x7aa3
xorl %ecx, %ecx
movb (%r11,%rcx), %al
shrb %al
addb %al, 0x1(%rbx,%rcx)
incq %rcx
cmpq %rcx, %rsi
jne 0x79f6
jmp 0x7aa5
xorl %ecx, %ecx
cmpl 0x10(%rsp), %ecx
jge 0x7ac7
movl %ecx, %r15d
movq 0x30(%rsp), %rax
leaq (%r11,%rax), %r12
movzbl (%r8,%r15), %r13d
movzbl (%r11,%r15), %edx
movzbl (%r12,%r15), %ecx
leal (%rdx,%r13), %r10d
subl %ecx, %r10d
movl %r10d, %eax
subl %r13d, %eax
movl %eax, %ebp
negl %ebp
cmovsl %eax, %ebp
movl %r10d, %r9d
subl %edx, %r9d
movl %r9d, %eax
negl %eax
cmovsl %r9d, %eax
subl %ecx, %r10d
movl %r10d, %r9d
negl %r9d
cmovsl %r10d, %r9d
cmpl %r9d, %eax
ja 0x7a6b
movl %edx, %ecx
cmpl %r9d, %ebp
cmoval %ecx, %r13d
cmpl %eax, %ebp
cmoval %ecx, %r13d
addb %r13b, 0x1(%rbx,%r15)
incq %r15
cmpq %r15, %rdi
jne 0x7a25
jmp 0x7ac7
xorl %ecx, %ecx
cmpl 0x10(%rsp), %ecx
jge 0x7ac7
movl %ecx, %eax
movb (%r11,%rax), %cl
addb %cl, 0x1(%rbx,%rax)
incq %rax
cmpq %rax, %rdi
jne 0x7a91
jmp 0x7ac7
xorl %ecx, %ecx
cmpl 0x10(%rsp), %ecx
jge 0x7ac7
movl %ecx, %eax
movzbl (%r8,%rax), %ecx
movzbl (%r11,%rax), %edx
addl %ecx, %edx
shrl %edx
addb %dl, 0x1(%rbx,%rax)
incq %rax
cmpq %rax, %rdi
jne 0x7aad
incq %rbx
incl %r14d
movq %rbx, %r11
movq 0x40(%rsp), %rax
addq %rax, %rbx
addq 0x38(%rsp), %r8
cmpl 0x1c(%rsp), %r14d
jne 0x7966
movq 0x20(%rsp), %rdi
callq 0x3410
movl $0x1, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
jmp 0x7af7