// File: /workspace/github_c_makefile_star2_O1/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_page.c
// Function: lv_page_focus
void lv_page_focus(lv_obj_t * page, const lv_obj_t * obj, lv_anim_enable_t anim_en)
{
    lv_page_ext_t * ext = lv_obj_get_ext_attr(page);

#if LV_USE_ANIMATION
    /* Be sure there is no position changing animation in progress
     * because it can overide the current changes*/
    lv_anim_del(page, (lv_anim_exec_xcb_t)lv_obj_set_x);
    lv_anim_del(page, (lv_anim_exec_xcb_t)lv_obj_set_y);
    lv_anim_del(ext->scrl, (lv_anim_exec_xcb_t)lv_obj_set_x);
    lv_anim_del(ext->scrl, (lv_anim_exec_xcb_t)lv_obj_set_y);
#endif

    const lv_style_t * style      = lv_page_get_style(page, LV_PAGE_STYLE_BG);
    const lv_style_t * style_scrl = lv_page_get_style(page, LV_PAGE_STYLE_SCRL);

    /*If obj is higher then the page focus where the "error" is smaller*/
    lv_coord_t obj_y      = obj->coords.y1 - ext->scrl->coords.y1;
    lv_coord_t obj_h      = lv_obj_get_height(obj);
    lv_coord_t scrlable_y = lv_obj_get_y(ext->scrl);
    lv_coord_t page_h     = lv_obj_get_height(page);

    lv_coord_t top_err = -(scrlable_y + obj_y);
    lv_coord_t bot_err = scrlable_y + obj_y + obj_h - page_h;

    /*Out of the page on the top*/
    if((obj_h <= page_h && top_err > 0) || (obj_h > page_h && top_err < bot_err)) {
        /*Calculate a new position and let some space above*/
        scrlable_y = -(obj_y - style_scrl->body.padding.top - style->body.padding.top);
        scrlable_y += style_scrl->body.padding.top;
    }
    /*Out of the page on the bottom*/
    else if((obj_h <= page_h && bot_err > 0) || (obj_h > page_h && top_err >= bot_err)) {
        /*Calculate a new position and let some space below*/
        scrlable_y = -(obj_y + style_scrl->body.padding.bottom + style->body.padding.bottom);
        scrlable_y -= style_scrl->body.padding.bottom;
        scrlable_y += page_h - obj_h;
    }

    /*If obj is wider then the page focus where the "error" is smaller*/
    lv_coord_t obj_x      = obj->coords.x1 - ext->scrl->coords.x1;
    lv_coord_t obj_w      = lv_obj_get_width(obj);
    lv_coord_t scrlable_x = lv_obj_get_x(ext->scrl);
    lv_coord_t page_w     = lv_obj_get_width(page);

    lv_coord_t left_err  = -(scrlable_x + obj_x);
    lv_coord_t right_err = scrlable_x + obj_x + obj_w - page_w;

    /*Out of the page on the left*/
    if((obj_w <= page_w && left_err > 0) || (obj_w > page_w && left_err < right_err)) {
        /*Calculate a new position and let some space above*/
        scrlable_x = -(obj_x - style_scrl->body.padding.left - style->body.padding.left);
        scrlable_x += style_scrl->body.padding.left;
    }
    /*Out of the page on the rigth*/
    else if((obj_w <= page_w && right_err > 0) || (obj_w > page_w && left_err >= right_err)) {
        /*Calculate a new position and let some space below*/
        scrlable_x = -(obj_x + style_scrl->body.padding.right + style->body.padding.right);
        scrlable_x -= style_scrl->body.padding.right;
        scrlable_x += page_w - obj_w;
    }

    if(anim_en == LV_ANIM_OFF || lv_page_get_anim_time(page) == 0) {
        lv_obj_set_y(ext->scrl, scrlable_y);
        lv_obj_set_x(ext->scrl, scrlable_x);
    } else {
#if LV_USE_ANIMATION
        lv_anim_t a;
        a.act_time = 0;
        a.start    = lv_obj_get_y(ext->scrl);
        a.end      = scrlable_y;
        a.time     = lv_page_get_anim_time(page);
        a.ready_cb = NULL;
        a.playback = 0;
        a.repeat   = 0;
        a.var      = ext->scrl;
        a.path_cb  = lv_anim_path_linear;
        a.exec_cb  = (lv_anim_exec_xcb_t)lv_obj_set_y;
        lv_anim_create(&a);

        a.start   = lv_obj_get_x(ext->scrl);
        a.end     = scrlable_x;
        a.exec_cb = (lv_anim_exec_xcb_t)lv_obj_set_x;
        lv_anim_create(&a);
#endif
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movl %edx, 0x1c(%rsp)
movq %rsi, %rbp
movq %rdi, %r15
callq 0x6ad8
movq %rax, %rbx
leaq -0x21115(%rip), %r14    # 0x54c3
movq %r15, %rdi
movq %r14, %rsi
callq 0x295b1
leaq -0x210e9(%rip), %r12    # 0x5501
movq %r15, %rdi
movq %r12, %rsi
callq 0x295b1
movq 0x8(%rbx), %rdi
movq %r14, %rsi
callq 0x295b1
movq 0x8(%rbx), %rdi
movq %r12, %rsi
callq 0x295b1
movq %r15, %rdi
xorl %esi, %esi
callq 0x25ddf
movq %rax, 0x10(%rsp)
movq %r15, %rdi
movl $0x1, %esi
callq 0x25ddf
movq %rax, 0x8(%rsp)
movzwl 0x22(%rbp), %r12d
movq 0x8(%rbx), %rax
subw 0x22(%rax), %r12w
movq %rbp, %rdi
callq 0x567b
movl %eax, %r14d
movq 0x8(%rbx), %rdi
callq 0x4bfe
movl %eax, %r13d
movq %r15, %rdi
callq 0x567b
leal (%r12,%r13), %esi
movl %r14d, %edx
subw %ax, %dx
movl %esi, %ecx
negl %ecx
movswl %cx, %ecx
cmpw %ax, %r14w
jg 0x26676
testl %ecx, %ecx
jg 0x2668d
addl %esi, %edx
movswl %dx, %edx
cmpw %ax, %r14w
jle 0x267f7
cmpl %edx, %ecx
jge 0x267f7
movq 0x8(%rsp), %rax
movzwl 0x16(%rax), %eax
movq 0x10(%rsp), %rcx
movzwl 0x16(%rcx), %ecx
subl %r12d, %ecx
leal (%rcx,%rax,2), %r13d
movzwl 0x20(%rbp), %r12d
movq 0x8(%rbx), %rax
subw 0x20(%rax), %r12w
movq %rbp, %rdi
callq 0x5651
movl %eax, %r14d
movq 0x8(%rbx), %rdi
callq 0x4bc6
movl %eax, %ebp
movq %r15, %rdi
callq 0x5651
leal (%r12,%rbp), %esi
movl %r14d, %edx
subw %ax, %dx
movl %esi, %ecx
negl %ecx
movswl %cx, %ecx
cmpw %ax, %r14w
jg 0x266ed
testl %ecx, %ecx
jg 0x26704
addl %esi, %edx
movswl %dx, %edx
cmpw %ax, %r14w
jle 0x26843
cmpl %edx, %ecx
jge 0x26843
movq 0x8(%rsp), %rax
movzwl 0x1a(%rax), %eax
movq 0x10(%rsp), %rcx
movzwl 0x1a(%rcx), %ecx
subl %r12d, %ecx
leal (%rcx,%rax,2), %ebp
cmpb $0x0, 0x1c(%rsp)
je 0x267d0
movq %r15, %rdi
callq 0x26367
testw %ax, %ax
je 0x267d0
leaq 0x20(%rsp), %r14
movw $0x0, 0x2a(%r14)
movq 0x8(%rbx), %rdi
callq 0x4bfe
cwtl
movl %eax, 0x20(%r14)
movswl %r13w, %eax
movl %eax, 0x24(%r14)
movq %r15, %rdi
callq 0x26367
movw %ax, 0x28(%r14)
movq $0x0, 0x18(%r14)
andb $-0x4, 0x30(%r14)
movq 0x8(%rbx), %rax
movq %rax, (%r14)
leaq 0x2d73(%rip), %rax      # 0x294f5
movq %rax, 0x10(%r14)
leaq -0x2128c(%rip), %rax    # 0x5501
movq %rax, 0x8(%r14)
movq %r14, %rdi
callq 0x29521
movq 0x8(%rbx), %rdi
callq 0x4bc6
cwtl
movl %eax, 0x20(%r14)
movswl %bp, %eax
movl %eax, 0x24(%r14)
leaq -0x212f2(%rip), %rax    # 0x54c3
movq %rax, 0x8(%r14)
movq %r14, %rdi
callq 0x29521
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x8(%rbx), %rdi
movswl %r13w, %esi
callq 0x5501
movq 0x8(%rbx), %rdi
movswl %bp, %esi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x54c3
cmpl %edx, %ecx
setl %cl
cmpw %ax, %r14w
setle %sil
setg %dil
testw %dx, %dx
setle %dl
orb %dil, %dl
cmpb $0x1, %dl
jne 0x2681f
orb %cl, %sil
jne 0x266a6
addl %r12d, %r14d
movq 0x10(%rsp), %rcx
addw 0x18(%rcx), %r14w
movq 0x8(%rsp), %rcx
movzwl 0x18(%rcx), %ecx
leal (%r14,%rcx,2), %ecx
subl %ecx, %eax
movl %eax, %r13d
jmp 0x266a6
cmpl %edx, %ecx
setl %cl
cmpw %ax, %r14w
setle %sil
setg %dil
testw %dx, %dx
setle %dl
orb %dil, %dl
cmpb $0x1, %dl
jne 0x2686b
orb %cl, %sil
jne 0x2671c
addl %r12d, %r14d
movq 0x10(%rsp), %rcx
addw 0x1c(%rcx), %r14w
movq 0x8(%rsp), %rcx
movzwl 0x1c(%rcx), %ecx
leal (%r14,%rcx,2), %ecx
subl %ecx, %eax
movl %eax, %ebp
jmp 0x2671c