// File: /workspace/github_cpp_makefile_star2_O1/shirat74[P]resample/Resampler.cc
// Function: Resampler::setupContributorForDownsample(float, int, int)
void
Resampler::setupContributorForDownsample (float   scale,
                                          int32_t dstSize,
                                          int32_t boundary)
{
  float supportSize = support / scale;

  contributor.resize(dstSize);

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

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movq %rdx, 0x30(%rsp)
movl %esi, %ebp
movss %xmm0, 0x10(%rsp)
movq %rdi, %r14
movss 0x8(%rdi), %xmm0
movss %xmm0, 0xc(%rsp)
leaq 0x10(%rdi), %r15
movslq %esi, %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x4562
testl %r12d, %r12d
jle 0x3f7d
movss 0xc(%rsp), %xmm0
divss 0x10(%rsp), %xmm0
movss %xmm0, 0xc(%rsp)
addss %xmm0, %xmm0
addss 0x2376(%rip), %xmm0     # 0x6154
cvttss2si %xmm0, %eax
cltq
movq %rax, 0x40(%rsp)
movl %ebp, %eax
movq %rax, 0x38(%rsp)
movq 0x30(%rsp), %rax
leal -0x1(,%rax,2), %ebp
xorl %ebx, %ebx
movq (%r15), %rax
movq %rbx, %r12
shlq $0x5, %r12
movl $0x0, (%rax,%r12)
leaq 0x50(%rsp), %r13
movq %r13, %rdi
movq 0x40(%rsp), %rsi
leaq 0x1f(%rsp), %rdx
callq 0x4592
movq (%r15), %rax
leaq (%rax,%r12), %rdi
addq $0x8, %rdi
movq %r13, %rsi
callq 0x4624
movq %rbx, 0x48(%rsp)
xorps %xmm0, %xmm0
cvtsi2ss %ebx, %xmm0
divss 0x10(%rsp), %xmm0
movss %xmm0, 0x18(%rsp)
subss 0xc(%rsp), %xmm0
callq 0x21a0
movaps %xmm0, 0x20(%rsp)
movss 0xc(%rsp), %xmm0
addss 0x18(%rsp), %xmm0
callq 0x2100
movaps 0x20(%rsp), %xmm1
cvttss2si %xmm1, %ebx
cvttps2dq %xmm1, %xmm1
cvtdq2ps %xmm1, %xmm1
xorps %xmm2, %xmm2
movss %xmm2, 0x20(%rsp)
movss %xmm0, 0x14(%rsp)
ucomiss %xmm1, %xmm0
jb 0x3edd
leal 0x1(%rbx), %r13d
xorps %xmm0, %xmm0
movss %xmm0, 0x20(%rsp)
movss 0x18(%rsp), %xmm0
subss %xmm1, %xmm0
mulss 0x10(%rsp), %xmm0
callq *(%r14)
xorps %xmm1, %xmm1
cvtsi2ss %r13d, %xmm1
movss 0x20(%rsp), %xmm2
addss %xmm0, %xmm2
movss %xmm2, 0x20(%rsp)
incl %r13d
movss 0x14(%rsp), %xmm0
ucomiss %xmm1, %xmm0
jae 0x3ea4
xorps %xmm1, %xmm1
cvtsi2ss %ebx, %xmm1
movss 0x14(%rsp), %xmm0
ucomiss %xmm1, %xmm0
jb 0x3f53
movl %ebx, %r13d
negl %r13d
movss 0x18(%rsp), %xmm0
subss %xmm1, %xmm0
mulss 0x10(%rsp), %xmm0
callq *(%r14)
divss 0x20(%rsp), %xmm0
leal (%rbp,%r13), %eax
cmpl 0x30(%rsp), %ebx
cmovll %ebx, %eax
testl %ebx, %ebx
cmovsl %r13d, %eax
movq (%r15), %rcx
movslq (%rcx,%r12), %rdx
leal 0x1(%rdx), %esi
movl %esi, (%rcx,%r12)
movq 0x8(%rcx,%r12), %rcx
movl %eax, (%rcx,%rdx,8)
incl %ebx
xorps %xmm1, %xmm1
cvtsi2ss %ebx, %xmm1
movss %xmm0, 0x4(%rcx,%rdx,8)
decl %r13d
movss 0x14(%rsp), %xmm0
ucomiss %xmm1, %xmm0
jae 0x3ef5
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x3f6a
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x22d0
movq 0x48(%rsp), %rbx
incq %rbx
cmpq 0x38(%rsp), %rbx
jne 0x3dfe
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x3f90
jmp 0x3f90
movq %rax, %rbx
movq 0x50(%rsp), %rdi
testq %rdi, %rdi
je 0x3faa
movq 0x60(%rsp), %rsi
subq %rdi, %rsi
callq 0x22d0
movq %rbx, %rdi
callq 0x2400