// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/dsstore.c
// Function: do_one_node
static void do_one_node(deark *c, lctx *d, u32 blk_id)
{
	i64 node_offs, node_size;
	unsigned int mode;
	i64 count;
	i64 pos;
	i64 k;
	int saved_indent_level;

	de_dbg_indent_save(c, &saved_indent_level);

	d->depth++;
	if(d->depth > DSSTORE_MAX_DEPTH) goto done;
	if(blk_id >= d->blkcount) goto done;
	if(d->block_addr_table[blk_id].decoded) goto done;
	d->block_addr_table[blk_id].decoded = 1;

	if(!block_id_to_offset_and_size(c, d, blk_id, &node_offs,
		&node_size))
	{
		goto done;
	}

	de_dbg(c, "node: id=%u, offs=%d, len=%d", (unsigned int)blk_id,
		(int)node_offs, (int)node_size);
	de_dbg_indent(c, 1);
	pos = node_offs;
	mode = (unsigned int)de_getu32be_p(&pos);
	de_dbg(c, "mode: %u", mode);
	count = de_getu32be_p(&pos);
	de_dbg(c, "count: %d", (int)count);

	{
		// If 'mode' is 0, there are 'count' records here.
		i64 bytes_consumed = 0;

		if(mode!=0) {
			u32 next_blk_id;
			next_blk_id = (u32)de_getu32be_p(&pos);
			de_dbg(c, "next block id: %u", (unsigned int)next_blk_id);
			do_one_node(c, d, next_blk_id);
		}

		for(k=0; k<count; k++) {
			de_dbg(c, "record[%d] at %d (for node@%d)", (int)k, (int)pos, (int)node_offs);
			de_dbg_indent(c, 1);
			if(!do_record(c, d, pos, &bytes_consumed)) break;
			de_dbg_indent(c, -1);
			pos += bytes_consumed;
		}
	}

done:
	de_dbg_indent_restore(c, saved_indent_level);
	d->depth--;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movl %edx, %ebp
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x2c(%rsp), %rsi
callq 0xdebae
movl 0x30(%rbx), %eax
leal 0x1(%rax), %ecx
movl %ecx, 0x30(%rbx)
cmpl $0xf, %eax
jg 0x56bd6
movl %ebp, %eax
cmpq %rax, 0x20(%rbx)
jle 0x56bd6
movq 0x28(%rbx), %rcx
cmpb $0x0, 0x4(%rcx,%rax,8)
je 0x56bf7
movl 0x2c(%rsp), %esi
movq %r14, %rdi
callq 0xdebb7
decl 0x30(%rbx)
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movb $0x1, 0x4(%rcx,%rax,8)
leaq 0xc8(%rsp), %rcx
leaq 0xc0(%rsp), %r8
movq %r14, %rdi
movq %rbx, %rsi
movl %ebp, %edx
callq 0x571d8
testl %eax, %eax
je 0x56bd6
movq 0xc8(%rsp), %r12
movl 0xc0(%rsp), %r8d
leaq 0xbe0c1(%rip), %rsi     # 0x114cf5
movq %r14, %rdi
movl %ebp, %edx
movl %r12d, %ecx
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rsi
movq %r14, %rdi
callq 0xdeba7
leaq 0x18(%rsp), %r15
movq %r12, 0xb0(%rsp)
movq %r12, (%r15)
movq 0x18(%r14), %rdi
movq %r15, %rsi
callq 0xe4071
movq %rax, %r13
leaq 0xc5c28(%rip), %rsi     # 0x11c89c
movq %r14, %rdi
movl %r13d, %edx
xorl %eax, %eax
callq 0xde896
movq 0x18(%r14), %rdi
movq %r15, %rsi
callq 0xe4071
leaq 0xaef1c(%rip), %rsi     # 0x105bb0
movq %r14, %rdi
movq %rax, %r12
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
testl %r13d, %r13d
je 0x56cdb
movq 0x18(%r14), %rdi
leaq 0x18(%rsp), %rsi
callq 0xe4071
movq %rax, %r15
leaq 0xbe052(%rip), %rsi     # 0x114d12
movq %r14, %rdi
movl %r15d, %edx
xorl %eax, %eax
callq 0xde896
movq %r14, %rdi
movq %rbx, %rsi
movl %r15d, %edx
callq 0x56b92
xorl %eax, %eax
testq %r12, %r12
cmovleq %rax, %r12
movq %r12, 0xb8(%rsp)
xorl %ebp, %ebp
cmpq %rbp, 0xb8(%rsp)
je 0x56bd6
movl 0x18(%rsp), %ecx
movq %r14, %rdi
leaq 0xbe01a(%rip), %rsi     # 0x114d24
movl %ebp, %edx
movq 0xb0(%rsp), %r8
xorl %eax, %eax
callq 0xde896
movq %r14, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq 0x18(%rsp), %r12
movq %r12, 0x8(%rsp)
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
andq $0x0, 0xa0(%rsp)
movq 0x18(%r14), %rdi
leaq 0x8(%rsp), %rsi
callq 0xe4071
movb $0x1, %r13b
cmpq $0x800, %rax            # imm = 0x800
jg 0x570c9
movq %rax, %r15
movq %r12, 0x20(%rsp)
movq %r14, %rdi
callq 0xeac74
movq %rax, %r13
movq %rax, 0x40(%rsp)
movq 0x18(%r14), %rdi
movq 0x8(%rsp), %rsi
addq %r15, %r15
movq %r15, %rdx
movq %rax, %rcx
xorl %r8d, %r8d
pushq $0x4
popq %r12
movl %r12d, %r9d
callq 0xe4c9a
movq %r13, %rdi
callq 0xeb877
movq %r14, %rdi
leaq 0xd7c91(%rip), %rsi     # 0x12ea5e
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
addq 0x8(%rsp), %r15
movq %r15, 0x8(%rsp)
movq 0x18(%r14), %rdi
movq %r15, %rsi
leaq 0x48(%rsp), %rdx
movl %r12d, %ecx
xorl %r8d, %r8d
callq 0xe657c
movq %r14, %rdi
leaq 0xbdf41(%rip), %rsi     # 0x114d43
leaq 0x58(%rsp), %rdx
xorl %eax, %eax
callq 0xde896
movq 0x8(%rsp), %rsi
addq $0x4, %rsi
movq %rsi, 0x8(%rsp)
movq 0x18(%r14), %rdi
leaq 0x78(%rsp), %rdx
movl %r12d, %ecx
xorl %r8d, %r8d
callq 0xe657c
movq %r14, %rdi
leaq 0xbdf1b(%rip), %rsi     # 0x114d55
leaq 0x88(%rsp), %rdx
xorl %eax, %eax
callq 0xde896
movq 0x8(%rsp), %rax
leaq 0x4(%rax), %rsi
movq %rsi, 0x8(%rsp)
movq %rsi, 0x30(%rsp)
movl 0x7c(%rsp), %ecx
cmpl $0x75737472, %ecx       # imm = 0x75737472
je 0x57041
cmpl $0x626f6f6c, %ecx       # imm = 0x626F6F6C
pushq $0x5
popq %r12
je 0x56f87
cmpl $0x636f6d70, %ecx       # imm = 0x636F6D70
movb $0x1, %r13b
je 0x5702b
cmpl $0x64757463, %ecx       # imm = 0x64757463
je 0x56fc3
cmpl $0x6c6f6e67, %ecx       # imm = 0x6C6F6E67
je 0x56f44
cmpl $0x73686f72, %ecx       # imm = 0x73686F72
je 0x56f6d
cmpl $0x74797065, %ecx       # imm = 0x74797065
je 0x56f57
cmpl $0x626c6f62, %ecx       # imm = 0x626C6F62
jne 0x56fa0
movq 0x18(%r14), %rdi
callq 0xe404f
movq %rax, %r13
movq %r14, %rdi
leaq 0xbded4(%rip), %rsi     # 0x114db1
movl %r13d, %edx
xorl %eax, %eax
callq 0xde896
leaq 0x4(%r13), %rax
movq %rax, 0x38(%rsp)
movq 0x30(%rsp), %r15
addq $0x4, %r15
cmpq $0x8, %r13
jl 0x56f1d
movq 0x18(%r14), %rdi
movq %r15, %rsi
leaq 0xb2d0f(%rip), %rdx     # 0x109c1c
pushq $0x8
popq %rcx
callq 0xe4d48
testl %eax, %eax
je 0x570fc
movq 0x18(%r14), %rsi
movl $0x1, (%rsp)
movl $0x100, %r8d            # imm = 0x100
movq %r14, %rdi
movq %r15, %rdx
movq %r13, %rcx
xorl %r9d, %r9d
callq 0xded3a
jmp 0x570af
movq $0x4, 0x38(%rsp)
movq %r14, %rdi
pushq $0x4
jmp 0x57039
movq $0x4, 0x38(%rsp)
pushq $0x4
popq %rax
movq 0x20(%rsp), %r12
jmp 0x570c1
movq $0x4, 0x38(%rsp)
addq $0x6, %rax
movq %r14, %rdi
movq %rax, %rsi
pushq $0x2
jmp 0x57039
movq $0x1, 0x38(%rsp)
movq %r14, %rdi
pushq $0x1
popq %rdx
callq 0x57228
jmp 0x570af
movq %r14, %rdi
leaq 0xbddbb(%rip), %rsi     # 0x114d65
leaq 0x80(%rsp), %rdx
xorl %eax, %eax
callq 0xdf05a
movq 0x20(%rsp), %r12
jmp 0x570c9
movq $0x8, 0x38(%rsp)
movq 0x18(%r14), %rdi
callq 0xe41f2
movq %rax, %r15
movq %rax, %rdi
shrq $0x10, %rdi
leaq 0xd0(%rsp), %r12
movq %r12, %rsi
callq 0xe0102
movb $0x1, 0xd1(%rsp)
movq %r12, %rdi
leaq 0xe0(%rsp), %r12
movq %r12, %rsi
pushq $0x40
popq %rdx
xorl %ecx, %ecx
callq 0xe0644
movq %r14, %rdi
leaq 0xbddc1(%rip), %rsi     # 0x114dda
movq %r15, %rdx
movq %r12, %rcx
xorl %eax, %eax
callq 0xde896
jmp 0x570b2
movq $0x8, 0x38(%rsp)
movq %r14, %rdi
pushq $0x8
popq %rdx
callq 0x57228
jmp 0x570b2
movq 0x18(%r14), %rdi
callq 0xe404f
movq %rax, %r13
addq $0x4, %rax
movq %rax, 0x38(%rsp)
movq %r14, %rdi
callq 0xeac74
movq %rax, %r15
movq 0x18(%r14), %rdi
movq 0x30(%rsp), %rsi
addq $0x4, %rsi
addq %r13, %r13
movl $0x4, (%rsp)
movl $0x3e8, %ecx            # imm = 0x3E8
movq %r13, %rdx
movq %rax, %r8
xorl %r9d, %r9d
callq 0xe4ced
movq %r15, %rdi
callq 0xeb877
movq %r14, %rdi
leaq 0xae6ae(%rip), %rsi     # 0x10574b
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq %r15, %rdi
callq 0xeaf3c
movb $0x1, %r13b
movq 0x38(%rsp), %rax
testq %rax, %rax
movq 0x20(%rsp), %r12
jle 0x570c9
addq %rax, 0x8(%rsp)
xorl %r13d, %r13d
movq 0x8(%rsp), %r15
movq 0x40(%rsp), %rdi
callq 0xeaf3c
testb %r13b, %r13b
jne 0x56bd6
subq %r12, %r15
movq %r14, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
addq %r15, 0x18(%rsp)
incq %rbp
jmp 0x56cee
movq %r14, %rdi
leaq 0xbdcb8(%rip), %rsi     # 0x114dbe
movl %r15d, %edx
xorl %eax, %eax
callq 0xde896
movq %r14, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq %r14, %rdi
callq 0xeac74
movq %rax, 0x10(%rsp)
cmpb $0x0, 0xd0(%r14)
je 0x57155
movq 0x40(%rsp), %rsi
movq 0x10(%rsp), %rdi
callq 0xead71
movq 0x10(%rsp), %rdi
leaq 0xd7531(%rip), %rsi     # 0x12e67e
movl %r12d, %edx
callq 0xeae42
movq 0x10(%rsp), %rdi
movl %r12d, %esi
leaq 0xbdc6d(%rip), %rdx     # 0x114dd1
leaq 0x50(%rsp), %rcx
xorl %eax, %eax
callq 0xeae8b
movq %r14, %rdi
callq 0xdfd1a
movq %rax, 0xa8(%rsp)
movq %r14, %rdi
movq %rax, %rsi
movq 0x10(%rsp), %r12
movq %r12, %rdx
xorl %ecx, %ecx
callq 0xdfd55
movq 0x18(%r14), %rsi
movq %r14, %rdi
movq %r15, %rdx
movq %r13, %rcx
movq 0xa8(%rsp), %r15
movq %r15, %r8
xorl %r9d, %r9d
callq 0xec602
movq %r12, %rdi
callq 0xeaf3c
movq %r14, %rdi
movq %r15, %rsi
callq 0xdfd24
movq %r14, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
jmp 0x570af