// File: /workspace/github_c_makefile_star2_O0/algorithm-archivists[P]GathVL/src/objects/../../include/stb_image_resize.h
// Function: stbir__resize_allocated(stbir__info*, void const*, int, void*, int, int, unsigned int, stbir_datatype, stbir_edge, stbir_edge, stbir_colorspace, void*, unsigned long)
static int stbir__resize_allocated(stbir__info *info,
    const void* input_data, int input_stride_in_bytes,
    void* output_data, int output_stride_in_bytes,
    int alpha_channel, stbir_uint32 flags, stbir_datatype type,
    stbir_edge edge_horizontal, stbir_edge edge_vertical, stbir_colorspace colorspace,
    void* tempmem, size_t tempmem_size_in_bytes)
{
    size_t memory_required = stbir__calculate_memory(info);

    int width_stride_input = input_stride_in_bytes ? input_stride_in_bytes : info->channels * info->input_w * stbir__type_size[type];
    int width_stride_output = output_stride_in_bytes ? output_stride_in_bytes : info->channels * info->output_w * stbir__type_size[type];

#ifdef STBIR_DEBUG_OVERWRITE_TEST
#define OVERWRITE_ARRAY_SIZE 8
    unsigned char overwrite_output_before_pre[OVERWRITE_ARRAY_SIZE];
    unsigned char overwrite_tempmem_before_pre[OVERWRITE_ARRAY_SIZE];
    unsigned char overwrite_output_after_pre[OVERWRITE_ARRAY_SIZE];
    unsigned char overwrite_tempmem_after_pre[OVERWRITE_ARRAY_SIZE];

    size_t begin_forbidden = width_stride_output * (info->output_h - 1) + info->output_w * info->channels * stbir__type_size[type];
    memcpy(overwrite_output_before_pre, &((unsigned char*)output_data)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE);
    memcpy(overwrite_output_after_pre, &((unsigned char*)output_data)[begin_forbidden], OVERWRITE_ARRAY_SIZE);
    memcpy(overwrite_tempmem_before_pre, &((unsigned char*)tempmem)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE);
    memcpy(overwrite_tempmem_after_pre, &((unsigned char*)tempmem)[tempmem_size_in_bytes], OVERWRITE_ARRAY_SIZE);
#endif

    STBIR_ASSERT(info->channels >= 0);
    STBIR_ASSERT(info->channels <= STBIR_MAX_CHANNELS);

    if (info->channels < 0 || info->channels > STBIR_MAX_CHANNELS)
        return 0;

    STBIR_ASSERT(info->horizontal_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table));
    STBIR_ASSERT(info->vertical_filter < STBIR__ARRAY_SIZE(stbir__filter_info_table));

    if (info->horizontal_filter >= STBIR__ARRAY_SIZE(stbir__filter_info_table))
        return 0;
    if (info->vertical_filter >= STBIR__ARRAY_SIZE(stbir__filter_info_table))
        return 0;

    if (alpha_channel < 0)
        flags |= STBIR_FLAG_ALPHA_USES_COLORSPACE | STBIR_FLAG_ALPHA_PREMULTIPLIED;

    if (!(flags&STBIR_FLAG_ALPHA_USES_COLORSPACE) || !(flags&STBIR_FLAG_ALPHA_PREMULTIPLIED))
        STBIR_ASSERT(alpha_channel >= 0 && alpha_channel < info->channels);

    if (alpha_channel >= info->channels)
        return 0;

    STBIR_ASSERT(tempmem);

    if (!tempmem)
        return 0;

    STBIR_ASSERT(tempmem_size_in_bytes >= memory_required);

    if (tempmem_size_in_bytes < memory_required)
        return 0;

    memset(tempmem, 0, tempmem_size_in_bytes);

    info->input_data = input_data;
    info->input_stride_bytes = width_stride_input;

    info->output_data = output_data;
    info->output_stride_bytes = width_stride_output;

    info->alpha_channel = alpha_channel;
    info->flags = flags;
    info->type = type;
    info->edge_horizontal = edge_horizontal;
    info->edge_vertical = edge_vertical;
    info->colorspace = colorspace;

    info->horizontal_coefficient_width   = stbir__get_coefficient_width  (info->horizontal_filter, info->horizontal_scale);
    info->vertical_coefficient_width     = stbir__get_coefficient_width  (info->vertical_filter  , info->vertical_scale  );
    info->horizontal_filter_pixel_width  = stbir__get_filter_pixel_width (info->horizontal_filter, info->horizontal_scale);
    info->vertical_filter_pixel_width    = stbir__get_filter_pixel_width (info->vertical_filter  , info->vertical_scale  );
    info->horizontal_filter_pixel_margin = stbir__get_filter_pixel_margin(info->horizontal_filter, info->horizontal_scale);
    info->vertical_filter_pixel_margin   = stbir__get_filter_pixel_margin(info->vertical_filter  , info->vertical_scale  );

    info->ring_buffer_length_bytes = info->output_w * info->channels * sizeof(float);
    info->decode_buffer_pixels = info->input_w + info->horizontal_filter_pixel_margin * 2;

#define STBIR__NEXT_MEMPTR(current, newtype) (newtype*)(((unsigned char*)current) + current##_size)

    info->horizontal_contributors = (stbir__contributors *) tempmem;
    info->horizontal_coefficients = STBIR__NEXT_MEMPTR(info->horizontal_contributors, float);
    info->vertical_contributors = STBIR__NEXT_MEMPTR(info->horizontal_coefficients, stbir__contributors);
    info->vertical_coefficients = STBIR__NEXT_MEMPTR(info->vertical_contributors, float);
    info->decode_buffer = STBIR__NEXT_MEMPTR(info->vertical_coefficients, float);

    if (stbir__use_height_upsampling(info))
    {
        info->horizontal_buffer = NULL;
        info->ring_buffer = STBIR__NEXT_MEMPTR(info->decode_buffer, float);
        info->encode_buffer = STBIR__NEXT_MEMPTR(info->ring_buffer, float);

        STBIR_ASSERT((size_t)STBIR__NEXT_MEMPTR(info->encode_buffer, unsigned char) == (size_t)tempmem + tempmem_size_in_bytes);
    }
    else
    {
        info->horizontal_buffer = STBIR__NEXT_MEMPTR(info->decode_buffer, float);
        info->ring_buffer = STBIR__NEXT_MEMPTR(info->horizontal_buffer, float);
        info->encode_buffer = NULL;

        STBIR_ASSERT((size_t)STBIR__NEXT_MEMPTR(info->ring_buffer, unsigned char) == (size_t)tempmem + tempmem_size_in_bytes);
    }

#undef STBIR__NEXT_MEMPTR

    // This signals that the ring buffer is empty
    info->ring_buffer_begin_index = -1;

    stbir__calculate_filters(info->horizontal_contributors, info->horizontal_coefficients, info->horizontal_filter, info->horizontal_scale, info->horizontal_shift, info->input_w, info->output_w);
    stbir__calculate_filters(info->vertical_contributors, info->vertical_coefficients, info->vertical_filter, info->vertical_scale, info->vertical_shift, info->input_h, info->output_h);

    STBIR_PROGRESS_REPORT(0);

    if (stbir__use_height_upsampling(info))
        stbir__buffer_loop_upsample(info);
    else
        stbir__buffer_loop_downsample(info);

    STBIR_PROGRESS_REPORT(1);

#ifdef STBIR_DEBUG_OVERWRITE_TEST
    STBIR_ASSERT(memcmp(overwrite_output_before_pre, &((unsigned char*)output_data)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE) == 0);
    STBIR_ASSERT(memcmp(overwrite_output_after_pre, &((unsigned char*)output_data)[begin_forbidden], OVERWRITE_ARRAY_SIZE) == 0);
    STBIR_ASSERT(memcmp(overwrite_tempmem_before_pre, &((unsigned char*)tempmem)[-OVERWRITE_ARRAY_SIZE], OVERWRITE_ARRAY_SIZE) == 0);
    STBIR_ASSERT(memcmp(overwrite_tempmem_after_pre, &((unsigned char*)tempmem)[tempmem_size_in_bytes], OVERWRITE_ARRAY_SIZE) == 0);
#endif

    return 1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq 0x40(%rbp), %rax
movq 0x38(%rbp), %rax
movl 0x30(%rbp), %eax
movl 0x28(%rbp), %eax
movl 0x20(%rbp), %eax
movl 0x18(%rbp), %eax
movl 0x10(%rbp), %eax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movl %r9d, -0x30(%rbp)
movq -0x10(%rbp), %rdi
callq 0x30300
movl %eax, %eax
movq %rax, -0x38(%rbp)
cmpl $0x0, -0x1c(%rbp)
je 0x30633
movl -0x1c(%rbp), %eax
movl %eax, -0x44(%rbp)
jmp 0x30658
movq -0x10(%rbp), %rax
movl 0x4c(%rax), %eax
movq -0x10(%rbp), %rcx
imull 0x8(%rcx), %eax
movl 0x18(%rbp), %ecx
movl %ecx, %edx
leaq 0x1efb2(%rip), %rcx     # 0x4f600
movzbl (%rcx,%rdx), %ecx
imull %ecx, %eax
movl %eax, -0x44(%rbp)
movl -0x44(%rbp), %eax
movl %eax, -0x3c(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x3066c
movl -0x2c(%rbp), %eax
movl %eax, -0x48(%rbp)
jmp 0x30691
movq -0x10(%rbp), %rax
movl 0x4c(%rax), %eax
movq -0x10(%rbp), %rcx
imull 0x20(%rcx), %eax
movl 0x18(%rbp), %ecx
movl %ecx, %edx
leaq 0x1ef79(%rip), %rcx     # 0x4f600
movzbl (%rcx,%rdx), %ecx
imull %ecx, %eax
movl %eax, -0x48(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x40(%rbp)
movq -0x10(%rbp), %rax
cmpl $0x0, 0x4c(%rax)
jl 0x306a3
jmp 0x306c2
leaq 0xc447(%rip), %rdi      # 0x3caf1
leaq 0xc268(%rip), %rsi      # 0x3c919
movl $0x906, %edx            # imm = 0x906
leaq 0xc448(%rip), %rcx      # 0x3cb05
callq 0x50f0
movq -0x10(%rbp), %rax
cmpl $0x40, 0x4c(%rax)
jg 0x306ce
jmp 0x306ed
leaq 0xc4d8(%rip), %rdi      # 0x3cbad
leaq 0xc23d(%rip), %rsi      # 0x3c919
movl $0x907, %edx            # imm = 0x907
leaq 0xc41d(%rip), %rcx      # 0x3cb05
callq 0x50f0
movq -0x10(%rbp), %rax
cmpl $0x0, 0x4c(%rax)
jl 0x30701
movq -0x10(%rbp), %rax
cmpl $0x40, 0x4c(%rax)
jle 0x3070d
movl $0x0, -0x4(%rbp)
jmp 0x30cb6
movq -0x10(%rbp), %rax
movl 0x5c(%rax), %eax
cmpq $0x6, %rax
jae 0x3071c
jmp 0x3073b
leaq 0xc257(%rip), %rdi      # 0x3c97a
leaq 0xc1ef(%rip), %rsi      # 0x3c919
movl $0x90c, %edx            # imm = 0x90C
leaq 0xc3cf(%rip), %rcx      # 0x3cb05
callq 0x50f0
movq -0x10(%rbp), %rax
movl 0x60(%rax), %eax
cmpq $0x6, %rax
jae 0x3074a
jmp 0x30769
leaq 0xc2a9(%rip), %rdi      # 0x3c9fa
leaq 0xc1c1(%rip), %rsi      # 0x3c919
movl $0x90d, %edx            # imm = 0x90D
leaq 0xc3a1(%rip), %rcx      # 0x3cb05
callq 0x50f0
movq -0x10(%rbp), %rax
movl 0x5c(%rax), %eax
cmpq $0x6, %rax
jb 0x30782
movl $0x0, -0x4(%rbp)
jmp 0x30cb6
movq -0x10(%rbp), %rax
movl 0x60(%rax), %eax
cmpq $0x6, %rax
jb 0x3079b
movl $0x0, -0x4(%rbp)
jmp 0x30cb6
cmpl $0x0, -0x30(%rbp)
jge 0x307aa
movl 0x10(%rbp), %eax
orl $0x3, %eax
movl %eax, 0x10(%rbp)
movl 0x10(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x307c0
movl 0x10(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
jne 0x30807
xorl %eax, %eax
cmpl $0x0, -0x30(%rbp)
movb %al, -0x49(%rbp)
jl 0x307db
movl -0x30(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x4c(%rcx), %eax
setl %al
movb %al, -0x49(%rbp)
movb -0x49(%rbp), %al
testb $0x1, %al
jne 0x307e4
jmp 0x307e6
jmp 0x30805
leaq 0xc3d5(%rip), %rdi      # 0x3cbc2
leaq 0xc125(%rip), %rsi      # 0x3c919
movl $0x918, %edx            # imm = 0x918
leaq 0xc305(%rip), %rcx      # 0x3cb05
callq 0x50f0
jmp 0x30807
movl -0x30(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x4c(%rcx), %eax
jl 0x3081f
movl $0x0, -0x4(%rbp)
jmp 0x30cb6
cmpq $0x0, 0x38(%rbp)
je 0x30828
jmp 0x30847
leaq 0xc3c8(%rip), %rdi      # 0x3cbf7
leaq 0xc0e3(%rip), %rsi      # 0x3c919
movl $0x91d, %edx            # imm = 0x91D
leaq 0xc2c3(%rip), %rcx      # 0x3cb05
callq 0x50f0
cmpq $0x0, 0x38(%rbp)
jne 0x3085a
movl $0x0, -0x4(%rbp)
jmp 0x30cb6
movq 0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
jb 0x30866
jmp 0x30885
leaq 0xc392(%rip), %rdi      # 0x3cbff
leaq 0xc0a5(%rip), %rsi      # 0x3c919
movl $0x922, %edx            # imm = 0x922
leaq 0xc285(%rip), %rcx      # 0x3cb05
callq 0x50f0
movq 0x40(%rbp), %rax
cmpq -0x38(%rbp), %rax
jae 0x3089b
movl $0x0, -0x4(%rbp)
jmp 0x30cb6
movq 0x38(%rbp), %rdi
movq 0x40(%rbp), %rdx
xorl %esi, %esi
callq 0x51a0
movq -0x18(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, (%rax)
movl -0x3c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movl -0x40(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x28(%rax)
movl -0x30(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x50(%rax)
movl 0x10(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x54(%rax)
movl 0x18(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x58(%rax)
movl 0x20(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x64(%rax)
movl 0x28(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x68(%rax)
movl 0x30(%rbp), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x6c(%rax)
movq -0x10(%rbp), %rax
movl 0x5c(%rax), %edi
movq -0x10(%rbp), %rax
movss 0x44(%rax), %xmm0
callq 0x31400
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xa8(%rax)
movq -0x10(%rbp), %rax
movl 0x60(%rax), %edi
movq -0x10(%rbp), %rax
movss 0x48(%rax), %xmm0
callq 0x31400
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xac(%rax)
movq -0x10(%rbp), %rax
movl 0x5c(%rax), %edi
movq -0x10(%rbp), %rax
movss 0x44(%rax), %xmm0
callq 0x30d20
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xb0(%rax)
movq -0x10(%rbp), %rax
movl 0x60(%rax), %edi
movq -0x10(%rbp), %rax
movss 0x48(%rax), %xmm0
callq 0x30d20
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xb4(%rax)
movq -0x10(%rbp), %rax
movl 0x5c(%rax), %edi
movq -0x10(%rbp), %rax
movss 0x44(%rax), %xmm0
callq 0x30cf0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xb8(%rax)
movq -0x10(%rbp), %rax
movl 0x60(%rax), %edi
movq -0x10(%rbp), %rax
movss 0x48(%rax), %xmm0
callq 0x30cf0
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xbc(%rax)
movq -0x10(%rbp), %rax
movl 0x20(%rax), %eax
movq -0x10(%rbp), %rcx
imull 0x4c(%rcx), %eax
cltq
shlq $0x2, %rax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xc8(%rax)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x10(%rbp), %rax
movl 0xb8(%rax), %eax
shll %eax
addl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x90(%rax)
movq 0x38(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x70(%rax)
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rcx
movq -0x10(%rbp), %rax
movslq 0xf0(%rax), %rax
addq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x78(%rax)
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rcx
movq -0x10(%rbp), %rax
movslq 0xf4(%rax), %rax
addq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x80(%rax)
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rcx
movq -0x10(%rbp), %rax
movslq 0xf8(%rax), %rax
addq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x88(%rax)
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rcx
movq -0x10(%rbp), %rax
movslq 0xfc(%rax), %rax
addq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x98(%rax)
movq -0x10(%rbp), %rdi
callq 0x30f00
cmpl $0x0, %eax
je 0x30b5f
movq -0x10(%rbp), %rax
movq $0x0, 0xa0(%rax)
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rcx
movq -0x10(%rbp), %rax
movslq 0x100(%rax), %rax
addq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xe0(%rax)
movq -0x10(%rbp), %rax
movq 0xe0(%rax), %rcx
movq -0x10(%rbp), %rax
movslq 0x108(%rax), %rax
addq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xe8(%rax)
movq -0x10(%rbp), %rax
movq 0xe8(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x10c(%rcx), %rcx
addq %rcx, %rax
movq 0x38(%rbp), %rcx
addq 0x40(%rbp), %rcx
cmpq %rcx, %rax
jne 0x30b3b
jmp 0x30b5a
leaq 0xc0e6(%rip), %rdi      # 0x3cc28
leaq 0xbdd0(%rip), %rsi      # 0x3c919
movl $0x94e, %edx            # imm = 0x94E
leaq 0xbfb0(%rip), %rcx      # 0x3cb05
callq 0x50f0
jmp 0x30bff
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rcx
movq -0x10(%rbp), %rax
movslq 0x100(%rax), %rax
addq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xa0(%rax)
movq -0x10(%rbp), %rax
movq 0xa0(%rax), %rcx
movq -0x10(%rbp), %rax
movslq 0x104(%rax), %rax
addq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0xe0(%rax)
movq -0x10(%rbp), %rax
movq $0x0, 0xe8(%rax)
movq -0x10(%rbp), %rax
movq 0xe0(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x108(%rcx), %rcx
addq %rcx, %rax
movq 0x38(%rbp), %rcx
addq 0x40(%rbp), %rcx
cmpq %rcx, %rax
jne 0x30bde
jmp 0x30bfd
leaq 0xc0c9(%rip), %rdi      # 0x3ccae
leaq 0xbd2d(%rip), %rsi      # 0x3c919
movl $0x956, %edx            # imm = 0x956
leaq 0xbf0d(%rip), %rcx      # 0x3cb05
callq 0x50f0
jmp 0x30bff
movq -0x10(%rbp), %rax
movl $0xffffffff, 0xd8(%rax) # imm = 0xFFFFFFFF
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rsi
movq -0x10(%rbp), %rax
movl 0x5c(%rax), %edx
movq -0x10(%rbp), %rax
movss 0x44(%rax), %xmm0
movq -0x10(%rbp), %rax
movss 0x3c(%rax), %xmm1
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x10(%rbp), %rax
movl 0x20(%rax), %r8d
callq 0x314a0
movq -0x10(%rbp), %rax
movq 0x80(%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x88(%rax), %rsi
movq -0x10(%rbp), %rax
movl 0x60(%rax), %edx
movq -0x10(%rbp), %rax
movss 0x48(%rax), %xmm0
movq -0x10(%rbp), %rax
movss 0x40(%rax), %xmm1
movq -0x10(%rbp), %rax
movl 0xc(%rax), %ecx
movq -0x10(%rbp), %rax
movl 0x24(%rax), %r8d
callq 0x314a0
movq -0x10(%rbp), %rdi
callq 0x30f00
cmpl $0x0, %eax
je 0x30ca6
movq -0x10(%rbp), %rdi
callq 0x31710
jmp 0x30caf
movq -0x10(%rbp), %rdi
callq 0x31920
movl $0x1, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nop