// File: lunasorcery[P]brailify/./stb/stb_image_resize.h
// Function: stbir__calculate_coefficients_downsample(stbir__info*, stbir_filter, float, int, int, float, stbir__contributors*, float*)
static void stbir__calculate_coefficients_downsample(stbir__info* stbir_info, stbir_filter filter, float scale_ratio, int out_first_pixel, int out_last_pixel, float out_center_of_in, stbir__contributors* contributor, float* coefficient_group)
{
    int i;

     STBIR_ASSERT(out_last_pixel - out_first_pixel <= (int)ceil(stbir__filter_info_table[filter].support(scale_ratio) * 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 = out_first_pixel;
    contributor->n1 = out_last_pixel;

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

    for (i = 0; i <= out_last_pixel - out_first_pixel; i++)
    {
        float out_pixel_center = (float)(i + out_first_pixel) + 0.5f;
        float x = out_pixel_center - out_center_of_in;
        coefficient_group[i] = stbir__filter_info_table[filter].kernel(x, scale_ratio) * scale_ratio;
    }

    STBIR_ASSERT(stbir__filter_info_table[filter].kernel((float)(out_last_pixel + 1) + 0.5f - out_center_of_in, scale_ratio) == 0);

    for (i = out_last_pixel - out_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
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)
movl -0x18(%rbp), %eax
subl -0x14(%rbp), %eax
movl %eax, -0x40(%rbp)
movl -0xc(%rbp), %eax
movl %eax, %ecx
leaq 0xab64(%rip), %rax      # 0x264b0
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movss -0x10(%rbp), %xmm0
callq *%rax
movss 0x46be(%rip), %xmm1     # 0x20024
mulss %xmm1, %xmm0
callq 0x1f610
movl -0x40(%rbp), %eax
cvttss2si %xmm0, %ecx
cmpl %ecx, %eax
jg 0x1b97c
jmp 0x1b99b
leaq 0x5d84(%rip), %rdi      # 0x21707
leaq 0x57e0(%rip), %rsi      # 0x2116a
movl $0x43a, %edx            # imm = 0x43A
leaq 0x5dda(%rip), %rcx      # 0x21770
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 0x1b9bf
jmp 0x1b9de
leaq 0x5c8b(%rip), %rdi      # 0x21651
leaq 0x579d(%rip), %rsi      # 0x2116a
movl $0x43f, %edx            # imm = 0x43F
leaq 0x5d97(%rip), %rcx      # 0x21770
callq 0x1090
movl $0x0, -0x34(%rbp)
movl -0x34(%rbp), %eax
movl -0x18(%rbp), %ecx
subl -0x14(%rbp), %ecx
cmpl %ecx, %eax
jg 0x1ba5b
movl -0x34(%rbp), %eax
addl -0x14(%rbp), %eax
cvtsi2ss %eax, %xmm0
movss 0x460c(%rip), %xmm1     # 0x20010
addss %xmm1, %xmm0
movss %xmm0, -0x38(%rbp)
movss -0x38(%rbp), %xmm0
subss -0x1c(%rbp), %xmm0
movss %xmm0, -0x3c(%rbp)
movl -0xc(%rbp), %eax
movl %eax, %ecx
leaq 0xaa88(%rip), %rax      # 0x264b0
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movss -0x3c(%rbp), %xmm0
movss -0x10(%rbp), %xmm1
callq *%rax
mulss -0x10(%rbp), %xmm0
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss %xmm0, (%rax,%rcx,4)
movl -0x34(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x34(%rbp)
jmp 0x1b9e5
movl -0xc(%rbp), %eax
movl %eax, %ecx
leaq 0xaa49(%rip), %rax      # 0x264b0
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl -0x18(%rbp), %ecx
addl $0x1, %ecx
cvtsi2ss %ecx, %xmm0
movss 0x458d(%rip), %xmm1     # 0x20010
addss %xmm1, %xmm0
subss -0x1c(%rbp), %xmm0
movss -0x10(%rbp), %xmm1
callq *%rax
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x1ba9f
jp 0x1ba9f
jmp 0x1babe
leaq 0x5d4d(%rip), %rdi      # 0x217f3
leaq 0x56bd(%rip), %rsi      # 0x2116a
movl $0x448, %edx            # imm = 0x448
leaq 0x5cb7(%rip), %rcx      # 0x21770
callq 0x1090
movl -0x18(%rbp), %eax
subl -0x14(%rbp), %eax
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jl 0x1bb06
movq -0x30(%rbp), %rax
movslq -0x34(%rbp), %rcx
movss (%rax,%rcx,4), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x1bae6
jp 0x1bae6
jmp 0x1bae8
jmp 0x1bb06
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 0x1bac7
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)