// File: /workspace/github_c_makefile_star2_O2/baskerville[P]bspwm/src/events.c
// Function: configure_request
void configure_request(xcb_generic_event_t *evt)
{
	xcb_configure_request_event_t *e = (xcb_configure_request_event_t *) evt;

	coordinates_t loc;
	bool is_managed = locate_window(e->window, &loc);
	client_t *c = (is_managed ? loc.node->client : NULL);
	uint16_t width, height;

	if (!is_managed) {
		uint16_t mask = 0;
		uint32_t values[7];
		unsigned short i = 0;

		if (e->value_mask & XCB_CONFIG_WINDOW_X) {
			mask |= XCB_CONFIG_WINDOW_X;
			values[i++] = e->x;
		}

		if (e->value_mask & XCB_CONFIG_WINDOW_Y) {
			mask |= XCB_CONFIG_WINDOW_Y;
			values[i++] = e->y;
		}

		if (e->value_mask & XCB_CONFIG_WINDOW_WIDTH) {
			mask |= XCB_CONFIG_WINDOW_WIDTH;
			values[i++] = e->width;
		}

		if (e->value_mask & XCB_CONFIG_WINDOW_HEIGHT) {
			mask |= XCB_CONFIG_WINDOW_HEIGHT;
			values[i++] = e->height;
		}

		if (e->value_mask & XCB_CONFIG_WINDOW_BORDER_WIDTH) {
			mask |= XCB_CONFIG_WINDOW_BORDER_WIDTH;
			values[i++] = e->border_width;
		}

		if (e->value_mask & XCB_CONFIG_WINDOW_SIBLING) {
			mask |= XCB_CONFIG_WINDOW_SIBLING;
			values[i++] = e->sibling;
		}

		if (e->value_mask & XCB_CONFIG_WINDOW_STACK_MODE) {
			mask |= XCB_CONFIG_WINDOW_STACK_MODE;
			values[i++] = e->stack_mode;
		}

		xcb_configure_window(dpy, e->window, mask, values);

	} else if (IS_FLOATING(c)) {
		width = c->floating_rectangle.width;
		height = c->floating_rectangle.height;

		if (e->value_mask & XCB_CONFIG_WINDOW_X) {
			c->floating_rectangle.x = e->x;
		}

		if (e->value_mask & XCB_CONFIG_WINDOW_Y) {
			c->floating_rectangle.y = e->y;
		}

		if (e->value_mask & XCB_CONFIG_WINDOW_WIDTH) {
			width = e->width;
		}

		if (e->value_mask & XCB_CONFIG_WINDOW_HEIGHT) {
			height = e->height;
		}

		apply_size_hints(c, &width, &height);
		c->floating_rectangle.width = width;
		c->floating_rectangle.height = height;
		xcb_rectangle_t r = c->floating_rectangle;

		r.x -= c->border_width;
		r.y -= c->border_width;

		window_move_resize(e->window, r.x, r.y, r.width, r.height);

		put_status(SBSC_MASK_NODE_GEOMETRY, "node_geometry 0x%08X 0x%08X 0x%08X %ux%u+%i+%i\n", loc.monitor->id, loc.desktop->id, e->window, r.width, r.height, r.x, r.y);

		monitor_t *m = monitor_from_client(c);
		if (m != loc.monitor) {
			transfer_node(loc.monitor, loc.desktop, loc.node, m, m->desk, m->desk->focus, false);
		}
	} else {
		if (c->state == STATE_PSEUDO_TILED) {
			width = c->floating_rectangle.width;
			height = c->floating_rectangle.height;
			if (e->value_mask & XCB_CONFIG_WINDOW_WIDTH) {
				width = e->width;
			}
			if (e->value_mask & XCB_CONFIG_WINDOW_HEIGHT) {
				height = e->height;
			}
			apply_size_hints(c, &width, &height);
			if (width != c->floating_rectangle.width || height != c->floating_rectangle.height) {
				c->floating_rectangle.width = width;
				c->floating_rectangle.height = height;
				arrange(loc.monitor, loc.desktop);
			}
		}


		xcb_configure_notify_event_t evt;
		unsigned int bw = c->border_width;

		xcb_rectangle_t r = IS_FULLSCREEN(c) ? loc.monitor->rectangle : c->tiled_rectangle;

		evt.response_type = XCB_CONFIGURE_NOTIFY;
		evt.event = e->window;
		evt.window = e->window;
		evt.above_sibling = XCB_NONE;
		evt.x = r.x;
		evt.y = r.y;
		evt.width = r.width;
		evt.height = r.height;
		evt.border_width = bw;
		evt.override_redirect = false;

		xcb_send_event(dpy, false, e->window, XCB_EVENT_MASK_STRUCTURE_NOTIFY, (const char *) &evt);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
movl 0x8(%rdi), %edi
leaq 0x8(%rsp), %rsi
callq 0x199cc
testb %al, %al
je 0xd483
movq 0x18(%rsp), %rax
movq 0x48(%rax), %r14
movl 0x308(%r14), %ecx
cmpl $0x1, %ecx
je 0xd547
cmpl $0x2, %ecx
jne 0xd5da
movzwl 0x31c(%r14), %eax
movw %ax, 0x6(%rsp)
movzwl 0x31e(%r14), %eax
movw %ax, 0x4(%rsp)
movzwl 0x1a(%rbx), %eax
testb $0x1, %al
je 0xd37e
movzwl 0x10(%rbx), %ecx
movw %cx, 0x318(%r14)
testb $0x2, %al
je 0xd38e
movzwl 0x12(%rbx), %ecx
movw %cx, 0x31a(%r14)
testb $0x4, %al
je 0xd39b
movzwl 0x14(%rbx), %ecx
movw %cx, 0x6(%rsp)
testb $0x8, %al
je 0xd3a8
movzwl 0x16(%rbx), %eax
movw %ax, 0x4(%rsp)
leaq 0x6(%rsp), %r15
leaq 0x4(%rsp), %r12
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x1008b
movzwl (%r15), %ebp
movw %bp, 0x31c(%r14)
movzwl (%r12), %r15d
movw %r15w, 0x31e(%r14)
movl 0x300(%r14), %eax
movl 0x318(%r14), %ecx
movzwl 0x31a(%r14), %edx
subl %eax, %ecx
subl %eax, %edx
movl 0x8(%rbx), %edi
movswl %dx, %r12d
movswl %cx, %r13d
movl %r13d, %esi
movl %r12d, %edx
movl %ebp, %ecx
movl %r15d, %r8d
callq 0xf602
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
movl 0x20(%rax), %edx
movl 0x20(%rcx), %ecx
movl 0x8(%rbx), %r8d
subq $0x8, %rsp
leaq 0x111e3(%rip), %rsi     # 0x1e610
movl $0x800000, %edi         # imm = 0x800000
movl %ebp, %r9d
xorl %eax, %eax
pushq %r12
pushq %r13
pushq %r15
callq 0x1d07d
addq $0x20, %rsp
movq %r14, %rdi
callq 0x7330
movq 0x8(%rsp), %rdi
cmpq %rdi, %rax
je 0xd673
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x58(%rax), %r8
movq 0x38(%r8), %r9
subq $0x8, %rsp
movq %rax, %rcx
pushq $0x0
callq 0x9937
popq %rcx
popq %rdx
jmp 0xd673
movzwl 0x1a(%rbx), %eax
testb $0x1, %al
jne 0xd48f
xorl %edx, %edx
jmp 0xd49b
movswl 0x10(%rbx), %ecx
movl %ecx, 0x20(%rsp)
movw $0x1, %dx
testb $0x2, %al
jne 0xd4a3
movl %edx, %ecx
jmp 0xd4b4
movzwl %dx, %esi
leal 0x2(%rsi), %ecx
movswl 0x12(%rbx), %edi
leal 0x1(%rsi), %edx
movl %edi, 0x20(%rsp,%rsi,4)
testb $0x4, %al
je 0xd4cc
movzwl %cx, %ecx
orl $0x4, %ecx
movzwl 0x14(%rbx), %esi
movzwl %dx, %edi
leal 0x1(%rdi), %edx
movl %esi, 0x20(%rsp,%rdi,4)
testb $0x8, %al
je 0xd4e4
movzwl %cx, %ecx
orl $0x8, %ecx
movzwl 0x16(%rbx), %esi
movzwl %dx, %edi
leal 0x1(%rdi), %edx
movl %esi, 0x20(%rsp,%rdi,4)
testb $0x10, %al
je 0xd4fc
movzwl %cx, %ecx
orl $0x10, %ecx
movzwl 0x18(%rbx), %esi
movzwl %dx, %edi
leal 0x1(%rdi), %edx
movl %esi, 0x20(%rsp,%rdi,4)
testb $0x20, %al
je 0xd513
movzwl %cx, %ecx
orl $0x20, %ecx
movl 0xc(%rbx), %esi
movzwl %dx, %edi
leal 0x1(%rdi), %edx
movl %esi, 0x20(%rsp,%rdi,4)
testb $0x40, %al
je 0xd528
movzwl %cx, %ecx
orl $0x40, %ecx
movzbl 0x1(%rbx), %eax
movzwl %dx, %edx
movl %eax, 0x20(%rsp,%rdx,4)
leaq 0x1b199(%rip), %rax     # 0x286c8
movq (%rax), %rdi
movl 0x8(%rbx), %esi
movzwl %cx, %edx
leaq 0x20(%rsp), %rcx
callq 0x4310
jmp 0xd673
movzwl 0x31c(%r14), %eax
movw %ax, 0x6(%rsp)
movzwl 0x31e(%r14), %eax
movw %ax, 0x4(%rsp)
movzwl 0x1a(%rbx), %eax
testb $0x4, %al
je 0xd572
movzwl 0x14(%rbx), %ecx
movw %cx, 0x6(%rsp)
testb $0x8, %al
je 0xd57f
movzwl 0x16(%rbx), %eax
movw %ax, 0x4(%rsp)
leaq 0x6(%rsp), %r15
leaq 0x4(%rsp), %r12
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x1008b
movzwl (%r15), %eax
movzwl (%r12), %ecx
cmpw 0x31c(%r14), %ax
jne 0xd5b4
cmpw 0x31e(%r14), %cx
je 0xd5d3
movw %ax, 0x31c(%r14)
movw %cx, 0x31e(%r14)
movq 0x8(%rsp), %rdi
movq 0x10(%rsp), %rsi
callq 0x8670
movl 0x308(%r14), %ecx
movl 0x300(%r14), %eax
cmpl $0x3, %ecx
jne 0xd5fd
movq 0x8(%rsp), %r14
leaq 0x4c(%r14), %rcx
leaq 0x4e(%r14), %rdx
leaq 0x50(%r14), %rsi
addq $0x52, %r14
jmp 0xd619
leaq 0x320(%r14), %rcx
leaq 0x322(%r14), %rdx
leaq 0x324(%r14), %rsi
addq $0x326, %r14            # imm = 0x326
movzwl (%rcx), %ecx
movzwl (%rdx), %edi
movzwl (%rsi), %esi
movzwl (%r14), %r9d
leaq 0x20(%rsp), %r8
movb $0x16, (%r8)
movl 0x8(%rbx), %edx
movl %edx, 0x4(%r8)
movl %edx, 0x8(%r8)
andl $0x0, 0xc(%r8)
movw %cx, 0x10(%r8)
movw %di, 0x12(%r8)
movw %si, 0x14(%r8)
movw %r9w, 0x16(%r8)
movw %ax, 0x18(%r8)
movb $0x0, 0x1a(%r8)
leaq 0x1b064(%rip), %rax     # 0x286c8
movq (%rax), %rdi
xorl %esi, %esi
movl $0x20000, %ecx          # imm = 0x20000
callq 0x4600
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq