// File: lunasorcery[P]brailify/./stb/stb_image_resize.h
// Function: stbir__calculate_coefficients_upsample(stbir__info*, stbir_filter, float, int, int, float, stbir__contributors*, float*)
static void stbir__calculate_coefficients_upsample(stbir__info* stbir_info, 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 $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movss %xmm0, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movss %xmm1, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
xorps %xmm0, %xmm0
movss %xmm0, -0x38(%rbp)
movl -0x18(%rbp), %eax
subl -0x14(%rbp), %eax
movl %eax, -0x44(%rbp)
movl -0xc(%rbp), %eax
movl %eax, %ecx
leaq 0xb01c(%rip), %rax      # 0x264b0
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movss 0x4b5d(%rip), %xmm0     # 0x20004
divss -0x10(%rbp), %xmm0
callq *%rax
movss 0x4b6e(%rip), %xmm1     # 0x20024
mulss %xmm1, %xmm0
callq 0x1f610
movl -0x44(%rbp), %eax
cvttss2si %xmm0, %ecx
cmpl %ecx, %eax
jg 0x1b4cc
jmp 0x1b4eb
leaq 0x609a(%rip), %rdi      # 0x2156d
leaq 0x5c90(%rip), %rsi      # 0x2116a
movl $0x40a, %edx            # imm = 0x40A
leaq 0x60ea(%rip), %rcx      # 0x215d0
callq 0x1090
movl -0x14(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movl -0x18(%rbp), %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x28(%rbp), %rax
movl 0x4(%rax), %eax
movq -0x28(%rbp), %rcx
cmpl (%rcx), %eax
jl 0x1b50f
jmp 0x1b52e
leaq 0x613b(%rip), %rdi      # 0x21651
leaq 0x5c4d(%rip), %rsi      # 0x2116a
movl $0x40f, %edx            # imm = 0x40F
leaq 0x60a7(%rip), %rcx      # 0x215d0
callq 0x1090
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl -0x18(%rbp), %ecx
subl -0x14(%rbp), %ecx
cmpl %ecx, %eax
jg 0x1b5f9
movl -0x34(%rbp), %eax
addl -0x14(%rbp), %eax
cvtsi2ss %eax, %xmm0
movss 0x4ab8(%rip), %xmm1     # 0x20010
addss %xmm1, %xmm0
movss %xmm0, -0x40(%rbp)
movl -0xc(%rbp), %eax
movl %eax, %ecx
leaq 0xaf43(%rip), %rax      # 0x264b0
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movss -0x1c(%rbp), %xmm0
subss -0x40(%rbp), %xmm0
movss 0x4a7b(%rip), %xmm1     # 0x20004
divss -0x10(%rbp), %xmm1
callq *%rax
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
cmpl $0x0, -0x34(%rbp)
jne 0x1b5d4
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x1b5d4
jp 0x1b5d4
movl -0x14(%rbp), %ecx
addl $0x1, %ecx
movl %ecx, -0x14(%rbp)
movq -0x28(%rbp), %rax
movl %ecx, (%rax)
movl -0x34(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1b5eb
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
addss -0x38(%rbp), %xmm0
movss %xmm0, -0x38(%rbp)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1b535
movl -0xc(%rbp), %eax
movl %eax, %ecx
leaq 0xaeab(%rip), %rax      # 0x264b0
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x18(%rbp), %ecx
addl $0x1, %ecx
cvtsi2ss %ecx, %xmm0
movss 0x49ef(%rip), %xmm1     # 0x20010
addss %xmm1, %xmm0
subss -0x1c(%rbp), %xmm0
movss 0x49d2(%rip), %xmm1     # 0x20004
divss -0x10(%rbp), %xmm1
callq *%rax
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x1b645
jp 0x1b645
jmp 0x1b664
leaq 0x6028(%rip), %rdi      # 0x21674
leaq 0x5b17(%rip), %rsi      # 0x2116a
movl $0x421, %edx            # imm = 0x421
leaq 0x5f71(%rip), %rcx      # 0x215d0
callq 0x1090
movss -0x38(%rbp), %xmm0
cvtss2sd %xmm0, %xmm0
movsd 0x4a43(%rip), %xmm1     # 0x200b8
ucomisd %xmm1, %xmm0
jbe 0x1b67d
jmp 0x1b69c
leaq 0x605c(%rip), %rdi      # 0x216e0
leaq 0x5adf(%rip), %rsi      # 0x2116a
movl $0x423, %edx            # imm = 0x423
leaq 0x5f39(%rip), %rcx      # 0x215d0
callq 0x1090
movss 0x49c4(%rip), %xmm0     # 0x20068
ucomiss -0x38(%rbp), %xmm0
jbe 0x1b6ac
jmp 0x1b6cb
leaq 0x6040(%rip), %rdi      # 0x216f3
leaq 0x5ab0(%rip), %rsi      # 0x2116a
movl $0x424, %edx            # imm = 0x424
leaq 0x5f0a(%rip), %rcx      # 0x215d0
callq 0x1090
movss 0x4931(%rip), %xmm0     # 0x20004
divss -0x38(%rbp), %xmm0
movss %xmm0, -0x3c(%rbp)
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl -0x18(%rbp), %ecx
subl -0x14(%rbp), %ecx
cmpl %ecx, %eax
jg 0x1b713
movss -0x3c(%rbp), %xmm0
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
mulss (%rax,%rcx,4), %xmm0
movss %xmm0, (%rax,%rcx,4)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1b6e4
movl -0x18(%rbp), %eax
subl -0x14(%rbp), %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jl 0x1b75b
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x1b73b
jp 0x1b73b
jmp 0x1b73d
jmp 0x1b75b
movq -0x28(%rbp), %rax
movl (%rax), %ecx
addl -0x34(%rbp), %ecx
subl $0x1, %ecx
movq -0x28(%rbp), %rax
movl %ecx, 0x4(%rax)
movl -0x34(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1b71c
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)