// File: lvandeve[P]lodepng/pngdetail.cpp
// Function: rescale(std::vector<unsigned char, std::allocator<unsigned char>> const&, int, int, int, int, bool)
std::vector<unsigned char> rescale(const std::vector<unsigned char>& in,
                                   int w0, int h0, int w1, int h1, bool smooth) {
  int numchannels = in.size() / (w0 * h0);
  std::vector<unsigned char> out(w1 * h1 * numchannels);
  if(smooth) {
    // box filter.
    std::vector<unsigned char> temp(w1 * h0 * numchannels);
    for(int c = 0; c < numchannels; c++) {
      for(int x = 0; x < w1; x++) {
        float xaf = x * 1.0 * w0 / w1;
        float xbf = (x + 1.0) * w0 / w1;
        int xa = (int)xaf;
        int xb = (int)xbf;
        double norm = 1.0 / (xbf - xaf);
        xaf -= std::floor(xaf);
        xbf -= std::floor(xbf);
        for(int y = 0; y < h0; y++) {
          int index1 = x * numchannels + y * w1 * numchannels;
          double val = 0;
          for(int x0 = xa; x0 <= xb && x0 < w0; x0++) {
            int index0 = x0 * numchannels + y * w0 * numchannels;
            double v = 1;
            if(x0 == xa) v -= xaf;
            if(x0 == xb) v -= (1 - xbf);
            val += v * in[index0 + c];
          }
          temp[index1 + c] = val * norm;
        }
      }
      for(int y = 0; y < h1; y++) {
        float yaf = y * 1.0 * h0 / h1;
        float ybf = (y + 1.0) * h0 / h1;
        int ya = (int)yaf;
        int yb = (int)ybf;
        double norm = 1.0 / (ybf - yaf);
        yaf -= std::floor(yaf);
        ybf -= std::floor(ybf);
        for(int x = 0; x < w1; x++) {
          int index1 = x * numchannels + y * w1 * numchannels;
          double val = 0;
          for(int y0 = ya; y0 <= yb && y0 < h0; y0++) {
            int index0 = x * numchannels + y0 * w1 * numchannels;
            double v = 1;
            if(y0 == ya) v -= yaf;
            if(y0 == yb) v -= (1 - ybf);
            val += v * temp[index0 + c];
          }
          out[index1 + c] = val * norm;
        }
      }
    }
  } else {
    for(int y = 0; y < h1; y++) {
      int y0 = (int)((y + 0.5) * h0 / h1 - 0.5);
      for (int x = 0; x < w1; x++) {
        int x0 = (int)((x + 0.5) * w0 / w1 - 0.5);
        int index0 = x0 * numchannels + y0 * w0 * numchannels;
        int index1 = x * numchannels + y * w1 * numchannels;
        for (int c = 0; c < numchannels; c++) {
          out[index1 + c] = in[index0 + c];
        }
      }
    }
  }
  return out;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1a0, %rsp            # imm = 0x1A0
movq %rdi, -0x118(%rbp)
movq %rdi, %rax
movq %rax, -0x120(%rbp)
movb 0x10(%rbp), %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movl %r8d, -0x1c(%rbp)
movl %r9d, -0x20(%rbp)
andb $0x1, %al
movb %al, -0x21(%rbp)
movq -0x10(%rbp), %rdi
callq 0x19370
movl -0x14(%rbp), %ecx
movl -0x18(%rbp), %edx
imull %edx, %ecx
movslq %ecx, %rcx
xorl %edx, %edx
divq %rcx
movl %eax, -0x28(%rbp)
movb $0x0, -0x29(%rbp)
movl -0x1c(%rbp), %eax
movl -0x20(%rbp), %ecx
imull %ecx, %eax
movl -0x28(%rbp), %ecx
imull %ecx, %eax
cltq
movq %rax, -0x110(%rbp)
movb $0x0, -0x2a(%rbp)
leaq -0x2b(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x1af10
movq -0x118(%rbp), %rdi
movq -0x110(%rbp), %rsi
movq -0x108(%rbp), %rcx
leaq -0x2a(%rbp), %rdx
callq 0x32190
jmp 0x28fe7
leaq -0x2b(%rbp), %rdi
callq 0x1af60
testb $0x1, -0x21(%rbp)
je 0x296c7
movl -0x1c(%rbp), %eax
movl -0x18(%rbp), %ecx
imull %ecx, %eax
movl -0x28(%rbp), %ecx
imull %ecx, %eax
cltq
movq %rax, -0x130(%rbp)
movb $0x0, -0x59(%rbp)
leaq -0x5a(%rbp), %rdi
movq %rdi, -0x128(%rbp)
callq 0x1af10
movq -0x130(%rbp), %rsi
movq -0x128(%rbp), %rcx
leaq -0x58(%rbp), %rdi
leaq -0x59(%rbp), %rdx
callq 0x32190
jmp 0x29043
leaq -0x5a(%rbp), %rdi
callq 0x1af60
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x296a1
movl $0x0, -0x64(%rbp)
movl -0x64(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x29373
cvtsi2sdl -0x64(%rbp), %xmm0
cvtsi2sdl -0x14(%rbp), %xmm1
mulsd %xmm1, %xmm0
cvtsi2sdl -0x1c(%rbp), %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0x68(%rbp)
cvtsi2sdl -0x64(%rbp), %xmm1
movsd 0x10a01(%rip), %xmm0    # 0x39aa0
addsd %xmm0, %xmm1
cvtsi2sdl -0x14(%rbp), %xmm2
mulsd %xmm2, %xmm1
cvtsi2sdl -0x1c(%rbp), %xmm2
divsd %xmm2, %xmm1
cvtsd2ss %xmm1, %xmm1
movss %xmm1, -0x6c(%rbp)
cvttss2si -0x68(%rbp), %eax
movl %eax, -0x70(%rbp)
cvttss2si -0x6c(%rbp), %eax
movl %eax, -0x74(%rbp)
movss -0x6c(%rbp), %xmm1
movss -0x68(%rbp), %xmm2
subss %xmm2, %xmm1
cvtss2sd %xmm1, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x80(%rbp)
movss -0x68(%rbp), %xmm0
callq 0x32210
movss %xmm0, -0x134(%rbp)
jmp 0x290fd
movss -0x134(%rbp), %xmm1
movss -0x68(%rbp), %xmm0
subss %xmm1, %xmm0
movss %xmm0, -0x68(%rbp)
movss -0x6c(%rbp), %xmm0
callq 0x32210
movss %xmm0, -0x138(%rbp)
jmp 0x29127
movss -0x138(%rbp), %xmm1
movss -0x6c(%rbp), %xmm0
subss %xmm1, %xmm0
movss %xmm0, -0x6c(%rbp)
movl $0x0, -0x84(%rbp)
movl -0x84(%rbp), %eax
cmpl -0x18(%rbp), %eax
jge 0x29363
movl -0x64(%rbp), %eax
imull -0x28(%rbp), %eax
movl -0x84(%rbp), %ecx
imull -0x1c(%rbp), %ecx
imull -0x28(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x88(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0x90(%rbp)
movl -0x70(%rbp), %eax
movl %eax, -0x94(%rbp)
movl -0x94(%rbp), %ecx
xorl %eax, %eax
cmpl -0x74(%rbp), %ecx
movb %al, -0x139(%rbp)
jg 0x291ac
movl -0x94(%rbp), %eax
cmpl -0x14(%rbp), %eax
setl %al
movb %al, -0x139(%rbp)
movb -0x139(%rbp), %al
testb $0x1, %al
jne 0x291bb
jmp 0x29305
movl -0x94(%rbp), %eax
imull -0x28(%rbp), %eax
movl -0x84(%rbp), %ecx
imull -0x14(%rbp), %ecx
imull -0x28(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0x98(%rbp)
movsd 0x108bd(%rip), %xmm0    # 0x39aa0
movsd %xmm0, -0xa0(%rbp)
movl -0x94(%rbp), %eax
cmpl -0x70(%rbp), %eax
jne 0x29263
movss -0x68(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd -0xa0(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0xa0(%rbp)
jmp 0x29263
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x2b(%rbp), %rdi
callq 0x1af60
jmp 0x298a5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x5a(%rbp), %rdi
callq 0x1af60
jmp 0x29895
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x19430
jmp 0x296c2
movl -0x94(%rbp), %eax
cmpl -0x74(%rbp), %eax
jne 0x29293
movss 0x10782(%rip), %xmm0    # 0x399f8
subss -0x6c(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd -0xa0(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0xa0(%rbp)
movsd -0xa0(%rbp), %xmm0
movsd %xmm0, -0x150(%rbp)
movq -0x10(%rbp), %rdi
movl -0x98(%rbp), %eax
movl -0x60(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x19350
movq %rax, -0x148(%rbp)
jmp 0x292c3
movsd -0x150(%rbp), %xmm0
movq -0x148(%rbp), %rax
movzbl (%rax), %eax
cvtsi2sd %eax, %xmm2
movsd -0x90(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x90(%rbp)
movl -0x94(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0x29187
movsd -0x90(%rbp), %xmm0
movsd -0x80(%rbp), %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movb %al, -0x159(%rbp)
movl -0x88(%rbp), %eax
movl -0x60(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
leaq -0x58(%rbp), %rdi
callq 0x19560
movq %rax, -0x158(%rbp)
jmp 0x29340
movq -0x158(%rbp), %rax
movb -0x159(%rbp), %cl
movb %cl, (%rax)
movl -0x84(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x84(%rbp)
jmp 0x29147
jmp 0x29365
movl -0x64(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x64(%rbp)
jmp 0x29066
movl $0x0, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x29691
cvtsi2sdl -0xa4(%rbp), %xmm0
cvtsi2sdl -0x18(%rbp), %xmm1
mulsd %xmm1, %xmm0
cvtsi2sdl -0x20(%rbp), %xmm1
divsd %xmm1, %xmm0
cvtsd2ss %xmm0, %xmm0
movss %xmm0, -0xa8(%rbp)
cvtsi2sdl -0xa4(%rbp), %xmm1
movsd 0x106de(%rip), %xmm0    # 0x39aa0
addsd %xmm0, %xmm1
cvtsi2sdl -0x18(%rbp), %xmm2
mulsd %xmm2, %xmm1
cvtsi2sdl -0x20(%rbp), %xmm2
divsd %xmm2, %xmm1
cvtsd2ss %xmm1, %xmm1
movss %xmm1, -0xac(%rbp)
cvttss2si -0xa8(%rbp), %eax
movl %eax, -0xb0(%rbp)
cvttss2si -0xac(%rbp), %eax
movl %eax, -0xb4(%rbp)
movss -0xac(%rbp), %xmm1
movss -0xa8(%rbp), %xmm2
subss %xmm2, %xmm1
cvtss2sd %xmm1, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0xc0(%rbp)
movss -0xa8(%rbp), %xmm0
callq 0x32210
movss %xmm0, -0x160(%rbp)
jmp 0x2943b
movss -0x160(%rbp), %xmm1
movss -0xa8(%rbp), %xmm0
subss %xmm1, %xmm0
movss %xmm0, -0xa8(%rbp)
movss -0xac(%rbp), %xmm0
callq 0x32210
movss %xmm0, -0x164(%rbp)
jmp 0x2946e
movss -0x164(%rbp), %xmm1
movss -0xac(%rbp), %xmm0
subss %xmm1, %xmm0
movss %xmm0, -0xac(%rbp)
movl $0x0, -0xc4(%rbp)
movl -0xc4(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x2967b
movl -0xc4(%rbp), %eax
imull -0x28(%rbp), %eax
movl -0xa4(%rbp), %ecx
imull -0x1c(%rbp), %ecx
imull -0x28(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0xc8(%rbp)
xorps %xmm0, %xmm0
movsd %xmm0, -0xd0(%rbp)
movl -0xb0(%rbp), %eax
movl %eax, -0xd4(%rbp)
movl -0xd4(%rbp), %ecx
xorl %eax, %eax
cmpl -0xb4(%rbp), %ecx
movb %al, -0x165(%rbp)
jg 0x29502
movl -0xd4(%rbp), %eax
cmpl -0x18(%rbp), %eax
setl %al
movb %al, -0x165(%rbp)
movb -0x165(%rbp), %al
testb $0x1, %al
jne 0x29511
jmp 0x29617
movl -0xc4(%rbp), %eax
imull -0x28(%rbp), %eax
movl -0xd4(%rbp), %ecx
imull -0x1c(%rbp), %ecx
imull -0x28(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0xd8(%rbp)
movsd 0x10567(%rip), %xmm0    # 0x39aa0
movsd %xmm0, -0xe0(%rbp)
movl -0xd4(%rbp), %eax
cmpl -0xb0(%rbp), %eax
jne 0x2956f
movss -0xa8(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd -0xe0(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0xe0(%rbp)
movl -0xd4(%rbp), %eax
cmpl -0xb4(%rbp), %eax
jne 0x295a5
movss 0x10473(%rip), %xmm0    # 0x399f8
subss -0xac(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd -0xe0(%rbp), %xmm0
subsd %xmm1, %xmm0
movsd %xmm0, -0xe0(%rbp)
movsd -0xe0(%rbp), %xmm0
movsd %xmm0, -0x178(%rbp)
movl -0xd8(%rbp), %eax
movl -0x60(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
leaq -0x58(%rbp), %rdi
callq 0x19560
movq %rax, -0x170(%rbp)
jmp 0x295d5
movsd -0x178(%rbp), %xmm0
movq -0x170(%rbp), %rax
movzbl (%rax), %eax
cvtsi2sd %eax, %xmm2
movsd -0xd0(%rbp), %xmm1
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0xd0(%rbp)
movl -0xd4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xd4(%rbp)
jmp 0x294da
movq -0x118(%rbp), %rdi
movsd -0xd0(%rbp), %xmm0
movsd -0xc0(%rbp), %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movb %al, -0x181(%rbp)
movl -0xc8(%rbp), %eax
movl -0x60(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x19560
movq %rax, -0x180(%rbp)
jmp 0x29658
movq -0x180(%rbp), %rax
movb -0x181(%rbp), %cl
movb %cl, (%rax)
movl -0xc4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc4(%rbp)
jmp 0x29494
jmp 0x2967d
movl -0xa4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa4(%rbp)
jmp 0x2937d
jmp 0x29693
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x29053
leaq -0x58(%rbp), %rdi
callq 0x19430
jmp 0x296ac
jmp 0x2986f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x29895
jmp 0x29895
movl $0x0, -0xe4(%rbp)
movl -0xe4(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x2986d
cvtsi2sdl -0xe4(%rbp), %xmm0
movsd 0x106a0(%rip), %xmm1    # 0x39d90
addsd %xmm1, %xmm0
cvtsi2sdl -0x18(%rbp), %xmm1
mulsd %xmm1, %xmm0
cvtsi2sdl -0x20(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd 0x10682(%rip), %xmm1    # 0x39d90
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0xe8(%rbp)
movl $0x0, -0xec(%rbp)
movl -0xec(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jge 0x29857
cvtsi2sdl -0xec(%rbp), %xmm0
movsd 0x1064b(%rip), %xmm1    # 0x39d90
addsd %xmm1, %xmm0
cvtsi2sdl -0x14(%rbp), %xmm1
mulsd %xmm1, %xmm0
cvtsi2sdl -0x1c(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd 0x1062d(%rip), %xmm1    # 0x39d90
subsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movl %eax, -0xf0(%rbp)
movl -0xf0(%rbp), %eax
imull -0x28(%rbp), %eax
movl -0xe8(%rbp), %ecx
imull -0x14(%rbp), %ecx
imull -0x28(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0xf4(%rbp)
movl -0xec(%rbp), %eax
imull -0x28(%rbp), %eax
movl -0xe4(%rbp), %ecx
imull -0x1c(%rbp), %ecx
imull -0x28(%rbp), %ecx
addl %ecx, %eax
movl %eax, -0xf8(%rbp)
movl $0x0, -0xfc(%rbp)
movl -0xfc(%rbp), %eax
cmpl -0x28(%rbp), %eax
jge 0x29841
movq -0x10(%rbp), %rdi
movl -0xf4(%rbp), %eax
movl -0xfc(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x19350
movq %rax, -0x190(%rbp)
jmp 0x297e9
movq -0x118(%rbp), %rdi
movq -0x190(%rbp), %rax
movb (%rax), %al
movb %al, -0x199(%rbp)
movl -0xf8(%rbp), %eax
movl -0xfc(%rbp), %ecx
addl %ecx, %eax
movslq %eax, %rsi
callq 0x19560
movq %rax, -0x198(%rbp)
jmp 0x2981e
movq -0x198(%rbp), %rax
movb -0x199(%rbp), %cl
movb %cl, (%rax)
movl -0xfc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xfc(%rbp)
jmp 0x297bb
jmp 0x29843
movl -0xec(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xec(%rbp)
jmp 0x29726
jmp 0x29859
movl -0xe4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xe4(%rbp)
jmp 0x296d1
jmp 0x2986f
movb $0x1, -0x29(%rbp)
testb $0x1, -0x29(%rbp)
jne 0x29885
movq -0x118(%rbp), %rdi
callq 0x19430
movq -0x120(%rbp), %rax
addq $0x1a0, %rsp            # imm = 0x1A0
popq %rbp
retq
movq -0x118(%rbp), %rdi
callq 0x19430
jmp 0x298a3
jmp 0x298a5
movq -0x38(%rbp), %rdi
callq 0x2430
movq %rax, %rdi
callq 0x19400
nopw %cs:(%rax,%rax)