// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/cfb.c
// Function: do_read_dir_entry
static void do_read_dir_entry(deark *c, lctx *d, i64 dir_entry_idx, i64 dir_entry_offs)
{
	i64 name_len_bytes;
	i64 raw_sec_id;
	struct dir_entry_info *dei = NULL;

	if(!d->dir_entry) goto done; // error
	dei = &d->dir_entry[dir_entry_idx];

	dei->pass = 3; // Default pass in which to process this entry

	dei->entry_type = dbuf_getbyte(d->dir, dir_entry_offs+66);
	switch(dei->entry_type) {
	case OBJTYPE_EMPTY: dei->entry_type_name="empty"; break;
	case OBJTYPE_STORAGE: dei->entry_type_name="storage object"; break;
	case OBJTYPE_STREAM: dei->entry_type_name="stream"; break;
	case OBJTYPE_ROOT_STORAGE: dei->entry_type_name="root storage object"; break;
	default: dei->entry_type_name="?";
	}

	if(dei->entry_type==OBJTYPE_EMPTY) goto done;

	dei->name_len_raw = dbuf_getu16le(d->dir, dir_entry_offs+64);

	name_len_bytes = dei->name_len_raw-2; // Ignore the trailing U+0000
	if(name_len_bytes<0) name_len_bytes = 0;

	dei->fname_srd = dbuf_read_string(d->dir, dir_entry_offs, name_len_bytes, name_len_bytes,
		DE_CONVFLAG_WANT_UTF8, DE_ENCODING_UTF16LE);

	dei->node_color = dbuf_getbyte(d->dir, dir_entry_offs+67);

	if(dei->entry_type==OBJTYPE_STORAGE || dei->entry_type==OBJTYPE_STREAM) {
		dei->sibling_id[0] = (i32)dbuf_geti32le(d->dir, dir_entry_offs+68);
		dei->sibling_id[1] = (i32)dbuf_geti32le(d->dir, dir_entry_offs+72);
	}

	if(dei->entry_type==OBJTYPE_STORAGE || dei->entry_type==OBJTYPE_ROOT_STORAGE) {
		dei->child_id = (i32)dbuf_geti32le(d->dir, dir_entry_offs+76);
	}

	if(dei->entry_type==OBJTYPE_STORAGE || dei->entry_type==OBJTYPE_ROOT_STORAGE) {
		dbuf_read(d->dir, dei->clsid, dir_entry_offs+80, 16);
		fmtutil_guid_to_uuid(dei->clsid);
	}

	read_and_cvt_timestamp(c, d->dir, dir_entry_offs+108, &dei->mod_time);

	raw_sec_id = dbuf_geti32le(d->dir, dir_entry_offs+116);

	if(d->major_ver<=3) {
		dei->stream_size = dbuf_getu32le(d->dir, dir_entry_offs+120);
	}
	else {
		dei->stream_size = dbuf_geti64le(d->dir, dir_entry_offs+120);
		de_sanitize_length(&dei->stream_size);
	}

	dei->is_mini_stream = (dei->entry_type==OBJTYPE_STREAM) && (dei->stream_size < d->std_stream_min_size);

	if(dei->is_mini_stream) {
		dei->minisec_id = raw_sec_id;
	}
	else {
		dei->normal_sec_id = raw_sec_id;
	}

	if((d->subformat_req==SUBFMT_THUMBSDB || d->subformat_req==SUBFMT_AUTO) &&
		!de_strcmp(dei->fname_srd->sz_utf8, "Catalog"))
	{
		dei->is_thumbsdb_catalog = 1;
		if(d->decode_streams) dei->pass = 2;
	}

	if(dei->entry_type==OBJTYPE_ROOT_STORAGE) {
		dei->pass = 1;
	}

	do_per_dir_entry_format_detection(c, d, dei);

done:
	;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x98(%rax)
jne 0x526c3
jmp 0x52a86
movq -0x10(%rbp), %rax
movq 0x98(%rax), %rax
movq -0x18(%rbp), %rdx
movq %rdx, %rcx
shlq $0x7, %rcx
leaq (%rcx,%rdx,8), %rcx
addq %rcx, %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl $0x3, (%rax)
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rdi
movq -0x20(%rbp), %rsi
addq $0x42, %rsi
callq 0x165060
movb %al, %cl
movq -0x38(%rbp), %rax
movb %cl, 0x4(%rax)
movq -0x38(%rbp), %rax
movzbl 0x4(%rax), %eax
movq %rax, -0x40(%rbp)
subq $0x5, %rax
ja 0x52779
movq -0x40(%rbp), %rax
leaq 0x152d48(%rip), %rcx    # 0x1a5474
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x38(%rbp), %rax
leaq 0x1502c5(%rip), %rcx    # 0x1a2a05
movq %rcx, 0x50(%rax)
jmp 0x52788
movq -0x38(%rbp), %rax
leaq 0x1531e7(%rip), %rcx    # 0x1a5938
movq %rcx, 0x50(%rax)
jmp 0x52788
movq -0x38(%rbp), %rax
leaq 0x153480(%rip), %rcx    # 0x1a5be2
movq %rcx, 0x50(%rax)
jmp 0x52788
movq -0x38(%rbp), %rax
leaq 0x1531c0(%rip), %rcx    # 0x1a5933
movq %rcx, 0x50(%rax)
jmp 0x52788
movq -0x38(%rbp), %rax
leaq 0x1654a9(%rip), %rcx    # 0x1b7c2d
movq %rcx, 0x50(%rax)
movq -0x38(%rbp), %rax
movzbl 0x4(%rax), %eax
cmpl $0x0, %eax
jne 0x5279a
jmp 0x52a86
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rdi
movq -0x20(%rbp), %rsi
addq $0x40, %rsi
callq 0x165280
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x58(%rax)
movq -0x38(%rbp), %rax
movq 0x58(%rax), %rax
subq $0x2, %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jge 0x527dc
movq $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rdi
movq -0x20(%rbp), %rsi
movq -0x28(%rbp), %rdx
movq -0x28(%rbp), %rcx
movl $0x10, %r8d
movl $0x3, %r9d
callq 0x1664c0
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rdi
movq -0x20(%rbp), %rsi
addq $0x43, %rsi
callq 0x165060
movb %al, %cl
movq -0x38(%rbp), %rax
movb %cl, 0x60(%rax)
movq -0x38(%rbp), %rax
movzbl 0x4(%rax), %eax
cmpl $0x1, %eax
je 0x5284a
movq -0x38(%rbp), %rax
movzbl 0x4(%rax), %eax
cmpl $0x2, %eax
jne 0x5288c
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rdi
movq -0x20(%rbp), %rsi
addq $0x44, %rsi
callq 0x165600
movl %eax, %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x68(%rax)
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rdi
movq -0x20(%rbp), %rsi
addq $0x48, %rsi
callq 0x165600
movl %eax, %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x6c(%rax)
movq -0x38(%rbp), %rax
movzbl 0x4(%rax), %eax
cmpl $0x1, %eax
je 0x528a6
movq -0x38(%rbp), %rax
movzbl 0x4(%rax), %eax
cmpl $0x5, %eax
jne 0x528c7
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rdi
movq -0x20(%rbp), %rsi
addq $0x4c, %rsi
callq 0x165600
movl %eax, %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x64(%rax)
movq -0x38(%rbp), %rax
movzbl 0x4(%rax), %eax
cmpl $0x1, %eax
je 0x528e1
movq -0x38(%rbp), %rax
movzbl 0x4(%rax), %eax
cmpl $0x5, %eax
jne 0x52913
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rdi
movq -0x38(%rbp), %rsi
addq $0x30, %rsi
movq -0x20(%rbp), %rdx
addq $0x50, %rdx
movl $0x10, %ecx
callq 0x164d10
movq -0x38(%rbp), %rdi
addq $0x30, %rdi
callq 0x174010
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rsi
movq -0x20(%rbp), %rdx
addq $0x6c, %rdx
movq -0x38(%rbp), %rcx
addq $0x40, %rcx
callq 0x52fa0
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rdi
movq -0x20(%rbp), %rsi
addq $0x74, %rsi
callq 0x165600
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x3, 0x18(%rax)
jg 0x52983
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rdi
movq -0x20(%rbp), %rsi
addq $0x78, %rsi
callq 0x165540
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x529b3
movq -0x10(%rbp), %rax
movq 0x90(%rax), %rdi
movq -0x20(%rbp), %rsi
addq $0x78, %rsi
callq 0x1657e0
movq %rax, %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x38(%rbp), %rdi
addq $0x10, %rdi
callq 0x15f830
movq -0x38(%rbp), %rax
movzbl 0x4(%rax), %ecx
xorl %eax, %eax
cmpl $0x2, %ecx
movb %al, -0x41(%rbp)
jne 0x529db
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x10(%rbp), %rcx
cmpq 0x38(%rcx), %rax
setl %al
movb %al, -0x41(%rbp)
movb -0x41(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
movq -0x38(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x38(%rbp), %rax
cmpl $0x0, 0x8(%rax)
je 0x52a02
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x20(%rax)
jmp 0x52a0e
movq -0x30(%rbp), %rcx
movq -0x38(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
cmpl $0x2, (%rax)
je 0x52a20
movq -0x10(%rbp), %rax
cmpl $0x0, (%rax)
jne 0x52a5e
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rax
movq 0x20(%rax), %rdi
leaq 0x152f14(%rip), %rsi    # 0x1a5947
callq 0x191a0
cmpl $0x0, %eax
jne 0x52a5e
movq -0x38(%rbp), %rax
movb $0x1, 0x80(%rax)
movq -0x10(%rbp), %rax
cmpb $0x0, 0xd(%rax)
je 0x52a5c
movq -0x38(%rbp), %rax
movl $0x2, (%rax)
jmp 0x52a5e
movq -0x38(%rbp), %rax
movzbl 0x4(%rax), %eax
cmpl $0x5, %eax
jne 0x52a75
movq -0x38(%rbp), %rax
movl $0x1, (%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0x53000
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)