// File: /workspace/github_c_makefile_star2_O3/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, -0x54(%rbp)
movq %r8, -0x98(%rbp)
movq %rcx, -0x90(%rbp)
movq %rdx, %r12
movq %rsi, -0x88(%rbp)
movq %rdi, -0x50(%rbp)
movq (%rdi), %rcx
testq %rcx, %rcx
je 0x13377
movq (%rcx), %r14
testq %r14, %r14
je 0x13377
movq 0x8(%rcx), %rax
movq 0x18(%rcx), %rcx
xorl %r13d, %r13d
movq %r14, %rdx
xorl %esi, %esi
movq (%rax), %rdi
testq %rdi, %rdi
je 0x1336a
movq (%rdi), %rdi
testq %rdi, %rdi
je 0x1336a
movq (%rdi), %rdi
cmpq %r13, %rdi
cmovaq %rdi, %r13
cmovaq %r14, %rdx
incq %rsi
addq %rcx, %rax
cmpq %rdx, %rsi
jb 0x1334c
jmp 0x1337d
xorl %r13d, %r13d
xorl %r14d, %r14d
movl $0x8, %esi
movq %r13, %rdi
callq *0xcea5(%rip)           # 0x20230
movq %rax, %rbx
movl $0x8, %esi
movq %r14, %rdi
callq *0xce94(%rip)           # 0x20230
movq %rax, %r15
testq %rbx, %rbx
sete %al
testq %r15, %r15
sete %cl
orb %al, %cl
cmpb $0x1, %cl
jne 0x133ce
movq %rbx, %rdi
callq *0xce7d(%rip)           # 0x20238
movq %r15, %rdi
callq *0xce74(%rip)           # 0x20238
movl $0xfffffffc, %eax       # imm = 0xFFFFFFFC
jmp 0x1379e
movq %r15, -0x30(%rbp)
movq %r12, -0x80(%rbp)
movq -0x50(%rbp), %rdx
movq 0x8(%rdx), %rax
testq %rax, %rax
leaq 0xce60(%rip), %rcx      # 0x20248
cmovneq %rax, %rcx
movq %rcx, -0x48(%rbp)
testq %r13, %r13
movq %rbx, %rax
je 0x13770
movq $0x0, -0x68(%rbp)
xorl %r12d, %r12d
movq %r13, -0x78(%rbp)
movq %rax, -0x60(%rbp)
movq $0x0, (%rax,%r12,8)
testq %r14, %r14
je 0x1360d
xorl %r13d, %r13d
movq (%rdx), %rax
testq %rax, %rax
je 0x134b3
cmpq %r13, (%rax)
jbe 0x134b3
movq 0x8(%rax), %rcx
movq 0x18(%rax), %rax
imulq %r13, %rax
movq (%rcx,%rax), %rax
testq %rax, %rax
je 0x134b3
movq (%rax), %rax
testq %rax, %rax
je 0x134b3
cmpq %r12, (%rax)
jbe 0x134b3
movq 0x8(%rax), %rcx
movq 0x18(%rax), %rax
imulq %r12, %rax
movq (%rcx,%rax), %r15
movq %r12, -0x38(%rbp)
movq %r13, -0x40(%rbp)
testq %r15, %r15
je 0x134bb
movl 0x8(%r15), %eax
cmpl $0x1, %eax
je 0x13532
testl %eax, %eax
jne 0x1353b
movq -0x60(%rbp), %rbx
movq (%rbx,%r12,8), %rax
movq %rax, -0x70(%rbp)
movq %r15, %rdi
leaq -0x48(%rbp), %rsi
callq 0x13f38
cmpq %rax, -0x70(%rbp)
jbe 0x13541
movq (%rbx,%r12,8), %rax
jmp 0x1354d
movq %r12, -0x38(%rbp)
movq %r13, -0x40(%rbp)
movq -0x48(%rbp), %rdi
movq %r13, %rsi
movq %r12, %rdx
movl $0x40, %ecx
callq 0x140c5
testl %eax, %eax
je 0x13520
movslq %eax, %rbx
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
movl $0x4, %ecx
callq 0x140c5
movslq %eax, %r15
addq %rbx, %r15
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
movl $0x8, %ecx
callq 0x140c5
cltq
addq %r15, %rax
movq -0x30(%rbp), %rdx
movq (%rdx,%r13,8), %rcx
cmpq %rax, %rcx
cmovaq %rcx, %rax
movq %rax, (%rdx,%r13,8)
movq -0x50(%rbp), %rdx
incq %r13
cmpq %r13, %r14
jne 0x13423
jmp 0x13592
movl $0x1, %eax
movq %rax, -0x68(%rbp)
movq -0x30(%rbp), %rcx
jmp 0x13555
movq %r15, %rdi
leaq -0x48(%rbp), %rsi
callq 0x13f38
movq -0x30(%rbp), %rcx
movq %rax, (%rbx,%r12,8)
leaq -0x48(%rbp), %rsi
movq (%rcx,%r13,8), %rbx
movq %r15, %rdi
callq 0x14008
cmpq %rax, %rbx
jbe 0x13578
movq -0x30(%rbp), %rcx
movq (%rcx,%r13,8), %rax
movq -0x50(%rbp), %rdx
jmp 0x1358c
movq %r15, %rdi
leaq -0x48(%rbp), %rsi
callq 0x14008
movq -0x50(%rbp), %rdx
movq -0x30(%rbp), %rcx
movq %rax, (%rcx,%r13,8)
jmp 0x13524
cmpl $0x1, -0x54(%rbp)
movq -0x78(%rbp), %r13
jne 0x1361b
xorl %ebx, %ebx
xorl %r15d, %r15d
movq (%rdx), %rax
testq %rax, %rax
je 0x135ff
cmpq %r15, (%rax)
jbe 0x135ff
movq 0x8(%rax), %rcx
movq 0x18(%rax), %rax
imulq %r15, %rax
movq (%rcx,%rax), %rax
testq %rax, %rax
je 0x135ff
movq (%rax), %rax
testq %rax, %rax
je 0x135ff
cmpq %r12, (%rax)
jbe 0x135ff
movq 0x8(%rax), %rcx
movq 0x18(%rax), %rax
imulq %r12, %rax
cmpq $0x0, (%rcx,%rax)
je 0x135ff
movq %r12, -0x38(%rbp)
movq %r15, -0x40(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x1426a
movq -0x50(%rbp), %rdx
cmpq %rax, %rbx
cmovbeq %rax, %rbx
incq %r15
cmpq %r15, %r14
jne 0x135a1
movq -0x60(%rbp), %rax
jmp 0x13615
cmpl $0x1, -0x54(%rbp)
jne 0x1361f
xorl %ebx, %ebx
addq %rbx, (%rax,%r12,8)
jmp 0x1361f
movq -0x60(%rbp), %rax
incq %r12
cmpq %r13, %r12
jne 0x1340f
cmpl $0x0, -0x68(%rbp)
je 0x13770
xorl %r12d, %r12d
testq %r14, %r14
je 0x13761
leaq 0x1(%r12), %r8
leaq (%rax,%r12,8), %r9
xorl %ebx, %ebx
movq (%rdx), %rax
testq %rax, %rax
je 0x13715
cmpq %rbx, (%rax)
jbe 0x13715
movq 0x8(%rax), %rcx
movq 0x18(%rax), %rax
imulq %rbx, %rax
movq (%rcx,%rax), %r15
testq %r15, %r15
je 0x13715
movq (%r15), %rax
testq %rax, %rax
je 0x13715
cmpq %r12, (%rax)
jbe 0x13715
movq 0x8(%rax), %rcx
movq 0x18(%rax), %rax
imulq %r12, %rax
movq (%rcx,%rax), %rdi
movq %r12, -0x38(%rbp)
movq %rbx, -0x40(%rbp)
testq %rdi, %rdi
je 0x1371d
cmpl $0x1, 0x8(%rdi)
jne 0x1371d
movq %r9, -0x68(%rbp)
movq %r8, -0x70(%rbp)
leaq -0x48(%rbp), %rsi
callq 0x13f38
movq %rax, %r13
cmpl $0x1, -0x54(%rbp)
jne 0x136d8
leaq -0x48(%rbp), %rdi
callq 0x1426a
addq %rax, %r13
movq %r15, %rdi
movq %r12, %rsi
callq 0x14355
leaq (%rax,%r12), %rcx
movq -0x60(%rbp), %rdx
movq (%rdx,%r12,8), %rdx
movq -0x70(%rbp), %r8
cmpq %rcx, %r8
jae 0x1372b
movl $0x1, %esi
movq -0x68(%rbp), %r9
movq (%r9,%rsi,8), %rdi
addq %rdi, %rdx
incq %rdx
incq %rsi
cmpq %rsi, %rax
jne 0x13701
jmp 0x1372f
movq %r12, -0x38(%rbp)
movq %rbx, -0x40(%rbp)
incq %rbx
cmpq %r14, %rbx
jne 0x1364c
jmp 0x13754
movq -0x68(%rbp), %r9
subq %rdx, %r13
movq -0x50(%rbp), %rdx
jbe 0x1371d
movq %r12, %rax
movq -0x60(%rbp), %rsi
incq (%rsi,%rax,8)
incq %rax
cmpq %rcx, %rax
cmoveq %r12, %rax
decq %r13
jne 0x1373b
jmp 0x1371d
movq %r8, %r12
movq -0x78(%rbp), %r13
movq -0x60(%rbp), %rax
jmp 0x13767
incq %r12
movq %r12, %r8
cmpq %r13, %r8
jne 0x13638
movq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, (%rax)
movq -0x80(%rbp), %rax
movq %r13, (%rax)
movq -0x90(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rcx, (%rax)
movq -0x98(%rbp), %rax
movq %r14, (%rax)
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq