// File: /workspace/github_c_makefile_star2_O1/9wm[P]9wm/grab.c
// Function: sweepdrag
int
sweepdrag(Client * c, XButtonEvent * e0, void (*recalc) ())
{
	XEvent ev;
	int idle;
	int cx, cy, rx, ry;
	int ox, oy, odx, ody;
	XButtonEvent *e;

	ox = c->x;
	oy = c->y;
	odx = c->dx;
	ody = c->dy;
	c->x -= BORDER;
	c->y -= BORDER;
	c->dx += 2 * BORDER;
	c->dy += 2 * BORDER;
	if (e0) {
		c->x = cx = e0->x;
		c->y = cy = e0->y;
		recalc(c, e0->x, e0->y);
	} else
		getmouse(&cx, &cy, c->screen);
	XGrabServer(dpy);
	drawbound(c);
	idle = 0;
	for (;;) {
		if (XCheckMaskEvent(dpy, ButtonMask, &ev) == 0) {
			getmouse(&rx, &ry, c->screen);
			if (rx != cx || ry != cy || ++idle > 300) {
				drawbound(c);
				if (rx == cx && ry == cy) {
					XUngrabServer(dpy);
					XFlush(dpy);
					misleep(500);
					XGrabServer(dpy);
					idle = 0;
				}
				recalc(c, rx, ry);
				cx = rx;
				cy = ry;
				drawbound(c);
				XFlush(dpy);
			}
			misleep(50);
			continue;
		}
		e = &ev.xbutton;
		switch (ev.type) {
		case ButtonPress:
		case ButtonRelease:
			drawbound(c);
			ungrab(e);
			XUngrabServer(dpy);
			recalc(c, ev.xbutton.x, ev.xbutton.y);
			if (c->dx < 0) {
				c->x += c->dx;
				c->dx = -c->dx;
			}
			if (c->dy < 0) {
				c->y += c->dy;
				c->dy = -c->dy;
			}
			c->x += BORDER;
			c->y += BORDER;
			c->dx -= 2 * BORDER;
			c->dy -= 2 * BORDER;
			if (c->dx < 4 || c->dy < 4 || c->dx < c->min_dx || c->dy < c->min_dy)
				goto bad;
			return 1;
		}
	}
      bad:
	c->x = ox;
	c->y = oy;
	c->dx = odx;
	c->dy = ody;
	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x118, %rsp            # imm = 0x118
movq %rdx, %r14
movq %rdi, %rbx
movl 0x28(%rdi), %ecx
movl 0x2c(%rdi), %edx
movl 0x30(%rdi), %edi
movl 0x34(%rbx), %r8d
leaq 0x4e16(%rip), %rax      # 0xb320
movl (%rax), %eax
movl %ecx, 0x1c(%rsp)
subl %eax, %ecx
movl %ecx, 0x28(%rbx)
movl %edx, 0x18(%rsp)
movl %edx, %ecx
subl %eax, %ecx
movl %ecx, 0x2c(%rbx)
movq %rdi, 0x40(%rsp)
leal (%rdi,%rax,2), %ecx
movl %ecx, 0x30(%rbx)
movq %r8, 0x38(%rsp)
leal (%r8,%rax,2), %eax
movl %eax, 0x34(%rbx)
testq %rsi, %rsi
je 0x655c
movl 0x40(%rsi), %eax
movl %eax, 0x14(%rsp)
movl %eax, 0x28(%rbx)
movl 0x44(%rsi), %edx
movl %edx, 0x10(%rsp)
movl %edx, 0x2c(%rbx)
movq %rbx, %rdi
movl %eax, %esi
xorl %eax, %eax
callq *%r14
jmp 0x65a6
movq 0xf8(%rbx), %rax
leaq 0x540e(%rip), %rcx      # 0xb978
movq (%rcx), %rdi
movq 0x8(%rax), %rsi
subq $0x8, %rsp
leaq 0x28(%rsp), %rax
leaq 0x2c(%rsp), %r10
leaq 0x50(%rsp), %r11
leaq 0x60(%rsp), %rdx
leaq 0x30(%rsp), %rcx
leaq 0x1c(%rsp), %r8
leaq 0x18(%rsp), %r9
pushq %rax
pushq %r10
pushq %r11
callq 0x22c0
addq $0x20, %rsp
leaq 0x53cb(%rip), %r13      # 0xb978
movq (%r13), %rdi
callq 0x23c0
movq %rbx, %rdi
callq 0x63c3
leaq 0x58(%rsp), %r15
leaq 0x28(%rsp), %r12
xorl %ebp, %ebp
movq (%r13), %rdi
movl $0xc, %esi
movq %r15, %rdx
callq 0x24b0
testl %eax, %eax
je 0x65f0
movl 0x58(%rsp), %eax
andl $-0x2, %eax
cmpl $0x4, %eax
jne 0x65ca
jmp 0x6708
movq 0xf8(%rbx), %rax
movq (%r13), %rdi
movq 0x8(%rax), %rsi
subq $0x8, %rsp
movq %r12, %rdx
leaq 0x50(%rsp), %rcx
leaq 0x14(%rsp), %r8
leaq 0x10(%rsp), %r9
leaq 0x5c(%rsp), %rax
pushq %rax
leaq 0x30(%rsp), %rax
pushq %rax
leaq 0x3c(%rsp), %rax
pushq %rax
callq 0x22c0
addq $0x20, %rsp
movl 0xc(%rsp), %eax
cmpl 0x14(%rsp), %eax
jne 0x6655
movl 0x8(%rsp), %eax
cmpl 0x10(%rsp), %eax
jne 0x6655
leal 0x1(%rbp), %eax
cmpl $0x12c, %ebp            # imm = 0x12C
movl %eax, %ebp
jl 0x66e1
movq %rbx, %rdi
callq 0x63c3
movl 0xc(%rsp), %eax
cmpl 0x14(%rsp), %eax
jne 0x66b0
movl 0x8(%rsp), %eax
cmpl 0x10(%rsp), %eax
jne 0x66b0
movq (%r13), %rdi
callq 0x2300
movq (%r13), %rdi
callq 0x2480
movq $0x0, 0x28(%rsp)
movq $0x7a120, 0x30(%rsp)    # imm = 0x7A120
xorl %ebp, %ebp
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r12, %r8
callq 0x22f0
movq (%r13), %rdi
callq 0x23c0
movl 0xc(%rsp), %esi
movl 0x8(%rsp), %edx
movq %rbx, %rdi
xorl %eax, %eax
callq *%r14
movl 0xc(%rsp), %eax
movl %eax, 0x14(%rsp)
movl 0x8(%rsp), %eax
movl %eax, 0x10(%rsp)
movq %rbx, %rdi
callq 0x63c3
movq (%r13), %rdi
callq 0x2480
movq $0x0, 0x28(%rsp)
movq $0xc350, 0x30(%rsp)     # imm = 0xC350
xorl %edi, %edi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
movq %r12, %r8
callq 0x22f0
jmp 0x65ca
movq %rbx, %rdi
callq 0x63c3
leaq 0x58(%rsp), %r15
movq %r15, %rdi
callq 0x5b87
movq (%r13), %rdi
callq 0x2300
movl 0x40(%r15), %esi
movl 0x44(%r15), %edx
movq %rbx, %rdi
xorl %eax, %eax
callq *%r14
movl 0x30(%rbx), %eax
testl %eax, %eax
jns 0x6745
addl %eax, 0x28(%rbx)
negl %eax
movl %eax, 0x30(%rbx)
movl 0x34(%rbx), %eax
testl %eax, %eax
jns 0x6754
addl %eax, 0x2c(%rbx)
negl %eax
movl %eax, 0x34(%rbx)
leaq 0x4bc5(%rip), %rax      # 0xb320
movl (%rax), %edx
addl %edx, 0x28(%rbx)
addl %edx, 0x2c(%rbx)
addl %edx, %edx
movl 0x30(%rbx), %eax
movl 0x34(%rbx), %ecx
subl %edx, %eax
movl %eax, 0x30(%rbx)
subl %edx, %ecx
movl %ecx, 0x34(%rbx)
cmpl $0x4, %eax
setl %dl
cmpl $0x4, %ecx
setl %sil
orb %dl, %sil
jne 0x679c
cmpl 0x90(%rbx), %eax
jl 0x679c
movl $0x1, %eax
cmpl 0x94(%rbx), %ecx
jge 0x67bc
movl 0x1c(%rsp), %eax
movl %eax, 0x28(%rbx)
movl 0x18(%rsp), %eax
movl %eax, 0x2c(%rbx)
movq 0x40(%rsp), %rax
movl %eax, 0x30(%rbx)
movq 0x38(%rsp), %rax
movl %eax, 0x34(%rbx)
xorl %eax, %eax
addq $0x118, %rsp            # imm = 0x118
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq