// File: /workspace/github_c_makefile_star2_O3/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 0xff6d
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)
xorl %edx, %edx
callq *0x507de(%rip)          # 0x60328
movq %r15, %rdi
callq 0x6af7
movq %rax, %r12
movq %r15, %rdi
callq 0x66b6
movq %rax, %rbx
movq %r15, %rdi
callq 0x69eb
movq %rbx, 0x70(%rsp)
movzwl 0x16(%rbx), %ecx
addw 0x22(%r15), %cx
movb %al, 0x27(%rsp)
movw %cx, 0x2e(%rsp)
cmpw $0x0, 0x2(%r12)
je 0xff58
xorl %ebx, %ebx
xorl %eax, %eax
movq %r15, 0x68(%rsp)
movl %eax, 0x60(%rsp)
movzwl %ax, %esi
movq %r15, %rdi
callq 0x10941
movzwl 0x2e(%rsp), %ecx
leal 0x1(%rcx), %edx
movw %dx, 0x2a(%rsp)
addl %eax, %ecx
movw %cx, 0x2e(%rsp)
movq 0x70(%rsp), %rcx
movzwl 0x1a(%rcx), %ecx
addw 0x20(%r15), %cx
movw %cx, 0x2c(%rsp)
cmpw $0x0, (%r12)
je 0xff41
movzwl %ax, %ecx
shrl $0xf, %ecx
addl %eax, %ecx
movswl %cx, %eax
shrl %eax
movl %eax, 0x64(%rsp)
movq 0x8(%r12), %rax
xorl %r13d, %r13d
xorl %r15d, %r15d
movzwl %bx, %ebx
movq (%rax,%rbx,8), %rax
testq %rax, %rax
je 0xfc04
movb (%rax), %bpl
jmp 0xfc07
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 0x799d
movl 0x2c(%rsp), %ecx
movl %ecx, %eax
incl %eax
movw %ax, 0x28(%rsp)
movzwl %r15w, %eax
movzwl 0x30(%r12,%rax,2), %eax
addw %cx, %ax
movw %ax, 0x2c(%rsp)
movzwl (%r12), %ecx
decl %ecx
cmpl %ecx, %r13d
jge 0xfca9
movq 0x8(%r12), %rdx
movq (%rdx,%rbx,8), %rdi
testq %rdi, %rdi
je 0xfca9
xorl %esi, %esi
movl %r13d, %r8d
movl %esi, %r9d
movb (%rdi), %bpl
testb $0x4, %bpl
je 0xff32
movl %r8d, %esi
addw 0x32(%r12,%rsi,2), %ax
movw %ax, 0x2c(%rsp)
leal 0x1(%r9), %esi
movzwl %si, %edi
leal (%rdi,%r13), %r8d
cmpl %ecx, %r8d
jge 0xfc9a
addl %ebx, %edi
movq (%rdx,%rdi,8), %rdi
testq %rdi, %rdi
jne 0xfc61
movl %r8d, 0x30(%rsp)
incl %r9d
movq %r9, 0x50(%rsp)
jmp 0xfcb7
movq $0x0, 0x50(%rsp)
movl %r13d, 0x30(%rsp)
movzbl 0x27(%rsp), %ecx
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
leaq 0x80(%rsp), %rdx
movl %ecx, 0x44(%rsp)
callq 0x36968
movq 0x8(%r12), %rax
movq (%rax,%rbx,8), %rsi
testq %rsi, %rsi
je 0xff10
movq %r14, %r13
movq 0x28(%rsp), %xmm0
movq 0x96(%rsp), %xmm1
pshuflw $0x72, %xmm1, %xmm1     # xmm1 = xmm1[2,0,3,1,4,5,6,7]
movdqa %xmm0, %xmm2
paddw %xmm1, %xmm2
psubw %xmm1, %xmm0
pshufd $0x55, %xmm0, %xmm0     # xmm0 = xmm0[1,1,1,1]
movdqa %xmm2, %xmm1
punpckldq %xmm0, %xmm1    # xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
movq %xmm1, 0x38(%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
psubw %xmm2, %xmm0
movd %xmm0, %eax
incl %eax
movzbl %r14b, %edi
movl %edi, (%rsp)
movswl %ax, %r9d
leaq 0x34(%rsp), %rdi
callq 0x2acd4
testb %r15b, %r15b
jne 0xfd96
movzwl 0x2a(%rsp), %eax
addw 0x64(%rsp), %ax
movzwl 0x36(%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 0x2f88b(%rip), %rcx     # 0x3f630
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
orb $0x4, %r14b
jmp 0xfdb8
orb $0x8, %r14b
leaq 0x78(%rsp), %rdi
movq %r13, %rsi
leaq 0x28(%rsp), %rdx
callq 0x28d24
movzbl %r14b, %ebp
testb %al, %al
je 0xfe22
movq 0x8(%r12), %rax
movq (%rax,%rbx,8), %r14
incq %r14
movq 0x68(%rsp), %rdi
callq 0x4ab2
movzbl %al, %eax
movl %eax, 0x18(%rsp)
pxor %xmm0, %xmm0
movdqu %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 0x3a5ac
movzwl 0x28(%rsp), %eax
movzwl 0x2c(%rsp), %ecx
movw %ax, 0x4c(%rsp)
movw %cx, 0x48(%rsp)
movw $0x1, %r14w
movq 0x8(%r12), %rax
movq (%rax,%rbx,8), %rcx
movzwl %r14w, %r14d
movzbl (%rcx,%r14), %edx
cmpl $0xa, %edx
je 0xfe5f
testl %edx, %edx
jne 0xff05
jmp 0xff0d
movb $0x0, (%rcx,%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 0x34(%rsp), %rdi
callq 0x2acd4
movzwl 0x36(%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 0x3ad34
movq 0x8(%r12), %rax
movq (%rax,%r15), %rax
movb $0xa, (%rax,%r14)
incl %r14d
jmp 0xfe3b
movq %r13, %r14
movq 0x50(%rsp), %rcx
addl %ecx, %ebx
incl %ebx
movl 0x30(%rsp), %r15d
incl %r15d
movzwl %r15w, %r13d
cmpw (%r12), %r13w
jb 0xfbf3
jmp 0xff41
movq %r9, 0x50(%rsp)
movl %r8d, 0x30(%rsp)
jmp 0xfcb7
movl 0x60(%rsp), %eax
incl %eax
cmpw 0x2(%r12), %ax
movq 0x68(%rsp), %r15
jb 0xfb95
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