// File: /workspace/github_c_makefile_star2_O0/kaiserschmarrn0[P]mywm/mywm.c
// Function: configure_request
static void configure_request(xcb_generic_event_t *ev) {
	xcb_configure_request_event_t *e = (xcb_configure_request_event_t *)ev;
	window *found = search_all(NULL, TYPE_ALL, WIN_CHILD, e->window);
	
	uint32_t vals[6];
	unsigned int i = 0;

	if (!found || !found->normal) {
		int i = mask_to_geo(e, vals);

		CHECK_MASK(vals, i, e->sibling, e->value_mask, XCB_CONFIG_WINDOW_SIBLING)
		CHECK_MASK(vals, i, e->stack_mode, e->value_mask, XCB_CONFIG_WINDOW_STACK_MODE)

		xcb_configure_window(conn, e->window, e->value_mask, vals);

		return;
	}
	
	if (!found->is_i_full && !found->is_e_full) {
		uint32_t ignore = XCB_CONFIG_WINDOW_STACK_MODE | XCB_CONFIG_WINDOW_SIBLING;
		
		if (e->value_mask & XCB_CONFIG_WINDOW_X) {
			vals[i++] = e->x - PAD;
		}
		if (e->value_mask & XCB_CONFIG_WINDOW_Y) {
			vals[i++] = e->y - PAD_N;
		}
		if (e->value_mask & XCB_CONFIG_WINDOW_WIDTH) {
			vals[i++] = e->width - 2 * PAD;
		}
		if (e->value_mask & XCB_CONFIG_WINDOW_HEIGHT) {
			vals[i++] = e->height - PAD_N - PAD;
		}

		update_geometry(found, e->value_mask & ~ignore, vals);
	}
		
	if (e->value_mask & XCB_CONFIG_WINDOW_STACK_MODE) {
		switch (e->stack_mode) {
			case XCB_STACK_MODE_ABOVE: mywm_raise(found); break;
			case XCB_STACK_MODE_BELOW: /* dumbass */ break;
		}
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movl 0x8(%rax), %ecx
xorl %eax, %eax
movl %eax, %edi
xorl %edx, %edx
movl %edx, %esi
callq 0x87a0
movq %rax, -0x18(%rbp)
movl $0x0, -0x34(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x4eab
movq -0x18(%rbp), %rax
cmpl $0x0, 0xc0(%rax)
jne 0x4f36
movq -0x10(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x5560
movl %eax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movzwl 0x1a(%rax), %eax
andl $0x20, %eax
cmpl $0x0, %eax
je 0x4ee3
movq -0x10(%rbp), %rax
movl 0xc(%rax), %ecx
movl -0x38(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x38(%rbp)
cltq
movl %ecx, -0x30(%rbp,%rax,4)
movq -0x10(%rbp), %rax
movzwl 0x1a(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x4f0c
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %ecx
movl -0x38(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x38(%rbp)
cltq
movl %ecx, -0x30(%rbp,%rax,4)
movq 0xb535(%rip), %rdi      # 0x10448
movq -0x10(%rbp), %rax
movl 0x8(%rax), %esi
movq -0x10(%rbp), %rax
movw 0x1a(%rax), %ax
leaq -0x30(%rbp), %rcx
movzwl %ax, %edx
callq 0x31d0
movl %eax, -0x3c(%rbp)
jmp 0x5069
movq -0x18(%rbp), %rax
cmpl $0x0, 0x18c(%rax)
jne 0x502f
movq -0x18(%rbp), %rax
cmpl $0x0, 0x190(%rax)
jne 0x502f
movl $0x60, -0x40(%rbp)
movq -0x10(%rbp), %rax
movzwl 0x1a(%rax), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x4f8b
movq -0x10(%rbp), %rax
movswl 0x10(%rax), %ecx
subl $0x1, %ecx
movl -0x34(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x34(%rbp)
movl %eax, %eax
movl %ecx, -0x30(%rbp,%rax,4)
movq -0x10(%rbp), %rax
movzwl 0x1a(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
je 0x4fb7
movq -0x10(%rbp), %rax
movswl 0x12(%rax), %ecx
subl $0x20, %ecx
movl -0x34(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x34(%rbp)
movl %eax, %eax
movl %ecx, -0x30(%rbp,%rax,4)
movq -0x10(%rbp), %rax
movzwl 0x1a(%rax), %eax
andl $0x4, %eax
cmpl $0x0, %eax
je 0x4fe3
movq -0x10(%rbp), %rax
movzwl 0x14(%rax), %ecx
subl $0x2, %ecx
movl -0x34(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x34(%rbp)
movl %eax, %eax
movl %ecx, -0x30(%rbp,%rax,4)
movq -0x10(%rbp), %rax
movzwl 0x1a(%rax), %eax
andl $0x8, %eax
cmpl $0x0, %eax
je 0x5012
movq -0x10(%rbp), %rax
movzwl 0x16(%rax), %ecx
subl $0x20, %ecx
subl $0x1, %ecx
movl -0x34(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x34(%rbp)
movl %eax, %eax
movl %ecx, -0x30(%rbp,%rax,4)
movq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rax
movzwl 0x1a(%rax), %esi
movl -0x40(%rbp), %eax
xorl $-0x1, %eax
andl %eax, %esi
leaq -0x30(%rbp), %rdx
callq 0x63f0
movq -0x10(%rbp), %rax
movzwl 0x1a(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x5069
movq -0x10(%rbp), %rax
movzbl 0x1(%rax), %eax
movl %eax, -0x44(%rbp)
testl %eax, %eax
je 0x505a
jmp 0x5050
movl -0x44(%rbp), %eax
subl $0x1, %eax
je 0x5065
jmp 0x5067
movq -0x18(%rbp), %rdi
callq 0x5c80
jmp 0x5067
jmp 0x5067
jmp 0x5069
addq $0x50, %rsp
popq %rbp
retq
nop