// File: /workspace/github_c_makefile_star2_O0/baskerville[P]bspwm/src/monitor.c
// Function: adapt_geometry
void adapt_geometry(xcb_rectangle_t *rs, xcb_rectangle_t *rd, node_t *n)
{
	for (node_t *f = first_extrema(n); f != NULL; f = next_leaf(f, n)) {
		if (f->client == NULL) {
			continue;
		}
		client_t *c = f->client;
		/* Clip the rectangle to fit into the monitor.	Without this, the fitting
		 * algorithm doesn't work as expected. This also conserves the
		 * out-of-bounds regions */
		int left_adjust = MAX((rs->x - c->floating_rectangle.x), 0);
		int top_adjust = MAX((rs->y - c->floating_rectangle.y), 0);
		int right_adjust = MAX((c->floating_rectangle.x + c->floating_rectangle.width) - (rs->x + rs->width), 0);
		int bottom_adjust = MAX((c->floating_rectangle.y + c->floating_rectangle.height) - (rs->y + rs->height), 0);
		c->floating_rectangle.x += left_adjust;
		c->floating_rectangle.y += top_adjust;
		c->floating_rectangle.width -= (left_adjust + right_adjust);
		c->floating_rectangle.height -= (top_adjust + bottom_adjust);

		int dx_s = c->floating_rectangle.x - rs->x;
		int dy_s = c->floating_rectangle.y - rs->y;

		int nume_x = dx_s * (rd->width - c->floating_rectangle.width);
		int nume_y = dy_s * (rd->height - c->floating_rectangle.height);

		int deno_x = rs->width - c->floating_rectangle.width;
		int deno_y = rs->height - c->floating_rectangle.height;

		int dx_d = (deno_x == 0 ? 0 : nume_x / deno_x);
		int dy_d = (deno_y == 0 ? 0 : nume_y / deno_y);

		/* Translate and undo clipping */
		c->floating_rectangle.width += left_adjust + right_adjust;
		c->floating_rectangle.height += top_adjust + bottom_adjust;
		c->floating_rectangle.x = rd->x + dx_d - left_adjust;
		c->floating_rectangle.y = rd->y + dy_d - top_adjust;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rdi
callq 0xbe70
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
je 0x861c
movq -0x20(%rbp), %rax
cmpq $0x0, 0x48(%rax)
jne 0x82fc
jmp 0x8606
movq -0x20(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movswl (%rax), %eax
movq -0x28(%rbp), %rcx
movswl 0x318(%rcx), %ecx
subl %ecx, %eax
cmpl $0x0, %eax
jle 0x833a
movq -0x8(%rbp), %rax
movswl (%rax), %eax
movq -0x28(%rbp), %rcx
movswl 0x318(%rcx), %ecx
subl %ecx, %eax
movl %eax, -0x5c(%rbp)
jmp 0x8341
xorl %eax, %eax
movl %eax, -0x5c(%rbp)
jmp 0x8341
movl -0x5c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movq -0x8(%rbp), %rax
movswl 0x2(%rax), %eax
movq -0x28(%rbp), %rcx
movswl 0x31a(%rcx), %ecx
subl %ecx, %eax
cmpl $0x0, %eax
jle 0x837b
movq -0x8(%rbp), %rax
movswl 0x2(%rax), %eax
movq -0x28(%rbp), %rcx
movswl 0x31a(%rcx), %ecx
subl %ecx, %eax
movl %eax, -0x60(%rbp)
jmp 0x8382
xorl %eax, %eax
movl %eax, -0x60(%rbp)
jmp 0x8382
movl -0x60(%rbp), %eax
movl %eax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movswl 0x318(%rax), %eax
movq -0x28(%rbp), %rcx
movzwl 0x31c(%rcx), %ecx
addl %ecx, %eax
movq -0x8(%rbp), %rcx
movswl (%rcx), %ecx
movq -0x8(%rbp), %rdx
movzwl 0x4(%rdx), %edx
addl %edx, %ecx
subl %ecx, %eax
cmpl $0x0, %eax
jle 0x83e8
movq -0x28(%rbp), %rax
movswl 0x318(%rax), %eax
movq -0x28(%rbp), %rcx
movzwl 0x31c(%rcx), %ecx
addl %ecx, %eax
movq -0x8(%rbp), %rcx
movswl (%rcx), %ecx
movq -0x8(%rbp), %rdx
movzwl 0x4(%rdx), %edx
addl %edx, %ecx
subl %ecx, %eax
movl %eax, -0x64(%rbp)
jmp 0x83ef
xorl %eax, %eax
movl %eax, -0x64(%rbp)
jmp 0x83ef
movl -0x64(%rbp), %eax
movl %eax, -0x34(%rbp)
movq -0x28(%rbp), %rax
movswl 0x31a(%rax), %eax
movq -0x28(%rbp), %rcx
movzwl 0x31e(%rcx), %ecx
addl %ecx, %eax
movq -0x8(%rbp), %rcx
movswl 0x2(%rcx), %ecx
movq -0x8(%rbp), %rdx
movzwl 0x6(%rdx), %edx
addl %edx, %ecx
subl %ecx, %eax
cmpl $0x0, %eax
jle 0x8457
movq -0x28(%rbp), %rax
movswl 0x31a(%rax), %eax
movq -0x28(%rbp), %rcx
movzwl 0x31e(%rcx), %ecx
addl %ecx, %eax
movq -0x8(%rbp), %rcx
movswl 0x2(%rcx), %ecx
movq -0x8(%rbp), %rdx
movzwl 0x6(%rdx), %edx
addl %edx, %ecx
subl %ecx, %eax
movl %eax, -0x68(%rbp)
jmp 0x845e
xorl %eax, %eax
movl %eax, -0x68(%rbp)
jmp 0x845e
movl -0x68(%rbp), %eax
movl %eax, -0x38(%rbp)
movl -0x2c(%rbp), %edx
movq -0x28(%rbp), %rax
movswl 0x318(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x318(%rax)
movl -0x30(%rbp), %edx
movq -0x28(%rbp), %rax
movswl 0x31a(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x31a(%rax)
movl -0x2c(%rbp), %edx
addl -0x34(%rbp), %edx
movq -0x28(%rbp), %rax
movzwl 0x31c(%rax), %ecx
subl %edx, %ecx
movw %cx, 0x31c(%rax)
movl -0x30(%rbp), %edx
addl -0x38(%rbp), %edx
movq -0x28(%rbp), %rax
movzwl 0x31e(%rax), %ecx
subl %edx, %ecx
movw %cx, 0x31e(%rax)
movq -0x28(%rbp), %rax
movswl 0x318(%rax), %eax
movq -0x8(%rbp), %rcx
movswl (%rcx), %ecx
subl %ecx, %eax
movl %eax, -0x3c(%rbp)
movq -0x28(%rbp), %rax
movswl 0x31a(%rax), %eax
movq -0x8(%rbp), %rcx
movswl 0x2(%rcx), %ecx
subl %ecx, %eax
movl %eax, -0x40(%rbp)
movl -0x3c(%rbp), %eax
movq -0x10(%rbp), %rcx
movzwl 0x4(%rcx), %ecx
movq -0x28(%rbp), %rdx
movzwl 0x31c(%rdx), %edx
subl %edx, %ecx
imull %ecx, %eax
movl %eax, -0x44(%rbp)
movl -0x40(%rbp), %eax
movq -0x10(%rbp), %rcx
movzwl 0x6(%rcx), %ecx
movq -0x28(%rbp), %rdx
movzwl 0x31e(%rdx), %edx
subl %edx, %ecx
imull %ecx, %eax
movl %eax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movzwl 0x4(%rax), %eax
movq -0x28(%rbp), %rcx
movzwl 0x31c(%rcx), %ecx
subl %ecx, %eax
movl %eax, -0x4c(%rbp)
movq -0x8(%rbp), %rax
movzwl 0x6(%rax), %eax
movq -0x28(%rbp), %rcx
movzwl 0x31e(%rcx), %ecx
subl %ecx, %eax
movl %eax, -0x50(%rbp)
cmpl $0x0, -0x4c(%rbp)
jne 0x856e
xorl %eax, %eax
movl %eax, -0x6c(%rbp)
jmp 0x8578
movl -0x44(%rbp), %eax
cltd
idivl -0x4c(%rbp)
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movl %eax, -0x54(%rbp)
cmpl $0x0, -0x50(%rbp)
jne 0x858b
xorl %eax, %eax
movl %eax, -0x70(%rbp)
jmp 0x8595
movl -0x48(%rbp), %eax
cltd
idivl -0x50(%rbp)
movl %eax, -0x70(%rbp)
movl -0x70(%rbp), %eax
movl %eax, -0x58(%rbp)
movl -0x2c(%rbp), %edx
addl -0x34(%rbp), %edx
movq -0x28(%rbp), %rax
movzwl 0x31c(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x31c(%rax)
movl -0x30(%rbp), %edx
addl -0x38(%rbp), %edx
movq -0x28(%rbp), %rax
movzwl 0x31e(%rax), %ecx
addl %edx, %ecx
movw %cx, 0x31e(%rax)
movq -0x10(%rbp), %rax
movswl (%rax), %eax
addl -0x54(%rbp), %eax
subl -0x2c(%rbp), %eax
movw %ax, %cx
movq -0x28(%rbp), %rax
movw %cx, 0x318(%rax)
movq -0x10(%rbp), %rax
movswl 0x2(%rax), %eax
addl -0x58(%rbp), %eax
subl -0x30(%rbp), %eax
movw %ax, %cx
movq -0x28(%rbp), %rax
movw %cx, 0x31a(%rax)
movq -0x20(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0xbf80
movq %rax, -0x20(%rbp)
jmp 0x82e1
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)