// File: /workspace/github_c_makefile_star2_O3/jsummers[P]deark/modules/hlp.c
// Function: do_file
static void do_file(deark *c, lctx *d, i64 pos1, enum hlp_filetype file_fmt, int force_extract,
	struct de_stringreaderdata *fn)
{
	i64 reserved_space;
	i64 used_space;
	i64 pos = pos1;
	UI fileflags;

	de_dbg(c, "file at %"I64_FMT", type=%s", pos1, file_type_to_type_name(file_fmt));
	de_dbg_indent(c, 1);

	// FILEHEADER
	reserved_space = de_getu32le_p(&pos);
	de_dbg(c, "ReservedSpace: %"I64_FMT, reserved_space);

	used_space = de_getu32le_p(&pos);
	de_dbg(c, "UsedSpace: %"I64_FMT, used_space);

	fileflags = (UI)de_getbyte_p(&pos);
	de_dbg(c, "FileFlags: 0x%02x", fileflags);

	if(used_space==0) goto done;
	if(pos+used_space > c->infile->len) {
		de_err(c, "Object at %"I64_FMT" (len %"I64_FMT") goes beyond end of file",
			pos, used_space);
		goto done;
	}

	if(force_extract) {
		do_extract_raw_file(c, d, pos, used_space, fn);
		goto done;
	}

	switch(file_fmt) {
	case FILETYPE_INTERNALDIR:
		do_file_INTERNALDIR(c, d, pos, used_space);
		break;
	case FILETYPE_TOPIC:
		do_file_TOPIC(c, d, pos, used_space);
		break;
	case FILETYPE_PHRASES:
		do_file_Phrases(c, d, pos, used_space);
		break;
	case FILETYPE_PHRINDEX:
		do_file_PhrIndex(c, d, pos, used_space);
		break;
	case FILETYPE_PHRIMAGE:
		do_file_PhrImage(c, d, pos, used_space);
		break;
	case FILETYPE_SYSTEM:
		do_file_SYSTEM(c, d, pos, used_space);
		break;
	case FILETYPE_SHG:
		d->has_shg = 1;
		do_file_SHG(c, d, pos, used_space);
		break;
	case FILETYPE_EXTRACTABLE:
		do_extract_raw_file(c, d, pos, used_space, fn);
		break;
	default: ;
	}

done:
	de_dbg_indent(c, -1);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r9, 0x8(%rsp)
movl %r8d, %ebp
movl %ecx, %r13d
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x10(%rsp), %r14
movq %rdx, (%r14)
movslq %ecx, %rax
leaq 0xca340(%rip), %rsi     # 0x12109c
movslq -0x4(%rsi,%rax,4), %rcx
addq %rsi, %rcx
leaq 0xca430(%rip), %rsi     # 0x12119b
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xeed83
leaq 0xca41e(%rip), %rsi     # 0x1211b0
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xeed83
movq %rax, %r12
leaq 0xca40e(%rip), %rsi     # 0x1211c3
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r14, %rsi
callq 0xeeb4b
movzbl %al, %edx
leaq 0xca3fa(%rip), %rsi     # 0x1211d2
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
testq %r12, %r12
je 0x56e29
movq 0x10(%rsp), %rdx
movq %r12, %rax
addq %rdx, %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jle 0x56e12
leaq 0xca3e1(%rip), %rsi     # 0x1211e4
movq %rbx, %rdi
movq %r12, %rcx
xorl %eax, %eax
callq 0xe9295
jmp 0x56e29
testl %ebp, %ebp
je 0x56e45
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rcx
movq 0x8(%rsp), %r8
callq 0x56ee0
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
addl $-0x2, %r13d
cmpl $0x7, %r13d
ja 0x56e29
leaq 0xca20e(%rip), %rax     # 0x121064
movslq (%rax,%r13,4), %rcx
addq %rax, %rcx
jmpq *%rcx
movq %rbx, %rdi
movq %r15, %rsi
callq 0x56f71
jmp 0x56e29
movl $0x1, 0xa8(%r15)
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rcx
callq 0x58c75
jmp 0x56e29
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rcx
callq 0x58761
jmp 0x56e29
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rcx
callq 0x5783b
jmp 0x56e29
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rcx
callq 0x586c2
jmp 0x56e29
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rcx
callq 0x5818e
jmp 0x56e29
movq %rbx, %rdi
movq %r15, %rsi
movq %r12, %rcx
callq 0x58450
jmp 0x56e29