// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x80, %rsp
movb %dl, %al
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movb %al, -0x11(%rbp)
movq -0x8(%rbp), %rdi
callq 0xa8f0
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x36e40(%rip), %rsi    # 0x80b0
callq 0x44560
movq -0x8(%rbp), %rdi
leaq -0x36de0(%rip), %rsi    # 0x8120
callq 0x44560
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x36e64(%rip), %rsi    # 0x80b0
callq 0x44560
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
leaq -0x36e08(%rip), %rsi    # 0x8120
callq 0x44560
movq -0x8(%rbp), %rdi
xorl %esi, %esi
callq 0x3e100
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x3e100
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movswl 0x22(%rax), %eax
movq -0x20(%rbp), %rcx
movq 0x8(%rcx), %rcx
movswl 0x22(%rcx), %ecx
subl %ecx, %eax
movw %ax, -0x32(%rbp)
movq -0x10(%rbp), %rdi
callq 0x8350
movw %ax, -0x34(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x73c0
movw %ax, -0x36(%rbp)
movq -0x8(%rbp), %rdi
callq 0x8350
movw %ax, -0x38(%rbp)
movswl -0x36(%rbp), %ecx
movswl -0x32(%rbp), %eax
addl %eax, %ecx
xorl %eax, %eax
subl %ecx, %eax
movw %ax, -0x3a(%rbp)
movswl -0x36(%rbp), %eax
movswl -0x32(%rbp), %ecx
addl %ecx, %eax
movswl -0x34(%rbp), %ecx
addl %ecx, %eax
movswl -0x38(%rbp), %ecx
subl %ecx, %eax
movw %ax, -0x3c(%rbp)
movswl -0x34(%rbp), %eax
movswl -0x38(%rbp), %ecx
cmpl %ecx, %eax
jg 0x3efd4
movswl -0x3a(%rbp), %eax
cmpl $0x0, %eax
jg 0x3efec
movswl -0x34(%rbp), %eax
movswl -0x38(%rbp), %ecx
cmpl %ecx, %eax
jle 0x3f020
movswl -0x3a(%rbp), %eax
movswl -0x3c(%rbp), %ecx
cmpl %ecx, %eax
jge 0x3f020
movswl -0x32(%rbp), %ecx
movq -0x30(%rbp), %rax
movswl 0x16(%rax), %eax
subl %eax, %ecx
movq -0x28(%rbp), %rax
movswl 0x16(%rax), %eax
subl %eax, %ecx
xorl %eax, %eax
subl %ecx, %eax
movw %ax, -0x36(%rbp)
movq -0x30(%rbp), %rax
movswl 0x16(%rax), %ecx
movswl -0x36(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x36(%rbp)
jmp 0x3f095
movswl -0x34(%rbp), %eax
movswl -0x38(%rbp), %ecx
cmpl %ecx, %eax
jg 0x3f035
movswl -0x3c(%rbp), %eax
cmpl $0x0, %eax
jg 0x3f04d
movswl -0x34(%rbp), %eax
movswl -0x38(%rbp), %ecx
cmpl %ecx, %eax
jle 0x3f093
movswl -0x3a(%rbp), %eax
movswl -0x3c(%rbp), %ecx
cmpl %ecx, %eax
jl 0x3f093
movswl -0x32(%rbp), %ecx
movq -0x30(%rbp), %rax
movswl 0x18(%rax), %eax
addl %eax, %ecx
movq -0x28(%rbp), %rax
movswl 0x18(%rax), %eax
addl %eax, %ecx
xorl %eax, %eax
subl %ecx, %eax
movw %ax, -0x36(%rbp)
movq -0x30(%rbp), %rax
movswl 0x18(%rax), %ecx
movswl -0x36(%rbp), %eax
subl %ecx, %eax
movw %ax, -0x36(%rbp)
movswl -0x38(%rbp), %ecx
movswl -0x34(%rbp), %eax
subl %eax, %ecx
movswl -0x36(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x36(%rbp)
jmp 0x3f095
movq -0x10(%rbp), %rax
movswl 0x20(%rax), %eax
movq -0x20(%rbp), %rcx
movq 0x8(%rcx), %rcx
movswl 0x20(%rcx), %ecx
subl %ecx, %eax
movw %ax, -0x3e(%rbp)
movq -0x10(%rbp), %rdi
callq 0x8310
movw %ax, -0x40(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x7350
movw %ax, -0x42(%rbp)
movq -0x8(%rbp), %rdi
callq 0x8310
movw %ax, -0x44(%rbp)
movswl -0x42(%rbp), %ecx
movswl -0x3e(%rbp), %eax
addl %eax, %ecx
xorl %eax, %eax
subl %ecx, %eax
movw %ax, -0x46(%rbp)
movswl -0x42(%rbp), %eax
movswl -0x3e(%rbp), %ecx
addl %ecx, %eax
movswl -0x40(%rbp), %ecx
addl %ecx, %eax
movswl -0x44(%rbp), %ecx
subl %ecx, %eax
movw %ax, -0x48(%rbp)
movswl -0x40(%rbp), %eax
movswl -0x44(%rbp), %ecx
cmpl %ecx, %eax
jg 0x3f11b
movswl -0x46(%rbp), %eax
cmpl $0x0, %eax
jg 0x3f133
movswl -0x40(%rbp), %eax
movswl -0x44(%rbp), %ecx
cmpl %ecx, %eax
jle 0x3f167
movswl -0x46(%rbp), %eax
movswl -0x48(%rbp), %ecx
cmpl %ecx, %eax
jge 0x3f167
movswl -0x3e(%rbp), %ecx
movq -0x30(%rbp), %rax
movswl 0x1a(%rax), %eax
subl %eax, %ecx
movq -0x28(%rbp), %rax
movswl 0x1a(%rax), %eax
subl %eax, %ecx
xorl %eax, %eax
subl %ecx, %eax
movw %ax, -0x42(%rbp)
movq -0x30(%rbp), %rax
movswl 0x1a(%rax), %ecx
movswl -0x42(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x42(%rbp)
jmp 0x3f1dc
movswl -0x40(%rbp), %eax
movswl -0x44(%rbp), %ecx
cmpl %ecx, %eax
jg 0x3f17c
movswl -0x48(%rbp), %eax
cmpl $0x0, %eax
jg 0x3f194
movswl -0x40(%rbp), %eax
movswl -0x44(%rbp), %ecx
cmpl %ecx, %eax
jle 0x3f1da
movswl -0x46(%rbp), %eax
movswl -0x48(%rbp), %ecx
cmpl %ecx, %eax
jl 0x3f1da
movswl -0x3e(%rbp), %ecx
movq -0x30(%rbp), %rax
movswl 0x1c(%rax), %eax
addl %eax, %ecx
movq -0x28(%rbp), %rax
movswl 0x1c(%rax), %eax
addl %eax, %ecx
xorl %eax, %eax
subl %ecx, %eax
movw %ax, -0x42(%rbp)
movq -0x30(%rbp), %rax
movswl 0x1c(%rax), %ecx
movswl -0x42(%rbp), %eax
subl %ecx, %eax
movw %ax, -0x42(%rbp)
movswl -0x44(%rbp), %ecx
movswl -0x40(%rbp), %eax
subl %eax, %ecx
movswl -0x42(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x42(%rbp)
jmp 0x3f1dc
movzbl -0x11(%rbp), %eax
cmpl $0x0, %eax
je 0x3f1f6
movq -0x8(%rbp), %rdi
callq 0x3eb00
movzwl %ax, %eax
cmpl $0x0, %eax
jne 0x3f21d
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
movswl -0x36(%rbp), %esi
callq 0x8120
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
movswl -0x42(%rbp), %esi
callq 0x80b0
jmp 0x3f2bb
movw $0x0, -0x56(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x73c0
cwtl
movl %eax, -0x60(%rbp)
movswl -0x36(%rbp), %eax
movl %eax, -0x5c(%rbp)
movq -0x8(%rbp), %rdi
callq 0x3eb00
movw %ax, -0x58(%rbp)
movq $0x0, -0x68(%rbp)
movb -0x50(%rbp), %al
andb $-0x2, %al
orb $0x0, %al
movb %al, -0x50(%rbp)
movb -0x50(%rbp), %al
andb $-0x3, %al
orb $0x0, %al
movb %al, -0x50(%rbp)
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x80(%rbp)
leaq 0x51b9(%rip), %rax      # 0x44430
movq %rax, -0x70(%rbp)
leaq -0x37162(%rip), %rax    # 0x8120
movq %rax, -0x78(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x444a0
movq -0x20(%rbp), %rax
movq 0x8(%rax), %rdi
callq 0x7350
cwtl
movl %eax, -0x60(%rbp)
movswl -0x42(%rbp), %eax
movl %eax, -0x5c(%rbp)
leaq -0x371fe(%rip), %rax    # 0x80b0
movq %rax, -0x78(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x444a0
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)