// File: /workspace/github_c_makefile_star2_O1/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_img.c
// Function: lv_img_design
static bool lv_img_design(lv_obj_t * img, const lv_area_t * mask, lv_design_mode_t mode)
{
    const lv_style_t * style = lv_obj_get_style(img);
    lv_img_ext_t * ext       = lv_obj_get_ext_attr(img);

    if(mode == LV_DESIGN_COVER_CHK) {
        bool cover = false;
        if(ext->src_type == LV_IMG_SRC_UNKNOWN || ext->src_type == LV_IMG_SRC_SYMBOL) return false;

        if(ext->cf == LV_IMG_CF_TRUE_COLOR || ext->cf == LV_IMG_CF_RAW) cover = lv_area_is_in(mask, &img->coords);

        return cover;
    } else if(mode == LV_DESIGN_DRAW_MAIN) {
        if(ext->h == 0 || ext->w == 0) return true;
        lv_area_t coords;
        lv_opa_t opa_scale = lv_obj_get_opa_scale(img);

        lv_obj_get_coords(img, &coords);

        if(ext->src_type == LV_IMG_SRC_FILE || ext->src_type == LV_IMG_SRC_VARIABLE) {
            coords.x1 -= ext->offset.x;
            coords.y1 -= ext->offset.y;

            LV_LOG_TRACE("lv_img_design: start to draw image");
            lv_area_t cords_tmp;
            cords_tmp.y1 = coords.y1;
            cords_tmp.y2 = coords.y1 + ext->h - 1;

            for(; cords_tmp.y1 <= coords.y2; cords_tmp.y1 += ext->h, cords_tmp.y2 += ext->h) {
                cords_tmp.x1 = coords.x1;
                cords_tmp.x2 = coords.x1 + ext->w - 1;
                for(; cords_tmp.x1 <= coords.x2; cords_tmp.x1 += ext->w, cords_tmp.x2 += ext->w) {
                    lv_draw_img(&cords_tmp, mask, ext->src, style, opa_scale);
                }
            }
        } else if(ext->src_type == LV_IMG_SRC_SYMBOL) {
            LV_LOG_TRACE("lv_img_design: start to draw symbol");
            lv_style_t style_mod;
            lv_style_copy(&style_mod, style);
            style_mod.text.color = style->image.color;
            lv_draw_label(&coords, mask, &style_mod, opa_scale, ext->src, LV_TXT_FLAG_NONE, NULL, NULL, NULL, lv_obj_get_base_dir(img));
        } else {
            /*Trigger the error handler of image drawer*/
            LV_LOG_WARN("lv_img_design: image source type is unknown");
            lv_draw_img(&img->coords, mask, NULL, style, opa_scale);
        }
    }

    return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %edx, %ebp
movq %rsi, %r14
movq %rdi, %r13
callq 0x6697
movq %rax, %r15
movq %r13, %rdi
callq 0x6ad8
movq %rax, %r12
movb $0x1, %bl
testl %ebp, %ebp
je 0x2378b
cmpl $0x2, %ebp
jne 0x2388a
movzbl 0x10(%r12), %eax
testb $0x2, %al
jne 0x23888
shrl $0x3, %eax
cmpl $0x4, %eax
je 0x2376e
cmpl $0x1, %eax
jne 0x23888
addq $0x20, %r13
movq %r14, %rdi
movq %r13, %rsi
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x28750
cmpw $0x0, 0xe(%r12)
je 0x2388a
cmpw $0x0, 0xc(%r12)
je 0x2388a
movq %r13, %rdi
callq 0x69cc
movl %eax, %ebp
leaq 0x28(%rsp), %rsi
movq %r13, %rdi
callq 0x5427
movzbl 0x10(%r12), %eax
andl $0x3, %eax
cmpl $0x2, %eax
jae 0x2389b
movzwl 0x8(%r12), %eax
subw %ax, 0x28(%rsp)
movzwl 0x2a(%rsp), %eax
subw 0xa(%r12), %ax
movw %ax, 0x2a(%rsp)
movw %ax, 0x32(%rsp)
movzwl 0xe(%r12), %ecx
addw %ax, %cx
decl %ecx
movw %cx, 0x36(%rsp)
cmpw 0x2e(%rsp), %ax
jg 0x2388a
movzbl %bpl, %ebp
leaq 0x30(%rsp), %r13
movzwl 0x28(%rsp), %eax
movw %ax, 0x30(%rsp)
movzwl 0xc(%r12), %ecx
addw %ax, %cx
decl %ecx
movw %cx, 0x34(%rsp)
cmpw 0x2c(%rsp), %ax
jg 0x23867
movq (%r12), %rdx
movq %r13, %rdi
movq %r14, %rsi
movq %r15, %rcx
movl %ebp, %r8d
callq 0x3bc40
movzwl 0xc(%r12), %eax
movzwl 0x30(%rsp), %ecx
addw %ax, %cx
movw %cx, 0x30(%rsp)
addw %ax, 0x34(%rsp)
cmpw 0x2c(%rsp), %cx
jle 0x23833
movzwl 0xe(%r12), %eax
movzwl 0x32(%rsp), %ecx
addw %ax, %cx
movw %cx, 0x32(%rsp)
addw %ax, 0x36(%rsp)
cmpw 0x2e(%rsp), %cx
jle 0x23812
jmp 0x2388a
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jne 0x238f9
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
callq 0x798d
movzwl 0x38(%r15), %eax
leaq 0x30(%rsp), %rcx
movw %ax, 0x20(%rcx)
movq (%r12), %r15
movq %r13, %rdi
callq 0x4abc
movzbl %al, %eax
movl %eax, 0x18(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
movq $0x0, 0x10(%rsp)
movzbl %bpl, %ecx
leaq 0x28(%rsp), %rdi
movq %r14, %rsi
leaq 0x30(%rsp), %rdx
movq %r15, %r8
xorl %r9d, %r9d
callq 0x3a034
jmp 0x2388a
addq $0x20, %r13
movzbl %bpl, %r8d
movq %r13, %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %r15, %rcx
callq 0x3bc40
jmp 0x2388a