// File: /workspace/github_c_makefile_star2_O1/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 0x6ad8
movq %rax, %r14
andb $-0xf, 0x2a(%rax)
movq %r15, %rdi
callq 0x26288
movq %rax, %rdi
movl $0x1, %esi
callq 0x604d
callq 0x3784
movq %rax, %r12
leaq 0x14(%rsp), %rsi
movq %rax, %rdi
callq 0x3832
leaq 0x10(%rsp), %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x387e
movzwl (%r13), %eax
xorl %r12d, %r12d
testw %ax, %ax
je 0x1243d
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 0x12408
movw %ax, 0x10(%rsp)
movzwl 0x20(%r15), %eax
subw 0x20(%rbx), %ax
addl %eax, %r12d
movq %r15, %rdi
callq 0x5651
movl %eax, %ebp
movq %rbx, %rdi
callq 0x5651
movzwl %ax, %ecx
shrl $0xf, %ecx
addl %eax, %ecx
movswl %cx, %eax
shrl %eax
movzwl 0x24(%r14), %r15d
cmpw %ax, %r12w
jle 0x12484
movq %rbx, %rdi
callq 0x4abc
cmpb $0x1, %al
jne 0x12499
incl %r15d
jmp 0x1249c
addl %ebp, %r12d
cmpw %ax, %r12w
jge 0x1249c
movq %rbx, %rdi
callq 0x4abc
cmpb $0x1, %al
jne 0x1247f
decl %r15d
movswl %r15w, %eax
movzwl 0x26(%r14), %r14d
cmpl %eax, %r14d
jle 0x124b7
xorl %r14d, %r14d
testw %r15w, %r15w
cmovgl %r15d, %r14d
jmp 0x124ba
decl %r14d
movq %rbx, %rdi
callq 0x120df
movl %eax, %ebp
movzwl %r14w, %esi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x11c4a
movq %rbx, %rdi
callq 0x120df
movzwl %ax, %eax
movl %eax, 0xc(%rsp)
cmpw %ax, %bp
je 0x124fb
leaq 0xc(%rsp), %rdx
movq %rbx, %rdi
movl $0xe, %esi
callq 0x4fea
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop