// File: /workspace/github_c_makefile_star2_O3/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 0x3c5a(%rip), %rax      # 0xa780
movq 0x30(%rax), %rax
testq %rax, %rax
je 0x6e0a
cmpb $0x0, 0x1b(%rax)
jne 0x6e0a
movq %rdi, %rbx
movl 0x20(%rax), %ebp
movq 0x3c06(%rip), %r14      # 0xa750
movq %r14, %rdi
movl %ebp, %esi
callq 0x33b0
movq %r14, %rdi
movl %eax, %esi
xorl %edx, %edx
callq 0x3240
testq %rax, %rax
je 0x6e19
movswl 0xc(%rax), %ecx
movl %ecx, 0x14(%rsp)
movswl 0xe(%rax), %ecx
movl %ecx, 0x10(%rsp)
movzwl 0x10(%rax), %ebp
movzwl 0x12(%rax), %r13d
movq %rax, %rdi
callq 0x3050
movq 0x3bbf(%rip), %r14      # 0xa750
movq 0x3bd8(%rip), %rax      # 0xa770
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 0x6e0a
movq %rax, %r14
movswl 0x10(%rax), %eax
movl %eax, 0xc(%rsp)
movswl 0x12(%r14), %eax
movl %eax, 0x8(%rsp)
movq 0x3b7b(%rip), %r15      # 0xa750
movq 0x3b94(%rip), %rax      # 0xa770
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 0x6c1e
cmpb $0x0, 0x1(%rax)
je 0x6c34
movq %rax, %rdi
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x3050
movq %rax, %rdi
callq 0x3050
movq 0x3b3d(%rip), %rax      # 0xa780
movq 0x30(%rax), %rdi
cmpb $0x1, 0x1c(%rdi)
jne 0x6c5f
xorl %esi, %esi
callq 0x67b5
movq 0x3b25(%rip), %rax      # 0xa780
movq 0x30(%rax), %rdi
cmpb $0x0, 0x1a(%rdi)
jne 0x6cc8
movb $0x1, 0x1a(%rdi)
movl 0x28(%rdi), %edx
testl %edx, %edx
je 0x6cc8
movl 0x2c(%rdi), %r8d
testl %r8d, %r8d
je 0x6cc8
cmpl $0x31, %edx
ja 0x6c8a
movl $0x32, 0x28(%rdi)
movl $0x32, %edx
cmpl $0x31, %r8d
ja 0x6c9d
movl $0x32, 0x2c(%rdi)
movl $0x32, %r8d
movq 0x3aac(%rip), %rax      # 0xa750
movl 0x20(%rdi), %esi
movq %rsp, %rcx
movl %edx, (%rcx)
movl %r8d, 0x4(%rcx)
movq %rax, %rdi
movl $0xc, %edx
callq 0x32c0
movq 0x3abc(%rip), %rax      # 0xa780
movq 0x30(%rax), %rdi
callq 0x3dc0
leaq 0x3b2c(%rip), %r15      # 0xa800
movq 0x3a75(%rip), %rdi      # 0xa750
callq 0x3190
movq 0x3a69(%rip), %rdi      # 0xa750
callq 0x34e0
testq %rax, %rax
je 0x6cd4
movq %rax, %r12
movzbl (%rax), %eax
andl $0x7f, %eax
cmpl $0x13, %eax
jle 0x6d19
cmpl $0x17, %eax
je 0x6d0d
cmpl $0x14, %eax
jne 0x6dd0
movq %r12, %rdi
callq *(%r15,%rax,8)
jmp 0x6dd0
cmpl $0x6, %eax
jne 0x6d84
movl (%rbx), %edx
movswl 0x14(%r12), %esi
subl 0xc(%rsp), %esi
cmpl $0x1, %edx
movl %ebp, %eax
cmovel 0x14(%rsp), %eax
movl %r13d, %ecx
cmovel 0x10(%rsp), %ecx
addl %esi, %eax
movswl 0x16(%r12), %esi
subl 0x8(%rsp), %ecx
addl %esi, %ecx
testl %edx, %edx
je 0x6d8e
cmpl $0x1, %edx
jne 0x6dc4
movq 0x39f6(%rip), %rdi      # 0xa750
movq 0x3a1f(%rip), %rdx      # 0xa780
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 0x6dbc
addl $-0x2, %eax
cmpl $0x4, %eax
jae 0x6dd0
jmp 0x6dec
movq 0x39bb(%rip), %rdi      # 0xa750
movq 0x39e4(%rip), %rdx      # 0xa780
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 0x3985(%rip), %rdi      # 0xa750
callq 0x3190
movq %r12, %rdi
callq 0x3050
movq 0x39a1(%rip), %rax      # 0xa780
cmpq $0x0, 0x30(%rax)
jne 0x6cd4
jmp 0x6df4
movq %r12, %rdi
callq 0x3050
movq 0x3955(%rip), %rdi      # 0xa750
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 0x412(%rip), %rsi       # 0x7232
movl $0x1, %edi
movl %ebp, %edx
xorl %eax, %eax
callq 0x31b0