// File: /workspace/github_c_makefile_star2_O2/baskerville[P]bspwm/src/events.c
// Function: handle_state
void handle_state(monitor_t *m, desktop_t *d, node_t *n, xcb_atom_t state, unsigned int action)
{
	if (state == ewmh->_NET_WM_STATE_FULLSCREEN) {
		if (action == XCB_EWMH_WM_STATE_ADD && (ignore_ewmh_fullscreen & STATE_TRANSITION_ENTER) == 0) {
			set_state(m, d, n, STATE_FULLSCREEN);
		} else if (action == XCB_EWMH_WM_STATE_REMOVE && (ignore_ewmh_fullscreen & STATE_TRANSITION_EXIT) == 0) {
			if (n->client->state == STATE_FULLSCREEN) {
				set_state(m, d, n, n->client->last_state);
			}
		} else if (action == XCB_EWMH_WM_STATE_TOGGLE) {
			client_state_t next_state = IS_FULLSCREEN(n->client) ? n->client->last_state : STATE_FULLSCREEN;
			if ((next_state == STATE_FULLSCREEN && (ignore_ewmh_fullscreen & STATE_TRANSITION_ENTER) == 0) ||
			    (next_state != STATE_FULLSCREEN && (ignore_ewmh_fullscreen & STATE_TRANSITION_EXIT) == 0)) {
				set_state(m, d, n, next_state);
			}
		}
		arrange(m, d);
	} else if (state == ewmh->_NET_WM_STATE_BELOW) {
		if (action == XCB_EWMH_WM_STATE_ADD) {
			set_layer(m, d, n, LAYER_BELOW);
		} else if (action == XCB_EWMH_WM_STATE_REMOVE) {
			if (n->client->layer == LAYER_BELOW) {
				set_layer(m, d, n, n->client->last_layer);
			}
		} else if (action == XCB_EWMH_WM_STATE_TOGGLE) {
			set_layer(m, d, n, n->client->layer == LAYER_BELOW ? n->client->last_layer : LAYER_BELOW);
		}
	} else if (state == ewmh->_NET_WM_STATE_ABOVE) {
		if (action == XCB_EWMH_WM_STATE_ADD) {
			set_layer(m, d, n, LAYER_ABOVE);
		} else if (action == XCB_EWMH_WM_STATE_REMOVE) {
			if (n->client->layer == LAYER_ABOVE) {
				set_layer(m, d, n, n->client->last_layer);
			}
		} else if (action == XCB_EWMH_WM_STATE_TOGGLE) {
			set_layer(m, d, n, n->client->layer == LAYER_ABOVE ? n->client->last_layer : LAYER_ABOVE);
		}
	} else if (state == ewmh->_NET_WM_STATE_HIDDEN) {
		if (action == XCB_EWMH_WM_STATE_ADD) {
			set_hidden(m, d, n, true);
		} else if (action == XCB_EWMH_WM_STATE_REMOVE) {
			set_hidden(m, d, n, false);
		} else if (action == XCB_EWMH_WM_STATE_TOGGLE) {
			set_hidden(m, d, n, !n->hidden);
		}
	} else if (state == ewmh->_NET_WM_STATE_STICKY) {
		if (action == XCB_EWMH_WM_STATE_ADD) {
			set_sticky(m, d, n, true);
		} else if (action == XCB_EWMH_WM_STATE_REMOVE) {
			set_sticky(m, d, n, false);
		} else if (action == XCB_EWMH_WM_STATE_TOGGLE) {
			set_sticky(m, d, n, !n->sticky);
		}
	} else if (state == ewmh->_NET_WM_STATE_DEMANDS_ATTENTION) {
		if (action == XCB_EWMH_WM_STATE_ADD) {
			set_urgent(m, d, n, true);
		} else if (action == XCB_EWMH_WM_STATE_REMOVE) {
			set_urgent(m, d, n, false);
		} else if (action == XCB_EWMH_WM_STATE_TOGGLE) {
			set_urgent(m, d, n, !n->client->urgent);
		}
#define HANDLE_WM_STATE(s)  \
	} else if (state == ewmh->_NET_WM_STATE_##s) { \
		if (action == XCB_EWMH_WM_STATE_ADD) { \
			n->client->wm_flags |= WM_FLAG_##s; \
		} else if (action == XCB_EWMH_WM_STATE_REMOVE) { \
			n->client->wm_flags &= ~WM_FLAG_##s; \
		} else if (action == XCB_EWMH_WM_STATE_TOGGLE) { \
			n->client->wm_flags ^= WM_FLAG_##s; \
		} \
		ewmh_wm_state_update(n);
	HANDLE_WM_STATE(MODAL)
	HANDLE_WM_STATE(MAXIMIZED_VERT)
	HANDLE_WM_STATE(MAXIMIZED_HORZ)
	HANDLE_WM_STATE(SHADED)
	HANDLE_WM_STATE(SKIP_TASKBAR)
	HANDLE_WM_STATE(SKIP_PAGER)
	}
#undef HANDLE_WM_STATE
}

// Assembly:
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x1b263(%rip), %rax     # 0x28e30
movq (%rax), %rax
cmpl %ecx, 0x128(%rax)
jne 0xdbf6
testl %r8d, %r8d
je 0xdc8a
cmpl $0x2, %r8d
je 0xdc56
cmpl $0x1, %r8d
je 0xdc72
jmp 0xdd68
cmpl %ecx, 0x130(%rax)
jne 0xdc28
testl %r8d, %r8d
je 0xdcfb
cmpl $0x2, %r8d
je 0xdce3
cmpl $0x1, %r8d
jne 0xdfc8
movq %r14, %rdi
movq %rbx, %rsi
xorl %ecx, %ecx
jmp 0xdd97
cmpl %ecx, 0x12c(%rax)
jne 0xdcb6
testl %r8d, %r8d
je 0xdd7a
cmpl $0x2, %r8d
je 0xdd3f
cmpl $0x1, %r8d
je 0xdd4c
jmp 0xdfc8
movq 0x48(%rdx), %rax
cmpl $0x3, 0x308(%rax)
jne 0xdc72
movl 0x30c(%rax), %ecx
cmpl $0x3, %ecx
jne 0xdd51
leaq 0x1b187(%rip), %rax     # 0x28e00
testb $0x1, (%rax)
jne 0xdd68
pushq $0x3
popq %rcx
jmp 0xdd5d
leaq 0x1b16f(%rip), %rax     # 0x28e00
testb $0x2, (%rax)
jne 0xdd68
movq 0x48(%rdx), %rax
cmpl $0x3, 0x308(%rax)
jne 0xdd68
movl 0x30c(%rax), %ecx
jmp 0xdd5d
cmpl %ecx, 0x124(%rax)
jne 0xdd0e
testl %r8d, %r8d
je 0xdddf
cmpl $0x2, %r8d
je 0xddd0
cmpl $0x1, %r8d
jne 0xdfc8
pushq $0x1
popq %rcx
jmp 0xddd7
movq 0x48(%rdx), %rax
xorl %ecx, %ecx
cmpl $0x0, 0x310(%rax)
jne 0xdd91
jmp 0xdd8b
movq 0x48(%rdx), %rax
cmpl $0x0, 0x310(%rax)
jne 0xdfc8
jmp 0xdd8b
cmpl %ecx, 0x10c(%rax)
jne 0xdda3
testl %r8d, %r8d
je 0xde37
cmpl $0x2, %r8d
je 0xde28
cmpl $0x1, %r8d
jne 0xdfc8
pushq $0x1
popq %rcx
jmp 0xde2f
movq 0x48(%rdx), %rax
cmpl $0x2, 0x310(%rax)
je 0xdd8b
pushq $0x2
popq %rcx
jmp 0xdd91
leaq 0x1b0a8(%rip), %rax     # 0x28e00
testb $0x2, (%rax)
jne 0xdd68
movq %r14, %rdi
movq %rbx, %rsi
callq 0xbd28
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x8670
movq 0x48(%rdx), %rax
cmpl $0x2, 0x310(%rax)
jne 0xdfc8
movl 0x314(%rax), %ecx
movq %r14, %rdi
movq %rbx, %rsi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xbc3d
cmpl %ecx, 0x134(%rax)
jne 0xddf3
testl %r8d, %r8d
je 0xde96
cmpl $0x2, %r8d
je 0xde80
cmpl $0x1, %r8d
jne 0xdfc8
pushq $0x1
popq %rcx
jmp 0xde8e
movzbl 0x25(%rdx), %ecx
xorl $0x1, %ecx
movq %r14, %rdi
movq %rbx, %rsi
jmp 0xdde7
movq %r14, %rdi
movq %rbx, %rsi
xorl %ecx, %ecx
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xc0c5
cmpl %ecx, 0x108(%rax)
jne 0xde4b
testl %r8d, %r8d
je 0xdeef
cmpl $0x2, %r8d
je 0xdedf
cmpl $0x1, %r8d
jne 0xe01c
movq 0x48(%rdx), %rax
orl $0x1, 0x378(%rax)
jmp 0xe01c
movzbl 0x26(%rdx), %ecx
xorl $0x1, %ecx
movq %r14, %rdi
movq %rbx, %rsi
jmp 0xde3f
movq %r14, %rdi
movq %rbx, %rsi
xorl %ecx, %ecx
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xc2b8
cmpl %ecx, 0x110(%rax)
jne 0xdeaa
testl %r8d, %r8d
je 0xdf44
cmpl $0x2, %r8d
je 0xdf34
cmpl $0x1, %r8d
jne 0xe01c
movq 0x48(%rdx), %rax
orl $0x4, 0x378(%rax)
jmp 0xe01c
movq 0x48(%rdx), %rax
movzbl 0x304(%rax), %ecx
xorl $0x1, %ecx
movq %r14, %rdi
movq %rbx, %rsi
jmp 0xde9e
movq %r14, %rdi
movq %rbx, %rsi
xorl %ecx, %ecx
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0xa072
cmpl %ecx, 0x114(%rax)
jne 0xdeff
testl %r8d, %r8d
je 0xdf95
cmpl $0x2, %r8d
je 0xdf85
cmpl $0x1, %r8d
jne 0xe01c
movq 0x48(%rdx), %rax
orl $0x8, 0x378(%rax)
jmp 0xe01c
movq 0x48(%rdx), %rax
xorl $0x1, 0x378(%rax)
jmp 0xe01c
movq 0x48(%rdx), %rax
andl $-0x2, 0x378(%rax)
jmp 0xe01c
cmpl %ecx, 0x118(%rax)
jne 0xdf54
testl %r8d, %r8d
je 0xdfdd
cmpl $0x2, %r8d
je 0xdfd0
cmpl $0x1, %r8d
jne 0xe01c
movq 0x48(%rdx), %rax
orl $0x10, 0x378(%rax)
jmp 0xe01c
movq 0x48(%rdx), %rax
xorl $0x4, 0x378(%rax)
jmp 0xe01c
movq 0x48(%rdx), %rax
andl $-0x5, 0x378(%rax)
jmp 0xe01c
cmpl %ecx, 0x11c(%rax)
jne 0xdfa2
testl %r8d, %r8d
je 0xdff7
cmpl $0x2, %r8d
je 0xdfea
cmpl $0x1, %r8d
jne 0xe01c
movq 0x48(%rdx), %rax
orl $0x20, 0x378(%rax)
jmp 0xe01c
movq 0x48(%rdx), %rax
xorl $0x8, 0x378(%rax)
jmp 0xe01c
movq 0x48(%rdx), %rax
andl $-0x9, 0x378(%rax)
jmp 0xe01c
cmpl %ecx, 0x120(%rax)
jne 0xdfc8
testl %r8d, %r8d
je 0xe011
cmpl $0x2, %r8d
je 0xe004
cmpl $0x1, %r8d
jne 0xe01c
movq 0x48(%rdx), %rax
orl $0x40, 0x378(%rax)
jmp 0xe01c
addq $0x8, %rsp
popq %rbx
popq %r14
retq
movq 0x48(%rdx), %rax
xorl $0x10, 0x378(%rax)
jmp 0xe01c
movq 0x48(%rdx), %rax
andl $-0x11, 0x378(%rax)
jmp 0xe01c
movq 0x48(%rdx), %rax
xorl $0x20, 0x378(%rax)
jmp 0xe01c
movq 0x48(%rdx), %rax
andl $-0x21, 0x378(%rax)
jmp 0xe01c
movq 0x48(%rdx), %rax
xorl $0x40, 0x378(%rax)
jmp 0xe01c
movq 0x48(%rdx), %rax
andl $-0x41, 0x378(%rax)
movq %rdx, %rdi
addq $0x8, %rsp
popq %rbx
popq %r14
jmp 0x1cbb9
nop