// File: /workspace/github_c_makefile_star2_O3/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 0x10b46
movq 0x48(%r14), %rax
testq %rax, %rax
je 0x10b46
cmpl $0x3, 0x308(%rax)
jne 0x10b5b
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 %ecx, %r12d
movl %edx, %ebp
movl %esi, %r15d
movq %rdi, %rbx
xorl %edi, %edi
xorl %esi, %esi
movq %r14, %rdx
callq 0x970b
movq 0x48(%r14), %rdi
movl 0x308(%rdi), %ecx
testl %ecx, %ecx
je 0x10c01
movl %ecx, 0x10(%rsp)
movl %r12d, %r8d
movq %rax, %rdx
shrq $0x10, %rdx
movq %rax, %r12
shrq $0x20, %r12
movq %rax, %r10
shrq $0x30, %r10
movzwl %r12w, %r9d
testb %r13b, %r13b
movq %rax, 0x28(%rsp)
movq %rdx, 0x20(%rsp)
movq %r10, 0x18(%rsp)
je 0x10c21
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
sete %al
movl %eax, 0xc(%rsp)
movl %r15d, %esi
shrl $0x3, %esi
andl $0x1, %esi
negl %edx
sbbl %ecx, %ecx
orl %esi, %ecx
imull %r8d, %ecx
addl %r10d, %ecx
jmp 0x10cdf
movl %r12d, 0x10(%rsp)
movl $0x1, %esi
testb $0x1, %r15b
jne 0x10c37
movl $0x3, %esi
testb $0x4, %r15b
jne 0x10c37
xorl %r12d, %r12d
jmp 0x10c42
testb $0x1, %r15b
jne 0x10ca1
testb $0x4, %r15b
je 0x10ca9
movswl %ax, %ecx
subl %ecx, %ebp
movl %ebp, %r9d
jmp 0x10ca9
movq %r14, %rdi
callq 0xaccc
movq %rax, %r12
xorl %esi, %esi
testb $0x2, %r15b
jne 0x10c5a
movl $0x2, %esi
testb $0x8, %r15b
jne 0x10c5a
xorl %r14d, %r14d
jmp 0x10c65
movq %r14, %rdi
callq 0xaccc
movq %rax, %r14
movq %r12, %rax
orq %r14, %rax
je 0x10b46
testq %r12, %r12
je 0x10e38
testb %r13b, %r13b
je 0x10df6
cvtsi2sd %ebp, %xmm0
movzwl 0x1c(%r12), %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
addsd 0x8(%r12), %xmm0
jmp 0x10e10
movswl %ax, %ecx
subl %ebp, %ecx
addl %ecx, %r9d
testb $0x2, %r15b
jne 0x10cba
testb $0x8, %r15b
jne 0x10ccf
movl %r10d, %ecx
jmp 0x10cd9
movswl %dx, %edx
movl %r10d, %ecx
subl %r8d, %ecx
addl %edx, %ecx
movl $0x0, 0xc(%rsp)
jmp 0x10cdf
movswl %dx, %ecx
movl %r8d, %edx
subl %ecx, %edx
movl %edx, %ecx
movb $0x1, %al
movl %eax, 0xc(%rsp)
cmpl $0x2, %r9d
movl $0x1, %eax
cmovll %eax, %r9d
leaq 0x16(%rsp), %r13
movw %r9w, (%r13)
cmpl $0x2, %ecx
cmovll %eax, %ecx
leaq 0x14(%rsp), %rdx
movw %cx, (%rdx)
movq %r13, %rsi
movq %rdi, %rbp
callq 0x10ebf
movl $0x1, %eax
andl %eax, %r15d
movzwl (%r13), %r13d
subl %r13d, %r12d
testl %r15d, %r15d
cmovel %r15d, %r12d
movq 0x28(%rsp), %rax
addl %r12d, %eax
leaq 0x14(%rsp), %rcx
movzwl (%rcx), %r15d
movq 0x20(%rsp), %rdx
movl %edx, %ecx
addl 0x18(%rsp), %ecx
subl %r15d, %ecx
cmpb $0x0, 0xc(%rsp)
cmovel %ecx, %edx
movw %ax, 0x318(%rbp)
movw %dx, 0x31a(%rbp)
movw %r13w, 0x31c(%rbp)
movw %r15w, 0x31e(%rbp)
cmpl $0x2, 0x10(%rsp)
jne 0x10eab
movl (%r14), %esi
movswl %ax, %r12d
leaq 0x30(%rsp), %rcx
movl %r12d, (%rcx)
movswl %dx, %ebp
movl %ebp, 0x4(%rcx)
movl %r13d, 0x8(%rcx)
movl %r15d, 0xc(%rcx)
leaq 0x1892e(%rip), %rax     # 0x296c8
movq (%rax), %rdi
movl $0xf, %edx
callq 0x4310
leaq 0x19078(%rip), %rax     # 0x29e26
movb $0x1, %r14b
cmpb $0x0, (%rax)
jne 0x10b49
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
movl 0x20(%rax), %edx
movl 0x20(%rcx), %ecx
movq 0x10(%rbx), %rax
movl (%rax), %r8d
subq $0x8, %rsp
leaq 0xe837(%rip), %rsi      # 0x1f610
movl $0x800000, %edi         # imm = 0x800000
movl %r13d, %r9d
xorl %eax, %eax
pushq %rbp
pushq %r12
pushq %r15
callq 0x1e6b8
addq $0x20, %rsp
jmp 0x10b49
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 0xe7e8(%rip), %xmm0     # 0x1f608
minsd %xmm1, %xmm0
movsd %xmm0, 0x8(%r12)
movq 0x18(%r12), %rsi
movq %r12, %rdi
callq 0xb4db
testq %r14, %r14
je 0x10eab
testb %r13b, %r13b
je 0x10e63
xorps %xmm0, %xmm0
cvtsi2sdl 0x10(%rsp), %xmm0
movzwl 0x1e(%r14), %eax
xorps %xmm1, %xmm1
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
addsd 0x8(%r14), %xmm0
jmp 0x10e85
movswl 0x1a(%r14), %eax
movl 0x10(%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 0xe773(%rip), %xmm0     # 0x1f608
minsd %xmm1, %xmm0
movsd %xmm0, 0x8(%r14)
movq 0x18(%r14), %rsi
movq %r14, %rdi
callq 0xb4db
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
callq 0x8958
movb $0x1, %r14b
jmp 0x10b49