// File: /workspace/github_c_makefile_star2_O3/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 0xdcf7
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
leal 0x7(%r8), %eax
movl %eax, -0x74(%rsp)
movl %eax, %r13d
shrl $0x3, %r13d
movl %edx, %eax
shrl $0x3, %eax
movl %r8d, %r9d
imulq %rax, %r9
andl $0x7, %edx
imull %r8d, %edx
addl $0x7, %edx
shrl $0x3, %edx
leaq (%r9,%rdx), %r8
addq %rdx, %r9
incq %r9
cmpl $0x1, %r13d
setne %al
leaq 0x1(%r13), %rdx
cmpq %r8, %rdx
setb %dl
andb %al, %dl
movb %dl, -0x75(%rsp)
leaq 0x2(%r13), %rax
movq %rax, -0x8(%rsp)
leaq 0x3(%r13), %rax
movq %rax, -0x58(%rsp)
movl %ecx, %eax
movq %rax, 0x10(%rsp)
leaq 0x1(%rsi), %r15
leaq 0x3(%rsi), %rax
movq %rax, -0x38(%rsp)
movq %r13, %rax
negq %rax
movq %rax, -0x50(%rsp)
movq %rdi, %rax
subq %r13, %rax
movq %rax, -0x60(%rsp)
leaq 0x4(%rsi), %r12
leaq (%rdi,%r13), %rax
addq $0x3, %rax
movq %r8, %r10
subq %r13, %r10
leaq (%rsi,%r13), %r11
addq $0x4, %r11
leaq (%rdi,%r13), %rbx
movq %rsi, 0x28(%rsp)
leaq (%rsi,%r13), %rbp
incq %rbp
xorl %edx, %edx
movq %rdi, 0x20(%rsp)
movq %rdi, %r14
xorl %ecx, %ecx
movq %r13, -0x40(%rsp)
movq %r8, -0x70(%rsp)
movq %r9, 0x18(%rsp)
movq %r10, -0x28(%rsp)
movq %rcx, -0x80(%rsp)
movq %r9, %rcx
imulq %rdx, %rcx
movq 0x28(%rsp), %rsi
movzbl (%rsi,%rcx), %ecx
cmpq $0x4, %rcx
ja 0xdcfa
movq %r8, %rdi
imulq %rdx, %rdi
addq 0x20(%rsp), %rdi
leaq 0x4def(%rip), %r9       # 0x12350
movslq (%r9,%rcx,4), %rcx
addq %r9, %rcx
movq %rax, -0x10(%rsp)
movq %r11, -0x68(%rsp)
movq %rdx, 0x30(%rsp)
movq %rdi, -0x30(%rsp)
jmpq *%rcx
testq %r8, %r8
movq %r15, %rsi
je 0xd7c8
xorl %ecx, %ecx
movb (%rsi,%rcx), %dl
movb %dl, (%r14,%rcx)
incq %rcx
cmpq %rcx, %r8
jne 0xd58c
jmp 0xd7c8
cmpq $0x0, -0x80(%rsp)
movq %r15, %rsi
je 0xd748
cmpl $0x8, -0x74(%rsp)
movq %rbx, -0x18(%rsp)
movq %rbp, -0x20(%rsp)
jae 0xd816
xorl %r9d, %r9d
movq -0x80(%rsp), %r15
cmpq %r8, %r9
movq -0x28(%rsp), %r10
movq -0x18(%rsp), %rbx
movq -0x20(%rsp), %rbp
je 0xd7c8
movq -0x50(%rsp), %rax
leaq (%r15,%rax), %rdx
movzbl (%r15,%r9), %r10d
movzbl (%rdx,%r9), %ecx
movl %r10d, %eax
subl %ecx, %eax
movl %eax, %r8d
negl %r8d
cmovsl %eax, %r8d
movq -0x60(%rsp), %rax
movzbl (%rax,%r9), %r11d
movl $0xff, %edi
andl %edi, %r8d
movl %r11d, %eax
subl %ecx, %eax
movl %eax, %ebx
negl %ebx
cmovsl %eax, %ebx
andl %edi, %ebx
leal (%r10,%r11), %eax
subl %ecx, %eax
subl %ecx, %eax
movl %eax, %ebp
negl %ebp
cmovsl %eax, %ebp
cmpl %r8d, %ebx
cmovael %r8d, %ebx
movq -0x70(%rsp), %r8
cmovbl %r10d, %r11d
movq -0x28(%rsp), %r10
cmpl %ebx, %ebp
movq -0x20(%rsp), %rbp
movq -0x18(%rsp), %rbx
cmovbl %ecx, %r11d
addb (%rsi,%r9), %r11b
movb %r11b, (%r14,%r9)
incq %r9
cmpq %r9, %r8
jne 0xd5ed
jmp 0xd7c8
cmpq $0x0, -0x80(%rsp)
movq %r15, %rsi
je 0xd77c
testq %r8, %r8
movq -0x80(%rsp), %rax
je 0xd7c8
xorl %ecx, %ecx
movb (%rax,%rcx), %dl
addb (%rsi,%rcx), %dl
movb %dl, (%r14,%rcx)
incq %rcx
cmpq %rcx, %r8
jne 0xd68e
jmp 0xd7c8
cmpq $0x0, -0x80(%rsp)
movq %r15, %rsi
je 0xd794
cmpl $0x8, -0x74(%rsp)
movq -0x80(%rsp), %rax
jb 0xd6d6
xorl %ecx, %ecx
movb (%rax,%rcx), %dl
shrb %dl
addb (%rsi,%rcx), %dl
movb %dl, (%r14,%rcx)
incq %rcx
cmpq %rcx, %r13
jne 0xd6c2
cmpq %r13, %r8
jbe 0xd7c8
addq %r13, %rax
xorl %ecx, %ecx
movzbl (%r14,%rcx), %edx
movzbl (%rax,%rcx), %r9d
addl %edx, %r9d
shrl %r9d
addb (%rbp,%rcx), %r9b
movb %r9b, (%rbx,%rcx)
incq %rcx
cmpq %rcx, %r10
jne 0xd6e4
jmp 0xd7c8
cmpl $0x8, -0x74(%rsp)
movq %r15, %rsi
jb 0xd725
xorl %ecx, %ecx
movb (%rsi,%rcx), %dl
movb %dl, (%r14,%rcx)
incq %rcx
cmpq %rcx, %r13
jne 0xd716
cmpq %r13, %r8
jbe 0xd7c8
xorl %ecx, %ecx
movb (%r14,%rcx), %dl
addb (%rbp,%rcx), %dl
movb %dl, (%rbx,%rcx)
incq %rcx
cmpq %rcx, %r10
jne 0xd730
jmp 0xd7c8
cmpl $0x8, -0x74(%rsp)
jb 0xd760
xorl %ecx, %ecx
movb (%rsi,%rcx), %al
movb %al, (%r14,%rcx)
incq %rcx
cmpq %rcx, %r13
jne 0xd751
cmpq %r13, %r8
jbe 0xd7c8
xorl %ecx, %ecx
movb (%r14,%rcx), %al
addb (%rbp,%rcx), %al
movb %al, (%rbx,%rcx)
incq %rcx
cmpq %rcx, %r10
jne 0xd767
jmp 0xd7c8
testq %r8, %r8
je 0xd7c8
xorl %ecx, %ecx
movb (%rsi,%rcx), %dl
movb %dl, (%r14,%rcx)
incq %rcx
cmpq %rcx, %r8
jne 0xd783
jmp 0xd7c8
cmpl $0x8, -0x74(%rsp)
jb 0xd7ac
xorl %ecx, %ecx
movb (%rsi,%rcx), %dl
movb %dl, (%r14,%rcx)
incq %rcx
cmpq %rcx, %r13
jne 0xd79d
cmpq %r13, %r8
jbe 0xd7c8
xorl %ecx, %ecx
movb (%r14,%rcx), %dl
shrb %dl
addb (%rbp,%rcx), %dl
movb %dl, (%rbx,%rcx)
incq %rcx
cmpq %rcx, %r10
jne 0xd7b3
movq 0x30(%rsp), %rdx
incq %rdx
addq %r8, %r14
movq 0x18(%rsp), %r9
addq %r9, %rsi
movq %rsi, %r15
addq %r9, -0x38(%rsp)
addq %r8, -0x60(%rsp)
addq %r9, %r12
movq -0x10(%rsp), %rax
addq %r8, %rax
movq -0x68(%rsp), %r11
addq %r9, %r11
addq %r8, %rbx
addq %r9, %rbp
cmpq 0x10(%rsp), %rdx
movq -0x30(%rsp), %rcx
jne 0xd52f
jmp 0xdce6
xorl %ecx, %ecx
movq -0x80(%rsp), %r15
movb (%r15,%rcx), %dl
addb (%rsi,%rcx), %dl
movb %dl, (%r14,%rcx)
incq %rcx
cmpq %rcx, %r13
jne 0xd81d
cmpl $0x20, -0x74(%rsp)
movq %r12, -0x48(%rsp)
jb 0xda4e
movq %r13, %r9
cmpq %r8, -0x58(%rsp)
movl $0xff, %ebx
jae 0xd5cc
movq -0x58(%rsp), %rax
addq %r15, %rax
movq %rax, (%rsp)
xorl %r9d, %r9d
movzbl (%r14,%r9), %ebp
movzbl 0x1(%r14,%r9), %edi
movq (%rsp), %r8
movzbl -0x3(%r8,%r9), %r10d
movzbl (%r15,%r9), %ecx
movl %r10d, %edx
subl %ecx, %edx
movl %edx, %r15d
negl %r15d
cmovsl %edx, %r15d
movzbl 0x2(%r14,%r9), %r11d
andl %ebx, %r15d
movl %ebp, %r13d
subl %ecx, %r13d
movl %r13d, %edx
negl %edx
cmovsl %r13d, %edx
andl %ebx, %edx
leal (%r10,%rbp), %r13d
subl %ecx, %r13d
subl %ecx, %r13d
movl %r13d, %r12d
negl %r12d
cmovsl %r13d, %r12d
movzbl -0x2(%r8,%r9), %r13d
cmpl %r15d, %edx
cmovael %r15d, %edx
movzbl -0x1(%r8,%r9), %r15d
cmovbl %r10d, %ebp
cmpl %edx, %r12d
cmovbl %ecx, %ebp
movq -0x68(%rsp), %rax
addb -0x3(%rax,%r9), %bpl
movq -0x80(%rsp), %rax
movzbl 0x1(%rax,%r9), %ecx
movl %r13d, %edx
subl %ecx, %edx
movl %edx, %r12d
negl %r12d
cmovsl %edx, %r12d
andl %ebx, %r12d
movl %edi, %r10d
subl %ecx, %r10d
movl %r10d, %edx
negl %edx
cmovsl %r10d, %edx
andl %ebx, %edx
leal (%rdi,%r13), %r10d
subl %ecx, %r10d
subl %ecx, %r10d
movl %r10d, %eax
negl %eax
cmovsl %r10d, %eax
movzbl (%r8,%r9), %r10d
cmpl %r12d, %edx
cmovael %r12d, %edx
movq %rdi, %r8
cmovbl %r13d, %r8d
movq -0x80(%rsp), %rdi
movzbl 0x2(%rdi,%r9), %r13d
movl $0xff, %ebx
cmpl %edx, %eax
cmovbl %ecx, %r8d
movq -0x68(%rsp), %rdi
addb -0x2(%rdi,%r9), %r8b
movq %r8, 0x8(%rsp)
movl %r15d, %eax
subl %r13d, %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
andl %ebx, %ecx
movl %r11d, %eax
subl %r13d, %eax
movl %eax, %r12d
negl %r12d
cmovsl %eax, %r12d
andl %ebx, %r12d
leal (%r15,%r11), %r8d
subl %r13d, %r8d
subl %r13d, %r8d
movl %r8d, %eax
negl %eax
cmovsl %r8d, %eax
cmpl %ecx, %r12d
cmovael %ecx, %r12d
cmovbl %r15d, %r11d
movq -0x80(%rsp), %rcx
movzbl 0x3(%rcx,%r9), %edx
cmpl %r12d, %eax
cmovbl %r13d, %r11d
movq -0x40(%rsp), %r13
addb -0x1(%rdi,%r9), %r11b
movl %r10d, %eax
subl %edx, %eax
movl %eax, %r8d
negl %r8d
cmovsl %eax, %r8d
movzbl 0x3(%r14,%r9), %ecx
andl %ebx, %r8d
movl %ecx, %eax
subl %edx, %eax
movl %eax, %r15d
negl %r15d
cmovsl %eax, %r15d
andl %ebx, %r15d
leal (%r10,%rcx), %eax
subl %edx, %eax
subl %edx, %eax
movl %eax, %r12d
negl %r12d
cmovsl %eax, %r12d
cmpl %r8d, %r15d
cmovael %r8d, %r15d
movq -0x70(%rsp), %r8
cmovbl %r10d, %ecx
cmpl %r15d, %r12d
movq -0x80(%rsp), %r15
cmovbl %edx, %ecx
addb (%rdi,%r9), %cl
movq -0x10(%rsp), %rax
movb %bpl, -0x3(%rax,%r9)
movq 0x8(%rsp), %rdx
movb %dl, -0x2(%rax,%r9)
movb %r11b, -0x1(%rax,%r9)
movb %cl, (%rax,%r9)
leaq (%r9,%r13), %rax
addq $0x7, %rax
addq $0x4, %r9
cmpq %r8, %rax
jb 0xd862
addq %r13, %r9
movq -0x48(%rsp), %r12
jmp 0xd5cc
cmpl $0x3, %r13d
jne 0xdbbe
movl $0x3, %r9d
cmpq %r8, -0x8(%rsp)
movl $0xff, %edi
jae 0xd5cc
movq -0x30(%rsp), %rax
movb (%rax), %r11b
movl $0x3, %edx
movzbl (%r15,%rdx), %r10d
movzbl -0x3(%r15,%rdx), %r9d
movl %r10d, %eax
subl %r9d, %eax
movl %eax, %ecx
negl %ecx
cmovsl %eax, %ecx
andl %edi, %ecx
movzbl %r11b, %r11d
movl %r11d, %eax
subl %r9d, %eax
movl %eax, %ebx
negl %ebx
cmovsl %eax, %ebx
andl %edi, %ebx
leal (%r10,%r11), %eax
subl %r9d, %eax
subl %r9d, %eax
movl %eax, %ebp
negl %ebp
cmovsl %eax, %ebp
cmpl %ecx, %ebx
movl $0xff, %edi
jb 0xdac7
movl %ecx, %ebx
movl %r11d, %r10d
cmpl %ebx, %ebp
jb 0xdace
movl %r10d, %r9d
movzbl -0x2(%r14,%rdx), %r11d
movzbl 0x1(%r15,%rdx), %ebx
movzbl 0x2(%r15,%rdx), %r10d
movzbl -0x2(%r15,%rdx), %ecx
addb -0x3(%r12,%rdx), %r9b
movl %ebx, %eax
subl %ecx, %eax
movl %eax, %r8d
negl %r8d
cmovsl %eax, %r8d
andl %edi, %r8d
movl %r11d, %eax
subl %ecx, %eax
movl %eax, %ebp
negl %ebp
cmovsl %eax, %ebp
andl %edi, %ebp
leal (%rbx,%r11), %eax
subl %ecx, %eax
subl %ecx, %eax
movl %eax, %r15d
negl %r15d
cmovsl %eax, %r15d
cmpl %r8d, %ebp
cmovael %r8d, %ebp
cmovbl %ebx, %r11d
movq -0x80(%rsp), %rax
movzbl -0x1(%rax,%rdx), %ebx
cmpl %ebp, %r15d
cmovbl %ecx, %r11d
addb -0x2(%r12,%rdx), %r11b
movl %r10d, %eax
subl %ebx, %eax
movl %eax, %r8d
negl %r8d
cmovsl %eax, %r8d
movzbl -0x1(%r14,%rdx), %ecx
andl %edi, %r8d
movl %ecx, %eax
subl %ebx, %eax
movl %eax, %ebp
negl %ebp
cmovsl %eax, %ebp
andl %edi, %ebp
leal (%r10,%rcx), %eax
subl %ebx, %eax
subl %ebx, %eax
movl %eax, %r15d
negl %r15d
cmovsl %eax, %r15d
cmpl %r8d, %ebp
cmovael %r8d, %ebp
cmovbl %r10d, %ecx
cmpl %ebp, %r15d
movq -0x80(%rsp), %r15
cmovbl %ebx, %ecx
addb -0x1(%r12,%rdx), %cl
movb %r9b, (%r14,%rdx)
movb %r11b, 0x1(%r14,%rdx)
movb %cl, 0x2(%r14,%rdx)
movl %r9d, %r11d
leaq 0x3(%rdx), %r9
addq $0x5, %rdx
movq -0x70(%rsp), %r8
cmpq %r8, %rdx
movq %r9, %rdx
jb 0xda7b
jmp 0xd5cc
movq %r13, %r9
cmpb $0x0, -0x75(%rsp)
movl $0xff, %edi
je 0xd5cc
movq -0x50(%rsp), %rax
leaq (%r15,%rax), %rdx
movl $0x2, %r11d
movq -0x60(%rsp), %rax
movzbl (%rax,%r11), %r9d
movzbl 0x1(%rax,%r11), %r10d
movzbl (%r15,%r11), %ecx
movzbl (%rdx,%r11), %r13d
movl %ecx, %eax
subl %r13d, %eax
movl %eax, %r8d
negl %r8d
cmovsl %eax, %r8d
andl %edi, %r8d
movl %r9d, %eax
subl %r13d, %eax
movl %eax, %ebp
negl %ebp
cmovsl %eax, %ebp
andl %edi, %ebp
leal (%rcx,%r9), %eax
subl %r13d, %eax
subl %r13d, %eax
movl %eax, %r15d
negl %r15d
cmovsl %eax, %r15d
movq -0x80(%rsp), %rax
movzbl 0x1(%rax,%r11), %ebx
cmpl %r8d, %ebp
cmovael %r8d, %ebp
cmovbl %ecx, %r9d
movzbl 0x1(%rdx,%r11), %ecx
cmpl %ebp, %r15d
cmovbl %r13d, %r9d
movq -0x40(%rsp), %r13
movl $0xff, %r15d
movq -0x38(%rsp), %rdi
addb -0x2(%rdi,%r11), %r9b
movl %ebx, %eax
subl %ecx, %eax
movl %eax, %r8d
negl %r8d
cmovsl %eax, %r8d
andl %r15d, %r8d
movl %r10d, %eax
subl %ecx, %eax
movl %eax, %ebp
negl %ebp
cmovsl %eax, %ebp
andl %r15d, %ebp
leal (%rbx,%r10), %eax
subl %ecx, %eax
subl %ecx, %eax
movl %eax, %r15d
negl %r15d
cmovsl %eax, %r15d
cmpl %r8d, %ebp
cmovael %r8d, %ebp
movq -0x70(%rsp), %r8
cmovbl %ebx, %r10d
cmpl %ebp, %r15d
movq -0x80(%rsp), %r15
cmovbl %ecx, %r10d
addb -0x1(%rdi,%r11), %r10b
movl $0xff, %edi
movq -0x48(%rsp), %r12
movb %r9b, (%r14,%r11)
movb %r10b, 0x1(%r14,%r11)
leaq 0x2(%r11), %r9
addq $0x3, %r11
cmpq %r8, %r11
movq %r9, %r11
jb 0xdbe0
jmp 0xd5cc
xorl %eax, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
retq
movl $0x24, %eax
jmp 0xdce8