// File: /workspace/github_c_makefile_star2_O2/baskerville[P]bspwm/src/tree.c
// Function: set_state
bool set_state(monitor_t *m, desktop_t *d, node_t *n, client_state_t s)
{
	if (n == NULL || n->client == NULL || n->client->state == s) {
		return false;
	}

	client_t *c = n->client;

	bool was_tiled = IS_TILED(c);

	c->last_state = c->state;
	c->state = s;

	switch (c->last_state) {
		case STATE_TILED:
		case STATE_PSEUDO_TILED:
			break;
		case STATE_FLOATING:
			set_floating(m, d, n, false);
			break;
		case STATE_FULLSCREEN:
			set_fullscreen(m, d, n, false);
			break;
	}

	put_status(SBSC_MASK_NODE_STATE, "node_state 0x%08X 0x%08X 0x%08X %s off\n", m->id, d->id, n->id, STATE_STR(c->last_state));

	switch (c->state) {
		case STATE_TILED:
		case STATE_PSEUDO_TILED:
			break;
		case STATE_FLOATING:
			set_floating(m, d, n, true);
			break;
		case STATE_FULLSCREEN:
			set_fullscreen(m, d, n, true);
			break;
	}

	put_status(SBSC_MASK_NODE_STATE, "node_state 0x%08X 0x%08X 0x%08X %s on\n", m->id, d->id, n->id, STATE_STR(c->state));

	if (n == m->desk->focus) {
		put_status(SBSC_MASK_REPORT);
	}

	if (single_monocle && was_tiled != IS_TILED(c)) {
		if (was_tiled && d->layout != LAYOUT_MONOCLE && tiled_count(d->root, true) <= 1) {
			set_layout(m, d, LAYOUT_MONOCLE, false);
		} else if (!was_tiled && d->layout == LAYOUT_MONOCLE && tiled_count(d->root, true) > 1) {
			set_layout(m, d, d->user_layout, false);
		}
	}

	return true;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testq %rdx, %rdx
je 0xbd50
movq %rdx, %r15
movq 0x48(%rdx), %r13
testq %r13, %r13
je 0xbd50
movl 0x308(%r13), %r12d
cmpl %ecx, %r12d
jne 0xbd63
xorl %ebp, %ebp
movl %ebp, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rsi, %rbx
movq %rdi, %r14
movl %r12d, 0x30c(%r13)
movl %ecx, 0x308(%r13)
cmpl $0x3, %r12d
je 0xbd98
movl %r12d, %eax
cmpl $0x2, %r12d
jne 0xbdaf
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0xbf2a
jmp 0xbda8
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0xbf96
movl 0x30c(%r13), %eax
movl 0x20(%r14), %edx
movl 0x20(%rbx), %ecx
movl (%r15), %r8d
testl %eax, %eax
je 0xbdcb
cmpl $0x2, %eax
jne 0xbdd4
leaq 0x13edd(%rip), %r9      # 0x1fca6
jmp 0xbde9
leaq 0x13e83(%rip), %r9      # 0x1fc55
jmp 0xbde9
cmpl $0x3, %eax
leaq 0x13ed2(%rip), %rax     # 0x1fcb0
leaq 0x13eb3(%rip), %r9      # 0x1fc98
cmoveq %rax, %r9
leaq 0x12a31(%rip), %rsi     # 0x1e821
movl $0x1000000, %edi        # imm = 0x1000000
xorl %eax, %eax
callq 0x1d07d
movl 0x308(%r13), %eax
cmpl $0x3, %eax
je 0xbe20
cmpl $0x2, %eax
jne 0xbe38
pushq $0x1
popq %rcx
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xbf2a
jmp 0xbe31
pushq $0x1
popq %rcx
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0xbf96
movl 0x308(%r13), %eax
movl 0x20(%r14), %edx
movl 0x20(%rbx), %ecx
movl (%r15), %r8d
testl %eax, %eax
je 0xbe54
cmpl $0x2, %eax
jne 0xbe5d
leaq 0x13e54(%rip), %r9      # 0x1fca6
jmp 0xbe72
leaq 0x13dfa(%rip), %r9      # 0x1fc55
jmp 0xbe72
cmpl $0x3, %eax
leaq 0x13e49(%rip), %rax     # 0x1fcb0
leaq 0x13e2a(%rip), %r9      # 0x1fc98
cmoveq %rax, %r9
leaq 0x129d0(%rip), %rsi     # 0x1e849
movl $0x1000000, %edi        # imm = 0x1000000
xorl %eax, %eax
callq 0x1d07d
movq 0x58(%r14), %rax
cmpq %r15, 0x38(%rax)
jne 0xbe99
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x1d07d
leaq 0x1cf58(%rip), %rax     # 0x28df8
movb $0x1, %bpl
cmpb $0x1, (%rax)
jne 0xbd52
cmpl $0x2, 0x308(%r13)
setb %al
cmpl $0x2, %r12d
setae %cl
xorb %al, %cl
jne 0xbd52
movl 0x24(%rbx), %eax
cmpl $0x1, %r12d
ja 0xbef3
cmpl $0x1, %eax
je 0xbd52
pushq $0x1
popq %r15
movq 0x30(%rbx), %rdi
movl %r15d, %esi
callq 0x93c6
cmpl $0x2, %eax
jge 0xbd52
jmp 0xbf15
cmpl $0x1, %eax
jne 0xbd52
movq 0x30(%rbx), %rdi
pushq $0x1
popq %rsi
callq 0x93c6
cmpl $0x2, %eax
jl 0xbd52
movl 0x28(%rbx), %r15d
movq %r14, %rdi
movq %rbx, %rsi
movl %r15d, %edx
xorl %ecx, %ecx
callq 0x7b4b
jmp 0xbd52