// File: /workspace/github_c_makefile_star2_O1/baskerville[P]bspwm/src/restore.c
// Function: restore_monitor
monitor_t *restore_monitor(jsmntok_t **t, char *json)
{
	int num = (*t)->size;
	(*t)++;
	monitor_t *m = make_monitor(NULL, NULL, UINT32_MAX);
	uint32_t focused_desktop_id = 0;

	for (int i = 0; i < num; i++) {
		if (keyeq("name", *t, json)) {
			(*t)++;
			snprintf(m->name, (*t)->end - (*t)->start + 1, "%s", json + (*t)->start);
		RESTORE_UINT(id, &m->id)
		RESTORE_UINT(randrId, &m->randr_id)
		RESTORE_BOOL(wired, &m->wired)
		RESTORE_UINT(stickyCount, &m->sticky_count)
		RESTORE_INT(windowGap, &m->window_gap)
		RESTORE_UINT(borderWidth, &m->border_width)
		RESTORE_UINT(focusedDesktopId, &focused_desktop_id)
		} else if (keyeq("padding", *t, json)) {
			(*t)++;
			restore_padding(&m->padding, t, json);
			continue;
		} else if (keyeq("rectangle", *t, json)) {
			(*t)++;
			restore_rectangle(&m->rectangle, t, json);
			update_root(m, &m->rectangle);
			continue;
		} else if (keyeq("desktops", *t, json)) {
			(*t)++;
			int s = (*t)->size;
			(*t)++;
			for (int j = 0; j < s; j++) {
				desktop_t *d = restore_desktop(t, json);
				add_desktop(m, d);
			}
			continue;
		} else {
			warn("Restore monitor: unknown key: '%.*s'.\n", (*t)->end - (*t)->start, json + (*t)->start);
			(*t)++;
		}
		(*t)++;
	}

	if (focused_desktop_id != 0) {
		for (desktop_t *d = m->desk_head; d != NULL; d = d->next) {
			if (d->id == focused_desktop_id) {
				m->desk = d;
				break;
			}
		}
	}

	return m;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rsi, %r14
movq %rdi, %r15
movq (%rdi), %rax
movl 0xc(%rax), %r13d
addq $0x10, %rax
movq %rax, (%rdi)
xorl %edi, %edi
xorl %esi, %esi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0x6b68
movq %rax, %rbx
movl $0x0, 0x4(%rsp)
testl %r13d, %r13d
jle 0x1ba32
leaq 0x4c(%rbx), %rax
movq %rax, 0x8(%rsp)
leaq 0x30(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x48(%rbx), %rax
movq %rax, 0x18(%rsp)
leaq 0x44(%rbx), %rax
movq %rax, 0x20(%rsp)
leaq 0x40(%rbx), %rax
movq %rax, 0x28(%rsp)
leaq 0x2c(%rbx), %rax
movq %rax, 0x30(%rsp)
leaq 0x24(%rbx), %rax
movq %rax, 0x38(%rsp)
movq %rbx, %rax
addq $0x20, %rax
movq %rax, 0x40(%rsp)
xorl %ebp, %ebp
movq (%r15), %r12
leaq 0x48fa(%rip), %rdi      # 0x20056
movq %r12, %rsi
movq %r14, %rdx
callq 0x1b678
testb %al, %al
je 0x1b79a
leaq 0x10(%r12), %rax
movq %rax, (%r15)
movl 0x18(%r12), %eax
movslq 0x14(%r12), %rcx
subl %ecx, %eax
incl %eax
movslq %eax, %rsi
addq %r14, %rcx
movq %rbx, %rdi
leaq 0x38b6(%rip), %rdx      # 0x1f047
xorl %eax, %eax
callq 0x4110
jmp 0x1b807
leaq 0x5c16(%rip), %rdi      # 0x213b7
movq %r12, %rsi
movq %r14, %rdx
callq 0x1b678
testb %al, %al
je 0x1b7ce
leaq 0x10(%r12), %rax
movq %rax, (%r15)
movslq 0x14(%r12), %rdi
addq %r14, %rdi
leaq 0x4e54(%rip), %rsi      # 0x2061b
movq 0x40(%rsp), %rdx
jmp 0x1b800
leaq 0x5be5(%rip), %rdi      # 0x213ba
movq %r12, %rsi
movq %r14, %rdx
callq 0x1b678
testb %al, %al
je 0x1b81b
leaq 0x10(%r12), %rax
movq %rax, (%r15)
movslq 0x14(%r12), %rdi
addq %r14, %rdi
leaq 0x4e20(%rip), %rsi      # 0x2061b
movq 0x38(%rsp), %rdx
xorl %eax, %eax
callq 0x41c0
addq $0x10, (%r15)
incl %ebp
cmpl %r13d, %ebp
jne 0x1b752
jmp 0x1ba32
leaq 0x5ba0(%rip), %rdi      # 0x213c2
movq %r12, %rsi
movq %r14, %rdx
callq 0x1b678
testb %al, %al
je 0x1b869
leaq 0x10(%r12), %rax
movq %rax, (%r15)
movslq 0x14(%r12), %rax
leaq (%r14,%rax), %rdi
movslq 0x18(%r12), %rsi
subq %rax, %rsi
callq 0x5e6e
movq %rax, %r12
movq %rax, %rdi
movq 0x30(%rsp), %rsi
callq 0x169bc
movq %r12, %rdi
callq 0x4460
jmp 0x1b807
leaq 0x5b58(%rip), %rdi      # 0x213c8
movq %r12, %rsi
movq %r14, %rdx
callq 0x1b678
testb %al, %al
je 0x1b8a0
leaq 0x10(%r12), %rax
movq %rax, (%r15)
movslq 0x14(%r12), %rdi
addq %r14, %rdi
leaq 0x4d85(%rip), %rsi      # 0x2061b
movq 0x28(%rsp), %rdx
jmp 0x1b800
leaq 0x5b2d(%rip), %rdi      # 0x213d4
movq %r12, %rsi
movq %r14, %rdx
callq 0x1b678
testb %al, %al
je 0x1b8d7
leaq 0x10(%r12), %rax
movq %rax, (%r15)
movslq 0x14(%r12), %rdi
addq %r14, %rdi
leaq 0x589e(%rip), %rsi      # 0x2116b
movq 0x20(%rsp), %rdx
jmp 0x1b800
leaq 0x5b00(%rip), %rdi      # 0x213de
movq %r12, %rsi
movq %r14, %rdx
callq 0x1b678
testb %al, %al
je 0x1b90e
leaq 0x10(%r12), %rax
movq %rax, (%r15)
movslq 0x14(%r12), %rdi
addq %r14, %rdi
leaq 0x4d17(%rip), %rsi      # 0x2061b
movq 0x18(%rsp), %rdx
jmp 0x1b800
leaq 0x5ad5(%rip), %rdi      # 0x213ea
movq %r12, %rsi
movq %r14, %rdx
callq 0x1b678
testb %al, %al
je 0x1b945
leaq 0x10(%r12), %rax
movq %rax, (%r15)
movslq 0x14(%r12), %rdi
addq %r14, %rdi
leaq 0x4ce0(%rip), %rsi      # 0x2061b
leaq 0x4(%rsp), %rdx
jmp 0x1b800
leaq 0x4d7f(%rip), %rdi      # 0x206cb
movq %r12, %rsi
movq %r14, %rdx
callq 0x1b678
testb %al, %al
je 0x1b977
addq $0x10, %r12
movq %r12, (%r15)
movq 0x10(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1bbbb
jmp 0x1b80b
leaq 0x47ee(%rip), %rdi      # 0x2016c
movq %r12, %rsi
movq %r14, %rdx
callq 0x1b678
testb %al, %al
je 0x1b9b7
addq $0x10, %r12
movq %r12, (%r15)
movq 0x8(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1bcf2
movq %rbx, %rdi
movq %r12, %rsi
callq 0x6c4e
jmp 0x1b80b
leaq 0x4839(%rip), %rdi      # 0x201f7
movq %r12, %rsi
movq %r14, %rdx
callq 0x1b678
testb %al, %al
je 0x1ba0c
leaq 0x10(%r12), %rax
movq %rax, (%r15)
movl 0x1c(%r12), %eax
addq $0x20, %r12
movq %r12, (%r15)
testl %eax, %eax
jle 0x1b80b
movl %eax, %r12d
movq %r15, %rdi
movq %r14, %rsi
callq 0x1be29
movq %rbx, %rdi
movq %rax, %rsi
callq 0x8389
decl %r12d
jne 0x1b9ec
jmp 0x1b80b
movl 0x8(%r12), %esi
movslq 0x4(%r12), %rdx
subl %edx, %esi
addq %r14, %rdx
leaq 0x59d9(%rip), %rdi      # 0x213fb
xorl %eax, %eax
callq 0x4b50
addq $0x10, (%r15)
jmp 0x1b807
movl 0x4(%rsp), %eax
testl %eax, %eax
je 0x1ba52
movq 0x60(%rbx), %rcx
testq %rcx, %rcx
je 0x1ba52
cmpl %eax, 0x20(%rcx)
je 0x1ba4e
movq 0x48(%rcx), %rcx
jmp 0x1ba3e
movq %rcx, 0x58(%rbx)
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq