// File: /workspace/github_c_makefile_star2_O0/OnionIoT[P]lv_example/lvgl/src/lv_core/lv_indev.c
// Function: indev_drag
static void indev_drag(lv_indev_proc_t * state)
{
    lv_obj_t * drag_obj    = state->types.pointer.act_obj;
    bool drag_just_started = false;

    /*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;

    if(lv_obj_get_drag(drag_obj) == false) return;

    lv_drag_dir_t allowed_dirs = lv_obj_get_drag_dir(drag_obj);

    /*Count the movement by drag*/
    state->types.pointer.drag_sum.x += state->types.pointer.vect.x;
    state->types.pointer.drag_sum.y += state->types.pointer.vect.y;

    /*Enough move?*/
    if(state->types.pointer.drag_limit_out == 0) {
        /*If a move is greater then LV_DRAG_LIMIT then begin the drag*/
        if(((allowed_dirs & LV_DRAG_DIR_HOR) &&
            LV_MATH_ABS(state->types.pointer.drag_sum.x) >= indev_act->driver.drag_limit) ||
           ((allowed_dirs & LV_DRAG_DIR_VER) &&
            LV_MATH_ABS(state->types.pointer.drag_sum.y) >= indev_act->driver.drag_limit)) {
            state->types.pointer.drag_limit_out = 1;
            drag_just_started                   = true;
        }
    }

    /*If the drag limit is exceeded handle the dragging*/
    if(state->types.pointer.drag_limit_out != 0) {
        /*Set new position if the vector is not zero*/
        if(state->types.pointer.vect.x != 0 || state->types.pointer.vect.y != 0) {

            uint16_t inv_buf_size =
                lv_disp_get_inv_buf_size(indev_act->driver.disp); /*Get the number of currently invalidated areas*/

            lv_coord_t prev_x     = drag_obj->coords.x1;
            lv_coord_t prev_y     = drag_obj->coords.y1;
            lv_coord_t prev_par_w = lv_obj_get_width(lv_obj_get_parent(drag_obj));
            lv_coord_t prev_par_h = lv_obj_get_height(lv_obj_get_parent(drag_obj));

            /*Get the coordinates of the object and modify them*/
            lv_coord_t act_x = lv_obj_get_x(drag_obj);
            lv_coord_t act_y = lv_obj_get_y(drag_obj);

            if(allowed_dirs == LV_DRAG_DIR_ALL) {
                if(drag_just_started) {
                    act_x += state->types.pointer.drag_sum.x;
                    act_y += state->types.pointer.drag_sum.y;
                }
                lv_obj_set_pos(drag_obj, act_x + state->types.pointer.vect.x, act_y + state->types.pointer.vect.y);
            } else if(allowed_dirs & LV_DRAG_DIR_HOR) {
                if(drag_just_started) {
                    act_x += state->types.pointer.drag_sum.x;
                }
                lv_obj_set_x(drag_obj, act_x + state->types.pointer.vect.x);
            } else if(allowed_dirs & LV_DRAG_DIR_VER) {
                if(drag_just_started) {
                    act_y += state->types.pointer.drag_sum.y;
                }
                lv_obj_set_y(drag_obj, act_y + state->types.pointer.vect.y);
            }

            /*If the object didn't moved then clear the invalidated areas*/
            if(drag_obj->coords.x1 == prev_x && drag_obj->coords.y1 == prev_y) {
//                state->types.pointer.drag_in_prog = 0;
                /*In a special case if the object is moved on a page and
                 * the scrollable has fit == true and the object is dragged of the page then
                 * while its coordinate is not changing only the parent's size is reduced */
                lv_coord_t act_par_w = lv_obj_get_width(lv_obj_get_parent(drag_obj));
                lv_coord_t act_par_h = lv_obj_get_height(lv_obj_get_parent(drag_obj));
                if(act_par_w == prev_par_w && act_par_h == prev_par_h) {
                    uint16_t new_inv_buf_size = lv_disp_get_inv_buf_size(indev_act->driver.disp);
                    lv_disp_pop_from_inv_buf(indev_act->driver.disp, new_inv_buf_size - inv_buf_size);
                }
            } else {
                state->types.pointer.drag_in_prog = 1;
                /*Set the drag in progress flag*/
                /*Send the drag begin signal on first move*/
                if(drag_just_started) {
                    drag_obj->signal_cb(drag_obj, LV_SIGNAL_DRAG_BEGIN, indev_act);
                    if(indev_reset_check(state)) return;
                    lv_event_send(drag_obj, LV_EVENT_DRAG_BEGIN, NULL);
                    if(indev_reset_check(state)) return;
                }
            }
        }
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq 0x20(%rax), %rax
movq %rax, -0x10(%rbp)
movb $0x0, -0x11(%rbp)
movq -0x10(%rbp), %rdi
callq 0xa610
andb $0x1, %al
movzbl %al, %ecx
xorl %eax, %eax
cmpl $0x0, %ecx
movb %al, -0x27(%rbp)
je 0x5f6f
cmpq $0x0, -0x10(%rbp)
setne %al
movb %al, -0x27(%rbp)
movb -0x27(%rbp), %al
testb $0x1, %al
jne 0x5f78
jmp 0x5f87
movq -0x10(%rbp), %rdi
callq 0x71b0
movq %rax, -0x10(%rbp)
jmp 0x5f4c
cmpq $0x0, -0x10(%rbp)
jne 0x5f93
jmp 0x632c
movq -0x10(%rbp), %rdi
callq 0xa500
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x5fab
jmp 0x632c
movq -0x10(%rbp), %rdi
callq 0xa560
movb %al, -0x12(%rbp)
movq -0x8(%rbp), %rax
movswl 0x10(%rax), %edx
movq -0x8(%rbp), %rax
movswl 0x14(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x14(%rax)
movq -0x8(%rbp), %rax
movswl 0x12(%rax), %edx
movq -0x8(%rbp), %rax
movswl 0x16(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x16(%rax)
movq -0x8(%rbp), %rax
movb 0x38(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x609c
movzbl -0x12(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x603f
movq -0x8(%rbp), %rax
movswl 0x14(%rax), %eax
cmpl $0x0, %eax
jle 0x601e
movq -0x8(%rbp), %rax
movswl 0x14(%rax), %eax
movl %eax, -0x2c(%rbp)
jmp 0x602d
movq -0x8(%rbp), %rax
movswl 0x14(%rax), %ecx
xorl %eax, %eax
subl %ecx, %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq 0x82f31(%rip), %rcx     # 0x88f68
movzbl 0x28(%rcx), %ecx
cmpl %ecx, %eax
jge 0x6086
movzbl -0x12(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x609a
movq -0x8(%rbp), %rax
movswl 0x16(%rax), %eax
cmpl $0x0, %eax
jle 0x6065
movq -0x8(%rbp), %rax
movswl 0x16(%rax), %eax
movl %eax, -0x30(%rbp)
jmp 0x6074
movq -0x8(%rbp), %rax
movswl 0x16(%rax), %ecx
xorl %eax, %eax
subl %ecx, %eax
movl %eax, -0x30(%rbp)
movl -0x30(%rbp), %eax
movq 0x82eea(%rip), %rcx     # 0x88f68
movzbl 0x28(%rcx), %ecx
cmpl %ecx, %eax
jl 0x609a
movq -0x8(%rbp), %rax
movb 0x38(%rax), %cl
andb $-0x2, %cl
orb $0x1, %cl
movb %cl, 0x38(%rax)
movb $0x1, -0x11(%rbp)
jmp 0x609c
movq -0x8(%rbp), %rax
movb 0x38(%rax), %al
andb $0x1, %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0x632c
movq -0x8(%rbp), %rax
movswl 0x10(%rax), %eax
cmpl $0x0, %eax
jne 0x60cf
movq -0x8(%rbp), %rax
movswl 0x12(%rax), %eax
cmpl $0x0, %eax
je 0x632a
movq 0x82e92(%rip), %rax     # 0x88f68
movq 0x18(%rax), %rdi
callq 0xdbf0
movw %ax, -0x14(%rbp)
movq -0x10(%rbp), %rax
movw 0x20(%rax), %ax
movw %ax, -0x16(%rbp)
movq -0x10(%rbp), %rax
movw 0x22(%rax), %ax
movw %ax, -0x18(%rbp)
movq -0x10(%rbp), %rdi
callq 0x71b0
movq %rax, %rdi
callq 0x8310
movw %ax, -0x1a(%rbp)
movq -0x10(%rbp), %rdi
callq 0x71b0
movq %rax, %rdi
callq 0x8350
movw %ax, -0x1c(%rbp)
movq -0x10(%rbp), %rdi
callq 0x7350
movw %ax, -0x1e(%rbp)
movq -0x10(%rbp), %rdi
callq 0x73c0
movw %ax, -0x20(%rbp)
movzbl -0x12(%rbp), %eax
cmpl $0x3, %eax
jne 0x61a5
testb $0x1, -0x11(%rbp)
je 0x6172
movq -0x8(%rbp), %rax
movswl 0x14(%rax), %ecx
movswl -0x1e(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x1e(%rbp)
movq -0x8(%rbp), %rax
movswl 0x16(%rax), %ecx
movswl -0x20(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movswl -0x1e(%rbp), %eax
movq -0x8(%rbp), %rcx
movswl 0x10(%rcx), %ecx
addl %ecx, %eax
movw %ax, %cx
movswl -0x20(%rbp), %eax
movq -0x8(%rbp), %rdx
movswl 0x12(%rdx), %edx
addl %edx, %eax
movswl %cx, %esi
movswl %ax, %edx
callq 0x71f0
jmp 0x6227
movzbl -0x12(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x61e5
testb $0x1, -0x11(%rbp)
je 0x61c9
movq -0x8(%rbp), %rax
movswl 0x14(%rax), %ecx
movswl -0x1e(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x1e(%rbp)
movq -0x10(%rbp), %rdi
movswl -0x1e(%rbp), %eax
movq -0x8(%rbp), %rcx
movswl 0x10(%rcx), %ecx
addl %ecx, %eax
movswl %ax, %esi
callq 0x80b0
jmp 0x6225
movzbl -0x12(%rbp), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x6223
testb $0x1, -0x11(%rbp)
je 0x6209
movq -0x8(%rbp), %rax
movswl 0x16(%rax), %ecx
movswl -0x20(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x20(%rbp)
movq -0x10(%rbp), %rdi
movswl -0x20(%rbp), %eax
movq -0x8(%rbp), %rcx
movswl 0x12(%rcx), %ecx
addl %ecx, %eax
movswl %ax, %esi
callq 0x8120
jmp 0x6225
jmp 0x6227
movq -0x10(%rbp), %rax
movswl 0x20(%rax), %eax
movswl -0x16(%rbp), %ecx
cmpl %ecx, %eax
jne 0x62c0
movq -0x10(%rbp), %rax
movswl 0x22(%rax), %eax
movswl -0x18(%rbp), %ecx
cmpl %ecx, %eax
jne 0x62c0
movq -0x10(%rbp), %rdi
callq 0x71b0
movq %rax, %rdi
callq 0x8310
movw %ax, -0x22(%rbp)
movq -0x10(%rbp), %rdi
callq 0x71b0
movq %rax, %rdi
callq 0x8350
movw %ax, -0x24(%rbp)
movswl -0x22(%rbp), %eax
movswl -0x1a(%rbp), %ecx
cmpl %ecx, %eax
jne 0x62be
movswl -0x24(%rbp), %eax
movswl -0x1c(%rbp), %ecx
cmpl %ecx, %eax
jne 0x62be
movq 0x82cd4(%rip), %rax     # 0x88f68
movq 0x18(%rax), %rdi
callq 0xdbf0
movw %ax, -0x26(%rbp)
movq 0x82cc0(%rip), %rax     # 0x88f68
movq 0x18(%rax), %rdi
movzwl -0x26(%rbp), %eax
movzwl -0x14(%rbp), %ecx
subl %ecx, %eax
movzwl %ax, %esi
callq 0xdc10
jmp 0x6328
movq -0x8(%rbp), %rax
movb 0x38(%rax), %cl
andb $-0x3, %cl
orb $0x2, %cl
movb %cl, 0x38(%rax)
testb $0x1, -0x11(%rbp)
je 0x6326
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
movq -0x10(%rbp), %rdi
movq 0x82c7f(%rip), %rdx     # 0x88f68
movl $0xe, %esi
callq *%rax
movq -0x8(%rbp), %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x62ff
jmp 0x6301
jmp 0x632c
movq -0x10(%rbp), %rdi
movl $0x8, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x7990
movq -0x8(%rbp), %rdi
callq 0x5ee0
testb $0x1, %al
jne 0x6322
jmp 0x6324
jmp 0x632c
jmp 0x6326
jmp 0x6328
jmp 0x632a
jmp 0x632c
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)