// File: /workspace/github_c_makefile_star2_O0/OnionIoT[P]lv_example/lvgl/src/lv_core/lv_refr.c
// Function: lv_refr_area
static void lv_refr_area(const lv_area_t * area_p)
{
    /*True double buffering: there are two screen sized buffers. Just redraw directly into a
     * buffer*/
    if(lv_disp_is_true_double_buf(disp_refr)) {
        lv_disp_buf_t * vdb = lv_disp_get_buf(disp_refr);
        vdb->area.x1        = 0;
        vdb->area.x2        = lv_disp_get_hor_res(disp_refr) - 1;
        vdb->area.y1        = 0;
        vdb->area.y2        = lv_disp_get_ver_res(disp_refr) - 1;
        lv_refr_area_part(area_p);
    }
    /*The buffer is smaller: refresh the area in parts*/
    else {
        lv_disp_buf_t * vdb = lv_disp_get_buf(disp_refr);
        /*Calculate the max row num*/
        lv_coord_t w = lv_area_get_width(area_p);
        lv_coord_t h = lv_area_get_height(area_p);
        lv_coord_t y2 =
            area_p->y2 >= lv_disp_get_ver_res(disp_refr) ? y2 = lv_disp_get_ver_res(disp_refr) - 1 : area_p->y2;

        int32_t max_row = (uint32_t)vdb->size / w;

        if(max_row > h) max_row = h;

        /*Round down the lines of VDB if rounding is added*/
        if(disp_refr->driver.rounder_cb) {
            lv_area_t tmp;
            tmp.x1 = 0;
            tmp.x2 = 0;
            tmp.y1 = 0;

            lv_coord_t h_tmp = max_row;
            do {
                tmp.y2 = h_tmp - 1;
                disp_refr->driver.rounder_cb(&disp_refr->driver, &tmp);

                /*If this height fits into `max_row` then fine*/
                if(lv_area_get_height(&tmp) <= max_row) break;

                /*Decrement the height of the area until it fits into `max_row` after rounding*/
                h_tmp--;
            } while(h_tmp > 0);

            if(h_tmp <= 0) {
                LV_LOG_WARN("Can't set VDB height using the round function. (Wrong round_cb or to "
                            "small VDB)");
                return;
            } else {
                max_row = tmp.y2 + 1;
            }
        }

        /*Always use the full row*/
        lv_coord_t row;
        lv_coord_t row_last = 0;
        for(row = area_p->y1; row + max_row - 1 <= y2; row += max_row) {
            /*Calc. the next y coordinates of VDB*/
            vdb->area.x1 = area_p->x1;
            vdb->area.x2 = area_p->x2;
            vdb->area.y1 = row;
            vdb->area.y2 = row + max_row - 1;
            if(vdb->area.y2 > y2) vdb->area.y2 = y2;
            row_last = vdb->area.y2;
            lv_refr_area_part(area_p);
        }

        /*If the last y coordinates are not handled yet ...*/
        if(y2 != row_last) {
            /*Calc. the next y coordinates of VDB*/
            vdb->area.x1 = area_p->x1;
            vdb->area.x2 = area_p->x2;
            vdb->area.y1 = row;
            vdb->area.y2 = y2;

            /*Refresh this part too*/
            lv_refr_area_part(area_p);
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq 0x7dbfd(%rip), %rdi     # 0x88f90
callq 0xdcd0
testb $0x1, %al
jne 0xb39e
jmp 0xb406
movq 0x7dbeb(%rip), %rdi     # 0x88f90
callq 0xdbd0
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movw $0x0, 0x1c(%rax)
movq 0x7dbd1(%rip), %rdi     # 0x88f90
callq 0xd940
cwtl
subl $0x1, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x20(%rax)
movq -0x10(%rbp), %rax
movw $0x0, 0x1e(%rax)
movq 0x7dbac(%rip), %rdi     # 0x88f90
callq 0xd9b0
cwtl
subl $0x1, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, 0x22(%rax)
movq -0x8(%rbp), %rdi
callq 0xb630
jmp 0xb627
movq 0x7db83(%rip), %rdi     # 0x88f90
callq 0xdbd0
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rdi
callq 0xb360
movw %ax, -0x1a(%rbp)
movq -0x8(%rbp), %rdi
callq 0xb710
movw %ax, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movswl 0x6(%rax), %eax
movl %eax, -0x38(%rbp)
movq 0x7db4e(%rip), %rdi     # 0x88f90
callq 0xd9b0
movw %ax, %cx
movl -0x38(%rbp), %eax
movswl %cx, %ecx
cmpl %ecx, %eax
jl 0xb46e
movq 0x7db35(%rip), %rdi     # 0x88f90
callq 0xd9b0
cwtl
subl $0x1, %eax
movw %ax, -0x1e(%rbp)
cwtl
movl %eax, -0x3c(%rbp)
jmp 0xb479
movq -0x8(%rbp), %rax
movswl 0x6(%rax), %eax
movl %eax, -0x3c(%rbp)
movl -0x3c(%rbp), %eax
movw %ax, -0x1e(%rbp)
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
movswl -0x1a(%rbp), %ecx
xorl %edx, %edx
divl %ecx
movl %eax, -0x24(%rbp)
movl -0x24(%rbp), %eax
movswl -0x1c(%rbp), %ecx
cmpl %ecx, %eax
jle 0xb4a4
movswl -0x1c(%rbp), %eax
movl %eax, -0x24(%rbp)
movq 0x7dae5(%rip), %rax     # 0x88f90
cmpq $0x0, 0x20(%rax)
je 0xb52e
movw $0x0, -0x2c(%rbp)
movw $0x0, -0x28(%rbp)
movw $0x0, -0x2a(%rbp)
movl -0x24(%rbp), %eax
movw %ax, -0x2e(%rbp)
movswl -0x2e(%rbp), %eax
subl $0x1, %eax
movw %ax, -0x26(%rbp)
movq 0x7dab3(%rip), %rax     # 0x88f90
movq 0x20(%rax), %rax
movq 0x7daa8(%rip), %rdi     # 0x88f90
leaq -0x2c(%rbp), %rsi
callq *%rax
leaq -0x2c(%rbp), %rdi
callq 0xb710
cwtl
cmpl -0x24(%rbp), %eax
jg 0xb4ff
jmp 0xb514
movw -0x2e(%rbp), %ax
addw $-0x1, %ax
movw %ax, -0x2e(%rbp)
movswl -0x2e(%rbp), %eax
cmpl $0x0, %eax
jg 0xb4cb
movswl -0x2e(%rbp), %eax
cmpl $0x0, %eax
jg 0xb522
jmp 0xb627
movswl -0x26(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0xb52e
movw $0x0, -0x32(%rbp)
movq -0x8(%rbp), %rax
movw 0x2(%rax), %ax
movw %ax, -0x30(%rbp)
movswl -0x30(%rbp), %eax
addl -0x24(%rbp), %eax
subl $0x1, %eax
movswl -0x1e(%rbp), %ecx
cmpl %ecx, %eax
jg 0xb5d9
movq -0x8(%rbp), %rax
movw (%rax), %cx
movq -0x18(%rbp), %rax
movw %cx, 0x1c(%rax)
movq -0x8(%rbp), %rax
movw 0x4(%rax), %cx
movq -0x18(%rbp), %rax
movw %cx, 0x20(%rax)
movw -0x30(%rbp), %cx
movq -0x18(%rbp), %rax
movw %cx, 0x1e(%rax)
movswl -0x30(%rbp), %eax
addl -0x24(%rbp), %eax
subl $0x1, %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, 0x22(%rax)
movq -0x18(%rbp), %rax
movswl 0x22(%rax), %eax
movswl -0x1e(%rbp), %ecx
cmpl %ecx, %eax
jle 0xb5b2
movw -0x1e(%rbp), %cx
movq -0x18(%rbp), %rax
movw %cx, 0x22(%rax)
movq -0x18(%rbp), %rax
movw 0x22(%rax), %ax
movw %ax, -0x32(%rbp)
movq -0x8(%rbp), %rdi
callq 0xb630
movl -0x24(%rbp), %ecx
movswl -0x30(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x30(%rbp)
jmp 0xb540
movswl -0x1e(%rbp), %eax
movswl -0x32(%rbp), %ecx
cmpl %ecx, %eax
je 0xb625
movq -0x8(%rbp), %rax
movw (%rax), %cx
movq -0x18(%rbp), %rax
movw %cx, 0x1c(%rax)
movq -0x8(%rbp), %rax
movw 0x4(%rax), %cx
movq -0x18(%rbp), %rax
movw %cx, 0x20(%rax)
movw -0x30(%rbp), %cx
movq -0x18(%rbp), %rax
movw %cx, 0x1e(%rax)
movw -0x1e(%rbp), %cx
movq -0x18(%rbp), %rax
movw %cx, 0x22(%rax)
movq -0x8(%rbp), %rdi
callq 0xb630
jmp 0xb627
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)