// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movl %r8d, -0x20(%rbp)
movq %r9, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x50(%rbp)
movl -0x1c(%rbp), %edi
callq 0x7b8a0
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rdx
movq %rax, %rcx
leaq 0x1316bf(%rip), %rsi    # 0x1acd40
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x40(%rbp), %rsi
callq 0x165580
movq %rax, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rdx
leaq 0x13169b(%rip), %rsi    # 0x1acd55
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x40(%rbp), %rsi
callq 0x165580
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rdx
leaq 0x131683(%rip), %rsi    # 0x1acd68
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x40(%rbp), %rsi
callq 0x165170
movzbl %al, %eax
movl %eax, -0x44(%rbp)
movq -0x8(%rbp), %rdi
movl -0x44(%rbp), %edx
leaq 0x131666(%rip), %rsi    # 0x1acd77
movb $0x0, %al
callq 0x15b0d0
cmpq $0x0, -0x38(%rbp)
jne 0x7b724
jmp 0x7b87d
movq -0x40(%rbp), %rax
addq -0x38(%rbp), %rax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
cmpq 0x18(%rcx), %rax
jle 0x7b759
movq -0x8(%rbp), %rdi
movq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rcx
leaq 0x13163c(%rip), %rsi    # 0x1acd89
movb $0x0, %al
callq 0x15bfb0
jmp 0x7b87d
cmpl $0x0, -0x20(%rbp)
je 0x7b77d
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x28(%rbp), %r8
callq 0x7b960
jmp 0x7b87d
movl -0x1c(%rbp), %eax
addl $-0x2, %eax
movl %eax, %ecx
movq %rcx, -0x60(%rbp)
subl $0x7, %eax
ja 0x7b879
movq -0x60(%rbp), %rax
leaq 0x1313b3(%rip), %rcx    # 0x1acb50
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rcx
callq 0x7ba30
jmp 0x7b87b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rcx
callq 0x7ba80
jmp 0x7b87b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rcx
callq 0x7bea0
jmp 0x7b87b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rcx
callq 0x7c250
jmp 0x7b87b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rcx
callq 0x7c480
jmp 0x7b87b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rcx
callq 0x7c560
jmp 0x7b87b
movq -0x10(%rbp), %rax
movl $0x1, 0xa8(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rcx
callq 0x7c660
jmp 0x7b87b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x38(%rbp), %rcx
movq -0x28(%rbp), %r8
callq 0x7b960
jmp 0x7b87b
jmp 0x7b87b
jmp 0x7b87d
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)