// File: /workspace/github_c_makefile_star2_O0/OnionIoT[P]lv_example/lvgl/src/lv_objx/lv_tileview.c
// Function: drag_end_handler
static void drag_end_handler(lv_obj_t * tileview)
{
    lv_tileview_ext_t * ext = lv_obj_get_ext_attr(tileview);
    lv_indev_t * indev      = lv_indev_get_act();
    lv_point_t point_act;
    lv_indev_get_point(indev, &point_act);
    lv_obj_t * scrl = lv_page_get_scrl(tileview);
    lv_point_t p;

    p.x = -(scrl->coords.x1 - lv_obj_get_width(tileview) / 2);
    p.y = -(scrl->coords.y1 - lv_obj_get_height(tileview) / 2);

    /*From the drag vector (drag throw) predict the end position*/
    if(ext->drag_hor) {
        lv_point_t vect;
        lv_indev_get_vect(indev, &vect);
        lv_coord_t predict = 0;

        while(vect.x != 0) {
            predict += vect.x;
            vect.x = vect.x * (100 - LV_INDEV_DEF_DRAG_THROW) / 100;
        }

        p.x -= predict;
    } else if(ext->drag_ver) {
        lv_point_t vect;
        lv_indev_get_vect(indev, &vect);
        lv_coord_t predict = 0;

        while(vect.y != 0) {
            predict += vect.y;
            vect.y = vect.y * (100 - LV_INDEV_DEF_DRAG_THROW) / 100;
        }

        p.y -= predict;
    }

    /*Get the index of the tile*/
    p.x = p.x / lv_obj_get_width(tileview);
    p.y = p.y / lv_obj_get_height(tileview);

    /*Max +- move*/
    lv_coord_t x_move = p.x - ext->act_id.x;
    lv_coord_t y_move = p.y - ext->act_id.y;
    if(x_move < -1) x_move = -1;
    if(x_move > 1) x_move = 1;
    if(y_move < -1) y_move = -1;
    if(y_move > 1) y_move = 1;

    /*Set the new tile*/
    lv_tileview_set_tile_act(tileview, ext->act_id.x + x_move, ext->act_id.y + y_move, true);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
callq 0xa8f0
movq %rax, -0x10(%rbp)
callq 0x4b70
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rdi
leaq -0x1c(%rbp), %rsi
callq 0x4d30
movq -0x8(%rbp), %rdi
callq 0x3e970
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rax
movswl 0x20(%rax), %eax
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rdi
callq 0x8310
movl -0x44(%rbp), %ecx
cwtl
movl $0x2, %esi
cltd
idivl %esi
subl %eax, %ecx
xorl %eax, %eax
subl %ecx, %eax
movw %ax, -0x2c(%rbp)
movq -0x28(%rbp), %rax
movswl 0x22(%rax), %eax
movl %eax, -0x40(%rbp)
movq -0x8(%rbp), %rdi
callq 0x8350
movl -0x40(%rbp), %ecx
cwtl
movl $0x2, %esi
cltd
idivl %esi
subl %eax, %ecx
xorl %eax, %eax
subl %ecx, %eax
movw %ax, -0x2a(%rbp)
movq -0x10(%rbp), %rax
movb 0x60(%rax), %al
shrb $0x4, %al
andb $0x1, %al
cmpb $0x0, %al
je 0x1fd4f
movq -0x18(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x4e20
movw $0x0, -0x32(%rbp)
movswl -0x30(%rbp), %eax
cmpl $0x0, %eax
je 0x1fd3f
movswl -0x30(%rbp), %ecx
movswl -0x32(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x32(%rbp)
movswl -0x30(%rbp), %eax
imull $0x50, %eax, %eax
movl $0x64, %ecx
cltd
idivl %ecx
movw %ax, -0x30(%rbp)
jmp 0x1fd13
movswl -0x32(%rbp), %ecx
movswl -0x2c(%rbp), %eax
subl %ecx, %eax
movw %ax, -0x2c(%rbp)
jmp 0x1fdae
movq -0x10(%rbp), %rax
movb 0x60(%rax), %al
shrb $0x5, %al
andb $0x1, %al
cmpb $0x0, %al
je 0x1fdac
movq -0x18(%rbp), %rdi
leaq -0x36(%rbp), %rsi
callq 0x4e20
movw $0x0, -0x38(%rbp)
movswl -0x34(%rbp), %eax
cmpl $0x0, %eax
je 0x1fd9e
movswl -0x34(%rbp), %ecx
movswl -0x38(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x38(%rbp)
movswl -0x34(%rbp), %eax
imull $0x50, %eax, %eax
movl $0x64, %ecx
cltd
idivl %ecx
movw %ax, -0x34(%rbp)
jmp 0x1fd72
movswl -0x38(%rbp), %ecx
movswl -0x2a(%rbp), %eax
subl %ecx, %eax
movw %ax, -0x2a(%rbp)
jmp 0x1fdae
movswl -0x2c(%rbp), %eax
movl %eax, -0x4c(%rbp)
movq -0x8(%rbp), %rdi
callq 0x8310
movw %ax, %cx
movl -0x4c(%rbp), %eax
movswl %cx, %ecx
cltd
idivl %ecx
movw %ax, -0x2c(%rbp)
movswl -0x2a(%rbp), %eax
movl %eax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
callq 0x8350
movw %ax, %cx
movl -0x48(%rbp), %eax
movswl %cx, %ecx
cltd
idivl %ecx
movw %ax, -0x2a(%rbp)
movswl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
movswl 0x5c(%rcx), %ecx
subl %ecx, %eax
movw %ax, -0x3a(%rbp)
movswl -0x2a(%rbp), %eax
movq -0x10(%rbp), %rcx
movswl 0x5e(%rcx), %ecx
subl %ecx, %eax
movw %ax, -0x3c(%rbp)
movswl -0x3a(%rbp), %eax
cmpl $-0x1, %eax
jge 0x1fe21
movw $0xffff, -0x3a(%rbp)    # imm = 0xFFFF
movswl -0x3a(%rbp), %eax
cmpl $0x1, %eax
jle 0x1fe30
movw $0x1, -0x3a(%rbp)
movswl -0x3c(%rbp), %eax
cmpl $-0x1, %eax
jge 0x1fe3f
movw $0xffff, -0x3c(%rbp)    # imm = 0xFFFF
movswl -0x3c(%rbp), %eax
cmpl $0x1, %eax
jle 0x1fe4e
movw $0x1, -0x3c(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movswl 0x5c(%rax), %eax
movswl -0x3a(%rbp), %ecx
addl %ecx, %eax
movw %ax, %dx
movq -0x10(%rbp), %rax
movswl 0x5e(%rax), %eax
movswl -0x3c(%rbp), %ecx
addl %ecx, %eax
movl $0x1, %ecx
movswl %dx, %esi
movswl %ax, %edx
callq 0x1f630
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)