// File: /workspace/github_c_makefile_star2_O1/OnionIoT[P]lv_example/lvgl/src/lv_core/lv_indev.c
// Function: indev_drag_throw
static void indev_drag_throw(lv_indev_proc_t * proc)
{
    if(proc->types.pointer.drag_in_prog == 0) return;

    lv_obj_t * drag_obj = proc->types.pointer.last_obj;

    /*If drag parent is active check recursively the drag_parent attribute*/
    while(lv_obj_get_drag_parent(drag_obj) != false && drag_obj != NULL) {
        drag_obj = lv_obj_get_parent(drag_obj);
    }

    if(drag_obj == NULL) {
        return;
    }

    /*Return if the drag throw is not enabled*/
    if(lv_obj_get_drag_throw(drag_obj) == false) {
        proc->types.pointer.drag_in_prog = 0;
        drag_obj->signal_cb(drag_obj, LV_SIGNAL_DRAG_END, indev_act);
        lv_event_send(drag_obj, LV_EVENT_DRAG_END, NULL);
        if(indev_reset_check(proc)) return;

        lv_event_send(drag_obj, LV_EVENT_DRAG_END, NULL);
        return;
    }

    lv_drag_dir_t allowed_dirs = lv_obj_get_drag_dir(drag_obj);

    /*Reduce the vectors*/
    proc->types.pointer.drag_throw_vect.x =
        proc->types.pointer.drag_throw_vect.x * (100 - indev_act->driver.drag_throw) / 100;
    proc->types.pointer.drag_throw_vect.y =
        proc->types.pointer.drag_throw_vect.y * (100 - indev_act->driver.drag_throw) / 100;

    if(proc->types.pointer.drag_throw_vect.x != 0 || proc->types.pointer.drag_throw_vect.y != 0) {
        /*Get the coordinates and modify them*/
        lv_area_t coords_ori;
        lv_obj_get_coords(drag_obj, &coords_ori);
        lv_coord_t act_x = lv_obj_get_x(drag_obj) + proc->types.pointer.drag_throw_vect.x;
        lv_coord_t act_y = lv_obj_get_y(drag_obj) + proc->types.pointer.drag_throw_vect.y;

        if(allowed_dirs == LV_DRAG_DIR_ALL)
            lv_obj_set_pos(drag_obj, act_x, act_y);
        else if(allowed_dirs & LV_DRAG_DIR_HOR)
            lv_obj_set_x(drag_obj, act_x);
        else if(allowed_dirs & LV_DRAG_DIR_VER)
            lv_obj_set_y(drag_obj, act_y);

        lv_area_t coord_new;
        lv_obj_get_coords(drag_obj, &coord_new);

        /*If non of the coordinates are changed then do not continue throwing*/
        if((coords_ori.x1 == coord_new.x1 || proc->types.pointer.drag_throw_vect.x == 0) &&
           (coords_ori.y1 == coord_new.y1 || proc->types.pointer.drag_throw_vect.y == 0)) {
            proc->types.pointer.drag_in_prog      = 0;
            proc->types.pointer.vect.x            = 0;
            proc->types.pointer.vect.y            = 0;
            proc->types.pointer.drag_throw_vect.x = 0;
            proc->types.pointer.drag_throw_vect.y = 0;
            drag_obj->signal_cb(drag_obj, LV_SIGNAL_DRAG_END, indev_act);
            if(indev_reset_check(proc)) return;
            lv_event_send(drag_obj, LV_EVENT_DRAG_END, NULL);
            if(indev_reset_check(proc)) return;
        }
    }
    /*If the types.pointer.vectors become 0 -> types.pointer.drag_in_prog = 0 and send a drag end
       signal*/
    else {
        proc->types.pointer.drag_in_prog = 0;
        drag_obj->signal_cb(drag_obj, LV_SIGNAL_DRAG_END, indev_act);
        if(indev_reset_check(proc)) return;
        lv_event_send(drag_obj, LV_EVENT_DRAG_END, NULL);
        if(indev_reset_check(proc)) return;
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
testb $0x2, 0x38(%rdi)
je 0x43c5
movq %rdi, %rbx
movq 0x28(%rdi), %r14
movq %r14, %rdi
callq 0x6975
xorb $0x1, %al
testq %r14, %r14
sete %cl
orb %al, %cl
jne 0x4204
movq %r14, %rdi
callq 0x4abf
movq %rax, %r14
movq %rax, %rdi
callq 0x6975
testb %al, %al
je 0x4204
testq %r14, %r14
jne 0x41e8
testq %r14, %r14
je 0x43c5
movq %r14, %rdi
callq 0x694d
testb %al, %al
je 0x429d
movq %r14, %rdi
callq 0x6928
movl %eax, %ebp
movswl 0x18(%rbx), %eax
movq 0x5bc66(%rip), %rdx     # 0x5fe98
movzbl 0x29(%rdx), %ecx
movl $0x64, %esi
movl $0x64, %edi
subl %ecx, %edi
imull %eax, %edi
movslq %edi, %rax
imulq $0x51eb851f, %rax, %rcx # imm = 0x51EB851F
movq %rcx, %rax
shrq $0x3f, %rax
shrq $0x25, %rcx
addl %eax, %ecx
movw %cx, 0x18(%rbx)
movswl 0x1a(%rbx), %eax
movzbl 0x29(%rdx), %edi
subl %edi, %esi
imull %eax, %esi
movslq %esi, %rax
imulq $0x51eb851f, %rax, %rax # imm = 0x51EB851F
movq %rax, %rsi
shrq $0x3f, %rsi
sarq $0x25, %rax
addl %esi, %eax
movw %ax, 0x1a(%rbx)
testw %cx, %cx
jne 0x42e6
movzwl %ax, %eax
testl %eax, %eax
jne 0x42e6
andb $-0x3, 0x38(%rbx)
jmp 0x4393
andb $-0x3, 0x38(%rbx)
movq 0x5bbf0(%rip), %rdx     # 0x5fe98
movq %r14, %rdi
movl $0xf, %esi
callq *0x30(%r14)
movq %r14, %rdi
movl $0x9, %esi
xorl %edx, %edx
callq 0x4fea
testb $0x2, 0x48(%rbx)
jne 0x43ba
movq %r14, %rdi
movl $0x9, %esi
xorl %edx, %edx
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x4fea
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x5427
movq %r14, %rdi
callq 0x4bc6
movl %eax, %r15d
addw 0x18(%rbx), %r15w
movq %r14, %rdi
callq 0x4bfe
addw 0x1a(%rbx), %ax
cmpb $0x3, %bpl
jne 0x4326
movswl %r15w, %esi
movswl %ax, %edx
movq %r14, %rdi
callq 0x4ae2
jmp 0x434b
testb $0x1, %bpl
jne 0x433f
testb $0x2, %bpl
je 0x434b
movswl %ax, %esi
movq %r14, %rdi
callq 0x5501
jmp 0x434b
movswl %r15w, %esi
movq %r14, %rdi
callq 0x54c3
leaq 0x10(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x5427
movzwl 0x8(%rsp), %eax
cmpw (%r15), %ax
je 0x436d
cmpw $0x0, 0x18(%rbx)
jne 0x43c5
movzwl 0xa(%rsp), %eax
cmpw 0x12(%rsp), %ax
je 0x4380
cmpw $0x0, 0x1a(%rbx)
jne 0x43c5
andb $-0x3, 0x38(%rbx)
xorl %eax, %eax
movl %eax, 0x10(%rbx)
movl %eax, 0x18(%rbx)
movq 0x5bb05(%rip), %rdx     # 0x5fe98
movq %r14, %rdi
movl $0xf, %esi
callq *0x30(%r14)
testb $0x2, 0x48(%rbx)
jne 0x43ba
movq %r14, %rdi
movl $0x9, %esi
xorl %edx, %edx
callq 0x4fea
testb $0x2, 0x48(%rbx)
je 0x43c5
movq $0x0, 0x5badb(%rip) # 0x5fea0
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq