// File: /workspace/github_c_makefile_star2_O2/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 $0x108, %rsp            # imm = 0x108
movq %rdi, %r14
movq 0x5437(%rip), %rdi      # 0x94e8
movq 0x28(%rdi), %rbx
testq %rbx, %rbx
je 0x4434
cmpl $0x0, 0x18(%rbx)
jne 0x4434
callq 0x3b63
movq 0x53ec(%rip), %rdi      # 0x94c0
movq 0x54d5(%rip), %rsi      # 0x95b0
movq 0x54d6(%rip), %rax      # 0x95b8
andq $0x0, 0x10(%rsp)
movq %rax, 0x8(%rsp)
andq $0x0, (%rsp)
pushq $0x4c
popq %rcx
pushq $0x1
popq %r8
xorl %edx, %edx
movl %r8d, %r9d
callq 0x2170
testl %eax, %eax
jne 0x4434
leaq 0x34(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x4446
testl %eax, %eax
je 0x4434
movl %r14d, %eax
movq %rax, 0x38(%rsp)
cmpl $0x1, %eax
jne 0x4173
movq 0x30(%rbx), %rcx
movq %rcx, 0x28(%rsp)
testq %rcx, %rcx
je 0x4434
movq 0x5378(%rip), %rdi      # 0x94c0
movq 0x38(%rbx), %rdx
movl 0x8(%rbx), %eax
movl 0xc(%rbx), %ecx
incl %eax
incl %ecx
andl $0x0, (%rsp)
movl %ecx, 0x10(%rsp)
movl %eax, 0x8(%rsp)
xorl %esi, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x2360
jmp 0x417c
movq $0x0, 0x28(%rsp)
movl (%rbx), %eax
movl %eax, 0x24(%rsp)
movl 0x4(%rbx), %eax
movl %eax, 0x20(%rsp)
leaq 0x48(%rsp), %r14
leaq 0x50fb(%rip), %r12      # 0x9290
xorl %r15d, %r15d
movq 0x5321(%rip), %rdi      # 0x94c0
movl $0x10804c, %esi         # imm = 0x10804C
movq %r14, %rdx
callq 0x2340
movl 0x48(%rsp), %eax
cmpq $0x6, %rax
je 0x41da
cmpl $0xc, %eax
je 0x41c5
cmpl $0x17, %eax
je 0x41c5
cmpl $0x14, %eax
jne 0x41d0
movq %r14, %rdi
callq *(%r12,%rax,8)
movl 0x48(%rsp), %eax
cmpl $0x5, %eax
jne 0x4198
jmp 0x4389
movq 0x80(%rsp), %rcx
movq %rcx, %rax
subq %r15, %rax
cmpq $0x11, %rax
jb 0x41cc
movq %rcx, 0x40(%rsp)
cmpl $0x1, 0x38(%rsp)
jne 0x426e
movl (%rbx), %r12d
movl 0x4(%rbx), %r13d
movl 0x88(%rsp), %ebp
subl 0x24(%rsp), %ebp
testl %ebp, %ebp
movl $0x0, %eax
cmovlel %eax, %ebp
movl 0x8c(%rsp), %r15d
incl %ebp
subl 0x20(%rsp), %r15d
testl %r15d, %r15d
cmovlel %eax, %r15d
incl %r15d
movq 0x28(%rsp), %rax
movl 0x8(%rax), %edx
addl %ebp, %edx
movq 0x52a8(%rip), %rax      # 0x94e8
movl 0x8(%rax), %ecx
cmpl %ecx, %edx
jl 0x42a3
movl 0x14(%rax), %esi
addl %ecx, %esi
cmpl %esi, %edx
jg 0x42a3
movq 0x28(%rsp), %rdx
movl 0x18(%rdx), %edx
addl %r15d, %edx
movl 0x18(%rax), %esi
cmpl %esi, %edx
jl 0x42a3
addl 0x1c(%rax), %esi
cmpl %esi, %edx
jg 0x42a3
jmp 0x431d
movl 0x88(%rsp), %r12d
addl 0x24(%rsp), %r12d
subl 0x34(%rsp), %r12d
movl 0x8c(%rsp), %r13d
addl 0x20(%rsp), %r13d
subl 0x30(%rsp), %r13d
movl 0x8(%rbx), %ebp
movl 0xc(%rbx), %r15d
movq 0x5248(%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 0x42b9
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 0x42db
movl %edx, %r12d
jmp 0x42e0
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 0x42f9
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 0x431a
subl %esi, %ecx
movl %ecx, %edx
movl %edx, %r13d
cmpl $0x0, 0x10(%rbx)
je 0x4353
movq %rbx, %rdi
movl %r12d, %esi
movl %r13d, %edx
movl %ebp, %ecx
movl %r15d, %r8d
callq 0x3c26
movq 0x5183(%rip), %rdi      # 0x94c0
callq 0x2320
movq 0x40(%rsp), %r15
leaq 0x4f42(%rip), %r12      # 0x9290
jmp 0x41cc
movq 0x40(%rax), %rax
leaq 0x125(%rip), %rcx       # 0x4483
cmpq %rcx, 0x8(%rax)
je 0x436f
callq 0x300d
cmpl $0x0, 0x10(%rbx)
jne 0x4323
movq 0x5172(%rip), %rax      # 0x94e8
movq 0x40(%rax), %rax
leaq 0x102(%rip), %rcx       # 0x4483
cmpq %rcx, 0x8(%rax)
jne 0x4336
jmp 0x4323
movq 0x5130(%rip), %rdi      # 0x94c0
cmpl $0x1, 0x38(%rsp)
jne 0x43ef
movq 0x38(%rbx), %rdx
movl 0x8(%rbx), %eax
movl 0xc(%rbx), %ecx
incl %eax
incl %ecx
andl $0x0, (%rsp)
movl %ecx, 0x10(%rsp)
movl %eax, 0x8(%rsp)
xorl %esi, %esi
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0x2360
movq 0x50f9(%rip), %rdi      # 0x94c0
xorl %esi, %esi
callq 0x2100
pushq $0x10
popq %r14
leaq 0x48(%rsp), %r15
movq 0x50e2(%rip), %rdi      # 0x94c0
movq %r14, %rsi
movq %r15, %rdx
callq 0x22c0
testl %eax, %eax
jne 0x43d7
jmp 0x43f6
xorl %esi, %esi
callq 0x2100
movl (%rbx), %edi
movl 0x4(%rbx), %esi
callq 0x44c3
testq %rax, %rax
je 0x442c
movq %rax, %r14
cmpq 0x50d9(%rip), %rax      # 0x94e8
je 0x442c
movq %rbx, %rdi
movq %r14, %rsi
callq 0x44fc
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0x45b1
callq 0x4701
movq %rbx, %rdi
callq 0x3c7d
addq $0x108, %rsp            # imm = 0x108
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq