// File: /workspace/github_c_makefile_star2_O1/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, 0x48(%rsp)
movq %rdi, 0x38(%rsp)
testl %edx, %edx
je 0x213b9
cmpl $0x2, %edx
jne 0x216fc
movq 0x3f08f(%rip), %rax     # 0x60428
movzbl %dl, %edx
movq 0x38(%rsp), %rdi
movq 0x48(%rsp), %rsi
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
movzbl %dl, %edx
movq 0x38(%rsp), %rbx
movq %rbx, %rdi
movq 0x48(%rsp), %rsi
callq *0x3f059(%rip)          # 0x60428
movq %rbx, %rdi
callq 0x6ad8
movq %rax, %rbp
movq %rbx, %rdi
callq 0x6697
movq %rax, 0x60(%rsp)
movq %rbx, %rdi
callq 0x69cc
movb %al, 0x2f(%rsp)
leaq 0x58(%rsp), %rsi
movq %rbx, %rdi
callq 0x5427
cmpw $0x0, 0x40(%rbp)
je 0x216fc
movb 0x46(%rbp), %al
andb $0x1, %al
movb %al, 0x2e(%rsp)
xorl %r12d, %r12d
leaq 0x21fae(%rip), %r13     # 0x433cc
xorl %r15d, %r15d
movq %rbp, 0x50(%rsp)
movq (%rbp), %rbx
movzwl %r15w, %r14d
movq (%rbx,%r14,8), %rdi
movq %r13, %rsi
callq 0x20e0
incl %r15d
testl %eax, %eax
je 0x2142a
movq 0x10(%rbp), %rax
testb $0x8, (%rax,%r12,2)
jne 0x216ec
movq 0x8(%rbp), %rcx
movq (%rcx,%r12,8), %rsi
movq %rsi, 0x20(%rsp)
movzwl 0x58(%rsp), %ecx
movq %rsi, 0x70(%rsp)
leal (%rsi,%rcx), %edx
movw %dx, 0x20(%rsp)
movzwl 0x5a(%rsp), %edx
movzwl 0x22(%rsp), %esi
movq %rsi, 0x68(%rsp)
addl %edx, %esi
movw %si, 0x22(%rsp)
movl 0x24(%rsp), %esi
movl %esi, 0x30(%rsp)
addl %esi, %ecx
movw %cx, 0x24(%rsp)
movzwl 0x26(%rsp), %ecx
movl %ecx, 0x34(%rsp)
addl %ecx, %edx
movw %dx, 0x26(%rsp)
movzwl (%rax,%r12,2), %eax
movb $0x5, %cl
testb $0x20, %al
jne 0x21500
testb %al, %al
setns %sil
movzwl 0x42(%rbp), %edx
cmpq %rdx, %r12
setne %dil
movb $0x1, %cl
testb %dil, %sil
jne 0x21500
cmpq %rdx, %r12
setne %sil
testb %al, %al
js 0x214d9
movb $0x2, %cl
testb %sil, %sil
je 0x21500
testb %al, %al
setns %al
cmpq %rdx, %r12
je 0x214e9
movb $0x3, %cl
testb %al, %al
je 0x21500
xorl %ecx, %ecx
testb %sil, %sil
sete %cl
leal (%rcx,%rcx,2), %ecx
incl %ecx
testb %al, %al
movl $0x1, %eax
cmovnel %eax, %ecx
movq %r12, 0x78(%rsp)
movzbl %cl, %esi
movq 0x38(%rsp), %rdi
callq 0x21ccf
leaq 0x80(%rsp), %rdi
movq %rax, %r12
movq %rax, %rsi
callq 0x798d
movb 0x8e(%rsp), %al
testb $0x10, %al
je 0x215cd
movswl 0x22(%rsp), %ecx
movq 0x38(%rsp), %rdx
movswl 0x22(%rdx), %edx
movq 0x60(%rsp), %rsi
movswl 0x16(%rsi), %esi
addl %edx, %esi
cmpl %ecx, %esi
jne 0x2155a
andb $-0x3, %al
movb %al, 0x8e(%rsp)
movswl 0x26(%rsp), %eax
movq 0x38(%rsp), %rcx
movswl 0x26(%rcx), %ecx
movq 0x60(%rsp), %rdx
movswl 0x18(%rdx), %edx
subl %edx, %ecx
cmpl %eax, %ecx
jne 0x2157f
andb $-0x2, 0x8e(%rsp)
cmpw $0x1, %r15w
je 0x2159f
movq 0x50(%rsp), %rax
movq (%rax), %rax
movq -0x8(%rax,%r14,8), %rdi
movq %r13, %rsi
callq 0x20e0
testl %eax, %eax
jne 0x215a7
andb $-0x5, 0x8e(%rsp)
movq 0x50(%rsp), %rax
movq (%rax), %rax
movq 0x8(%rax,%r14,8), %rdi
cmpb $0x0, (%rdi)
je 0x215c5
movq %r13, %rsi
callq 0x20e0
testl %eax, %eax
jne 0x215cd
andb $-0x9, 0x8e(%rsp)
movl 0x30(%rsp), %ebx
subl 0x70(%rsp), %ebx
incl %ebx
movl 0x34(%rsp), %ebp
subl 0x68(%rsp), %ebp
incl %ebp
movzbl 0x2f(%rsp), %ecx
movl %ecx, 0x34(%rsp)
leaq 0x20(%rsp), %rdi
movq 0x48(%rsp), %rsi
leaq 0x80(%rsp), %rdx
callq 0x365ac
testb $0x1, (%r12)
cmovneq 0x60(%rsp), %r12
movq 0x28(%r12), %rdx
movq 0x50(%rsp), %rax
movq (%rax), %rax
shll $0x3, %r14d
movq (%rax,%r14), %rsi
movswl 0x30(%r12), %ecx
movswl 0x32(%r12), %r8d
movzwl 0x5c(%rsp), %eax
subw 0x58(%rsp), %ax
incl %eax
movzbl 0x2e(%rsp), %edi
movl %edi, 0x30(%rsp)
movl %edi, (%rsp)
movswl %ax, %r9d
leaq 0x44(%rsp), %rdi
callq 0x2a643
movswl %bx, %ecx
movswl 0x44(%rsp), %eax
subl %eax, %ecx
movl %ecx, %edx
shrl $0x1f, %edx
addl %ecx, %edx
shrl %edx
addw 0x20(%rsp), %dx
movw %dx, 0x20(%rsp)
movswl %bp, %ecx
movswl 0x46(%rsp), %esi
subl %esi, %ecx
movl %ecx, %edi
shrl $0x1f, %edi
addl %ecx, %edi
shrl %edi
addw 0x22(%rsp), %di
movw %di, 0x22(%rsp)
addl %edx, %eax
movw %ax, 0x24(%rsp)
addl %edi, %esi
movw %si, 0x26(%rsp)
movq 0x50(%rsp), %rbp
movq (%rbp), %rax
movq (%rax,%r14), %r14
movq 0x38(%rsp), %rdi
callq 0x4abc
movzbl %al, %eax
movl %eax, 0x18(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
leaq 0x20(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq %r12, %rdx
movl 0x34(%rsp), %ecx
movq %r14, %r8
movl 0x30(%rsp), %r9d
callq 0x3a034
movq 0x78(%rsp), %r12
incq %r12
movzwl 0x40(%rbp), %eax
cmpq %rax, %r12
jb 0x21426
movb $0x1, %al
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq