// File: /workspace/github_c_makefile_star2_O1/neosploit[P]compiler/libfort/lib/fort.c
// Function: create_row_from_string
FT_INTERNAL
f_row_t *create_row_from_string(const char *str)
{
    typedef char char_type;
    char_type *(*strdup_)(const char_type * str) = F_STRDUP;
    const char_type zero_char = '\0';
    f_status(*fill_cell_from_string_)(f_cell_t *cell, const char *str) = fill_cell_from_string;
    const char_type *const zero_string = "";
#define STRCHR strchr

    char_type *pos = NULL;
    char_type *base_pos = NULL;
    size_t number_of_separators = 0;

    f_row_t *row = create_row();
    if (row == NULL)
        return NULL;

    if (str == NULL)
        return row;

    char_type *str_copy = strdup_(str);
    if (str_copy == NULL)
        goto clear;

    pos = str_copy;
    base_pos = str_copy;
    number_of_separators = 0;
    while (*pos) {
        pos = STRCHR(pos, g_col_separator);
        if (pos != NULL) {
            *(pos) = zero_char;
            ++pos;
            number_of_separators++;
        }

        f_cell_t *cell = create_cell();
        if (cell == NULL)
            goto clear;

        int status = fill_cell_from_string_(cell, base_pos);
        if (FT_IS_ERROR(status)) {
            destroy_cell(cell);
            goto clear;
        }

        status = vector_push(row->cells, &cell);
        if (FT_IS_ERROR(status)) {
            destroy_cell(cell);
            goto clear;
        }

        if (pos == NULL)
            break;
        base_pos = pos;
    }

    /* special case if in format string last cell is empty */
    while (vector_size(row->cells) < (number_of_separators + 1)) {
        f_cell_t *cell = create_cell();
        if (cell == NULL)
            goto clear;

        int status = fill_cell_from_string_(cell, zero_string);
        if (FT_IS_ERROR(status)) {
            destroy_cell(cell);
            goto clear;
        }

        status = vector_push(row->cells, &cell);
        if (FT_IS_ERROR(status)) {
            destroy_cell(cell);
            goto clear;
        }
    }

    F_FREE(str_copy);
    return row;

clear:
    destroy_row(row);
    F_FREE(str_copy);
    return NULL;

#undef STRCHR
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r15
xorl %r14d, %r14d
xorl %edi, %edi
callq 0x12e1d
testq %rax, %rax
je 0x132ef
movq %rax, %rbx
testq %r15, %r15
je 0x132ec
movq %r15, %rdi
callq 0x13301
movq %rax, %r13
testq %rax, %rax
je 0x132cd
movq %rbx, -0x40(%rbp)
xorl %r12d, %r12d
leaq -0x30(%rbp), %r14
movq %r13, %r15
movq %r13, -0x48(%rbp)
cmpb $0x0, (%r13)
je 0x1321e
movsbl 0xe0e5(%rip), %esi      # 0x21240
movq %r13, %rdi
callq 0x70f0
testq %rax, %rax
je 0x13176
movq %rax, %r13
movb $0x0, (%rax)
incq %r13
incq %r12
jmp 0x13179
xorl %r13d, %r13d
callq 0x13368
movq %rax, -0x30(%rbp)
movl $0x2, %ebx
testq %rax, %rax
je 0x13204
movq %rax, %rdi
movq %r15, %rsi
callq 0x13338
testl %eax, %eax
js 0x131bf
movq -0x40(%rbp), %rax
movq (%rax), %rdi
movq %r14, %rsi
callq 0xf454
testl %eax, %eax
js 0x131bf
xorl %ebx, %ebx
testq %r13, %r13
sete %bl
cmovneq %r13, %r15
shll $0x2, %ebx
jmp 0x13204
movq %r12, -0x38(%rbp)
movq %r15, %r12
movq -0x30(%rbp), %r15
testq %r15, %r15
je 0x131fd
movq (%r15), %r14
testq %r14, %r14
je 0x131f0
movq (%r14), %rdi
callq *0xe058(%rip)           # 0x21238
movq $0x0, (%r14)
movq %r14, %rdi
callq *0xe048(%rip)           # 0x21238
movq %r15, %rdi
callq *0xe03f(%rip)           # 0x21238
leaq -0x30(%rbp), %r14
movq %r12, %r15
movq -0x38(%rbp), %r12
testl %ebx, %ebx
je 0x13149
cmpl $0x2, %ebx
movq -0x40(%rbp), %rbx
movq -0x48(%rbp), %r13
jne 0x13226
jmp 0x132cd
movq -0x40(%rbp), %rbx
movq -0x48(%rbp), %r13
movq (%rbx), %rax
testq %rax, %rax
je 0x13279
incq %r12
leaq 0x5b76(%rip), %r15      # 0x18dae
leaq -0x30(%rbp), %r14
cmpq %r12, (%rax)
jae 0x132e3
callq 0x13368
movq %rax, -0x30(%rbp)
testq %rax, %rax
je 0x132cd
movq (%rax), %rdi
movq %r15, %rsi
callq 0x133f2
testl %eax, %eax
js 0x13298
movq (%rbx), %rdi
movq %r14, %rsi
callq 0xf454
testl %eax, %eax
js 0x13298
movq (%rbx), %rax
testq %rax, %rax
jne 0x1323c
leaq 0x753b(%rip), %rdi      # 0x1a7bb
leaq 0x67ff(%rip), %rsi      # 0x19a86
leaq 0x810f(%rip), %rcx      # 0x1b39d
movl $0x1c74, %edx           # imm = 0x1C74
callq 0x7130
movq -0x30(%rbp), %r15
testq %r15, %r15
je 0x132cd
movq (%r15), %r12
testq %r12, %r12
je 0x132c4
movq (%r12), %rdi
callq *0xdf85(%rip)           # 0x21238
movq $0x0, (%r12)
movq %r12, %rdi
callq *0xdf74(%rip)           # 0x21238
movq %r15, %rdi
callq *0xdf6b(%rip)           # 0x21238
movq %rbx, %rdi
callq 0xef82
movq %r13, %rdi
callq *0xdf5a(%rip)           # 0x21238
xorl %r14d, %r14d
jmp 0x132ef
movq %r13, %rdi
callq *0xdf4c(%rip)           # 0x21238
movq %rbx, %r14
movq %r14, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq