// File: /workspace/github_c_makefile_star2_O2/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_canvas.c
// Function: lv_canvas_draw_text
void lv_canvas_draw_text(lv_obj_t * canvas, lv_coord_t x, lv_coord_t y, lv_coord_t max_w, const lv_style_t * style,
                         const char * txt, lv_label_align_t align)
{
    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_area_t coords;
    coords.x1 = x;
    coords.y1 = y;
    coords.x2 = x + max_w - 1;
    coords.y2 = dsc->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_txt_flag_t flag;
    switch(align) {
        case LV_LABEL_ALIGN_LEFT: flag = LV_TXT_FLAG_NONE; break;
        case LV_LABEL_ALIGN_RIGHT: flag = LV_TXT_FLAG_RIGHT; break;
        case LV_LABEL_ALIGN_CENTER: flag = LV_TXT_FLAG_CENTER; break;
        default: flag = LV_TXT_FLAG_NONE; break;
    }

    lv_draw_label(&coords, &mask, style, LV_OPA_COVER, txt, flag, NULL,  NULL, NULL, lv_obj_get_base_dir(canvas));

    lv_refr_set_disp_refreshing(refr_ori);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x218, %rsp            # imm = 0x218
movq %r9, %rbp
movq %r8, %rbx
movl %ecx, %r12d
movl %edx, %r14d
movl %esi, %r13d
movq %rdi, %r15
callq 0x7994
testb %al, %al
je 0x17082
movq %rbx, %rdi
callq 0x7994
testb %al, %al
je 0x17093
movq %r15, %rdi
callq 0x16510
leaq 0x40(%rsp), %rcx
andw $0x0, (%rcx)
movq %rax, 0x28(%rsp)
movq %rbp, 0x38(%rsp)
movl (%rax), %ebp
movq %rbx, 0x30(%rsp)
movl %ebp, %ebx
shrl $0xa, %ebx
movl $0x7ff, %eax            # imm = 0x7FF
andl %eax, %ebx
leal -0x1(%rbx), %eax
movw %ax, 0x4(%rcx)
andw $0x0, 0x2(%rcx)
shrl $0x15, %ebp
leal -0x1(%rbp), %eax
movw %ax, 0x6(%rcx)
leaq 0x48(%rsp), %rdx
movw %r13w, (%rdx)
movw %r14w, 0x2(%rdx)
leal -0x1(%r13,%r12), %ecx
movw %cx, 0x4(%rdx)
movw %ax, 0x6(%rdx)
leaq 0x78(%rsp), %r14
movl $0x1a0, %edx            # imm = 0x1A0
movq %r14, %rdi
xorl %esi, %esi
callq 0x20a0
movq 0x28(%rsp), %r13
movq 0x8(%r13), %rsi
imull %ebx, %ebp
leaq 0x50(%rsp), %r12
movq %r12, %rdi
xorl %edx, %edx
movl %ebp, %ecx
callq 0x7b7f
leaq 0x40(%rsp), %rbp
movq (%rbp), %rax
movq %rax, 0x1c(%r12)
movq %r14, %rdi
callq 0x7b5c
movq %r12, 0x8(%r14)
movl (%r13), %eax
movl %eax, %ecx
shrl $0xa, %ecx
movl $0x7ff, %edx            # imm = 0x7FF
andl %edx, %ecx
movw %cx, (%r14)
shrl $0x15, %eax
movw %ax, 0x2(%r14)
callq 0x6e0e
movq %rax, %r12
movq %r14, %rdi
callq 0x6e16
movb 0x250(%rsp), %cl
cmpb $0x2, %cl
sete %al
shlb $0x3, %al
cmpb $0x1, %cl
movzbl %al, %eax
pushq $0x4
popq %rbx
cmovnel %eax, %ebx
movq %r15, %rdi
callq 0x47b9
movzbl %al, %eax
movl %eax, 0x18(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, (%rsp)
andq $0x0, 0x10(%rsp)
movzbl %bl, %r9d
leaq 0x48(%rsp), %rdi
movq %rbp, %rsi
movq 0x30(%rsp), %rdx
movl $0xff, %ecx
movq 0x38(%rsp), %r8
callq 0x3699c
movq %r12, %rdi
callq 0x6e16
addq $0x218, %rsp            # imm = 0x218
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x240bb(%rip), %rdi     # 0x3b144
movq %r15, %rsi
callq 0x7b01
jmp 0x17091
leaq 0x240aa(%rip), %rdi     # 0x3b144
movq %rbx, %rsi
callq 0x7b01
jmp 0x170a2