// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/amiga-dsk.c
// Function: do_file
static void do_file(deark *c, lctx *d, struct member_data *md)
{
	i64 pos1, pos;
	i64 fnlen;
	i64 header_key;
	i64 blocks_tbl_pos;
	i64 n;
	int need_curpath_pop = 0;
	de_ucstring *fullfn = NULL;
	int saved_indent_level;

	de_dbg_indent_save(c, &saved_indent_level);

	if(md->sec_type!=ADF_ST_FILE) goto done;
	pos1 = md->header_pos;
	de_dbg(c, "file, header at blk#%"I64_FMT" (%"I64_FMT")", md->header_blknum, pos1);
	de_dbg_indent(c, 1);

	pos = pos1 + 4;
	header_key = de_getu32be_p(&pos);
	de_dbg(c, "header_key: %u", (UI)header_key);
	md->tmpbpt.high_seq = de_getu32be_p(&pos);
	de_dbg(c, "high_seq: %u", (UI)md->tmpbpt.high_seq);
	pos += 4; // data_size - unused
	md->first_data_block = de_getu32be_p(&pos);
	de_dbg(c, "first data block: %"I64_FMT, md->first_data_block);

	if(header_key!=md->header_blknum) {
		de_err(c, "Bad self-pointer (%"I64_FMT") in block #%"I64_FMT, header_key,
			md->header_blknum);
		goto done;
	}

	blocks_tbl_pos = md->header_pos + 24;
	md->tmpbpt.blocks_tbl_capacity = (d->bsize/4) - 56;
	md->tmpbpt.blocks_tbl = de_mallocarray(c, md->tmpbpt.blocks_tbl_capacity,
		sizeof(md->tmpbpt.blocks_tbl[0]));

	read_blocks_table(c, d, blocks_tbl_pos, &md->tmpbpt);

	read_protection_flags(c, d, md, pos1+d->bsize-192);

	pos = pos1+d->bsize-188;
	md->fsize = de_getu32be_p(&pos);
	de_dbg(c, "file size: %"I64_FMT, md->fsize);

	pos = pos1+d->bsize-92;
	read_ofs_timestamp(c, pos, &md->mod_time, "mod time");

	pos = pos1+d->bsize-80;
	fnlen = (i64)de_getbyte_p(&pos);
	if(fnlen>30) fnlen=30;
	md->fn = ucstring_create(c);
	dbuf_read_to_ucstring(c->infile, pos, fnlen, md->fn, 0, DE_ENCODING_LATIN1);
	de_dbg(c, "filename: \"%s\"", ucstring_getpsz_d(md->fn));
	de_strarray_push(d->curpath, md->fn);
	need_curpath_pop = 1;

	pos = pos1+d->bsize-12;
	n = de_getu32be_p(&pos);
	de_dbg(c, "parent dir: %"I64_FMT, n);
	md->first_ext_block = de_getu32be_p(&pos);
	de_dbg(c, "first ext. block: %"I64_FMT, md->first_ext_block);

	if(md->sec_type!=ADF_ST_FILE) {
		de_dbg(c, "[not a supported file type]");
		goto done;
	}

	md->fi->original_filename_flag = 1;
	fullfn = ucstring_create(c);
	de_strarray_make_path(d->curpath, fullfn, DE_MPFLAG_NOTRAILINGSLASH);
	de_finfo_set_name_from_ucstring(c, md->fi, fullfn, DE_SNFLAG_FULLPATH);

	if(md->mod_time.is_valid) {
		md->fi->timestamp[DE_TIMESTAMPIDX_MODIFY] = md->mod_time;
	}

	md->outf = dbuf_create_output_file(c, NULL, md->fi, 0x0);

	if(d->is_ffs) {
		read_file_using_blocks_table(c, d, md);
	}
	else {
		read_file_ofs_style(c, d, md);
	}

done:
	if(need_curpath_pop) {
		de_strarray_pop(d->curpath);
	}
	ucstring_destroy(fullfn);
	de_dbg_indent_restore(c, saved_indent_level);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl $0x0, -0x4c(%rbp)
movq $0x0, -0x58(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x5c(%rbp), %rsi
callq 0x15b580
movq -0x18(%rbp), %rax
cmpl $-0x3, 0x30(%rax)
je 0x33fcf
jmp 0x34407
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x20(%rbp)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq (%rax), %rdx
movq -0x20(%rbp), %rcx
leaq 0x16cd73(%rip), %rsi    # 0x1a0d64
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x20(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x1654b0
movq %rax, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rax
movl %eax, %edx
leaq 0x16cd4a(%rip), %rsi    # 0x1a0d82
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x1654b0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x70(%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x70(%rax), %rax
movl %eax, %edx
leaq 0x16cd21(%rip), %rsi    # 0x1a0d91
movb $0x0, %al
callq 0x15b0d0
movq -0x28(%rbp), %rax
addq $0x4, %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x1654b0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rdx
leaq 0x16ccec(%rip), %rsi    # 0x1a0d9e
movb $0x0, %al
callq 0x15b0d0
movq -0x38(%rbp), %rax
movq -0x18(%rbp), %rcx
cmpq (%rcx), %rax
je 0x340e8
movq -0x8(%rbp), %rdi
movq -0x38(%rbp), %rdx
movq -0x18(%rbp), %rax
movq (%rax), %rcx
leaq 0x16ccd8(%rip), %rsi    # 0x1a0db4
movb $0x0, %al
callq 0x15bfb0
jmp 0x34407
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
addq $0x18, %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movl $0x4, %ecx
cqto
idivq %rcx
movq %rax, %rcx
subq $0x38, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x78(%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x78(%rax), %rsi
movl $0x8, %edx
callq 0x15c450
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x80(%rax)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x40(%rbp), %rdx
movq -0x18(%rbp), %rcx
addq $0x70, %rcx
callq 0x34880
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
movq -0x20(%rbp), %rcx
movq -0x10(%rbp), %rax
addq 0x8(%rax), %rcx
subq $0xc0, %rcx
callq 0x34470
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
addq 0x8(%rcx), %rax
subq $0xbc, %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x1654b0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rdx
leaq 0x16e35b(%rip), %rsi    # 0x1a251a
movb $0x0, %al
callq 0x15b0d0
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
addq 0x8(%rcx), %rax
subq $0x5c, %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x18(%rbp), %rdx
addq $0x40, %rdx
leaq 0x185981(%rip), %rcx    # 0x1b9b72
callq 0x34510
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
addq 0x8(%rcx), %rax
subq $0x50, %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x165170
movzbl %al, %eax
movq %rax, -0x30(%rbp)
cmpq $0x1e, -0x30(%rbp)
jle 0x34231
movq $0x1e, -0x30(%rbp)
movq -0x8(%rbp), %rdi
callq 0x1711d0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x38(%rax)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rcx
xorl %r8d, %r8d
movl $0x5, %r9d
callq 0x1669f0
movq -0x8(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rdi
callq 0x172650
movq -0x68(%rbp), %rdi
movq %rax, %rdx
leaq 0x1932f5(%rip), %rsi    # 0x1c7583
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x38(%rax), %rsi
callq 0x1728d0
movl $0x1, -0x4c(%rbp)
movq -0x20(%rbp), %rax
movq -0x10(%rbp), %rcx
addq 0x8(%rcx), %rax
subq $0xc, %rax
movq %rax, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x1654b0
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rdi
movq -0x48(%rbp), %rdx
leaq 0x16caf0(%rip), %rsi    # 0x1a0dd9
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x28(%rbp), %rsi
callq 0x1654b0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rdx
leaq 0x16caca(%rip), %rsi    # 0x1a0de9
movb $0x0, %al
callq 0x15b0d0
movq -0x18(%rbp), %rax
cmpl $-0x3, 0x30(%rax)
je 0x34347
movq -0x8(%rbp), %rdi
leaq 0x16cac4(%rip), %rsi    # 0x1a0dff
movb $0x0, %al
callq 0x15b0d0
jmp 0x34407
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rax
movb $0x1, 0x8(%rax)
movq -0x8(%rbp), %rdi
callq 0x1711d0
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
movq -0x58(%rbp), %rsi
movl $0x1, %edx
callq 0x1729c0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rsi
movq -0x58(%rbp), %rdx
movl $0x1, %ecx
callq 0x15d2c0
movq -0x18(%rbp), %rax
cmpb $0x0, 0x40(%rax)
je 0x343b6
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x40(%rcx), %rdx
movq %rdx, 0x18(%rax)
movq 0x48(%rcx), %rcx
movq %rcx, 0x20(%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movq 0x68(%rax), %rdx
xorl %eax, %eax
movl %eax, %esi
xorl %ecx, %ecx
callq 0x166c60
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x50(%rax)
movq -0x10(%rbp), %rax
cmpb $0x0, (%rax)
je 0x343f4
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x34940
jmp 0x34405
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x34a40
jmp 0x34407
cmpl $0x0, -0x4c(%rbp)
je 0x3441a
movq -0x10(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x172850
movq -0x58(%rbp), %rdi
callq 0x171750
movq -0x8(%rbp), %rdi
movl -0x5c(%rbp), %esi
callq 0x15b5a0
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)