// File: /workspace/github_c_makefile_star2_O2/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, 0x50(%rsp)
movq %rdi, 0x38(%rsp)
testl %edx, %edx
je 0x1fb15
cmpl $0x2, %edx
jne 0x1fe3f
movq 0x3e933(%rip), %rax     # 0x5e428
pushq $0x2
popq %rdx
movq 0x38(%rsp), %rdi
movq 0x50(%rsp), %rsi
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmpq *%rax
xorl %r13d, %r13d
movq 0x38(%rsp), %rbx
movq %rbx, %rdi
movq 0x50(%rsp), %rsi
xorl %edx, %edx
callq *0x3e8fb(%rip)          # 0x5e428
movq %rbx, %rdi
callq 0x6747
movq %rax, %r14
movq %rbx, %rdi
callq 0x6316
movq %rax, 0x68(%rsp)
movq %rbx, %rdi
callq 0x6649
movb %al, 0x2f(%rsp)
leaq 0x58(%rsp), %rsi
movq %rbx, %rdi
callq 0x50e5
movb 0x46(%r14), %al
andb $0x1, %al
movb %al, 0x2e(%rsp)
xorl %r15d, %r15d
movq %r14, 0x48(%rsp)
movzwl 0x40(%r14), %eax
cmpq %rax, %r13
jae 0x1fe3f
movq (%r14), %rax
movzwl %r15w, %ebx
movq (%rax,%rbx,8), %rcx
cmpb $0xa, (%rcx)
jne 0x1fb9a
leal 0x1(%rbx), %r15d
cmpb $0x0, 0x1(%rcx)
je 0x1fb81
jmp 0x1fb9e
leal 0x1(%rbx), %r15d
movq 0x10(%r14), %rax
testb $0x8, (%rax,%r13,2)
jne 0x1fe37
movq 0x8(%r14), %rcx
movq (%rcx,%r13,8), %r14
movzwl 0x58(%rsp), %ecx
leal (%rcx,%r14), %edx
movw %dx, 0x30(%rsp)
movzwl 0x5a(%rsp), %edx
movl %r14d, %esi
shrl $0x10, %esi
movq %rsi, 0x60(%rsp)
addl %edx, %esi
movw %si, 0x32(%rsp)
movq %r14, %rbp
shrq $0x20, %rbp
addl %ebp, %ecx
movw %cx, 0x34(%rsp)
movq %r14, %r12
shrq $0x30, %r12
addl %r12d, %edx
movw %dx, 0x36(%rsp)
movzwl (%rax,%r13,2), %eax
movb $0x5, %cl
testb $0x20, %al
jne 0x1fc56
testb %al, %al
setns %sil
movq 0x48(%rsp), %rcx
movzwl 0x42(%rcx), %edx
cmpq %rdx, %r13
setne %dil
movb $0x1, %cl
testb %dil, %sil
jne 0x1fc56
cmpq %rdx, %r13
setne %sil
testb %al, %al
js 0x1fc31
movb $0x2, %cl
testb %sil, %sil
je 0x1fc56
testb %al, %al
setns %al
cmpq %rdx, %r13
je 0x1fc41
movb $0x3, %cl
testb %al, %al
je 0x1fc56
xorl %ecx, %ecx
testb %sil, %sil
sete %cl
leal (%rcx,%rcx,2), %ecx
incl %ecx
testb %al, %al
pushq $0x1
popq %rax
cmovnel %eax, %ecx
movq %r13, 0x78(%rsp)
movzbl %cl, %esi
movq 0x38(%rsp), %rdi
callq 0x20368
movq %rax, %r13
leaq 0x80(%rsp), %rdi
movq %rax, %rsi
callq 0x74d4
movb 0x8e(%rsp), %al
testb $0x10, %al
je 0x1fd2f
movswl 0x32(%rsp), %ecx
movq 0x38(%rsp), %rdx
movswl 0x22(%rdx), %edx
movq 0x68(%rsp), %rsi
movswl 0x16(%rsi), %esi
addl %edx, %esi
cmpl %ecx, %esi
jne 0x1fcb0
andb $-0x3, %al
movb %al, 0x8e(%rsp)
movswl 0x36(%rsp), %ecx
movq 0x38(%rsp), %rdx
movswl 0x26(%rdx), %edx
movq 0x68(%rsp), %rsi
movswl 0x18(%rsi), %esi
subl %esi, %edx
cmpl %ecx, %edx
jne 0x1fcd6
andb $-0x2, %al
movb %al, 0x8e(%rsp)
testq %rbx, %rbx
je 0x1fcfe
movq 0x48(%rsp), %rcx
movq (%rcx), %rcx
movq -0x8(%rcx,%rbx,8), %rdx
cmpb $0xa, (%rdx)
jne 0x1fd0f
cmpb $0x0, 0x1(%rdx)
jne 0x1fd0f
andb $-0x5, %al
movb %al, 0x8e(%rsp)
jmp 0x1fd0f
andb $-0x5, %al
movb %al, 0x8e(%rsp)
movq 0x48(%rsp), %rcx
movq (%rcx), %rcx
movq 0x8(%rcx,%rbx,8), %rcx
movzbl (%rcx), %edx
testl %edx, %edx
je 0x1fd26
cmpl $0xa, %edx
jne 0x1fd2f
cmpb $0x0, 0x1(%rcx)
jne 0x1fd2f
andb $-0x9, %al
movb %al, 0x8e(%rsp)
subl %r14d, %ebp
incl %ebp
subl 0x60(%rsp), %r12d
incl %r12d
movzbl 0x2f(%rsp), %ecx
movl %ecx, 0x60(%rsp)
leaq 0x30(%rsp), %rdi
movq 0x50(%rsp), %rsi
leaq 0x80(%rsp), %rdx
callq 0x336d4
testb $0x1, (%r13)
cmovneq 0x68(%rsp), %r13
movq 0x28(%r13), %rdx
movq 0x48(%rsp), %r14
movq (%r14), %rax
shll $0x3, %ebx
movq (%rax,%rbx), %rsi
movswl 0x30(%r13), %ecx
movswl 0x32(%r13), %r8d
movzwl 0x5c(%rsp), %eax
subw 0x58(%rsp), %ax
incl %eax
movzbl 0x2e(%rsp), %edi
movl %edi, 0x74(%rsp)
movl %edi, (%rsp)
movswl %ax, %r9d
leaq 0x44(%rsp), %rdi
callq 0x28723
movswl %bp, %eax
movswl 0x44(%rsp), %esi
subl %esi, %eax
cltd
pushq $0x2
popq %r8
idivl %r8d
movl %eax, %ecx
addw 0x30(%rsp), %cx
movw %cx, 0x30(%rsp)
movswl %r12w, %eax
movswl 0x46(%rsp), %edi
subl %edi, %eax
cltd
idivl %r8d
addw 0x32(%rsp), %ax
movw %ax, 0x32(%rsp)
addl %ecx, %esi
movw %si, 0x34(%rsp)
addl %eax, %edi
movw %di, 0x36(%rsp)
movq (%r14), %rax
movq (%rax,%rbx), %rbx
movq 0x38(%rsp), %rdi
callq 0x47b9
movzbl %al, %eax
movl %eax, 0x18(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
andq $0x0, 0x10(%rsp)
leaq 0x30(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq %r13, %rdx
movl 0x60(%rsp), %ecx
movq %rbx, %r8
movl 0x74(%rsp), %r9d
callq 0x3699c
movq 0x78(%rsp), %r13
incq %r13
jmp 0x1fb70
movb $0x1, %al
addq $0xc8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq