// File: /workspace/github_c_makefile_star2_O3/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_tabview.c
// Function: tabpage_press_lost_handler
static void tabpage_press_lost_handler(lv_obj_t * tabview, lv_obj_t * tabpage)
{
    lv_tabview_ext_t * ext = lv_obj_get_ext_attr(tabview);
    ext->drag_hor          = 0;
    ext->draging           = 0;
    ext->scroll_ver        = 0;

    lv_obj_set_drag(lv_page_get_scrl(tabpage), true);

    lv_indev_t * indev = lv_indev_get_act();
    lv_point_t point_act;
    lv_indev_get_point(indev, &point_act);
    lv_point_t vect;
    lv_indev_get_vect(indev, &vect);
    lv_coord_t x_predict = 0;

    while(vect.x != 0) {
        x_predict += vect.x;
        vect.x = vect.x * (100 - LV_INDEV_DEF_DRAG_THROW) / 100;
    }

    lv_coord_t page_x1  = tabpage->coords.x1 - tabview->coords.x1 + x_predict;
    lv_coord_t page_x2  = page_x1 + lv_obj_get_width(tabpage);
    lv_coord_t treshold = lv_obj_get_width(tabview) / 2;

    int16_t tab_cur = ext->tab_cur;
    if(page_x1 > treshold) {
            if(lv_obj_get_base_dir(tabview) == LV_BIDI_DIR_RTL) tab_cur++;
            else tab_cur--;
    } else if(page_x2 < treshold) {
            if(lv_obj_get_base_dir(tabview) == LV_BIDI_DIR_RTL) tab_cur--;
            else tab_cur++;
    }

    if(tab_cur > ext->tab_cnt - 1) tab_cur = ext->tab_cnt - 1;
    else if(tab_cur < 0) tab_cur = 0;

    uint32_t id_prev = lv_tabview_get_tab_act(tabview);
    lv_tabview_set_tab_act(tabview, tab_cur, LV_ANIM_ON);
    uint32_t id_new = lv_tabview_get_tab_act(tabview);

    lv_res_t res = LV_RES_OK;
    if(id_prev != id_new) res = lv_event_send(tabview, LV_EVENT_VALUE_CHANGED, &id_new);

    if(res != LV_RES_OK) return;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r15
movq %rdi, %rbx
callq 0x6af7
movq %rax, %r14
andb $-0xf, 0x2a(%rax)
movq %r15, %rdi
callq 0x2695e
movq %rax, %rdi
movl $0x1, %esi
callq 0x606c
callq 0x378a
movq %rax, %r12
leaq 0x14(%rsp), %rsi
movq %rax, %rdi
callq 0x3838
leaq 0x10(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x3884
movzwl (%r13), %eax
xorl %r12d, %r12d
testw %ax, %ax
je 0x12455
movswl %ax, %ecx
addl %eax, %r12d
shll $0x4, %ecx
leal (%rcx,%rcx,4), %eax
cltq
imulq $0x51eb851f, %rax, %rax # imm = 0x51EB851F
movq %rax, %rdx
shrq $0x3f, %rdx
shrq $0x25, %rax
addl %edx, %eax
leal (%rcx,%rcx,4), %ecx
addl $0x63, %ecx
cmpl $0xc6, %ecx
ja 0x12420
movw %ax, 0x10(%rsp)
movzwl 0x20(%r15), %eax
subw 0x20(%rbx), %ax
addl %eax, %r12d
movq %r15, %rdi
callq 0x566d
movl %eax, %ebp
movq %rbx, %rdi
callq 0x566d
movzwl %ax, %ecx
shrl $0xf, %ecx
addl %eax, %ecx
movswl %cx, %eax
shrl %eax
movzwl 0x24(%r14), %r15d
cmpw %ax, %r12w
jle 0x1249c
movq %rbx, %rdi
callq 0x4ab2
cmpb $0x1, %al
jne 0x124b1
incl %r15d
jmp 0x124b4
addl %ebp, %r12d
cmpw %ax, %r12w
jge 0x124b4
movq %rbx, %rdi
callq 0x4ab2
cmpb $0x1, %al
jne 0x12497
decl %r15d
movswl %r15w, %eax
movzwl 0x26(%r14), %r14d
cmpl %eax, %r14d
jle 0x124cf
xorl %r14d, %r14d
testw %r15w, %r15w
cmovgl %r15d, %r14d
jmp 0x124d2
decl %r14d
movq %rbx, %rdi
callq 0x1210d
movl %eax, %ebp
movzwl %r14w, %esi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x11c83
movq %rbx, %rdi
callq 0x1210d
movzwl %ax, %eax
movl %eax, 0xc(%rsp)
cmpw %ax, %bp
je 0x12513
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
movl $0xe, %esi
callq 0x5018
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop