// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/dosbackup.c
// Function: v33_scan_one_input_file
static void v33_scan_one_input_file(deark *c, lctx *d, dbuf *inf, int xidx)
{
	u8 is_control_file = 0;
	u8 last_disk_marker = 0;
	int control_file_seq = 0;

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

	if(d->v33_num_control_files_found < d->v33_num_volumes) {
		is_control_file = v33_looks_like_control_file(inf);
	}
	de_dbg(c, "is control file: %u", (UI)is_control_file);
	if(is_control_file) {
		control_file_seq = (int)dbuf_getbyte(inf, 9);
		de_dbg(c, "seq num: %d", control_file_seq);

		last_disk_marker = dbuf_getbyte(inf, 0x8a);
		de_dbg(c, "last disk marker: 0x%02x", (UI)last_disk_marker);
		if((last_disk_marker==0 && control_file_seq==d->v33_num_volumes) ||
			(last_disk_marker!=0 && control_file_seq!=d->v33_num_volumes))
		{
			d->errflag = 1;
			d->need_errmsg = 1;
			goto done;
		}

		// We could pretty easily support out-of-order control files, but
		// that's probably a bad idea if we're not also supporting out-of-order
		// data files.
		if(control_file_seq != d->v33_num_control_files_found+1) {
			d->errflag = 1;
			d->need_errmsg = 1;
			goto done;
		}
		d->v33_control_file_xidxs[control_file_seq - 1] = xidx;
		d->v33_num_control_files_found++;
	}
	else {
		if(d->v33_num_data_files_found >= d->v33_num_volumes) {
			d->errflag = 1;
			d->need_errmsg = 1;
			goto done;
		}
		d->data_file_xidxs[d->v33_num_data_files_found] = xidx;
		d->v33_num_data_files_found++;
	}

done:
	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)
movb $0x0, -0x1d(%rbp)
movb $0x0, -0x1e(%rbp)
movl $0x0, -0x24(%rbp)
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %edx
leaq 0x13da68(%rip), %rsi    # 0x1aa60c
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x10(%rbp), %rax
movl 0x14(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x6cbd5
movq -0x18(%rbp), %rdi
callq 0x6cd30
movb %al, -0x1d(%rbp)
movq -0x8(%rbp), %rdi
movzbl -0x1d(%rbp), %edx
leaq 0x13da38(%rip), %rsi    # 0x1aa61c
movb $0x0, %al
callq 0x15b0d0
cmpb $0x0, -0x1d(%rbp)
je 0x6cccd
movq -0x18(%rbp), %rdi
movl $0x9, %esi
callq 0x165060
movzbl %al, %eax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rdi
movl -0x24(%rbp), %edx
leaq 0x13da19(%rip), %rsi    # 0x1aa630
movb $0x0, %al
callq 0x15b0d0
movq -0x18(%rbp), %rdi
movl $0x8a, %esi
callq 0x165060
movb %al, -0x1e(%rbp)
movq -0x8(%rbp), %rdi
movzbl -0x1e(%rbp), %edx
leaq 0x13d9fe(%rip), %rsi    # 0x1aa63c
movb $0x0, %al
callq 0x15b0d0
movzbl -0x1e(%rbp), %eax
cmpl $0x0, %eax
jne 0x6cc5a
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0xc(%rcx), %eax
je 0x6cc6f
movzbl -0x1e(%rbp), %eax
cmpl $0x0, %eax
je 0x6cc84
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
cmpl 0xc(%rcx), %eax
je 0x6cc84
movq -0x10(%rbp), %rax
movb $0x1, 0x8(%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x9(%rax)
jmp 0x6cd14
movl -0x24(%rbp), %eax
movq -0x10(%rbp), %rcx
movl 0x14(%rcx), %ecx
addl $0x1, %ecx
cmpl %ecx, %eax
je 0x6cca7
movq -0x10(%rbp), %rax
movb $0x1, 0x8(%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x9(%rax)
jmp 0x6cd14
movl -0x1c(%rbp), %edx
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movl -0x24(%rbp), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movq -0x10(%rbp), %rax
movl 0x14(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x14(%rax)
jmp 0x6cd12
movq -0x10(%rbp), %rax
movl 0x18(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jl 0x6ccef
movq -0x10(%rbp), %rax
movb $0x1, 0x8(%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x9(%rax)
jmp 0x6cd14
movl -0x1c(%rbp), %edx
movq -0x10(%rbp), %rax
movq 0x28(%rax), %rax
movq -0x10(%rbp), %rcx
movslq 0x18(%rcx), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x10(%rbp), %rax
movl 0x18(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x18(%rax)
jmp 0x6cd14
movq -0x8(%rbp), %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0x15b560
addq $0x30, %rsp
popq %rbp
retq
nopl (%rax,%rax)