// File: /workspace/github_c_makefile_star2_O3/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 $0x58, %rsp
movq %rcx, %r15
movl %edi, %r14d
imull %edx, %r14d
leal 0x7(%r14), %ebx
testl %r14d, %r14d
cmovnsl %r14d, %ebx
sarl $0x3, %ebx
andl $0x7, %r14d
cmpl $0x1, %r14d
movl %ebx, %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, 0x4(%rsp)
movq %rax, 0x8(%rsp)
incl %eax
movslq %eax, %rsi
movl $0x1, %edi
callq 0x3270
movq %rax, 0x20(%rsp)
movl %ebp, 0x1c(%rsp)
testl %ebp, %ebp
jle 0x7c57
movq 0x8(%rsp), %rax
movslq %eax, %rcx
movq %rcx, 0x40(%rsp)
movl 0x4(%rsp), %ecx
movslq %ecx, %rdx
xorl %esi, %esi
testl %edx, %edx
movl $0x0, %r12d
cmovgl %ecx, %r12d
movl %edx, %ecx
movq %rcx, 0x10(%rsp)
movl %eax, %r8d
movq %r15, %rdi
subq %rdx, %rdi
incq %rdi
movslq %ebx, %rax
cmpl $0x1, %r14d
sbbq $-0x1, %rax
incq %rax
movq %rax, 0x38(%rsp)
negq %rdx
movq %rdx, 0x30(%rsp)
leaq 0x1(%r15), %rcx
movq 0x20(%rsp), %rbx
movzbl (%r15), %eax
cmpq $0x4, %rax
ja 0x7c75
movq %r15, 0x28(%rsp)
movq %rsi, 0x48(%rsp)
leaq 0x3839(%rip), %rdx      # 0xb2e0
movslq (%rdx,%rax,4), %rax
addq %rdx, %rax
jmpq *%rax
movq %r12, %rax
cmpl 0x8(%rsp), %r12d
jge 0x7c27
movb (%rdi,%rax), %dl
addb %dl, (%rcx,%rax)
incq %rax
cmpq %rax, %r8
jne 0x7abe
jmp 0x7c27
cmpl $0x0, 0x4(%rsp)
jle 0x7b4e
xorl %eax, %eax
movq 0x10(%rsp), %rsi
movq 0x28(%rsp), %r9
movb (%rbx,%rax), %dl
addb %dl, 0x1(%r9,%rax)
incq %rax
cmpq %rax, %rsi
jne 0x7ae4
movl 0x4(%rsp), %eax
jmp 0x7b50
cmpl $0x0, 0x4(%rsp)
jle 0x7beb
xorl %eax, %eax
movq 0x10(%rsp), %rsi
movb (%rbx,%rax), %dl
addb %dl, (%rcx,%rax)
incq %rax
cmpq %rax, %rsi
jne 0x7b0c
movl 0x4(%rsp), %eax
jmp 0x7bed
cmpl $0x0, 0x4(%rsp)
jle 0x7c05
xorl %eax, %eax
movq 0x10(%rsp), %rsi
movb (%rbx,%rax), %dl
shrb %dl
addb %dl, (%rcx,%rax)
incq %rax
cmpq %rax, %rsi
jne 0x7b35
movl 0x4(%rsp), %eax
jmp 0x7c07
xorl %eax, %eax
cmpl 0x8(%rsp), %eax
jge 0x7c27
movq 0x30(%rsp), %rax
leaq (%rbx,%rax), %rdx
movq %r8, %r9
movq %rcx, %r14
movq %rdi, %r10
movq %rdi, 0x50(%rsp)
movq %r8, %r15
movzbl (%r10,%r12), %r13d
movzbl (%rbx,%r12), %r11d
movq %r12, %rdi
movzbl (%rdx,%r12), %r12d
leal (%r11,%r13), %r8d
subl %r12d, %r8d
movl %r8d, %eax
subl %r13d, %eax
movl %eax, %esi
negl %esi
cmovsl %eax, %esi
movl %r8d, %ebp
subl %r11d, %ebp
movl %ebp, %eax
negl %eax
cmovsl %ebp, %eax
subl %r12d, %r8d
movl %r8d, %ebp
negl %ebp
cmovsl %r8d, %ebp
cmpl %ebp, %eax
ja 0x7bba
movl %r11d, %r12d
cmpl %ebp, %esi
cmoval %r12d, %r13d
cmpl %eax, %esi
cmoval %r12d, %r13d
movq %rdi, %r12
addb %r13b, (%r14,%rdi)
incq %r10
incq %rdx
incq %r14
incq %rbx
decq %r9
cmpq %r9, %rdi
movq %r15, %r8
movq 0x50(%rsp), %rdi
jne 0x7b71
jmp 0x7c27
xorl %eax, %eax
cmpl 0x8(%rsp), %eax
jge 0x7c27
movl %eax, %eax
movb (%rbx,%rax), %dl
addb %dl, (%rcx,%rax)
incq %rax
cmpq %rax, %r8
jne 0x7bf5
jmp 0x7c27
xorl %eax, %eax
cmpl 0x8(%rsp), %eax
jge 0x7c27
movl %eax, %eax
movzbl (%rdi,%rax), %edx
movzbl (%rbx,%rax), %esi
addl %edx, %esi
shrl %esi
addb %sil, (%rcx,%rax)
incq %rax
cmpq %rax, %r8
jne 0x7c0f
movq 0x28(%rsp), %rdx
incq %rdx
movq 0x48(%rsp), %rsi
incl %esi
movq %rdx, %rbx
movq 0x40(%rsp), %rax
leaq (%rdx,%rax), %r15
movq 0x38(%rsp), %rax
addq %rax, %rdi
addq %rax, %rcx
cmpl 0x1c(%rsp), %esi
jne 0x7a88
movq 0x20(%rsp), %rdi
callq 0x3410
movl $0x1, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
jmp 0x7c66