// File: /workspace/github_c_makefile_star2_O2/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 $0x38, %rsp
movq 0x10(%rdi), %r14
testq %r14, %r14
je 0xfd34
movq 0x48(%r14), %rax
testq %rax, %rax
je 0xfd34
cmpl $0x3, 0x308(%rax)
jne 0xfd49
xorl %r14d, %r14d
movl %r14d, %eax
addq $0x38, %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 0x932e
movq 0x48(%r14), %rdi
movl 0x308(%rdi), %ecx
testl %ecx, %ecx
je 0xfdef
movl %ecx, 0x18(%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, 0x30(%rsp)
movq %rdx, 0x28(%rsp)
movq %r10, 0x20(%rsp)
je 0xfe05
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 0xfecf
testb $0x1, %r15b
movl %r12d, 0x14(%rsp)
jne 0xfe1b
testb $0x4, %r15b
jne 0xfe54
xorl %r12d, %r12d
jmp 0xfe62
testb $0x1, %r15b
jne 0xfe1f
testb $0x4, %r15b
je 0xfe27
movswl %ax, %ecx
subl %ecx, %ebp
movl %ebp, %r9d
jmp 0xfe27
pushq $0x1
jmp 0xfe56
movswl %ax, %ecx
subl %ebp, %ecx
addl %ecx, %r9d
testb $0x2, %r15b
jne 0xfe3f
testb $0x8, %r15b
jne 0xfebf
movl %r10d, %ecx
jmp 0xfec9
movswl %dx, %edx
movl %r10d, %ecx
subl %r8d, %ecx
addl %edx, %ecx
movl $0x0, 0xc(%rsp)
jmp 0xfecf
pushq $0x3
popq %rsi
movq %r14, %rdi
callq 0xa62f
movq %rax, %r12
xorl %esi, %esi
testb $0x2, %r15b
jne 0xfe78
testb $0x8, %r15b
jne 0xfe75
xorl %r14d, %r14d
jmp 0xfe83
pushq $0x2
popq %rsi
movq %r14, %rdi
callq 0xa62f
movq %rax, %r14
movq %r12, %rax
orq %r14, %rax
je 0xfd34
testq %r12, %r12
je 0x10010
testb %r13b, %r13b
je 0xffce
cvtsi2sd %ebp, %xmm0
movzwl 0x1c(%r12), %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
addsd 0x8(%r12), %xmm0
jmp 0xffe8
movswl %dx, %ecx
movl %r8d, %edx
subl %ecx, %edx
movl %edx, %ecx
movb $0x1, %al
movl %eax, 0xc(%rsp)
cmpl $0x2, %r9d
pushq $0x1
popq %rax
cmovll %eax, %r9d
leaq 0x1e(%rsp), %r13
movw %r9w, (%r13)
cmpl $0x2, %ecx
cmovll %eax, %ecx
leaq 0x12(%rsp), %rdx
movw %cx, (%rdx)
movq %r13, %rsi
movq %rdi, %rbp
callq 0x1008b
pushq $0x1
popq %rax
andl %eax, %r15d
movzwl (%r13), %r13d
subl %r13d, %r12d
testl %r15d, %r15d
cmovel %r15d, %r12d
movq 0x30(%rsp), %rax
addl %r12d, %eax
leaq 0x12(%rsp), %rcx
movzwl (%rcx), %r15d
movq 0x28(%rsp), %rdx
movl %edx, %ecx
addl 0x20(%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, 0x18(%rsp)
jne 0x10077
movq %rdx, %rcx
movl (%r14), %edi
movswl %ax, %r12d
movswl %cx, %ebp
movl %r12d, %esi
movl %ebp, %edx
movl %r13d, %ecx
movl %r15d, %r8d
callq 0xf602
leaq 0x18ea0(%rip), %rax     # 0x28e26
movb $0x1, %r14b
cmpb $0x0, (%rax)
jne 0xfd37
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 0xe65f(%rip), %rsi      # 0x1e610
movl $0x800000, %edi         # imm = 0x800000
movl %r13d, %r9d
xorl %eax, %eax
pushq %rbp
pushq %r12
pushq %r15
callq 0x1d07d
addq $0x20, %rsp
jmp 0xfd37
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 0xe610(%rip), %xmm0     # 0x1e608
minsd %xmm1, %xmm0
movsd %xmm0, 0x8(%r12)
movq 0x18(%r12), %rsi
movq %r12, %rdi
callq 0xad6e
testq %r14, %r14
je 0x10077
testb %r13b, %r13b
je 0x10035
cvtsi2sdl 0x14(%rsp), %xmm0
movzwl 0x1e(%r14), %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
addsd 0x8(%r14), %xmm0
jmp 0x10051
movswl 0x1a(%r14), %eax
movl 0x14(%rsp), %ecx
subl %eax, %ecx
cvtsi2sd %ecx, %xmm0
movzwl 0x1e(%r14), %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
xorpd %xmm1, %xmm1
maxsd %xmm0, %xmm1
movsd 0xe5a7(%rip), %xmm0     # 0x1e608
minsd %xmm1, %xmm0
movsd %xmm0, 0x8(%r14)
movq 0x18(%r14), %rsi
movq %r14, %rdi
callq 0xad6e
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
callq 0x8670
movb $0x1, %r14b
jmp 0xfd37