// File: /workspace/github_c_makefile_star2_O3/tudurom[P]windowchef/wm.c
// Function: handle_wm_state
static void
handle_wm_state(struct client *client, xcb_atom_t state, unsigned int action)
{
	int16_t mon_x, mon_y;
	uint16_t mon_w, mon_h;

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

	if (state == ewmh->_NET_WM_STATE_FULLSCREEN) {
		if (action == XCB_EWMH_WM_STATE_ADD) {
			maximize_window(client, mon_x, mon_y, mon_w, mon_h);
		} else if (action == XCB_EWMH_WM_STATE_REMOVE && client->maxed) {
			reset_window(client);
			set_focused(client);
		} else if (action == XCB_EWMH_WM_STATE_TOGGLE) {
			if (client->maxed) {
				reset_window(client);
				set_focused(client);
			} else {
				maximize_window(client, mon_x, mon_y, mon_w, mon_h);
			}
		}
	} else if (state == ewmh->_NET_WM_STATE_MAXIMIZED_VERT) {
		if (action == XCB_EWMH_WM_STATE_ADD) {
			vmaximize_window(client, mon_y, mon_h);
		} else if (action == XCB_EWMH_WM_STATE_REMOVE) {
			if (client->vmaxed)
				reset_window(client);
		} else if (action == XCB_EWMH_WM_STATE_TOGGLE) {
			if (client->vmaxed)
				reset_window(client);
			else
				vmaximize_window(client, mon_y, mon_h);
		}
	} else if (state == ewmh->_NET_WM_STATE_MAXIMIZED_HORZ) {
		if (action == XCB_EWMH_WM_STATE_ADD) {
			hmaximize_window(client, mon_y, mon_h);
		} else if (action == XCB_EWMH_WM_STATE_REMOVE) {
			if (client->hmaxed)
				reset_window(client);
		} else if (action == XCB_EWMH_WM_STATE_TOGGLE) {
			if (client->hmaxed)
				reset_window(client);
			else
				hmaximize_window(client, mon_x, mon_w);
		}
	}
}

// Assembly:
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
testq %rdi, %rdi
je 0x5d8a
movq 0x40(%rbx), %rdi
testq %rdi, %rdi
je 0x5d8a
movzwl 0x10(%rdi), %ecx
movzwl 0x12(%rdi), %eax
jmp 0x5d95
movq 0x6a47(%rip), %rdi      # 0xc7d8
xorl %eax, %eax
xorl %ecx, %ecx
movzwl 0x14(%rdi), %r8d
movzwl 0x16(%rdi), %edi
movq 0x661b(%rip), %r9       # 0xc3c0
cmpl %esi, 0x128(%r9)
jne 0x5dc5
testl %edx, %edx
je 0x5e55
cmpl $0x2, %edx
je 0x5e1b
cmpl $0x1, %edx
je 0x5e3a
jmp 0x5e89
cmpl %esi, 0x110(%r9)
jne 0x5ded
testl %edx, %edx
je 0x5ea5
cmpl $0x2, %edx
je 0x5e8f
cmpl $0x1, %edx
jne 0x5e89
jmp 0x5e95
cmpl %esi, 0x114(%r9)
jne 0x5e89
testl %edx, %edx
je 0x5ec7
cmpl $0x2, %edx
je 0x5ead
cmpl $0x1, %edx
jne 0x5e89
movswl %ax, %esi
movzwl %di, %edx
jmp 0x5eba
cmpb $0x1, 0x24(%rbx)
jne 0x5e3a
movq %rbx, %rdi
callq 0x4f0a
movq %rbx, %rdi
callq 0x4f9e
movl (%rbx), %esi
leaq 0xc(%rsp), %rcx
jmp 0x5e72
movswl %cx, %esi
movswl %ax, %edx
movzwl %r8w, %ecx
movzwl %di, %r8d
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
jmp 0x4e27
cmpb $0x1, 0x24(%rbx)
jne 0x5e89
movq %rbx, %rdi
callq 0x4f0a
movq %rbx, %rdi
callq 0x4f9e
movl (%rbx), %esi
leaq 0x8(%rsp), %rcx
movl $0x0, (%rcx)
movq 0x6539(%rip), %rdi      # 0xc3b8
movl $0x40, %edx
callq 0x3200
addq $0x10, %rsp
popq %rbx
retq
cmpb $0x1, 0x26(%rbx)
je 0x5ecd
movswl %ax, %esi
movzwl %di, %edx
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
jmp 0x5eda
cmpb $0x1, 0x26(%rbx)
jne 0x5e89
jmp 0x5ecd
cmpb $0x1, 0x25(%rbx)
je 0x5ecd
movswl %cx, %esi
movzwl %r8w, %edx
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
jmp 0x5f8d
cmpb $0x1, 0x25(%rbx)
jne 0x5e89
movq %rbx, %rdi
addq $0x10, %rsp
popq %rbx
jmp 0x4f0a