// File: /workspace/github_c_makefile_star2_O3/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 $0x38, %rsp
movq %rdi, %r14
callq 0x87b6
movq 0x10(%r14), %rdi
movq %rdi, 0x59241(%rip)     # 0x5fec0
movzwl 0x198(%rdi), %edx
testl $0x3ff, %edx            # imm = 0x3FF
je 0x710a
movl %eax, 0x24(%rsp)
xorl %ebx, %ebx
leaq 0x8(%rsp), %r14
testl $0x3ff, %edx            # imm = 0x3FF
je 0x6d7b
cmpb $0x0, 0x178(%rdi,%rbx)
jne 0x6d7b
xorl %r12d, %r12d
cmpq %rbx, %r12
je 0x6d63
cmpb $0x0, 0x178(%rdi,%r12)
jne 0x6d63
leaq (%rdi,%rbx,8), %rax
addq $0x78, %rax
leaq (%rdi,%r12,8), %rsi
addq $0x78, %rsi
movq %rax, %rdi
callq 0x28daa
movq 0x591cf(%rip), %rdi     # 0x5fec0
testb %al, %al
je 0x6d63
leaq (%rdi,%rbx,8), %rsi
addq $0x78, %rsi
leaq (%rdi,%r12,8), %rdx
addq $0x78, %rdx
movq %r14, %rdi
callq 0x28d63
movq %r14, %rdi
callq 0x28d09
movl %eax, %ebp
movq 0x591a2(%rip), %rax     # 0x5fec0
leaq (%rax,%rbx,8), %rdi
addq $0x78, %rdi
callq 0x28d09
movl %eax, %r15d
movq 0x5918b(%rip), %rax     # 0x5fec0
leaq (%rax,%r12,8), %rdi
addq $0x78, %rdi
callq 0x28d09
addl %r15d, %eax
movq 0x59174(%rip), %rdi     # 0x5fec0
cmpl %eax, %ebp
jae 0x6d63
movq 0x8(%rsp), %rax
movq %rax, 0x78(%rdi,%rbx,8)
movb $0x1, 0x178(%rdi,%r12)
incq %r12
movzwl 0x198(%rdi), %eax
andl $0x3ff, %eax            # imm = 0x3FF
cmpq %rax, %r12
jb 0x6cba
incq %rbx
movzwl 0x198(%rdi), %edx
movl %edx, %ecx
andl $0x3ff, %ecx            # imm = 0x3FF
cmpq %rcx, %rbx
jb 0x6c9d
movl $0x0, 0x59128(%rip)     # 0x5fec8
testw %cx, %cx
je 0x715c
xorl %r15d, %r15d
xorl %ebx, %ebx
cmpb $0x0, 0x178(%rdi,%rbx)
jne 0x6fe1
leaq (%rdi,%rbx,8), %r14
addq $0x78, %r14
callq 0x8635
movl %eax, %ebp
movq 0x590ee(%rip), %rdi     # 0x5fec0
callq 0x85d8
movq %rax, %r12
testb %bpl, %bpl
je 0x6e1b
movw %r15w, 0x1c(%r12)
movq 0x590d4(%rip), %rdi     # 0x5fec0
callq 0x84dc
decl %eax
movw %ax, 0x20(%r12)
movw %r15w, 0x1e(%r12)
movq 0x590ba(%rip), %rdi     # 0x5fec0
callq 0x84fe
decl %eax
movw %ax, 0x22(%r12)
movq %r14, %rdi
jmp 0x6fb4
movq %rbx, 0x10(%rsp)
movzwl 0x4(%r14), %r13d
movzwl 0x6(%r14), %ebp
subw (%r14), %r13w
movq %r14, %rbx
movl %ebp, %r14d
subw 0x2(%rbx), %r14w
movq 0x59080(%rip), %rdi     # 0x5fec0
callq 0x84fe
cmpw %ax, %bp
movq %rbx, 0x18(%rsp)
jge 0x6e55
movzwl 0x6(%rbx), %esi
jmp 0x6e65
movq 0x59064(%rip), %rdi     # 0x5fec0
callq 0x84fe
movl %eax, %esi
decl %esi
incl %r13d
incl %r14d
movl 0x18(%r12), %eax
movswl %r13w, %ecx
xorl %edx, %edx
divl %ecx
movswl %r14w, %ebx
cmpl %ebx, %eax
cmovll %eax, %ebx
movq 0x59038(%rip), %rax     # 0x5fec0
cmpq $0x0, 0x20(%rax)
je 0x6f05
movl %esi, %r15d
movl $0x0, 0x8(%rsp)
movw $0x0, 0xc(%rsp)
movl %ebx, %r14d
leal -0x1(%r14), %ebp
movw %bp, 0xe(%rsp)
movq 0x5900c(%rip), %rdi     # 0x5fec0
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 0x6ee9
movl %ebp, %r14d
testw %bp, %bp
jg 0x6ea4
movq 0x10(%rsp), %rbx
xorl %r15d, %r15d
jmp 0x6fb9
testw %r14w, %r14w
movq 0x10(%rsp), %rbx
movl %r15d, %esi
movl $0x0, %r15d
jle 0x6fb9
incl %eax
movl %eax, %ebx
movq 0x18(%rsp), %rax
movswl 0x2(%rax), %eax
movswl %si, %r8d
leal (%rbx,%rax), %ecx
decl %ecx
cmpl %r8d, %ecx
jle 0x6f21
xorl %r15d, %r15d
jmp 0x6f7f
movl %eax, %ebp
addl %ebx, %ebp
movq 0x18(%rsp), %rdi
movzwl (%rdi), %edx
movw %dx, 0x1c(%r12)
movzwl 0x4(%rdi), %edx
movw %dx, 0x20(%r12)
movw %ax, 0x1e(%r12)
movswl %cx, %eax
cmpl %r8d, %eax
cmovgl %esi, %ecx
movl %ecx, %r15d
movw %cx, 0x22(%r12)
movl %r8d, %r13d
movq %r12, %r14
movl %esi, %r12d
callq 0x7309
movl %r13d, %r8d
movl %r12d, %esi
movq %r14, %r12
movl %ebp, %eax
movswl %bp, %edx
leal (%rdx,%rbx), %ecx
decl %ecx
movl %edx, %ebp
addl %ebx, %ebp
cmpl %r13d, %ecx
jle 0x6f25
cmpw %r15w, %si
movl $0x0, %r15d
movq 0x10(%rsp), %rbx
je 0x6fb9
movq 0x18(%rsp), %rdi
movzwl (%rdi), %ecx
movw %cx, 0x1c(%r12)
movzwl 0x4(%rdi), %ecx
movw %cx, 0x20(%r12)
movw %ax, 0x1e(%r12)
movw %si, 0x22(%r12)
callq 0x7309
movq 0x58f00(%rip), %rdi     # 0x5fec0
cmpq $0x0, 0x30(%rdi)
je 0x6fe1
leaq (%rdi,%rbx,8), %rdi
addq $0x78, %rdi
callq 0x28d09
addl %eax, 0x58eee(%rip)     # 0x5fec8
movq 0x58edf(%rip), %rdi     # 0x5fec0
incq %rbx
movzwl 0x198(%rdi), %eax
andl $0x3ff, %eax            # imm = 0x3FF
cmpq %rax, %rbx
jb 0x6dae
testw %ax, %ax
je 0x715c
callq 0x8635
movq 0x58eb2(%rip), %rbp     # 0x5fec0
testb %al, %al
je 0x7116
movq %rbp, %rdi
callq 0x85d8
movq %rax, %r14
callq 0x72a3
testb $0x1, 0x24(%r14)
jne 0x7026
movq (%r14), %r12
movq 0x10(%r14), %rbx
cmpq %r12, %rbx
jne 0x703d
movq 0x8(%r14), %r12
movq 0x58e7c(%rip), %rdi     # 0x5fec0
callq 0x84dc
movq 0x58e70(%rip), %rbp     # 0x5fec0
movzwl 0x198(%rbp), %r15d
testl $0x3ff, %r15d           # imm = 0x3FF
je 0x711e
movq %r12, 0x30(%rsp)
movq %rbx, 0x10(%rsp)
movswq %ax, %rax
movq %rax, 0x28(%rsp)
leaq (%rax,%rax), %r14
xorl %r13d, %r13d
cmpb $0x0, 0x178(%rbp,%r13)
jne 0x70f4
movzwl 0x7a(%rbp,%r13,8), %ebx
cmpw 0x7e(%rbp,%r13,8), %bx
jg 0x70f4
movswq %bx, %r12
movzwl 0x7c(%rbp,%r13,8), %eax
movswq 0x78(%rbp,%r13,8), %rcx
subl %ecx, %eax
incl %eax
cwtl
addl %eax, %eax
movq %rax, 0x18(%rsp)
imulq 0x28(%rsp), %r12
addq %rcx, %r12
addq %r12, %r12
movq 0x30(%rsp), %r15
movl %r12d, %r12d
movq 0x10(%rsp), %rax
leaq (%rax,%r12), %rdi
leaq (%r15,%r12), %rsi
movq 0x18(%rsp), %rdx
callq 0x20f0
addq %r14, %r12
incl %ebx
cmpw 0x7e(%rbp,%r13,8), %bx
jle 0x70c5
movzwl 0x198(%rbp), %r15d
incq %r13
movl %r15d, %eax
andl $0x3ff, %eax            # imm = 0x3FF
cmpq %rax, %r13
jb 0x707f
jmp 0x711e
movl $0x0, 0x58db4(%rip)     # 0x5fec8
jmp 0x715c
movzwl 0x198(%rbp), %r15d
leaq 0x78(%rbp), %rdi
andl $0xfc00, %r15d          # imm = 0xFC00
movl $0x120, %edx            # imm = 0x120
xorl %esi, %esi
callq 0x20a0
movw %r15w, 0x198(%rbp)
movq 0x30(%rbp), %rbx
testq %rbx, %rbx
je 0x715c
movl 0x24(%rsp), %edi
callq 0x87cd
movl 0x58d73(%rip), %edx     # 0x5fec8
movq %rbp, %rdi
movl %eax, %esi
callq *%rbx
callq 0x367c3
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq