// File: /workspace/github_c_makefile_star2_O1/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_page.c
// Function: lv_page_sb_refresh
static void lv_page_sb_refresh(lv_obj_t * page)
{
    lv_page_ext_t * ext      = lv_obj_get_ext_attr(page);
    const lv_style_t * style = lv_obj_get_style(page);
    lv_obj_t * scrl          = ext->scrl;
    lv_coord_t size_tmp;
    lv_coord_t scrl_w = lv_obj_get_width(scrl);
    lv_coord_t scrl_h = lv_obj_get_height(scrl);
    lv_coord_t obj_w  = lv_obj_get_width(page);
    lv_coord_t obj_h  = lv_obj_get_height(page);

    /*Always let 'scrollbar width' padding above, under, left and right to the scrollbars
     * else:
     * - horizontal and vertical scrollbars can overlap on the corners
     * - if the page has radius the scrollbar can be out of the radius  */
    lv_coord_t sb_hor_pad = LV_MATH_MAX(ext->sb.style->body.padding.inner, style->body.padding.right);
    lv_coord_t sb_ver_pad = LV_MATH_MAX(ext->sb.style->body.padding.inner, style->body.padding.bottom);

    if(ext->sb.mode == LV_SB_MODE_OFF) return;

    if(ext->sb.mode == LV_SB_MODE_ON) {
        ext->sb.hor_draw = 1;
        ext->sb.ver_draw = 1;
    }

    /*Invalidate the current (old) scrollbar areas*/
    lv_disp_t * disp = lv_obj_get_disp(page);
    lv_area_t sb_area_tmp;
    if(ext->sb.hor_draw != 0) {
        lv_area_copy(&sb_area_tmp, &ext->sb.hor_area);
        sb_area_tmp.x1 += page->coords.x1;
        sb_area_tmp.y1 += page->coords.y1;
        sb_area_tmp.x2 += page->coords.x1;
        sb_area_tmp.y2 += page->coords.y1;
        lv_inv_area(disp, &sb_area_tmp);
    }
    if(ext->sb.ver_draw != 0) {
        lv_area_copy(&sb_area_tmp, &ext->sb.ver_area);
        sb_area_tmp.x1 += page->coords.x1;
        sb_area_tmp.y1 += page->coords.y1;
        sb_area_tmp.x2 += page->coords.x1;
        sb_area_tmp.y2 += page->coords.y1;
        lv_inv_area(disp, &sb_area_tmp);
    }

    if(ext->sb.mode == LV_SB_MODE_DRAG && lv_indev_is_dragging(lv_indev_get_act()) == false) {
        ext->sb.hor_draw = 0;
        ext->sb.ver_draw = 0;
        return;
    }

    /*Full sized horizontal scrollbar*/
    if(scrl_w <= obj_w - style->body.padding.left - style->body.padding.right) {
        lv_area_set_width(&ext->sb.hor_area, obj_w - 2 * sb_hor_pad);
        lv_area_set_pos(&ext->sb.hor_area, sb_hor_pad,
                        obj_h - ext->sb.style->body.padding.inner - ext->sb.style->body.padding.bottom);
        if(ext->sb.mode == LV_SB_MODE_AUTO || ext->sb.mode == LV_SB_MODE_DRAG) ext->sb.hor_draw = 0;
    }
    /*Smaller horizontal scrollbar*/
    else {
        size_tmp =
            (obj_w * (obj_w - (2 * sb_hor_pad))) / (scrl_w + style->body.padding.left + style->body.padding.right);
        if(size_tmp < LV_PAGE_SB_MIN_SIZE) size_tmp = LV_PAGE_SB_MIN_SIZE;
        lv_area_set_width(&ext->sb.hor_area, size_tmp);

        lv_area_set_pos(&ext->sb.hor_area,
                        sb_hor_pad +
                            (-(lv_obj_get_x(scrl) - style->body.padding.left) * (obj_w - size_tmp - 2 * sb_hor_pad)) /
                                (scrl_w + style->body.padding.left + style->body.padding.right - obj_w),
                        obj_h - ext->sb.style->body.padding.inner - ext->sb.style->body.padding.bottom);

        if(ext->sb.mode == LV_SB_MODE_AUTO || ext->sb.mode == LV_SB_MODE_DRAG) ext->sb.hor_draw = 1;
    }

    /*Full sized vertical scroll bar*/
    if(scrl_h <= obj_h - style->body.padding.top - style->body.padding.bottom) {
        lv_area_set_height(&ext->sb.ver_area, obj_h - 2 * sb_ver_pad);
        lv_area_set_pos(&ext->sb.ver_area,
                        obj_w - ext->sb.style->body.padding.inner - ext->sb.style->body.padding.right, sb_ver_pad);
        if(ext->sb.mode == LV_SB_MODE_AUTO || ext->sb.mode == LV_SB_MODE_DRAG) ext->sb.ver_draw = 0;
    }
    /*Smaller vertical scroll bar*/
    else {
        size_tmp =
            (obj_h * (obj_h - (2 * sb_ver_pad))) / (scrl_h + style->body.padding.top + style->body.padding.bottom);
        if(size_tmp < LV_PAGE_SB_MIN_SIZE) size_tmp = LV_PAGE_SB_MIN_SIZE;
        lv_area_set_height(&ext->sb.ver_area, size_tmp);

        lv_area_set_pos(&ext->sb.ver_area,
                        obj_w - ext->sb.style->body.padding.inner - ext->sb.style->body.padding.right,
                        sb_ver_pad + (-(lv_obj_get_y(scrl) - ext->sb.style->body.padding.bottom) *
                                      (obj_h - size_tmp - 2 * sb_ver_pad)) /
                                         (scrl_h + style->body.padding.top + style->body.padding.bottom - obj_h));

        if(ext->sb.mode == LV_SB_MODE_AUTO || ext->sb.mode == LV_SB_MODE_DRAG) ext->sb.ver_draw = 1;
    }

    /*Invalidate the new scrollbar areas*/
    if(ext->sb.hor_draw != 0) {
        lv_area_copy(&sb_area_tmp, &ext->sb.hor_area);
        sb_area_tmp.x1 += page->coords.x1;
        sb_area_tmp.y1 += page->coords.y1;
        sb_area_tmp.x2 += page->coords.x1;
        sb_area_tmp.y2 += page->coords.y1;
        lv_inv_area(disp, &sb_area_tmp);
    }
    if(ext->sb.ver_draw != 0) {
        lv_area_copy(&sb_area_tmp, &ext->sb.ver_area);
        sb_area_tmp.x1 += page->coords.x1;
        sb_area_tmp.y1 += page->coords.y1;
        sb_area_tmp.x2 += page->coords.x1;
        sb_area_tmp.y2 += page->coords.y1;
        lv_inv_area(disp, &sb_area_tmp);
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %rbx
callq 0x6ad8
movq %rax, %r14
movq %rbx, %rdi
callq 0x6697
movq %rax, %r12
movq 0x8(%r14), %r15
movq %r15, %rdi
callq 0x5651
movl %eax, %ebp
movq %r15, %rdi
callq 0x567b
movw %ax, 0x28(%rsp)
movq %rbx, %rdi
callq 0x5651
movl %eax, 0xc(%rsp)
movq %rbx, %rdi
callq 0x567b
movq 0x10(%r14), %rcx
movzwl 0x1e(%rcx), %ecx
movzwl 0x1c(%r12), %r13d
cmpw %r13w, %cx
cmovgl %ecx, %r13d
movzwl 0x18(%r12), %edx
cmpw %dx, %cx
cmovgl %ecx, %edx
movl 0x28(%r14), %esi
movl %esi, %ecx
shrl $0x2, %ecx
andl $0x7, %ecx
je 0x2624a
movl %eax, 0x10(%rsp)
movq %r15, 0x40(%rsp)
movq %rdx, 0x20(%rsp)
cmpl $0x1, %ecx
jne 0x25eee
orb $0x3, %sil
movb %sil, 0x28(%r14)
movq %rbx, %rdi
callq 0x5033
movq %rax, %r15
testb $0x1, 0x28(%r14)
je 0x25f2c
movq 0x18(%r14), %rax
leaq 0x30(%rsp), %rsi
movq %rax, (%rsi)
movl 0x20(%rbx), %ecx
addl %ecx, %eax
movw %ax, (%rsi)
movzwl 0x22(%rbx), %eax
addw %ax, 0x2(%rsi)
addw %cx, 0x4(%rsi)
addw %ax, 0x6(%rsi)
movq %r15, %rdi
callq 0x7184
testb $0x2, 0x28(%r14)
je 0x25f5f
movq 0x20(%r14), %rax
leaq 0x30(%rsp), %rsi
movq %rax, (%rsi)
movl 0x20(%rbx), %ecx
addl %ecx, %eax
movw %ax, (%rsi)
movzwl 0x22(%rbx), %eax
addw %ax, 0x2(%rsi)
addw %cx, 0x4(%rsi)
addw %ax, 0x6(%rsi)
movq %r15, %rdi
callq 0x7184
movb 0x28(%r14), %al
andb $0x1c, %al
cmpb $0x8, %al
jne 0x25f7e
callq 0x3784
movq %rax, %rdi
callq 0x3863
testb %al, %al
je 0x26245
movq %r15, 0x38(%rsp)
movswl %bp, %r15d
movl 0xc(%rsp), %edx
movswl %dx, %ebp
movswl 0x1a(%r12), %eax
movswl 0x1c(%r12), %ecx
addl %eax, %ecx
movl %ebp, %eax
subl %ecx, %eax
cmpl %r15d, %eax
jge 0x26053
movswl %r13w, %eax
movq %rax, 0x50(%rsp)
leal (%rax,%rax), %edx
movl %ebp, %eax
subl %edx, %eax
imull %ebp, %eax
addl %r15d, %ecx
cltd
idivl %ecx
cmpw $0xd, %ax
movl $0xc, %ecx
cmovgel %eax, %ecx
leaq 0x18(%r14), %rdi
movq %rdi, 0x18(%rsp)
movzwl %cx, %esi
movq %rsi, 0x48(%rsp)
callq 0x28609
movq 0x40(%rsp), %rdi
callq 0x4bc6
cwtl
movswl 0x1a(%r12), %ecx
movswl 0x1c(%r12), %esi
addl %ecx, %esi
subl %eax, %ecx
movq 0x50(%rsp), %rax
movq 0x48(%rsp), %rdx
leal (%rdx,%rax,2), %eax
subl %ebp, %r15d
subl %eax, %ebp
imull %ecx, %ebp
addl %r15d, %esi
movl %ebp, %eax
cltd
idivl %esi
addl %r13d, %eax
movq 0x10(%r14), %rcx
movzwl 0x1e(%rcx), %edx
addw 0x18(%rcx), %dx
movl 0x10(%rsp), %ecx
subl %edx, %ecx
movswl %ax, %esi
movswl %cx, %edx
movq 0x18(%rsp), %rdi
callq 0x2861e
movb 0x28(%r14), %al
movl %eax, %ecx
andb $0x18, %cl
cmpb $0x8, %cl
jne 0x2609f
orb $0x1, %al
jmp 0x2609b
leaq 0x18(%r14), %r15
movl %edx, %ecx
subl %r13d, %ecx
subl %r13d, %ecx
movswl %cx, %esi
movq %r15, %rdi
callq 0x28609
movq 0x10(%r14), %rax
movzwl 0x1e(%rax), %ecx
addw 0x18(%rax), %cx
movl 0x10(%rsp), %eax
subl %ecx, %eax
movswl %ax, %edx
movswl %r13w, %esi
movq %r15, %rdi
callq 0x2861e
movb 0x28(%r14), %al
movl %eax, %ecx
andb $0x18, %cl
cmpb $0x8, %cl
jne 0x2609f
andb $-0x12, %al
movb %al, 0x28(%r14)
movswl 0x28(%rsp), %r13d
movl 0x10(%rsp), %edx
movswl %dx, %ebp
movswl 0x16(%r12), %eax
movswl 0x18(%r12), %ecx
addl %eax, %ecx
movl %ebp, %eax
subl %ecx, %eax
cmpl %r13d, %eax
jge 0x26186
movswl 0x20(%rsp), %eax
movq %rax, 0x28(%rsp)
leal (%rax,%rax), %edx
movl %ebp, %eax
subl %edx, %eax
imull %ebp, %eax
addl %r13d, %ecx
cltd
idivl %ecx
cmpw $0xd, %ax
movl $0xc, %ecx
cmovgel %eax, %ecx
movq %r14, %rdi
addq $0x20, %rdi
movq %rdi, 0x10(%rsp)
movzwl %cx, %esi
movq %rsi, 0x18(%rsp)
callq 0x28613
movq 0x10(%r14), %rax
movzwl 0x1e(%rax), %ecx
addw 0x1c(%rax), %cx
movl 0xc(%rsp), %r15d
subl %ecx, %r15d
movq 0x40(%rsp), %rdi
callq 0x4bfe
cwtl
movq 0x10(%r14), %rcx
movswl 0x18(%rcx), %ecx
subl %eax, %ecx
movq 0x28(%rsp), %rax
movq 0x18(%rsp), %rdx
leal (%rdx,%rax,2), %eax
subl %ebp, %r13d
subl %eax, %ebp
imull %ecx, %ebp
movswl 0x16(%r12), %eax
movswl 0x18(%r12), %ecx
addl %eax, %ecx
addl %r13d, %ecx
movl %ebp, %eax
cltd
idivl %ecx
addl 0x20(%rsp), %eax
movswl %ax, %edx
movswl %r15w, %esi
movq 0x10(%rsp), %rdi
callq 0x2861e
movb 0x28(%r14), %al
movl %eax, %ecx
andb $0x18, %cl
cmpb $0x8, %cl
movq 0x38(%rsp), %r15
jne 0x261dd
orb $0x2, %al
jmp 0x261d9
movq %r14, %r15
addq $0x20, %r15
movq 0x20(%rsp), %r12
subl %r12d, %edx
subl %r12d, %edx
movswl %dx, %esi
movq %r15, %rdi
callq 0x28613
movq 0x10(%r14), %rax
movzwl 0x1e(%rax), %ecx
addw 0x1c(%rax), %cx
movl 0xc(%rsp), %eax
subl %ecx, %eax
movswl %ax, %esi
movswl %r12w, %edx
movq %r15, %rdi
callq 0x2861e
movb 0x28(%r14), %al
movl %eax, %ecx
andb $0x18, %cl
cmpb $0x8, %cl
movq 0x38(%rsp), %r15
jne 0x261dd
andb $-0x13, %al
movb %al, 0x28(%r14)
testb $0x1, 0x28(%r14)
je 0x26210
movq 0x18(%r14), %rax
leaq 0x30(%rsp), %rsi
movq %rax, (%rsi)
movl 0x20(%rbx), %ecx
addl %ecx, %eax
movw %ax, (%rsi)
movzwl 0x22(%rbx), %eax
addw %ax, 0x2(%rsi)
addw %cx, 0x4(%rsi)
addw %ax, 0x6(%rsi)
movq %r15, %rdi
callq 0x7184
testb $0x2, 0x28(%r14)
je 0x2624a
movq 0x20(%r14), %rax
leaq 0x30(%rsp), %rsi
movq %rax, (%rsi)
movl 0x20(%rbx), %ecx
addl %ecx, %eax
movw %ax, (%rsi)
movzwl 0x22(%rbx), %eax
addw %ax, 0x2(%rsi)
addw %cx, 0x4(%rsi)
addw %ax, 0x6(%rsi)
movq %r15, %rdi
callq 0x7184
jmp 0x2624a
andb $-0x4, 0x28(%r14)
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq