// File: /workspace/github_c_makefile_star2_O2/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), %ebp
addq $0x10, %rax
movq %rax, (%rdi)
xorl %r12d, %r12d
pushq $-0x1
popq %rdx
xorl %edi, %edi
xorl %esi, %esi
callq 0x6984
leaq 0x4(%rsp), %rcx
andl $0x0, (%rcx)
movq %rax, %rbx
addq $0x4c, %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)
leaq 0x20(%rbx), %rax
movq %rax, 0x40(%rsp)
testl %ebp, %ebp
cmovlel %r12d, %ebp
xorl %r12d, %r12d
cmpl %ebp, %r12d
je 0x1a2d0
movq (%r15), %r13
leaq 0x4ff9(%rip), %rdi      # 0x1f013
movq %r13, %rsi
movq %r14, %rdx
callq 0x19f32
testb %al, %al
je 0x1a055
leaq 0x10(%r13), %rax
movq %rax, (%r15)
movl 0x18(%r13), %eax
movslq 0x14(%r13), %rcx
subl %ecx, %eax
incl %eax
movslq %eax, %rsi
addq %r14, %rcx
movq %rbx, %rdi
leaq 0x3ffb(%rip), %rdx      # 0x1e047
xorl %eax, %eax
callq 0x4110
jmp 0x1a0be
leaq 0x630f(%rip), %rdi      # 0x2036b
movq %r13, %rsi
movq %r14, %rdx
callq 0x19f32
testb %al, %al
je 0x1a087
leaq 0x10(%r13), %rax
movq %rax, (%r15)
movslq 0x14(%r13), %rdi
addq %r14, %rdi
leaq 0x554f(%rip), %rsi      # 0x1f5cf
movq 0x40(%rsp), %rdx
jmp 0x1a0b7
leaq 0x62e0(%rip), %rdi      # 0x2036e
movq %r13, %rsi
movq %r14, %rdx
callq 0x19f32
testb %al, %al
je 0x1a0ca
leaq 0x10(%r13), %rax
movq %rax, (%r15)
movslq 0x14(%r13), %rdi
addq %r14, %rdi
leaq 0x551d(%rip), %rsi      # 0x1f5cf
movq 0x38(%rsp), %rdx
xorl %eax, %eax
callq 0x41c0
addq $0x10, (%r15)
incl %r12d
jmp 0x1a007
leaq 0x62a5(%rip), %rdi      # 0x20376
movq %r13, %rsi
movq %r14, %rdx
callq 0x19f32
testb %al, %al
je 0x1a115
leaq 0x10(%r13), %rax
movq %rax, (%r15)
movslq 0x14(%r13), %rax
leaq (%r14,%rax), %rdi
movslq 0x18(%r13), %rsi
subq %rax, %rsi
callq 0x5d82
movq %rax, %r13
movq %rax, %rdi
movq 0x30(%rsp), %rsi
callq 0x15728
movq %r13, %rdi
callq 0x4460
jmp 0x1a0be
leaq 0x6260(%rip), %rdi      # 0x2037c
movq %r13, %rsi
movq %r14, %rdx
callq 0x19f32
testb %al, %al
je 0x1a14a
leaq 0x10(%r13), %rax
movq %rax, (%r15)
movslq 0x14(%r13), %rdi
addq %r14, %rdi
leaq 0x548f(%rip), %rsi      # 0x1f5cf
movq 0x28(%rsp), %rdx
jmp 0x1a0b7
leaq 0x6237(%rip), %rdi      # 0x20388
movq %r13, %rsi
movq %r14, %rdx
callq 0x19f32
testb %al, %al
je 0x1a17f
leaq 0x10(%r13), %rax
movq %rax, (%r15)
movslq 0x14(%r13), %rdi
addq %r14, %rdi
leaq 0x5faa(%rip), %rsi      # 0x2011f
movq 0x20(%rsp), %rdx
jmp 0x1a0b7
leaq 0x620c(%rip), %rdi      # 0x20392
movq %r13, %rsi
movq %r14, %rdx
callq 0x19f32
testb %al, %al
je 0x1a1b4
leaq 0x10(%r13), %rax
movq %rax, (%r15)
movslq 0x14(%r13), %rdi
addq %r14, %rdi
leaq 0x5425(%rip), %rsi      # 0x1f5cf
movq 0x18(%rsp), %rdx
jmp 0x1a0b7
leaq 0x61e3(%rip), %rdi      # 0x2039e
movq %r13, %rsi
movq %r14, %rdx
callq 0x19f32
testb %al, %al
je 0x1a1e9
leaq 0x10(%r13), %rax
movq %rax, (%r15)
movslq 0x14(%r13), %rdi
addq %r14, %rdi
leaq 0x53f0(%rip), %rsi      # 0x1f5cf
leaq 0x4(%rsp), %rdx
jmp 0x1a0b7
leaq 0x548f(%rip), %rdi      # 0x1f67f
movq %r13, %rsi
movq %r14, %rdx
callq 0x19f32
testb %al, %al
je 0x1a21b
addq $0x10, %r13
movq %r13, (%r15)
movq 0x10(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1a478
jmp 0x1a0c2
leaq 0x4f07(%rip), %rdi      # 0x1f129
movq %r13, %rsi
movq %r14, %rdx
callq 0x19f32
testb %al, %al
je 0x1a25b
addq $0x10, %r13
movq %r13, (%r15)
movq 0x8(%rsp), %r13
movq %r13, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1a5b8
movq %rbx, %rdi
movq %r13, %rsi
callq 0x6a5d
jmp 0x1a0c2
leaq 0x4f4f(%rip), %rdi      # 0x1f1b1
movq %r13, %rsi
movq %r14, %rdx
callq 0x19f32
testb %al, %al
je 0x1a2ac
movl 0x1c(%r13), %eax
addq $0x20, %r13
movq %r13, (%r15)
movl %eax, %r13d
testl %eax, %eax
movl $0x0, %eax
cmovlel %eax, %r13d
subl $0x1, %r13d
jb 0x1a0c2
movq %r15, %rdi
movq %r14, %rsi
callq 0x1a6f8
movq %rbx, %rdi
movq %rax, %rsi
callq 0x7fe2
jmp 0x1a28a
movl 0x8(%r13), %esi
movslq 0x4(%r13), %rdx
subl %edx, %esi
addq %r14, %rdx
leaq 0x60ef(%rip), %rdi      # 0x203af
xorl %eax, %eax
callq 0x5b50
addq $0x10, (%r15)
jmp 0x1a0be
movl 0x4(%rsp), %eax
testl %eax, %eax
je 0x1a2f6
movq %rbx, %rcx
addq $0x60, %rcx
movq (%rcx), %rcx
testq %rcx, %rcx
je 0x1a2f6
cmpl %eax, 0x20(%rcx)
je 0x1a2f2
addq $0x48, %rcx
jmp 0x1a2df
movq %rcx, 0x58(%rbx)
movq %rbx, %rax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq