// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/dosbackup.c
// Function: dbk20_scan_one_input_file
static void dbk20_scan_one_input_file(deark *c, lctx *d,
	dbuf *inf, int xidx)
{
	u8 last_frg_marker;
	int file_seq;
	u8 *fsig_actual = NULL;

	de_dbg(c, "[input file %d]", xidx);
	de_dbg_indent(c, 1);

	last_frg_marker = dbuf_getbyte(inf, 0);
	de_dbg(c, "last frg marker: 0x%02x", (UI)last_frg_marker);
	file_seq = (int)dbuf_getu16le(inf, 1);
	de_dbg(c, "seq num: %d", file_seq);

	if(d->num_input_files_tot==1 && (file_seq!=1 || last_frg_marker==0)) {
		de_err(c, "This is one fragment of a fragmented file.");
		de_info(c, "Note: Use \"-mp\" option, and list all fragments.");
		d->errflag = 1;
		goto done;
	}

	if(file_seq<1 || file_seq>d->num_input_files_tot) {
		d->errflag = 1;
		d->need_errmsg = 1;
		goto done;
	}
	if((last_frg_marker==0 && file_seq==d->num_input_files_tot) ||
		(last_frg_marker!=0 && file_seq!=d->num_input_files_tot))
	{
		d->errflag = 1;
		d->need_errmsg = 1;
		goto done;
	}

	fsig_actual = de_malloc(c, V20_FSIG_LEN);
	dbuf_read(inf, fsig_actual, 5, V20_FSIG_LEN);
	if(d->v20_fsig_expected) {
		if(de_memcmp(d->v20_fsig_expected, fsig_actual, V20_FSIG_LEN)) {
			// We were given fragments of different files
			d->errflag = 1;
			d->need_errmsg = 1;
			goto done;
		}
	}
	else {
		// First fragment. Don't compare, but save for next time
		d->v20_fsig_expected = fsig_actual;
		fsig_actual = NULL;
	}

	d->data_file_xidxs[file_seq - 1] = xidx;

done:
	de_free(c, fsig_actual);
	de_dbg_indent(c, -1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq $0x0, -0x30(%rbp)
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %edx
leaq 0x13cb5f(%rip), %rsi    # 0x1aa60c
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x18(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x165060
movb %al, -0x1d(%rbp)
movq -0x8(%rbp), %rdi
movzbl -0x1d(%rbp), %edx
leaq 0x13cc9f(%rip), %rsi    # 0x1aa780
movb $0x0, %al
callq 0x15b0d0
movq -0x18(%rbp), %rdi
movl $0x1, %esi
callq 0x165280
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rdi
movl -0x24(%rbp), %edx
leaq 0x13cb29(%rip), %rsi    # 0x1aa630
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rax
cmpl $0x1, 0x10(%rax)
jne 0x6db58
cmpl $0x1, -0x24(%rbp)
jne 0x6db27
movzbl -0x1d(%rbp), %eax
cmpl $0x0, %eax
jne 0x6db58
movq -0x8(%rbp), %rdi
leaq 0x13cc66(%rip), %rsi    # 0x1aa798
movb $0x0, %al
callq 0x15bfb0
movq -0x8(%rbp), %rdi
leaq 0x13cc7f(%rip), %rsi    # 0x1aa7c3
movb $0x0, %al
callq 0x15c0c0
movq -0x10(%rbp), %rax
movb $0x1, 0x8(%rax)
jmp 0x6dc4c
cmpl $0x1, -0x24(%rbp)
jl 0x6db6a
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x10(%rcx), %eax
jle 0x6db7f
movq -0x10(%rbp), %rax
movb $0x1, 0x8(%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x9(%rax)
jmp 0x6dc4c
movzbl -0x1d(%rbp), %eax
cmpl $0x0, %eax
jne 0x6db94
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x10(%rcx), %eax
je 0x6dba9
movzbl -0x1d(%rbp), %eax
cmpl $0x0, %eax
je 0x6dbbe
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0x10(%rcx), %eax
je 0x6dbbe
movq -0x10(%rbp), %rax
movb $0x1, 0x8(%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x9(%rax)
jmp 0x6dc4c
movq -0x8(%rbp), %rdi
movl $0x4f, %esi
callq 0x15b780
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rdi
movq -0x30(%rbp), %rsi
movl $0x5, %edx
movl $0x4f, %ecx
callq 0x164d10
movq -0x10(%rbp), %rax
cmpq $0x0, 0x40(%rax)
je 0x6dc21
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rdi
movq -0x30(%rbp), %rsi
movl $0x4f, %edx
callq 0x19170
cmpl $0x0, %eax
je 0x6dc1f
movq -0x10(%rbp), %rax
movb $0x1, 0x8(%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x9(%rax)
jmp 0x6dc4c
jmp 0x6dc35
movq -0x30(%rbp), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
movq $0x0, -0x30(%rbp)
movl -0x1c(%rbp), %edx
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movq -0x8(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x15b820
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax)