// File: /workspace/github_c_makefile_star2_O0/baskerville[P]bspwm/src/tree.c
// Function: adjust_ratios
void adjust_ratios(node_t *n, xcb_rectangle_t rect)
{
#define NULL_OR_VACANT(n) ((n) == NULL || (n)->vacant)
	if (NULL_OR_VACANT(n)) {
		return;
	}

	double ratio;

	if (n->split_type == TYPE_VERTICAL) {
		double position = (double) n->rectangle.x + n->split_ratio * (double) n->rectangle.width;
		ratio = (position - (double) rect.x) / (double) rect.width;
	} else {
		double position = (double) n->rectangle.y + n->split_ratio * (double) n->rectangle.height;
		ratio = (position - (double) rect.y) / (double) rect.height;
	}

	ratio = MAX(0.0, ratio);
	ratio = MIN(1.0, ratio);
	n->split_ratio = ratio;

	xcb_rectangle_t first_rect;
	xcb_rectangle_t second_rect;
	unsigned int fence;

	if (NULL_OR_VACANT(n->first_child)) {
		adjust_ratios(n->second_child, rect);
		return;
	}
	if (NULL_OR_VACANT(n->second_child)) {
		adjust_ratios(n->first_child, rect);
		return;
	}
#undef NULL_OR_VACANT

	if (n->split_type == TYPE_VERTICAL) {
		fence = rect.width * n->split_ratio;
		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;
		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};
	}

	adjust_ratios(n->first_child, first_rect);
	adjust_ratios(n->second_child, second_rect);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rsi, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
cmpq $0x0, -0x10(%rbp)
je 0xf4b1
movq -0x10(%rbp), %rax
testb $0x1, 0x24(%rax)
je 0xf4b6
jmp 0xf72e
movq -0x10(%rbp), %rax
cmpl $0x1, 0x4(%rax)
jne 0xf50a
movq -0x10(%rbp), %rax
movswl 0x18(%rax), %ecx
cvtsi2sd %ecx, %xmm1
movsd 0x8(%rax), %xmm0
movzwl 0x1c(%rax), %eax
cvtsi2sd %eax, %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x20(%rbp)
movsd -0x20(%rbp), %xmm0
movswl -0x8(%rbp), %eax
cvtsi2sd %eax, %xmm1
subsd %xmm1, %xmm0
movzwl -0x4(%rbp), %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
jmp 0xf552
movq -0x10(%rbp), %rax
movswl 0x1a(%rax), %ecx
cvtsi2sd %ecx, %xmm1
movsd 0x8(%rax), %xmm0
movzwl 0x1e(%rax), %eax
cvtsi2sd %eax, %xmm2
mulsd %xmm2, %xmm0
addsd %xmm1, %xmm0
movsd %xmm0, -0x28(%rbp)
movsd -0x28(%rbp), %xmm0
movswl -0x6(%rbp), %eax
cvtsi2sd %eax, %xmm1
subsd %xmm1, %xmm0
movzwl -0x2(%rbp), %eax
cvtsi2sd %eax, %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x18(%rbp)
xorps %xmm0, %xmm0
ucomisd -0x18(%rbp), %xmm0
jbe 0xf566
xorps %xmm0, %xmm0
movsd %xmm0, -0x68(%rbp)
jmp 0xf570
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x68(%rbp)
movsd -0x68(%rbp), %xmm0
movsd %xmm0, -0x18(%rbp)
movsd -0x18(%rbp), %xmm0
movsd 0x1e229(%rip), %xmm1    # 0x2d7b0
ucomisd %xmm1, %xmm0
jbe 0xf59c
movsd 0x1e21b(%rip), %xmm0    # 0x2d7b0
movsd %xmm0, -0x70(%rbp)
jmp 0xf5a6
movsd -0x18(%rbp), %xmm0
movsd %xmm0, -0x70(%rbp)
movsd -0x70(%rbp), %xmm0
movsd %xmm0, -0x18(%rbp)
movsd -0x18(%rbp), %xmm0
movq -0x10(%rbp), %rax
movsd %xmm0, 0x8(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0xf5d7
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rax
testb $0x1, 0x24(%rax)
je 0xf5ed
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x8(%rbp), %rsi
callq 0xf490
jmp 0xf72e
movq -0x10(%rbp), %rax
cmpq $0x0, 0x38(%rax)
je 0xf606
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rax
testb $0x1, 0x24(%rax)
je 0xf61c
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x8(%rbp), %rsi
callq 0xf490
jmp 0xf72e
movq -0x10(%rbp), %rax
cmpl $0x1, 0x4(%rax)
jne 0xf69a
movzwl -0x4(%rbp), %eax
cvtsi2sd %eax, %xmm0
movq -0x10(%rbp), %rax
movsd 0x8(%rax), %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, -0x3c(%rbp)
movw -0x8(%rbp), %ax
movw %ax, -0x44(%rbp)
movw -0x6(%rbp), %ax
movw %ax, -0x42(%rbp)
movl -0x3c(%rbp), %eax
movw %ax, -0x40(%rbp)
movw -0x2(%rbp), %ax
movw %ax, -0x3e(%rbp)
movq -0x44(%rbp), %rax
movq %rax, -0x30(%rbp)
movswl -0x8(%rbp), %eax
addl -0x3c(%rbp), %eax
movw %ax, -0x4c(%rbp)
movw -0x6(%rbp), %ax
movw %ax, -0x4a(%rbp)
movzwl -0x4(%rbp), %eax
subl -0x3c(%rbp), %eax
movw %ax, -0x48(%rbp)
movw -0x2(%rbp), %ax
movw %ax, -0x46(%rbp)
movq -0x4c(%rbp), %rax
movq %rax, -0x38(%rbp)
jmp 0xf70c
movzwl -0x2(%rbp), %eax
cvtsi2sd %eax, %xmm0
movq -0x10(%rbp), %rax
movsd 0x8(%rax), %xmm1
mulsd %xmm1, %xmm0
cvttsd2si %xmm0, %rax
movl %eax, -0x3c(%rbp)
movw -0x8(%rbp), %ax
movw %ax, -0x54(%rbp)
movw -0x6(%rbp), %ax
movw %ax, -0x52(%rbp)
movw -0x4(%rbp), %ax
movw %ax, -0x50(%rbp)
movl -0x3c(%rbp), %eax
movw %ax, -0x4e(%rbp)
movq -0x54(%rbp), %rax
movq %rax, -0x30(%rbp)
movw -0x8(%rbp), %ax
movw %ax, -0x5c(%rbp)
movswl -0x6(%rbp), %eax
addl -0x3c(%rbp), %eax
movw %ax, -0x5a(%rbp)
movw -0x4(%rbp), %ax
movw %ax, -0x58(%rbp)
movzwl -0x2(%rbp), %eax
subl -0x3c(%rbp), %eax
movw %ax, -0x56(%rbp)
movq -0x5c(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x30(%rbp), %rsi
callq 0xf490
movq -0x10(%rbp), %rax
movq 0x38(%rax), %rdi
movq -0x38(%rbp), %rsi
callq 0xf490
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)