// File: /workspace/github_c_makefile_star2_O0/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
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movl %r9d, -0x34(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x18f56
movl $0xfffffffc, -0x4(%rbp) # imm = 0xFFFFFFFC
jmp 0x196d4
movq $0x0, -0x40(%rbp)
movq $0x0, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
movq -0x10(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x48(%rbp), %rdx
callq 0x1a120
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x54(%rbp)
jge 0x18f93
movl -0x54(%rbp), %eax
movl %eax, -0x4(%rbp)
jmp 0x196d4
movq 0x11286(%rip), %rax     # 0x2a220
movq -0x48(%rbp), %rdi
movl $0x8, %esi
callq *%rax
movq %rax, -0x60(%rbp)
movq 0x11270(%rip), %rax     # 0x2a220
movq -0x50(%rbp), %rdi
movl $0x8, %esi
callq *%rax
movq %rax, -0x68(%rbp)
cmpq $0x0, -0x60(%rbp)
je 0x18fcd
cmpq $0x0, -0x68(%rbp)
jne 0x18ff3
movq 0x11254(%rip), %rax     # 0x2a228
movq -0x60(%rbp), %rdi
callq *%rax
movq 0x11247(%rip), %rax     # 0x2a228
movq -0x68(%rbp), %rdi
callq *%rax
movl $0xfffffffc, -0x4(%rbp) # imm = 0xFFFFFFFC
jmp 0x196d4
movl $0x0, -0x6c(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x8(%rax)
je 0x19016
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x120(%rbp)
jmp 0x19026
leaq 0x1121b(%rip), %rax     # 0x2a238
movq %rax, -0x120(%rbp)
jmp 0x19026
movq -0x120(%rbp), %rax
movq %rax, -0x88(%rbp)
movq $0x0, -0x90(%rbp)
movq $0x0, -0x90(%rbp)
movq -0x90(%rbp), %rax
cmpq -0x48(%rbp), %rax
jae 0x19452
movq -0x60(%rbp), %rax
movq -0x90(%rbp), %rcx
movq $0x0, (%rax,%rcx,8)
movq $0x0, -0x98(%rbp)
movq $0x0, -0x98(%rbp)
movq -0x98(%rbp), %rax
cmpq -0x50(%rbp), %rax
jae 0x1933d
movq -0x10(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0x1a200
movq %rax, -0xa0(%rbp)
movq -0xa0(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0x1a230
movq %rax, -0xa8(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0x80(%rbp)
cmpq $0x0, -0xa8(%rbp)
je 0x1923b
movq -0xa8(%rbp), %rdi
callq 0x1a260
movl %eax, %ecx
movl %ecx, -0x124(%rbp)
testl %eax, %eax
je 0x19129
jmp 0x19104
movl -0x124(%rbp), %eax
subl $0x1, %eax
je 0x191ab
jmp 0x19115
movl -0x124(%rbp), %eax
subl $0x2, %eax
je 0x191b4
jmp 0x191b6
movq -0x60(%rbp), %rax
movq -0x90(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x130(%rbp)
movq -0xa8(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x1a2b0
movq %rax, %rcx
movq -0x130(%rbp), %rax
cmpq %rcx, %rax
jbe 0x19179
movq -0x60(%rbp), %rax
movq -0x90(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x138(%rbp)
jmp 0x19193
movq -0xa8(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x1a2b0
movq %rax, -0x138(%rbp)
movq -0x138(%rbp), %rdx
movq -0x60(%rbp), %rax
movq -0x90(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x191b6
movl $0x1, -0x6c(%rbp)
jmp 0x191b6
jmp 0x191b6
movq -0x68(%rbp), %rax
movq -0x98(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x140(%rbp)
movq -0xa8(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x1a410
movq %rax, %rcx
movq -0x140(%rbp), %rax
cmpq %rcx, %rax
jbe 0x19206
movq -0x68(%rbp), %rax
movq -0x98(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x148(%rbp)
jmp 0x19220
movq -0xa8(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x1a410
movq %rax, -0x148(%rbp)
movq -0x148(%rbp), %rdx
movq -0x68(%rbp), %rax
movq -0x98(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x19324
movq -0x88(%rbp), %rdi
movq -0x80(%rbp), %rsi
movq -0x78(%rbp), %rdx
movl $0x40, %ecx
callq 0x1a550
cltq
movq %rax, -0xb0(%rbp)
cmpq $0x0, -0xb0(%rbp)
je 0x19322
movq -0x88(%rbp), %rdi
movq -0x80(%rbp), %rsi
movq -0x78(%rbp), %rdx
movl $0x4, %ecx
callq 0x1a550
cltq
movq %rax, -0xb8(%rbp)
movq -0x88(%rbp), %rdi
movq -0x80(%rbp), %rsi
movq -0x78(%rbp), %rdx
movl $0x8, %ecx
callq 0x1a550
cltq
movq %rax, -0xc0(%rbp)
movq -0x68(%rbp), %rax
movq -0x98(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq -0xb0(%rbp), %rcx
addq -0xb8(%rbp), %rcx
addq -0xc0(%rbp), %rcx
cmpq %rcx, %rax
jbe 0x192f0
movq -0x68(%rbp), %rax
movq -0x98(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x150(%rbp)
jmp 0x1930c
movq -0xb0(%rbp), %rax
addq -0xb8(%rbp), %rax
addq -0xc0(%rbp), %rax
movq %rax, -0x150(%rbp)
movq -0x150(%rbp), %rdx
movq -0x68(%rbp), %rax
movq -0x98(%rbp), %rcx
movq %rdx, (%rax,%rcx,8)
jmp 0x19324
jmp 0x19326
movq -0x98(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x98(%rbp)
jmp 0x19084
cmpl $0x1, -0x34(%rbp)
jne 0x19439
movq $0x0, -0x40(%rbp)
movq $0x0, -0x98(%rbp)
movq -0x98(%rbp), %rax
cmpq -0x50(%rbp), %rax
jae 0x19422
movq -0x10(%rbp), %rdi
movq -0x98(%rbp), %rsi
callq 0x1a200
movq %rax, -0xc8(%rbp)
movq -0xc8(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0x1a230
movq %rax, -0xd0(%rbp)
cmpq $0x0, -0xd0(%rbp)
jne 0x193a8
jmp 0x1940b
movq -0x90(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x98(%rbp), %rax
movq %rax, -0x80(%rbp)
movq -0xd0(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x1a690
movq %rax, -0xd8(%rbp)
movq -0x40(%rbp), %rax
cmpq -0xd8(%rbp), %rax
jbe 0x193f2
movq -0x40(%rbp), %rax
movq %rax, -0x158(%rbp)
jmp 0x19400
movq -0xd8(%rbp), %rax
movq %rax, -0x158(%rbp)
movq -0x158(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x98(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x98(%rbp)
jmp 0x1935a
movq -0x40(%rbp), %rdx
movq -0x60(%rbp), %rax
movq -0x90(%rbp), %rcx
addq (%rax,%rcx,8), %rdx
movq %rdx, (%rax,%rcx,8)
jmp 0x1943b
movq -0x90(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x90(%rbp)
jmp 0x1904a
cmpl $0x0, -0x6c(%rbp)
je 0x196a1
movq $0x0, -0x90(%rbp)
movq -0x90(%rbp), %rax
cmpq -0x48(%rbp), %rax
jae 0x1969f
movq $0x0, -0xe0(%rbp)
movq $0x0, -0xe0(%rbp)
movq -0xe0(%rbp), %rax
cmpq -0x50(%rbp), %rax
jae 0x19686
movq -0x10(%rbp), %rdi
movq -0xe0(%rbp), %rsi
callq 0x1a200
movq %rax, -0xe8(%rbp)
movq -0xe8(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0x1a230
movq %rax, -0xf0(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0xe0(%rbp), %rax
movq %rax, -0x80(%rbp)
cmpq $0x0, -0xf0(%rbp)
je 0x1966d
movq -0xf0(%rbp), %rdi
callq 0x1a260
cmpl $0x1, %eax
jne 0x1966b
movq -0xf0(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x1a2b0
movq %rax, -0xf8(%rbp)
cmpl $0x1, -0x34(%rbp)
jne 0x1954a
movq -0xf0(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x1a690
addq -0xf8(%rbp), %rax
movq %rax, -0xf8(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0x160(%rbp)
movq -0xe8(%rbp), %rdi
movq -0x90(%rbp), %rsi
callq 0x1a800
movq %rax, %rcx
movq -0x160(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x100(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0x108(%rbp)
movq -0x60(%rbp), %rax
movq -0x90(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x110(%rbp)
movq -0x90(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x118(%rbp)
movq -0x118(%rbp), %rax
cmpq -0x100(%rbp), %rax
jae 0x195fa
movq -0x60(%rbp), %rax
movq -0x118(%rbp), %rcx
movq (%rax,%rcx,8), %rax
addq $0x1, %rax
addq -0x110(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0x118(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x118(%rbp)
jmp 0x195b5
jmp 0x195fc
movq -0x110(%rbp), %rax
cmpq -0xf8(%rbp), %rax
jb 0x1960e
jmp 0x19669
movq -0x60(%rbp), %rax
movq -0x108(%rbp), %rcx
movq (%rax,%rcx,8), %rdx
addq $0x1, %rdx
movq %rdx, (%rax,%rcx,8)
movq -0x110(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x110(%rbp)
movq -0x108(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x108(%rbp)
movq -0x108(%rbp), %rax
cmpq -0x100(%rbp), %rax
jne 0x19667
movq -0x90(%rbp), %rax
movq %rax, -0x108(%rbp)
jmp 0x195fc
jmp 0x1966b
jmp 0x1966d
jmp 0x1966f
movq -0xe0(%rbp), %rax
addq $0x1, %rax
movq %rax, -0xe0(%rbp)
jmp 0x1948e
jmp 0x19688
movq -0x90(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x90(%rbp)
jmp 0x19467
jmp 0x196a1
movq -0x60(%rbp), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x48(%rbp), %rcx
movq -0x20(%rbp), %rax
movq %rcx, (%rax)
movq -0x68(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x50(%rbp), %rcx
movq -0x30(%rbp), %rax
movq %rcx, (%rax)
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq