// File: /workspace/github_c_makefile_star2_O2/OnionIoT[P]lv_example/lvgl/src/lv_core/lv_refr.c
// Function: lv_disp_refr_task
void lv_disp_refr_task(lv_task_t * task)
{
    LV_LOG_TRACE("lv_refr_task: started");

    uint32_t start = lv_tick_get();

    disp_refr = task->user_data;

    lv_refr_join_area();

    lv_refr_areas();

    /*If refresh happened ...*/
    if(disp_refr->inv_p != 0) {
        /*In true double buffered mode copy the refreshed areas to the new VDB to keep it up to
         * date*/
        if(lv_disp_is_true_double_buf(disp_refr)) {
            lv_disp_buf_t * vdb = lv_disp_get_buf(disp_refr);

            /*Flush the content of the VDB*/
            lv_refr_vdb_flush();

            /* With true double buffering the flushing should be only the address change of the
             * current frame buffer. Wait until the address change is ready and copy the changed
             * content to the other frame buffer (new active VDB) to keep the buffers synchronized*/
            while(vdb->flushing)
                ;

            uint8_t * buf_act = (uint8_t *)vdb->buf_act;
            uint8_t * buf_ina = (uint8_t *)vdb->buf_act == vdb->buf1 ? vdb->buf2 : vdb->buf1;

            lv_coord_t hres = lv_disp_get_hor_res(disp_refr);
            uint16_t a;
            for(a = 0; a < disp_refr->inv_p; a++) {
                if(disp_refr->inv_area_joined[a] == 0) {
                    lv_coord_t y;
                    uint32_t start_offs =
                        (hres * disp_refr->inv_areas[a].y1 + disp_refr->inv_areas[a].x1) * sizeof(lv_color_t);
                    uint32_t line_length = lv_area_get_width(&disp_refr->inv_areas[a]) * sizeof(lv_color_t);

                    for(y = disp_refr->inv_areas[a].y1; y <= disp_refr->inv_areas[a].y2; y++) {
                        memcpy(buf_act + start_offs, buf_ina + start_offs, line_length);
                        start_offs += hres * sizeof(lv_color_t);
                    }
                }
            }
        } /*End of true double buffer handling*/

        /*Clean up*/
        memset(disp_refr->inv_areas, 0, sizeof(disp_refr->inv_areas));
        memset(disp_refr->inv_area_joined, 0, sizeof(disp_refr->inv_area_joined));
        disp_refr->inv_p = 0;

        /*Call monitor cb if present*/
        if(disp_refr->driver.monitor_cb) {
            disp_refr->driver.monitor_cb(&disp_refr->driver, lv_tick_elaps(start), px_num);
        }
    }

    lv_draw_free_buf();

    LV_LOG_TRACE("lv_refr_task: ready");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %r14
callq 0x801a
movl %eax, 0x1c(%rsp)
movq 0x10(%r14), %rdi
movq %rdi, 0x57604(%rip)     # 0x5dec0
xorl %r12d, %r12d
leaq 0x8(%rsp), %r14
movzwl 0x198(%rdi), %eax
andl $0x3ff, %eax            # imm = 0x3FF
cmpq %rax, %r12
jae 0x69ab
cmpb $0x0, 0x178(%rdi,%r12)
je 0x68e9
incq %r12
jmp 0x68c4
xorl %ebx, %ebx
movzwl 0x198(%rdi), %eax
andl $0x3ff, %eax            # imm = 0x3FF
cmpq %rax, %rbx
jae 0x68e4
cmpq %r12, %rbx
je 0x69a3
cmpb $0x0, 0x178(%rdi,%rbx)
jne 0x69a3
leaq (%rdi,%r12,8), %rax
addq $0x78, %rax
leaq (%rdi,%rbx,8), %rsi
addq $0x78, %rsi
movq %rax, %rdi
callq 0x26906
movq 0x5758e(%rip), %rdi     # 0x5dec0
testb %al, %al
je 0x69a3
leaq (%rdi,%r12,8), %rsi
addq $0x78, %rsi
leaq (%rdi,%rbx,8), %rdx
addq $0x78, %rdx
movq %r14, %rdi
callq 0x268bf
movq %r14, %rdi
callq 0x26865
movl %eax, %ebp
movq 0x57561(%rip), %rax     # 0x5dec0
leaq (%rax,%r12,8), %rdi
addq $0x78, %rdi
callq 0x26865
movl %eax, %r15d
movq 0x5754a(%rip), %rax     # 0x5dec0
leaq (%rax,%rbx,8), %rdi
addq $0x78, %rdi
callq 0x26865
addl %r15d, %eax
movq 0x57533(%rip), %rdi     # 0x5dec0
cmpl %eax, %ebp
jae 0x69a3
movq 0x8(%rsp), %rax
movq %rax, 0x78(%rdi,%r12,8)
movb $0x1, 0x178(%rdi,%rbx)
incq %rbx
jmp 0x68eb
andl $0x0, 0x57516(%rip)     # 0x5dec8
xorl %r13d, %r13d
movzwl 0x198(%rdi), %eax
andl $0x3ff, %eax            # imm = 0x3FF
cmpq %rax, %r13
jae 0x6bb7
cmpb $0x0, 0x178(%rdi,%r13)
jne 0x6baf
leaq (%rdi,%r13,8), %r15
addq $0x78, %r15
callq 0x7ea2
movl %eax, %ebp
movq 0x574d1(%rip), %rdi     # 0x5dec0
callq 0x7e45
movq %rax, %r12
testb %bpl, %bpl
je 0x6a31
andw $0x0, 0x1c(%r12)
movq 0x574b6(%rip), %rdi     # 0x5dec0
callq 0x7d4c
decl %eax
movw %ax, 0x20(%r12)
andw $0x0, 0x1e(%r12)
movq 0x5749b(%rip), %rdi     # 0x5dec0
callq 0x7d6e
decl %eax
jmp 0x6b79
movzwl 0x4(%r15), %ebp
movzwl 0x6(%r15), %r14d
subw (%r15), %bp
movl %r14d, %ebx
subw 0x2(%r15), %bx
movq 0x57472(%rip), %rdi     # 0x5dec0
callq 0x7d6e
cmpw %ax, %r14w
jge 0x6a60
movzwl 0x6(%r15), %eax
jmp 0x6a6e
movq 0x57459(%rip), %rdi     # 0x5dec0
callq 0x7d6e
decl %eax
movl %eax, (%rsp)
incl %ebp
incl %ebx
movl 0x18(%r12), %eax
movswl %bp, %ecx
xorl %edx, %edx
divl %ecx
movswl %bx, %ebx
cmpl %ebx, %eax
cmovll %eax, %ebx
movq 0x57430(%rip), %rax     # 0x5dec0
cmpq $0x0, 0x20(%rax)
je 0x6ae2
andl $0x0, 0x8(%rsp)
andw $0x0, 0xc(%rsp)
movl %ebx, %r14d
leal -0x1(%r14), %ebp
movw %bp, 0xe(%rsp)
movq 0x5740b(%rip), %rdi     # 0x5dec0
leaq 0x8(%rsp), %rsi
callq *0x20(%rdi)
movswl 0xe(%rsp), %eax
movzwl 0xa(%rsp), %ecx
movl %eax, %edx
subw %cx, %dx
incl %edx
movswl %dx, %ecx
cmpl %ecx, %ebx
jge 0x6ae9
movl %ebp, %r14d
testw %bp, %bp
jg 0x6aa5
jmp 0x6b87
movq %r13, 0x10(%rsp)
jmp 0x6afc
testw %r14w, %r14w
jle 0x6b87
movq %r13, 0x10(%rsp)
incl %eax
movl %eax, %ebx
movzwl 0x2(%r15), %r14d
movswl (%rsp), %ebp
xorl %r13d, %r13d
movswl %r14w, %eax
addl %ebx, %eax
decl %eax
cmpl %ebp, %eax
jg 0x6b4f
movzwl (%r15), %ecx
movw %cx, 0x1c(%r12)
movzwl 0x4(%r15), %ecx
movw %cx, 0x20(%r12)
movw %r14w, 0x1e(%r12)
movswl %ax, %ecx
movl %ebp, %r13d
cmpl %ebp, %ecx
jg 0x6b3c
movl %eax, %r13d
addl %ebx, %r14d
movw %r13w, 0x22(%r12)
movq %r15, %rdi
callq 0x6e84
jmp 0x6b08
cmpw %r13w, (%rsp)
movq 0x10(%rsp), %r13
je 0x6b87
movzwl (%r15), %eax
movw %ax, 0x1c(%r12)
movzwl 0x4(%r15), %eax
movw %ax, 0x20(%r12)
movw %r14w, 0x1e(%r12)
movl (%rsp), %eax
movw %ax, 0x22(%r12)
movq %r15, %rdi
callq 0x6e84
movq 0x57332(%rip), %rdi     # 0x5dec0
cmpq $0x0, 0x30(%rdi)
je 0x6baf
leaq (%rdi,%r13,8), %rdi
addq $0x78, %rdi
callq 0x26865
addl %eax, 0x57320(%rip)     # 0x5dec8
movq 0x57311(%rip), %rdi     # 0x5dec0
incq %r13
jmp 0x69b5
testw %ax, %ax
je 0x6ceb
callq 0x7ea2
movq 0x572f4(%rip), %r14     # 0x5dec0
testb %al, %al
je 0x6ca6
movq %r14, %rdi
callq 0x7e45
movq %rax, %r14
callq 0x6e1e
testb $0x1, 0x24(%r14)
jne 0x6be4
movq (%r14), %rcx
movq 0x10(%r14), %rax
movq %rax, 0x10(%rsp)
movq %rcx, (%rsp)
cmpq %rcx, %rax
jne 0x6c08
movq 0x8(%r14), %rax
movq %rax, (%rsp)
movq 0x572b1(%rip), %rdi     # 0x5dec0
callq 0x7d4c
movq 0x572a5(%rip), %r14     # 0x5dec0
movswq %ax, %rax
movq %rax, 0x20(%rsp)
leaq (%rax,%rax), %rbp
xorl %r13d, %r13d
movzwl 0x198(%r14), %ebx
movl %ebx, %eax
andl $0x3ff, %eax            # imm = 0x3FF
cmpq %rax, %r13
jae 0x6cae
cmpb $0x0, 0x178(%r14,%r13)
je 0x6c4f
incq %r13
jmp 0x6c2b
movswq 0x7a(%r14,%r13,8), %r12
movq %r12, %rbx
imulq 0x20(%rsp), %rbx
movswq 0x78(%r14,%r13,8), %rax
addq %rax, %rbx
addq %rbx, %rbx
movzwl 0x7c(%r14,%r13,8), %ecx
subl %eax, %ecx
incl %ecx
movswl %cx, %r15d
addl %r15d, %r15d
cmpw 0x7e(%r14,%r13,8), %r12w
jg 0x6c4a
movl %ebx, %ebx
movq 0x10(%rsp), %rax
leaq (%rax,%rbx), %rdi
movq (%rsp), %rax
leaq (%rax,%rbx), %rsi
movq %r15, %rdx
callq 0x20f0
addq %rbp, %rbx
incl %r12d
jmp 0x6c7b
movzwl 0x198(%r14), %ebx
leaq 0x78(%r14), %rdi
andl $0xfc00, %ebx           # imm = 0xFC00
movl $0x120, %edx            # imm = 0x120
xorl %esi, %esi
callq 0x20a0
movw %bx, 0x198(%r14)
movq 0x30(%r14), %rbx
testq %rbx, %rbx
je 0x6ceb
movl 0x1c(%rsp), %edi
callq 0x8031
movl 0x571e4(%rip), %edx     # 0x5dec8
movq %r14, %rdi
movl %eax, %esi
callq *%rbx
callq 0x33543
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq