// File: /workspace/github_c_makefile_star2_O2/tditlu[P]shadetabler/src/lodepng/lodepng.c
// Function: unfilter
static unsigned unfilter(unsigned char* out, const unsigned char* in, unsigned w, unsigned h, unsigned bpp) {
  /*
  For PNG filter method 0
  this function unfilters a single image (e.g. without interlacing this is called once, with Adam7 seven times)
  out must have enough bytes allocated already, in must have the scanlines + 1 filtertype byte per scanline
  w and h are image dimensions or dimensions of reduced image, bpp is bits per pixel
  in and out are allowed to be the same memory address (but aren't the same size since in has the extra filter bytes)
  */

  unsigned y;
  unsigned char* prevline = 0;

  /*bytewidth is used for filtering, is 1 when bpp < 8, number of bytes per pixel otherwise*/
  size_t bytewidth = (bpp + 7u) / 8u;
  /*the width of a scanline in bytes, not including the filter type*/
  size_t linebytes = lodepng_get_raw_size_idat(w, 1, bpp) - 1u;

  for(y = 0; y < h; ++y) {
    size_t outindex = linebytes * y;
    size_t inindex = (1 + linebytes) * y; /*the extra filterbyte added to each row*/
    unsigned char filterType = in[inindex];

    CERROR_TRY_RETURN(unfilterScanline(&out[outindex], &in[inindex + 1], prevline, bytewidth, filterType, linebytes));

    prevline = &out[outindex];
  }

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movq %rdi, %r13
leal 0x7(%r8), %eax
movl %eax, 0x3c(%rsp)
movl %eax, %r15d
shrl $0x3, %r15d
movl %edx, %eax
shrl $0x3, %eax
movl %r8d, %edi
imulq %rax, %rdi
andl $0x7, %edx
imull %r8d, %edx
addl $0x7, %edx
shrl $0x3, %edx
leaq (%rdi,%rdx), %r8
leaq (%rdi,%rdx), %rax
incq %rax
movl %ecx, %ecx
movq %rcx, 0xa0(%rsp)
leaq 0x1(%rsi), %rdi
leaq 0x3(%rsi), %rcx
movq %rcx, 0x70(%rsp)
movq %r15, %rcx
negq %rcx
movq %rcx, 0x68(%rsp)
movq %r13, %rcx
subq %r15, %rcx
movq %rcx, 0x58(%rsp)
leaq 0x4(%rsi), %rcx
movq %rcx, 0x78(%rsp)
leaq (%r15,%r13), %r9
leaq 0x3(%r15), %rcx
movq %rcx, 0x80(%rsp)
movq %rsi, 0x98(%rsp)
addq %r15, %rsi
incq %rsi
movq %r13, 0x90(%rsp)
xorl %edx, %edx
xorl %r14d, %r14d
movq %r15, 0x50(%rsp)
movq %r8, 0x48(%rsp)
movq %rax, 0x88(%rsp)
cmpq 0xa0(%rsp), %rdx
je 0xbe01
imulq %rdx, %rax
movq 0x98(%rsp), %rcx
movzbl (%rcx,%rax), %eax
cmpq $0x4, %rax
ja 0xbe15
leaq 0x3911(%rip), %rcx      # 0xf260
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
movq %rdx, 0xb0(%rsp)
jmpq *%rax
xorl %eax, %eax
cmpq %rax, %r8
je 0xb9f2
movb (%rdi,%rax), %cl
movb %cl, (%r13,%rax)
incq %rax
jmp 0xb962
xorl %eax, %eax
testq %r14, %r14
je 0xb9a4
cmpq %rax, %r15
je 0xbab9
movb (%r14,%rax), %cl
addb (%rdi,%rax), %cl
movb %cl, (%r13,%rax)
incq %rax
jmp 0xb97f
movb (%rdi,%rax), %cl
movb %cl, (%r13,%rax)
incq %rax
cmpq %rax, %r15
jne 0xb999
xorl %eax, %eax
leaq (%r15,%rax), %rcx
cmpq %r8, %rcx
jae 0xb9f2
movb (%r13,%rax), %cl
addb (%rsi,%rax), %cl
movb %cl, (%r9,%rax)
incq %rax
jmp 0xb9ab
xorl %eax, %eax
testq %r14, %r14
je 0xb9ed
cmpq %rax, %r8
je 0xb9f2
movb (%r14,%rax), %cl
addb (%rdi,%rax), %cl
movb %cl, (%r13,%rax)
incq %rax
jmp 0xb9cc
movb (%rdi,%rax), %cl
movb %cl, (%r13,%rax)
incq %rax
cmpq %rax, %r8
jne 0xb9e2
movq %r8, %r14
movq 0xb0(%rsp), %rdx
imulq %rdx, %r14
addq 0x90(%rsp), %r14
incq %rdx
addq %r8, %r13
movq 0x88(%rsp), %rax
addq %rax, %rdi
addq %rax, 0x70(%rsp)
addq %r8, 0x58(%rsp)
addq %rax, 0x78(%rsp)
addq %r8, %r9
addq %rax, %rsi
jmp 0xb920
xorl %eax, %eax
testq %r14, %r14
je 0xba62
cmpq %rax, %r15
je 0xbbea
movb (%r14,%rax), %cl
shrb %cl
addb (%rdi,%rax), %cl
movb %cl, (%r13,%rax)
incq %rax
jmp 0xba3b
movb (%rdi,%rax), %cl
movb %cl, (%r13,%rax)
incq %rax
cmpq %rax, %r15
jne 0xba57
xorl %eax, %eax
leaq (%r15,%rax), %rcx
cmpq %r8, %rcx
jae 0xb9f2
movb (%r13,%rax), %cl
shrb %cl
addb (%rsi,%rax), %cl
movb %cl, (%r9,%rax)
incq %rax
jmp 0xba69
xorl %eax, %eax
cmpq %rax, %r15
je 0xba99
movb (%rdi,%rax), %cl
movb %cl, (%r13,%rax)
incq %rax
jmp 0xba87
xorl %eax, %eax
leaq (%r15,%rax), %rcx
cmpq %r8, %rcx
jae 0xb9f2
movb (%r13,%rax), %cl
addb (%rsi,%rax), %cl
movb %cl, (%r9,%rax)
incq %rax
jmp 0xba9b
cmpl $0x20, 0x3c(%rsp)
movq %rdi, 0x40(%rsp)
movq %r9, 0x30(%rsp)
movq %rsi, 0x28(%rsp)
jb 0xbc17
movq 0x80(%rsp), %rax
addq %r14, %rax
movq %rax, 0xa8(%rsp)
xorl %r12d, %r12d
leaq (%r15,%r12), %rax
addq $0x3, %rax
cmpq %r8, %rax
jae 0xbcf3
movzbl (%r13,%r12), %edi
movzbl 0x1(%r13,%r12), %eax
movl %eax, 0x64(%rsp)
movzbl 0x2(%r13,%r12), %eax
movl %eax, 0x20(%rsp)
movzbl 0x3(%r13,%r12), %eax
movl %eax, 0x10(%rsp)
movq 0xa8(%rsp), %rax
movzbl -0x3(%rax,%r12), %esi
movzbl -0x2(%rax,%r12), %r15d
movzbl -0x1(%rax,%r12), %ecx
movl %ecx, 0x14(%rsp)
movzbl (%rax,%r12), %eax
movl %eax, 0xc(%rsp)
movzbl (%r14,%r12), %edx
movzbl 0x1(%r14,%r12), %ebp
movzbl 0x2(%r14,%r12), %ebx
movzbl 0x3(%r14,%r12), %eax
movl %eax, 0x1c(%rsp)
callq 0xbfc0
movb %al, 0x18(%rsp)
movl 0x64(%rsp), %edi
movl %r15d, %esi
movq 0x50(%rsp), %r15
movl %ebp, %edx
callq 0xbfc0
movl %eax, %ebp
movl 0x20(%rsp), %edi
movl 0x14(%rsp), %esi
movl %ebx, %edx
callq 0xbfc0
movl %eax, %ebx
movl 0x10(%rsp), %edi
movl 0xc(%rsp), %esi
movl 0x1c(%rsp), %edx
callq 0xbfc0
movq 0x48(%rsp), %r8
movq 0x28(%rsp), %rcx
movd (%rcx,%r12), %xmm0
movzbl 0x18(%rsp), %ecx
movzbl %bpl, %edx
shll $0x8, %edx
orl %ecx, %edx
movzbl %bl, %ecx
shll $0x10, %ecx
orl %edx, %ecx
movzbl %al, %eax
shll $0x18, %eax
orl %ecx, %eax
movd %eax, %xmm1
paddb %xmm0, %xmm1
movq 0x30(%rsp), %rax
movd %xmm1, (%rax,%r12)
addq $0x4, %r12
jmp 0xbae9
addq %r15, %r14
xorl %eax, %eax
leaq (%r15,%rax), %rcx
cmpq %r8, %rcx
jae 0xb9f2
movzbl (%r13,%rax), %ecx
movzbl (%r14,%rax), %edx
addl %ecx, %edx
shrl %edx
addb (%rsi,%rax), %dl
movb %dl, (%r9,%rax)
incq %rax
jmp 0xbbef
cmpl $0x3, %r15d
jne 0xbd55
pushq $0x3
popq %r12
leaq 0x2(%r12), %rax
cmpq %r8, %rax
jae 0xbd05
movq 0x78(%rsp), %rax
movb -0x3(%rax,%r12), %cl
movb %cl, 0x14(%rsp)
movb -0x2(%rax,%r12), %cl
movb %cl, 0xc(%rsp)
movb -0x1(%rax,%r12), %al
movb %al, 0x10(%rsp)
movzbl -0x3(%r13,%r12), %edi
movzbl -0x2(%r13,%r12), %ebx
movzbl -0x1(%r13,%r12), %eax
movl %eax, 0x20(%rsp)
movzbl (%r14,%r12), %esi
movzbl 0x1(%r14,%r12), %r15d
movzbl 0x2(%r14,%r12), %eax
movl %eax, 0x1c(%rsp)
movzbl -0x3(%r14,%r12), %edx
movzbl -0x2(%r14,%r12), %ebp
movzbl -0x1(%r14,%r12), %eax
movl %eax, 0x18(%rsp)
callq 0xbfc0
addb 0x14(%rsp), %al
movb %al, (%r13,%r12)
movl %ebx, %edi
movl %r15d, %esi
movq 0x50(%rsp), %r15
movl %ebp, %edx
callq 0xbfc0
addb 0xc(%rsp), %al
movb %al, 0x1(%r13,%r12)
movl 0x20(%rsp), %edi
movl 0x1c(%rsp), %esi
movl 0x18(%rsp), %edx
callq 0xbfc0
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %r9
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %r8
addb 0x10(%rsp), %al
movb %al, 0x2(%r13,%r12)
addq $0x3, %r12
jmp 0xbc25
addq %r15, %r12
movq 0x40(%rsp), %rdi
movq 0x30(%rsp), %r9
movq 0x28(%rsp), %rsi
movq 0x68(%rsp), %rax
leaq (%r14,%rax), %rbx
cmpq %r12, %r8
je 0xb9f2
movb (%rdi,%r12), %bpl
movq 0x58(%rsp), %rax
movzbl (%rax,%r12), %edi
movzbl (%r14,%r12), %esi
movzbl (%rbx,%r12), %edx
callq 0xbfc0
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %r9
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %r8
addb %bpl, %al
movb %al, (%r13,%r12)
incq %r12
jmp 0xbd0e
movq %r15, %r12
cmpl $0x10, 0x3c(%rsp)
jb 0xbd05
movq 0x68(%rsp), %rax
addq %r14, %rax
movq %rax, 0x20(%rsp)
pushq $0x2
popq %r12
leaq 0x1(%r12), %rax
cmpq %r8, %rax
jae 0xbd05
movq 0x70(%rsp), %rax
movb -0x2(%rax,%r12), %cl
movb %cl, 0xc(%rsp)
movb -0x1(%rax,%r12), %al
movb %al, 0x10(%rsp)
movq 0x58(%rsp), %rax
movzbl (%rax,%r12), %edi
movzbl 0x1(%rax,%r12), %ebx
movzbl (%r14,%r12), %esi
movzbl 0x1(%r14,%r12), %ebp
movq 0x20(%rsp), %rax
movzbl (%rax,%r12), %edx
movzbl 0x1(%rax,%r12), %r15d
callq 0xbfc0
addb 0xc(%rsp), %al
movb %al, (%r13,%r12)
movl %ebx, %edi
movl %ebp, %esi
movl %r15d, %edx
movq 0x50(%rsp), %r15
callq 0xbfc0
movq 0x28(%rsp), %rsi
movq 0x30(%rsp), %r9
movq 0x40(%rsp), %rdi
movq 0x48(%rsp), %r8
addb 0x10(%rsp), %al
movb %al, 0x1(%r13,%r12)
addq $0x2, %r12
jmp 0xbd70
xorl %eax, %eax
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x24
popq %rax
jmp 0xbe03