// File: /workspace/github_c_makefile_star2_O0/algorithm-archivists[P]GathVL/src/objects/../../include/stb_image_resize.h
// Function: stbir__calculate_coefficients_upsample(stbir_filter, float, int, int, float, stbir__contributors*, float*)
static void stbir__calculate_coefficients_upsample(stbir_filter filter, float scale, int in_first_pixel, int in_last_pixel, float in_center_of_out, stbir__contributors* contributor, float* coefficient_group)
{
    int i;
    float total_filter = 0;
    float filter_scale;

    STBIR_ASSERT(in_last_pixel - in_first_pixel <= (int)ceil(stbir__filter_info_table[filter].support(1/scale) * 2)); // Taken directly from stbir__get_coefficient_width() which we can't call because we don't know if we're horizontal or vertical.

    contributor->n0 = in_first_pixel;
    contributor->n1 = in_last_pixel;

    STBIR_ASSERT(contributor->n1 >= contributor->n0);

    for (i = 0; i <= in_last_pixel - in_first_pixel; i++)
    {
        float in_pixel_center = (float)(i + in_first_pixel) + 0.5f;
        coefficient_group[i] = stbir__filter_info_table[filter].kernel(in_center_of_out - in_pixel_center, 1 / scale);

        // If the coefficient is zero, skip it. (Don't do the <0 check here, we want the influence of those outside pixels.)
        if (i == 0 && !coefficient_group[i])
        {
            contributor->n0 = ++in_first_pixel;
            i--;
            continue;
        }

        total_filter += coefficient_group[i];
    }

    STBIR_ASSERT(stbir__filter_info_table[filter].kernel((float)(in_last_pixel + 1) + 0.5f - in_center_of_out, 1/scale) == 0);

    STBIR_ASSERT(total_filter > 0.9);
    STBIR_ASSERT(total_filter < 1.1f); // Make sure it's not way off.

    // Make sure the sum of all coefficients is 1.
    filter_scale = 1 / total_filter;

    for (i = 0; i <= in_last_pixel - in_first_pixel; i++)
        coefficient_group[i] *= filter_scale;

    for (i = in_last_pixel - in_first_pixel; i >= 0; i--)
    {
        if (coefficient_group[i])
            break;

        // This line has no weight. We can skip it.
        contributor->n1 = contributor->n0 + i - 1;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl %edi, -0x4(%rbp)
movss %xmm0, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movss %xmm1, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x30(%rbp)
movl -0x10(%rbp), %eax
subl -0xc(%rbp), %eax
movl %eax, -0x3c(%rbp)
movl -0x4(%rbp), %eax
movl %eax, %ecx
leaq 0x1d9a0(%rip), %rax     # 0x4f5a0
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movss 0x9795(%rip), %xmm0     # 0x3b3a8
divss -0x8(%rbp), %xmm0
callq *%rax
movss 0x979a(%rip), %xmm1     # 0x3b3bc
mulss %xmm1, %xmm0
callq 0x35bf0
movl -0x3c(%rbp), %eax
cvttss2si %xmm0, %ecx
cmpl %ecx, %eax
jg 0x31c38
jmp 0x31c57
leaq 0xb0f1(%rip), %rdi      # 0x3cd30
leaq 0xacd3(%rip), %rsi      # 0x3c919
movl $0x411, %edx            # imm = 0x411
leaq 0xb141(%rip), %rcx      # 0x3cd93
callq 0x50f0
movl -0xc(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x10(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x20(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x20(%rbp), %rcx
cmpl (%rcx), %eax
jl 0x31c7b
jmp 0x31c9a
leaq 0xb183(%rip), %rdi      # 0x3ce05
leaq 0xac90(%rip), %rsi      # 0x3c919
movl $0x416, %edx            # imm = 0x416
leaq 0xb0fe(%rip), %rcx      # 0x3cd93
callq 0x50f0
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl -0x10(%rbp), %ecx
subl -0xc(%rbp), %ecx
cmpl %ecx, %eax
jg 0x31d65
movl -0x2c(%rbp), %eax
addl -0xc(%rbp), %eax
cvtsi2ss %eax, %xmm0
movss 0x96f0(%rip), %xmm1     # 0x3b3b4
addss %xmm1, %xmm0
movss %xmm0, -0x38(%rbp)
movl -0x4(%rbp), %eax
movl %eax, %ecx
leaq 0x1d8c7(%rip), %rax     # 0x4f5a0
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movss -0x14(%rbp), %xmm0
subss -0x38(%rbp), %xmm0
movss 0x96b3(%rip), %xmm1     # 0x3b3a8
divss -0x8(%rbp), %xmm1
callq *%rax
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
cmpl $0x0, -0x2c(%rbp)
jne 0x31d40
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x31d40
jp 0x31d40
movl -0xc(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0xc(%rbp)
movq -0x20(%rbp), %rax
movl %ecx, (%rax)
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x31d57
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
addss -0x30(%rbp), %xmm0
movss %xmm0, -0x30(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x31ca1
movl -0x4(%rbp), %eax
movl %eax, %ecx
leaq 0x1d82f(%rip), %rax     # 0x4f5a0
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x10(%rbp), %ecx
addl $0x1, %ecx
cvtsi2ss %ecx, %xmm0
movss 0x9627(%rip), %xmm1     # 0x3b3b4
addss %xmm1, %xmm0
subss -0x14(%rbp), %xmm0
movss 0x960a(%rip), %xmm1     # 0x3b3a8
divss -0x8(%rbp), %xmm1
callq *%rax
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x31db1
jp 0x31db1
jmp 0x31dd0
leaq 0xb070(%rip), %rdi      # 0x3ce28
leaq 0xab5a(%rip), %rsi      # 0x3c919
movl $0x428, %edx            # imm = 0x428
leaq 0xafc8(%rip), %rcx      # 0x3cd93
callq 0x50f0
movss -0x30(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x965f(%rip), %xmm1     # 0x3b440
ucomisd %xmm1, %xmm0
jbe 0x31de9
jmp 0x31e08
leaq 0xb0a4(%rip), %rdi      # 0x3ce94
leaq 0xab22(%rip), %rsi      # 0x3c919
movl $0x42a, %edx            # imm = 0x42A
leaq 0xaf90(%rip), %rcx      # 0x3cd93
callq 0x50f0
movss 0x95f0(%rip), %xmm0     # 0x3b400
ucomiss -0x30(%rbp), %xmm0
jbe 0x31e18
jmp 0x31e37
leaq 0xb088(%rip), %rdi      # 0x3cea7
leaq 0xaaf3(%rip), %rsi      # 0x3c919
movl $0x42b, %edx            # imm = 0x42B
leaq 0xaf61(%rip), %rcx      # 0x3cd93
callq 0x50f0
movss 0x9569(%rip), %xmm0     # 0x3b3a8
divss -0x30(%rbp), %xmm0
movss %xmm0, -0x34(%rbp)
movl $0x0, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movl -0x10(%rbp), %ecx
subl -0xc(%rbp), %ecx
cmpl %ecx, %eax
jg 0x31e7f
movss -0x34(%rbp), %xmm0
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
mulss (%rax,%rcx,4), %xmm0
movss %xmm0, (%rax,%rcx,4)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x31e50
movl -0x10(%rbp), %eax
subl -0xc(%rbp), %eax
movl %eax, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jl 0x31ec7
movq -0x28(%rbp), %rax
movslq -0x2c(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x31ea7
jp 0x31ea7
jmp 0x31ea9
jmp 0x31ec7
movq -0x20(%rbp), %rax
movl (%rax), %ecx
addl -0x2c(%rbp), %ecx
subl $0x1, %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x4(%rax)
movl -0x2c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x31e88
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)