// File: /workspace/github_c_makefile_star2_O1/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_table.c
// Function: lv_table_design
static bool lv_table_design(lv_obj_t * table, const lv_area_t * mask, lv_design_mode_t mode)
{
    /*Return false if the object is not covers the mask_p area*/
    if(mode == LV_DESIGN_COVER_CHK) {
        return false;
    }
    /*Draw the object*/
    else if(mode == LV_DESIGN_DRAW_MAIN) {
        ancestor_scrl_design(table, mask, mode);

        lv_table_ext_t * ext        = lv_obj_get_ext_attr(table);
        const lv_style_t * bg_style = lv_obj_get_style(table);
        lv_coord_t h_row;
        lv_point_t txt_size;
        lv_area_t cell_area;
        lv_area_t txt_area;
        lv_txt_flag_t txt_flags;
        lv_opa_t opa_scale = lv_obj_get_opa_scale(table);

        uint16_t col;
        uint16_t row;
        uint16_t cell = 0;

        cell_area.y2 = table->coords.y1 + bg_style->body.padding.top;
        for(row = 0; row < ext->row_cnt; row++) {
            h_row = get_row_height(table, row);

            cell_area.y1 = cell_area.y2 + 1;
            cell_area.y2 = cell_area.y1 + h_row - 1;

            cell_area.x2 = table->coords.x1 + bg_style->body.padding.left;

            for(col = 0; col < ext->col_cnt; col++) {

                lv_table_cell_format_t format;
                if(ext->cell_data[cell]) {
                    format.format_byte = ext->cell_data[cell][0];
                } else {
                    format.s.right_merge = 0;
                    format.s.align       = LV_LABEL_ALIGN_LEFT;
                    format.s.type        = 0;
                    format.s.crop        = 1;
                }


                lv_style_t cell_style;
                lv_style_copy(&cell_style, ext->cell_style[format.s.type]);
                cell_area.x1 = cell_area.x2 + 1;
                cell_area.x2 = cell_area.x1 + ext->col_w[col] - 1;

                uint16_t col_merge = 0;
                for(col_merge = 0; col_merge + col < ext->col_cnt - 1; col_merge++) {

                    if(ext->cell_data[cell + col_merge] != NULL) {
                        format.format_byte = ext->cell_data[cell + col_merge][0];
                        if(format.s.right_merge)
                            cell_area.x2 += ext->col_w[col + col_merge + 1];
                        else
                            break;
                    } else {
                        break;
                    }
                }

                lv_draw_rect(&cell_area, mask, &cell_style, opa_scale);

                if(ext->cell_data[cell]) {

                    txt_area.x1 = cell_area.x1 + cell_style.body.padding.left;
                    txt_area.x2 = cell_area.x2 - cell_style.body.padding.right;
                    txt_area.y1 = cell_area.y1 + cell_style.body.padding.top;
                    txt_area.y2 = cell_area.y2 - cell_style.body.padding.bottom;
                    /*Align the content to the middle if not cropped*/
                    if(format.s.crop == 0) {
                        txt_flags = LV_TXT_FLAG_NONE;
                    } else {
                        txt_flags = LV_TXT_FLAG_EXPAND;
                    }

                    lv_txt_get_size(&txt_size, ext->cell_data[cell] + 1, cell_style.text.font,
                                    cell_style.text.letter_space, cell_style.text.line_space,
                                    lv_area_get_width(&txt_area), txt_flags);

                    /*Align the content to the middle if not cropped*/
                    if(format.s.crop == 0) {
                        txt_area.y1 = cell_area.y1 + h_row / 2 - txt_size.y / 2;
                        txt_area.y2 = cell_area.y1 + h_row / 2 + txt_size.y / 2;
                    }

                    switch(format.s.align) {
                        default:
                        case LV_LABEL_ALIGN_LEFT: txt_flags |= LV_TXT_FLAG_NONE; break;
                        case LV_LABEL_ALIGN_RIGHT: txt_flags |= LV_TXT_FLAG_RIGHT; break;
                        case LV_LABEL_ALIGN_CENTER: txt_flags |= LV_TXT_FLAG_CENTER; break;
                    }

                    lv_area_t label_mask;
                    bool label_mask_ok;
                    label_mask_ok = lv_area_intersect(&label_mask, mask, &cell_area);
                    if(label_mask_ok) {
                        lv_draw_label(&txt_area, &label_mask, &cell_style, opa_scale, ext->cell_data[cell] + 1,
                                      txt_flags, NULL, NULL, NULL, lv_obj_get_base_dir(table));
                    }
                    /*Draw lines after '\n's*/
                    lv_point_t p1;
                    lv_point_t p2;
                    p1.x = cell_area.x1;
                    p2.x = cell_area.x2;
                    uint16_t i;
                    for(i = 1; ext->cell_data[cell][i] != '\0'; i++) {
                        if(ext->cell_data[cell][i] == '\n') {
                            ext->cell_data[cell][i] = '\0';
                            lv_txt_get_size(&txt_size, ext->cell_data[cell] + 1, cell_style.text.font,
                                            cell_style.text.letter_space, cell_style.text.line_space,
                                            lv_area_get_width(&txt_area), txt_flags);

                            p1.y = txt_area.y1 + txt_size.y + cell_style.text.line_space / 2;
                            p2.y = txt_area.y1 + txt_size.y + cell_style.text.line_space / 2;
                            lv_draw_line(&p1, &p2, mask, &cell_style, opa_scale);

                            ext->cell_data[cell][i] = '\n';
                        }
                    }
                }

                cell += col_merge + 1;
                col += col_merge;
            }
        }
    }
    /*Post draw when the children are drawn*/
    else if(mode == LV_DESIGN_DRAW_POST) {
    }

    return true;
}

// Assembly:
testl %edx, %edx
jne 0xff69
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rsi, %r14
movq %rdi, %r15
movl %edx, 0x5c(%rsp)
movzbl %dl, %edx
callq *0x507fa(%rip)          # 0x60328
movq %r15, %rdi
callq 0x6ad8
movq %rax, %r12
movq %r15, %rdi
callq 0x6697
movq %rax, %rbx
movq %r15, %rdi
callq 0x69cc
movq %rbx, 0x70(%rsp)
movzwl 0x16(%rbx), %ecx
addw 0x22(%r15), %cx
movb %al, 0x33(%rsp)
movw %cx, 0x30(%rsp)
cmpw $0x0, 0x2(%r12)
je 0xff54
xorl %ebx, %ebx
xorl %eax, %eax
movq %r15, 0x68(%rsp)
movl %eax, 0x60(%rsp)
movzwl %ax, %esi
movq %r15, %rdi
callq 0x1090c
movzwl 0x30(%rsp), %ecx
leal 0x1(%rcx), %edx
movw %dx, 0x2c(%rsp)
addl %eax, %ecx
movw %cx, 0x30(%rsp)
movq 0x70(%rsp), %rcx
movzwl 0x1a(%rcx), %ecx
addw 0x20(%r15), %cx
movw %cx, 0x2e(%rsp)
cmpw $0x0, (%r12)
je 0xff3d
movzwl %ax, %ecx
shrl $0xf, %ecx
addl %eax, %ecx
movswl %cx, %eax
shrl %eax
movl %eax, 0x64(%rsp)
xorl %r13d, %r13d
xorl %r15d, %r15d
movq 0x8(%r12), %rax
movzwl %bx, %ebx
movq (%rax,%rbx,8), %rax
testq %rax, %rax
je 0xfbe8
movb (%rax), %bpl
jmp 0xfbeb
movb $0x20, %bpl
movl %ebp, %eax
shrb $0x3, %al
andb $0x3, %al
movzbl %al, %eax
movq 0x10(%r12,%rax,8), %rsi
leaq 0x80(%rsp), %rdi
callq 0x798d
movzwl 0x2e(%rsp), %eax
movl %eax, %ecx
incl %ecx
movw %cx, 0x2a(%rsp)
movzwl %r15w, %ecx
movzwl 0x30(%r12,%rcx,2), %ecx
addw %ax, %cx
movw %cx, 0x2e(%rsp)
movzwl (%r12), %eax
decl %eax
cmpl %eax, %r13d
jge 0xfc93
movq 0x8(%r12), %rcx
movq (%rcx,%rbx,8), %rdi
testq %rdi, %rdi
je 0xfc93
movzwl 0x2e(%rsp), %edx
xorl %esi, %esi
movl %r13d, %r8d
movl %esi, %r9d
movb (%rdi), %bpl
testb $0x4, %bpl
je 0xff2e
movl %r8d, %esi
addw 0x32(%r12,%rsi,2), %dx
movw %dx, 0x2e(%rsp)
leal 0x1(%r9), %esi
movzwl %si, %edi
leal (%rdi,%r13), %r8d
cmpl %eax, %r8d
jge 0xfc84
addl %ebx, %edi
movq (%rcx,%rdi,8), %rdi
testq %rdi, %rdi
jne 0xfc4b
movl %r8d, 0x34(%rsp)
incl %r9d
movq %r9, 0x50(%rsp)
jmp 0xfca1
movq $0x0, 0x50(%rsp)
movl %r13d, 0x34(%rsp)
movzbl 0x33(%rsp), %ecx
leaq 0x2a(%rsp), %rdi
movq %r14, %rsi
leaq 0x80(%rsp), %rdx
movl %ecx, 0x44(%rsp)
callq 0x365ac
movq 0x8(%r12), %rax
movq (%rax,%rbx,8), %rsi
testq %rsi, %rsi
je 0xff0c
movq %r14, %r13
movzwl 0x9a(%rsp), %eax
addw 0x2a(%rsp), %ax
movzwl 0x96(%rsp), %ecx
movw %ax, 0x38(%rsp)
movzwl 0x2e(%rsp), %edx
movzwl 0x30(%rsp), %edi
subw 0x9c(%rsp), %dx
movw %dx, 0x3c(%rsp)
movl %edx, %r9d
subl %eax, %r9d
addw 0x2c(%rsp), %cx
movw %cx, 0x3a(%rsp)
subw 0x98(%rsp), %di
movw %di, 0x3e(%rsp)
movl %ebp, %r15d
andb $0x20, %r15b
movl %r15d, %r14d
shrb $0x4, %r14b
incq %rsi
movq 0xa8(%rsp), %rdx
movswl 0xb0(%rsp), %ecx
movswl 0xb2(%rsp), %r8d
incl %r9d
movzbl %r14b, %eax
movl %eax, (%rsp)
movswl %r9w, %r9d
leaq 0x40(%rsp), %rdi
callq 0x2a643
testb %r15b, %r15b
jne 0xfd94
movzwl 0x2c(%rsp), %eax
addw 0x64(%rsp), %ax
movzwl 0x42(%rsp), %ecx
movl %ecx, %edx
shrl $0xf, %edx
addl %ecx, %edx
movswl %dx, %ecx
sarl %ecx
movl %eax, %edx
subl %ecx, %edx
movw %dx, 0x3a(%rsp)
addl %eax, %ecx
movw %cx, 0x3e(%rsp)
andb $0x3, %bpl
movzbl %bpl, %eax
leaq 0x2f771(%rip), %rcx     # 0x3f514
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
orb $0x4, %r14b
jmp 0xfdb6
orb $0x8, %r14b
leaq 0x78(%rsp), %rdi
movq %r13, %rsi
leaq 0x2a(%rsp), %rdx
callq 0x2865e
movzbl %r14b, %ebp
testb %al, %al
je 0xfe1e
movq 0x8(%r12), %rax
movq (%rax,%rbx,8), %r14
incq %r14
movq 0x68(%rsp), %rdi
callq 0x4abc
movzbl %al, %eax
movl %eax, 0x18(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
leaq 0x38(%rsp), %rdi
leaq 0x78(%rsp), %rsi
leaq 0x80(%rsp), %rdx
movl 0x44(%rsp), %ecx
movq %r14, %r8
movl %ebp, %r9d
callq 0x3a034
movzwl 0x2a(%rsp), %eax
movzwl 0x2e(%rsp), %ecx
movw %ax, 0x4c(%rsp)
movw %cx, 0x48(%rsp)
movw $0x1, %r14w
movq 0x8(%r12), %rax
movq (%rax,%rbx,8), %rax
movzwl %r14w, %r14d
movzbl (%rax,%r14), %ecx
cmpl $0xa, %ecx
je 0xfe5b
testl %ecx, %ecx
jne 0xff01
jmp 0xff09
movb $0x0, (%rax,%r14)
movq 0x8(%r12), %rax
leal (,%rbx,8), %r15d
movq (%rax,%r15), %rsi
incq %rsi
movq 0xa8(%rsp), %rdx
movswl 0xb0(%rsp), %ecx
movswl 0xb2(%rsp), %r8d
movzwl 0x3c(%rsp), %eax
subw 0x38(%rsp), %ax
incl %eax
movl %ebp, (%rsp)
movswl %ax, %r9d
leaq 0x40(%rsp), %rdi
callq 0x2a643
movzwl 0x42(%rsp), %eax
addw 0x3a(%rsp), %ax
movzwl 0xb2(%rsp), %ecx
movl %ecx, %edx
shrl $0xf, %edx
addl %ecx, %edx
movswl %dx, %ecx
sarl %ecx
addl %eax, %ecx
movw %cx, 0x4e(%rsp)
movw %cx, 0x4a(%rsp)
leaq 0x4c(%rsp), %rdi
leaq 0x48(%rsp), %rsi
movq %r13, %rdx
leaq 0x80(%rsp), %rcx
movl 0x44(%rsp), %r8d
callq 0x3a7b0
movq 0x8(%r12), %rax
movq (%rax,%r15), %rax
movb $0xa, (%rax,%r14)
incl %r14d
jmp 0xfe37
movq %r13, %r14
movq 0x50(%rsp), %rax
addl %eax, %ebx
incl %ebx
movl 0x34(%rsp), %r15d
incl %r15d
movzwl %r15w, %r13d
cmpw (%r12), %r13w
jb 0xfbd2
jmp 0xff3d
movq %r9, 0x50(%rsp)
movl %r8d, 0x34(%rsp)
jmp 0xfca1
movl 0x60(%rsp), %eax
incl %eax
cmpw 0x2(%r12), %ax
movq 0x68(%rsp), %r15
jb 0xfb79
movl 0x5c(%rsp), %edx
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
cmpb $0x2, %dl
setne %al
retq