// File: /workspace/github_c_makefile_star2_O3/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 0x66b6
movq %rax, %r15
movq %r13, %rdi
callq 0x6af7
movq %rax, %r12
movb $0x1, %bl
testl %ebp, %ebp
je 0x23ebd
cmpl $0x2, %ebp
jne 0x23fd8
movzbl 0x10(%r12), %eax
testb $0x2, %al
jne 0x23fd6
shrl $0x3, %eax
cmpl $0x4, %eax
je 0x23ea0
cmpl $0x1, %eax
jne 0x23fd6
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 0x28dd5
cmpw $0x0, 0xe(%r12)
je 0x23fd8
cmpw $0x0, 0xc(%r12)
je 0x23fd8
movq %r13, %rdi
callq 0x69eb
movl %eax, %ebp
leaq 0x28(%rsp), %rsi
movq %r13, %rdi
callq 0x542b
movzbl 0x10(%r12), %eax
andl $0x3, %eax
cmpl $0x2, %eax
jae 0x23fe9
movq 0x8(%r12), %xmm0
movd 0x28(%rsp), %xmm1
psubw %xmm0, %xmm1
movd %xmm1, 0x28(%rsp)
pextrw $0x1, %xmm1, %eax
movw %ax, 0x32(%rsp)
movzwl 0xe(%r12), %ecx
leal (%rax,%rcx), %esi
decl %esi
movw %si, 0x36(%rsp)
movzwl 0x2e(%rsp), %r8d
cmpw %r8w, %ax
jg 0x23fd8
movzwl 0xc(%r12), %edx
movzwl 0x2c(%rsp), %edi
movzbl %bpl, %ebp
leaq 0x30(%rsp), %r13
movl 0x28(%rsp), %r9d
movw %r9w, 0x30(%rsp)
leal (%r9,%rdx), %r10d
decl %r10d
movw %r10w, 0x34(%rsp)
cmpw %di, %r9w
jg 0x23fc0
movq (%r12), %rdx
movq %r13, %rdi
movq %r14, %rsi
movq %r15, %rcx
movl %ebp, %r8d
callq 0x3c03c
movzwl 0xc(%r12), %edx
movzwl 0x30(%rsp), %eax
addw %dx, %ax
movw %ax, 0x30(%rsp)
addw %dx, 0x34(%rsp)
movzwl 0x2c(%rsp), %edi
cmpw %di, %ax
jle 0x23f73
movzwl 0xe(%r12), %ecx
movzwl 0x32(%rsp), %eax
movzwl 0x36(%rsp), %esi
movzwl 0x2e(%rsp), %r8d
addl %ecx, %eax
movw %ax, 0x32(%rsp)
addl %ecx, %esi
movw %si, 0x36(%rsp)
cmpw %r8w, %ax
jle 0x23f55
jmp 0x23fd8
xorl %ebx, %ebx
movl %ebx, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jne 0x24049
leaq 0x30(%rsp), %rdi
movq %r15, %rsi
callq 0x799d
movzwl 0x38(%r15), %eax
leaq 0x30(%rsp), %rcx
movw %ax, 0x20(%rcx)
movq (%r12), %r15
movq %r13, %rdi
callq 0x4ab2
movzbl %al, %eax
movl %eax, 0x18(%rsp)
pxor %xmm0, %xmm0
movdqu %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 0x3a5ac
jmp 0x23fd8
addq $0x20, %r13
movzbl %bpl, %r8d
movq %r13, %rdi
movq %r14, %rsi
xorl %edx, %edx
movq %r15, %rcx
callq 0x3c03c
jmp 0x23fd8