// File: /workspace/github_c_makefile_star2_O1/neosploit[P]compiler/libfort/lib/fort.c
// Function: table_rows_and_cols_geometry
FT_INTERNAL
f_status table_rows_and_cols_geometry(const ft_table_t *table,
                                      size_t **col_width_arr_p, size_t *col_width_arr_sz,
                                      size_t **row_height_arr_p, size_t *row_height_arr_sz,
                                      enum f_geometry_type geom)
{
    if (table == NULL) {
        return FT_GEN_ERROR;
    }

    size_t max_invis_codepoints = 0;
    size_t cols = 0;
    size_t rows = 0;
    int status = get_table_sizes(table, &rows, &cols);
    if (FT_IS_ERROR(status))
        return status;

    size_t *col_width_arr = (size_t *)F_CALLOC(cols, sizeof(size_t));
    size_t *row_height_arr = (size_t *)F_CALLOC(rows, sizeof(size_t));
    if (col_width_arr == NULL || row_height_arr == NULL) {
        F_FREE(col_width_arr);
        F_FREE(row_height_arr);
        return FT_GEN_ERROR;
    }

    int combined_cells_found = 0;
    f_context_t context;
    context.table_properties = (table->properties ? table->properties : &g_table_properties);
    size_t col = 0;
    for (col = 0; col < cols; ++col) {
        col_width_arr[col] = 0;
        size_t row = 0;
        for (row = 0; row < rows; ++row) {
            const f_row_t *row_p = get_row_c(table, row);
            const f_cell_t *cell = get_cell_c(row_p, col);
            context.column = col;
            context.row = row;
            if (cell) {
                switch (get_cell_type(cell)) {
                    case COMMON_CELL:
                        col_width_arr[col] = MAX(col_width_arr[col], cell_vis_width(cell, &context));
                        break;
                    case GROUP_MASTER_CELL:
                        combined_cells_found = 1;
                        break;
                    case GROUP_SLAVE_CELL:
                        ; /* Do nothing */
                        break;
                }
                row_height_arr[row] = MAX(row_height_arr[row], hint_height_cell(cell, &context));
            } else {
                size_t cell_empty_string_height = get_cell_property_hierarchically(context.table_properties, context.row, context.column, FT_CPROP_EMPTY_STR_HEIGHT);
                if (cell_empty_string_height) {
                    size_t cell_top_padding = get_cell_property_hierarchically(context.table_properties, context.row, context.column, FT_CPROP_TOP_PADDING);
                    size_t cell_bottom_padding = get_cell_property_hierarchically(context.table_properties, context.row, context.column, FT_CPROP_BOTTOM_PADDING);
                    row_height_arr[row] = MAX(row_height_arr[row], cell_empty_string_height + cell_top_padding + cell_bottom_padding);
                }
            }
        }

        if (geom == INTERN_REPR_GEOMETRY) {
            max_invis_codepoints = 0;
            for (row = 0; row < rows; ++row) {
                const f_row_t *row_p = get_row_c(table, row);
                const f_cell_t *cell = get_cell_c(row_p, col);
                if (!cell)
                    continue;
                context.column = col;
                context.row = row;
                size_t inv_codepoints = cell_invis_codes_width(cell, &context);
                max_invis_codepoints = MAX(max_invis_codepoints, inv_codepoints);
            }
            col_width_arr[col] += max_invis_codepoints;
        }
    }

    if (combined_cells_found) {
        for (col = 0; col < cols; ++col) {
            size_t row = 0;
            for (row = 0; row < rows; ++row) {
                const f_row_t *row_p = get_row_c(table, row);
                const f_cell_t *cell = get_cell_c(row_p, col);
                context.column = col;
                context.row = row;
                if (cell) {
                    if (get_cell_type(cell) == GROUP_MASTER_CELL) {
                        size_t hint_width = cell_vis_width(cell, &context);
                        if (geom == INTERN_REPR_GEOMETRY) {
                            hint_width += cell_invis_codes_width(cell, &context);
                        }
                        size_t slave_col = col + group_cell_number(row_p, col);
                        size_t cur_adj_col = col;
                        size_t group_width = col_width_arr[col];
                        size_t i;
                        for (i = col + 1; i < slave_col; ++i)
                            group_width += col_width_arr[i] + FORT_COL_SEPARATOR_LENGTH;
                        /* adjust col. widths */
                        while (1) {
                            if (group_width >= hint_width)
                                break;
                            col_width_arr[cur_adj_col] += 1;
                            group_width++;
                            cur_adj_col++;
                            if (cur_adj_col == slave_col)
                                cur_adj_col = col;
                        }
                    }
                }
            }
        }
    }

    /* todo: Maybe it is better to move min width checking to a particular cell
     * width checking. At the moment min width includes paddings. Maybe it is
     * better that min width weren't include paddings but be min width of the
     * cell content without padding
     */
    /*
    if (table->properties) {
        for (size_t i = 0; i < cols; ++i) {
            col_width_arr[i] = MAX((int)col_width_arr[i], fort_props_column_width(table->properties, i));
        }
    }
    */

    *col_width_arr_p = col_width_arr;
    *col_width_arr_sz = cols;
    *row_height_arr_p = row_height_arr;
    *row_height_arr_sz = rows;
    return FT_SUCCESS;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %r9d, -0x5c(%rbp)
movq %rdi, -0x50(%rbp)
movq (%rdi), %rdi
testq %rdi, %rdi
movq %rcx, -0xa0(%rbp)
movq %rdx, -0x98(%rbp)
movq %rsi, -0x90(%rbp)
je 0x138d8
movq (%rdi), %rdx
testq %rdx, %rdx
je 0x138e1
movq 0x8(%rdi), %rax
movq 0x18(%rdi), %rcx
xorl %edi, %edi
movq %rdx, %rbx
movq (%rax), %rsi
testq %rsi, %rsi
je 0x138c2
movq (%rsi), %rsi
testq %rsi, %rsi
je 0x138c2
movq (%rsi), %rsi
jmp 0x138c4
xorl %esi, %esi
cmpq %rdi, %rsi
cmovaq %rsi, %rdi
addq %rcx, %rax
decq %rdx
jne 0x138ad
movq %r8, %r12
jmp 0x138e9
movq %r8, %r12
xorl %edi, %edi
xorl %ebx, %ebx
jmp 0x138e9
movq %r8, %r12
xorl %edi, %edi
movq %rdx, %rbx
movl $0x8, %esi
movq %rdi, %r14
callq *0xd939(%rip)           # 0x21230
movq %rax, %r15
movl $0x8, %esi
movq %rbx, -0x30(%rbp)
movq %rbx, %rdi
callq *0xd924(%rip)           # 0x21230
movq %r15, %r8
movq %rax, %r13
testq %r15, %r15
sete %al
testq %r13, %r13
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x13941
movq %r8, %rdi
callq *0xd90a(%rip)           # 0x21238
movq %r13, %rdi
callq *0xd901(%rip)           # 0x21238
movl $0xfffffffc, %eax       # imm = 0xFFFFFFFC
jmp 0x13cf4
movq -0x50(%rbp), %r15
movq 0x8(%r15), %rax
testq %rax, %rax
leaq 0xd8f5(%rip), %rcx      # 0x21248
cmovneq %rax, %rcx
movq %rcx, -0x48(%rbp)
xorl %eax, %eax
testq %r14, %r14
movq %r14, -0x70(%rbp)
movq %r8, -0x58(%rbp)
movq %r13, -0x80(%rbp)
movq %r12, -0x88(%rbp)
je 0x13ba7
movq $0x0, -0x78(%rbp)
xorl %r12d, %r12d
movq -0x30(%rbp), %rdx
movq $0x0, (%r8,%r12,8)
testq %rdx, %rdx
je 0x13b0c
xorl %ebx, %ebx
movq %r12, -0x68(%rbp)
movq (%r15), %rax
testq %rax, %rax
je 0x139be
cmpq %rbx, (%rax)
jbe 0x139be
movq 0x8(%rax), %rcx
movq 0x18(%rax), %rax
imulq %rbx, %rax
movq (%rcx,%rax), %rax
jmp 0x139c0
xorl %eax, %eax
testq %rax, %rax
je 0x139e4
movq (%rax), %rax
testq %rax, %rax
je 0x139e4
cmpq %r12, (%rax)
jbe 0x139e4
movq 0x8(%rax), %rcx
movq 0x18(%rax), %rax
imulq %r12, %rax
movq (%rcx,%rax), %r15
jmp 0x139e7
xorl %r15d, %r15d
movq %r12, -0x38(%rbp)
movq %rbx, -0x40(%rbp)
testq %r15, %r15
je 0x13a2f
movl 0x8(%r15), %eax
cmpl $0x1, %eax
je 0x13aa0
testl %eax, %eax
jne 0x13ac0
movq (%r8,%r12,8), %r14
movq %r15, %rdi
leaq -0x48(%rbp), %rsi
movq %r8, %r13
callq 0x1450d
cmpq %rax, %r14
jbe 0x13aab
movq (%r13,%r12,8), %rax
jmp 0x13ab7
movq -0x48(%rbp), %rdi
movq %rbx, %rsi
movq %r12, %rdx
movl $0x40, %ecx
callq 0x1469a
testl %eax, %eax
je 0x13a92
movslq %eax, %r14
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
movl $0x4, %ecx
callq 0x1469a
movslq %eax, %r15
addq %r14, %r15
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
movl $0x8, %ecx
callq 0x1469a
cltq
addq %r15, %rax
movq (%r13,%rbx,8), %rcx
cmpq %rax, %rcx
cmovaq %rcx, %rax
movq %rax, (%r13,%rbx,8)
movq -0x30(%rbp), %rdx
movq -0x58(%rbp), %r8
movq -0x50(%rbp), %r15
jmp 0x13b00
movl $0x1, %eax
movq %rax, -0x78(%rbp)
jmp 0x13ac0
movq %r15, %rdi
leaq -0x48(%rbp), %rsi
callq 0x1450d
movq %rax, (%r13,%r12,8)
movq -0x80(%rbp), %r13
leaq -0x48(%rbp), %rsi
movq (%r13,%rbx,8), %r14
movq %r15, %rdi
movq %rsi, %r12
callq 0x145dd
cmpq %rax, %r14
jbe 0x13ae0
movq (%r13,%rbx,8), %rax
jmp 0x13aeb
movq %r15, %rdi
movq %r12, %rsi
callq 0x145dd
movq -0x30(%rbp), %rdx
movq -0x50(%rbp), %r15
movq %rax, (%r13,%rbx,8)
movq -0x58(%rbp), %r8
movq -0x68(%rbp), %r12
incq %rbx
cmpq %rbx, %rdx
jne 0x1399f
cmpl $0x1, -0x5c(%rbp)
jne 0x13b8e
xorl %ebx, %ebx
testq %rdx, %rdx
je 0x13b8a
xorl %r14d, %r14d
movq (%r15), %rax
testq %rax, %rax
je 0x13b3b
cmpq %r14, (%rax)
jbe 0x13b3b
movq 0x8(%rax), %rcx
movq 0x18(%rax), %rax
imulq %r14, %rax
movq (%rcx,%rax), %rax
jmp 0x13b3d
xorl %eax, %eax
testq %rax, %rax
je 0x13b82
movq (%rax), %rax
testq %rax, %rax
je 0x13b82
cmpq %r12, (%rax)
jbe 0x13b82
movq 0x8(%rax), %rcx
movq 0x18(%rax), %rax
imulq %r12, %rax
cmpq $0x0, (%rcx,%rax)
je 0x13b82
movq %r12, -0x38(%rbp)
movq %r14, -0x40(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x1486b
movq -0x58(%rbp), %r8
movq -0x30(%rbp), %rdx
cmpq %rax, %rbx
cmovbeq %rax, %rbx
incq %r14
cmpq %r14, %rdx
jne 0x13b1c
addq %rbx, (%r8,%r12,8)
incq %r12
movq -0x70(%rbp), %r14
cmpq %r14, %r12
jne 0x13988
cmpl $0x0, -0x78(%rbp)
setne %al
jmp 0x13bab
movq -0x30(%rbp), %rdx
testb %al, %al
je 0x13cc6
testq %r14, %r14
je 0x13cc6
xorl %ebx, %ebx
movq %r8, %r13
testq %rdx, %rdx
je 0x13cb2
leaq 0x1(%rbx), %rax
movq %rax, -0x68(%rbp)
xorl %r14d, %r14d
movq -0x50(%rbp), %rax
movq (%rax), %rax
testq %rax, %rax
je 0x13bf8
cmpq %r14, (%rax)
jbe 0x13bf8
movq 0x8(%rax), %rcx
movq 0x18(%rax), %rax
imulq %r14, %rax
movq (%rcx,%rax), %r15
jmp 0x13bfb
xorl %r15d, %r15d
testq %r15, %r15
je 0x13c1f
movq (%r15), %rax
testq %rax, %rax
je 0x13c1f
cmpq %rbx, (%rax)
jbe 0x13c1f
movq 0x8(%rax), %rcx
movq 0x18(%rax), %rax
imulq %rbx, %rax
movq (%rcx,%rax), %rdi
jmp 0x13c21
xorl %edi, %edi
movq %rbx, -0x38(%rbp)
movq %r14, -0x40(%rbp)
testq %rdi, %rdi
je 0x13ca6
cmpl $0x1, 0x8(%rdi)
jne 0x13ca6
leaq -0x48(%rbp), %rsi
callq 0x1450d
movq %rax, %r12
cmpl $0x1, -0x5c(%rbp)
jne 0x13c52
leaq -0x48(%rbp), %rdi
callq 0x1486b
addq %rax, %r12
movq %r15, %rdi
movq %rbx, %rsi
callq 0x14956
leaq (%rax,%rbx), %rcx
movq -0x58(%rbp), %r8
movq (%r8,%rbx,8), %rdx
cmpq %rcx, -0x68(%rbp)
jae 0x13c87
movl $0x1, %esi
movq (%r13,%rsi,8), %rdi
addq %rdi, %rdx
incq %rdx
incq %rsi
cmpq %rsi, %rax
jne 0x13c74
subq %rdx, %r12
movq -0x30(%rbp), %rdx
jbe 0x13ca6
movq %rbx, %rax
incq (%r8,%rax,8)
incq %rax
cmpq %rcx, %rax
cmoveq %rbx, %rax
decq %r12
jne 0x13c93
incq %r14
cmpq %rdx, %r14
jne 0x13bd5
incq %rbx
addq $0x8, %r13
movq -0x70(%rbp), %r14
cmpq %r14, %rbx
jne 0x13bc1
movq -0x90(%rbp), %rax
movq %r8, (%rax)
movq -0x98(%rbp), %rax
movq %r14, (%rax)
movq -0xa0(%rbp), %rax
movq -0x80(%rbp), %rcx
movq %rcx, (%rax)
movq -0x88(%rbp), %rax
movq %rdx, (%rax)
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq