// File: /workspace/github_c_makefile_star2_O1/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 0xc673
movq %rdx, %r15
movq 0x48(%rdx), %r13
testq %r13, %r13
je 0xc673
movl 0x308(%r13), %r12d
cmpl %ecx, %r12d
jne 0xc686
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 0xc6b8
cmpl $0x2, %r12d
jne 0xc6c8
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0xc855
jmp 0xc6c8
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0xc8c1
movl 0x20(%r14), %edx
movl 0x20(%rbx), %ecx
movl (%r15), %r8d
movl 0x30c(%r13), %eax
testl %eax, %eax
je 0xc6eb
cmpl $0x2, %eax
jne 0xc6f4
leaq 0x14609(%rip), %r9      # 0x20cf2
jmp 0xc709
leaq 0x145af(%rip), %r9      # 0x20ca1
jmp 0xc709
cmpl $0x3, %eax
leaq 0x145fe(%rip), %rax     # 0x20cfc
leaq 0x145df(%rip), %r9      # 0x20ce4
cmoveq %rax, %r9
leaq 0x13121(%rip), %rsi     # 0x1f831
movl $0x1000000, %edi        # imm = 0x1000000
xorl %eax, %eax
callq 0x1eb0b
movl 0x308(%r13), %eax
cmpl $0x3, %eax
je 0xc742
cmpl $0x2, %eax
jne 0xc755
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movl $0x1, %ecx
callq 0xc855
jmp 0xc755
movq %r14, %rdi
movq %rbx, %rsi
movq %r15, %rdx
movl $0x1, %ecx
callq 0xc8c1
movl 0x20(%r14), %edx
movl 0x20(%rbx), %ecx
movl (%r15), %r8d
movl 0x308(%r13), %eax
testl %eax, %eax
je 0xc778
cmpl $0x2, %eax
jne 0xc781
leaq 0x1457c(%rip), %r9      # 0x20cf2
jmp 0xc796
leaq 0x14522(%rip), %r9      # 0x20ca1
jmp 0xc796
cmpl $0x3, %eax
leaq 0x14571(%rip), %rax     # 0x20cfc
leaq 0x14552(%rip), %r9      # 0x20ce4
cmoveq %rax, %r9
leaq 0x130bc(%rip), %rsi     # 0x1f859
movl $0x1000000, %edi        # imm = 0x1000000
xorl %eax, %eax
callq 0x1eb0b
movq 0x58(%r14), %rax
cmpq %r15, 0x38(%rax)
jne 0xc7bf
movl $0x1, %edi
xorl %eax, %eax
callq 0x1eb0b
leaq 0x1d632(%rip), %rax     # 0x29df8
movb $0x1, %bpl
cmpb $0x1, (%rax)
jne 0xc675
cmpl $0x2, 0x308(%r13)
setb %al
cmpl $0x2, %r12d
setae %cl
xorb %al, %cl
jne 0xc675
cmpl $0x1, %r12d
ja 0xc81b
cmpl $0x1, 0x24(%rbx)
je 0xc811
movq 0x30(%rbx), %rdi
movl $0x1, %r15d
movl $0x1, %esi
callq 0x98c5
cmpl $0x2, %eax
jl 0xc840
cmpl $0x2, %r12d
jb 0xc675
cmpl $0x1, 0x24(%rbx)
jne 0xc675
movq 0x30(%rbx), %rdi
movl $0x1, %esi
callq 0x98c5
cmpl $0x2, %eax
jl 0xc675
movl 0x28(%rbx), %r15d
movq %r14, %rdi
movq %rbx, %rsi
movl %r15d, %edx
xorl %ecx, %ecx
callq 0x7ec3
jmp 0xc675