// File: /workspace/github_c_makefile_star2_O0/baskerville[P]bspwm/src/window.c
// Function: apply_size_hints
void apply_size_hints(client_t *c, uint16_t *width, uint16_t *height)
{
	if (!SHOULD_HONOR_SIZE_HINTS(c->honor_size_hints, c->state)) {
		return;
	}

	int32_t minw = 0, minh = 0;
	int32_t basew = 0, baseh = 0, real_basew = 0, real_baseh = 0;

	if (c->size_hints.flags & XCB_ICCCM_SIZE_HINT_BASE_SIZE) {
		basew = c->size_hints.base_width;
		baseh = c->size_hints.base_height;
		real_basew = basew;
		real_baseh = baseh;
	} else if (c->size_hints.flags & XCB_ICCCM_SIZE_HINT_P_MIN_SIZE) {
		/* base size is substituted with min size if not specified */
		basew = c->size_hints.min_width;
		baseh = c->size_hints.min_height;
	}

	if (c->size_hints.flags & XCB_ICCCM_SIZE_HINT_P_MIN_SIZE) {
		minw = c->size_hints.min_width;
		minh = c->size_hints.min_height;
	} else if (c->size_hints.flags & XCB_ICCCM_SIZE_HINT_BASE_SIZE) {
		/* min size is substituted with base size if not specified */
		minw = c->size_hints.base_width;
		minh = c->size_hints.base_height;
	}

	/* Handle the size aspect ratio */
	if (c->size_hints.flags & XCB_ICCCM_SIZE_HINT_P_ASPECT &&
	    c->size_hints.min_aspect_den > 0 &&
	    c->size_hints.max_aspect_den > 0 &&
	    *height > real_baseh &&
	    *width > real_basew) {
		/* ICCCM mandates:
		 * If a base size is provided along with the aspect ratio fields, the base size should be subtracted from the
		 * window size prior to checking that the aspect ratio falls in range. If a base size is not provided, nothing
		 * should be subtracted from the window size. (The minimum size is not to be used in place of the base size for
		 * this purpose.)
		 */
		double dx = *width - real_basew;
		double dy = *height - real_baseh;
		double ratio = dx / dy;
		double min = c->size_hints.min_aspect_num / (double) c->size_hints.min_aspect_den;
		double max = c->size_hints.max_aspect_num / (double) c->size_hints.max_aspect_den;

		if (max > 0 && min > 0 && ratio > 0) {
			if (ratio < min) {
				/* dx is lower than allowed, make dy lower to compensate this (+ 0.5 to force proper rounding). */
				dy = dx / min + 0.5;
				*width  = dx + real_basew;
				*height = dy + real_baseh;
			} else if (ratio > max) {
				/* dx is too high, lower it (+0.5 for proper rounding) */
				dx = dy * max + 0.5;
				*width  = dx + real_basew;
				*height = dy + real_baseh;
			}
		}
	}

	/* Handle the minimum size */
	*width = MAX(*width, minw);
	*height = MAX(*height, minh);

	/* Handle the maximum size */
	if (c->size_hints.flags & XCB_ICCCM_SIZE_HINT_P_MAX_SIZE)
	{
		if (c->size_hints.max_width > 0) {
			*width = MIN(*width, c->size_hints.max_width);
		}
		if (c->size_hints.max_height > 0) {
			*height = MIN(*height, c->size_hints.max_height);
		}
	}

	/* Handle the size increment */
	if (c->size_hints.flags & (XCB_ICCCM_SIZE_HINT_P_RESIZE_INC | XCB_ICCCM_SIZE_HINT_BASE_SIZE) &&
	    c->size_hints.width_inc > 0 && c->size_hints.height_inc > 0) {
		uint16_t t1 = *width, t2 = *height;
		unsigned_subtract(t1, basew);
		unsigned_subtract(t2, baseh);
		*width -= t1 % c->size_hints.width_inc;
		*height -= t2 % c->size_hints.height_inc;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x328(%rax)
je 0x17fb8
movq -0x8(%rbp), %rax
cmpl $0x1, 0x328(%rax)
jne 0x17f77
movq -0x8(%rbp), %rax
cmpl $0x3, 0x308(%rax)
jne 0x17fbd
movq -0x8(%rbp), %rax
cmpl $0x3, 0x328(%rax)
jne 0x17f91
movq -0x8(%rbp), %rax
cmpl $0x0, 0x308(%rax)
je 0x17fbd
movq -0x8(%rbp), %rax
cmpl $0x2, 0x328(%rax)
jne 0x17fb8
movq -0x8(%rbp), %rax
cmpl $0x2, 0x308(%rax)
je 0x17fbd
movq -0x8(%rbp), %rax
cmpl $0x1, 0x308(%rax)
je 0x17fbd
jmp 0x1844e
movl $0x0, -0x1c(%rbp)
movl $0x0, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movl $0x0, -0x30(%rbp)
movq -0x8(%rbp), %rax
movl 0x32c(%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x18023
movq -0x8(%rbp), %rax
movl 0x368(%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movl 0x36c(%rax), %eax
movl %eax, -0x28(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x28(%rbp), %eax
movl %eax, -0x30(%rbp)
jmp 0x18051
movq -0x8(%rbp), %rax
movl 0x32c(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x1804f
movq -0x8(%rbp), %rax
movl 0x340(%rax), %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movl 0x344(%rax), %eax
movl %eax, -0x28(%rbp)
jmp 0x18051
movq -0x8(%rbp), %rax
movl 0x32c(%rax), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x1807f
movq -0x8(%rbp), %rax
movl 0x340(%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movl 0x344(%rax), %eax
movl %eax, -0x20(%rbp)
jmp 0x180af
movq -0x8(%rbp), %rax
movl 0x32c(%rax), %eax
andl $0x100, %eax            # imm = 0x100
cmpl $0x0, %eax
je 0x180ad
movq -0x8(%rbp), %rax
movl 0x368(%rax), %eax
movl %eax, -0x1c(%rbp)
movq -0x8(%rbp), %rax
movl 0x36c(%rax), %eax
movl %eax, -0x20(%rbp)
jmp 0x180af
movq -0x8(%rbp), %rax
movl 0x32c(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x18288
movq -0x8(%rbp), %rax
cmpl $0x0, 0x35c(%rax)
jle 0x18288
movq -0x8(%rbp), %rax
cmpl $0x0, 0x364(%rax)
jle 0x18288
movq -0x18(%rbp), %rax
movzwl (%rax), %eax
cmpl -0x30(%rbp), %eax
jle 0x18288
movq -0x10(%rbp), %rax
movzwl (%rax), %eax
cmpl -0x2c(%rbp), %eax
jle 0x18288
movq -0x10(%rbp), %rax
movzwl (%rax), %eax
subl -0x2c(%rbp), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x38(%rbp)
movq -0x18(%rbp), %rax
movzwl (%rax), %eax
subl -0x30(%rbp), %eax
cvtsi2sd %eax, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x38(%rbp), %xmm0
divsd -0x40(%rbp), %xmm0
movsd %xmm0, -0x48(%rbp)
movq -0x8(%rbp), %rax
cvtsi2sdl 0x358(%rax), %xmm0
movq -0x8(%rbp), %rax
cvtsi2sdl 0x35c(%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x50(%rbp)
movq -0x8(%rbp), %rax
cvtsi2sdl 0x360(%rax), %xmm0
movq -0x8(%rbp), %rax
cvtsi2sdl 0x364(%rax), %xmm1
divsd %xmm1, %xmm0
movsd %xmm0, -0x58(%rbp)
movsd -0x58(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x18286
movsd -0x50(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x18286
movsd -0x48(%rbp), %xmm0
xorps %xmm1, %xmm1
ucomisd %xmm1, %xmm0
jbe 0x18286
movsd -0x48(%rbp), %xmm1
movsd -0x50(%rbp), %xmm0
ucomisd %xmm1, %xmm0
jbe 0x1821f
movsd -0x38(%rbp), %xmm0
movsd -0x50(%rbp), %xmm1
divsd %xmm1, %xmm0
movsd 0x153b4(%rip), %xmm1    # 0x2d590
addsd %xmm1, %xmm0
movsd %xmm0, -0x40(%rbp)
movsd -0x38(%rbp), %xmm0
cvtsi2sdl -0x2c(%rbp), %xmm1
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, (%rax)
movsd -0x40(%rbp), %xmm0
cvtsi2sdl -0x30(%rbp), %xmm1
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, (%rax)
jmp 0x18284
movsd -0x48(%rbp), %xmm0
ucomisd -0x58(%rbp), %xmm0
jbe 0x18282
movsd -0x40(%rbp), %xmm0
movsd -0x58(%rbp), %xmm1
mulsd %xmm1, %xmm0
movsd 0x1534f(%rip), %xmm1    # 0x2d590
addsd %xmm1, %xmm0
movsd %xmm0, -0x38(%rbp)
movsd -0x38(%rbp), %xmm0
cvtsi2sdl -0x2c(%rbp), %xmm1
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, (%rax)
movsd -0x40(%rbp), %xmm0
cvtsi2sdl -0x30(%rbp), %xmm1
addsd %xmm1, %xmm0
cvttsd2si %xmm0, %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, (%rax)
jmp 0x18284
jmp 0x18286
jmp 0x18288
movq -0x10(%rbp), %rax
movzwl (%rax), %eax
cmpl -0x1c(%rbp), %eax
jle 0x182a0
movq -0x10(%rbp), %rax
movzwl (%rax), %eax
movl %eax, -0x60(%rbp)
jmp 0x182a6
movl -0x1c(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, (%rax)
movq -0x18(%rbp), %rax
movzwl (%rax), %eax
cmpl -0x20(%rbp), %eax
jle 0x182cb
movq -0x18(%rbp), %rax
movzwl (%rax), %eax
movl %eax, -0x64(%rbp)
jmp 0x182d1
movl -0x20(%rbp), %eax
movl %eax, -0x64(%rbp)
movl -0x64(%rbp), %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, (%rax)
movq -0x8(%rbp), %rax
movl 0x32c(%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x18382
movq -0x8(%rbp), %rax
cmpl $0x0, 0x348(%rax)
jle 0x1833a
movq -0x10(%rbp), %rax
movzwl (%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0x348(%rcx), %eax
jge 0x18320
movq -0x10(%rbp), %rax
movzwl (%rax), %eax
movl %eax, -0x68(%rbp)
jmp 0x1832d
movq -0x8(%rbp), %rax
movl 0x348(%rax), %eax
movl %eax, -0x68(%rbp)
movl -0x68(%rbp), %eax
movw %ax, %cx
movq -0x10(%rbp), %rax
movw %cx, (%rax)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x34c(%rax)
jle 0x18380
movq -0x18(%rbp), %rax
movzwl (%rax), %eax
movq -0x8(%rbp), %rcx
cmpl 0x34c(%rcx), %eax
jge 0x18366
movq -0x18(%rbp), %rax
movzwl (%rax), %eax
movl %eax, -0x6c(%rbp)
jmp 0x18373
movq -0x8(%rbp), %rax
movl 0x34c(%rax), %eax
movl %eax, -0x6c(%rbp)
movl -0x6c(%rbp), %eax
movw %ax, %cx
movq -0x18(%rbp), %rax
movw %cx, (%rax)
jmp 0x18382
movq -0x8(%rbp), %rax
movl 0x32c(%rax), %eax
andl $0x140, %eax            # imm = 0x140
cmpl $0x0, %eax
je 0x1844e
movq -0x8(%rbp), %rax
cmpl $0x0, 0x350(%rax)
jle 0x1844e
movq -0x8(%rbp), %rax
cmpl $0x0, 0x354(%rax)
jle 0x1844e
movq -0x10(%rbp), %rax
movw (%rax), %ax
movw %ax, -0x5a(%rbp)
movq -0x18(%rbp), %rax
movw (%rax), %ax
movw %ax, -0x5c(%rbp)
movl -0x24(%rbp), %eax
movzwl -0x5a(%rbp), %ecx
cmpl %ecx, %eax
jle 0x183e5
movw $0x0, -0x5a(%rbp)
jmp 0x183f2
movl -0x24(%rbp), %ecx
movzwl -0x5a(%rbp), %eax
subl %ecx, %eax
movw %ax, -0x5a(%rbp)
jmp 0x183f4
jmp 0x183f6
movl -0x28(%rbp), %eax
movzwl -0x5c(%rbp), %ecx
cmpl %ecx, %eax
jle 0x18409
movw $0x0, -0x5c(%rbp)
jmp 0x18416
movl -0x28(%rbp), %ecx
movzwl -0x5c(%rbp), %eax
subl %ecx, %eax
movw %ax, -0x5c(%rbp)
jmp 0x18418
movzwl -0x5a(%rbp), %eax
movq -0x8(%rbp), %rcx
cltd
idivl 0x350(%rcx)
movq -0x10(%rbp), %rax
movzwl (%rax), %ecx
subl %edx, %ecx
movw %cx, (%rax)
movzwl -0x5c(%rbp), %eax
movq -0x8(%rbp), %rcx
cltd
idivl 0x354(%rcx)
movq -0x18(%rbp), %rax
movzwl (%rax), %ecx
subl %edx, %ecx
movw %cx, (%rax)
popq %rbp
retq