// File: /workspace/github_c_makefile_star2_O0/baskerville[P]bspwm/src/tree.c
// Function: apply_layout
void apply_layout(monitor_t *m, desktop_t *d, node_t *n, xcb_rectangle_t rect, xcb_rectangle_t root_rect)
{
	if (n == NULL) {
		return;
	}

	n->rectangle = rect;

	if (n->presel != NULL) {
		draw_presel_feedback(m, d, n);
	}

	if (is_leaf(n)) {

		if (n->client == NULL) {
			return;
		}

		unsigned int bw;
		bool the_only_window = !m->prev && !m->next && d->root->client;
		if ((borderless_monocle && d->layout == LAYOUT_MONOCLE && IS_TILED(n->client))
		    || (borderless_singleton && the_only_window)
		    || n->client->state == STATE_FULLSCREEN) {
			bw = 0;
		} else {
			bw = n->client->border_width;
		}

		xcb_rectangle_t r;
		xcb_rectangle_t cr = get_window_rectangle(n);
		client_state_t s = n->client->state;
		/* tiled and pseudo-tiled clients */
		if (s == STATE_TILED || s == STATE_PSEUDO_TILED) {
			int wg = (gapless_monocle && d->layout == LAYOUT_MONOCLE ? 0 : d->window_gap);
			r = rect;
			int bleed = wg + 2 * bw;
			r.width = (bleed < r.width ? r.width - bleed : 1);
			r.height = (bleed < r.height ? r.height - bleed : 1);
			/* pseudo-tiled clients */
			if (s == STATE_PSEUDO_TILED) {
				xcb_rectangle_t f = n->client->floating_rectangle;
				r.width = MIN(r.width, f.width);
				r.height = MIN(r.height, f.height);
				if (center_pseudo_tiled) {
					r.x = rect.x - bw + (rect.width - wg - r.width) / 2;
					r.y = rect.y - bw + (rect.height - wg - r.height) / 2;
				}
			}
			n->client->tiled_rectangle = r;
		/* floating clients */
		} else if (s == STATE_FLOATING) {
			r = n->client->floating_rectangle;
		/* fullscreen clients */
		} else {
			r = m->rectangle;
			n->client->tiled_rectangle = r;
		}

		apply_size_hints(n->client, &r.width, &r.height);

		if (!rect_eq(r, cr)) {
			window_move_resize(n->id, r.x, r.y, r.width, r.height);
			if (!grabbing) {
				put_status(SBSC_MASK_NODE_GEOMETRY, "node_geometry 0x%08X 0x%08X 0x%08X %ux%u+%i+%i\n", m->id, d->id, n->id, r.width, r.height, r.x, r.y);
			}
		}

		window_border_width(n->id, bw);

	} else {
		xcb_rectangle_t first_rect;
		xcb_rectangle_t second_rect;

		if (d->layout == LAYOUT_MONOCLE || n->first_child->vacant || n->second_child->vacant) {
			first_rect = second_rect = rect;
		} else {
			unsigned int fence;
			if (n->split_type == TYPE_VERTICAL) {
				fence = rect.width * n->split_ratio;
				if ((n->first_child->constraints.min_width + n->second_child->constraints.min_width) <= rect.width) {
					if (fence < n->first_child->constraints.min_width) {
						fence = n->first_child->constraints.min_width;
						n->split_ratio = (double) fence / (double) rect.width;
					} else if (fence > (uint16_t) (rect.width - n->second_child->constraints.min_width)) {
						fence = (rect.width - n->second_child->constraints.min_width);
						n->split_ratio = (double) fence / (double) rect.width;
					}
				}
				first_rect = (xcb_rectangle_t) {rect.x, rect.y, fence, rect.height};
				second_rect = (xcb_rectangle_t) {rect.x + fence, rect.y, rect.width - fence, rect.height};
			} else {
				fence = rect.height * n->split_ratio;
				if ((n->first_child->constraints.min_height + n->second_child->constraints.min_height) <= rect.height) {
					if (fence < n->first_child->constraints.min_height) {
						fence = n->first_child->constraints.min_height;
						n->split_ratio = (double) fence / (double) rect.height;
					} else if (fence > (uint16_t) (rect.height - n->second_child->constraints.min_height)) {
						fence = (rect.height - n->second_child->constraints.min_height);
						n->split_ratio = (double) fence / (double) rect.height;
					}
				}
				first_rect = (xcb_rectangle_t) {rect.x, rect.y, rect.width, fence};
				second_rect = (xcb_rectangle_t) {rect.x, rect.y + fence, rect.width, rect.height - fence};
			}
		}

		apply_layout(m, d, n->first_child, first_rect, root_rect);
		apply_layout(m, d, n->second_child, second_rect, root_rect);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xc0, %rsp
movq %rcx, -0x8(%rbp)
movq %r8, -0x10(%rbp)
movq %rdi, -0x18(%rbp)
movq %rsi, -0x20(%rbp)
movq %rdx, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jne 0xb19b
jmp 0xb85b
movq -0x28(%rbp), %rax
movq -0x8(%rbp), %rcx
movq %rcx, 0x18(%rax)
movq -0x28(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0xb1c3
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0x16b80
movq -0x28(%rbp), %rdi
callq 0xb870
testb $0x1, %al
jne 0xb1d5
jmp 0xb56c
movq -0x28(%rbp), %rax
cmpq $0x0, 0x48(%rax)
jne 0xb1e5
jmp 0xb85b
movq -0x18(%rbp), %rcx
xorl %eax, %eax
cmpq $0x0, 0x70(%rcx)
movb %al, -0x89(%rbp)
jne 0xb221
movq -0x18(%rbp), %rcx
xorl %eax, %eax
cmpq $0x0, 0x78(%rcx)
movb %al, -0x89(%rbp)
jne 0xb221
movq -0x20(%rbp), %rax
movq 0x30(%rax), %rax
cmpq $0x0, 0x48(%rax)
setne %al
movb %al, -0x89(%rbp)
movb -0x89(%rbp), %al
andb $0x1, %al
movb %al, -0x2d(%rbp)
leaq 0x2abb3(%rip), %rax     # 0x35de6
testb $0x1, (%rax)
je 0xb264
movq -0x20(%rbp), %rax
cmpl $0x1, 0x24(%rax)
jne 0xb264
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
cmpl $0x0, 0x308(%rax)
je 0xb287
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
cmpl $0x1, 0x308(%rax)
je 0xb287
leaq 0x2ab7e(%rip), %rax     # 0x35de9
testb $0x1, (%rax)
je 0xb276
testb $0x1, -0x2d(%rbp)
jne 0xb287
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
cmpl $0x3, 0x308(%rax)
jne 0xb290
movl $0x0, -0x2c(%rbp)
jmp 0xb2a1
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movl 0x300(%rax), %eax
movl %eax, -0x2c(%rbp)
movq -0x28(%rbp), %rdi
callq 0x172f0
movq %rax, -0x3e(%rbp)
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movl 0x308(%rax), %eax
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
je 0xb2cf
cmpl $0x1, -0x44(%rbp)
jne 0xb474
leaq 0x2ab11(%rip), %rax     # 0x35de7
testb $0x1, (%rax)
je 0xb2ef
movq -0x20(%rbp), %rax
cmpl $0x1, 0x24(%rax)
jne 0xb2ef
xorl %eax, %eax
movl %eax, -0x90(%rbp)
jmp 0xb2fc
movq -0x20(%rbp), %rax
movl 0x60(%rax), %eax
movl %eax, -0x90(%rbp)
movl -0x90(%rbp), %eax
movl %eax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x36(%rbp)
movl -0x48(%rbp), %eax
movl -0x2c(%rbp), %ecx
shll %ecx
addl %ecx, %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
movzwl -0x32(%rbp), %ecx
cmpl %ecx, %eax
jge 0xb334
movzwl -0x32(%rbp), %eax
subl -0x4c(%rbp), %eax
movl %eax, -0x94(%rbp)
jmp 0xb341
movl $0x1, %eax
movl %eax, -0x94(%rbp)
jmp 0xb341
movl -0x94(%rbp), %eax
movw %ax, -0x32(%rbp)
movl -0x4c(%rbp), %eax
movzwl -0x30(%rbp), %ecx
cmpl %ecx, %eax
jge 0xb365
movzwl -0x30(%rbp), %eax
subl -0x4c(%rbp), %eax
movl %eax, -0x98(%rbp)
jmp 0xb372
movl $0x1, %eax
movl %eax, -0x98(%rbp)
jmp 0xb372
movl -0x98(%rbp), %eax
movw %ax, -0x30(%rbp)
cmpl $0x1, -0x44(%rbp)
jne 0xb45f
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x318(%rax), %rax
movq %rax, -0x54(%rbp)
movzwl -0x32(%rbp), %eax
movzwl -0x50(%rbp), %ecx
cmpl %ecx, %eax
jge 0xb3b1
movzwl -0x32(%rbp), %eax
movl %eax, -0x9c(%rbp)
jmp 0xb3bb
movzwl -0x50(%rbp), %eax
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %eax
movw %ax, -0x32(%rbp)
movzwl -0x30(%rbp), %eax
movzwl -0x4e(%rbp), %ecx
cmpl %ecx, %eax
jge 0xb3dd
movzwl -0x30(%rbp), %eax
movl %eax, -0xa0(%rbp)
jmp 0xb3e7
movzwl -0x4e(%rbp), %eax
movl %eax, -0xa0(%rbp)
movl -0xa0(%rbp), %eax
movw %ax, -0x30(%rbp)
leaq 0x2a9fd(%rip), %rax     # 0x35df5
testb $0x1, (%rax)
je 0xb45d
movswl -0x8(%rbp), %eax
subl -0x2c(%rbp), %eax
movl %eax, -0xa8(%rbp)
movzwl -0x4(%rbp), %eax
subl -0x48(%rbp), %eax
movzwl -0x32(%rbp), %ecx
subl %ecx, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0xa8(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x36(%rbp)
movswl -0x6(%rbp), %eax
subl -0x2c(%rbp), %eax
movl %eax, -0xa4(%rbp)
movzwl -0x2(%rbp), %eax
subl -0x48(%rbp), %eax
movzwl -0x30(%rbp), %ecx
subl %ecx, %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0xa4(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x34(%rbp)
jmp 0xb45f
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x36(%rbp), %rcx
movq %rcx, 0x320(%rax)
jmp 0xb4b0
cmpl $0x2, -0x44(%rbp)
jne 0xb48f
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq 0x318(%rax), %rax
movq %rax, -0x36(%rbp)
jmp 0xb4ae
movq -0x18(%rbp), %rax
movq 0x4c(%rax), %rax
movq %rax, -0x36(%rbp)
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rax
movq -0x36(%rbp), %rcx
movq %rcx, 0x320(%rax)
jmp 0xb4b0
movq -0x28(%rbp), %rax
movq 0x48(%rax), %rdi
leaq -0x36(%rbp), %rsi
addq $0x4, %rsi
leaq -0x36(%rbp), %rdx
addq $0x6, %rdx
callq 0x17f40
movq -0x36(%rbp), %rdi
movq -0x3e(%rbp), %rsi
callq 0x7100
testb $0x1, %al
jne 0xb559
movq -0x28(%rbp), %rax
movl (%rax), %edi
movw -0x36(%rbp), %dx
movw -0x34(%rbp), %cx
movw -0x32(%rbp), %ax
movswl %dx, %esi
movswl %cx, %edx
movzwl %ax, %ecx
movzwl -0x30(%rbp), %r8d
callq 0x16da0
leaq 0x2a90c(%rip), %rax     # 0x35e16
testb $0x1, (%rax)
jne 0xb557
movq -0x18(%rbp), %rax
movl 0x20(%rax), %edx
movq -0x20(%rbp), %rax
movl 0x20(%rax), %ecx
movq -0x28(%rbp), %rax
movl (%rax), %r8d
movzwl -0x32(%rbp), %r9d
movzwl -0x30(%rbp), %r11d
movswl -0x36(%rbp), %r10d
movswl -0x34(%rbp), %eax
movl $0x800000, %edi         # imm = 0x800000
leaq 0x22275(%rip), %rsi     # 0x2d7b8
movl %r11d, (%rsp)
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
movb $0x0, %al
callq 0x2c0b0
jmp 0xb559
movq -0x28(%rbp), %rax
movl (%rax), %edi
movl -0x2c(%rbp), %esi
callq 0x18670
jmp 0xb85b
movq -0x20(%rbp), %rax
cmpl $0x1, 0x24(%rax)
je 0xb592
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
testb $0x1, 0x24(%rax)
jne 0xb592
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rax
testb $0x1, 0x24(%rax)
je 0xb5a7
movq -0x8(%rbp), %rax
movq %rax, -0x64(%rbp)
movq -0x64(%rbp), %rax
movq %rax, -0x5c(%rbp)
jmp 0xb821
movq -0x28(%rbp), %rax
cmpl $0x1, 0x4(%rax)
jne 0xb6e5
movzwl -0x4(%rbp), %eax
cvtsi2sd %eax, %xmm0
movq -0x28(%rbp), %rax
movsd 0x8(%rax), %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, -0x68(%rbp)
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movzwl 0x20(%rax), %eax
movq -0x28(%rbp), %rcx
movq 0x38(%rcx), %rcx
movzwl 0x20(%rcx), %ecx
addl %ecx, %eax
movzwl -0x4(%rbp), %ecx
cmpl %ecx, %eax
jg 0xb68b
movl -0x68(%rbp), %eax
movq -0x28(%rbp), %rcx
movq 0x30(%rcx), %rcx
movzwl 0x20(%rcx), %ecx
cmpl %ecx, %eax
jae 0xb639
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movzwl 0x20(%rax), %eax
movl %eax, -0x68(%rbp)
movl -0x68(%rbp), %eax
cvtsi2sd %rax, %xmm0
movzwl -0x4(%rbp), %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, 0x8(%rax)
jmp 0xb689
movl -0x68(%rbp), %eax
movzwl -0x4(%rbp), %ecx
movq -0x28(%rbp), %rdx
movq 0x38(%rdx), %rdx
movzwl 0x20(%rdx), %edx
subl %edx, %ecx
movzwl %cx, %ecx
cmpl %ecx, %eax
jbe 0xb687
movzwl -0x4(%rbp), %eax
movq -0x28(%rbp), %rcx
movq 0x38(%rcx), %rcx
movzwl 0x20(%rcx), %ecx
subl %ecx, %eax
movl %eax, -0x68(%rbp)
movl -0x68(%rbp), %eax
cvtsi2sd %rax, %xmm0
movzwl -0x4(%rbp), %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, 0x8(%rax)
jmp 0xb689
jmp 0xb68b
movw -0x8(%rbp), %ax
movw %ax, -0x70(%rbp)
movw -0x6(%rbp), %ax
movw %ax, -0x6e(%rbp)
movl -0x68(%rbp), %eax
movw %ax, -0x6c(%rbp)
movw -0x2(%rbp), %ax
movw %ax, -0x6a(%rbp)
movq -0x70(%rbp), %rax
movq %rax, -0x5c(%rbp)
movswl -0x8(%rbp), %eax
addl -0x68(%rbp), %eax
movw %ax, -0x78(%rbp)
movw -0x6(%rbp), %ax
movw %ax, -0x76(%rbp)
movzwl -0x4(%rbp), %eax
subl -0x68(%rbp), %eax
movw %ax, -0x74(%rbp)
movw -0x2(%rbp), %ax
movw %ax, -0x72(%rbp)
movq -0x78(%rbp), %rax
movq %rax, -0x64(%rbp)
jmp 0xb81f
movzwl -0x2(%rbp), %eax
cvtsi2sd %eax, %xmm0
movq -0x28(%rbp), %rax
movsd 0x8(%rax), %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, -0x68(%rbp)
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movzwl 0x22(%rax), %eax
movq -0x28(%rbp), %rcx
movq 0x38(%rcx), %rcx
movzwl 0x22(%rcx), %ecx
addl %ecx, %eax
movzwl -0x2(%rbp), %ecx
cmpl %ecx, %eax
jg 0xb7bb
movl -0x68(%rbp), %eax
movq -0x28(%rbp), %rcx
movq 0x30(%rcx), %rcx
movzwl 0x22(%rcx), %ecx
cmpl %ecx, %eax
jae 0xb769
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rax
movzwl 0x22(%rax), %eax
movl %eax, -0x68(%rbp)
movl -0x68(%rbp), %eax
cvtsi2sd %rax, %xmm0
movzwl -0x2(%rbp), %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, 0x8(%rax)
jmp 0xb7b9
movl -0x68(%rbp), %eax
movzwl -0x2(%rbp), %ecx
movq -0x28(%rbp), %rdx
movq 0x38(%rdx), %rdx
movzwl 0x22(%rdx), %edx
subl %edx, %ecx
movzwl %cx, %ecx
cmpl %ecx, %eax
jbe 0xb7b7
movzwl -0x2(%rbp), %eax
movq -0x28(%rbp), %rcx
movq 0x38(%rcx), %rcx
movzwl 0x22(%rcx), %ecx
subl %ecx, %eax
movl %eax, -0x68(%rbp)
movl -0x68(%rbp), %eax
cvtsi2sd %rax, %xmm0
movzwl -0x2(%rbp), %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
movq -0x28(%rbp), %rax
movsd %xmm0, 0x8(%rax)
jmp 0xb7b9
jmp 0xb7bb
movw -0x8(%rbp), %ax
movw %ax, -0x80(%rbp)
movw -0x6(%rbp), %ax
movw %ax, -0x7e(%rbp)
movw -0x4(%rbp), %ax
movw %ax, -0x7c(%rbp)
movl -0x68(%rbp), %eax
movw %ax, -0x7a(%rbp)
movq -0x80(%rbp), %rax
movq %rax, -0x5c(%rbp)
movw -0x8(%rbp), %ax
movw %ax, -0x88(%rbp)
movswl -0x6(%rbp), %eax
addl -0x68(%rbp), %eax
movw %ax, -0x86(%rbp)
movw -0x4(%rbp), %ax
movw %ax, -0x84(%rbp)
movzwl -0x2(%rbp), %eax
subl -0x68(%rbp), %eax
movw %ax, -0x82(%rbp)
movq -0x88(%rbp), %rax
movq %rax, -0x64(%rbp)
jmp 0xb821
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rax
movq 0x30(%rax), %rdx
movq -0x5c(%rbp), %rcx
movq -0x10(%rbp), %r8
callq 0xb170
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rax
movq 0x38(%rax), %rdx
movq -0x64(%rbp), %rcx
movq -0x10(%rbp), %r8
callq 0xb170
addq $0xc0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)