// File: /workspace/github_c_makefile_star2_O1/baskerville[P]bspwm/src/window.c
// Function: resize_client
bool resize_client(coordinates_t *loc, resize_handle_t rh, int dx, int dy, bool relative)
{
	node_t *n = loc->node;
	if (n == NULL || n->client == NULL || n->client->state == STATE_FULLSCREEN) {
		return false;
	}
	node_t *horizontal_fence = NULL, *vertical_fence = NULL;
	xcb_rectangle_t rect = get_rectangle(NULL, NULL, n);
	uint16_t width = rect.width, height = rect.height;
	int16_t x = rect.x, y = rect.y;
	if (n->client->state == STATE_TILED) {
		if (rh & HANDLE_LEFT) {
			vertical_fence = find_fence(n, DIR_WEST);
		} else if (rh & HANDLE_RIGHT) {
			vertical_fence = find_fence(n, DIR_EAST);
		}
		if (rh & HANDLE_TOP) {
			horizontal_fence = find_fence(n, DIR_NORTH);
		} else if (rh & HANDLE_BOTTOM) {
			horizontal_fence = find_fence(n, DIR_SOUTH);
		}
		if (vertical_fence == NULL && horizontal_fence == NULL) {
			return false;
		}
		if (vertical_fence != NULL) {
			double sr = 0.0;
			if (relative) {
				sr = vertical_fence->split_ratio + (double) dx / (double) vertical_fence->rectangle.width;
			} else {
				sr = (double) (dx - vertical_fence->rectangle.x) / (double) vertical_fence->rectangle.width;
			}
			sr = MAX(0, sr);
			sr = MIN(1, sr);
			vertical_fence->split_ratio = sr;
			adjust_ratios(vertical_fence, vertical_fence->rectangle);
		}
		if (horizontal_fence != NULL) {
			double sr = 0.0;
			if (relative) {
				sr = horizontal_fence->split_ratio + (double) dy / (double) horizontal_fence->rectangle.height;
			} else {
				sr = (double) (dy - horizontal_fence->rectangle.y) / (double) horizontal_fence->rectangle.height;
			}
			sr = MAX(0, sr);
			sr = MIN(1, sr);
			horizontal_fence->split_ratio = sr;
			adjust_ratios(horizontal_fence, horizontal_fence->rectangle);
		}
		arrange(loc->monitor, loc->desktop);
	} else {
		int w = width, h = height;
		if (relative) {
			w += dx * (rh & HANDLE_LEFT ? -1 : (rh & HANDLE_RIGHT ? 1 : 0));
			h += dy * (rh & HANDLE_TOP ? -1 : (rh & HANDLE_BOTTOM ? 1 : 0));
		} else {
			if (rh & HANDLE_LEFT) {
				w = x + width - dx;
			} else if (rh & HANDLE_RIGHT) {
				w = dx - x;
			}
			if (rh & HANDLE_TOP) {
				h = y + height - dy;
			} else if (rh & HANDLE_BOTTOM) {
				h = dy - y;
			}
		}
		width = MAX(1, w);
		height = MAX(1, h);
		apply_size_hints(n->client, &width, &height);
		if (rh & HANDLE_LEFT) {
			x += rect.width - width;
		}
		if (rh & HANDLE_TOP) {
			y += rect.height - height;
		}
		n->client->floating_rectangle = (xcb_rectangle_t) {x, y, width, height};
		if (n->client->state == STATE_FLOATING) {
			window_move_resize(n->id, x, y, width, height);

			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, width, height, x, y);
			}
		} else {
			arrange(loc->monitor, loc->desktop);
		}
	}
	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 0x10b14
movq 0x48(%r14), %rax
testq %rax, %rax
je 0x10b14
cmpl $0x3, 0x308(%rax)
jne 0x10b29
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %r8d, %r13d
movl %edx, %ebp
movl %esi, %r15d
movq %rdi, %rbx
movl %ecx, 0x4(%rsp)
xorl %edi, %edi
xorl %esi, %esi
movq %r14, %rdx
callq 0x982d
movq %rax, %r12
shrq $0x20, %r12
movq %rax, %r8
shrq $0x30, %r8
movw %r12w, 0xa(%rsp)
movw %r8w, 0x8(%rsp)
movq 0x48(%r14), %rdi
movl 0x308(%rdi), %ecx
testl %ecx, %ecx
je 0x10bd8
movl %ecx, 0xc(%rsp)
movq %rbx, 0x10(%rsp)
movq %rax, %rbx
shrq $0x10, %rbx
movzwl %r12w, %r9d
testb %r13b, %r13b
movq %rax, 0x28(%rsp)
movq %rbx, 0x20(%rsp)
movq %r8, 0x18(%rsp)
je 0x10bf3
movl %r15d, %edx
andl $0x1, %edx
movl %r15d, %esi
shrl $0x2, %esi
andl $0x1, %esi
xorl %ecx, %ecx
negl %edx
movl $0x0, %edx
sbbl %edx, %edx
orl %esi, %edx
imull %ebp, %edx
addl %edx, %r9d
movl %r15d, %edx
andl $0x2, %edx
movl %r15d, %esi
shrl $0x3, %esi
andl $0x1, %esi
negl %edx
sbbl %ecx, %ecx
orl %esi, %ecx
imull 0x4(%rsp), %ecx
addl %r8d, %ecx
jmp 0x10ca5
movl $0x1, %esi
testb $0x1, %r15b
jne 0x10c09
movl $0x3, %esi
testb $0x4, %r15b
jne 0x10c09
xorl %r12d, %r12d
jmp 0x10c14
testb $0x1, %r15b
jne 0x10c73
testb $0x4, %r15b
je 0x10c7b
movswl %ax, %ecx
subl %ecx, %ebp
movl %ebp, %r9d
jmp 0x10c7b
movq %r14, %rdi
callq 0xacd5
movq %rax, %r12
xorl %esi, %esi
testb $0x2, %r15b
jne 0x10c2c
movl $0x2, %esi
testb $0x8, %r15b
jne 0x10c2c
xorl %r14d, %r14d
jmp 0x10c37
movq %r14, %rdi
callq 0xacd5
movq %rax, %r14
movq %r12, %rax
orq %r14, %rax
je 0x10b14
testq %r12, %r12
je 0x10e0d
testb %r13b, %r13b
je 0x10dcb
cvtsi2sd %ebp, %xmm0
movzwl 0x1c(%r12), %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
addsd 0x8(%r12), %xmm0
jmp 0x10de5
movswl %ax, %ecx
subl %ebp, %ecx
addl %ecx, %r9d
testb $0x2, %r15b
jne 0x10c8c
testb $0x8, %r15b
jne 0x10c9a
movl %r8d, %ecx
jmp 0x10ca5
movswl %bx, %edx
movl %r8d, %ecx
subl 0x4(%rsp), %ecx
addl %edx, %ecx
jmp 0x10ca5
movswl %bx, %ecx
movl 0x4(%rsp), %edx
subl %ecx, %edx
movl %edx, %ecx
cmpl $0x2, %r9d
movl $0x1, %ebp
cmovll %ebp, %r9d
leaq 0xa(%rsp), %rbx
movw %r9w, (%rbx)
cmpl $0x2, %ecx
cmovll %ebp, %ecx
leaq 0x8(%rsp), %rdx
movw %cx, (%rdx)
movq %rdi, %r13
movq %rbx, %rsi
callq 0x10e94
andl %r15d, %ebp
movzwl (%rbx), %edx
subl %edx, %r12d
testl %ebp, %ebp
cmovel %ebp, %r12d
movq 0x28(%rsp), %rax
addl %r12d, %eax
leaq 0x8(%rsp), %rcx
movzwl (%rcx), %r12d
movq 0x20(%rsp), %rbx
movl %ebx, %ecx
addl 0x18(%rsp), %ecx
subl %r12d, %ecx
testb $0x2, %r15b
cmovnel %ecx, %ebx
movw %ax, 0x318(%r13)
movw %bx, 0x31a(%r13)
movw %dx, 0x31c(%r13)
movw %r12w, 0x31e(%r13)
cmpl $0x2, 0xc(%rsp)
jne 0x10dba
movl (%r14), %esi
movswl %ax, %r15d
leaq 0x30(%rsp), %rcx
movl %r15d, (%rcx)
movswl %bx, %ebp
movl %ebp, 0x4(%rcx)
movl %edx, %ebx
movl %edx, 0x8(%rcx)
movl %r12d, 0xc(%rcx)
leaq 0x1896f(%rip), %rax     # 0x296c8
movq (%rax), %rdi
movl $0xf, %edx
callq 0x4310
leaq 0x190b9(%rip), %rax     # 0x29e26
movb $0x1, %r14b
cmpb $0x0, (%rax)
jne 0x10b17
movq 0x10(%rsp), %rsi
movq (%rsi), %rax
movq 0x8(%rsi), %rcx
movl 0x20(%rax), %edx
movl 0x20(%rcx), %ecx
movq 0x10(%rsi), %rax
movl (%rax), %r8d
subq $0x8, %rsp
leaq 0xe883(%rip), %rsi      # 0x1f620
movl $0x800000, %edi         # imm = 0x800000
movl %ebx, %r9d
xorl %eax, %eax
pushq %rbp
pushq %r15
pushq %r12
callq 0x1eb0b
addq $0x20, %rsp
jmp 0x10b17
movq 0x10(%rsp), %rax
movq (%rax), %rdi
movq 0x8(%rax), %rsi
jmp 0x10e87
movswl 0x18(%r12), %eax
subl %eax, %ebp
cvtsi2sd %ebp, %xmm0
movzwl 0x1c(%r12), %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
maxsd %xmm0, %xmm1
movsd 0xe823(%rip), %xmm0     # 0x1f618
minsd %xmm1, %xmm0
movsd %xmm0, 0x8(%r12)
movq 0x18(%r12), %rsi
movq %r12, %rdi
callq 0xb4b5
testq %r14, %r14
je 0x10e80
testb %r13b, %r13b
je 0x10e38
xorps %xmm0, %xmm0
cvtsi2sdl 0x4(%rsp), %xmm0
movzwl 0x1e(%r14), %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
addsd 0x8(%r14), %xmm0
jmp 0x10e5a
movswl 0x1a(%r14), %eax
movl 0x4(%rsp), %ecx
subl %eax, %ecx
xorps %xmm0, %xmm0
cvtsi2sd %ecx, %xmm0
movzwl 0x1e(%r14), %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
maxsd %xmm0, %xmm1
movsd 0xe7ae(%rip), %xmm0     # 0x1f618
minsd %xmm1, %xmm0
movsd %xmm0, 0x8(%r14)
movq 0x18(%r14), %rsi
movq %r14, %rdi
callq 0xb4b5
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
callq 0x8a5c
movb $0x1, %r14b
jmp 0x10b17