// File: /workspace/github_cpp_makefile_star2_O2/mhe[P]raytracerframework_cpp/lodepng.cpp
// Function: filterScanline(unsigned char*, unsigned char const*, unsigned char const*, unsigned long, unsigned long, unsigned char)
static void filterScanline(unsigned char* out, const unsigned char* scanline, const unsigned char* prevline, size_t length, size_t bytewidth, unsigned char filterType)
{
  size_t i;
  switch(filterType)
  {
    case 0:
      if(prevline) for(i = 0; i < length; i++) out[i] = scanline[i];
      else         for(i = 0; i < length; i++) out[i] = scanline[i];
      break;
    case 1:
      if(prevline)
      {
        for(i =         0; i < bytewidth; i++) out[i] = scanline[i];
        for(i = bytewidth; i < length   ; i++) out[i] = scanline[i] - scanline[i - bytewidth];
      }
      else
      {
        for(i =         0; i < bytewidth; i++) out[i] = scanline[i];
        for(i = bytewidth; i <    length; i++) out[i] = scanline[i] - scanline[i - bytewidth];
      }
      break;
    case 2:
      if(prevline) for(i = 0; i < length; i++) out[i] = scanline[i] - prevline[i];
      else         for(i = 0; i < length; i++) out[i] = scanline[i];
      break;
    case 3:
      if(prevline)
      {
        for(i =         0; i < bytewidth; i++) out[i] = scanline[i] - prevline[i] / 2;
        for(i = bytewidth; i <    length; i++) out[i] = scanline[i] - ((scanline[i - bytewidth] + prevline[i]) / 2);
      }
      else
      {
        for(i =         0; i < length; i++) out[i] = scanline[i];
        for(i = bytewidth; i < length; i++) out[i] = scanline[i] - scanline[i - bytewidth] / 2;
      }
      break;
    case 4:
      if(prevline)
      {
        for(i =         0; i < bytewidth; i++) out[i] = (unsigned char)(scanline[i] - paethPredictor(0, prevline[i], 0));
        for(i = bytewidth; i <    length; i++) out[i] = (unsigned char)(scanline[i] - paethPredictor(scanline[i - bytewidth], prevline[i], prevline[i - bytewidth]));
      }
      else
      {
        for(i =         0; i < bytewidth; i++) out[i] = scanline[i];
        for(i = bytewidth; i <    length; i++) out[i] = (unsigned char)(scanline[i] - paethPredictor(scanline[i - bytewidth], 0, 0));
      }
      break;
  default: return; /*unexisting filter type given*/
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rcx, %r10
movq %rdx, %r13
movq %rsi, %r14
movq %rdi, %r15
movl %r9d, %eax
leaq 0xac25(%rip), %rcx      # 0x22880
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
xorl %eax, %eax
testq %r13, %r13
je 0x17c8c
cmpq %rax, %r10
je 0x17d02
movb (%r14,%rax), %cl
movb %cl, (%r15,%rax)
incq %rax
jmp 0x17c6b
movb (%r14,%rax), %cl
movb %cl, (%r15,%rax)
incq %rax
cmpq %rax, %r10
jne 0x17c81
jmp 0x17d02
testq %r13, %r13
je 0x17e6e
movq %r10, -0x48(%rbp)
xorl %ebx, %ebx
movq %r8, -0x30(%rbp)
cmpq %rbx, %r8
je 0x17df5
movb (%r14,%rbx), %r12b
movzbl (%r13,%rbx), %esi
xorl %edi, %edi
xorl %edx, %edx
callq 0x178b2
movq -0x30(%rbp), %r8
subb %al, %r12b
movb %r12b, (%r15,%rbx)
incq %rbx
jmp 0x17ca6
xorl %eax, %eax
testq %r13, %r13
jne 0x17ceb
jmp 0x17cfd
movb (%r14,%rax), %cl
subb (%r13,%rax), %cl
movb %cl, (%r15,%rax)
incq %rax
cmpq %rax, %r10
jne 0x17cdb
jmp 0x17d02
movb (%r14,%rax), %cl
movb %cl, (%r15,%rax)
incq %rax
cmpq %rax, %r10
jne 0x17cf2
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
xorl %eax, %eax
testq %r13, %r13
jne 0x17d2e
jmp 0x17d71
movb (%r14,%rax), %cl
movb (%r13,%rax), %dl
shrb %dl
subb %dl, %cl
movb %cl, (%r15,%rax)
incq %rax
cmpq %rax, %r8
jne 0x17d1a
leaq (%r14,%r8), %rax
addq %r8, %r13
addq %r8, %r15
xorl %ecx, %ecx
leaq (%r8,%rcx), %rdx
cmpq %r10, %rdx
jae 0x17d02
movb (%rax,%rcx), %dl
movzbl (%r14,%rcx), %esi
movzbl (%r13,%rcx), %edi
addl %esi, %edi
shrl %edi
subb %dil, %dl
movb %dl, (%r15,%rcx)
incq %rcx
jmp 0x17d3f
movb (%r14,%rax), %cl
movb %cl, (%r15,%rax)
incq %rax
cmpq %rax, %r10
jne 0x17d66
leaq (%r14,%r8), %rax
addq %r8, %r15
xorl %ecx, %ecx
leaq (%r8,%rcx), %rdx
cmpq %r10, %rdx
jae 0x17d02
movb (%rax,%rcx), %dl
movb (%r14,%rcx), %sil
shrb %sil
subb %sil, %dl
movb %dl, (%r15,%rcx)
incq %rcx
jmp 0x17d7f
xorl %eax, %eax
testq %r13, %r13
je 0x17dca
cmpq %rax, %r8
je 0x17e48
movb (%r14,%rax), %cl
movb %cl, (%r15,%rax)
incq %rax
jmp 0x17da9
movb (%r14,%rax), %cl
movb %cl, (%r15,%rax)
incq %rax
cmpq %rax, %r8
jne 0x17dbf
leaq (%r14,%r8), %rax
addq %r8, %r15
xorl %ecx, %ecx
leaq (%r8,%rcx), %rdx
cmpq %r10, %rdx
jae 0x17d02
movb (%rax,%rcx), %dl
subb (%r14,%rcx), %dl
movb %dl, (%r15,%rcx)
incq %rcx
jmp 0x17dd8
leaq (%r14,%r8), %rax
movq %rax, -0x40(%rbp)
leaq (%r8,%r13), %rax
movq %rax, -0x38(%rbp)
addq %r8, %r15
xorl %ebx, %ebx
leaq (%r8,%rbx), %rax
cmpq -0x48(%rbp), %rax
jae 0x17d02
movq -0x40(%rbp), %rax
movb (%rax,%rbx), %r12b
movzbl (%r14,%rbx), %edi
movq -0x38(%rbp), %rax
movzbl (%rax,%rbx), %esi
movzbl (%r13,%rbx), %edx
callq 0x178b2
movq -0x30(%rbp), %r8
subb %al, %r12b
movb %r12b, (%r15,%rbx)
incq %rbx
jmp 0x17e0a
leaq (%r14,%r8), %rax
addq %r8, %r15
xorl %ecx, %ecx
leaq (%r8,%rcx), %rdx
cmpq %r10, %rdx
jae 0x17d02
movb (%rax,%rcx), %dl
subb (%r14,%rcx), %dl
movb %dl, (%r15,%rcx)
incq %rcx
jmp 0x17e51
xorl %eax, %eax
cmpq %rax, %r8
je 0x17e82
movb (%r14,%rax), %cl
movb %cl, (%r15,%rax)
incq %rax
jmp 0x17e70
leaq (%r14,%r8), %rax
addq %r8, %r15
xorl %ecx, %ecx
leaq (%r8,%rcx), %rdx
cmpq %r10, %rdx
jae 0x17d02
movb (%rax,%rcx), %dl
subb (%r14,%rcx), %dl
movb %dl, (%r15,%rcx)
incq %rcx
jmp 0x17e8b