// File: /workspace/github_c_makefile_star2_O0/neosploit[P]compiler/libfort/lib/fort.c
// Function: ft_to_string_impl
static
const void *ft_to_string_impl(const ft_table_t *table, enum f_string_type b_type)
{
    assert(table);

    const char *result = NULL;

    /* Determine size of table string representation */
    size_t cod_height = 0;
    size_t cod_width = 0;
    int status = table_internal_codepoints_geometry(table, &cod_height, &cod_width);
    if (FT_IS_ERROR(status)) {
        return NULL;
    }
    size_t n_codepoints = cod_height * cod_width + 1;

    /* Allocate string buffer for string representation */
    if (table->conv_buffer == NULL) {
        ((ft_table_t *)table)->conv_buffer = create_string_buffer(n_codepoints, b_type);
        if (table->conv_buffer == NULL)
            return NULL;
    }
    while (string_buffer_cod_width_capacity(table->conv_buffer) < n_codepoints) {
        if (FT_IS_ERROR(realloc_string_buffer_without_copy(table->conv_buffer))) {
            return NULL;
        }
    }
    if (!buffer_check_align(table->conv_buffer))
        return NULL;
    char *buffer = (char *)buffer_get_data(table->conv_buffer);

    size_t cols = 0;
    size_t rows = 0;
    size_t *col_vis_width_arr = NULL;
    size_t *row_vis_height_arr = NULL;
    status = table_rows_and_cols_geometry(table, &col_vis_width_arr, &cols, &row_vis_height_arr, &rows, VISIBLE_GEOMETRY);
    if (FT_IS_ERROR(status))
        return NULL;

    if (rows == 0) {
        F_FREE(col_vis_width_arr);
        F_FREE(row_vis_height_arr);
        return empty_str_arr[b_type];
    }

    int tmp = 0;
    size_t i = 0;
    f_context_t context;
    context.table_properties = (table->properties ? table->properties : &g_table_properties);
    f_row_t *prev_row = NULL;
    f_row_t *cur_row = NULL;
    f_separator_t *cur_sep = NULL;
    size_t sep_size = vector_size(table->separators);

    f_conv_context_t cntx;
    cntx.u.buf = buffer;
    cntx.raw_avail = string_buffer_raw_capacity(table->conv_buffer);
    cntx.cntx = &context;
    cntx.b_type = b_type;

    /* Print top margin */
    for (i = 0; i < context.table_properties->entire_table_properties.top_margin; ++i) {
        FT_CHECK(print_n_strings(&cntx, cod_width - 1/* minus new_line*/, FT_SPACE));
        FT_CHECK(print_n_strings(&cntx, 1, FT_NEWLINE));
    }

    for (i = 0; i < rows; ++i) {
        cur_sep = (i < sep_size) ? VECTOR_AT(table->separators, i, f_separator_t *) : NULL;
        cur_row = VECTOR_AT(table->rows, i, f_row_t *);
        enum f_hor_separator_pos separatorPos = (i == 0) ? TOP_SEPARATOR : INSIDE_SEPARATOR;
        context.row = i;
        FT_CHECK(print_row_separator(&cntx, col_vis_width_arr, cols, prev_row, cur_row, separatorPos, cur_sep));
        FT_CHECK(snprintf_row(cur_row, &cntx, col_vis_width_arr, cols, row_vis_height_arr[i]));
        prev_row = cur_row;
    }
    cur_row = NULL;
    cur_sep = (i < sep_size) ? VECTOR_AT(table->separators, i, f_separator_t *) : NULL;
    context.row = i;
    FT_CHECK(print_row_separator(&cntx, col_vis_width_arr, cols, prev_row, cur_row, BOTTOM_SEPARATOR, cur_sep));

    /* Print bottom margin */
    for (i = 0; i < context.table_properties->entire_table_properties.bottom_margin; ++i) {
        FT_CHECK(print_n_strings(&cntx, cod_width - 1/* minus new_line*/, FT_SPACE));
        FT_CHECK(print_n_strings(&cntx, 1, FT_NEWLINE));
    }

    result = buffer;

clear:
    F_FREE(col_vis_width_arr);
    F_FREE(row_vis_height_arr);
    return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0x1557b
jmp 0x1559a
leaq 0xd60e(%rip), %rdi      # 0x22b90
leaq 0xd60d(%rip), %rsi      # 0x22b96
movl $0xcf2, %edx            # imm = 0xCF2
leaq 0xe4eb(%rip), %rcx      # 0x23a80
callq 0x7120
movq $0x0, -0x20(%rbp)
movq $0x0, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x28(%rbp), %rsi
leaq -0x30(%rbp), %rdx
callq 0x18da0
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jge 0x155d9
movq $0x0, -0x8(%rbp)
jmp 0x15ac8
movq -0x28(%rbp), %rax
imulq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x15626
movq -0x40(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x17450
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0x15624
movq $0x0, -0x8(%rbp)
jmp 0x15ac8
jmp 0x15626
jmp 0x15628
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x18dd0
cmpq -0x40(%rbp), %rax
jae 0x1565c
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x177b0
cmpl $0x0, %eax
jge 0x1565a
movq $0x0, -0x8(%rbp)
jmp 0x15ac8
jmp 0x15628
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x18df0
cmpl $0x0, %eax
jne 0x1567b
movq $0x0, -0x8(%rbp)
jmp 0x15ac8
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x18ed0
movq %rax, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq $0x0, -0x58(%rbp)
movq $0x0, -0x60(%rbp)
movq $0x0, -0x68(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x60(%rbp), %rsi
leaq -0x50(%rbp), %rdx
leaq -0x68(%rbp), %rcx
leaq -0x58(%rbp), %r8
xorl %r9d, %r9d
callq 0x18f20
movl %eax, -0x34(%rbp)
cmpl $0x0, -0x34(%rbp)
jge 0x156de
movq $0x0, -0x8(%rbp)
jmp 0x15ac8
cmpq $0x0, -0x58(%rbp)
jne 0x15718
movq 0x14b3c(%rip), %rax     # 0x2a228
movq -0x60(%rbp), %rdi
callq *%rax
movq 0x14b2f(%rip), %rax     # 0x2a228
movq -0x68(%rbp), %rdi
callq *%rax
movl -0x14(%rbp), %eax
movl %eax, %ecx
leaq 0x16165(%rip), %rax     # 0x2b870
movq (%rax,%rcx,8), %rax
movq %rax, -0x8(%rbp)
jmp 0x15ac8
movl $0x0, -0x6c(%rbp)
movq $0x0, -0x78(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x15743
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0xe0(%rbp)
jmp 0x15753
leaq 0x14aee(%rip), %rax     # 0x2a238
movq %rax, -0xe0(%rbp)
jmp 0x15753
movq -0xe0(%rbp), %rax
movq %rax, -0x90(%rbp)
movq $0x0, -0x98(%rbp)
movq $0x0, -0xa0(%rbp)
movq $0x0, -0xa8(%rbp)
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
callq 0x132b0
movq %rax, -0xb0(%rbp)
movq -0x48(%rbp), %rax
movq %rax, -0xd0(%rbp)
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x196e0
movq %rax, -0xc8(%rbp)
leaq -0x90(%rbp), %rax
movq %rax, -0xc0(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0xb8(%rbp)
movq $0x0, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq -0x90(%rbp), %rcx
movl 0x16c(%rcx), %ecx
cmpq %rcx, %rax
jae 0x15851
jmp 0x157ec
movq -0x30(%rbp), %rsi
subq $0x1, %rsi
leaq -0xd0(%rbp), %rdi
leaq 0xce27(%rip), %rdx      # 0x22629
callq 0x19700
movl %eax, -0x6c(%rbp)
cmpl $0x0, -0x6c(%rbp)
jge 0x15815
jmp 0x15aa6
jmp 0x15817
jmp 0x15819
leaq -0xd0(%rbp), %rdi
movl $0x1, %esi
leaq 0xc831(%rip), %rdx      # 0x2205d
callq 0x19700
movl %eax, -0x6c(%rbp)
cmpl $0x0, -0x6c(%rbp)
jge 0x1583f
jmp 0x15aa6
jmp 0x15841
jmp 0x15843
movq -0x78(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x78(%rbp)
jmp 0x157d4
movq $0x0, -0x78(%rbp)
movq -0x78(%rbp), %rax
cmpq -0x58(%rbp), %rax
jae 0x15983
movq -0x78(%rbp), %rax
cmpq -0xb0(%rbp), %rax
jae 0x15891
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x78(%rbp), %rsi
callq 0x13350
movq (%rax), %rax
movq %rax, -0xe8(%rbp)
jmp 0x1589c
xorl %eax, %eax
movq %rax, -0xe8(%rbp)
jmp 0x1589c
movq -0xe8(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rdi
movq -0x78(%rbp), %rsi
callq 0x13350
movq (%rax), %rax
movq %rax, -0xa0(%rbp)
movq -0x78(%rbp), %rdx
movl $0x1, %eax
xorl %ecx, %ecx
cmpq $0x0, %rdx
cmovel %ecx, %eax
movl %eax, -0xd4(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x60(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0x98(%rbp), %rcx
movq -0xa0(%rbp), %r8
movl -0xd4(%rbp), %r9d
movq -0xa8(%rbp), %rax
leaq -0xd0(%rbp), %rdi
movq %rax, (%rsp)
callq 0x19880
movl %eax, -0x6c(%rbp)
cmpl $0x0, -0x6c(%rbp)
jge 0x15929
jmp 0x15aa6
jmp 0x1592b
jmp 0x1592d
movq -0xa0(%rbp), %rdi
movq -0x60(%rbp), %rdx
movq -0x50(%rbp), %rcx
movq -0x68(%rbp), %rax
movq -0x78(%rbp), %rsi
movq (%rax,%rsi,8), %r8
leaq -0xd0(%rbp), %rsi
callq 0x198d0
movl %eax, -0x6c(%rbp)
cmpl $0x0, -0x6c(%rbp)
jge 0x15962
jmp 0x15aa6
jmp 0x15964
movq -0xa0(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x78(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x78(%rbp)
jmp 0x15859
movq $0x0, -0xa0(%rbp)
movq -0x78(%rbp), %rax
cmpq -0xb0(%rbp), %rax
jae 0x159b8
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rdi
movq -0x78(%rbp), %rsi
callq 0x13350
movq (%rax), %rax
movq %rax, -0xf0(%rbp)
jmp 0x159c3
xorl %eax, %eax
movq %rax, -0xf0(%rbp)
jmp 0x159c3
movq -0xf0(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x88(%rbp)
movq -0x60(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq -0x98(%rbp), %rcx
movq -0xa0(%rbp), %r8
movq -0xa8(%rbp), %rax
leaq -0xd0(%rbp), %rdi
movl $0x2, %r9d
movq %rax, (%rsp)
callq 0x19880
movl %eax, -0x6c(%rbp)
cmpl $0x0, -0x6c(%rbp)
jge 0x15a1d
jmp 0x15aa6
jmp 0x15a1f
movq $0x0, -0x78(%rbp)
movq -0x78(%rbp), %rax
movq -0x90(%rbp), %rcx
movl 0x174(%rcx), %ecx
cmpq %rcx, %rax
jae 0x15a9e
jmp 0x15a3f
movq -0x30(%rbp), %rsi
subq $0x1, %rsi
leaq -0xd0(%rbp), %rdi
leaq 0xcbd4(%rip), %rdx      # 0x22629
callq 0x19700
movl %eax, -0x6c(%rbp)
cmpl $0x0, -0x6c(%rbp)
jge 0x15a65
jmp 0x15aa6
jmp 0x15a67
jmp 0x15a69
leaq -0xd0(%rbp), %rdi
movl $0x1, %esi
leaq 0xc5e1(%rip), %rdx      # 0x2205d
callq 0x19700
movl %eax, -0x6c(%rbp)
cmpl $0x0, -0x6c(%rbp)
jge 0x15a8c
jmp 0x15aa6
jmp 0x15a8e
jmp 0x15a90
movq -0x78(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x78(%rbp)
jmp 0x15a27
movq -0x48(%rbp), %rax
movq %rax, -0x20(%rbp)
movq 0x1477b(%rip), %rax     # 0x2a228
movq -0x60(%rbp), %rdi
callq *%rax
movq 0x1476e(%rip), %rax     # 0x2a228
movq -0x68(%rbp), %rdi
callq *%rax
movq -0x20(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopw %cs:(%rax,%rax)