// File: /workspace/github_c_makefile_star2_O2/baskerville[P]bspwm/src/window.c
// Function: move_client
bool move_client(coordinates_t *loc, int dx, int dy)
{
	node_t *n = loc->node;

	if (n == NULL || n->client == NULL) {
		return false;
	}

	monitor_t *pm = NULL;

	if (IS_TILED(n->client)) {
		if (!grabbing) {
			return false;
		}
		xcb_window_t pwin = XCB_NONE;
		query_pointer(&pwin, NULL);
		if (pwin == n->id) {
			return false;
		}
		coordinates_t dst;
		bool is_managed = (pwin != XCB_NONE && locate_window(pwin, &dst));
		if (is_managed && dst.monitor == loc->monitor && IS_TILED(dst.node->client)) {
			swap_nodes(loc->monitor, loc->desktop, n, loc->monitor, loc->desktop, dst.node, false);
			return true;
		} else {
			if (is_managed && dst.monitor == loc->monitor) {
				return false;
			} else {
				xcb_point_t pt = {0, 0};
				query_pointer(NULL, &pt);
				pm = monitor_from_point(pt);
			}
		}
	} else {
		client_t *c = n->client;
		xcb_rectangle_t rect = c->floating_rectangle;
		int16_t x = rect.x + dx;
		int16_t y = rect.y + dy;

		window_move(n->id, x, y);

		c->floating_rectangle.x = x;
		c->floating_rectangle.y = y;
		if (!grabbing) {
			put_status(SBSC_MASK_NODE_GEOMETRY, "node_geometry 0x%08X 0x%08X 0x%08X %ux%u+%i+%i\n", loc->monitor->id, loc->desktop->id, loc->node->id, rect.width, rect.height, x, y);
		}
		pm = monitor_from_client(c);
	}

	if (pm == NULL || pm == loc->monitor) {
		return true;
	}

	transfer_node(loc->monitor, loc->desktop, n, pm, pm->desk, pm->desk->focus, true);
	loc->monitor = pm;
	loc->desktop = pm->desk;

	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq 0x10(%rdi), %r14
testq %r14, %r14
je 0xfa00
movq 0x48(%r14), %r15
testq %r15, %r15
je 0xfa00
movq %rdi, %rbx
cmpl $0x1, 0x308(%r15)
ja 0xfa13
leaq 0x1944a(%rip), %rax     # 0x28e26
cmpb $0x1, (%rax)
jne 0xfa00
leaq 0x2c(%rsp), %r15
andl $0x0, (%r15)
movq %r15, %rdi
xorl %esi, %esi
callq 0xfb66
movl (%r15), %edi
cmpl (%r14), %edi
jne 0xfaf3
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movzwl 0x31c(%r15), %eax
movl %eax, 0x24(%rsp)
addw 0x318(%r15), %si
addw 0x31a(%r15), %dx
movzwl 0x31e(%r15), %ebp
movl (%r14), %edi
movswl %si, %r12d
movswl %dx, %r13d
movl %r12d, %esi
movl %r13d, %edx
callq 0xfcea
movw %r12w, 0x318(%r15)
movw %r13w, 0x31a(%r15)
leaq 0x193c2(%rip), %rax     # 0x28e26
cmpb $0x0, (%rax)
jne 0xfaa2
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
movl 0x20(%rax), %edx
movl 0x20(%rcx), %ecx
movq 0x10(%rbx), %rax
movl (%rax), %r8d
movl %r13d, 0x10(%rsp)
movl %r12d, 0x8(%rsp)
movl %ebp, (%rsp)
leaq 0xeb7f(%rip), %rsi      # 0x1e610
movl $0x800000, %edi         # imm = 0x800000
movl 0x24(%rsp), %r9d
xorl %eax, %eax
callq 0x1d07d
movq %r15, %rdi
callq 0x7330
movq %rax, %r15
movb $0x1, %bpl
testq %rax, %rax
je 0xfa02
movq (%rbx), %rdi
cmpq %rdi, %r15
je 0xfa02
movq 0x8(%rbx), %rsi
movq 0x58(%r15), %r8
movq 0x38(%r8), %r9
movl $0x1, (%rsp)
movq %r14, %rdx
movq %r15, %rcx
callq 0x9937
movq %r15, (%rbx)
movq 0x58(%r15), %rax
movq %rax, 0x8(%rbx)
jmp 0xfa02
testl %edi, %edi
je 0xfb0f
leaq 0x30(%rsp), %rsi
callq 0x199cc
testb %al, %al
je 0xfb0f
movq (%rbx), %rcx
cmpq %rcx, 0x30(%rsp)
je 0xfb2f
leaq 0x28(%rsp), %r15
andl $0x0, (%r15)
xorl %edi, %edi
movq %r15, %rsi
callq 0xfb66
movl (%r15), %edi
callq 0x72fe
jmp 0xfaaa
movq 0x40(%rsp), %r9
movq 0x48(%r9), %rax
movl 0x308(%rax), %eax
cmpl $0x2, %eax
setb %bpl
jae 0xfa02
movq 0x8(%rbx), %rsi
andl $0x0, (%rsp)
movq %rcx, %rdi
movq %r14, %rdx
movq %rsi, %r8
callq 0xb2c8
jmp 0xfa02