// File: /workspace/github_c_makefile_star2_O0/tudurom[P]windowchef/wm.c
// Function: grid_window
static void
grid_window(struct client *client, uint16_t grid_width, uint16_t grid_height, uint16_t grid_x, uint16_t grid_y, uint16_t occ_w, uint16_t occ_h)
{
	int16_t mon_x, mon_y;
	uint16_t base_w, base_h;
	uint16_t new_w, new_h;
	uint16_t mon_w, mon_h;

	if (client == NULL || grid_x >= grid_width || grid_y >= grid_height)
		return;

	DMSG("Gridding window in grid of size (%d, %d) pos (%d, %d) window size (%d, %d)\n", grid_width, grid_height, grid_x, grid_y, occ_w, occ_h);
	if (is_special(client)) {
		reset_window(client);
		set_focused(client);
	}

	get_monitor_size(client, &mon_x, &mon_y, &mon_w, &mon_h);

	base_w = (mon_w - conf.gap_left - conf.gap_right - (grid_width - 1) * conf.grid_gap
			- grid_width * 2 * conf.border_width) / grid_width;
	base_h = (mon_h - conf.gap_up - conf.gap_down - (grid_height - 1) * conf.grid_gap
			- grid_height * 2 * conf.border_width) / grid_height;
	/* calculate new window size */
	new_w = base_w * occ_w + (occ_w - 1) * (conf.grid_gap + 2 * conf.border_width);

	new_h = base_h * occ_h + (occ_h - 1) * (conf.grid_gap + 2 * conf.border_width);

	client->orig_geom = client->geom;

	client->geom.width = new_w;
	client->geom.height = new_h;

	client->geom.x = mon_x + conf.gap_left + grid_x
		* (conf.border_width + base_w + conf.border_width + conf.grid_gap);
	client->geom.y = mon_y + conf.gap_up + grid_y
		* (conf.border_width + base_h + conf.border_width + conf.grid_gap);

	client->gridded = true;
	client->grid.gx = grid_width;
	client->grid.gy = grid_height;
	client->grid.px = grid_x;
	client->grid.py = grid_y;
	client->grid.sx = occ_w;
	client->grid.sy = occ_h;

	DMSG("w: %d\th: %d\n", new_w, new_h);

	teleport_window(client->window, client->geom.x, client->geom.y);
	resize_window_absolute(client->window, client->geom.width, client->geom.height);

	xcb_flush(conn);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl %r8d, -0x34(%rbp)
movl %ecx, %eax
movl -0x34(%rbp), %ecx
movl %eax, -0x30(%rbp)
movl %edx, %eax
movl -0x30(%rbp), %edx
movl %eax, -0x2c(%rbp)
movl %esi, %eax
movl -0x2c(%rbp), %esi
movl %eax, -0x28(%rbp)
movq %rdi, %r8
movl -0x28(%rbp), %edi
movw %r9w, %ax
movw 0x10(%rbp), %r9w
movq %r8, -0x8(%rbp)
movw %di, -0xa(%rbp)
movw %si, -0xc(%rbp)
movw %dx, -0xe(%rbp)
movw %cx, -0x10(%rbp)
movw %ax, -0x12(%rbp)
cmpq $0x0, -0x8(%rbp)
je 0x99aa
movzwl -0xe(%rbp), %eax
movzwl -0xa(%rbp), %ecx
cmpl %ecx, %eax
jge 0x99aa
movzwl -0x10(%rbp), %eax
movzwl -0xc(%rbp), %ecx
cmpl %ecx, %eax
jl 0x99af
jmp 0x9c17
movq -0x8(%rbp), %rdi
callq 0x5780
testb $0x1, %al
jne 0x99be
jmp 0x99d0
movq -0x8(%rbp), %rdi
callq 0x57f0
movq -0x8(%rbp), %rdi
callq 0x6a10
movq -0x8(%rbp), %rdi
leaq -0x14(%rbp), %rsi
leaq -0x16(%rbp), %rdx
leaq -0x20(%rbp), %rcx
leaq -0x22(%rbp), %r8
callq 0x5550
movzwl -0x20(%rbp), %eax
movsbl 0x5dcf(%rip), %ecx      # 0xf7c3
subl %ecx, %eax
movsbl 0x5dc9(%rip), %ecx      # 0xf7c6
subl %ecx, %eax
movzwl -0xa(%rbp), %ecx
subl $0x1, %ecx
movsbl 0x5db5(%rip), %edx      # 0xf7c2
imull %edx, %ecx
subl %ecx, %eax
movzwl -0xa(%rbp), %ecx
shll %ecx
movsbl 0x5da1(%rip), %edx      # 0xf7c0
imull %edx, %ecx
subl %ecx, %eax
movzwl -0xa(%rbp), %ecx
cltd
idivl %ecx
movw %ax, -0x18(%rbp)
movzwl -0x22(%rbp), %eax
movsbl 0x5d8b(%rip), %ecx      # 0xf7c5
subl %ecx, %eax
movsbl 0x5d81(%rip), %ecx      # 0xf7c4
subl %ecx, %eax
movzwl -0xc(%rbp), %ecx
subl $0x1, %ecx
movsbl 0x5d6f(%rip), %edx      # 0xf7c2
imull %edx, %ecx
subl %ecx, %eax
movzwl -0xc(%rbp), %ecx
shll %ecx
movsbl 0x5d5b(%rip), %edx      # 0xf7c0
imull %edx, %ecx
subl %ecx, %eax
movzwl -0xc(%rbp), %ecx
cltd
idivl %ecx
movw %ax, -0x1a(%rbp)
movzwl -0x18(%rbp), %eax
movzwl -0x12(%rbp), %ecx
imull %ecx, %eax
movzwl -0x12(%rbp), %ecx
subl $0x1, %ecx
movsbl 0x5d34(%rip), %edx      # 0xf7c2
movsbl 0x5d2b(%rip), %esi      # 0xf7c0
shll %esi
addl %esi, %edx
imull %edx, %ecx
addl %ecx, %eax
movw %ax, -0x1c(%rbp)
movzwl -0x1a(%rbp), %eax
movzwl 0x10(%rbp), %ecx
imull %ecx, %eax
movzwl 0x10(%rbp), %ecx
subl $0x1, %ecx
movsbl 0x5d07(%rip), %edx      # 0xf7c2
movsbl 0x5cfe(%rip), %esi      # 0xf7c0
shll %esi
addl %esi, %edx
imull %edx, %ecx
addl %ecx, %eax
movw %ax, -0x1e(%rbp)
movq -0x8(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x4(%rcx), %rdx
movq %rdx, 0xe(%rax)
movw 0xc(%rcx), %cx
movw %cx, 0x16(%rax)
movw -0x1c(%rbp), %cx
movq -0x8(%rbp), %rax
movw %cx, 0x8(%rax)
movw -0x1e(%rbp), %cx
movq -0x8(%rbp), %rax
movw %cx, 0xa(%rax)
movswl -0x14(%rbp), %eax
movsbl 0x5cb9(%rip), %ecx      # 0xf7c3
addl %ecx, %eax
movzwl -0xe(%rbp), %ecx
movsbl 0x5ca9(%rip), %edx      # 0xf7c0
movzwl -0x18(%rbp), %esi
addl %esi, %edx
movsbl 0x5c9c(%rip), %esi      # 0xf7c0
addl %esi, %edx
movsbl 0x5c95(%rip), %esi      # 0xf7c2
addl %esi, %edx
imull %edx, %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x8(%rbp), %rax
movw %cx, 0x4(%rax)
movswl -0x16(%rbp), %eax
movsbl 0x5c7b(%rip), %ecx      # 0xf7c5
addl %ecx, %eax
movzwl -0x10(%rbp), %ecx
movsbl 0x5c69(%rip), %edx      # 0xf7c0
movzwl -0x1a(%rbp), %esi
addl %esi, %edx
movsbl 0x5c5c(%rip), %esi      # 0xf7c0
addl %esi, %edx
movsbl 0x5c55(%rip), %esi      # 0xf7c2
addl %esi, %edx
imull %edx, %ecx
addl %ecx, %eax
movw %ax, %cx
movq -0x8(%rbp), %rax
movw %cx, 0x6(%rax)
movq -0x8(%rbp), %rax
movb $0x1, 0x28(%rax)
movw -0xa(%rbp), %cx
movq -0x8(%rbp), %rax
movw %cx, 0x18(%rax)
movw -0xc(%rbp), %cx
movq -0x8(%rbp), %rax
movw %cx, 0x1a(%rax)
movw -0xe(%rbp), %cx
movq -0x8(%rbp), %rax
movw %cx, 0x1c(%rax)
movw -0x10(%rbp), %cx
movq -0x8(%rbp), %rax
movw %cx, 0x1e(%rax)
movw -0x12(%rbp), %cx
movq -0x8(%rbp), %rax
movw %cx, 0x20(%rax)
movw 0x10(%rbp), %cx
movq -0x8(%rbp), %rax
movw %cx, 0x22(%rax)
movq -0x8(%rbp), %rax
movl (%rax), %edi
movq -0x8(%rbp), %rax
movw 0x4(%rax), %cx
movq -0x8(%rbp), %rax
movswl %cx, %esi
movswl 0x6(%rax), %edx
callq 0x5460
movq -0x8(%rbp), %rax
movl (%rax), %edi
movq -0x8(%rbp), %rax
movw 0x8(%rax), %cx
movq -0x8(%rbp), %rax
movzwl %cx, %esi
movzwl 0xa(%rax), %edx
callq 0x54e0
movq 0x57c6(%rip), %rdi      # 0xf3d8
callq 0x3400
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax)