// File: /workspace/github_c_makefile_star2_O3/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 0xc733
movq %rdx, %r15
movq 0x48(%rdx), %r13
testq %r13, %r13
je 0xc733
movl 0x308(%r13), %r12d
cmpl %ecx, %r12d
jne 0xc746
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 0xc77b
movl %r12d, %eax
cmpl $0x2, %r12d
jne 0xc792
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0xc919
jmp 0xc78b
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0xc985
movl 0x30c(%r13), %eax
movl 0x20(%r14), %edx
movl 0x20(%rbx), %ecx
movl (%r15), %r8d
testl %eax, %eax
je 0xc7ae
cmpl $0x2, %eax
jne 0xc7b7
leaq 0x144fa(%rip), %r9      # 0x20ca6
jmp 0xc7cc
leaq 0x144a0(%rip), %r9      # 0x20c55
jmp 0xc7cc
cmpl $0x3, %eax
leaq 0x144ef(%rip), %rax     # 0x20cb0
leaq 0x144d0(%rip), %r9      # 0x20c98
cmoveq %rax, %r9
leaq 0x1304e(%rip), %rsi     # 0x1f821
movl $0x1000000, %edi        # imm = 0x1000000
xorl %eax, %eax
callq 0x1e6b8
movl 0x308(%r13), %eax
cmpl $0x3, %eax
je 0xc805
cmpl $0x2, %eax
jne 0xc81f
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movl $0x1, %ecx
callq 0xc919
jmp 0xc818
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movl $0x1, %ecx
callq 0xc985
movl 0x308(%r13), %eax
movl 0x20(%r14), %edx
movl 0x20(%rbx), %ecx
movl (%r15), %r8d
testl %eax, %eax
je 0xc83b
cmpl $0x2, %eax
jne 0xc844
leaq 0x1446d(%rip), %r9      # 0x20ca6
jmp 0xc859
leaq 0x14413(%rip), %r9      # 0x20c55
jmp 0xc859
cmpl $0x3, %eax
leaq 0x14462(%rip), %rax     # 0x20cb0
leaq 0x14443(%rip), %r9      # 0x20c98
cmoveq %rax, %r9
leaq 0x12fe9(%rip), %rsi     # 0x1f849
movl $0x1000000, %edi        # imm = 0x1000000
xorl %eax, %eax
callq 0x1e6b8
movq 0x58(%r14), %rax
cmpq %r15, 0x38(%rax)
jne 0xc882
movl $0x1, %edi
xorl %eax, %eax
callq 0x1e6b8
leaq 0x1d56f(%rip), %rax     # 0x29df8
movb $0x1, %bpl
cmpb $0x1, (%rax)
jne 0xc735
cmpl $0x2, 0x308(%r13)
setb %al
cmpl $0x2, %r12d
setae %cl
xorb %al, %cl
jne 0xc735
movl 0x24(%rbx), %eax
cmpl $0x1, %r12d
ja 0xc8e0
cmpl $0x1, %eax
je 0xc735
movq 0x30(%rbx), %rdi
movl $0x1, %r15d
movl $0x1, %esi
callq 0x97a3
cmpl $0x2, %eax
jge 0xc735
jmp 0xc904
cmpl $0x1, %eax
jne 0xc735
movq 0x30(%rbx), %rdi
movl $0x1, %esi
callq 0x97a3
cmpl $0x2, %eax
jl 0xc735
movl 0x28(%rbx), %r15d
movq %r14, %rdi
movq %rbx, %rsi
movl %r15d, %edx
xorl %ecx, %ecx
callq 0x7d6e
jmp 0xc735