// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
callq 0xa8f0
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movb 0x2a(%rax), %cl
andb $-0x5, %cl
orb $0x0, %cl
movb %cl, 0x2a(%rax)
movq -0x18(%rbp), %rax
movb 0x2a(%rax), %cl
andb $-0x3, %cl
orb $0x0, %cl
movb %cl, 0x2a(%rax)
movq -0x18(%rbp), %rax
movb 0x2a(%rax), %cl
andb $-0x9, %cl
orb $0x0, %cl
movb %cl, 0x2a(%rax)
movq -0x10(%rbp), %rdi
callq 0x3e970
movq %rax, %rdi
movl $0x1, %esi
callq 0x95a0
callq 0x4b70
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rdi
leaq -0x24(%rbp), %rsi
callq 0x4d30
movq -0x20(%rbp), %rdi
leaq -0x28(%rbp), %rsi
callq 0x4e20
movw $0x0, -0x2a(%rbp)
movswl -0x28(%rbp), %eax
cmpl $0x0, %eax
je 0x1e8c8
movswl -0x28(%rbp), %ecx
movswl -0x2a(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x2a(%rbp)
movswl -0x28(%rbp), %eax
imull $0x50, %eax, %eax
movl $0x64, %ecx
cltd
idivl %ecx
movw %ax, -0x28(%rbp)
jmp 0x1e89c
movq -0x10(%rbp), %rax
movswl 0x20(%rax), %eax
movq -0x8(%rbp), %rcx
movswl 0x20(%rcx), %ecx
subl %ecx, %eax
movswl -0x2a(%rbp), %ecx
addl %ecx, %eax
movw %ax, -0x2c(%rbp)
movswl -0x2c(%rbp), %eax
movl %eax, -0x44(%rbp)
movq -0x10(%rbp), %rdi
callq 0x8310
movw %ax, %cx
movl -0x44(%rbp), %eax
movswl %cx, %ecx
addl %ecx, %eax
movw %ax, -0x2e(%rbp)
movq -0x8(%rbp), %rdi
callq 0x8310
cwtl
movl $0x2, %ecx
cltd
idivl %ecx
movw %ax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movw 0x24(%rax), %ax
movw %ax, -0x32(%rbp)
movswl -0x2c(%rbp), %eax
movswl -0x30(%rbp), %ecx
cmpl %ecx, %eax
jle 0x1e95e
movq -0x8(%rbp), %rdi
callq 0x7180
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x1e950
movw -0x32(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x32(%rbp)
jmp 0x1e95c
movw -0x32(%rbp), %ax
addw $-0x1, %ax
movw %ax, -0x32(%rbp)
jmp 0x1e999
movswl -0x2e(%rbp), %eax
movswl -0x30(%rbp), %ecx
cmpl %ecx, %eax
jge 0x1e997
movq -0x8(%rbp), %rdi
callq 0x7180
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x1e989
movw -0x32(%rbp), %ax
addw $-0x1, %ax
movw %ax, -0x32(%rbp)
jmp 0x1e995
movw -0x32(%rbp), %ax
addw $0x1, %ax
movw %ax, -0x32(%rbp)
jmp 0x1e997
jmp 0x1e999
movswl -0x32(%rbp), %eax
movq -0x18(%rbp), %rcx
movzwl 0x26(%rcx), %ecx
subl $0x1, %ecx
cmpl %ecx, %eax
jle 0x1e9bd
movq -0x18(%rbp), %rax
movzwl 0x26(%rax), %eax
subl $0x1, %eax
movw %ax, -0x32(%rbp)
jmp 0x1e9ce
movswl -0x32(%rbp), %eax
cmpl $0x0, %eax
jge 0x1e9cc
movw $0x0, -0x32(%rbp)
jmp 0x1e9ce
movq -0x8(%rbp), %rdi
callq 0x1e280
movzwl %ax, %eax
movl %eax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movl $0x1, %edx
movzwl -0x32(%rbp), %esi
callq 0x1da50
movq -0x8(%rbp), %rdi
callq 0x1e280
movzwl %ax, %eax
movl %eax, -0x3c(%rbp)
movb $0x1, -0x3d(%rbp)
movl -0x38(%rbp), %eax
cmpl -0x3c(%rbp), %eax
je 0x1ea1f
movq -0x8(%rbp), %rdi
movl $0xe, %esi
leaq -0x3c(%rbp), %rdx
callq 0x7990
movb %al, -0x3d(%rbp)
movzbl -0x3d(%rbp), %eax
cmpl $0x1, %eax
je 0x1ea2a
jmp 0x1ea2a
addq $0x50, %rsp
popq %rbp
retq