// File: /workspace/github_c_makefile_star2_O0/tudurom[P]windowchef/wm.c
// Function: get_handle
static enum resize_handle
get_handle(struct client *client, xcb_point_t pos, enum pointer_action pac)
{
	if (client == NULL)
		return pac == POINTER_ACTION_RESIZE_SIDE ? HANDLE_LEFT : HANDLE_TOP_LEFT;

	enum resize_handle handle;
	struct window_geom geom = client->geom;

	if (pac == POINTER_ACTION_RESIZE_SIDE) {
		/* coordinates relative to the window */
		int16_t x = pos.x - geom.x;
		int16_t y = pos.y - geom.y;
		bool left_of_a = (x * geom.height) < (geom.width * y);
		bool left_of_b = ((geom.width - x) * geom.height) > (geom.width * y);

		/* Problem is that the above algorithm works in a 2d system
		   where the origin is in the bottom-left. */
		if (left_of_a) {
			if (left_of_b) {
				handle = HANDLE_LEFT;
			}
			else
				handle = HANDLE_BOTTOM;
		} else {
			if (left_of_b)
				handle = HANDLE_TOP;
			else
				handle = HANDLE_RIGHT;
		}
	} else if (pac == POINTER_ACTION_RESIZE_CORNER) {
		int16_t mid_x = geom.x + geom.width / 2;
		int16_t mid_y = geom.y + geom.height / 2;

		if (pos.y < mid_y) {
			if (pos.x < mid_x)
				handle = HANDLE_TOP_LEFT;
			else
				handle = HANDLE_TOP_RIGHT;
		} else {
			if (pos.x < mid_x)
				handle = HANDLE_BOTTOM_LEFT;
			else
				handle = HANDLE_BOTTOM_RIGHT;
		}
	} else {
		handle = HANDLE_TOP_LEFT;
	}

	return handle;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
movl %esi, -0x8(%rbp)
movq %rdi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x84cd
movl -0x14(%rbp), %edx
movl $0x4, %eax
xorl %ecx, %ecx
cmpl $0x4, %edx
cmovel %ecx, %eax
movl %eax, -0x4(%rbp)
jmp 0x8627
movq -0x10(%rbp), %rax
movq 0x4(%rax), %rcx
movq %rcx, -0x22(%rbp)
movw 0xc(%rax), %ax
movw %ax, -0x1a(%rbp)
cmpl $0x4, -0x14(%rbp)
jne 0x8588
movswl -0x8(%rbp), %eax
movswl -0x22(%rbp), %ecx
subl %ecx, %eax
movw %ax, -0x24(%rbp)
movswl -0x6(%rbp), %eax
movswl -0x20(%rbp), %ecx
subl %ecx, %eax
movw %ax, -0x26(%rbp)
movswl -0x24(%rbp), %eax
movzwl -0x1c(%rbp), %ecx
imull %ecx, %eax
movzwl -0x1e(%rbp), %ecx
movswl -0x26(%rbp), %edx
imull %edx, %ecx
cmpl %ecx, %eax
setl %al
andb $0x1, %al
movb %al, -0x27(%rbp)
movzwl -0x1e(%rbp), %eax
movswl -0x24(%rbp), %ecx
subl %ecx, %eax
movzwl -0x1c(%rbp), %ecx
imull %ecx, %eax
movzwl -0x1e(%rbp), %ecx
movswl -0x26(%rbp), %edx
imull %edx, %ecx
cmpl %ecx, %eax
setg %al
andb $0x1, %al
movb %al, -0x28(%rbp)
testb $0x1, -0x27(%rbp)
je 0x856b
testb $0x1, -0x28(%rbp)
je 0x8562
movl $0x0, -0x18(%rbp)
jmp 0x8569
movl $0x1, -0x18(%rbp)
jmp 0x8583
testb $0x1, -0x28(%rbp)
je 0x857a
movl $0x2, -0x18(%rbp)
jmp 0x8581
movl $0x3, -0x18(%rbp)
jmp 0x8583
jmp 0x8621
cmpl $0x3, -0x14(%rbp)
jne 0x8618
movswl -0x22(%rbp), %eax
movl %eax, -0x34(%rbp)
movzwl -0x1e(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x34(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x2a(%rbp)
movswl -0x20(%rbp), %eax
movl %eax, -0x30(%rbp)
movzwl -0x1c(%rbp), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x30(%rbp), %eax
addl %ecx, %eax
movw %ax, -0x2c(%rbp)
movswl -0x6(%rbp), %eax
movswl -0x2c(%rbp), %ecx
cmpl %ecx, %eax
jge 0x85f8
movswl -0x8(%rbp), %eax
movswl -0x2a(%rbp), %ecx
cmpl %ecx, %eax
jge 0x85ef
movl $0x4, -0x18(%rbp)
jmp 0x85f6
movl $0x5, -0x18(%rbp)
jmp 0x8616
movswl -0x8(%rbp), %eax
movswl -0x2a(%rbp), %ecx
cmpl %ecx, %eax
jge 0x860d
movl $0x6, -0x18(%rbp)
jmp 0x8614
movl $0x7, -0x18(%rbp)
jmp 0x8616
jmp 0x861f
movl $0x4, -0x18(%rbp)
jmp 0x8621
movl -0x18(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
popq %rbp
retq
nopl (%rax)