// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x260, %rsp            # imm = 0x260
movw %cx, %ax
movw %dx, %cx
movw %si, %dx
movb 0x10(%rbp), %sil
movq %rdi, -0x8(%rbp)
movw %dx, -0xa(%rbp)
movw %cx, -0xc(%rbp)
movw %ax, -0xe(%rbp)
movq %r8, -0x18(%rbp)
movq %r9, -0x20(%rbp)
movq -0x8(%rbp), %rdi
callq 0xd120
testb $0x1, %al
jne 0x27b8f
movq -0x8(%rbp), %rsi
leaq 0x40574(%rip), %rdi     # 0x680fc
callq 0xd410
jmp 0x27b8d
movq -0x18(%rbp), %rdi
callq 0xd120
testb $0x1, %al
jne 0x27bae
movq -0x18(%rbp), %rsi
leaq 0x40555(%rip), %rdi     # 0x680fc
callq 0xd410
jmp 0x27bac
movq -0x8(%rbp), %rdi
callq 0x26c90
movq %rax, -0x28(%rbp)
movw $0x0, -0x30(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %eax
shrl $0xa, %eax
andl $0x7ff, %eax            # imm = 0x7FF
decl %eax
movw %ax, -0x2c(%rbp)
movw $0x0, -0x2e(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %eax
shrl $0x15, %eax
decl %eax
movw %ax, -0x2a(%rbp)
movw -0xa(%rbp), %ax
movw %ax, -0x38(%rbp)
movw -0xc(%rbp), %ax
movw %ax, -0x36(%rbp)
movzwl -0xa(%rbp), %edx
movzwl -0xe(%rbp), %eax
movl %eax, %ecx
movl %edx, %eax
leal -0x1(%rax,%rcx), %eax
movw %ax, -0x34(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %eax
shrl $0x15, %eax
decl %eax
movw %ax, -0x32(%rbp)
leaq -0x1d8(%rbp), %rdi
movq %rdi, -0x218(%rbp)
xorl %esi, %esi
movl %esi, -0x224(%rbp)
movl $0x1a0, %edx            # imm = 0x1A0
callq 0x2090
movl -0x224(%rbp), %eax
movq -0x28(%rbp), %rcx
movq 0x8(%rcx), %rsi
movl (%rcx), %edx
movl %edx, %ecx
shrl $0xa, %ecx
andl $0x7ff, %ecx            # imm = 0x7FF
shrl $0x15, %edx
imull %edx, %ecx
movl %eax, %edx
leaq -0x200(%rbp), %rdi
movq %rdi, -0x220(%rbp)
callq 0xd660
leaq -0x1e4(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x27b20
movq -0x218(%rbp), %rdi
callq 0xd5a0
movq -0x220(%rbp), %rax
movq %rax, -0x1d0(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %eax
shrl $0xa, %eax
andl $0x7ff, %eax            # imm = 0x7FF
movw %ax, -0x1d8(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %eax
shrl $0x15, %eax
movw %ax, -0x1d6(%rbp)
callq 0xafe0
movq -0x218(%rbp), %rdi
movq %rax, -0x208(%rbp)
callq 0xaff0
movzbl 0x10(%rbp), %eax
movl %eax, -0x210(%rbp)
testl %eax, %eax
je 0x27d04
jmp 0x27cea
movl -0x210(%rbp), %eax
subl $0x1, %eax
je 0x27d16
jmp 0x27cf7
movl -0x210(%rbp), %eax
subl $0x2, %eax
je 0x27d0d
jmp 0x27d1f
movb $0x0, -0x209(%rbp)
jmp 0x27d26
movb $0x8, -0x209(%rbp)
jmp 0x27d26
movb $0x4, -0x209(%rbp)
jmp 0x27d26
movb $0x0, -0x209(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x238(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x230(%rbp)
movb -0x209(%rbp), %al
movb %al, -0x225(%rbp)
movq -0x8(%rbp), %rdi
callq 0x7180
movq -0x238(%rbp), %rdx
movq -0x230(%rbp), %r8
movb -0x225(%rbp), %r9b
leaq -0x38(%rbp), %rdi
leaq -0x30(%rbp), %rsi
movl $0xff, %ecx
xorl %r10d, %r10d
movzbl %r9b, %r9d
movq $0x0, (%rsp)
movq $0x0, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movzbl %al, %eax
movl %eax, 0x18(%rsp)
callq 0x5f210
movq -0x208(%rbp), %rdi
callq 0xaff0
addq $0x260, %rsp            # imm = 0x260
popq %rbp
retq
nopw %cs:(%rax,%rax)