// File: /workspace/github_c_makefile_star2_O2/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, %rbx
movq %rdi, %r14
movq (%rdi), %rax
movl 0xc(%rax), %r12d
addq $0x10, %rax
movq %rax, (%rdi)
xorl %r13d, %r13d
pushq $-0x1
popq %rsi
xorl %edi, %edi
callq 0x7efd
leaq 0x4(%rsp), %rcx
andl $0x0, (%rcx)
movq %rax, %r15
addq $0x50, %rax
movq %rax, 0x8(%rsp)
leaq 0x64(%r15), %rax
movq %rax, 0x10(%rsp)
leaq 0x60(%r15), %rax
movq %rax, 0x18(%rsp)
leaq 0x28(%r15), %rax
movq %rax, 0x20(%rsp)
leaq 0x24(%r15), %rax
movq %rax, 0x28(%rsp)
movq %r15, %rax
addq $0x20, %rax
movq %rax, 0x30(%rsp)
testl %r12d, %r12d
cmovlel %r13d, %r12d
leaq 0x489a(%rip), %r13      # 0x1f013
subl $0x1, %r12d
jb 0x1a9b7
movq (%r14), %rbp
movq %r13, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x19f32
testb %al, %al
je 0x1a7c6
leaq 0x10(%rbp), %rax
movq %rax, (%r14)
movl 0x18(%rbp), %eax
movslq 0x14(%rbp), %rcx
subl %ecx, %eax
incl %eax
movslq %eax, %rsi
addq %rbx, %rcx
movq %r15, %rdi
leaq 0x388d(%rip), %rdx      # 0x1e047
xorl %eax, %eax
callq 0x4110
jmp 0x1a889
leaq 0x5b9e(%rip), %rdi      # 0x2036b
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x19f32
testb %al, %al
je 0x1a802
leaq 0x10(%rbp), %rax
movq %rax, (%r14)
movslq 0x14(%rbp), %rdi
addq %rbx, %rdi
leaq 0x4dde(%rip), %rsi      # 0x1f5cf
movq 0x30(%rsp), %rdx
xorl %eax, %eax
callq 0x41c0
jmp 0x1a889
leaq 0x47ff(%rip), %rdi      # 0x1f008
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x19f32
testb %al, %al
je 0x1a840
leaq 0x10(%rbp), %rax
movq %rax, (%r14)
movslq 0x14(%rbp), %rax
leaq (%rbx,%rax), %rdi
movslq 0x18(%rbp), %rsi
subq %rax, %rsi
callq 0x5d82
movq %rax, %rbp
movq %rax, %rdi
movq 0x28(%rsp), %rsi
jmp 0x1a87c
leaq 0x5b8f(%rip), %rdi      # 0x203d6
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x19f32
testb %al, %al
je 0x1a892
leaq 0x10(%rbp), %rax
movq %rax, (%r14)
movslq 0x14(%rbp), %rax
leaq (%rbx,%rax), %rdi
movslq 0x18(%rbp), %rsi
subq %rax, %rsi
callq 0x5d82
movq %rax, %rbp
movq %rax, %rdi
movq 0x20(%rsp), %rsi
callq 0x1582f
movq %rbp, %rdi
callq 0x4460
addq $0x10, (%r14)
jmp 0x1a779
leaq 0x5aef(%rip), %rdi      # 0x20388
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x19f32
testb %al, %al
je 0x1a8c7
leaq 0x10(%rbp), %rax
movq %rax, (%r14)
movslq 0x14(%rbp), %rdi
addq %rbx, %rdi
leaq 0x5862(%rip), %rsi      # 0x2011f
movq 0x18(%rsp), %rdx
jmp 0x1a7f6
leaq 0x5ac4(%rip), %rdi      # 0x20392
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x19f32
testb %al, %al
je 0x1a8fc
leaq 0x10(%rbp), %rax
movq %rax, (%r14)
movslq 0x14(%rbp), %rdi
addq %rbx, %rdi
leaq 0x4cdd(%rip), %rsi      # 0x1f5cf
movq 0x10(%rsp), %rdx
jmp 0x1a7f6
leaq 0x5ade(%rip), %rdi      # 0x203e1
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x19f32
testb %al, %al
je 0x1a931
leaq 0x10(%rbp), %rax
movq %rax, (%r14)
movslq 0x14(%rbp), %rdi
addq %rbx, %rdi
leaq 0x4ca8(%rip), %rsi      # 0x1f5cf
leaq 0x4(%rsp), %rdx
jmp 0x1a7f6
leaq 0x4d47(%rip), %rdi      # 0x1f67f
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x19f32
testb %al, %al
je 0x1a963
addq $0x10, %rbp
movq %rbp, (%r14)
movq 0x8(%rsp), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x1a478
jmp 0x1a779
leaq 0x5a85(%rip), %rdi      # 0x203ef
movq %rbp, %rsi
movq %rbx, %rdx
callq 0x19f32
testb %al, %al
je 0x1a994
addq $0x10, %rbp
movq %rbp, (%r14)
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1a9de
movq %rax, 0x30(%r15)
jmp 0x1a779
movl 0x8(%rbp), %esi
movslq 0x4(%rbp), %rdx
subl %edx, %esi
addq %rbx, %rdx
leaq 0x5a4d(%rip), %rdi      # 0x203f4
xorl %eax, %eax
callq 0x5b50
addq $0x10, (%r14)
jmp 0x1a889
movl 0x4(%rsp), %esi
testl %esi, %esi
je 0x1a9cc
movq 0x30(%r15), %rdi
callq 0xa74e
movq %rax, 0x38(%r15)
movq %r15, %rax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq