// File: shirat74[P]resample/Resampler.cc
// Function: Resampler::resampleImage(Image const&, float, float)
Image
Resampler::resampleImage (const Image& src, float xsize, float ysize)
{
  float xScale, yScale;

  Image dst((uint32_t) xsize, (uint32_t) ysize, src.getNComps(), src.getBPC());

  xScale = (float) xsize / (float) src.getWidth();
  yScale = (float) ysize / (float) src.getHeight();

  // create intermediate image to hold horizontal zoom
  Image tmp(dst.getWidth(), src.getHeight(), src.getNComps(), src.getBPC());
  if (xScale < 1.0)
    setupContributorForDownsample(xScale, dst.getWidth(), src.getWidth());
  else
    setupContributorForUpsample  (xScale, dst.getWidth(), src.getWidth());
  resampleX(tmp, src);

  if (yScale < 1.0)
    setupContributorForDownsample(yScale, dst.getHeight(), src.getHeight());
  else
    setupContributorForUpsample  (yScale, dst.getHeight(), src.getHeight());
  resampleY(dst, tmp);

  return  dst;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movq %rdi, -0x70(%rbp)
movq %rdi, %rax
movq %rax, -0x88(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movss %xmm0, -0x1c(%rbp)
movss %xmm1, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x80(%rbp)
movb $0x0, -0x29(%rbp)
cvttss2si -0x1c(%rbp), %rax
movl %eax, -0x68(%rbp)
cvttss2si -0x20(%rbp), %rax
movl %eax, -0x64(%rbp)
movq -0x18(%rbp), %rdi
callq 0x5690
movb %al, -0x71(%rbp)
movq -0x18(%rbp), %rdi
callq 0x56e0
movb -0x71(%rbp), %cl
movq -0x70(%rbp), %rdi
movl -0x68(%rbp), %esi
movl -0x64(%rbp), %edx
movsbl %cl, %ecx
movsbl %al, %r8d
callq 0x3760
movss -0x1c(%rbp), %xmm0
movss %xmm0, -0x60(%rbp)
movq -0x18(%rbp), %rdi
callq 0x56b0
movl %eax, -0x5c(%rbp)
jmp 0x77c3
movss -0x60(%rbp), %xmm0
movl -0x5c(%rbp), %eax
cvtsi2ss %eax, %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0x24(%rbp)
movss -0x20(%rbp), %xmm0
movss %xmm0, -0x90(%rbp)
movq -0x18(%rbp), %rdi
callq 0x56c0
movl %eax, -0x8c(%rbp)
jmp 0x77f6
movq -0x70(%rbp), %rdi
movss -0x90(%rbp), %xmm0
movl -0x8c(%rbp), %eax
cvtsi2ss %eax, %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0x28(%rbp)
callq 0x56b0
movl %eax, -0x94(%rbp)
jmp 0x7822
movq -0x18(%rbp), %rdi
callq 0x56c0
movl %eax, -0x98(%rbp)
jmp 0x7833
movq -0x18(%rbp), %rdi
callq 0x5690
movb %al, -0x99(%rbp)
jmp 0x7844
movq -0x18(%rbp), %rdi
callq 0x56e0
movb %al, -0x9a(%rbp)
jmp 0x7855
movl -0x98(%rbp), %edx
movl -0x94(%rbp), %esi
movb -0x9a(%rbp), %al
movb -0x99(%rbp), %cl
movsbl %cl, %ecx
movsbl %al, %r8d
leaq -0x58(%rbp), %rdi
callq 0x3760
jmp 0x787f
movss -0x24(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x5798(%rip), %xmm0     # 0xd028
ucomisd %xmm1, %xmm0
jbe 0x7911
movq -0x70(%rbp), %rdi
movss -0x24(%rbp), %xmm0
movss %xmm0, -0xa4(%rbp)
callq 0x56b0
movl %eax, -0xa0(%rbp)
jmp 0x78b4
movq -0x18(%rbp), %rdi
callq 0x56b0
movl %eax, -0xa8(%rbp)
jmp 0x78c5
movl -0xa8(%rbp), %edx
movl -0xa0(%rbp), %esi
movss -0xa4(%rbp), %xmm0
movq -0x80(%rbp), %rdi
callq 0x6c60
jmp 0x78e4
jmp 0x7961
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x7a6a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x3df0
jmp 0x7a6a
movq -0x70(%rbp), %rdi
movss -0x24(%rbp), %xmm0
movss %xmm0, -0xb0(%rbp)
callq 0x56b0
movl %eax, -0xac(%rbp)
jmp 0x792f
movq -0x18(%rbp), %rdi
callq 0x56b0
movl %eax, -0xb4(%rbp)
jmp 0x7940
movl -0xb4(%rbp), %edx
movl -0xac(%rbp), %esi
movss -0xb0(%rbp), %xmm0
movq -0x80(%rbp), %rdi
callq 0x6f90
jmp 0x795f
jmp 0x7961
movq -0x80(%rbp), %rdi
movq -0x18(%rbp), %rdx
leaq -0x58(%rbp), %rsi
callq 0x7230
jmp 0x7974
movss -0x28(%rbp), %xmm0
cvtss2sd %xmm0, %xmm1
movsd 0x56a3(%rip), %xmm0     # 0xd028
ucomisd %xmm1, %xmm0
jbe 0x79db
movq -0x70(%rbp), %rdi
movss -0x28(%rbp), %xmm0
movss %xmm0, -0xbc(%rbp)
callq 0x56c0
movl %eax, -0xb8(%rbp)
jmp 0x79a9
movq -0x18(%rbp), %rdi
callq 0x56c0
movl %eax, -0xc0(%rbp)
jmp 0x79ba
movl -0xc0(%rbp), %edx
movl -0xb8(%rbp), %esi
movss -0xbc(%rbp), %xmm0
movq -0x80(%rbp), %rdi
callq 0x6c60
jmp 0x79d9
jmp 0x7a2b
movq -0x70(%rbp), %rdi
movss -0x28(%rbp), %xmm0
movss %xmm0, -0xc8(%rbp)
callq 0x56c0
movl %eax, -0xc4(%rbp)
jmp 0x79f9
movq -0x18(%rbp), %rdi
callq 0x56c0
movl %eax, -0xcc(%rbp)
jmp 0x7a0a
movl -0xcc(%rbp), %edx
movl -0xc4(%rbp), %esi
movss -0xc8(%rbp), %xmm0
movq -0x80(%rbp), %rdi
callq 0x6f90
jmp 0x7a29
jmp 0x7a2b
movq -0x70(%rbp), %rsi
movq -0x80(%rbp), %rdi
leaq -0x58(%rbp), %rdx
callq 0x74b0
jmp 0x7a3e
movb $0x1, -0x29(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x3df0
testb $0x1, -0x29(%rbp)
jne 0x7a5a
movq -0x70(%rbp), %rdi
callq 0x3df0
movq -0x88(%rbp), %rax
addq $0xd0, %rsp
popq %rbp
retq
movq -0x70(%rbp), %rdi
callq 0x3df0
movq -0x38(%rbp), %rdi
callq 0x34f0
nopl (%rax)