// File: /workspace/github_c_makefile_star2_O1/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:
testl %ecx, %ecx
je 0xdf55
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r11
movq %rdi, (%rsp)
leal 0x7(%r8), %esi
movl %esi, %r10d
shrl $0x3, %r10d
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), %r12
addq %rdi, %rdx
incq %rdx
movl %ecx, %eax
movq %rax, -0x8(%rsp)
leaq 0x1(%rbx), %rdi
movq %r10, %rax
negq %rax
movq %rax, -0x60(%rsp)
movq %r11, %r13
subq %r10, %r13
movl $0x2, %eax
subq %r10, %rax
movq %rax, -0x10(%rsp)
movq %r12, %r14
subq %r10, %r14
leaq (%r11,%r10), %rbp
leaq (%rbx,%r10), %r9
incq %r9
xorl %r15d, %r15d
xorl %r8d, %r8d
movl %esi, -0x7c(%rsp)
movq %rdx, %rsi
movq %r12, -0x48(%rsp)
movq %rbx, %rdx
movq %r10, -0x28(%rsp)
movq %rbx, -0x30(%rsp)
movq %rsi, -0x38(%rsp)
movq %r14, -0x40(%rsp)
movq %rsi, %rcx
imulq %r15, %rcx
movzbl (%rdx,%rcx), %ecx
cmpq $0x4, %rcx
ja 0xd83b
movq %rdx, %rbx
leaq 0x4b40(%rip), %rdx      # 0x12250
movslq (%rdx,%rcx,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
xorl %r8d, %r8d
movb $0x1, %cl
testq %r12, %r12
je 0xd8ab
movl %eax, %edx
xorl %eax, %eax
movb (%rdi,%rax), %cl
movb %cl, (%r11,%rax)
incq %rax
cmpq %rax, %r12
jne 0xd72b
jmp 0xd89f
testq %r8, %r8
je 0xd848
cmpl $0x8, -0x7c(%rsp)
jae 0xd8fd
xorl %edx, %edx
jmp 0xd920
movl %eax, %edx
testq %r8, %r8
je 0xd884
movb $0x1, %cl
testq %r12, %r12
je 0xdce4
xorl %eax, %eax
movb (%r8,%rax), %cl
addb (%rdi,%rax), %cl
movb %cl, (%r11,%rax)
incq %rax
cmpq %rax, %r12
jne 0xd772
movl %edx, %eax
jmp 0xd7f3
movl %eax, -0x80(%rsp)
testq %r8, %r8
je 0xd8b3
cmpl $0x8, -0x7c(%rsp)
movq %rbx, %rdx
jb 0xd7b7
xorl %eax, %eax
movb (%r8,%rax), %cl
shrb %cl
addb (%rdi,%rax), %cl
movb %cl, (%r11,%rax)
incq %rax
cmpq %rax, %r10
jne 0xd7a2
movb $0x1, %cl
cmpq %r10, %r12
jbe 0xdcdb
movq %r15, -0x68(%rsp)
addq %r10, %r8
xorl %eax, %eax
movzbl (%r11,%rax), %ecx
movzbl (%r8,%rax), %edx
addl %ecx, %edx
shrl %edx
addb (%r9,%rax), %dl
movb %dl, (%rbp,%rax)
incq %rax
cmpq %rax, %r14
jne 0xd7cc
movq -0x68(%rsp), %r15
movl -0x80(%rsp), %eax
movq %rbx, %rdx
jmp 0xdf0f
movl %eax, %edx
cmpl $0x8, -0x7c(%rsp)
jb 0xd815
xorl %eax, %eax
movb (%rdi,%rax), %cl
movb %cl, (%r11,%rax)
incq %rax
cmpq %rax, %r10
jne 0xd806
xorl %r8d, %r8d
movb $0x1, %cl
cmpq %r10, %r12
jbe 0xd8a9
xorl %eax, %eax
movb (%r11,%rax), %cl
addb (%r9,%rax), %cl
movb %cl, (%rbp,%rax)
incq %rax
cmpq %rax, %r14
jne 0xd825
jmp 0xd89f
xorl %ecx, %ecx
movl $0x24, %r8d
jmp 0xdf14
movl %eax, %edx
cmpl $0x8, -0x7c(%rsp)
jb 0xd862
xorl %eax, %eax
movb (%rdi,%rax), %cl
movb %cl, (%r11,%rax)
incq %rax
cmpq %rax, %r10
jne 0xd853
xorl %r8d, %r8d
movb $0x1, %cl
cmpq %r10, %r12
jbe 0xd8a9
xorl %eax, %eax
movb (%r11,%rax), %cl
addb (%r9,%rax), %cl
movb %cl, (%rbp,%rax)
incq %rax
cmpq %rax, %r14
jne 0xd86e
jmp 0xd89f
xorl %r8d, %r8d
movb $0x1, %cl
testq %r12, %r12
je 0xd8a9
xorl %eax, %eax
movb (%rdi,%rax), %cl
movb %cl, (%r11,%rax)
incq %rax
cmpq %rax, %r12
jne 0xd890
movl %edx, %eax
movq %rbx, %rdx
jmp 0xdf12
movl %edx, %eax
movq %rbx, %rdx
jmp 0xdf14
cmpl $0x8, -0x7c(%rsp)
movq %rbx, %rdx
jb 0xd8ce
xorl %eax, %eax
movb (%rdi,%rax), %cl
movb %cl, (%r11,%rax)
incq %rax
cmpq %rax, %r10
jne 0xd8bf
xorl %r8d, %r8d
movb $0x1, %cl
cmpq %r10, %r12
jbe 0xdcee
xorl %eax, %eax
movb (%r11,%rax), %cl
shrb %cl
addb (%r9,%rax), %cl
movb %cl, (%rbp,%rax)
incq %rax
cmpq %rax, %r14
jne 0xd8de
movl -0x80(%rsp), %eax
jmp 0xdf12
movq %r11, %rsi
movl %eax, %r11d
xorl %eax, %eax
movb (%r8,%rax), %cl
addb (%rdi,%rax), %cl
movb %cl, (%rsi,%rax)
incq %rax
cmpq %rax, %r10
jne 0xd905
movq %r10, %rdx
movl %r11d, %eax
movq %rsi, %r11
cmpl $0x20, -0x7c(%rsp)
movq %r13, -0x70(%rsp)
movq %rbp, -0x18(%rsp)
movq %r9, -0x20(%rsp)
movq %r15, -0x68(%rsp)
movl %eax, -0x80(%rsp)
jb 0xdb4c
movq %r11, %r9
leaq 0x3(%rdx), %r11
cmpq %r12, %r11
movq %rdi, %rsi
jae 0xde19
movq %rsi, -0x78(%rsp)
movq -0x60(%rsp), %rax
addq %r8, %rax
movq %rax, -0x58(%rsp)
movq %r9, -0x50(%rsp)
movzbl -0x3(%r13,%r11), %edx
movzbl -0x2(%r13,%r11), %ecx
movzbl -0x3(%r8,%r11), %eax
movzbl -0x2(%r8,%r11), %r15d
movq -0x58(%rsp), %rdi
movzbl -0x3(%rdi,%r11), %r9d
movl %eax, %r10d
subl %r9d, %r10d
movl %r10d, %ebp
negl %ebp
cmovsl %r10d, %ebp
movl $0xff, %esi
andl %esi, %ebp
movl %edx, %r10d
subl %r9d, %r10d
movl %r10d, %r13d
negl %r13d
cmovsl %r10d, %r13d
andl %esi, %r13d
leal (%rax,%rdx), %r10d
subl %r9d, %r10d
subl %r9d, %r10d
movl %r10d, %r14d
negl %r14d
cmovsl %r10d, %r14d
cmpl %ebp, %r13d
cmovael %ebp, %r13d
cmovbl %eax, %edx
movzbl -0x2(%rdi,%r11), %r10d
cmpl %r13d, %r14d
cmovbl %r9d, %edx
movq -0x78(%rsp), %rsi
addb -0x3(%rsi,%r11), %dl
movl %r15d, %eax
subl %r10d, %eax
movl %eax, %ebp
negl %ebp
cmovsl %eax, %ebp
movq -0x70(%rsp), %rax
movzbl -0x1(%rax,%r11), %eax
movl $0xff, %ebx
andl %ebx, %ebp
movl %ecx, %r9d
subl %r10d, %r9d
movl %r9d, %r14d
negl %r14d
cmovsl %r9d, %r14d
andl %ebx, %r14d
leal (%r15,%rcx), %r12d
subl %r10d, %r12d
subl %r10d, %r12d
movl %r12d, %r9d
negl %r9d
cmovsl %r12d, %r9d
movq -0x70(%rsp), %rbx
movzbl (%rbx,%r11), %r12d
cmpl %ebp, %r14d
cmovael %ebp, %r14d
movzbl -0x1(%r8,%r11), %r13d
cmovbl %r15d, %ecx
cmpl %r14d, %r9d
cmovbl %r10d, %ecx
addb -0x2(%rsi,%r11), %cl
movzbl -0x1(%rdi,%r11), %ebp
movl %r13d, %r9d
subl %ebp, %r9d
movl %r9d, %r14d
negl %r14d
cmovsl %r9d, %r14d
movl $0xff, %ebx
andl %ebx, %r14d
movl %eax, %r10d
subl %ebp, %r10d
movl %r10d, %r9d
negl %r9d
cmovsl %r10d, %r9d
andl %ebx, %r9d
leal (%rax,%r13), %ebx
subl %ebp, %ebx
subl %ebp, %ebx
movl %ebx, %r10d
negl %r10d
cmovsl %ebx, %r10d
movzbl (%r8,%r11), %ebx
cmpl %r14d, %r9d
cmovael %r14d, %r9d
cmovbl %r13d, %eax
movq -0x70(%rsp), %r13
movzbl (%rdi,%r11), %r15d
cmpl %r9d, %r10d
cmovbl %ebp, %eax
addb -0x1(%rsi,%r11), %al
movl %ebx, %r9d
subl %r15d, %r9d
movl %r9d, %r10d
negl %r10d
cmovsl %r9d, %r10d
movl $0xff, %edi
andl %edi, %r10d
movl %r12d, %r9d
subl %r15d, %r9d
movl %r9d, %ebp
negl %ebp
cmovsl %r9d, %ebp
andl %edi, %ebp
leal (%rbx,%r12), %r9d
subl %r15d, %r9d
subl %r15d, %r9d
movl %r9d, %r14d
negl %r14d
cmovsl %r9d, %r14d
movq -0x50(%rsp), %r9
cmpl %r10d, %ebp
cmovael %r10d, %ebp
cmovbl %ebx, %r12d
cmpl %ebp, %r14d
cmovbl %r15d, %r12d
addb (%rsi,%r11), %r12b
movb %dl, -0x3(%r9,%r11)
movb %cl, -0x2(%r9,%r11)
movb %al, -0x1(%r9,%r11)
movb %r12b, (%r9,%r11)
movq -0x48(%rsp), %r12
addq $0x4, %r11
cmpq %r12, %r11
jb 0xd96d
addq $-0x3, %r11
movq %r11, %rdx
jmp 0xde0f
movq %rdi, %rsi
cmpl $0x3, %r10d
jne 0xdcf7
leaq 0x2(%rdx), %rcx
cmpq %r12, %rcx
jae 0xde16
movq -0x10(%rsp), %rcx
leaq (%r8,%rcx), %rax
movq %rax, -0x78(%rsp)
movq %rdx, %rcx
movq %r11, -0x50(%rsp)
movzbl (%r13,%rcx), %r11d
movzbl 0x1(%r13,%rcx), %ebx
movzbl (%r8,%rcx), %r10d
movzbl 0x1(%r8,%rcx), %r9d
movq -0x78(%rsp), %rdi
movzbl -0x2(%rdi,%rcx), %r15d
movq %rsi, %rdx
movl %r10d, %eax
subl %r15d, %eax
movl %eax, %ebp
negl %ebp
cmovsl %eax, %ebp
movl $0xff, %esi
andl %esi, %ebp
movl %r11d, %eax
subl %r15d, %eax
movl %eax, %r14d
negl %r14d
cmovsl %eax, %r14d
andl %esi, %r14d
leal (%r10,%r11), %eax
subl %r15d, %eax
subl %r15d, %eax
movl %eax, %r12d
negl %r12d
cmovsl %eax, %r12d
movzbl 0x2(%r8,%rcx), %eax
cmpl %ebp, %r14d
cmovael %ebp, %r14d
cmovbl %r10d, %r11d
movzbl -0x1(%rdi,%rcx), %r10d
cmpl %r14d, %r12d
cmovbl %r15d, %r11d
addb (%rdx,%rcx), %r11b
movl %r9d, %ebp
subl %r10d, %ebp
movl %ebp, %r14d
negl %r14d
cmovsl %ebp, %r14d
andl %esi, %r14d
movl %ebx, %ebp
subl %r10d, %ebp
movl %ebp, %r15d
negl %r15d
cmovsl %ebp, %r15d
andl %esi, %r15d
leal (%r9,%rbx), %ebp
subl %r10d, %ebp
subl %r10d, %ebp
movl %ebp, %r12d
negl %r12d
cmovsl %ebp, %r12d
cmpl %r14d, %r15d
cmovael %r14d, %r15d
cmovbl %r9d, %ebx
movzbl (%rdi,%rcx), %r9d
cmpl %r15d, %r12d
cmovbl %r10d, %ebx
addb 0x1(%rdx,%rcx), %bl
movl %eax, %r10d
subl %r9d, %r10d
movl %r10d, %ebp
negl %ebp
cmovsl %r10d, %ebp
movzbl 0x2(%r13,%rcx), %r10d
andl %esi, %ebp
movl %r10d, %r14d
subl %r9d, %r14d
movl %r14d, %r15d
negl %r15d
cmovsl %r14d, %r15d
andl %esi, %r15d
leal (%rax,%r10), %r14d
subl %r9d, %r14d
subl %r9d, %r14d
movl %r14d, %r12d
negl %r12d
cmovsl %r14d, %r12d
cmpl %ebp, %r15d
cmovael %ebp, %r15d
cmovbl %eax, %r10d
movq %rdx, %rsi
cmpl %r15d, %r12d
movq -0x48(%rsp), %r12
cmovbl %r9d, %r10d
movq -0x50(%rsp), %r9
addb 0x2(%rdx,%rcx), %r10b
movb %r11b, (%r9,%rcx)
movb %bl, 0x1(%r9,%rcx)
movb %r10b, 0x2(%r9,%rcx)
leaq 0x3(%rcx), %rdx
addq $0x5, %rcx
cmpq %r12, %rcx
movq %rdx, %rcx
jb 0xdb7c
jmp 0xde19
movl -0x80(%rsp), %eax
jmp 0xde58
movl %edx, %eax
movq %rbx, %rdx
jmp 0xde58
movl -0x80(%rsp), %eax
jmp 0xdf14
cmpl $0x10, -0x7c(%rsp)
jb 0xde16
leaq 0x1(%rdx), %rcx
cmpq %r12, %rcx
movq %r11, %r9
jae 0xde19
movq %rsi, -0x78(%rsp)
movq -0x60(%rsp), %rax
addq %r8, %rax
movq %rax, -0x58(%rsp)
movzbl -0x1(%r13,%rcx), %edx
movq %r9, %rdi
movzbl -0x1(%r8,%rcx), %r9d
movzbl (%r8,%rcx), %r11d
movq -0x58(%rsp), %rsi
movzbl -0x1(%rsi,%rcx), %r10d
movl %r9d, %ebx
subl %r10d, %ebx
movl %ebx, %ebp
negl %ebp
cmovsl %ebx, %ebp
movl $0xff, %eax
andl %eax, %ebp
movl %edx, %ebx
subl %r10d, %ebx
movl %ebx, %r14d
negl %r14d
cmovsl %ebx, %r14d
andl %eax, %r14d
leal (%r9,%rdx), %ebx
subl %r10d, %ebx
subl %r10d, %ebx
movl %ebx, %r15d
negl %r15d
cmovsl %ebx, %r15d
cmpl %ebp, %r14d
cmovael %ebp, %r14d
cmovbl %r9d, %edx
movzbl (%rsi,%rcx), %r9d
cmpl %r14d, %r15d
cmovbl %r10d, %edx
movq -0x78(%rsp), %rsi
addb -0x1(%rsi,%rcx), %dl
movl %r11d, %r10d
subl %r9d, %r10d
movl %r10d, %ebx
negl %ebx
cmovsl %r10d, %ebx
movzbl (%r13,%rcx), %r10d
andl %eax, %ebx
movl %r10d, %ebp
subl %r9d, %ebp
movl %ebp, %r14d
negl %r14d
cmovsl %ebp, %r14d
andl %eax, %r14d
leal (%r11,%r10), %ebp
subl %r9d, %ebp
subl %r9d, %ebp
movl %ebp, %r15d
negl %r15d
cmovsl %ebp, %r15d
cmpl %ebx, %r14d
cmovael %ebx, %r14d
cmovbl %r11d, %r10d
cmpl %r14d, %r15d
cmovbl %r9d, %r10d
movq %rdi, %r9
addb (%rsi,%rcx), %r10b
movb %dl, -0x1(%rdi,%rcx)
movb %r10b, (%rdi,%rcx)
addq $0x2, %rcx
cmpq %r12, %rcx
jb 0xdd24
decq %rcx
movq %rcx, %rdx
movq -0x78(%rsp), %rsi
jmp 0xde19
movq %r11, %r9
movq %r9, %rbx
movb $0x1, %cl
cmpq %r12, %rdx
jne 0xde60
movq -0x28(%rsp), %r10
movq -0x38(%rsp), %rax
movq %rsi, %rdi
movq %rax, %rsi
movq -0x70(%rsp), %r13
movq -0x40(%rsp), %r14
movq -0x18(%rsp), %rbp
movq -0x20(%rsp), %r9
movq -0x68(%rsp), %r15
movl -0x80(%rsp), %eax
movq -0x30(%rsp), %rdx
movq %rbx, %r11
xorl %r8d, %r8d
jmp 0xdf14
movq -0x60(%rsp), %rcx
addq %r8, %rcx
movq -0x70(%rsp), %r13
movl $0xff, %r11d
movzbl (%r8,%rdx), %r9d
movzbl (%rcx,%rdx), %eax
movl %r9d, %r10d
subl %eax, %r10d
movl %r10d, %ebp
negl %ebp
cmovsl %r10d, %ebp
movzbl (%r13,%rdx), %r10d
andl %r11d, %ebp
movl %r10d, %r14d
subl %eax, %r14d
movl %r14d, %r15d
negl %r15d
cmovsl %r14d, %r15d
andl %r11d, %r15d
leal (%r9,%r10), %r14d
subl %eax, %r14d
subl %eax, %r14d
movl %r14d, %r12d
negl %r12d
cmovsl %r14d, %r12d
cmpl %ebp, %r15d
cmovael %ebp, %r15d
cmovbl %r9d, %r10d
cmpl %r15d, %r12d
movq -0x48(%rsp), %r12
cmovbl %eax, %r10d
addb (%rsi,%rdx), %r10b
movb %r10b, (%rbx,%rdx)
incq %rdx
cmpq %rdx, %r12
jne 0xde73
movq %rsi, %rdi
movq -0x28(%rsp), %r10
movq -0x38(%rsp), %rsi
movq -0x40(%rsp), %r14
movq -0x18(%rsp), %rbp
movq -0x20(%rsp), %r9
movq -0x68(%rsp), %r15
movl -0x80(%rsp), %eax
movq -0x30(%rsp), %rdx
movq %rbx, %r11
xorl %r8d, %r8d
movb $0x1, %cl
testb %cl, %cl
cmovel %r8d, %eax
je 0xdf46
movq %r12, %r8
imulq %r15, %r8
addq (%rsp), %r8
incq %r15
addq %r12, %r11
addq %rsi, %rdi
addq %r12, %r13
addq %r12, %rbp
addq %rsi, %r9
cmpq -0x8(%rsp), %r15
jne 0xd6f1
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
retq