// File: /workspace/github_c_makefile_star2_O0/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_canvas.c
// Function: lv_canvas_draw_line
void lv_canvas_draw_line(lv_obj_t * canvas, const lv_point_t * points, uint32_t point_cnt, 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_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;

#if LV_ANTIALIAS
    /*Disable anti-aliasing if drawing with transparent color to chroma keyed canvas*/
    lv_color_t ctransp = LV_COLOR_TRANSP;
    if(dsc->header.cf == LV_IMG_CF_TRUE_COLOR_CHROMA_KEYED &&
        style->body.main_color.full == ctransp.full &&
        style->body.grad_color.full == ctransp.full)
    {
        disp.driver.antialiasing = 0;
    }
#endif

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

    lv_style_t circle_style_tmp; /*If rounded...*/
    if(style->line.rounded) {
        lv_style_copy(&circle_style_tmp, style);
        circle_style_tmp.body.radius     = LV_RADIUS_CIRCLE;
        circle_style_tmp.body.main_color = style->line.color;
        circle_style_tmp.body.grad_color = style->line.color;
        circle_style_tmp.body.opa        = style->line.opa;
    }
    lv_area_t circle_area;
    uint32_t i;
    for(i = 0; i < point_cnt - 1; i++) {
        lv_draw_line(&points[i], &points[i + 1], &mask, style, LV_OPA_COVER);
        
        /*Draw circle on the joints if enabled*/
        if(style->line.rounded) {
            circle_area.x1 = points[i].x - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1);
            circle_area.y1 = points[i].y - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1);
            circle_area.x2 = points[i].x + ((style->line.width - 1) >> 1);
            circle_area.y2 = points[i].y + ((style->line.width - 1) >> 1);
            lv_draw_rect(&circle_area, &mask, &circle_style_tmp, LV_OPA_COVER);
        }
    }
    /*Draw circle on the last point too if enabled*/
    if(style->line.rounded) {
        circle_area.x1 = points[i].x - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1);
        circle_area.y1 = points[i].y - ((style->line.width - 1) >> 1) - ((style->line.width - 1) & 0x1);
        circle_area.x2 = points[i].x + ((style->line.width - 1) >> 1);
        circle_area.y2 = points[i].y + ((style->line.width - 1) >> 1);
        lv_draw_rect(&circle_area, &mask, &circle_style_tmp, LV_OPA_COVER);
    }
    
    lv_refr_set_disp_refreshing(refr_ori);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x260, %rsp            # imm = 0x260
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rdi
callq 0xd120
testb $0x1, %al
jne 0x27fd9
movq -0x8(%rbp), %rsi
leaq 0x4012a(%rip), %rdi     # 0x680fc
callq 0xd410
jmp 0x27fd7
movq -0x20(%rbp), %rdi
callq 0xd120
testb $0x1, %al
jne 0x27ff8
movq -0x20(%rbp), %rsi
leaq 0x4010b(%rip), %rdi     # 0x680fc
callq 0xd410
jmp 0x27ff6
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
subl $0x1, %eax
movw %ax, -0x2c(%rbp)
movw $0x0, -0x2e(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %eax
shrl $0x15, %eax
subl $0x1, %eax
movw %ax, -0x2a(%rbp)
leaq -0x1d0(%rbp), %rdi
xorl %esi, %esi
movl $0x1a0, %edx            # imm = 0x1A0
callq 0x2090
movq -0x28(%rbp), %rax
movq 0x8(%rax), %rsi
movq -0x28(%rbp), %rax
movl (%rax), %ecx
shrl $0xa, %ecx
andl $0x7ff, %ecx            # imm = 0x7FF
movq -0x28(%rbp), %rax
movl (%rax), %eax
shrl $0x15, %eax
imull %eax, %ecx
leaq -0x1f8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %edx
callq 0xd660
leaq -0x1f8(%rbp), %rdi
addq $0x1c, %rdi
leaq -0x30(%rbp), %rsi
callq 0x27b20
leaq -0x1d0(%rbp), %rdi
callq 0xd5a0
leaq -0x1f8(%rbp), %rax
movq %rax, -0x1c8(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %eax
shrl $0xa, %eax
andl $0x7ff, %eax            # imm = 0x7FF
movw %ax, -0x1d0(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %eax
shrl $0x15, %eax
movw %ax, -0x1ce(%rbp)
movw 0x404fc(%rip), %ax      # 0x685d2
movw %ax, -0x1fa(%rbp)
movq -0x28(%rbp), %rax
movl (%rax), %eax
andl $0x1f, %eax
cmpl $0x6, %eax
jne 0x28121
movq -0x20(%rbp), %rax
movzwl 0x2(%rax), %eax
movzwl -0x1fa(%rbp), %ecx
cmpl %ecx, %eax
jne 0x28121
movq -0x20(%rbp), %rax
movzwl 0x4(%rax), %eax
movzwl -0x1fa(%rbp), %ecx
cmpl %ecx, %eax
jne 0x28121
movb -0x1c0(%rbp), %al
andb $-0x2, %al
orb $0x0, %al
movb %al, -0x1c0(%rbp)
callq 0xafe0
movq %rax, -0x208(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0xaff0
movq -0x20(%rbp), %rax
movb 0x41(%rax), %al
andb $0x1, %al
cmpb $0x0, %al
je 0x2818a
movq -0x20(%rbp), %rsi
leaq -0x250(%rbp), %rdi
callq 0xc550
movw $0x7c18, -0x24a(%rbp)   # imm = 0x7C18
movq -0x20(%rbp), %rax
movw 0x3c(%rax), %ax
movw %ax, -0x24e(%rbp)
movq -0x20(%rbp), %rax
movw 0x3c(%rax), %ax
movw %ax, -0x24c(%rbp)
movq -0x20(%rbp), %rax
movb 0x40(%rax), %al
movb %al, -0x248(%rbp)
movl $0x0, -0x25c(%rbp)
movl -0x25c(%rbp), %eax
movl -0x14(%rbp), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jae 0x282d7
movq -0x10(%rbp), %rdi
movl -0x25c(%rbp), %eax
shlq $0x2, %rax
addq %rax, %rdi
movq -0x10(%rbp), %rsi
movl -0x25c(%rbp), %eax
addl $0x1, %eax
movl %eax, %eax
shlq $0x2, %rax
addq %rax, %rsi
movq -0x20(%rbp), %rcx
leaq -0x30(%rbp), %rdx
movl $0xff, %r8d
callq 0x5fcd0
movq -0x20(%rbp), %rax
movb 0x41(%rax), %al
andb $0x1, %al
cmpb $0x0, %al
je 0x282c1
movq -0x10(%rbp), %rax
movl -0x25c(%rbp), %ecx
movswl (%rax,%rcx,4), %eax
movq -0x20(%rbp), %rcx
movswl 0x3e(%rcx), %ecx
subl $0x1, %ecx
sarl %ecx
subl %ecx, %eax
movq -0x20(%rbp), %rcx
movswl 0x3e(%rcx), %ecx
subl $0x1, %ecx
andl $0x1, %ecx
subl %ecx, %eax
movw %ax, -0x258(%rbp)
movq -0x10(%rbp), %rax
movl -0x25c(%rbp), %ecx
movswl 0x2(%rax,%rcx,4), %eax
movq -0x20(%rbp), %rcx
movswl 0x3e(%rcx), %ecx
subl $0x1, %ecx
sarl %ecx
subl %ecx, %eax
movq -0x20(%rbp), %rcx
movswl 0x3e(%rcx), %ecx
subl $0x1, %ecx
andl $0x1, %ecx
subl %ecx, %eax
movw %ax, -0x256(%rbp)
movq -0x10(%rbp), %rax
movl -0x25c(%rbp), %ecx
movswl (%rax,%rcx,4), %eax
movq -0x20(%rbp), %rcx
movswl 0x3e(%rcx), %ecx
subl $0x1, %ecx
sarl %ecx
addl %ecx, %eax
movw %ax, -0x254(%rbp)
movq -0x10(%rbp), %rax
movl -0x25c(%rbp), %ecx
movswl 0x2(%rax,%rcx,4), %eax
movq -0x20(%rbp), %rcx
movswl 0x3e(%rcx), %ecx
subl $0x1, %ecx
sarl %ecx
addl %ecx, %eax
movw %ax, -0x252(%rbp)
leaq -0x258(%rbp), %rdi
leaq -0x30(%rbp), %rsi
leaq -0x250(%rbp), %rdx
movl $0xff, %ecx
callq 0x5a9e0
jmp 0x282c3
movl -0x25c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x25c(%rbp)
jmp 0x28194
movq -0x20(%rbp), %rax
movb 0x41(%rax), %al
andb $0x1, %al
cmpb $0x0, %al
je 0x283b6
movq -0x10(%rbp), %rax
movl -0x25c(%rbp), %ecx
movswl (%rax,%rcx,4), %eax
movq -0x20(%rbp), %rcx
movswl 0x3e(%rcx), %ecx
subl $0x1, %ecx
sarl %ecx
subl %ecx, %eax
movq -0x20(%rbp), %rcx
movswl 0x3e(%rcx), %ecx
subl $0x1, %ecx
andl $0x1, %ecx
subl %ecx, %eax
movw %ax, -0x258(%rbp)
movq -0x10(%rbp), %rax
movl -0x25c(%rbp), %ecx
movswl 0x2(%rax,%rcx,4), %eax
movq -0x20(%rbp), %rcx
movswl 0x3e(%rcx), %ecx
subl $0x1, %ecx
sarl %ecx
subl %ecx, %eax
movq -0x20(%rbp), %rcx
movswl 0x3e(%rcx), %ecx
subl $0x1, %ecx
andl $0x1, %ecx
subl %ecx, %eax
movw %ax, -0x256(%rbp)
movq -0x10(%rbp), %rax
movl -0x25c(%rbp), %ecx
movswl (%rax,%rcx,4), %eax
movq -0x20(%rbp), %rcx
movswl 0x3e(%rcx), %ecx
subl $0x1, %ecx
sarl %ecx
addl %ecx, %eax
movw %ax, -0x254(%rbp)
movq -0x10(%rbp), %rax
movl -0x25c(%rbp), %ecx
movswl 0x2(%rax,%rcx,4), %eax
movq -0x20(%rbp), %rcx
movswl 0x3e(%rcx), %ecx
subl $0x1, %ecx
sarl %ecx
addl %ecx, %eax
movw %ax, -0x252(%rbp)
leaq -0x258(%rbp), %rdi
leaq -0x30(%rbp), %rsi
leaq -0x250(%rbp), %rdx
movl $0xff, %ecx
callq 0x5a9e0
movq -0x208(%rbp), %rdi
callq 0xaff0
addq $0x260, %rsp            # imm = 0x260
popq %rbp
retq
nopl (%rax,%rax)