// File: lunasorcery[P]brailify/./stb/stb_image_resize.h
// Function: stbir__normalize_downsample_coefficients(stbir__info*, stbir__contributors*, float*, stbir_filter, float, float, int, int)
static void stbir__normalize_downsample_coefficients(stbir__info* stbir_info, stbir__contributors* contributors, float* coefficients, stbir_filter filter, float scale_ratio, float shift, int input_size, int output_size)
{
    int num_contributors = stbir__get_contributors(scale_ratio, filter, input_size, output_size);
    int num_coefficients = stbir__get_coefficient_width(filter, scale_ratio);
    int i, j;
    int skip;

    for (i = 0; i < output_size; i++)
    {
        float scale;
        float total = 0;

        for (j = 0; j < num_contributors; j++)
        {
            if (i >= contributors[j].n0 && i <= contributors[j].n1)
            {
                float coefficient = *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i - contributors[j].n0);
                total += coefficient;
            }
            else if (i < contributors[j].n0)
                break;
        }

        STBIR_ASSERT(total > 0.9f);
        STBIR_ASSERT(total < 1.1f);

        scale = 1 / total;

        for (j = 0; j < num_contributors; j++)
        {
            if (i >= contributors[j].n0 && i <= contributors[j].n1)
                *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i - contributors[j].n0) *= scale;
            else if (i < contributors[j].n0)
                break;
        }
    }

    // Optimize: Skip zero coefficients and contributions outside of image bounds.
    // Do this after normalizing because normalization depends on the n0/n1 values.
    for (j = 0; j < num_contributors; j++)
    {
        int range, max, width;

        skip = 0;
        while (*stbir__get_coefficient(coefficients, filter, scale_ratio, j, skip) == 0)
            skip++;

        contributors[j].n0 += skip;

        while (contributors[j].n0 < 0)
        {
            contributors[j].n0++;
            skip++;
        }

        range = contributors[j].n1 - contributors[j].n0 + 1;
        max = stbir__min(num_coefficients, range);

        width = stbir__get_coefficient_width(filter, scale_ratio);
        for (i = 0; i < max; i++)
        {
            if (i + skip >= width)
                break;

            *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i) = *stbir__get_coefficient(coefficients, filter, scale_ratio, j, i + skip);
        }

        continue;
    }

    // Using min to avoid writing into invalid pixels.
    for (i = 0; i < num_contributors; i++)
        contributors[i].n1 = stbir__min(contributors[i].n1, output_size - 1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movss %xmm0, -0x20(%rbp)
movss %xmm1, -0x24(%rbp)
movl %r8d, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movss -0x20(%rbp), %xmm0
movl -0x1c(%rbp), %edi
movl -0x28(%rbp), %esi
movl -0x2c(%rbp), %edx
callq 0x1a650
movl %eax, -0x30(%rbp)
movl -0x1c(%rbp), %edi
movss -0x20(%rbp), %xmm0
callq 0x1ac30
movl %eax, -0x34(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jge 0x1bd27
xorps %xmm0, %xmm0
movss %xmm0, -0x48(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x1bc0f
movl -0x38(%rbp), %eax
movq -0x10(%rbp), %rcx
movslq -0x3c(%rbp), %rdx
cmpl (%rcx,%rdx,8), %eax
jl 0x1bbeb
movl -0x38(%rbp), %eax
movq -0x10(%rbp), %rcx
movslq -0x3c(%rbp), %rdx
cmpl 0x4(%rcx,%rdx,8), %eax
jg 0x1bbeb
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
movss -0x20(%rbp), %xmm0
movl -0x3c(%rbp), %edx
movl -0x38(%rbp), %ecx
movq -0x10(%rbp), %rax
movslq -0x3c(%rbp), %r8
subl (%rax,%r8,8), %ecx
callq 0x1b790
movss (%rax), %xmm0
movss %xmm0, -0x4c(%rbp)
movss -0x4c(%rbp), %xmm0
addss -0x48(%rbp), %xmm0
movss %xmm0, -0x48(%rbp)
jmp 0x1bbff
movl -0x38(%rbp), %eax
movq -0x10(%rbp), %rcx
movslq -0x3c(%rbp), %rdx
cmpl (%rcx,%rdx,8), %eax
jge 0x1bbfd
jmp 0x1bc0f
jmp 0x1bbff
jmp 0x1bc01
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1bb81
movss -0x48(%rbp), %xmm0
movss 0x4450(%rip), %xmm1     # 0x2006c
ucomiss %xmm1, %xmm0
jbe 0x1bc23
jmp 0x1bc42
leaq 0x5c3a(%rip), %rdi      # 0x21864
leaq 0x5539(%rip), %rsi      # 0x2116a
movl $0x46b, %edx            # imm = 0x46B
leaq 0x5c34(%rip), %rcx      # 0x21871
callq 0x1090
movss 0x441e(%rip), %xmm0     # 0x20068
ucomiss -0x48(%rbp), %xmm0
jbe 0x1bc52
jmp 0x1bc71
leaq 0x5c9b(%rip), %rdi      # 0x218f4
leaq 0x550a(%rip), %rsi      # 0x2116a
movl $0x46c, %edx            # imm = 0x46C
leaq 0x5c05(%rip), %rcx      # 0x21871
callq 0x1090
movss 0x438b(%rip), %xmm0     # 0x20004
divss -0x48(%rbp), %xmm0
movss %xmm0, -0x44(%rbp)
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x1bd17
movl -0x38(%rbp), %eax
movq -0x10(%rbp), %rcx
movslq -0x3c(%rbp), %rdx
cmpl (%rcx,%rdx,8), %eax
jl 0x1bcf3
movl -0x38(%rbp), %eax
movq -0x10(%rbp), %rcx
movslq -0x3c(%rbp), %rdx
cmpl 0x4(%rcx,%rdx,8), %eax
jg 0x1bcf3
movss -0x44(%rbp), %xmm0
movss %xmm0, -0x5c(%rbp)
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
movss -0x20(%rbp), %xmm0
movl -0x3c(%rbp), %edx
movl -0x38(%rbp), %ecx
movq -0x10(%rbp), %rax
movslq -0x3c(%rbp), %r8
subl (%rax,%r8,8), %ecx
callq 0x1b790
movss -0x5c(%rbp), %xmm0
mulss (%rax), %xmm0
movss %xmm0, (%rax)
jmp 0x1bd07
movl -0x38(%rbp), %eax
movq -0x10(%rbp), %rcx
movslq -0x3c(%rbp), %rdx
cmpl (%rcx,%rdx,8), %eax
jge 0x1bd05
jmp 0x1bd17
jmp 0x1bd07
jmp 0x1bd09
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1bc8a
jmp 0x1bd19
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1bb66
movl $0x0, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x1be61
movl $0x0, -0x40(%rbp)
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
movss -0x20(%rbp), %xmm0
movl -0x3c(%rbp), %edx
movl -0x40(%rbp), %ecx
callq 0x1b790
movss (%rax), %xmm0
xorps %xmm1, %xmm1
ucomiss %xmm1, %xmm0
jne 0x1bd71
jp 0x1bd71
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x1bd41
movl -0x40(%rbp), %edx
movq -0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
addl (%rax,%rcx,8), %edx
movl %edx, (%rax,%rcx,8)
movq -0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,8)
jge 0x1bdac
movq -0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl (%rax,%rcx,8), %edx
addl $0x1, %edx
movl %edx, (%rax,%rcx,8)
movl -0x40(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x40(%rbp)
jmp 0x1bd82
movq -0x10(%rbp), %rax
movslq -0x3c(%rbp), %rcx
movl 0x4(%rax,%rcx,8), %eax
movq -0x10(%rbp), %rcx
movslq -0x3c(%rbp), %rdx
subl (%rcx,%rdx,8), %eax
addl $0x1, %eax
movl %eax, -0x50(%rbp)
movl -0x34(%rbp), %edi
movl -0x50(%rbp), %esi
callq 0x1beb0
movl %eax, -0x54(%rbp)
movl -0x1c(%rbp), %edi
movss -0x20(%rbp), %xmm0
callq 0x1ac30
movl %eax, -0x58(%rbp)
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x54(%rbp), %eax
jge 0x1be51
movl -0x38(%rbp), %eax
addl -0x40(%rbp), %eax
cmpl -0x58(%rbp), %eax
jl 0x1be03
jmp 0x1be51
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
movss -0x20(%rbp), %xmm0
movl -0x3c(%rbp), %edx
movl -0x38(%rbp), %ecx
addl -0x40(%rbp), %ecx
callq 0x1b790
movss (%rax), %xmm0
movss %xmm0, -0x60(%rbp)
movq -0x18(%rbp), %rdi
movl -0x1c(%rbp), %esi
movss -0x20(%rbp), %xmm0
movl -0x3c(%rbp), %edx
movl -0x38(%rbp), %ecx
callq 0x1b790
movss -0x60(%rbp), %xmm0
movss %xmm0, (%rax)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1bdee
jmp 0x1be53
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0x1bd2e
movl $0x0, -0x38(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x30(%rbp), %eax
jge 0x1bea0
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl 0x4(%rax,%rcx,8), %edi
movl -0x2c(%rbp), %esi
subl $0x1, %esi
callq 0x1beb0
movl %eax, %edx
movq -0x10(%rbp), %rax
movslq -0x38(%rbp), %rcx
movl %edx, 0x4(%rax,%rcx,8)
movl -0x38(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x38(%rbp)
jmp 0x1be68
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)