// File: /workspace/github_c_makefile_star2_O1/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 0x1078e
movq 0x48(%r14), %r15
testq %r15, %r15
je 0x1078e
movq %rdi, %rbx
cmpl $0x1, 0x308(%r15)
ja 0x107a7
leaq 0x196e6(%rip), %rax     # 0x29e26
cmpb $0x1, (%rax)
jne 0x1078e
leaq 0x2c(%rsp), %r12
movl $0x0, (%r12)
xorl %r15d, %r15d
movq %r12, %rdi
xorl %esi, %esi
callq 0x10928
movl (%r12), %edi
movl $0x0, %eax
movl $0x0, %r12d
cmpl (%r14), %edi
je 0x1091b
testl %edi, %edi
je 0x1089c
leaq 0x30(%rsp), %rsi
callq 0x1b0a3
jmp 0x1089e
xorl %r12d, %r12d
andb $0x1, %r12b
movl %r12d, %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 0x18ee1(%rip), %rdx     # 0x296c8
movq (%rdx), %rdi
movl %eax, %esi
movl $0x3, %edx
callq 0x4310
movw %r13w, 0x318(%r15)
movw %bp, 0x31a(%r15)
leaq 0x19619(%rip), %rax     # 0x29e26
cmpb $0x0, (%rax)
jne 0x1084b
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 0xede6(%rip), %rsi      # 0x1f620
movl $0x800000, %edi         # imm = 0x800000
movl 0x24(%rsp), %r9d
xorl %eax, %eax
callq 0x1eb0b
movq %r15, %rdi
callq 0x7565
movq %rax, %r15
movb $0x1, %r12b
testq %r15, %r15
je 0x10791
movq (%rbx), %rdi
cmpq %rdi, %r15
je 0x10791
movq 0x8(%rbx), %rsi
movq 0x58(%r15), %r8
movq 0x38(%r8), %r9
movl $0x1, (%rsp)
movq %r14, %rdx
movq %r15, %rcx
callq 0x9e52
movq %r15, (%rbx)
movq 0x58(%r15), %rax
movq %rax, 0x8(%rbx)
jmp 0x10791
xorl %eax, %eax
testb %al, %al
je 0x108f8
movq 0x30(%rsp), %rdx
movq (%rbx), %rcx
cmpq %rcx, %rdx
jne 0x108e4
movq 0x40(%rsp), %r9
movq 0x48(%r9), %rsi
cmpl $0x1, 0x308(%rsi)
ja 0x108e4
movq 0x8(%rbx), %rsi
movl $0x0, (%rsp)
movq %rcx, %rdi
movq %r14, %rdx
movq %rsi, %r8
callq 0xba8a
movb $0x1, %r12b
xorl %r15d, %r15d
xorl %eax, %eax
jmp 0x1091b
cmpq %rcx, %rdx
sete %cl
testb %cl, %al
je 0x108f8
xorl %r15d, %r15d
xorl %eax, %eax
xorl %r12d, %r12d
jmp 0x1091b
leaq 0x28(%rsp), %r15
movl $0x0, (%r15)
xorl %edi, %edi
movq %r15, %rsi
callq 0x10928
movl (%r15), %edi
callq 0x752f
movq %rax, %r15
movb $0x1, %al
testb %al, %al
je 0x10791
jmp 0x10856