// File: /workspace/github_c_makefile_star2_O0/OnionIoT[P]lv_example/lvgl/src/lv_draw/lv_draw_img.c
// Function: lv_img_draw_core
static lv_res_t lv_img_draw_core(const lv_area_t * coords, const lv_area_t * mask, const void * src,
                                 const lv_style_t * style, lv_opa_t opa_scale)
{

    lv_area_t mask_com; /*Common area of mask and coords*/
    bool union_ok;
    union_ok = lv_area_intersect(&mask_com, mask, coords);
    if(union_ok == false) {
        return LV_RES_OK; /*Out of mask. There is nothing to draw so the image is drawn
                             successfully.*/
    }

    lv_opa_t opa =
        opa_scale == LV_OPA_COVER ? style->image.opa : (uint16_t)((uint16_t)style->image.opa * opa_scale) >> 8;

    lv_img_cache_entry_t * cdsc = lv_img_cache_open(src, style);

    if(cdsc == NULL) return LV_RES_INV;

    bool chroma_keyed = lv_img_color_format_is_chroma_keyed(cdsc->dec_dsc.header.cf);
    bool alpha_byte   = lv_img_color_format_has_alpha(cdsc->dec_dsc.header.cf);

    if(cdsc->dec_dsc.error_msg != NULL) {
        LV_LOG_WARN("Image draw error");
        lv_draw_rect(coords, mask, &lv_style_plain, LV_OPA_COVER);
        lv_draw_label(coords, mask, &lv_style_plain, LV_OPA_COVER, cdsc->dec_dsc.error_msg, LV_TXT_FLAG_NONE, NULL, NULL, NULL, LV_BIDI_DIR_LTR);
    }
    /* The decoder open could open the image and gave the entire uncompressed image.
     * Just draw it!*/
    else if(cdsc->dec_dsc.img_data) {
        lv_draw_map(coords, mask, cdsc->dec_dsc.img_data, opa, chroma_keyed, alpha_byte, style->image.color,
                    style->image.intense);
    }
    /* The whole uncompressed image is not available. Try to read it line-by-line*/
    else {
        lv_coord_t width = lv_area_get_width(&mask_com);

        uint8_t  * buf = lv_draw_get_buf(lv_area_get_width(&mask_com) * LV_IMG_PX_SIZE_ALPHA_BYTE);  /*space for the possible alpha byte*/

        lv_area_t line;
        lv_area_copy(&line, &mask_com);
        lv_area_set_height(&line, 1);
        lv_coord_t x = mask_com.x1 - coords->x1;
        lv_coord_t y = mask_com.y1 - coords->y1;
        lv_coord_t row;
        lv_res_t read_res;
        for(row = mask_com.y1; row <= mask_com.y2; row++) {
            read_res = lv_img_decoder_read_line(&cdsc->dec_dsc, x, y, width, buf);
            if(read_res != LV_RES_OK) {
                lv_img_decoder_close(&cdsc->dec_dsc);
                LV_LOG_WARN("Image draw can't read the line");
                return LV_RES_INV;
            }
            lv_draw_map(&line, mask, buf, opa, chroma_keyed, alpha_byte, style->image.color, style->image.intense);
            line.y1++;
            line.y2++;
            y++;
        }
    }

    return LV_RES_OK;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x90, %rsp
movb %r8b, %al
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movb %al, -0x29(%rbp)
movq -0x18(%rbp), %rsi
movq -0x10(%rbp), %rdx
leaq -0x32(%rbp), %rdi
callq 0x427d0
andb $0x1, %al
movb %al, -0x33(%rbp)
movb -0x33(%rbp), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x61ebd
movb $0x1, -0x1(%rbp)
jmp 0x62154
movzbl -0x29(%rbp), %eax
cmpl $0xff, %eax
jne 0x61ed5
movq -0x28(%rbp), %rax
movzbl 0x3b(%rax), %eax
movl %eax, -0x64(%rbp)
jmp 0x61ef0
movq -0x28(%rbp), %rax
movzbl 0x3b(%rax), %eax
movzwl %ax, %eax
movzbl -0x29(%rbp), %ecx
imull %ecx, %eax
movzwl %ax, %eax
sarl $0x8, %eax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
movb %al, -0x34(%rbp)
movq -0x20(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x66680
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x61f17
movb $0x0, -0x1(%rbp)
jmp 0x62154
movq -0x40(%rbp), %rax
movl 0x1c(%rax), %eax
andl $0x1f, %eax
movzbl %al, %edi
callq 0x63080
andb $0x1, %al
movb %al, -0x41(%rbp)
movq -0x40(%rbp), %rax
movl 0x1c(%rax), %eax
andl $0x1f, %eax
movzbl %al, %edi
callq 0x630c0
andb $0x1, %al
movb %al, -0x42(%rbp)
movq -0x40(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x61fb6
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
leaq 0x27089(%rip), %rdx     # 0x88fe8
movl $0xff, %ecx
callq 0x5a9e0
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x40(%rbp), %rax
movq 0x30(%rax), %r8
leaq 0x27068(%rip), %rdx     # 0x88fe8
movl $0xff, %ecx
xorl %r9d, %r9d
xorl %eax, %eax
movq $0x0, (%rsp)
movq $0x0, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movl $0x0, 0x18(%rsp)
callq 0x5f210
jmp 0x62150
movq -0x40(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x62014
movq -0x10(%rbp), %rdi
movq -0x18(%rbp), %rsi
movq -0x40(%rbp), %rax
movq 0x20(%rax), %rdx
movb -0x34(%rbp), %cl
movb -0x41(%rbp), %r8b
movb -0x42(%rbp), %r9b
movq -0x28(%rbp), %r10
movq -0x28(%rbp), %rax
movb 0x3a(%rax), %al
andb $0x1, %r8b
andb $0x1, %r9b
movzbl %cl, %ecx
movzbl %r8b, %r8d
movzbl %r9b, %r9d
movzwl 0x38(%r10), %r10d
movl %r10d, (%rsp)
movzbl %al, %eax
movl %eax, 0x8(%rsp)
callq 0x59f30
jmp 0x6214e
leaq -0x32(%rbp), %rdi
callq 0x63490
movw %ax, -0x44(%rbp)
leaq -0x32(%rbp), %rdi
callq 0x63490
cwtl
imull $0x3, %eax, %edi
callq 0x5a6a0
movq %rax, -0x50(%rbp)
leaq -0x58(%rbp), %rdi
leaq -0x32(%rbp), %rsi
callq 0x634b0
leaq -0x58(%rbp), %rdi
movl $0x1, %esi
callq 0x426b0
movswl -0x32(%rbp), %eax
movq -0x10(%rbp), %rcx
movswl (%rcx), %ecx
subl %ecx, %eax
movw %ax, -0x5a(%rbp)
movswl -0x30(%rbp), %eax
movq -0x10(%rbp), %rcx
movswl 0x2(%rcx), %ecx
subl %ecx, %eax
movw %ax, -0x5c(%rbp)
movw -0x30(%rbp), %ax
movw %ax, -0x5e(%rbp)
movswl -0x5e(%rbp), %eax
movswl -0x2c(%rbp), %ecx
cmpl %ecx, %eax
jg 0x6214c
movq -0x40(%rbp), %rdi
movw -0x5a(%rbp), %dx
movw -0x5c(%rbp), %cx
movw -0x44(%rbp), %ax
movq -0x50(%rbp), %r8
movswl %dx, %esi
movswl %cx, %edx
movswl %ax, %ecx
callq 0x65be0
movb %al, -0x5f(%rbp)
movzbl -0x5f(%rbp), %eax
cmpl $0x1, %eax
je 0x620cd
movq -0x40(%rbp), %rdi
callq 0x65c60
movb $0x0, -0x1(%rbp)
jmp 0x62154
movq -0x18(%rbp), %rsi
movq -0x50(%rbp), %rdx
movb -0x34(%rbp), %cl
movb -0x41(%rbp), %r8b
movb -0x42(%rbp), %r9b
movq -0x28(%rbp), %r10
movq -0x28(%rbp), %rax
movb 0x3a(%rax), %al
leaq -0x58(%rbp), %rdi
andb $0x1, %r8b
andb $0x1, %r9b
movzbl %cl, %ecx
movzbl %r8b, %r8d
movzbl %r9b, %r9d
movzwl 0x38(%r10), %r10d
movl %r10d, (%rsp)
movzbl %al, %eax
movl %eax, 0x8(%rsp)
callq 0x59f30
movw -0x56(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x56(%rbp)
movw -0x52(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x52(%rbp)
movw -0x5c(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x5c(%rbp)
movw -0x5e(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x5e(%rbp)
jmp 0x6207d
jmp 0x6214e
jmp 0x62150
movb $0x1, -0x1(%rbp)
movb -0x1(%rbp), %al
addq $0x90, %rsp
popq %rbp
retq