// File: /workspace/github_c_makefile_star2_O3/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 0x6a8c
movq %rax, %rbx
movl $0x0, 0x4(%rsp)
testl %r13d, %r13d
jle 0x1b784
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 0x4b7d(%rip), %rdi      # 0x20013
movq %r12, %rsi
movq %r14, %rdx
callq 0x1b3b2
testb %al, %al
je 0x1b4d4
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 0x3b7c(%rip), %rdx      # 0x1f047
xorl %eax, %eax
callq 0x4110
jmp 0x1b541
leaq 0x5e90(%rip), %rdi      # 0x2136b
movq %r12, %rsi
movq %r14, %rdx
callq 0x1b3b2
testb %al, %al
je 0x1b508
leaq 0x10(%r12), %rax
movq %rax, (%r15)
movslq 0x14(%r12), %rdi
addq %r14, %rdi
leaq 0x50ce(%rip), %rsi      # 0x205cf
movq 0x40(%rsp), %rdx
jmp 0x1b53a
leaq 0x5e5f(%rip), %rdi      # 0x2136e
movq %r12, %rsi
movq %r14, %rdx
callq 0x1b3b2
testb %al, %al
je 0x1b555
leaq 0x10(%r12), %rax
movq %rax, (%r15)
movslq 0x14(%r12), %rdi
addq %r14, %rdi
leaq 0x509a(%rip), %rsi      # 0x205cf
movq 0x38(%rsp), %rdx
xorl %eax, %eax
callq 0x41c0
addq $0x10, (%r15)
incl %ebp
cmpl %r13d, %ebp
jne 0x1b48c
jmp 0x1b764
leaq 0x5e1a(%rip), %rdi      # 0x21376
movq %r12, %rsi
movq %r14, %rdx
callq 0x1b3b2
testb %al, %al
je 0x1b5a3
leaq 0x10(%r12), %rax
movq %rax, (%r15)
movslq 0x14(%r12), %rax
leaq (%r14,%rax), %rdi
movslq 0x18(%r12), %rsi
subq %rax, %rsi
callq 0x5e2f
movq %rax, %r12
movq %rax, %rdi
movq 0x30(%rsp), %rsi
callq 0x16884
movq %r12, %rdi
callq 0x4460
jmp 0x1b541
leaq 0x5dd2(%rip), %rdi      # 0x2137c
movq %r12, %rsi
movq %r14, %rdx
callq 0x1b3b2
testb %al, %al
je 0x1b5da
leaq 0x10(%r12), %rax
movq %rax, (%r15)
movslq 0x14(%r12), %rdi
addq %r14, %rdi
leaq 0x4fff(%rip), %rsi      # 0x205cf
movq 0x28(%rsp), %rdx
jmp 0x1b53a
leaq 0x5da7(%rip), %rdi      # 0x21388
movq %r12, %rsi
movq %r14, %rdx
callq 0x1b3b2
testb %al, %al
je 0x1b611
leaq 0x10(%r12), %rax
movq %rax, (%r15)
movslq 0x14(%r12), %rdi
addq %r14, %rdi
leaq 0x5b18(%rip), %rsi      # 0x2111f
movq 0x20(%rsp), %rdx
jmp 0x1b53a
leaq 0x5d7a(%rip), %rdi      # 0x21392
movq %r12, %rsi
movq %r14, %rdx
callq 0x1b3b2
testb %al, %al
je 0x1b648
leaq 0x10(%r12), %rax
movq %rax, (%r15)
movslq 0x14(%r12), %rdi
addq %r14, %rdi
leaq 0x4f91(%rip), %rsi      # 0x205cf
movq 0x18(%rsp), %rdx
jmp 0x1b53a
leaq 0x5d4f(%rip), %rdi      # 0x2139e
movq %r12, %rsi
movq %r14, %rdx
callq 0x1b3b2
testb %al, %al
je 0x1b67f
leaq 0x10(%r12), %rax
movq %rax, (%r15)
movslq 0x14(%r12), %rdi
addq %r14, %rdi
leaq 0x4f5a(%rip), %rsi      # 0x205cf
leaq 0x4(%rsp), %rdx
jmp 0x1b53a
leaq 0x4ff9(%rip), %rdi      # 0x2067f
movq %r12, %rsi
movq %r14, %rdx
callq 0x1b3b2
testb %al, %al
je 0x1b6b1
addq $0x10, %r12
movq %r12, (%r15)
movq 0x10(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1b8f0
jmp 0x1b545
leaq 0x4a71(%rip), %rdi      # 0x20129
movq %r12, %rsi
movq %r14, %rdx
callq 0x1b3b2
testb %al, %al
je 0x1b6f1
addq $0x10, %r12
movq %r12, (%r15)
movq 0x8(%rsp), %r12
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1ba2a
movq %rbx, %rdi
movq %r12, %rsi
callq 0x6b6f
jmp 0x1b545
leaq 0x4ab9(%rip), %rdi      # 0x201b1
movq %r12, %rsi
movq %r14, %rdx
callq 0x1b3b2
testb %al, %al
je 0x1b73e
movl 0x1c(%r12), %eax
addq $0x20, %r12
movq %r12, (%r15)
testl %eax, %eax
jle 0x1b545
movl %eax, %r12d
movq %r15, %rdi
movq %r14, %rsi
callq 0x1bb64
movq %rbx, %rdi
movq %rax, %rsi
callq 0x822e
decl %r12d
jne 0x1b71e
jmp 0x1b545
movl 0x8(%r12), %esi
movslq 0x4(%r12), %rdx
subl %edx, %esi
addq %r14, %rdx
leaq 0x5c5b(%rip), %rdi      # 0x213af
xorl %eax, %eax
callq 0x4b50
addq $0x10, (%r15)
jmp 0x1b541
movl 0x4(%rsp), %eax
testl %eax, %eax
je 0x1b784
movq 0x60(%rbx), %rcx
testq %rcx, %rcx
je 0x1b784
cmpl %eax, 0x20(%rcx)
je 0x1b780
movq 0x48(%rcx), %rcx
jmp 0x1b770
movq %rcx, 0x58(%rbx)
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq