// File: /workspace/github_c_makefile_star2_O2/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 0x6747
movq %rax, %r14
movq %rbx, %rdi
callq 0x6316
movq %rax, %r12
movq 0x8(%r14), %r15
movq %r15, %rdi
callq 0x5308
movl %eax, %ebp
movq %r15, %rdi
callq 0x5332
movw %ax, 0x30(%rsp)
movq %rbx, %rdi
callq 0x5308
movl %eax, 0xc(%rsp)
movq %rbx, %rdi
callq 0x5332
movl %eax, 0x18(%rsp)
movq 0x10(%r14), %rax
movzwl 0x1e(%rax), %eax
movzwl 0x1c(%r12), %r13d
cmpw %r13w, %ax
cmovgl %eax, %r13d
movzwl 0x18(%r12), %edx
cmpw %dx, %ax
cmovgl %eax, %edx
movl 0x28(%r14), %eax
movl %eax, %ecx
shrl $0x2, %ecx
andl $0x7, %ecx
je 0x2459b
movq %r15, 0x40(%rsp)
movq %rdx, 0x28(%rsp)
cmpl $0x1, %ecx
jne 0x24256
orb $0x3, %al
movb %al, 0x28(%r14)
movq %rbx, %rdi
callq 0x4d17
movq %rax, %r15
movb 0x28(%r14), %al
testb $0x1, %al
je 0x24292
movq 0x20(%rbx), %xmm0
pshufd $0x50, %xmm0, %xmm0     # xmm0 = xmm0[0,0,1,1]
movq 0x18(%r14), %xmm1
paddw %xmm0, %xmm1
leaq 0x38(%rsp), %rsi
movq %xmm1, (%rsi)
movq %r15, %rdi
callq 0x6cff
movb 0x28(%r14), %al
testb $0x2, %al
je 0x242bf
movq 0x20(%rbx), %xmm0
pshufd $0x50, %xmm0, %xmm0     # xmm0 = xmm0[0,0,1,1]
movq 0x20(%r14), %xmm1
paddw %xmm0, %xmm1
leaq 0x38(%rsp), %rsi
movq %xmm1, (%rsi)
movq %r15, %rdi
callq 0x6cff
movb 0x28(%r14), %al
andb $0x1c, %al
cmpb $0x8, %al
jne 0x242da
callq 0x35b3
movq %rax, %rdi
callq 0x3691
testb %al, %al
je 0x24534
movq %r15, 0x10(%rsp)
movq %rbx, 0x20(%rsp)
movswl %bp, %ebx
movl 0xc(%rsp), %edx
movswl %dx, %ebp
movswl 0x1a(%r12), %eax
movswl 0x1c(%r12), %ecx
addl %eax, %ecx
movl %ebp, %eax
subl %ecx, %eax
pushq $0xc
popq %rsi
cmpl %ebx, %eax
jge 0x243ac
movswl %r13w, %eax
movq %rax, 0x48(%rsp)
leal (%rax,%rax), %edx
movl %ebp, %eax
subl %edx, %eax
imull %ebp, %eax
addl %ebx, %ecx
cltd
idivl %ecx
cmpw $0xd, %ax
cmovll %esi, %eax
leaq 0x18(%r14), %rdi
movq %rdi, 0x50(%rsp)
movzwl %ax, %r15d
movl %r15d, %esi
callq 0x26829
movq 0x40(%rsp), %rdi
callq 0x48ca
cwtl
movswl 0x1a(%r12), %ecx
movswl 0x1c(%r12), %esi
addl %ecx, %esi
subl %eax, %ecx
movq 0x48(%rsp), %rax
leal (%r15,%rax,2), %eax
subl %ebp, %ebx
subl %eax, %ebp
imull %ecx, %ebp
addl %ebx, %esi
movl %ebp, %eax
cltd
idivl %esi
addl %r13d, %eax
movq 0x10(%r14), %rcx
movzwl 0x1e(%rcx), %edx
addw 0x18(%rcx), %dx
movl 0x18(%rsp), %r13d
movl %r13d, %ecx
subl %edx, %ecx
movswl %ax, %esi
movswl %cx, %edx
movq 0x50(%rsp), %rdi
callq 0x2683e
movb 0x28(%r14), %al
movl %eax, %ecx
andb $0x18, %cl
cmpb $0x8, %cl
jne 0x243fd
orb $0x1, %al
jmp 0x243f9
leaq 0x18(%r14), %r15
movl %edx, %ecx
subl %r13d, %ecx
subl %r13d, %ecx
movswl %cx, %esi
movq %r15, %rdi
callq 0x26829
movq 0x10(%r14), %rax
movzwl 0x1e(%rax), %ecx
addw 0x18(%rax), %cx
movl 0x18(%rsp), %edi
movl %edi, %eax
subl %ecx, %eax
movswl %ax, %edx
movswl %r13w, %esi
movl %edi, %r13d
movq %r15, %rdi
callq 0x2683e
movb 0x28(%r14), %al
movl %eax, %ecx
andb $0x18, %cl
cmpb $0x8, %cl
jne 0x243fd
andb $-0x12, %al
movb %al, 0x28(%r14)
movswl 0x30(%rsp), %ebx
movswl %r13w, %ebp
movswl 0x16(%r12), %eax
movswl 0x18(%r12), %ecx
addl %eax, %ecx
movl %ebp, %eax
subl %ecx, %eax
cmpl %ebx, %eax
jge 0x244d6
movswl 0x28(%rsp), %eax
movq %rax, 0x18(%rsp)
leal (%rax,%rax), %edx
movl %ebp, %eax
subl %edx, %eax
imull %ebp, %eax
addl %ebx, %ecx
cltd
idivl %ecx
cmpw $0xd, %ax
pushq $0xc
popq %rcx
cmovgel %eax, %ecx
movq %r14, %r15
addq $0x20, %r15
movzwl %cx, %esi
movq %rsi, 0x30(%rsp)
movq %r15, %rdi
callq 0x26833
movq 0x10(%r14), %rax
movzwl 0x1e(%rax), %ecx
addw 0x1c(%rax), %cx
movl 0xc(%rsp), %r13d
subl %ecx, %r13d
movq 0x40(%rsp), %rdi
callq 0x4902
cwtl
movq 0x10(%r14), %rcx
movswl 0x18(%rcx), %ecx
subl %eax, %ecx
movq 0x18(%rsp), %rax
movq 0x30(%rsp), %rdx
leal (%rdx,%rax,2), %eax
subl %ebp, %ebx
subl %eax, %ebp
imull %ecx, %ebp
movswl 0x16(%r12), %eax
movswl 0x18(%r12), %ecx
addl %eax, %ecx
addl %ebx, %ecx
movl %ebp, %eax
cltd
idivl %ecx
addl 0x28(%rsp), %eax
movswl %ax, %edx
movswl %r13w, %esi
movq %r15, %rdi
callq 0x2683e
movb 0x28(%r14), %al
movl %eax, %ecx
andb $0x18, %cl
cmpb $0x8, %cl
jne 0x2453b
orb $0x2, %al
movq 0x20(%rsp), %rbx
jmp 0x24529
movq %r14, %r15
addq $0x20, %r15
movq 0x28(%rsp), %rbx
subl %ebx, %r13d
subl %ebx, %r13d
movswl %r13w, %esi
movq %r15, %rdi
callq 0x26833
movq 0x10(%r14), %rax
movzwl 0x1e(%rax), %ecx
addw 0x1c(%rax), %cx
movl 0xc(%rsp), %eax
subl %ecx, %eax
movswl %ax, %esi
movswl %bx, %edx
movq %r15, %rdi
callq 0x2683e
movb 0x28(%r14), %al
movl %eax, %ecx
andb $0x18, %cl
cmpb $0x8, %cl
movq 0x20(%rsp), %rbx
jne 0x24540
andb $-0x13, %al
movq 0x10(%rsp), %r15
movb %al, 0x28(%r14)
jmp 0x24545
andb $-0x4, 0x28(%r14)
jmp 0x2459b
movq 0x20(%rsp), %rbx
movq 0x10(%rsp), %r15
testb $0x1, %al
je 0x24572
movq 0x20(%rbx), %xmm0
pshufd $0x50, %xmm0, %xmm0     # xmm0 = xmm0[0,0,1,1]
movq 0x18(%r14), %xmm1
paddw %xmm0, %xmm1
leaq 0x38(%rsp), %rsi
movq %xmm1, (%rsi)
movq %r15, %rdi
callq 0x6cff
movb 0x28(%r14), %al
testb $0x2, %al
je 0x2459b
movq 0x20(%rbx), %xmm0
pshufd $0x50, %xmm0, %xmm0     # xmm0 = xmm0[0,0,1,1]
movq 0x20(%r14), %xmm1
paddw %xmm0, %xmm1
leaq 0x38(%rsp), %rsi
movq %xmm1, (%rsi)
movq %r15, %rdi
callq 0x6cff
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq