// File: /workspace/github_c_makefile_star2_O2/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 $0xe8, %rsp
movq %rdx, %r14
movq %rdi, %rbx
movl 0x28(%rdi), %ecx
movl 0x2c(%rdi), %edx
movl 0x30(%rdi), %edi
movl 0x34(%rbx), %r8d
leaq 0x52be(%rip), %rax      # 0xb330
movl (%rax), %eax
movl %ecx, 0x14(%rsp)
subl %eax, %ecx
movl %ecx, 0x28(%rbx)
movl %edx, 0x10(%rsp)
movl %edx, %ecx
subl %eax, %ecx
movl %ecx, 0x2c(%rbx)
movq %rdi, 0x20(%rsp)
leal (%rdi,%rax,2), %ecx
movl %ecx, 0x30(%rbx)
movq %r8, 0x18(%rsp)
leal (%r8,%rax,2), %eax
movl %eax, 0x34(%rbx)
testq %rsi, %rsi
je 0x60c4
movl 0x40(%rsi), %eax
movl %eax, 0xc(%rsp)
movl %eax, 0x28(%rbx)
movl 0x44(%rsi), %edx
movl %edx, 0x8(%rsp)
movl %edx, 0x2c(%rbx)
movq %rbx, %rdi
movl %eax, %esi
xorl %eax, %eax
callq *%r14
jmp 0x60da
movq 0xf8(%rbx), %rdx
leaq 0xc(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x6419
leaq 0x58a7(%rip), %r13      # 0xb988
movq (%r13), %rdi
callq 0x23d0
movq %rbx, %rdi
callq 0x5f41
pushq $0xc
popq %r15
leaq 0x28(%rsp), %r12
xorl %ebp, %ebp
movq (%r13), %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x24c0
testl %eax, %eax
je 0x6121
movl 0x28(%rsp), %eax
andl $-0x2, %eax
cmpl $0x4, %eax
jne 0x60fd
jmp 0x61d3
movq 0xf8(%rbx), %rdx
leaq 0x4(%rsp), %rdi
movq %rsp, %rsi
callq 0x6419
movl 0x4(%rsp), %eax
cmpl 0xc(%rsp), %eax
jne 0x6155
movl (%rsp), %eax
cmpl 0x8(%rsp), %eax
jne 0x6155
leal 0x1(%rbp), %eax
cmpl $0x12c, %ebp            # imm = 0x12C
movl %eax, %ebp
jl 0x61c6
movq %rbx, %rdi
callq 0x5f41
movl 0x4(%rsp), %esi
movl (%rsp), %edx
cmpl 0xc(%rsp), %esi
jne 0x619e
cmpl 0x8(%rsp), %edx
jne 0x619e
movq (%r13), %rdi
callq 0x2310
movq (%r13), %rdi
callq 0x2490
movl $0x1f4, %edi            # imm = 0x1F4
callq 0x6011
movq (%r13), %rdi
callq 0x23d0
movl 0x4(%rsp), %esi
xorl %ebp, %ebp
movl (%rsp), %edx
movq %rbx, %rdi
xorl %eax, %eax
callq *%r14
movl 0x4(%rsp), %eax
movl %eax, 0xc(%rsp)
movl (%rsp), %eax
movl %eax, 0x8(%rsp)
movq %rbx, %rdi
callq 0x5f41
movq (%r13), %rdi
callq 0x2490
pushq $0x32
popq %rdi
callq 0x6011
jmp 0x60fd
movq %rbx, %rdi
callq 0x5f41
leaq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0x57ae
movq (%r13), %rdi
callq 0x2310
movl 0x40(%r15), %esi
movl 0x44(%r15), %edx
movq %rbx, %rdi
xorl %eax, %eax
callq *%r14
movl 0x30(%rbx), %eax
testl %eax, %eax
jns 0x620d
addl %eax, 0x28(%rbx)
negl %eax
movl 0x34(%rbx), %edx
movl %edx, %ecx
negl %ecx
cmovsl %edx, %ecx
movl %edx, %esi
sarl $0x1f, %esi
andl %edx, %esi
addl 0x2c(%rbx), %esi
leaq 0x5108(%rip), %rdx      # 0xb330
movl (%rdx), %edx
addl %edx, 0x28(%rbx)
addl %edx, %esi
movl %esi, 0x2c(%rbx)
addl %edx, %edx
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 0x6260
cmpl 0x90(%rbx), %eax
jl 0x6260
cmpl 0x94(%rbx), %ecx
jge 0x6292
movl 0x14(%rsp), %eax
movl %eax, 0x28(%rbx)
movl 0x10(%rsp), %eax
movl %eax, 0x2c(%rbx)
movq 0x20(%rsp), %rax
movl %eax, 0x30(%rbx)
movq 0x18(%rsp), %rax
movl %eax, 0x34(%rbx)
xorl %eax, %eax
addq $0xe8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x1
popq %rax
jmp 0x6280