// File: /workspace/github_c_makefile_star2_O2/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 0x6747
movq %rax, %r14
andb $-0xf, 0x2a(%rax)
movq %r15, %rdi
callq 0x245d9
pushq $0x1
popq %rsi
movq %rax, %rdi
callq 0x5ce4
callq 0x35b3
movq %rax, %r12
leaq 0x14(%rsp), %rsi
movq %rax, %rdi
callq 0x3661
leaq 0x10(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x36ac
xorl %r12d, %r12d
movzwl (%r13), %eax
pushq $0x64
popq %rcx
testw %ax, %ax
je 0x116c2
movswl %ax, %edx
addl %eax, %r12d
imull $0x50, %edx, %eax
cltd
idivl %ecx
movw %ax, 0x10(%rsp)
jmp 0x116aa
movzwl 0x20(%r15), %eax
subw 0x20(%rbx), %ax
addl %eax, %r12d
movq %r15, %rdi
callq 0x5308
movl %eax, %ebp
movq %rbx, %rdi
callq 0x5308
movw $0x2, %cx
cwtd
idivw %cx
movzwl 0x24(%r14), %r15d
cmpw %ax, %r12w
jle 0x11705
movq %rbx, %rdi
callq 0x47b9
cmpb $0x1, %al
jne 0x1171a
incl %r15d
jmp 0x1171d
addl %ebp, %r12d
cmpw %ax, %r12w
jge 0x1171d
movq %rbx, %rdi
callq 0x47b9
cmpb $0x1, %al
jne 0x11700
decl %r15d
movswl %r15w, %eax
movzwl 0x26(%r14), %r14d
cmpl %eax, %r14d
jle 0x11738
xorl %r14d, %r14d
testw %r15w, %r15w
cmovgl %r15d, %r14d
jmp 0x1173b
decl %r14d
movq %rbx, %rdi
callq 0x11381
movl %eax, %ebp
movzwl %r14w, %esi
pushq $0x1
popq %rdx
movq %rbx, %rdi
callq 0x10f12
movq %rbx, %rdi
callq 0x11381
movzwl %ax, %eax
movl %eax, 0xc(%rsp)
cmpw %ax, %bp
je 0x11778
pushq $0xe
popq %rsi
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
callq 0x4caf
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop