// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x40, %rsp
movl %edi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
movl -0x8(%rbp), %edi
movl -0x10(%rbp), %esi
callq 0x9cc0
movl %eax, -0x1c(%rbp)
movl -0x10(%rbp), %esi
movl $0x1, %edi
callq 0x9cc0
movl %eax, -0x20(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdi
callq 0x34f0
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rdi
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movslq %eax, %rdx
xorl %esi, %esi
callq 0x31d0
movq -0x30(%rbp), %rax
movq %rax, -0x38(%rbp)
movl $0x0, -0x28(%rbp)
movl -0x28(%rbp), %eax
cmpl -0xc(%rbp), %eax
jge 0x9854
movq -0x18(%rbp), %rax
movq %rax, %rcx
incq %rcx
movq %rcx, -0x18(%rbp)
movzbl (%rax), %eax
movq %rax, -0x40(%rbp)
subq $0x4, %rax
ja 0x9822
movq -0x40(%rbp), %rax
leaq 0x5a3e(%rip), %rcx      # 0xf04c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
jmp 0x982b
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x9648
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl (%rax,%rcx), %edx
addl $0x0, %edx
movb %dl, (%rax,%rcx)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x9623
jmp 0x964a
movl -0x24(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x967f
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
subl -0x20(%rbp), %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %esi
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl (%rax,%rcx), %edx
addl %esi, %edx
movb %dl, (%rax,%rcx)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x964a
jmp 0x982b
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x96bb
movq -0x38(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl (%rax,%rcx), %esi
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl (%rax,%rcx), %edx
addl %esi, %edx
movb %dl, (%rax,%rcx)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x968b
jmp 0x96bd
movl -0x24(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x96ed
movq -0x38(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl (%rax,%rcx), %esi
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl (%rax,%rcx), %edx
addl %esi, %edx
movb %dl, (%rax,%rcx)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x96bd
jmp 0x982b
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x9733
movq -0x38(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl (%rax,%rcx), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %esi
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl (%rax,%rcx), %edx
addl %esi, %edx
movb %dl, (%rax,%rcx)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x96f9
jmp 0x9735
movl -0x24(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x9782
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
subl -0x20(%rbp), %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %eax
movq -0x38(%rbp), %rcx
movslq -0x24(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
addl %ecx, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %esi
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl (%rax,%rcx), %edx
addl %esi, %edx
movb %dl, (%rax,%rcx)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x9735
jmp 0x982b
movl $0x0, -0x24(%rbp)
movl -0x24(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x97be
movq -0x38(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl (%rax,%rcx), %esi
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl (%rax,%rcx), %edx
addl %esi, %edx
movb %dl, (%rax,%rcx)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x978e
jmp 0x97c0
movl -0x24(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x9820
movq -0x18(%rbp), %rax
movl -0x24(%rbp), %ecx
subl -0x20(%rbp), %ecx
movslq %ecx, %rcx
movb (%rax,%rcx), %sil
movq -0x38(%rbp), %rax
movslq -0x24(%rbp), %rcx
movb (%rax,%rcx), %dl
movq -0x38(%rbp), %rax
movl -0x24(%rbp), %ecx
subl -0x20(%rbp), %ecx
movslq %ecx, %rcx
movzbl %sil, %edi
movzbl %dl, %esi
movzbl (%rax,%rcx), %edx
callq 0x9d10
movzbl %al, %esi
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movzbl (%rax,%rcx), %edx
addl %esi, %edx
movb %dl, (%rax,%rcx)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x97c0
jmp 0x982b
movl $0x0, -0x4(%rbp)
jmp 0x9864
jmp 0x982d
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movl -0x1c(%rbp), %ecx
movq -0x18(%rbp), %rax
movslq %ecx, %rcx
addq %rcx, %rax
movq %rax, -0x18(%rbp)
jmp 0x95d8
movq -0x30(%rbp), %rdi
callq 0x3410
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)