// File: /workspace/github_c_makefile_star2_O0/baskerville[P]bspwm/src/pointer.c
// Function: get_handle
resize_handle_t get_handle(node_t *n, xcb_point_t pos, pointer_action_t pac)
{
	resize_handle_t rh = HANDLE_BOTTOM_RIGHT;
	xcb_rectangle_t rect = get_rectangle(NULL, NULL, n);
	if (pac == ACTION_RESIZE_SIDE) {
		float W = rect.width;
		float H = rect.height;
		float ratio = W / H;
		float x = pos.x - rect.x;
		float y = pos.y - rect.y;
		float diag_a = ratio * y;
		float diag_b = W - diag_a;
		if (x < diag_a) {
			if (x < diag_b) {
				rh = HANDLE_LEFT;
			} else {
				rh = HANDLE_BOTTOM;
			}
		} else {
			if (x < diag_b) {
				rh = HANDLE_TOP;
			} else {
				rh = HANDLE_RIGHT;
			}
		}
	} else if (pac == ACTION_RESIZE_CORNER) {
		int16_t mid_x = rect.x + (rect.width / 2);
		int16_t mid_y = rect.y + (rect.height / 2);
		if (pos.x > mid_x) {
			if (pos.y > mid_y) {
				rh = HANDLE_BOTTOM_RIGHT;
			} else {
				rh = HANDLE_TOP_RIGHT;
			}
		} else {
			if (pos.y > mid_y) {
				rh = HANDLE_BOTTOM_LEFT;
			} else {
				rh = HANDLE_TOP_LEFT;
			}
		}
	}
	return rh;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movl %esi, -0x4(%rbp)
movq %rdi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl $0xc, -0x18(%rbp)
movq -0x10(%rbp), %rdx
xorl %eax, %eax
movl %eax, %esi
movq %rsi, %rdi
callq 0xc7f0
movq %rax, -0x20(%rbp)
cmpl $0x3, -0x14(%rbp)
jne 0x1539a
movzwl -0x1c(%rbp), %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x24(%rbp)
movzwl -0x1a(%rbp), %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x28(%rbp)
movss -0x24(%rbp), %xmm0
divss -0x28(%rbp), %xmm0
movss %xmm0, -0x2c(%rbp)
movswl -0x4(%rbp), %eax
movswl -0x20(%rbp), %ecx
subl %ecx, %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x30(%rbp)
movswl -0x2(%rbp), %eax
movswl -0x1e(%rbp), %ecx
subl %ecx, %eax
cvtsi2ss %eax, %xmm0
movss %xmm0, -0x34(%rbp)
movss -0x2c(%rbp), %xmm0
mulss -0x34(%rbp), %xmm0
movss %xmm0, -0x38(%rbp)
movss -0x24(%rbp), %xmm0
subss -0x38(%rbp), %xmm0
movss %xmm0, -0x3c(%rbp)
movss -0x30(%rbp), %xmm1
movss -0x38(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x15374
movss -0x30(%rbp), %xmm1
movss -0x3c(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x1536b
movl $0x1, -0x18(%rbp)
jmp 0x15372
movl $0x8, -0x18(%rbp)
jmp 0x15395
movss -0x30(%rbp), %xmm1
movss -0x3c(%rbp), %xmm0
ucomiss %xmm1, %xmm0
jbe 0x1538c
movl $0x2, -0x18(%rbp)
jmp 0x15393
movl $0x4, -0x18(%rbp)
jmp 0x15395
jmp 0x1542c
cmpl $0x4, -0x14(%rbp)
jne 0x1542a
movswl -0x20(%rbp), %eax
movl %eax, -0x48(%rbp)
movzwl -0x1c(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x48(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x3e(%rbp)
movswl -0x1e(%rbp), %eax
movl %eax, -0x44(%rbp)
movzwl -0x1a(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x44(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x40(%rbp)
movswl -0x4(%rbp), %eax
movswl -0x3e(%rbp), %ecx
cmpl %ecx, %eax
jle 0x1540a
movswl -0x2(%rbp), %eax
movswl -0x40(%rbp), %ecx
cmpl %ecx, %eax
jle 0x15401
movl $0xc, -0x18(%rbp)
jmp 0x15408
movl $0x6, -0x18(%rbp)
jmp 0x15428
movswl -0x2(%rbp), %eax
movswl -0x40(%rbp), %ecx
cmpl %ecx, %eax
jle 0x1541f
movl $0x9, -0x18(%rbp)
jmp 0x15426
movl $0x3, -0x18(%rbp)
jmp 0x15428
jmp 0x1542a
jmp 0x1542c
movl -0x18(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)