// File: shirat74[P]resample/Resampler.cc
// Function: Resampler::setupContributorForUpsample(float, int, int)
void
Resampler::setupContributorForUpsample (float   scale,
                                        int32_t dstSize,
                                        int32_t boundary)
{
  contributor.resize(dstSize);

  for (int32_t i = 0; i < dstSize; i++) {
    contributor[i].n = 0;
    std::vector<Contrib> p((int)(support * 2 + 1));
    contributor[i].p = p;
    float center = (float) i / scale;
    float left   = ceil (center - support);
    float right  = floor(center + support);
    for (int32_t j = left; j <= right; j++) {
      float   weight = (*filter_fn)(center - j);
      int32_t n = j;
      // reflect at boundary
      if (j < 0) {
        n = -j;
      } else if (j >= boundary) {
        n = (boundary - j) + boundary - 1;
      }
      int k = contributor[i].n++;
      contributor[i].p[k].pixel  = n;
      contributor[i].p[k].weight = weight;
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movq %rdi, -0x8(%rbp)
movss %xmm0, -0xc(%rbp)
movl %esi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x68(%rbp)
addq $0x10, %rdi
movslq -0x10(%rbp), %rsi
callq 0x7be0
movl $0x0, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x10(%rbp), %eax
jge 0x721c
movq -0x68(%rbp), %rdi
addq $0x10, %rdi
movslq -0x18(%rbp), %rsi
callq 0x7c70
movq %rax, %rcx
movq -0x68(%rbp), %rax
movl $0x0, (%rcx)
movss 0x8(%rax), %xmm0
addss %xmm0, %xmm0
movss 0x617b(%rip), %xmm1     # 0xd17c
addss %xmm1, %xmm0
cvttss2si %xmm0, %eax
cltq
movq %rax, -0x78(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0x70(%rbp)
callq 0x7c90
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
leaq -0x30(%rbp), %rdi
callq 0x7cb0
jmp 0x702f
leaq -0x31(%rbp), %rdi
callq 0x7d20
movq -0x68(%rbp), %rdi
addq $0x10, %rdi
movslq -0x18(%rbp), %rsi
callq 0x7c70
movq %rax, %rdi
addq $0x8, %rdi
leaq -0x30(%rbp), %rsi
callq 0x7d40
jmp 0x705b
movq -0x68(%rbp), %rax
cvtsi2ssl -0x18(%rbp), %xmm0
movss -0xc(%rbp), %xmm1
divss %xmm1, %xmm0
movss %xmm0, -0x48(%rbp)
movss -0x48(%rbp), %xmm0
movss 0x8(%rax), %xmm1
subss %xmm1, %xmm0
callq 0x7f90
movss %xmm0, -0x7c(%rbp)
jmp 0x708c
movq -0x68(%rbp), %rax
movss -0x7c(%rbp), %xmm0
movss %xmm0, -0x4c(%rbp)
movss -0x48(%rbp), %xmm0
movss 0x8(%rax), %xmm1
addss %xmm1, %xmm0
callq 0x7fb0
movss %xmm0, -0x80(%rbp)
jmp 0x70b4
movss -0x80(%rbp), %xmm0
movss %xmm0, -0x50(%rbp)
cvttss2si -0x4c(%rbp), %eax
movl %eax, -0x54(%rbp)
cvtsi2ssl -0x54(%rbp), %xmm1
movss -0x50(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jb 0x7205
movq -0x68(%rbp), %rax
movq (%rax), %rax
movss -0x48(%rbp), %xmm0
cvtsi2ssl -0x54(%rbp), %xmm1
subss %xmm1, %xmm0
callq *%rax
movss %xmm0, -0x84(%rbp)
jmp 0x70fa
movss -0x84(%rbp), %xmm0
movss %xmm0, -0x58(%rbp)
movl -0x54(%rbp), %eax
movl %eax, -0x5c(%rbp)
cmpl $0x0, -0x54(%rbp)
jge 0x7151
xorl %eax, %eax
subl -0x54(%rbp), %eax
movl %eax, -0x5c(%rbp)
jmp 0x716a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x31(%rbp), %rdi
callq 0x7d20
jmp 0x7225
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x7ff0
jmp 0x7225
movl -0x54(%rbp), %eax
cmpl -0x14(%rbp), %eax
jl 0x7168
movl -0x14(%rbp), %eax
subl -0x54(%rbp), %eax
addl -0x14(%rbp), %eax
subl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x716a
movq -0x68(%rbp), %rdi
addq $0x10, %rdi
movslq -0x18(%rbp), %rsi
callq 0x7c70
movq -0x68(%rbp), %rdi
movq %rax, %rcx
movl (%rcx), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, (%rcx)
movl %eax, -0x60(%rbp)
movl -0x5c(%rbp), %eax
movl %eax, -0x8c(%rbp)
addq $0x10, %rdi
movslq -0x18(%rbp), %rsi
callq 0x7c70
movq %rax, %rdi
addq $0x8, %rdi
movslq -0x60(%rbp), %rsi
callq 0x7fd0
movl -0x8c(%rbp), %ecx
movq -0x68(%rbp), %rdi
movl %ecx, (%rax)
movss -0x58(%rbp), %xmm0
movss %xmm0, -0x88(%rbp)
addq $0x10, %rdi
movslq -0x18(%rbp), %rsi
callq 0x7c70
movq %rax, %rdi
addq $0x8, %rdi
movslq -0x60(%rbp), %rsi
callq 0x7fd0
movss -0x88(%rbp), %xmm0
movss %xmm0, 0x4(%rax)
movl -0x54(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x54(%rbp)
jmp 0x70c6
leaq -0x30(%rbp), %rdi
callq 0x7ff0
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x6fc6
addq $0x90, %rsp
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x34f0
nop