// File: /workspace/github_c_makefile_star2_O3/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 0x4edd(%rip), %rax      # 0xb330
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 0x64a5
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 0x64ef
movq 0xf8(%rbx), %rax
leaq 0x54d5(%rip), %rcx      # 0xb988
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 0x22d0
addq $0x20, %rsp
leaq 0x5492(%rip), %r13      # 0xb988
movq (%r13), %rdi
callq 0x23d0
movq %rbx, %rdi
callq 0x630c
leaq 0x58(%rsp), %r15
leaq 0x28(%rsp), %r12
xorl %ebp, %ebp
movq (%r13), %rdi
movl $0xc, %esi
movq %r15, %rdx
callq 0x24c0
testl %eax, %eax
je 0x6539
movl 0x58(%rsp), %eax
andl $-0x2, %eax
cmpl $0x4, %eax
jne 0x6513
jmp 0x6651
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 0x22d0
addq $0x20, %rsp
movl 0xc(%rsp), %eax
cmpl 0x14(%rsp), %eax
jne 0x659e
movl 0x8(%rsp), %eax
cmpl 0x10(%rsp), %eax
jne 0x659e
leal 0x1(%rbp), %eax
cmpl $0x12c, %ebp            # imm = 0x12C
movl %eax, %ebp
jl 0x662a
movq %rbx, %rdi
callq 0x630c
movl 0xc(%rsp), %esi
movl 0x8(%rsp), %edx
cmpl 0x14(%rsp), %esi
jne 0x6601
cmpl 0x10(%rsp), %edx
jne 0x6601
movq (%r13), %rdi
callq 0x2310
movq (%r13), %rdi
callq 0x2490
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 0x2300
movq (%r13), %rdi
callq 0x23d0
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 0x630c
movq (%r13), %rdi
callq 0x2490
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 0x2300
jmp 0x6513
movq %rbx, %rdi
callq 0x630c
leaq 0x58(%rsp), %r15
movq %r15, %rdi
callq 0x5b13
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 0x668b
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 0x4c8a(%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 0x66e3
cmpl 0x90(%rbx), %eax
jl 0x66e3
movl $0x1, %eax
cmpl 0x94(%rbx), %ecx
jge 0x6703
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