// File: /workspace/github_c_makefile_star2_O3/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 0x813c
movq %rax, %rbx
movl $0x0, 0x4(%rsp)
testl %ebp, %ebp
jle 0x1be37
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 0x442f(%rip), %r12      # 0x20013
movq (%r15), %r13
movq %r12, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq 0x1b3b2
testb %al, %al
je 0x1bc28
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 0x342b(%rip), %rdx      # 0x1f047
xorl %eax, %eax
callq 0x4110
jmp 0x1bceb
leaq 0x573c(%rip), %rdi      # 0x2136b
movq %r13, %rsi
movq %r14, %rdx
callq 0x1b3b2
testb %al, %al
je 0x1bc64
leaq 0x10(%r13), %rax
movq %rax, (%r15)
movslq 0x14(%r13), %rdi
addq %r14, %rdi
leaq 0x497c(%rip), %rsi      # 0x205cf
movq 0x30(%rsp), %rdx
xorl %eax, %eax
callq 0x41c0
jmp 0x1bceb
leaq 0x439d(%rip), %rdi      # 0x20008
movq %r13, %rsi
movq %r14, %rdx
callq 0x1b3b2
testb %al, %al
je 0x1bca2
leaq 0x10(%r13), %rax
movq %rax, (%r15)
movslq 0x14(%r13), %rax
leaq (%r14,%rax), %rdi
movslq 0x18(%r13), %rsi
subq %rax, %rsi
callq 0x5e2f
movq %rax, %r13
movq %rax, %rdi
movq 0x28(%rsp), %rsi
jmp 0x1bcde
leaq 0x572d(%rip), %rdi      # 0x213d6
movq %r13, %rsi
movq %r14, %rdx
callq 0x1b3b2
testb %al, %al
je 0x1bcfc
leaq 0x10(%r13), %rax
movq %rax, (%r15)
movslq 0x14(%r13), %rax
leaq (%r14,%rax), %rdi
movslq 0x18(%r13), %rsi
subq %rax, %rsi
callq 0x5e2f
movq %rax, %r13
movq %rax, %rdi
movq 0x20(%rsp), %rsi
callq 0x1698f
movq %r13, %rdi
callq 0x4460
addq $0x10, (%r15)
decl %ebp
jne 0x1bbe4
jmp 0x1be22
leaq 0x5685(%rip), %rdi      # 0x21388
movq %r13, %rsi
movq %r14, %rdx
callq 0x1b3b2
testb %al, %al
je 0x1bd31
leaq 0x10(%r13), %rax
movq %rax, (%r15)
movslq 0x14(%r13), %rdi
addq %r14, %rdi
leaq 0x53f8(%rip), %rsi      # 0x2111f
movq 0x18(%rsp), %rdx
jmp 0x1bc58
leaq 0x565a(%rip), %rdi      # 0x21392
movq %r13, %rsi
movq %r14, %rdx
callq 0x1b3b2
testb %al, %al
je 0x1bd66
leaq 0x10(%r13), %rax
movq %rax, (%r15)
movslq 0x14(%r13), %rdi
addq %r14, %rdi
leaq 0x4873(%rip), %rsi      # 0x205cf
movq 0x10(%rsp), %rdx
jmp 0x1bc58
leaq 0x5674(%rip), %rdi      # 0x213e1
movq %r13, %rsi
movq %r14, %rdx
callq 0x1b3b2
testb %al, %al
je 0x1bd9b
leaq 0x10(%r13), %rax
movq %rax, (%r15)
movslq 0x14(%r13), %rdi
addq %r14, %rdi
leaq 0x483e(%rip), %rsi      # 0x205cf
leaq 0x4(%rsp), %rdx
jmp 0x1bc58
leaq 0x48dd(%rip), %rdi      # 0x2067f
movq %r13, %rsi
movq %r14, %rdx
callq 0x1b3b2
testb %al, %al
je 0x1bdcd
addq $0x10, %r13
movq %r13, (%r15)
movq 0x8(%rsp), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1b8f0
jmp 0x1bcef
leaq 0x561b(%rip), %rdi      # 0x213ef
movq %r13, %rsi
movq %r14, %rdx
callq 0x1b3b2
testb %al, %al
je 0x1bdfe
addq $0x10, %r13
movq %r13, (%r15)
movq %r15, %rdi
movq %r14, %rsi
callq 0x1be49
movq %rax, 0x30(%rbx)
jmp 0x1bcef
movl 0x8(%r13), %esi
movslq 0x4(%r13), %rdx
subl %edx, %esi
addq %r14, %rdx
leaq 0x55e2(%rip), %rdi      # 0x213f4
xorl %eax, %eax
callq 0x4b50
addq $0x10, (%r15)
jmp 0x1bceb
movl 0x4(%rsp), %esi
testl %esi, %esi
je 0x1be37
movq 0x30(%rbx), %rdi
callq 0xadf0
movq %rax, 0x38(%rbx)
movq %rbx, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq