// File: /workspace/github_c_makefile_star2_O1/baskerville[P]bspwm/src/restore.c
// Function: restore_desktop
desktop_t *restore_desktop(jsmntok_t **t, char *json)
{
	int s = (*t)->size;
	(*t)++;
	desktop_t *d = make_desktop(NULL, UINT32_MAX);
	xcb_window_t focusedNodeId = XCB_NONE;

	for (int i = 0; i < s; i++) {
		if (keyeq("name", *t, json)) {
			(*t)++;
			snprintf(d->name, (*t)->end - (*t)->start + 1, "%s", json + (*t)->start);
		RESTORE_UINT(id, &d->id)
		RESTORE_ANY(layout, &d->layout, parse_layout)
		RESTORE_ANY(userLayout, &d->user_layout, parse_layout)
		RESTORE_INT(windowGap, &d->window_gap)
		RESTORE_UINT(borderWidth, &d->border_width)
		} else if (keyeq("focusedNodeId", *t, json)) {
			(*t)++;
			sscanf(json + (*t)->start, "%u", &focusedNodeId);
		} else if (keyeq("padding", *t, json)) {
			(*t)++;
			restore_padding(&d->padding, t, json);
			continue;
		} else if (keyeq("root", *t, json)) {
			(*t)++;
			d->root = restore_node(t, json);
			continue;
		} else {
			warn("Restore desktop: unknown key: '%.*s'.\n", (*t)->end - (*t)->start, json + (*t)->start);
			(*t)++;
		}
		(*t)++;
	}

	if (focusedNodeId != XCB_NONE) {
		d->focus = find_by_id_in(d->root, focusedNodeId);
	}

	return d;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r14
movq %rdi, %r15
movq (%rdi), %rax
movl 0xc(%rax), %ebp
addq $0x10, %rax
movq %rax, (%rdi)
xorl %edi, %edi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x8297
movq %rax, %rbx
movl $0x0, 0x4(%rsp)
testl %ebp, %ebp
jle 0x1c0e7
leaq 0x50(%rbx), %rax
movq %rax, 0x8(%rsp)
leaq 0x64(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x60(%rbx), %rax
movq %rax, 0x18(%rsp)
leaq 0x28(%rbx), %rax
movq %rax, 0x20(%rsp)
leaq 0x24(%rbx), %rax
movq %rax, 0x28(%rsp)
movq %rbx, %rax
addq $0x20, %rax
movq %rax, 0x30(%rsp)
leaq 0x41ad(%rip), %r12      # 0x20056
movq (%r15), %r13
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x1b678
testb %al, %al
je 0x1beed
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 0x3166(%rip), %rdx      # 0x1f047
xorl %eax, %eax
callq 0x4110
jmp 0x1bfb0
leaq 0x54c3(%rip), %rdi      # 0x213b7
movq %r13, %rsi
movq %r14, %rdx
callq 0x1b678
testb %al, %al
je 0x1bf29
leaq 0x10(%r13), %rax
movq %rax, (%r15)
movslq 0x14(%r13), %rdi
addq %r14, %rdi
leaq 0x4703(%rip), %rsi      # 0x2061b
movq 0x30(%rsp), %rdx
xorl %eax, %eax
callq 0x41c0
jmp 0x1bfb0
leaq 0x411b(%rip), %rdi      # 0x2004b
movq %r13, %rsi
movq %r14, %rdx
callq 0x1b678
testb %al, %al
je 0x1bf67
leaq 0x10(%r13), %rax
movq %rax, (%r15)
movslq 0x14(%r13), %rax
leaq (%r14,%rax), %rdi
movslq 0x18(%r13), %rsi
subq %rax, %rsi
callq 0x5e6e
movq %rax, %r13
movq %rax, %rdi
movq 0x28(%rsp), %rsi
jmp 0x1bfa3
leaq 0x54b4(%rip), %rdi      # 0x21422
movq %r13, %rsi
movq %r14, %rdx
callq 0x1b678
testb %al, %al
je 0x1bfc1
leaq 0x10(%r13), %rax
movq %rax, (%r15)
movslq 0x14(%r13), %rax
leaq (%r14,%rax), %rdi
movslq 0x18(%r13), %rsi
subq %rax, %rsi
callq 0x5e6e
movq %rax, %r13
movq %rax, %rdi
movq 0x20(%rsp), %rsi
callq 0x16abc
movq %r13, %rdi
callq 0x4460
addq $0x10, (%r15)
decl %ebp
jne 0x1bea9
jmp 0x1c0e7
leaq 0x540c(%rip), %rdi      # 0x213d4
movq %r13, %rsi
movq %r14, %rdx
callq 0x1b678
testb %al, %al
je 0x1bff6
leaq 0x10(%r13), %rax
movq %rax, (%r15)
movslq 0x14(%r13), %rdi
addq %r14, %rdi
leaq 0x517f(%rip), %rsi      # 0x2116b
movq 0x18(%rsp), %rdx
jmp 0x1bf1d
leaq 0x53e1(%rip), %rdi      # 0x213de
movq %r13, %rsi
movq %r14, %rdx
callq 0x1b678
testb %al, %al
je 0x1c02b
leaq 0x10(%r13), %rax
movq %rax, (%r15)
movslq 0x14(%r13), %rdi
addq %r14, %rdi
leaq 0x45fa(%rip), %rsi      # 0x2061b
movq 0x10(%rsp), %rdx
jmp 0x1bf1d
leaq 0x53fb(%rip), %rdi      # 0x2142d
movq %r13, %rsi
movq %r14, %rdx
callq 0x1b678
testb %al, %al
je 0x1c060
leaq 0x10(%r13), %rax
movq %rax, (%r15)
movslq 0x14(%r13), %rdi
addq %r14, %rdi
leaq 0x45c5(%rip), %rsi      # 0x2061b
leaq 0x4(%rsp), %rdx
jmp 0x1bf1d
leaq 0x4664(%rip), %rdi      # 0x206cb
movq %r13, %rsi
movq %r14, %rdx
callq 0x1b678
testb %al, %al
je 0x1c092
addq $0x10, %r13
movq %r13, (%r15)
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1bbbb
jmp 0x1bfb4
leaq 0x53a2(%rip), %rdi      # 0x2143b
movq %r13, %rsi
movq %r14, %rdx
callq 0x1b678
testb %al, %al
je 0x1c0c3
addq $0x10, %r13
movq %r13, (%r15)
movq %r15, %rdi
movq %r14, %rsi
callq 0x1c10e
movq %rax, 0x30(%rbx)
jmp 0x1bfb4
movl 0x8(%r13), %esi
movslq 0x4(%r13), %rdx
subl %edx, %esi
addq %r14, %rdx
leaq 0x5369(%rip), %rdi      # 0x21440
xorl %eax, %eax
callq 0x4b50
addq $0x10, (%r15)
jmp 0x1bfb0
movl 0x4(%rsp), %esi
testl %esi, %esi
je 0x1c0fc
movq 0x30(%rbx), %rdi
callq 0xae3d
movq %rax, 0x38(%rbx)
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq