// File: /workspace/github_c_makefile_star2_O0/neosploit[P]compiler/libfort/lib/fort.c
// Function: create_row_from_fmt_string
FT_INTERNAL
f_row_t *create_row_from_fmt_string(const struct f_string_view  *fmt, va_list *va_args)
{
    f_string_buffer_t *buffer = create_string_buffer(DEFAULT_STR_BUF_SIZE, fmt->type);
    if (buffer == NULL)
        return NULL;

    size_t cols_origin = number_of_columns_in_format_string(fmt);
    size_t cols = 0;

    while (1) {
        va_list va;
        va_copy(va, *va_args);
        int virtual_sz = vsnprintf_buffer(buffer, fmt, &va);
        va_end(va);
        /* If error encountered */
        if (virtual_sz < 0)
            goto clear;

        /* Successful write */
        if ((size_t)virtual_sz < string_buffer_width_capacity(buffer))
            break;

        /* Otherwise buffer was too small, so incr. buffer size ant try again. */
        if (!FT_IS_SUCCESS(realloc_string_buffer_without_copy(buffer)))
            goto clear;
    }

    cols = number_of_columns_in_format_buffer(buffer);
    if (cols == cols_origin) {
        f_row_t *row = create_row_from_buffer(buffer);
        if (row == NULL) {
            goto clear;
        }

        destroy_string_buffer(buffer);
        return row;
    }

    if (cols_origin == 1) {
        f_row_t *row = create_row();
        if (row == NULL) {
            goto clear;
        }

        f_cell_t *cell = get_cell_and_create_if_not_exists(row, 0);
        if (cell == NULL) {
            destroy_row(row);
            goto clear;
        }

        f_status result = fill_cell_from_buffer(cell, buffer);
        if (FT_IS_ERROR(result)) {
            destroy_row(row);
            goto clear;
        }

        destroy_string_buffer(buffer);
        return row;
    }

    /*
     * todo: add processing of cols != cols_origin in a general way
     * (when cols_origin != 1).
     */

clear:
    destroy_string_buffer(buffer);
    return NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %esi
movl $0x400, %edi            # imm = 0x400
callq 0x17450
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x1708c
movq $0x0, -0x8(%rbp)
jmp 0x171d7
movq -0x10(%rbp), %rdi
callq 0x17590
movq %rax, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
leaq -0x50(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rax)
movups (%rcx), %xmm0
movups %xmm0, (%rax)
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x17620
movl %eax, -0x54(%rbp)
leaq -0x50(%rbp), %rax
cmpl $0x0, -0x54(%rbp)
jge 0x170da
jmp 0x171c6
movslq -0x54(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0x20(%rbp), %rdi
callq 0x176f0
movq %rax, %rcx
movq -0x80(%rbp), %rax
cmpq %rcx, %rax
jae 0x170f9
jmp 0x1710e
movq -0x20(%rbp), %rdi
callq 0x177b0
cmpl $0x0, %eax
jge 0x1710c
jmp 0x171c6
jmp 0x170a1
movq -0x20(%rbp), %rdi
callq 0x17850
movq %rax, -0x30(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x28(%rbp), %rax
jne 0x17154
movq -0x20(%rbp), %rdi
callq 0x178e0
movq %rax, -0x60(%rbp)
cmpq $0x0, -0x60(%rbp)
jne 0x1713e
jmp 0x171c6
movq -0x20(%rbp), %rdi
callq 0x13410
movq -0x60(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x171d7
cmpq $0x1, -0x28(%rbp)
jne 0x171c4
callq 0x171f0
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x68(%rbp)
jne 0x1716d
jmp 0x171c6
movq -0x68(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x17970
movq %rax, -0x70(%rbp)
cmpq $0x0, -0x70(%rbp)
jne 0x17190
movq -0x68(%rbp), %rdi
callq 0x13300
jmp 0x171c6
movq -0x70(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x179a0
movl %eax, -0x74(%rbp)
cmpl $0x0, -0x74(%rbp)
jge 0x171b1
movq -0x68(%rbp), %rdi
callq 0x13300
jmp 0x171c6
movq -0x20(%rbp), %rdi
callq 0x13410
movq -0x68(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x171d7
jmp 0x171c6
movq -0x20(%rbp), %rdi
callq 0x13410
movq $0x0, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)