// File: /workspace/github_c_makefile_star2_O3/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 0x43b2
movq %rdi, %rbx
movq 0x28(%rdi), %r14
movq %r14, %rdi
callq 0x6994
xorb $0x1, %al
testq %r14, %r14
sete %cl
orb %al, %cl
jne 0x41f1
movq %r14, %rdi
callq 0x4ab5
movq %rax, %r14
movq %rax, %rdi
callq 0x6994
testb %al, %al
je 0x41f1
testq %r14, %r14
jne 0x41d5
testq %r14, %r14
je 0x43b2
movq %r14, %rdi
callq 0x696c
testb %al, %al
je 0x428a
movq %r14, %rdi
callq 0x6947
movl %eax, %ebp
movswl 0x18(%rbx), %eax
movq 0x5bc79(%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 0x42d3
movzwl %ax, %eax
testl %eax, %eax
jne 0x42d3
andb $-0x3, 0x38(%rbx)
jmp 0x4380
andb $-0x3, 0x38(%rbx)
movq 0x5bc03(%rip), %rdx     # 0x5fe98
movq %r14, %rdi
movl $0xf, %esi
callq *0x30(%r14)
movq %r14, %rdi
movl $0x9, %esi
xorl %edx, %edx
callq 0x5018
testb $0x2, 0x48(%rbx)
jne 0x43a7
movq %r14, %rdi
movl $0x9, %esi
xorl %edx, %edx
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
jmp 0x5018
leaq 0x8(%rsp), %rsi
movq %r14, %rdi
callq 0x542b
movq %r14, %rdi
callq 0x4bdd
movl %eax, %r15d
addw 0x18(%rbx), %r15w
movq %r14, %rdi
callq 0x4c15
addw 0x1a(%rbx), %ax
cmpb $0x3, %bpl
jne 0x4313
movswl %r15w, %esi
movswl %ax, %edx
movq %r14, %rdi
callq 0x4ad8
jmp 0x4338
testb $0x1, %bpl
jne 0x432c
testb $0x2, %bpl
je 0x4338
movswl %ax, %esi
movq %r14, %rdi
callq 0x5519
jmp 0x4338
movswl %r15w, %esi
movq %r14, %rdi
callq 0x54db
leaq 0x10(%rsp), %r15
movq %r14, %rdi
movq %r15, %rsi
callq 0x542b
movzwl 0x8(%rsp), %eax
cmpw (%r15), %ax
je 0x435a
cmpw $0x0, 0x18(%rbx)
jne 0x43b2
movzwl 0xa(%rsp), %eax
cmpw 0x12(%rsp), %ax
je 0x436d
cmpw $0x0, 0x1a(%rbx)
jne 0x43b2
andb $-0x3, 0x38(%rbx)
xorl %eax, %eax
movl %eax, 0x10(%rbx)
movl %eax, 0x18(%rbx)
movq 0x5bb18(%rip), %rdx     # 0x5fe98
movq %r14, %rdi
movl $0xf, %esi
callq *0x30(%r14)
testb $0x2, 0x48(%rbx)
jne 0x43a7
movq %r14, %rdi
movl $0x9, %esi
xorl %edx, %edx
callq 0x5018
testb $0x2, 0x48(%rbx)
je 0x43b2
movq $0x0, 0x5baee(%rip) # 0x5fea0
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)