// File: /workspace/github_c_makefile_star2_O0/tudurom[P]windowchef/wm.c
// Function: setup_window
static struct client *
setup_window(xcb_window_t win)
{
	uint32_t values[2];
	xcb_ewmh_get_atoms_reply_t win_type;
	xcb_atom_t atom;
	struct client *client;
	struct list_item *item;
	struct list_item *focus_item;
	xcb_size_hints_t hints;

	if (xcb_ewmh_get_wm_window_type_reply(ewmh,
				xcb_ewmh_get_wm_window_type(ewmh, win),
				&win_type, NULL) == 1) {
		unsigned int i = 0;
		/* if the window is a toolbar or a dock, map it and ignore it */
		while (i < win_type.atoms_len &&
			(atom = win_type.atoms[i]) != ewmh->_NET_WM_WINDOW_TYPE_TOOLBAR
			&& atom != ewmh->_NET_WM_WINDOW_TYPE_DOCK
			&& atom != ewmh->_NET_WM_WINDOW_TYPE_DESKTOP)
			i++;

		if (i < win_type.atoms_len) {
			xcb_ewmh_get_atoms_reply_wipe(&win_type);
			xcb_map_window(conn, win);
			return NULL;
		}
	}

	/* subscribe to events */
	values[0] = XCB_EVENT_MASK_ENTER_WINDOW | XCB_EVENT_MASK_FOCUS_CHANGE;
	xcb_change_window_attributes(conn, win, XCB_CW_EVENT_MASK, values);

	/* in case of fire */
	xcb_change_save_set(conn, XCB_SET_MODE_INSERT, win);

	/* assign to the null group */
	xcb_ewmh_set_wm_desktop(ewmh, win, NULL_GROUP);

	item = list_add_item(&win_list);
	if (item == NULL)
		return NULL;

	focus_item = list_add_item(&focus_list);
	if (focus_item == NULL)
	    return NULL;

	client = malloc(sizeof(struct client));
	if (client == NULL)
		return NULL;

	/* initialize variables */
	focus_item->data = client;
	client->focus_item = focus_item;
	item->data = client;
	client->item = item;
	client->window = win;
	client->geom.x = client->geom.y = client->geom.width
				   = client->geom.height
				   = client->min_width = client->min_height = 0;
	client->grid.gx = client->grid.gy = client->grid.px
		= client->grid.py = client->grid.sx = client->grid.sy = 0;
	client->width_inc = client->height_inc = 1;
	client->maxed  = client->hmaxed = client->vmaxed
		= client->monocled = client->gridded = client->geom.set_by_user = false;
	client->monitor = NULL;
	client->mapped  = false;
	client->group   = NULL_GROUP;
	get_geometry(&client->window, &client->geom.x, &client->geom.y,
			&client->geom.width, &client->geom.height, &client->depth);

	xcb_icccm_get_wm_normal_hints_reply(conn,
			xcb_icccm_get_wm_normal_hints_unchecked(conn, win),
			&hints, NULL);

	if (hints.flags & XCB_ICCCM_SIZE_HINT_US_POSITION)
		client->geom.set_by_user = true;

	if (hints.flags & XCB_ICCCM_SIZE_HINT_P_MIN_SIZE) {
		client->min_width = hints.min_width;
		client->min_height = hints.min_height;
	}

	if (hints.flags & XCB_ICCCM_SIZE_HINT_P_RESIZE_INC) {
		client->width_inc  = hints.width_inc;
		client->height_inc = hints.height_inc;
	}

	update_window_status(client);
	DMSG("new window was born 0x%08x\n", client->window);

	return client;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movl %edi, -0xc(%rbp)
movq 0x88ab(%rip), %rax      # 0xf3e0
movq %rax, -0xc0(%rbp)
movq 0x889d(%rip), %rdi      # 0xf3e0
movl -0xc(%rbp), %esi
callq 0x3070
movq -0xc0(%rbp), %rdi
movl %eax, -0x9c(%rbp)
movl -0x9c(%rbp), %esi
leaq -0x30(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x3130
movzbl %al, %eax
cmpl $0x1, %eax
jne 0x6c46
movl $0x0, -0xa0(%rbp)
movl -0xa0(%rbp), %ecx
xorl %eax, %eax
cmpl -0x30(%rbp), %ecx
movb %al, -0xc1(%rbp)
jae 0x6bee
movq -0x28(%rbp), %rax
movl -0xa0(%rbp), %ecx
movl (%rax,%rcx,4), %ecx
movl %ecx, -0x34(%rbp)
movq 0x8835(%rip), %rdx      # 0xf3e0
xorl %eax, %eax
cmpl 0xd8(%rdx), %ecx
movb %al, -0xc1(%rbp)
je 0x6bee
movl -0x34(%rbp), %ecx
movq 0x881b(%rip), %rdx      # 0xf3e0
xorl %eax, %eax
cmpl 0xd4(%rdx), %ecx
movb %al, -0xc1(%rbp)
je 0x6bee
movl -0x34(%rbp), %eax
movq 0x8801(%rip), %rcx      # 0xf3e0
cmpl 0xd0(%rcx), %eax
setne %al
movb %al, -0xc1(%rbp)
movb -0xc1(%rbp), %al
testb $0x1, %al
jne 0x6bfa
jmp 0x6c0e
movl -0xa0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xa0(%rbp)
jmp 0x6b81
movl -0xa0(%rbp), %eax
cmpl -0x30(%rbp), %eax
jae 0x6c44
leaq -0x30(%rbp), %rdi
callq 0x36f0
movq 0x87af(%rip), %rdi      # 0xf3d8
movl -0xc(%rbp), %esi
callq 0x3280
movl %eax, -0xa4(%rbp)
movq $0x0, -0x8(%rbp)
jmp 0x6f13
jmp 0x6c46
movl $0x200010, -0x14(%rbp)  # imm = 0x200010
movq 0x8784(%rip), %rdi      # 0xf3d8
movl -0xc(%rbp), %esi
leaq -0x14(%rbp), %rcx
movl $0x800, %edx            # imm = 0x800
callq 0x3460
movl %eax, -0xa8(%rbp)
movq 0x8766(%rip), %rdi      # 0xf3d8
movl -0xc(%rbp), %edx
xorl %esi, %esi
callq 0x35a0
movl %eax, -0xac(%rbp)
movq 0x8757(%rip), %rdi      # 0xf3e0
movl -0xc(%rbp), %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x3450
movl %eax, -0xb0(%rbp)
leaq 0x8745(%rip), %rdi      # 0xf3e8
callq 0xb750
movq %rax, -0x48(%rbp)
cmpq $0x0, -0x48(%rbp)
jne 0x6cc0
movq $0x0, -0x8(%rbp)
jmp 0x6f13
leaq 0x8729(%rip), %rdi      # 0xf3f0
callq 0xb750
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
jne 0x6ce4
movq $0x0, -0x8(%rbp)
jmp 0x6f13
movl $0x60, %edi
callq 0x31b0
movq %rax, -0x40(%rbp)
cmpq $0x0, -0x40(%rbp)
jne 0x6d06
movq $0x0, -0x8(%rbp)
jmp 0x6f13
movq -0x40(%rbp), %rcx
movq -0x50(%rbp), %rax
movq %rcx, (%rax)
movq -0x50(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x40(%rbp), %rcx
movq -0x48(%rbp), %rax
movq %rcx, (%rax)
movq -0x48(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x30(%rax)
movl -0xc(%rbp), %ecx
movq -0x40(%rbp), %rax
movl %ecx, (%rax)
movq -0x40(%rbp), %rax
movw $0x0, 0x4a(%rax)
movq -0x40(%rbp), %rax
movw $0x0, 0x48(%rax)
movq -0x40(%rbp), %rax
movw $0x0, 0xa(%rax)
movq -0x40(%rbp), %rax
movw $0x0, 0x8(%rax)
movq -0x40(%rbp), %rax
movw $0x0, 0x6(%rax)
movq -0x40(%rbp), %rax
movw $0x0, 0x4(%rax)
movq -0x40(%rbp), %rax
movw $0x0, 0x22(%rax)
movq -0x40(%rbp), %rax
movw $0x0, 0x20(%rax)
movq -0x40(%rbp), %rax
movw $0x0, 0x1e(%rax)
movq -0x40(%rbp), %rax
movw $0x0, 0x1c(%rax)
movq -0x40(%rbp), %rax
movw $0x0, 0x1a(%rax)
movq -0x40(%rbp), %rax
movw $0x0, 0x18(%rax)
movq -0x40(%rbp), %rax
movw $0x1, 0x52(%rax)
movq -0x40(%rbp), %rax
movw $0x1, 0x50(%rax)
movq -0x40(%rbp), %rax
movb $0x0, 0xc(%rax)
movq -0x40(%rbp), %rax
movb $0x0, 0x28(%rax)
movq -0x40(%rbp), %rax
movb $0x0, 0x27(%rax)
movq -0x40(%rbp), %rax
movb $0x0, 0x26(%rax)
movq -0x40(%rbp), %rax
movb $0x0, 0x25(%rax)
movq -0x40(%rbp), %rax
movb $0x0, 0x24(%rax)
movq -0x40(%rbp), %rax
movq $0x0, 0x40(%rax)
movq -0x40(%rbp), %rax
movb $0x0, 0x54(%rax)
movq -0x40(%rbp), %rax
movl $0xffffffff, 0x58(%rax) # imm = 0xFFFFFFFF
movq -0x40(%rbp), %rdi
movq -0x40(%rbp), %rsi
addq $0x4, %rsi
movq -0x40(%rbp), %rdx
addq $0x4, %rdx
addq $0x2, %rdx
movq -0x40(%rbp), %rcx
addq $0x4, %rcx
addq $0x4, %rcx
movq -0x40(%rbp), %r8
addq $0x4, %r8
addq $0x6, %r8
movq -0x40(%rbp), %r9
addq $0x5c, %r9
callq 0x7250
movq 0x857c(%rip), %rax      # 0xf3d8
movq %rax, -0xd0(%rbp)
movq 0x856e(%rip), %rdi      # 0xf3d8
movl -0xc(%rbp), %esi
callq 0x30d0
movq -0xd0(%rbp), %rdi
movl %eax, -0xb4(%rbp)
movl -0xb4(%rbp), %esi
leaq -0x98(%rbp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x3700
movl -0x98(%rbp), %eax
andl $0x1, %eax
cmpl $0x0, %eax
je 0x6eab
movq -0x40(%rbp), %rax
movb $0x1, 0xc(%rax)
movl -0x98(%rbp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x6ed8
movl -0x84(%rbp), %eax
movw %ax, %cx
movq -0x40(%rbp), %rax
movw %cx, 0x48(%rax)
movl -0x80(%rbp), %eax
movw %ax, %cx
movq -0x40(%rbp), %rax
movw %cx, 0x4a(%rax)
movl -0x98(%rbp), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x6f02
movl -0x74(%rbp), %eax
movw %ax, %cx
movq -0x40(%rbp), %rax
movw %cx, 0x50(%rax)
movl -0x70(%rbp), %eax
movw %ax, %cx
movq -0x40(%rbp), %rax
movw %cx, 0x52(%rax)
movq -0x40(%rbp), %rdi
callq 0x5b70
movq -0x40(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
addq $0xd0, %rsp
popq %rbp
retq