// File: /workspace/github_c_makefile_star2_O1/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 $0x18, %rsp
movq 0x4a71(%rip), %rax      # 0xb780
movq 0x30(%rax), %rax
testq %rax, %rax
je 0x6fe4
cmpb $0x0, 0x1b(%rax)
jne 0x6fe4
movq %rdi, %rbx
movl 0x20(%rax), %ebp
movq 0x4a1d(%rip), %r14      # 0xb750
movq %r14, %rdi
movl %ebp, %esi
callq 0x33b0
movq %r14, %rdi
movl %eax, %esi
xorl %edx, %edx
callq 0x3240
testq %rax, %rax
je 0x6ff3
movswl 0xc(%rax), %r15d
movswl 0xe(%rax), %ecx
movl %ecx, 0x14(%rsp)
movzwl 0x10(%rax), %ebp
movzwl 0x12(%rax), %r13d
movq %rax, %rdi
callq 0x3050
movq 0x49d9(%rip), %r14      # 0xb750
movq 0x49f2(%rip), %rax      # 0xb770
movl (%rax), %esi
movq %r14, %rdi
callq 0x3330
xorl %r12d, %r12d
movq %r14, %rdi
movl %eax, %esi
xorl %edx, %edx
callq 0x3350
testq %rax, %rax
je 0x6fe4
movq %rax, %r14
movl %r15d, 0x10(%rsp)
movswl 0x10(%rax), %eax
movl %eax, 0xc(%rsp)
movswl 0x12(%r14), %eax
movl %eax, 0x8(%rsp)
movq 0x4990(%rip), %r15      # 0xb750
movq 0x49a9(%rip), %rax      # 0xb770
movl (%rax), %edx
subq $0x8, %rsp
movq %r15, %rdi
xorl %esi, %esi
movl $0x204c, %ecx           # imm = 0x204C
movl $0x1, %r8d
movl $0x1, %r9d
pushq %r12
pushq %r12
pushq %r12
callq 0x32f0
addq $0x20, %rsp
movq %r15, %rdi
movl %eax, %esi
xorl %edx, %edx
callq 0x3440
testq %rax, %rax
je 0x6e09
cmpb $0x0, 0x1(%rax)
je 0x6e11
movq %rax, %r14
jmp 0x6fdc
movq %rax, %rdi
callq 0x3050
movq 0x4960(%rip), %rax      # 0xb780
movq 0x30(%rax), %rdi
cmpb $0x1, 0x1c(%rdi)
jne 0x6e31
xorl %esi, %esi
callq 0x6972
movq 0x4948(%rip), %rax      # 0xb780
movq 0x30(%rax), %rax
testq %rax, %rax
je 0x6e8f
cmpb $0x0, 0x1a(%rax)
jne 0x6e8f
movb $0x1, 0x1a(%rax)
movl 0x28(%rax), %edx
testl %edx, %edx
je 0x6e8f
movl 0x2c(%rax), %ecx
testl %ecx, %ecx
je 0x6e8f
cmpl $0x31, %edx
ja 0x6e65
movl $0x32, 0x28(%rax)
cmpl $0x31, %ecx
ja 0x6e71
movl $0x32, 0x2c(%rax)
movq 0x48d8(%rip), %rdi      # 0xb750
movl 0x20(%rax), %esi
movq 0x28(%rax), %rax
movq %rsp, %rcx
movq %rax, (%rcx)
movl $0xc, %edx
callq 0x32c0
movq 0x48ea(%rip), %rax      # 0xb780
movq 0x30(%rax), %rdi
callq 0x3dcb
xorl %r15d, %r15d
movq 0x48a7(%rip), %rdi      # 0xb750
callq 0x3190
movq 0x489b(%rip), %rdi      # 0xb750
callq 0x34e0
testq %rax, %rax
je 0x6ea2
movq %rax, %r12
movzbl (%rax), %eax
andl $0x7f, %eax
cmpl $0x5, %eax
jg 0x6ee1
addl $-0x2, %eax
cmpl $0x4, %eax
jae 0x6fae
movb $0x1, %r15b
jmp 0x6fae
cmpl $0x6, %eax
je 0x6f06
cmpl $0x17, %eax
je 0x6ef4
cmpl $0x14, %eax
jne 0x6fae
movq %r12, %rdi
leaq 0x4902(%rip), %rcx      # 0xb800
callq *(%rcx,%rax,8)
jmp 0x6fae
movl (%rbx), %edx
movswl 0x14(%r12), %esi
subl 0xc(%rsp), %esi
cmpl $0x1, %edx
movl %ebp, %eax
cmovel 0x10(%rsp), %eax
movl %r13d, %ecx
cmovel 0x14(%rsp), %ecx
addl %esi, %eax
movswl 0x16(%r12), %esi
subl 0x8(%rsp), %ecx
addl %esi, %ecx
testl %edx, %edx
je 0x6f6c
cmpl $0x1, %edx
jne 0x6fa2
movq 0x480e(%rip), %rdi      # 0xb750
movq 0x4837(%rip), %rdx      # 0xb780
movq 0x30(%rdx), %rdx
movl 0x20(%rdx), %esi
movl %eax, (%rsp)
movl %ecx, 0x4(%rsp)
movq 0x38(%rdx), %r8
movq %r8, 0x30(%rdx)
movl %eax, 0x38(%rdx)
movl %ecx, 0x3c(%rdx)
movl $0x3, %edx
jmp 0x6f9a
movq 0x47dd(%rip), %rdi      # 0xb750
movq 0x4806(%rip), %rdx      # 0xb780
movq 0x30(%rdx), %rdx
movl 0x20(%rdx), %esi
cmpl $0x33, %eax
cmovll %ebp, %eax
cmpl $0x33, %ecx
cmovll %r13d, %ecx
movl %eax, (%rsp)
movl %ecx, 0x4(%rsp)
movl $0xc, %edx
movq %rsp, %rcx
callq 0x32c0
movq 0x47a7(%rip), %rdi      # 0xb750
callq 0x3190
movq %r12, %rdi
callq 0x3050
testb $0x1, %r15b
jne 0x6fce
movq 0x47bd(%rip), %rax      # 0xb780
cmpq $0x0, 0x30(%rax)
jne 0x6ea2
movq 0x477b(%rip), %rdi      # 0xb750
xorl %esi, %esi
callq 0x31d0
movq %r14, %rdi
callq 0x3050
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1220(%rip), %rsi      # 0x821a
movl $0x1, %edi
movl %ebp, %edx
xorl %eax, %eax
callq 0x31b0