// File: /workspace/github_c_makefile_star2_O3/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_canvas.c
// Function: lv_canvas_draw_img
void lv_canvas_draw_img(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, const void * src, const lv_style_t * style)
{
    LV_ASSERT_OBJ(canvas, LV_OBJX_NAME);
    LV_ASSERT_NULL(style);

    lv_img_dsc_t * dsc = lv_canvas_get_img(canvas);

    /* Create a dummy display to fool the lv_draw function.
     * It will think it draws to real screen. */
    lv_area_t mask;
    mask.x1 = 0;
    mask.x2 = dsc->header.w - 1;
    mask.y1 = 0;
    mask.y2 = dsc->header.h - 1;

    lv_img_header_t header;
    lv_res_t res = lv_img_decoder_get_info(src, &header);
    if(res != LV_RES_OK) {
        LV_LOG_WARN("lv_canvas_draw_img: Couldn't get the image data.");
        return;
    }

    lv_area_t coords;
    coords.x1 = x;
    coords.y1 = y;
    coords.x2 = x + header.w - 1;
    coords.y2 = y + header.h - 1;

    lv_disp_t disp;
    memset(&disp, 0, sizeof(lv_disp_t));

    lv_disp_buf_t disp_buf;
    lv_disp_buf_init(&disp_buf, (void *)dsc->data, NULL, dsc->header.w * dsc->header.h);
    lv_area_copy(&disp_buf.area, &mask);

    lv_disp_drv_init(&disp.driver);

    disp.driver.buffer  = &disp_buf;
    disp.driver.hor_res = dsc->header.w;
    disp.driver.ver_res = dsc->header.h;

    lv_disp_t * refr_ori = lv_refr_get_disp_refreshing();
    lv_refr_set_disp_refreshing(&disp);

    lv_draw_img(&coords, &mask, src, style, LV_OPA_COVER);

    lv_refr_set_disp_refreshing(refr_ori);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1e8, %rsp            # imm = 0x1E8
movq %r8, %rbx
movq %rcx, %r14
movl %edx, %r13d
movl %esi, %ebp
movq %rdi, %r15
callq 0x80e4
testb %al, %al
je 0x18a94
movq %rbx, %rdi
callq 0x80e4
testb %al, %al
je 0x18aa5
movq %r15, %rdi
callq 0x17bb1
movq %rax, %r15
xorl %eax, %eax
movw %ax, 0x8(%rsp)
movl (%r15), %ecx
movl %ecx, %edx
shrl $0xa, %edx
andl $0x7ff, %edx            # imm = 0x7FF
decl %edx
movw %dx, 0xc(%rsp)
movw %ax, 0xa(%rsp)
shrl $0x15, %ecx
decl %ecx
movw %cx, 0xe(%rsp)
leaq 0x14(%rsp), %rsi
movq %r14, %rdi
callq 0x3e49e
cmpb $0x1, %al
jne 0x18a82
leaq 0x18(%rsp), %r12
movw %bp, (%r12)
movw %r13w, 0x2(%r12)
movl 0x14(%rsp), %eax
movl %eax, %ecx
shrl $0xa, %ecx
movl $0x7ff, %edx            # imm = 0x7FF
andl %edx, %ecx
addl %ebp, %ecx
decl %ecx
movw %cx, 0x4(%r12)
shrl $0x15, %eax
addl %r13d, %eax
decl %eax
movw %ax, 0x6(%r12)
leaq 0x48(%rsp), %r13
movl $0x1a0, %edx            # imm = 0x1A0
movq %r13, %rdi
xorl %esi, %esi
callq 0x20a0
movq 0x8(%r15), %rsi
movl (%r15), %ecx
movl %ecx, %eax
shrl $0xa, %eax
movl $0x7ff, %edx            # imm = 0x7FF
andl %edx, %eax
shrl $0x15, %ecx
imull %eax, %ecx
leaq 0x20(%rsp), %rbp
movq %rbp, %rdi
xorl %edx, %edx
callq 0x830f
leaq 0x8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x1c(%rbp)
movq %r13, %rdi
callq 0x82ec
movq %rbp, 0x8(%r13)
movl (%r15), %eax
movl %eax, %ecx
shrl $0xa, %ecx
movl $0x7ff, %edx            # imm = 0x7FF
andl %edx, %ecx
movw %cx, (%r13)
shrl $0x15, %eax
movw %ax, 0x2(%r13)
callq 0x7293
movq %rax, %r15
movq %r13, %rdi
callq 0x729b
movq %r12, %rdi
leaq 0x8(%rsp), %rsi
movq %r14, %rdx
movq %rbx, %rcx
movl $0xff, %r8d
callq 0x3c03c
movq %r15, %rdi
callq 0x729b
addq $0x1e8, %rsp            # imm = 0x1E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x26749(%rip), %rdi     # 0x3f1e4
movq %r15, %rsi
callq 0x8294
jmp 0x18aa3
leaq 0x26738(%rip), %rdi     # 0x3f1e4
movq %rbx, %rsi
callq 0x8294
jmp 0x18ab4