// File: /workspace/github_c_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdi, %rbx
pushq $0x48
popq %rsi
callq 0xdecaf
movq %rax, %r14
movl $0x3, 0x4(%rax)
pushq $0xd
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0xe08d2
movl %eax, (%r14)
leaq 0xc6cd8(%rip), %rsi     # 0x1118f5
movq %rbx, %rdi
callq 0xe07f7
movq 0x30(%rbx), %rax
testq %rax, %rax
je 0x4ac5c
movl (%rax), %eax
movl %eax, %ecx
andl $0x80000001, %ecx       # imm = 0x80000001
cmpl $0x1, %ecx
jne 0x4ac5c
movq %rax, %rsi
incq %rsi
movl %esi, 0x10(%r14)
shrq %rsi
movl %esi, 0xc(%r14)
cmpl $0x1fe, %eax            # imm = 0x1FE
jb 0x4ac9b
movb $0x1, 0x9(%r14)
jmp 0x4ac7e
leaq 0xc6cb1(%rip), %rsi     # 0x111914
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
leaq 0xc6cb6(%rip), %rsi     # 0x11192a
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf37f
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4bbfc
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x4
popq %r15
movq %rbx, %rdi
movq %r15, %rdx
callq 0xdf66f
movq %rax, 0x20(%r14)
movslq 0xc(%r14), %rsi
movq %rbx, %rdi
movq %r15, %rdx
callq 0xdf66f
movq %rax, 0x28(%r14)
xorl %ecx, %ecx
movslq 0xc(%r14), %rdx
cmpq %rdx, %rcx
jge 0x4acdd
movq 0x20(%r14), %rdx
orl $-0x1, (%rdx,%rcx,4)
orl $-0x1, (%rax,%rcx,4)
incq %rcx
jmp 0x4acc3
leaq 0xc6c89(%rip), %rsi     # 0x11196d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
leaq 0x90(%rsp), %rax
andq $0x0, (%rax)
leaq 0xc6ca8(%rip), %rsi     # 0x1119a9
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
pushq $0x1
popq %rbp
movq %rbx, %rdi
movl %ebp, %esi
callq 0xdeba7
xorl %r13d, %r13d
cmpl 0x10(%r14), %r13d
jge 0x4ae62
cmpb $0x0, 0x8(%r14)
jne 0x4ae62
movq %rbx, %rdi
movl %r13d, %esi
callq 0xe10d7
movq %rax, 0x90(%rsp)
testq %rax, %rax
je 0x4ae5d
movq %rax, %r15
xorl %r12d, %r12d
movq %rbx, %rdi
leaq 0xc6c64(%rip), %rsi     # 0x1119c0
movl %r13d, %edx
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
movl %ebp, %esi
callq 0xdeba7
movl 0x14(%r14), %eax
cmpl 0xc(%r14), %eax
jge 0x4ad85
movq %r15, %rdi
callq 0x4bc67
movl %eax, %r12d
movzbl %r12b, %r12d
movq %rbx, %rdi
leaq 0xc6c3d(%rip), %rsi     # 0x1119d0
movl %r12d, %edx
xorl %eax, %eax
callq 0xde896
testb %r12b, %r12b
je 0x4ae18
movq %r15, %rdi
pushq $0x9
popq %rsi
callq 0xe3eb4
movzbl %al, %r12d
movq %rbx, %rdi
leaq 0xc6c29(%rip), %rsi     # 0x1119e4
movl %r12d, %edx
xorl %eax, %eax
callq 0xde896
movl $0x8a, %esi
movq %r15, %rdi
callq 0xe3eb4
movzbl %al, %r15d
movq %rbx, %rdi
leaq 0xc6c10(%rip), %rsi     # 0x1119f0
movl %r15d, %edx
xorl %eax, %eax
callq 0xde896
testb %r15b, %r15b
sete %al
cmpl %r12d, 0xc(%r14)
sete %cl
xorb %al, %cl
je 0x4ae30
movl 0x14(%r14), %eax
incl %eax
cmpl %r12d, %eax
jne 0x4ae30
movq 0x20(%r14), %rax
movl %r12d, %ecx
movl %r13d, -0x4(%rax,%rcx,4)
incl 0x14(%r14)
jmp 0x4ae37
movslq 0x18(%r14), %rax
cmpl 0xc(%r14), %eax
jge 0x4ae30
movq 0x28(%r14), %rcx
movl %r13d, (%rcx,%rax,4)
incl 0x18(%r14)
jmp 0x4ae37
movw $0x101, 0x8(%r14)       # imm = 0x101
movq %rbx, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
movq %rbx, %rdi
movl %r13d, %esi
leaq 0x90(%rsp), %rdx
callq 0xe1130
incl %r13d
jmp 0x4ad1b
movb $0x1, 0x8(%r14)
pushq $-0x1
popq %rsi
movq %rbx, %rdi
callq 0xdeba7
cmpb $0x0, 0x8(%r14)
jne 0x4ac7e
leaq 0xc6afb(%rip), %r15     # 0x11197a
leaq 0xc6b0c(%rip), %r12     # 0x111992
xorl %r13d, %r13d
movslq 0xc(%r14), %rax
cmpq %rax, %r13
jge 0x4aee5
movq 0x20(%r14), %rax
movl (%rax,%r13,4), %ecx
movq %rbx, %rdi
movq %r15, %rsi
movl %r13d, %edx
xorl %eax, %eax
callq 0xde9f1
movq 0x28(%r14), %rax
movl (%rax,%r13,4), %ecx
movq %rbx, %rdi
movq %r12, %rsi
movl %r13d, %edx
xorl %eax, %eax
callq 0xde9f1
movq 0x20(%r14), %rax
cmpl $0x0, (%rax,%r13,4)
js 0x4ac55
movq 0x28(%r14), %rax
cmpl $0x0, (%rax,%r13,4)
leaq 0x1(%r13), %r13
jns 0x4ae89
jmp 0x4ac55
leaq 0x28(%rsp), %rax
andq $0x0, (%rax)
leaq 0x40(%rsp), %rax
andq $0x0, (%rax)
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0xdebae
movq %rbx, %rdi
callq 0xeac74
movq %rax, 0x38(%r14)
xorl %r15d, %r15d
movq %r14, 0x20(%rsp)
movslq 0xc(%r14), %rax
cmpq %rax, %r15
jge 0x4b56b
cmpb $0x0, 0x8(%r14)
jne 0x4b56b
leaq 0x1(%r15), %r12
movq %rbx, %rdi
leaq 0xc6ad3(%rip), %rsi     # 0x111a11
movl %r12d, %edx
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq 0x20(%r14), %rax
movl (%rax,%r15,4), %esi
movq %rbx, %rdi
callq 0xe10d7
movq %rax, 0x28(%rsp)
testq %rax, %rax
je 0x4b566
movq 0x28(%r14), %rax
movl (%rax,%r15,4), %esi
movq %rbx, %rdi
callq 0xe10d7
movq %rax, 0x40(%rsp)
movq %rax, 0x38(%rsp)
testq %rax, %rax
je 0x4b566
movq %r12, 0x48(%rsp)
movq %r15, 0x50(%rsp)
movq 0x28(%rsp), %r15
movq %rbx, %rdi
leaq 0x34(%rsp), %rsi
callq 0xdebae
movq $0x0, 0x18(%rsp)
movq %r15, %rdi
xorl %esi, %esi
callq 0xe3eb4
movzbl %al, %eax
movq %rax, (%rsp)
movb $0x1, %al
movl %eax, 0xc(%rsp)
xorl %r12d, %r12d
movq %r15, 0x10(%rsp)
cmpl $0x0, 0x18(%rsp)
setle %al
cmpb $0x0, 0xc(%rsp)
sete %cl
testb %cl, %al
jne 0x4b50b
movq (%rsp), %rbp
movq 0x10(%rsp), %rax
cmpq 0x18(%rax), %rbp
jge 0x4b504
movq 0x18(%rsp), %r13
testl %r13d, %r13d
leaq 0xc6a1d(%rip), %rsi     # 0x111a2f
leaq 0xc6a06(%rip), %rax     # 0x111a1f
cmovleq %rax, %rsi
movq %rbx, %rdi
movq %rbp, %rdx
xorl %eax, %eax
callq 0xde896
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq 0x10(%rsp), %rdi
movq %rsp, %rsi
callq 0xe3f2a
movzbl %al, %r15d
movq %rbx, %rdi
leaq 0xc684c(%rip), %rsi     # 0x11189c
movq %r15, %rdx
xorl %eax, %eax
callq 0xde896
testl %r13d, %r13d
movq %rbp, 0x68(%rsp)
jle 0x4b3ed
cmpl $0x22, %r15d
jne 0x4b504
testq %r12, %r12
je 0x4b082
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4bca4
movq %rbx, %rdi
pushq $0x50
popq %rsi
callq 0xdecaf
movq %rax, %r12
movq %rax, %r14
movq (%rsp), %rsi
movq 0x20(%rsp), %rax
movl (%rax), %r9d
movq 0x10(%rsp), %rdi
pushq $0xc
popq %rcx
movq %rcx, %rdx
pushq $0x1
popq %r8
callq 0xe495c
movq %rax, 0x38(%r12)
addq $0xc, (%rsp)
movq 0x18(%rax), %rdi
callq 0xeb877
movq %rbx, %rdi
leaq 0xdbf1e(%rip), %rsi     # 0x126fee
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq %r12, 0x58(%rsp)
movq 0x38(%r12), %rax
movq 0x18(%rax), %rbp
movq 0x10(%rbp), %rax
testq %rax, %rax
movl $0x0, %ecx
cmovleq %rcx, %rax
xorl %ecx, %ecx
cmpq %rcx, %rax
je 0x4b11c
movq 0x8(%rbp), %rdx
movl (%rdx,%rcx,4), %esi
cmpl $0x5c, %esi
je 0x4b110
cmpl $0x2f, %esi
jne 0x4b117
movl $0x5f, (%rdx,%rcx,4)
incq %rcx
jmp 0x4b0fa
movq %r15, 0x60(%rsp)
movq %r14, %r12
movq %rbp, %rdi
callq 0xeaf76
testl %eax, %eax
je 0x4b13b
movq %rbp, %rdi
pushq $0x5f
popq %rsi
callq 0xeada5
movq 0x10(%rsp), %r14
movq %r14, %rdi
movq %rsp, %r15
movq %r15, %rsi
callq 0xe3f2a
movb %al, (%r12)
movzbl %al, %edx
movq %rbx, %rdi
leaq 0xc6901(%rip), %rsi     # 0x111a60
xorl %eax, %eax
callq 0xde896
movq %r14, %rdi
movq %r15, %rsi
callq 0xe40bf
movq %rax, 0x18(%r12)
movq %rbx, %rdi
leaq 0xc68f2(%rip), %rsi     # 0x111a72
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq %r14, %rdi
movq %r15, %rsi
callq 0xe3fc4
movl %eax, 0x4(%r12)
movq %rbx, %rdi
leaq 0xc68e3(%rip), %rsi     # 0x111a87
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq %r14, %rdi
movq %r15, %rsi
callq 0xe40bf
movq %rax, 0x8(%r12)
movq %rbx, %rdi
leaq 0xc68cc(%rip), %rsi     # 0x111a93
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq %r14, %rdi
movq %r15, %rsi
callq 0xe40bf
movq %rax, 0x10(%r12)
movq %rbx, %rdi
leaq 0xc68be(%rip), %rsi     # 0x111aa9
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq %r14, %rdi
movq %r15, %rsi
callq 0xe3fc4
movq %rax, %rbp
movl %ebp, 0x34(%r12)
movq %rbx, %rdi
callq 0xeac74
movq %rax, %r13
movq %rbx, %rdi
movl %ebp, %esi
movq %rax, %rdx
xorl %ecx, %ecx
callq 0xe0298
movq %r13, %rdi
callq 0xeb877
movq %rbx, %rdi
leaq 0xeb248(%rip), %rsi     # 0x13647c
movl %ebp, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0xde896
movq %r13, %rdi
callq 0xeaf3c
movq %r14, %rdi
movq %r15, %rsi
callq 0xe3fc4
movq %rax, 0x28(%r12)
movq %r14, %rdi
movq %r15, %rsi
callq 0xe3fc4
movq %rax, 0x20(%r12)
movq 0x58(%rsp), %rbp
addq $0x40, %rbp
movq 0x28(%r12), %rdx
movq %rbp, %rdi
movq %rax, %rsi
callq 0xe0110
movb $0x2, 0x41(%r12)
movq %rbp, %rdi
leaq 0x90(%rsp), %r15
movq %r15, %rsi
pushq $0x40
popq %rdx
xorl %ecx, %ecx
callq 0xe0644
movq %rbx, %rdi
leaq 0xc6816(%rip), %rsi     # 0x111abf
movq %r15, %rdx
xorl %eax, %eax
callq 0xde896
cmpl $0x2, 0x4(%r12)
movq 0x20(%rsp), %r14
movq 0x60(%rsp), %r13
jl 0x4b2d0
cmpq $0x0, 0x30(%r14)
jne 0x4b3a8
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4bccf
movq %rbx, %rdi
pushq $0x20
popq %rsi
callq 0xdecaf
movq %rax, 0x30(%r14)
movq %rbx, %rdi
callq 0xeac74
movq 0x30(%r14), %rcx
movq %rax, 0x18(%rcx)
movq 0x18(%r12), %rax
movq %rax, 0x10(%rcx)
movq %rbx, %rdi
callq 0xdfd1a
movq %rbp, %r15
movq %rax, %rbp
movq 0x30(%r14), %rax
movq 0x38(%r14), %rsi
movq 0x18(%rax), %rdi
callq 0xead71
movq 0x30(%r14), %rax
movq 0x18(%rax), %rdi
movq 0x38(%r12), %rax
movq 0x18(%rax), %rsi
callq 0xead71
movq 0x30(%r14), %rax
movq 0x18(%rax), %rdx
movq %rbx, %rdi
movq %rbp, %rsi
pushq $0x1
popq %rcx
callq 0xdfd55
movb $0x1, 0x8(%rbp)
movups (%r15), %xmm0
movups %xmm0, 0x18(%rbp)
movl 0x34(%r12), %eax
andl $0x18, %eax
cmpl $0x8, %eax
jne 0x4b36b
movb $0x1, 0xa(%rbp)
movq %rbx, %rdi
xorl %esi, %esi
movq %rbp, %rdx
xorl %ecx, %ecx
callq 0xe4e62
movq 0x30(%r14), %rcx
movq %rax, (%rcx)
movq 0x10(%r12), %rax
addq 0x8(%r12), %rax
movq 0x38(%rsp), %rcx
cmpq 0x18(%rcx), %rax
jle 0x4b39d
movw $0x101, 0x8(%r14)       # imm = 0x101
movq %rbx, %rdi
movq %rbp, %rsi
callq 0xdfd24
cmpb $0x0, 0x8(%r14)
jne 0x4b3dc
movq 0x30(%r14), %rax
testq %rax, %rax
je 0x4b3dc
movq 0x8(%r12), %rsi
movq 0x10(%r12), %rdx
movq (%rax), %rcx
movq 0x38(%rsp), %rdi
callq 0xe45f4
movq 0x10(%r12), %rax
movq 0x30(%r14), %rcx
addq %rax, 0x8(%rcx)
movq 0x18(%rsp), %rax
decl %eax
movq %rax, 0x18(%rsp)
jmp 0x4b4e8
cmpl $0x46, %r15d
jne 0x4b504
movq %r15, %r13
movq %r12, %rbp
movq 0x38(%r14), %rdi
callq 0xeac85
movq (%rsp), %rsi
movq 0x38(%r14), %rcx
movl (%r14), %r9d
movq 0x10(%rsp), %r12
movq %r12, %rdi
pushq $0x3f
popq %rdx
pushq $0x1
popq %r15
movl %r15d, %r8d
callq 0xe4c9a
addq $0x3f, (%rsp)
movq 0x38(%r14), %rdi
callq 0xeb877
movq %rbx, %rdi
leaq 0xc6600(%rip), %rsi     # 0x111a40
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x38(%r14), %rdi
movl %r15d, %esi
callq 0xf1712
movq %r12, %rdi
movq %rsp, %r15
movq %r15, %rsi
callq 0xe3fc4
movq %rbx, %rdi
leaq 0xc1949(%rip), %rsi     # 0x10cdb7
movq %rax, 0x18(%rsp)
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq %r12, %rdi
movq %r15, %rsi
callq 0xe40bf
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
leaq 0x70(%rsp), %r14
movq %r14, %rdi
cmpq %rcx, %rax
jne 0x4b4b2
leaq 0xe9085(%rip), %rsi     # 0x134525
pushq $0x14
popq %rdx
callq 0xde492
movl $0x0, 0xc(%rsp)
jmp 0x4b4cc
pushq $0x14
popq %rsi
leaq 0xd10e5(%rip), %rdx     # 0x11c5a1
movq %rax, %rcx
xorl %eax, %eax
callq 0xde40c
movb $0x1, %al
movl %eax, 0xc(%rsp)
movq %rbx, %rdi
leaq 0xc6579(%rip), %rsi     # 0x111a4f
movq %r14, %rdx
xorl %eax, %eax
callq 0xde896
movq %rbp, %r12
movq 0x20(%rsp), %r14
movq 0x68(%rsp), %rax
addq %r13, %rax
movq %rax, (%rsp)
movq %rbx, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
jmp 0x4afd8
movw $0x101, 0x8(%r14)       # imm = 0x101
movq %rbx, %rdi
movq %r12, %rsi
callq 0x4bca4
movl 0x34(%rsp), %esi
movq %rbx, %rdi
callq 0xdebb7
movq 0x20(%r14), %rax
movq 0x50(%rsp), %r15
movl (%rax,%r15,4), %esi
movq %rbx, %rdi
leaq 0x28(%rsp), %rdx
callq 0xe1130
movq 0x28(%r14), %rax
movl (%rax,%r15,4), %esi
movq %rbx, %rdi
leaq 0x40(%rsp), %rdx
callq 0xe1130
movq %rbx, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
movq 0x48(%rsp), %r15
jmp 0x4af18
movb $0x1, 0x8(%r14)
movl 0x30(%rsp), %esi
movq %rbx, %rdi
callq 0xdebb7
jmp 0x4ac7e