// File: /workspace/github_c_makefile_star2_O3/gitluin[P]sara/src/sara.c
// Function: manipulate
void
manipulate(const Arg arg){
	int x, y, ocx, ocy, nx, ny, nw, nh;
	client* c;
	XEvent ev;
	int doresize = (arg.i == WantResize), trytoggle = 0;
	monitor* m = NULL;
	Time lasttime = 0;

	if ( !(c = curmon->current) || c->isfull )
		return;

	restack(curmon);

	if (XGrabPointer(dis, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
		None, cursor, CurrentTime) != GrabSuccess)
		return;

	if (!getptrcoords(&x, &y))
		return;

	if (doresize){
		if ( !(m = c->mon) )
			return;
		XWarpPointer(dis, None, c->win, 0, 0, 0, 0, c->w + 1, c->h + 1);
	}

	ocx = c->x;
	ocy = c->y;
	do {
		XMaskEvent(dis, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
		switch(ev.type){
		case ConfigureRequest:
		case Expose:
		case MapRequest:
			events[ev.type](&ev);
			break;
		case MotionNotify:
			if ((ev.xmotion.time - lasttime) <= (1000 / 60))
				continue;
			lasttime = ev.xmotion.time;

			/* Only adjust if moving */
			nx = doresize ? c->x : ocx + (ev.xmotion.x - x);
			ny = doresize ? c->y : ocy + (ev.xmotion.y - y);
			/* Only adjust if resizing */
			nw = doresize ? MAX(ev.xmotion.x - ocx + 1, 1) : c->w;
			nh = doresize ? MAX(ev.xmotion.y - ocy + 1, 1) : c->h;

			/* if c extends beyond the boundaries of its monitor, make it a float */
			if (doresize && (m->mx + nw >= curmon->mx
						&& m->mx + nw <= curmon->mx + curmon->mw
						&& m->wy + nh >= curmon->wy
						&& m->wy + nh <= curmon->wy + curmon->wh)){
				trytoggle = 1;

			} else {
				/* if c is within snappx of the monitor borders,
				 * then snap and make it a float
				 */
				nx = (abs(curmon->mx - nx) < snappx) ? curmon->mx : nx;
				nx = (abs((curmon->mx + curmon->mw) - (nx + c->w)) < snappx)
					? curmon->mx + curmon->mw - c->w : nx;
				ny = (abs(curmon->wy - ny) < snappx) ? curmon->wy : ny;
				ny = (abs((curmon->wy + curmon->wh) - (ny + c->h)) < snappx)
					? curmon->wy + curmon->wh - c->h : ny;
				trytoggle = 1;
			}
			/* don't toggle if floating layout, do resize if floating */
			if (!c->isfloat && trytoggle && !(curmon->curlayout->arrange == &floaty))
				togglefloat(dumbarg);
			if (c->isfloat || (curmon->curlayout->arrange == &floaty))
				resizeclient(c, nx, ny, nw, nh);
			XFlush(dis);
			break;
		}
	} while (ev.type != ButtonRelease);

	if (doresize)
		XWarpPointer(dis, None, c->win, 0, 0, 0, 0, c->w + 1, c->h + 1);
	XUngrabPointer(dis, CurrentTime);

	if (doresize)
		while (XCheckMaskEvent(dis, EnterWindowMask, &ev));

	if ( (m = coordstomon(c->x, c->y)) && m != curmon){
		sendmon(c, m);
		changemon(m, YesFocus);
		outputstats();
	}
#ifdef _SHAPE_H_
	roundcorners(c);
#endif
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rdi, %r14
movq 0x50c2(%rip), %rdi      # 0x94e8
movq 0x28(%rdi), %rbx
testq %rbx, %rbx
je 0x47d7
cmpl $0x0, 0x18(%rbx)
jne 0x47d7
callq 0x3dff
movq 0x5077(%rip), %rdi      # 0x94c0
movq 0x5160(%rip), %rsi      # 0x95b0
subq $0x8, %rsp
xorl %eax, %eax
xorl %edx, %edx
movl $0x4c, %ecx
movl $0x1, %r8d
movl $0x1, %r9d
pushq %rax
pushq 0x5148(%rip)            # 0x95b8
pushq %rax
callq 0x2170
addq $0x20, %rsp
testl %eax, %eax
jne 0x47d7
movq 0x5037(%rip), %rdi      # 0x94c0
movq 0x5120(%rip), %rsi      # 0x95b0
subq $0x8, %rsp
leaq 0x38(%rsp), %rax
leaq 0x3c(%rsp), %r10
leaq 0x40(%rsp), %rcx
leaq 0x24(%rsp), %r8
leaq 0x20(%rsp), %r9
movq %rcx, %rdx
pushq %rax
pushq %r10
pushq %r10
callq 0x23d0
addq $0x20, %rsp
testl %eax, %eax
je 0x47d7
movl %r14d, %eax
movq %rax, 0x20(%rsp)
cmpl $0x1, %eax
jne 0x451a
movq 0x30(%rbx), %rcx
movq %rcx, 0x10(%rsp)
testq %rcx, %rcx
je 0x47d7
movq 0x4fd4(%rip), %rdi      # 0x94c0
movq 0x38(%rbx), %rdx
movl 0x8(%rbx), %eax
movl 0xc(%rbx), %r10d
incl %eax
incl %r10d
subq $0x8, %rsp
xorl %esi, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %r10
pushq %rax
pushq $0x0
callq 0x2360
addq $0x20, %rsp
jmp 0x4523
movq $0x0, 0x10(%rsp)
movl (%rbx), %eax
movl %eax, 0xc(%rsp)
movl 0x4(%rbx), %eax
movl %eax, 0x8(%rsp)
leaq 0x38(%rsp), %r14
leaq 0x4d54(%rip), %r12      # 0x9290
xorl %r15d, %r15d
movq 0x4f7a(%rip), %rdi      # 0x94c0
movl $0x10804c, %esi         # imm = 0x10804C
movq %r14, %rdx
callq 0x2340
movslq 0x38(%rsp), %rax
cmpq $0x13, %rax
jg 0x456a
cmpl $0x6, %eax
je 0x4589
cmpl $0xc, %eax
je 0x4574
jmp 0x457f
cmpl $0x17, %eax
je 0x4574
cmpl $0x14, %eax
jne 0x457f
movq %r14, %rdi
callq *(%r12,%rax,8)
movl 0x38(%rsp), %eax
cmpl $0x5, %eax
jne 0x453f
jmp 0x4729
movq 0x70(%rsp), %rcx
movq %rcx, %rax
subq %r15, %rax
cmpq $0x11, %rax
jb 0x457b
movq %rcx, 0x28(%rsp)
cmpl $0x1, 0x20(%rsp)
jne 0x4614
movl (%rbx), %r12d
movl 0x4(%rbx), %r13d
movl 0x78(%rsp), %ebp
subl 0xc(%rsp), %ebp
testl %ebp, %ebp
movl $0x0, %eax
cmovlel %eax, %ebp
movl 0x7c(%rsp), %r15d
incl %ebp
subl 0x8(%rsp), %r15d
testl %r15d, %r15d
cmovlel %eax, %r15d
incl %r15d
movq 0x10(%rsp), %rax
movl 0x8(%rax), %edx
addl %ebp, %edx
movq 0x4f02(%rip), %rax      # 0x94e8
movl 0x8(%rax), %ecx
cmpl %ecx, %edx
jl 0x4643
movl 0x14(%rax), %esi
addl %ecx, %esi
cmpl %esi, %edx
jg 0x4643
movq 0x10(%rsp), %rdx
movl 0x18(%rdx), %edx
addl %r15d, %edx
movl 0x18(%rax), %esi
cmpl %esi, %edx
jl 0x4643
addl 0x1c(%rax), %esi
cmpl %esi, %edx
jg 0x4643
jmp 0x46bd
movl 0x78(%rsp), %r12d
addl 0xc(%rsp), %r12d
subl 0x1c(%rsp), %r12d
movl 0x7c(%rsp), %r13d
addl 0x8(%rsp), %r13d
subl 0x18(%rsp), %r13d
movl 0x8(%rbx), %ebp
movl 0xc(%rbx), %r15d
movq 0x4ea8(%rip), %rax      # 0x94e8
movl 0x8(%rax), %ecx
movl %ecx, %edx
subl %r12d, %edx
movl %edx, %esi
negl %esi
cmovsl %edx, %esi
movl %ecx, %edx
cmpl $0x20, %esi
jb 0x4659
movl %r12d, %edx
addl 0x14(%rax), %ecx
movl 0x8(%rbx), %esi
movl %ecx, %r8d
subl %esi, %r8d
subl %edx, %r8d
movl %r8d, %edi
negl %edi
cmovsl %r8d, %edi
cmpl $0x20, %edi
jb 0x467b
movl %edx, %r12d
jmp 0x4680
subl %esi, %ecx
movl %ecx, %r12d
movl 0x18(%rax), %ecx
movl %ecx, %edx
subl %r13d, %edx
movl %edx, %esi
negl %esi
cmovsl %edx, %esi
movl %ecx, %edx
cmpl $0x20, %esi
jb 0x4699
movl %r13d, %edx
movl 0xc(%rbx), %esi
addl 0x1c(%rax), %ecx
movl %ecx, %r8d
subl %esi, %r8d
subl %edx, %r8d
movl %r8d, %edi
negl %edi
cmovsl %r8d, %edi
cmpl $0x20, %edi
jae 0x46ba
subl %esi, %ecx
movl %ecx, %edx
movl %edx, %r13d
cmpl $0x0, 0x10(%rbx)
je 0x46f3
movq %rbx, %rdi
movl %r12d, %esi
movl %r13d, %edx
movl %ebp, %ecx
movl %r15d, %r8d
callq 0x3ec4
movq 0x4de3(%rip), %rdi      # 0x94c0
callq 0x2320
movq 0x28(%rsp), %r15
leaq 0x4ba2(%rip), %r12      # 0x9290
jmp 0x457b
movq 0x40(%rax), %rax
leaq 0xeb(%rip), %rcx        # 0x47e9
cmpq %rcx, 0x8(%rax)
je 0x470f
callq 0x31c6
cmpl $0x0, 0x10(%rbx)
jne 0x46c3
movq 0x4dd2(%rip), %rax      # 0x94e8
movq 0x40(%rax), %rax
leaq 0xc8(%rip), %rcx        # 0x47e9
cmpq %rcx, 0x8(%rax)
jne 0x46d6
jmp 0x46c3
movq 0x4d90(%rip), %rdi      # 0x94c0
cmpl $0x1, 0x20(%rsp)
jne 0x4790
movq 0x38(%rbx), %rdx
movl 0x8(%rbx), %eax
movl 0xc(%rbx), %r10d
incl %eax
incl %r10d
subq $0x8, %rsp
xorl %esi, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq %r10
pushq %rax
pushq $0x0
callq 0x2360
addq $0x20, %rsp
movq 0x4d56(%rip), %rdi      # 0x94c0
xorl %esi, %esi
callq 0x2100
leaq 0x38(%rsp), %r14
movq 0x4d43(%rip), %rdi      # 0x94c0
movl $0x10, %esi
movq %r14, %rdx
callq 0x22c0
testl %eax, %eax
jne 0x4776
jmp 0x4797
xorl %esi, %esi
callq 0x2100
movl (%rbx), %edi
movl 0x4(%rbx), %esi
callq 0x4833
testq %rax, %rax
je 0x47cf
movq %rax, %r14
cmpq 0x4d38(%rip), %rax      # 0x94e8
je 0x47cf
movq %rbx, %rdi
movq %r14, %rsi
callq 0x486b
movq %r14, %rdi
movl $0x1, %esi
callq 0x4953
callq 0x4a60
movq %rbx, %rdi
callq 0x3f1d
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq