// File: lunasorcery[P]brailify/./stb/stb_image_resize.h
// Function: stbir__buffer_loop_upsample(stbir__info*)
static void stbir__buffer_loop_upsample(stbir__info* stbir_info)
{
    int y;
    float scale_ratio = stbir_info->vertical_scale;
    float out_scanlines_radius = stbir__filter_info_table[stbir_info->vertical_filter].support(1/scale_ratio) * scale_ratio;

    STBIR_ASSERT(stbir__use_height_upsampling(stbir_info));

    for (y = 0; y < stbir_info->output_h; y++)
    {
        float in_center_of_out = 0; // Center of the current out scanline in the in scanline space
        int in_first_scanline = 0, in_last_scanline = 0;

        stbir__calculate_sample_range_upsample(y, out_scanlines_radius, scale_ratio, stbir_info->vertical_shift, &in_first_scanline, &in_last_scanline, &in_center_of_out);

        STBIR_ASSERT(in_last_scanline - in_first_scanline <= stbir_info->vertical_filter_pixel_width);

        if (stbir_info->ring_buffer_begin_index >= 0)
        {
            // Get rid of whatever we don't need anymore.
            while (in_first_scanline > stbir_info->ring_buffer_first_scanline)
            {
                if (stbir_info->ring_buffer_first_scanline == stbir_info->ring_buffer_last_scanline)
                {
                    // We just popped the last scanline off the ring buffer.
                    // Reset it to the empty state.
                    stbir_info->ring_buffer_begin_index = -1;
                    stbir_info->ring_buffer_first_scanline = 0;
                    stbir_info->ring_buffer_last_scanline = 0;
                    break;
                }
                else
                {
                    stbir_info->ring_buffer_first_scanline++;
                    stbir_info->ring_buffer_begin_index = (stbir_info->ring_buffer_begin_index + 1) % stbir_info->vertical_filter_pixel_width;
                }
            }
        }

        // Load in new ones.
        if (stbir_info->ring_buffer_begin_index < 0)
            stbir__decode_and_resample_upsample(stbir_info, in_first_scanline);

        while (in_last_scanline > stbir_info->ring_buffer_last_scanline)
            stbir__decode_and_resample_upsample(stbir_info, stbir_info->ring_buffer_last_scanline + 1);

        // Now all buffers should be ready to write a row of vertical sampling.
        stbir__resample_vertical_upsample(stbir_info, y, in_first_scanline, in_last_scanline, in_center_of_out);

        STBIR_PROGRESS_REPORT((float)y / stbir_info->output_h);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movss 0x48(%rax), %xmm0
movss %xmm0, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl 0x60(%rax), %eax
movl %eax, %ecx
leaq 0xb506(%rip), %rax      # 0x264b0
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movss 0x5047(%rip), %xmm0     # 0x20004
divss -0x10(%rbp), %xmm0
callq *%rax
mulss -0x10(%rbp), %xmm0
movss %xmm0, -0x14(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1a730
cmpl $0x0, %eax
je 0x1afde
jmp 0x1affd
leaq 0x6d1d(%rip), %rdi      # 0x21d02
leaq 0x617e(%rip), %rsi      # 0x2116a
movl $0x80f, %edx            # imm = 0x80F
leaq 0x6909(%rip), %rcx      # 0x21901
callq 0x1090
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0x24(%rcx), %eax
jge 0x1b18b
xorps %xmm0, %xmm0
movss %xmm0, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl -0xc(%rbp), %edi
movss -0x14(%rbp), %xmm0
movss -0x10(%rbp), %xmm1
movq -0x8(%rbp), %rax
movss 0x40(%rax), %xmm2
leaq -0x1c(%rbp), %rsi
leaq -0x20(%rbp), %rdx
leaq -0x18(%rbp), %rcx
callq 0x1b360
movl -0x20(%rbp), %eax
subl -0x1c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0xb4(%rcx), %eax
jg 0x1b065
jmp 0x1b084
leaq 0x68c5(%rip), %rdi      # 0x21931
leaq 0x60f7(%rip), %rsi      # 0x2116a
movl $0x818, %edx            # imm = 0x818
leaq 0x6882(%rip), %rcx      # 0x21901
callq 0x1090
movq -0x8(%rbp), %rax
cmpl $0x0, 0xd4(%rax)
jl 0x1b124
jmp 0x1b097
movl -0x1c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0xcc(%rcx), %eax
jle 0x1b122
movq -0x8(%rbp), %rax
movl 0xcc(%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0xd0(%rcx), %eax
jne 0x1b0e8
movq -0x8(%rbp), %rax
movl $0xffffffff, 0xd4(%rax) # imm = 0xFFFFFFFF
movq -0x8(%rbp), %rax
movl $0x0, 0xcc(%rax)
movq -0x8(%rbp), %rax
movl $0x0, 0xd0(%rax)
jmp 0x1b122
movq -0x8(%rbp), %rax
movl 0xcc(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0xcc(%rax)
movq -0x8(%rbp), %rax
movl 0xd4(%rax), %eax
addl $0x1, %eax
movq -0x8(%rbp), %rcx
cltd
idivl 0xb4(%rcx)
movq -0x8(%rbp), %rax
movl %edx, 0xd4(%rax)
jmp 0x1b097
jmp 0x1b124
movq -0x8(%rbp), %rax
cmpl $0x0, 0xd4(%rax)
jge 0x1b13d
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %esi
callq 0x1bee0
jmp 0x1b13f
movl -0x20(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0xd0(%rcx), %eax
jle 0x1b166
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0xd0(%rax), %esi
addl $0x1, %esi
callq 0x1bee0
jmp 0x1b13f
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x1c(%rbp), %edx
movl -0x20(%rbp), %ecx
movss -0x18(%rbp), %xmm0
callq 0x1bf70
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x1b004
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)