// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/dosbackup.c
// Function: de_run_dosbackup33
static void de_run_dosbackup33(deark *c, de_module_params *mparams)
{
	lctx *d = NULL;
	int v;

	d = de_malloc(c, sizeof(lctx));
	d->fmtver = DOSBK_VER_DOS33;
	d->input_encoding = de_get_input_encoding(c, NULL, DE_ENCODING_CP437);
	de_declare_fmt(c, "MS-DOS BACKUP (MS-DOS 3.3-5.x)");

	if(!c->mp_data || ((c->mp_data->count%2)!=1)) {
		// (Need an odd number of *extra* files.)
		de_err(c, "Incomplete DOS BACKUP");
		de_info(c, "Note: Must use \"-mp\" option, and list all CONTROL and "
			"BACKUP files");
		goto done;
	}

	d->num_input_files_tot = 1+c->mp_data->count;

	d->v33_num_volumes = d->num_input_files_tot/2;
	if(d->v33_num_volumes<1 || d->v33_num_volumes>DOSBK33_MAX_VOLS) {
		d->need_errmsg = 1;
		goto done;
	}

	d->v33_control_file_xidxs = de_mallocarray(c, d->v33_num_volumes, sizeof(int));
	d->data_file_xidxs = de_mallocarray(c, d->v33_num_volumes, sizeof(int));
	for(v=0; v<d->v33_num_volumes; v++) {
		d->v33_control_file_xidxs[v] = -1;
		d->data_file_xidxs[v] = -1;
	}

	de_dbg(c, "num vols: %d", d->v33_num_volumes);
	scan_input_files33(c, d);
	if(d->errflag) goto done;

	// Verify that we have all the needed files.
	for(v=0; v<d->v33_num_volumes; v++) {
		de_dbg2(c, "ctrl file_idxs[%d] = %d", v, d->v33_control_file_xidxs[v]);
		de_dbg2(c, "data file idx[%d] = %d", v, d->data_file_xidxs[v]);
		if(d->v33_control_file_xidxs[v]<0 || d->data_file_xidxs[v]<0) {
			d->need_errmsg = 1;
			goto done;
		}
	}

	dosbackup33_main(c, d);

done:
	dbk_destroy_lctx(c, d);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq $0x0, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movl $0x48, %esi
callq 0x15b780
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl $0x3, 0x4(%rax)
movq -0x8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xd, %edx
callq 0x15e4a0
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, (%rax)
movq -0x8(%rbp), %rdi
leaq 0x13e2c7(%rip), %rsi    # 0x1aa541
callq 0x15e380
movq -0x8(%rbp), %rax
cmpq $0x0, 0x30(%rax)
je 0x6c2a1
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movl (%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
cmpl $0x1, %edx
je 0x6c2ca
movq -0x8(%rbp), %rdi
leaq 0x13e2b4(%rip), %rsi    # 0x1aa560
movb $0x0, %al
callq 0x15bfb0
movq -0x8(%rbp), %rdi
leaq 0x13e2b8(%rip), %rsi    # 0x1aa576
movb $0x0, %al
callq 0x15c0c0
jmp 0x6c47f
movq -0x8(%rbp), %rax
movq 0x30(%rax), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
movl $0x2, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x18(%rbp), %rax
cmpl $0x1, 0xc(%rax)
jl 0x6c30d
movq -0x18(%rbp), %rax
cmpl $0xff, 0xc(%rax)
jle 0x6c31a
movq -0x18(%rbp), %rax
movb $0x1, 0x9(%rax)
jmp 0x6c47f
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movslq 0xc(%rax), %rsi
movl $0x4, %edx
callq 0x15c450
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x20(%rax)
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movslq 0xc(%rax), %rsi
movl $0x4, %edx
callq 0x15c450
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x28(%rax)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x6c3a0
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x1c(%rbp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x1c(%rbp), %rcx
movl $0xffffffff, (%rax,%rcx,4) # imm = 0xFFFFFFFF
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x6c363
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movl 0xc(%rax), %edx
leaq 0x13e207(%rip), %rsi    # 0x1aa5b9
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x6c8a0
movq -0x18(%rbp), %rax
cmpb $0x0, 0x8(%rax)
je 0x6c3d5
jmp 0x6c47f
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x18(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x6c472
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %edx
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x1c(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
leaq 0x13e1bd(%rip), %rsi    # 0x1aa5c6
movb $0x0, %al
callq 0x15b350
movq -0x8(%rbp), %rdi
movl -0x1c(%rbp), %edx
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x1c(%rbp), %rcx
movl (%rax,%rcx,4), %ecx
leaq 0x13e1b1(%rip), %rsi    # 0x1aa5de
movb $0x0, %al
callq 0x15b350
movq -0x18(%rbp), %rax
movq 0x20(%rax), %rax
movslq -0x1c(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jl 0x6c458
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x1c(%rbp), %rcx
cmpl $0x0, (%rax,%rcx,4)
jge 0x6c462
movq -0x18(%rbp), %rax
movb $0x1, 0x9(%rax)
jmp 0x6c47f
jmp 0x6c464
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x6c3dc
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x6c960
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rsi
callq 0x6cad0
addq $0x20, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)