// File: /workspace/github_c_makefile_star2_O3/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 0x107de
movq 0x48(%r14), %r15
testq %r15, %r15
je 0x107de
movq %rdi, %rbx
cmpl $0x1, 0x308(%r15)
ja 0x107f1
leaq 0x1966f(%rip), %rax     # 0x29e26
cmpb $0x1, (%rax)
jne 0x107de
leaq 0x2c(%rsp), %r15
movl $0x0, (%r15)
movq %r15, %rdi
xorl %esi, %esi
callq 0x1095f
movl (%r15), %edi
cmpl (%r14), %edi
jne 0x108e6
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)
movzwl 0x31e(%r15), %r12d
addw 0x318(%r15), %si
addw 0x31a(%r15), %dx
movl (%r14), %eax
movswl %si, %r13d
leaq 0x30(%rsp), %rcx
movl %r13d, (%rcx)
movswl %dx, %ebp
movl %ebp, 0x4(%rcx)
leaq 0x18e97(%rip), %rdx     # 0x296c8
movq (%rdx), %rdi
movl %eax, %esi
movl $0x3, %edx
callq 0x4310
movw %r13w, 0x318(%r15)
movw %bp, 0x31a(%r15)
leaq 0x195cf(%rip), %rax     # 0x29e26
cmpb $0x0, (%rax)
jne 0x10895
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
movl 0x20(%rax), %edx
movl 0x20(%rcx), %ecx
movq 0x10(%rbx), %rax
movl (%rax), %r8d
movl %ebp, 0x10(%rsp)
movl %r13d, 0x8(%rsp)
movl %r12d, (%rsp)
leaq 0xed8c(%rip), %rsi      # 0x1f610
movl $0x800000, %edi         # imm = 0x800000
movl 0x24(%rsp), %r9d
xorl %eax, %eax
callq 0x1e6b8
movq %r15, %rdi
callq 0x747e
movq %rax, %r15
movb $0x1, %bpl
testq %rax, %rax
je 0x107e0
movq (%rbx), %rdi
cmpq %rdi, %r15
je 0x107e0
movq 0x8(%rbx), %rsi
movq 0x58(%r15), %r8
movq 0x38(%r8), %r9
movl $0x1, (%rsp)
movq %r14, %rdx
movq %r15, %rcx
callq 0x9e6b
movq %r15, (%rbx)
movq 0x58(%r15), %rax
movq %rax, 0x8(%rbx)
jmp 0x107e0
testl %edi, %edi
je 0x10902
leaq 0x30(%rsp), %rsi
callq 0x1ae3e
testb %al, %al
je 0x10902
movq (%rbx), %rcx
cmpq %rcx, 0x30(%rsp)
je 0x10925
leaq 0x28(%rsp), %r15
movl $0x0, (%r15)
xorl %edi, %edi
movq %r15, %rsi
callq 0x1095f
movl (%r15), %edi
callq 0x7446
jmp 0x1089d
movq 0x40(%rsp), %r9
movq 0x48(%r9), %rax
movl 0x308(%rax), %eax
cmpl $0x2, %eax
setb %bpl
jae 0x107e0
movq 0x8(%rbx), %rsi
movl $0x0, (%rsp)
movq %rcx, %rdi
movq %r14, %rdx
movq %rsi, %r8
callq 0xbad5
jmp 0x107e0