// File: /workspace/github_c_makefile_star2_O2/kaugm[P]mmwm/mmwm.c
// Function: mousemotion
void mousemotion(const Arg *arg)
{
    xcb_get_geometry_reply_t  *geometry;
    xcb_query_pointer_reply_t *pointer;
    xcb_grab_pointer_reply_t  *grab_reply;
    int mx, my, winx, winy, winw, winh, xw, yh;

    if (!M_CURRENT || M_CURRENT->isfullscreen)
        return;
    geometry = get_geometry(M_CURRENT->win);
    winx = geometry->x;     winy = geometry->y;
    winw = geometry->width; winh = geometry->height;
    free(geometry);

    pointer = xcb_query_pointer_reply(dis,
                                      xcb_query_pointer(dis, screen->root), 0);
    if (!pointer)
        return;
    mx = pointer->root_x;
    my = pointer->root_y;

    grab_reply = xcb_grab_pointer_reply(dis, xcb_grab_pointer(dis, 0,
        screen->root,
        BUTTONMASK|XCB_EVENT_MASK_BUTTON_MOTION|XCB_EVENT_MASK_POINTER_MOTION,
        XCB_GRAB_MODE_ASYNC, XCB_GRAB_MODE_ASYNC, XCB_NONE, XCB_NONE,
        XCB_CURRENT_TIME), NULL);

    if (!grab_reply || grab_reply->status != XCB_GRAB_STATUS_SUCCESS) {
        free(grab_reply);
        return;
    } else {
        free(grab_reply);
    }

    if (M_CURRENT->ismaximized)
        setmaximize(M_CURRENT, False);
    if (!M_CURRENT->isfloating)
        float_client(M_CURRENT);
    update_current(M_CURRENT);

    xcb_generic_event_t *e = NULL;
    xcb_motion_notify_event_t *ev = NULL;
    bool ungrab = false;
    do {
        xcb_flush(dis);
        while (!(e = xcb_wait_for_event(dis)))
            xcb_flush(dis);
        switch (e->response_type & ~0x80) {
            case XCB_CONFIGURE_REQUEST:
            case XCB_MAP_REQUEST:
                events[e->response_type & ~0x80](e);
                break;
            case XCB_MOTION_NOTIFY:
                ev = (xcb_motion_notify_event_t *)e;
                xw = (arg->i == MOVE ? winx : winw) + ev->root_x - mx;
                yh = (arg->i == MOVE ? winy : winh) + ev->root_y - my;
                if (arg->i == RESIZE) xcb_resize(dis, M_CURRENT->win,
                                      xw > MINWSZ ? xw : winw,
                                      yh > MINWSZ ? yh : winh);
                else if (arg->i == MOVE) xcb_move(dis, M_CURRENT->win, xw, yh, &M_CURRENT->position_info);
                xcb_flush(dis);
                break;
            case XCB_KEY_PRESS:
            case XCB_KEY_RELEASE:
            case XCB_BUTTON_PRESS:
            case XCB_BUTTON_RELEASE:
                ungrab = true;
        }
        if (e)
            free(e);
    } while (!ungrab && M_CURRENT);
    DEBUG("xcb: ungrab");
    xcb_ungrab_pointer(dis, XCB_CURRENT_TIME);

    free(pointer);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq 0x4151(%rip), %rax      # 0xa780
movq 0x30(%rax), %rax
testq %rax, %rax
je 0x66ff
cmpb $0x0, 0x1b(%rax)
jne 0x66ff
movq %rdi, %rbx
movl 0x20(%rax), %edi
callq 0x6917
movswl 0xc(%rax), %ecx
movl %ecx, 0x24(%rsp)
movswl 0xe(%rax), %r12d
movzwl 0x10(%rax), %r13d
movzwl 0x12(%rax), %ebp
movq %rax, %rdi
callq 0x3050
movq 0x40da(%rip), %r14      # 0xa750
movq 0x40f3(%rip), %rax      # 0xa770
movl (%rax), %esi
movq %r14, %rdi
callq 0x3320
movq %r14, %rdi
movl %eax, %esi
xorl %edx, %edx
callq 0x3340
testq %rax, %rax
je 0x66ff
movq %rax, %r14
movswl 0x10(%rax), %eax
movl %eax, 0x20(%rsp)
movswl 0x12(%r14), %eax
movl %eax, 0x1c(%rsp)
movq 0x409d(%rip), %r15      # 0xa750
movq 0x40b6(%rip), %rax      # 0xa770
movl (%rax), %edx
andl $0x0, 0x10(%rsp)
andl $0x0, 0x8(%rsp)
andl $0x0, (%rsp)
pushq $0x1
popq %r8
movq %r15, %rdi
xorl %esi, %esi
movl $0x204c, %ecx           # imm = 0x204C
movl %r8d, %r9d
callq 0x32e0
movq %r15, %rdi
movl %eax, %esi
xorl %edx, %edx
callq 0x3430
testq %rax, %rax
je 0x66f7
cmpb $0x0, 0x1(%rax)
je 0x670e
movq %rax, %r14
jmp 0x68a2
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rdi
callq 0x3050
movq 0x4063(%rip), %rax      # 0xa780
movq 0x30(%rax), %rdi
cmpb $0x1, 0x1c(%rdi)
jne 0x6739
xorl %esi, %esi
callq 0x62fa
movq 0x404b(%rip), %rax      # 0xa780
movq 0x30(%rax), %rdi
cmpb $0x0, 0x1a(%rdi)
jne 0x678c
movb $0x1, 0x1a(%rdi)
movl 0x28(%rdi), %edx
testl %edx, %edx
je 0x678c
movl 0x2c(%rdi), %ecx
testl %ecx, %ecx
je 0x678c
cmpl $0x31, %edx
ja 0x6760
movl $0x32, 0x28(%rdi)
pushq $0x32
popq %rdx
cmpl $0x31, %ecx
ja 0x676f
pushq $0x32
popq %rcx
movl $0x32, 0x2c(%rdi)
movq 0x3fda(%rip), %rax      # 0xa750
movl 0x20(%rdi), %esi
movq %rax, %rdi
callq 0x695a
movq 0x3ff8(%rip), %rax      # 0xa780
movq 0x30(%rax), %rdi
callq 0x3cfa
movq 0x3fb8(%rip), %rdi      # 0xa750
callq 0x3190
movq 0x3fac(%rip), %rdi      # 0xa750
callq 0x34d0
testq %rax, %rax
je 0x6791
movq %rax, %r15
movzbl (%rax), %eax
andl $0x7f, %eax
cmpq $0x6, %rax
je 0x67ea
cmpl $0x14, %eax
je 0x67d8
cmpl $0x17, %eax
je 0x67d8
addl $-0x2, %eax
cmpl $0x4, %eax
jae 0x6870
jmp 0x688c
movq %r15, %rdi
leaq 0x401e(%rip), %rcx      # 0xa800
callq *(%rcx,%rax,8)
jmp 0x6870
movl (%rbx), %eax
movswl 0x14(%r15), %esi
subl 0x20(%rsp), %esi
cmpl $0x1, %eax
movl %r13d, %edx
cmovel 0x24(%rsp), %edx
movl %ebp, %ecx
cmovel %r12d, %ecx
addl %esi, %edx
movswl 0x16(%r15), %esi
subl 0x1c(%rsp), %ecx
addl %esi, %ecx
testl %eax, %eax
je 0x683d
cmpl $0x1, %eax
jne 0x6864
movq 0x3f2d(%rip), %rdi      # 0xa750
movq 0x3f56(%rip), %rax      # 0xa780
movq 0x30(%rax), %r8
movl 0x20(%r8), %esi
addq $0x30, %r8
callq 0x4c77
jmp 0x6864
movq 0x3f0c(%rip), %rdi      # 0xa750
movq 0x3f35(%rip), %rax      # 0xa780
movq 0x30(%rax), %rax
cmpl $0x33, %edx
cmovll %r13d, %edx
movl 0x20(%rax), %esi
cmpl $0x33, %ecx
cmovll %ebp, %ecx
callq 0x695a
movq 0x3ee5(%rip), %rdi      # 0xa750
callq 0x3190
movq %r15, %rdi
callq 0x3050
movq 0x3f01(%rip), %rax      # 0xa780
cmpq $0x0, 0x30(%rax)
jne 0x6791
jmp 0x6894
movq %r15, %rdi
callq 0x3050
movq 0x3eb5(%rip), %rdi      # 0xa750
xorl %esi, %esi
callq 0x31d0
movq %r14, %rdi
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3050