// File: lunasorcery[P]brailify/./stb/stb_image_resize.h
// Function: stbir__buffer_loop_downsample(stbir__info*)
static void stbir__buffer_loop_downsample(stbir__info* stbir_info)
{
    int y;
    float scale_ratio = stbir_info->vertical_scale;
    int output_h = stbir_info->output_h;
    float in_pixels_radius = stbir__filter_info_table[stbir_info->vertical_filter].support(scale_ratio) / scale_ratio;
    int pixel_margin = stbir_info->vertical_filter_pixel_margin;
    int max_y = stbir_info->input_h + pixel_margin;

    STBIR_ASSERT(!stbir__use_height_upsampling(stbir_info));

    for (y = -pixel_margin; y < max_y; y++)
    {
        float out_center_of_in; // Center of the current out scanline in the in scanline space
        int out_first_scanline, out_last_scanline;

        stbir__calculate_sample_range_downsample(y, in_pixels_radius, scale_ratio, stbir_info->vertical_shift, &out_first_scanline, &out_last_scanline, &out_center_of_in);

        STBIR_ASSERT(out_last_scanline - out_first_scanline <= stbir_info->vertical_filter_pixel_width);

        if (out_last_scanline < 0 || out_first_scanline >= output_h)
            continue;

        stbir__empty_ring_buffer(stbir_info, out_first_scanline);

        stbir__decode_and_resample_downsample(stbir_info, y);

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

        while (out_last_scanline > stbir_info->ring_buffer_last_scanline)
            stbir__add_empty_ring_buffer_entry(stbir_info, stbir_info->ring_buffer_last_scanline + 1);

        // Now the horizontal buffer is ready to write to all ring buffer rows.
        stbir__resample_vertical_downsample(stbir_info, y, out_first_scanline, out_last_scanline, out_center_of_in);
    }

    stbir__empty_ring_buffer(stbir_info, stbir_info->output_h);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movss 0x48(%rax), %xmm0
movss %xmm0, -0x10(%rbp)
movq -0x8(%rbp), %rax
movl 0x24(%rax), %eax
movl %eax, -0x14(%rbp)
movq -0x8(%rbp), %rax
movl 0x60(%rax), %eax
movl %eax, %ecx
leaq 0xb2dc(%rip), %rax      # 0x264b0
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movss -0x10(%rbp), %xmm0
callq *%rax
divss -0x10(%rbp), %xmm0
movss %xmm0, -0x18(%rbp)
movq -0x8(%rbp), %rax
movl 0xbc(%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movl 0xc(%rax), %eax
addl -0x1c(%rbp), %eax
movl %eax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1a730
cmpl $0x0, %eax
setne %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x1b221
jmp 0x1b223
jmp 0x1b242
leaq 0x6ad7(%rip), %rdi      # 0x21d01
leaq 0x5f39(%rip), %rsi      # 0x2116a
movl $0x874, %edx            # imm = 0x874
leaq 0x6aee(%rip), %rcx      # 0x21d2b
callq 0x1090
xorl %eax, %eax
subl -0x1c(%rbp), %eax
movl %eax, -0xc(%rbp)
movl -0xc(%rbp), %eax
cmpl -0x20(%rbp), %eax
jge 0x1b33f
movl -0xc(%rbp), %edi
movss -0x18(%rbp), %xmm0
movss -0x10(%rbp), %xmm1
movq -0x8(%rbp), %rax
movss 0x40(%rax), %xmm2
leaq -0x28(%rbp), %rsi
leaq -0x2c(%rbp), %rdx
leaq -0x24(%rbp), %rcx
callq 0x1b7e0
movl -0x2c(%rbp), %eax
subl -0x28(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0xb4(%rcx), %eax
jg 0x1b291
jmp 0x1b2b0
leaq 0x6ac5(%rip), %rdi      # 0x21d5d
leaq 0x5ecb(%rip), %rsi      # 0x2116a
movl $0x87d, %edx            # imm = 0x87D
leaq 0x6a80(%rip), %rcx      # 0x21d2b
callq 0x1090
cmpl $0x0, -0x2c(%rbp)
jl 0x1b2be
movl -0x28(%rbp), %eax
cmpl -0x14(%rbp), %eax
jl 0x1b2c0
jmp 0x1b331
movq -0x8(%rbp), %rdi
movl -0x28(%rbp), %esi
callq 0x1ed90
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x1ef40
movq -0x8(%rbp), %rax
cmpl $0x0, 0xd4(%rax)
jge 0x1b2f1
movq -0x8(%rbp), %rdi
movl -0x28(%rbp), %esi
callq 0x1d7b0
jmp 0x1b2f3
movl -0x2c(%rbp), %eax
movq -0x8(%rbp), %rcx
cmpl 0xd0(%rcx), %eax
jle 0x1b31a
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0xd0(%rax), %esi
addl $0x1, %esi
callq 0x1d7b0
jmp 0x1b2f3
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x28(%rbp), %edx
movl -0x2c(%rbp), %ecx
movss -0x24(%rbp), %xmm0
callq 0x1efd0
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x1b24a
movq -0x8(%rbp), %rdi
movq -0x8(%rbp), %rax
movl 0x24(%rax), %esi
callq 0x1ed90
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)