// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x4c(%rbp), %rsi
callq 0x15b580
movq -0x10(%rbp), %rax
movl 0x30(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x30(%rax)
movq -0x10(%rbp), %rax
cmpl $0x10, 0x30(%rax)
jle 0x7fc4c
jmp 0x7fe0a
movl -0x14(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpq 0x20(%rcx), %rax
jl 0x7fc5e
jmp 0x7fe0a
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x14(%rbp), %ecx
cmpb $0x0, 0x4(%rax,%rcx,8)
je 0x7fc75
jmp 0x7fe0a
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x14(%rbp), %ecx
movb $0x1, 0x4(%rax,%rcx,8)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x14(%rbp), %edx
leaq -0x20(%rbp), %rcx
leaq -0x28(%rbp), %r8
callq 0x7ff50
cmpl $0x0, %eax
jne 0x7fca7
jmp 0x7fe0a
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %edx
movq -0x20(%rbp), %rax
movl %eax, %ecx
movq -0x28(%rbp), %rax
movl %eax, %r8d
leaq 0x12dcb8(%rip), %rsi    # 0x1ad97a
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x20(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x40(%rbp), %rsi
callq 0x1654b0
movl %eax, -0x2c(%rbp)
movq -0x8(%rbp), %rdi
movl -0x2c(%rbp), %edx
leaq 0x13573f(%rip), %rsi    # 0x1b5440
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x40(%rbp), %rsi
callq 0x1654b0
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rax
movl %eax, %edx
leaq 0x11ef4d(%rip), %rsi    # 0x19ec7b
movb $0x0, %al
callq 0x15b0d0
movq $0x0, -0x58(%rbp)
cmpl $0x0, -0x2c(%rbp)
je 0x7fd7c
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x40(%rbp), %rsi
callq 0x1654b0
movl %eax, -0x5c(%rbp)
movq -0x8(%rbp), %rdi
movl -0x5c(%rbp), %edx
leaq 0x12dc32(%rip), %rsi    # 0x1ad997
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movl -0x5c(%rbp), %edx
callq 0x7fc10
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x38(%rbp), %rax
jge 0x7fe08
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rax
movl %eax, %edx
movq -0x40(%rbp), %rax
movl %eax, %ecx
movq -0x20(%rbp), %rax
movl %eax, %r8d
leaq 0x12dbfd(%rip), %rsi    # 0x1ad9a9
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rdx
leaq -0x58(%rbp), %rcx
callq 0x80000
cmpl $0x0, %eax
jne 0x7fddd
jmp 0x7fe08
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
movq -0x58(%rbp), %rax
addq -0x40(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0x7fd84
jmp 0x7fe0a
movq -0x8(%rbp), %rdi
movl -0x4c(%rbp), %esi
callq 0x15b5a0
movq -0x10(%rbp), %rax
movl 0x30(%rax), %ecx
addl $-0x1, %ecx
movl %ecx, 0x30(%rax)
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)