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

        lv_btnm_ext_t * ext         = lv_obj_get_ext_attr(btnm);
        const lv_style_t * bg_style = lv_obj_get_style(btnm);
        const lv_style_t * btn_style;
        lv_opa_t opa_scale = lv_obj_get_opa_scale(btnm);

        lv_area_t area_btnm;
        lv_obj_get_coords(btnm, &area_btnm);

        lv_area_t area_tmp;
        lv_coord_t btn_w;
        lv_coord_t btn_h;

        uint16_t btn_i = 0;
        uint16_t txt_i = 0;
        lv_style_t style_tmp;
        lv_txt_flag_t txt_flag = LV_TXT_FLAG_NONE;

        if(ext->recolor) txt_flag = LV_TXT_FLAG_RECOLOR;
        for(btn_i = 0; btn_i < ext->btn_cnt; btn_i++, txt_i++) {
            /*Search the next valid text in the map*/
            while(strcmp(ext->map_p[txt_i], "\n") == 0) {
                txt_i++;
            }

            /*Skip hidden buttons*/
            if(button_is_hidden(ext->ctrl_bits[btn_i])) continue;

            lv_area_copy(&area_tmp, &ext->button_areas[btn_i]);
            area_tmp.x1 += area_btnm.x1;
            area_tmp.y1 += area_btnm.y1;
            area_tmp.x2 += area_btnm.x1;
            area_tmp.y2 += area_btnm.y1;

            btn_w = lv_area_get_width(&area_tmp);
            btn_h = lv_area_get_height(&area_tmp);

            /*Load the style*/
            bool tgl_state = button_get_tgl_state(ext->ctrl_bits[btn_i]);
            if(button_is_inactive(ext->ctrl_bits[btn_i]))
                btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_INA);
            else if(btn_i != ext->btn_id_pr && tgl_state == false)
                btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_REL);
            else if(btn_i == ext->btn_id_pr && tgl_state == false)
                btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_PR);
            else if(btn_i != ext->btn_id_pr && tgl_state == true)
                btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_TGL_REL);
            else if(btn_i == ext->btn_id_pr && tgl_state == true)
                btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_TGL_PR);
            else
                btn_style = lv_btnm_get_style(btnm, LV_BTNM_STYLE_BTN_REL); /*Not possible option, just to be sure*/

            lv_style_copy(&style_tmp, btn_style);

            /*Remove borders on the edges if `LV_BORDER_INTERNAL`*/
            if(style_tmp.body.border.part & LV_BORDER_INTERNAL) {
                if(area_tmp.y1 == btnm->coords.y1 + bg_style->body.padding.top) {
                    style_tmp.body.border.part &= ~LV_BORDER_TOP;
                }
                if(area_tmp.y2 == btnm->coords.y2 - bg_style->body.padding.bottom) {
                    style_tmp.body.border.part &= ~LV_BORDER_BOTTOM;
                }

                if(txt_i == 0) {
                    style_tmp.body.border.part &= ~LV_BORDER_LEFT;
                } else if(strcmp(ext->map_p[txt_i - 1], "\n") == 0) {
                    style_tmp.body.border.part &= ~LV_BORDER_LEFT;
                }

                if(ext->map_p[txt_i + 1][0] == '\0' || strcmp(ext->map_p[txt_i + 1], "\n") == 0) {
                    style_tmp.body.border.part &= ~LV_BORDER_RIGHT;
                }
            }
            lv_draw_rect(&area_tmp, mask, &style_tmp, opa_scale);

            /*Calculate the size of the text*/
            if(btn_style->glass) btn_style = bg_style;
            const lv_font_t * font = btn_style->text.font;
            lv_point_t txt_size;
            lv_txt_get_size(&txt_size, ext->map_p[txt_i], font, btn_style->text.letter_space,
                            btn_style->text.line_space, lv_area_get_width(&area_btnm), txt_flag);

            area_tmp.x1 += (btn_w - txt_size.x) / 2;
            area_tmp.y1 += (btn_h - txt_size.y) / 2;
            area_tmp.x2 = area_tmp.x1 + txt_size.x;
            area_tmp.y2 = area_tmp.y1 + txt_size.y;

            lv_draw_label(&area_tmp, mask, btn_style, opa_scale, ext->map_p[txt_i], txt_flag, NULL, NULL, NULL, lv_obj_get_base_dir(btnm));
        }
    }

    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xc8, %rsp
movq %rsi, 0x40(%rsp)
movq %rdi, 0x30(%rsp)
testl %edx, %edx
je 0x21bd4
cmpl $0x2, %edx
jne 0x21f1f
movq 0x3e876(%rip), %rax     # 0x60428
movq 0x30(%rsp), %rdi
movq 0x40(%rsp), %rsi
movl $0x2, %edx
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
movq 0x30(%rsp), %rbx
movq %rbx, %rdi
movq 0x40(%rsp), %rsi
xorl %edx, %edx
callq *0x3e83f(%rip)          # 0x60428
movq %rbx, %rdi
callq 0x6af7
movq %rax, %r13
movq %rbx, %rdi
callq 0x66b6
movq %rax, %rbp
movq %rbx, %rdi
callq 0x69eb
movb %al, 0x27(%rsp)
leaq 0x48(%rsp), %rsi
movq %rbx, %rdi
callq 0x542b
movzwl 0x40(%r13), %eax
testw %ax, %ax
je 0x21f1f
movb 0x46(%r13), %cl
andb $0x1, %cl
movb %cl, 0x26(%rsp)
xorl %r14d, %r14d
xorl %r15d, %r15d
movq %r13, 0x50(%rsp)
movq %rbp, 0x68(%rsp)
movq (%r13), %rcx
movzwl %r15w, %ebx
movq (%rcx,%rbx,8), %rdx
cmpb $0xa, (%rdx)
jne 0x21c5e
leal 0x1(%rbx), %r15d
cmpb $0x0, 0x1(%rdx)
je 0x21c45
jmp 0x21c62
leal 0x1(%rbx), %r15d
movq 0x10(%r13), %rcx
testb $0x8, (%rcx,%r14,2)
jne 0x21f10
movq 0x8(%r13), %rax
movq (%rax,%r14,8), %rdi
movzwl 0x48(%rsp), %eax
leal (%rax,%rdi), %edx
movw %dx, 0x28(%rsp)
movzwl 0x4a(%rsp), %edx
movl %edi, %esi
shrl $0x10, %esi
movq %rsi, 0x78(%rsp)
addl %edx, %esi
movw %si, 0x2a(%rsp)
movq %rdi, %r12
shrq $0x20, %r12
addl %r12d, %eax
movw %ax, 0x2c(%rsp)
movq %rdi, 0x58(%rsp)
movq %rdi, %rax
shrq $0x30, %rax
movq %rax, 0x60(%rsp)
addl %eax, %edx
movw %dx, 0x2e(%rsp)
movzwl (%rcx,%r14,2), %eax
movb $0x5, %cl
testb $0x20, %al
jne 0x21d20
testb %al, %al
setns %sil
movzwl 0x42(%r13), %edx
cmpq %rdx, %r14
setne %dil
movb $0x1, %cl
testb %dil, %sil
jne 0x21d20
cmpq %rdx, %r14
setne %sil
testb %al, %al
js 0x21cf9
movb $0x2, %cl
testb %sil, %sil
je 0x21d20
testb %al, %al
setns %al
cmpq %rdx, %r14
je 0x21d09
movb $0x3, %cl
testb %al, %al
je 0x21d20
xorl %ecx, %ecx
testb %sil, %sil
sete %cl
leal (%rcx,%rcx,2), %ecx
incl %ecx
testb %al, %al
movl $0x1, %eax
cmovnel %eax, %ecx
movzbl %cl, %esi
movq 0x30(%rsp), %rdi
callq 0x2248e
movq %rax, %r13
leaq 0x80(%rsp), %rdi
movq %rax, %rsi
callq 0x799d
movb 0x8e(%rsp), %al
testb $0x10, %al
je 0x21dea
movswl 0x2a(%rsp), %ecx
movq 0x30(%rsp), %rdx
movswl 0x22(%rdx), %edx
movswl 0x16(%rbp), %esi
addl %edx, %esi
cmpl %ecx, %esi
jne 0x21d70
andb $-0x3, %al
movb %al, 0x8e(%rsp)
movswl 0x2e(%rsp), %ecx
movq 0x30(%rsp), %rdx
movswl 0x26(%rdx), %edx
movswl 0x18(%rbp), %esi
subl %esi, %edx
cmpl %ecx, %edx
jne 0x21d91
andb $-0x2, %al
movb %al, 0x8e(%rsp)
testq %rbx, %rbx
je 0x21db9
movq 0x50(%rsp), %rcx
movq (%rcx), %rcx
movq -0x8(%rcx,%rbx,8), %rdx
cmpb $0xa, (%rdx)
jne 0x21dca
cmpb $0x0, 0x1(%rdx)
jne 0x21dca
andb $-0x5, %al
movb %al, 0x8e(%rsp)
jmp 0x21dca
andb $-0x5, %al
movb %al, 0x8e(%rsp)
movq 0x50(%rsp), %rcx
movq (%rcx), %rcx
movq 0x8(%rcx,%rbx,8), %rcx
movzbl (%rcx), %edx
testl %edx, %edx
je 0x21de1
cmpl $0xa, %edx
jne 0x21dea
cmpb $0x0, 0x1(%rcx)
jne 0x21dea
andb $-0x9, %al
movb %al, 0x8e(%rsp)
subl 0x58(%rsp), %r12d
incl %r12d
movq %r12, 0x70(%rsp)
movq 0x60(%rsp), %r12
subl 0x78(%rsp), %r12d
incl %r12d
movzbl 0x27(%rsp), %ecx
movl %ecx, 0x60(%rsp)
leaq 0x28(%rsp), %rdi
movq 0x40(%rsp), %rsi
leaq 0x80(%rsp), %rdx
callq 0x36968
testb $0x1, (%r13)
cmovneq %rbp, %r13
movq 0x28(%r13), %rdx
movq 0x50(%rsp), %rbp
movq (%rbp), %rax
shll $0x3, %ebx
movq (%rax,%rbx), %rsi
movswl 0x30(%r13), %ecx
movswl 0x32(%r13), %r8d
movzwl 0x4c(%rsp), %eax
subw 0x48(%rsp), %ax
incl %eax
movzbl 0x26(%rsp), %edi
movl %edi, 0x58(%rsp)
movl %edi, (%rsp)
movswl %ax, %r9d
leaq 0x3c(%rsp), %rdi
callq 0x2acd4
movswl 0x70(%rsp), %ecx
movswl 0x3c(%rsp), %eax
subl %eax, %ecx
movl %ecx, %edx
shrl $0x1f, %edx
addl %ecx, %edx
shrl %edx
addw 0x28(%rsp), %dx
movw %dx, 0x28(%rsp)
movswl %r12w, %ecx
movswl 0x3e(%rsp), %esi
subl %esi, %ecx
movl %ecx, %edi
shrl $0x1f, %edi
addl %ecx, %edi
shrl %edi
addw 0x2a(%rsp), %di
movw %di, 0x2a(%rsp)
addl %edx, %eax
movw %ax, 0x2c(%rsp)
addl %edi, %esi
movw %si, 0x2e(%rsp)
movq (%rbp), %rax
movq (%rax,%rbx), %rbx
movq 0x30(%rsp), %rdi
callq 0x4ab2
movzbl %al, %eax
movl %eax, 0x18(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
leaq 0x28(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq %r13, %rdx
movq %rbp, %r13
movq 0x68(%rsp), %rbp
movl 0x60(%rsp), %ecx
movq %rbx, %r8
movl 0x58(%rsp), %r9d
callq 0x3a5ac
movzwl 0x40(%r13), %eax
incq %r14
movzwl %ax, %ecx
cmpq %rcx, %r14
jb 0x21c41
movb $0x1, %al
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq