// File: /workspace/github_c_makefile_star2_O1/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
movl $0x48, %esi
callq 0xe969b
movq %rax, %r14
movl $0x3, 0x4(%rax)
movq %rbx, %rdi
xorl %esi, %esi
movl $0xd, %edx
callq 0xeb7d1
movl %eax, (%r14)
leaq 0xd1658(%rip), %rsi     # 0x11e8bd
movq %rbx, %rdi
callq 0xeb6d6
movq 0x30(%rbx), %rax
testq %rax, %rax
je 0x4d2a4
movl (%rax), %eax
movl %eax, %ecx
andl $0x80000001, %ecx       # imm = 0x80000001
cmpl $0x1, %ecx
jne 0x4d2a4
movq %rax, %rsi
incq %rsi
movl %esi, 0x10(%r14)
shrq %rsi
movl %esi, 0xc(%r14)
cmpl $0x1fe, %eax            # imm = 0x1FE
jb 0x4d2e3
movb $0x1, 0x9(%r14)
jmp 0x4d2c6
leaq 0xd1631(%rip), %rsi     # 0x11e8dc
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9df7
leaq 0xd1636(%rip), %rsi     # 0x11e8f2
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9ef5
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4e2d7
addq $0xd8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x4, %edx
movq %rbx, %rdi
callq 0xea259
movq %rax, 0x20(%r14)
movslq 0xc(%r14), %rsi
movl $0x4, %edx
movq %rbx, %rdi
callq 0xea259
movq %rax, 0x28(%r14)
movl 0xc(%r14), %edx
testl %edx, %edx
jle 0x4d32e
movq 0x20(%r14), %rcx
xorl %esi, %esi
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
movl %edi, (%rcx,%rsi,4)
movl %edi, (%rax,%rsi,4)
incq %rsi
movslq 0xc(%r14), %rdx
cmpq %rdx, %rsi
jl 0x4d31c
leaq 0xd1600(%rip), %rsi     # 0x11e935
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq $0x0, 0x90(%rsp)
leaq 0xd161f(%rip), %rsi     # 0x11e971
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
cmpl $0x0, 0x10(%r14)
jle 0x4d4be
leaq 0x90(%rsp), %r13
xorl %ebp, %ebp
cmpb $0x0, 0x8(%r14)
jne 0x4d4be
movq %rbx, %rdi
movl %ebp, %esi
callq 0xec0f5
movq %rax, 0x90(%rsp)
testq %rax, %rax
je 0x4d4b9
movq %rax, %r15
xorl %r12d, %r12d
movq %rbx, %rdi
leaq 0xd15d4(%rip), %rsi     # 0x11e988
movl %ebp, %edx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movl 0x14(%r14), %eax
cmpl 0xc(%r14), %eax
jge 0x4d3df
movq %r15, %rdi
callq 0x4e342
movl %eax, %r12d
movzbl %r12b, %r12d
movq %rbx, %rdi
leaq 0xd15ab(%rip), %rsi     # 0x11e998
movl %r12d, %edx
xorl %eax, %eax
callq 0xe9226
testb %r12b, %r12b
je 0x4d473
movl $0x9, %esi
movq %r15, %rdi
callq 0xef0d5
movzbl %al, %r12d
movq %rbx, %rdi
leaq 0xd1595(%rip), %rsi     # 0x11e9ac
movl %r12d, %edx
xorl %eax, %eax
callq 0xe9226
movl $0x8a, %esi
movq %r15, %rdi
callq 0xef0d5
movzbl %al, %r15d
movq %rbx, %rdi
leaq 0xd157c(%rip), %rsi     # 0x11e9b8
movl %r15d, %edx
xorl %eax, %eax
callq 0xe9226
testb %r15b, %r15b
sete %al
cmpl %r12d, 0xc(%r14)
sete %cl
xorb %al, %cl
je 0x4d48a
movl 0x14(%r14), %eax
incl %eax
cmpl %r12d, %eax
jne 0x4d48a
movq 0x20(%r14), %rax
movl %r12d, %ecx
movl %ebp, -0x4(%rax,%rcx,4)
incl 0x14(%r14)
jmp 0x4d491
movslq 0x18(%r14), %rax
cmpl 0xc(%r14), %eax
jge 0x4d48a
movq 0x28(%r14), %rcx
movl %ebp, (%rcx,%rax,4)
incl 0x18(%r14)
jmp 0x4d491
movw $0x101, 0x8(%r14)       # imm = 0x101
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movq %rbx, %rdi
movl %ebp, %esi
movq %r13, %rdx
callq 0xec15f
incl %ebp
cmpl 0x10(%r14), %ebp
jl 0x4d37e
jmp 0x4d4be
movb $0x1, 0x8(%r14)
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
cmpb $0x0, 0x8(%r14)
jne 0x4d2c6
cmpl $0x0, 0xc(%r14)
jle 0x4d548
leaq 0xd145e(%rip), %r15     # 0x11e942
leaq 0xd146f(%rip), %r12     # 0x11e95a
xorl %r13d, %r13d
movq 0x20(%r14), %rax
movl (%rax,%r13,4), %ecx
movq %rbx, %rdi
movq %r15, %rsi
movl %r13d, %edx
xorl %eax, %eax
callq 0xe93cf
movq 0x28(%r14), %rax
movl (%rax,%r13,4), %ecx
movq %rbx, %rdi
movq %r12, %rsi
movl %r13d, %edx
xorl %eax, %eax
callq 0xe93cf
movq 0x20(%r14), %rax
cmpl $0x0, (%rax,%r13,4)
js 0x4d29d
movq 0x28(%r14), %rax
cmpl $0x0, (%rax,%r13,4)
js 0x4d29d
incq %r13
movslq 0xc(%r14), %rax
cmpq %rax, %r13
jl 0x4d4ee
xorl %eax, %eax
movq %rax, 0x28(%rsp)
movq %rax, 0x48(%rsp)
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0xe958c
movq %rbx, %rdi
callq 0xf6870
movq %rax, 0x38(%r14)
cmpl $0x0, 0xc(%r14)
jle 0x4dc22
xorl %r12d, %r12d
cmpb $0x0, 0x8(%r14)
jne 0x4dc22
leaq 0x1(%r12), %r15
movq %rbx, %rdi
leaq 0xd1444(%rip), %rsi     # 0x11e9d9
movl %r15d, %edx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x20(%r14), %rax
movl (%rax,%r12,4), %esi
movq %rbx, %rdi
callq 0xec0f5
movq %rax, 0x28(%rsp)
testq %rax, %rax
je 0x4dc1d
movq 0x28(%r14), %rax
movl (%rax,%r12,4), %esi
movq %rbx, %rdi
callq 0xec0f5
movq %rax, 0x48(%rsp)
movq %rax, 0x38(%rsp)
testq %rax, %rax
je 0x4dc1d
movq %r12, 0x50(%rsp)
movq %r15, 0x58(%rsp)
movq 0x28(%rsp), %r12
movq %rbx, %rdi
leaq 0x34(%rsp), %rsi
callq 0xe958c
xorl %r15d, %r15d
movq %r12, %rdi
xorl %esi, %esi
callq 0xef0d5
movzbl %al, %eax
movq %rax, 0x10(%rsp)
movb $0x1, %cl
movq $0x0, 0x18(%rsp)
movq %r12, 0x20(%rsp)
movl $0x4, %ebp
testl %r15d, %r15d
jg 0x4d643
testb %cl, %cl
jne 0x4d643
xorl %ecx, %ecx
jmp 0x4dba9
movq 0x10(%rsp), %rdx
cmpq 0x18(%r12), %rdx
jge 0x4da57
movl %ecx, 0xc(%rsp)
testl %r15d, %r15d
leaq 0xd1396(%rip), %rsi     # 0x11e9f7
leaq 0xd137f(%rip), %rax     # 0x11e9e7
cmovleq %rax, %rsi
movq %rbx, %rdi
movq %rdx, 0x40(%rsp)
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq %r12, %rdi
leaq 0x10(%rsp), %rsi
callq 0xef14d
movzbl %al, %r13d
movq %rbx, %rdi
leaq 0xd11c1(%rip), %rsi     # 0x11e864
movq %r13, %rdx
xorl %eax, %eax
callq 0xe9226
testl %r15d, %r15d
jle 0x4da63
cmpl $0x22, %r13d
jne 0x4db25
movq %r13, 0x60(%rsp)
movq 0x18(%rsp), %r13
testq %r13, %r13
je 0x4d6e6
movq 0x38(%r13), %rsi
movq %rbx, %rdi
callq 0xf00aa
movq %rbx, %rdi
movq %r13, %rsi
callq 0xe9752
movl $0x50, %esi
movq %rbx, %rdi
callq 0xe969b
movq %rax, %r13
movq 0x10(%rsp), %rsi
movl (%r14), %r9d
movl $0xc, %edx
movl $0xc, %ecx
movq %r12, %rdi
movl $0x1, %r8d
callq 0xefe67
movq %rax, 0x38(%r13)
addq $0xc, 0x10(%rsp)
movq 0x18(%rax), %rdi
callq 0xf7557
movq %rbx, %rdi
leaq 0xe679b(%rip), %rsi     # 0x133ece
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x38(%r13), %rax
movq 0x18(%rax), %r12
movq 0x10(%r12), %rax
testq %rax, %rax
jle 0x4d772
movq 0x8(%r12), %rcx
xorl %edx, %edx
movl (%rcx,%rdx,4), %esi
cmpl $0x5c, %esi
je 0x4d763
cmpl $0x2f, %esi
jne 0x4d76a
movl $0x5f, (%rcx,%rdx,4)
incq %rdx
cmpq %rdx, %rax
jne 0x4d756
movq %r15, 0x68(%rsp)
movq %r12, %rdi
callq 0xf6bea
testl %eax, %eax
je 0x4d790
movq %r12, %rdi
movl $0x5f, %esi
callq 0xf69a2
movq 0x20(%rsp), %r15
movq %r15, %rdi
leaq 0x10(%rsp), %r12
movq %r12, %rsi
callq 0xef14d
movb %al, (%r13)
movzbl %al, %edx
movq %rbx, %rdi
leaq 0xd1272(%rip), %rsi     # 0x11ea28
xorl %eax, %eax
callq 0xe9226
movq %r15, %rdi
movq %r12, %rsi
callq 0xef3a0
movq %rax, 0x18(%r13)
movq %rbx, %rdi
leaq 0xd1264(%rip), %rsi     # 0x11ea3a
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq %r15, %rdi
movq %r12, %rsi
callq 0xef1ed
movl %eax, 0x4(%r13)
movq %rbx, %rdi
leaq 0xd1256(%rip), %rsi     # 0x11ea4f
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq %r15, %rdi
movq %r12, %rsi
callq 0xef3a0
movq %rax, 0x8(%r13)
movq %rbx, %rdi
leaq 0xd1240(%rip), %rsi     # 0x11ea5b
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq %r15, %rdi
movq %r12, %rsi
callq 0xef3a0
movq %rax, 0x10(%r13)
movq %rbx, %rdi
leaq 0xd1233(%rip), %rsi     # 0x11ea71
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq %r15, %rdi
movq %r12, %rsi
callq 0xef1ed
movq %rax, %r12
movl %r12d, 0x34(%r13)
movq %rbx, %rdi
callq 0xf6870
movq %rax, %rbp
movq %rbx, %rdi
movl %r12d, %esi
movq %rax, %rdx
xorl %ecx, %ecx
callq 0xeb03c
movq %rbp, %rdi
callq 0xf7557
movq %rbx, %rdi
leaq 0xf5b65(%rip), %rsi     # 0x1433ec
movl %r12d, %edx
movq %rax, %rcx
xorl %eax, %eax
callq 0xe9226
movq %rbp, %rdi
callq 0xf6bb0
movq %r15, %rdi
leaq 0x10(%rsp), %r12
movq %r12, %rsi
callq 0xef1ed
movq %rax, 0x28(%r13)
movq %r15, %rdi
movq %r12, %rsi
callq 0xef1ed
movq %rax, 0x20(%r13)
movq %r13, %rbp
addq $0x40, %rbp
movq 0x28(%r13), %rdx
movq %rbp, %rdi
movq %rax, %rsi
callq 0xeae33
movb $0x2, 0x41(%r13)
movl $0x40, %edx
movq %rbp, %rdi
leaq 0x90(%rsp), %r12
movq %r12, %rsi
xorl %ecx, %ecx
callq 0xeb4f8
movq %rbx, %rdi
leaq 0xd1189(%rip), %rsi     # 0x11ea87
movq %r12, %rdx
xorl %eax, %eax
callq 0xe9226
movq %r13, 0x18(%rsp)
cmpl $0x2, 0x4(%r13)
movq 0x68(%rsp), %r15
jl 0x4d924
cmpq $0x0, 0x30(%r14)
jne 0x4da03
movq %rbx, %rdi
movq %r14, %rsi
callq 0x4e3ae
movl $0x20, %esi
movq %rbx, %rdi
callq 0xe969b
movq %rax, 0x30(%r14)
movq %rbx, %rdi
callq 0xf6870
movq 0x30(%r14), %rcx
movq %rax, 0x18(%rcx)
movq 0x18(%rsp), %r13
movq 0x18(%r13), %rax
movq %rax, 0x10(%rcx)
movq %rbx, %rdi
callq 0xea9a9
movq %rax, %r12
movq 0x30(%r14), %rax
movq 0x38(%r14), %rsi
movq 0x18(%rax), %rdi
callq 0xf6969
movq 0x30(%r14), %rax
movq 0x18(%rax), %rdi
movq 0x38(%r13), %rax
movq 0x18(%rax), %rsi
callq 0xf6969
movq 0x30(%r14), %rax
movq 0x18(%rax), %rdx
movq %rbx, %rdi
movq %r12, %rsi
movl $0x1, %ecx
callq 0xea9e4
movb $0x1, 0x8(%r12)
movups (%rbp), %xmm0
movups %xmm0, 0x18(%r12)
movl 0x34(%r13), %eax
andl $0x18, %eax
cmpl $0x8, %eax
jne 0x4d9c8
movb $0x1, 0xa(%r12)
movq %rbx, %rdi
xorl %esi, %esi
movq %r12, %rdx
xorl %ecx, %ecx
callq 0xf037a
movq 0x30(%r14), %rcx
movq %rax, (%rcx)
movq 0x10(%r13), %rax
addq 0x8(%r13), %rax
movq 0x38(%rsp), %rcx
cmpq 0x18(%rcx), %rax
jle 0x4d9f8
movw $0x101, 0x8(%r14)       # imm = 0x101
movq %rbx, %rdi
movq %r12, %rsi
callq 0xea9b3
cmpb $0x0, 0x8(%r14)
jne 0x4da3c
movq 0x30(%r14), %rax
testq %rax, %rax
je 0x4da3c
movq 0x18(%rsp), %r12
movq 0x8(%r12), %rsi
movq 0x10(%r12), %rdx
movq (%rax), %rcx
movq 0x38(%rsp), %rdi
callq 0xefabc
movq 0x10(%r12), %rax
movq 0x30(%r14), %rcx
addq %rax, 0x8(%rcx)
decl %r15d
movq 0x20(%rsp), %r12
movq 0x40(%rsp), %rax
movl 0xc(%rsp), %ecx
movq 0x60(%rsp), %r13
jmp 0x4db8e
movw $0x101, 0x8(%r14)       # imm = 0x101
jmp 0x4dba9
cmpq $0x46, %r13
jne 0x4db32
movq 0x38(%r14), %rdi
callq 0xf6883
movq 0x10(%rsp), %rsi
movq 0x38(%r14), %rcx
movl (%r14), %r9d
movl $0x3f, %edx
movq %r12, %rdi
movl $0x1, %r8d
callq 0xf01b0
addq $0x3f, 0x10(%rsp)
movq 0x38(%r14), %rdi
callq 0xf7557
movq %rbx, %rdi
leaq 0xd0f5a(%rip), %rsi     # 0x11ea08
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x38(%r14), %rdi
movl $0x1, %esi
callq 0xfdb50
movq %r12, %rdi
leaq 0x10(%rsp), %rbp
movq %rbp, %rsi
callq 0xef1ed
movq %rax, %r15
movq %rbx, %rdi
leaq 0xcc2a4(%rip), %rsi     # 0x119d87
movl %r15d, %edx
xorl %eax, %eax
callq 0xe9226
movq %r12, %rdi
movq %rbp, %rsi
callq 0xef3a0
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
cmpq %rcx, %rax
jne 0x4db40
movl $0x14, %edx
leaq 0x70(%rsp), %r12
movq %r12, %rdi
leaq 0xf397f(%rip), %rsi     # 0x141495
callq 0xe8ded
movl $0x0, 0xc(%rsp)
jmp 0x4db64
movw $0x101, 0x8(%r14)       # imm = 0x101
movl 0xc(%rsp), %ecx
jmp 0x4dba9
movw $0x101, 0x8(%r14)       # imm = 0x101
movl $0x4, %ebp
jmp 0x4db7f
movl $0x14, %esi
leaq 0x70(%rsp), %r12
movq %r12, %rdi
leaq 0xdba5d(%rip), %rdx     # 0x1295b1
movq %rax, %rcx
xorl %eax, %eax
callq 0xe8d67
movb $0x1, %al
movl %eax, 0xc(%rsp)
xorl %ebp, %ebp
movq %rbx, %rdi
leaq 0xd0ea7(%rip), %rsi     # 0x11ea17
movq %r12, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x20(%rsp), %r12
cmpb $0x46, %r13b
movq 0x40(%rsp), %rax
movl 0xc(%rsp), %ecx
jne 0x4dba9
addq %r13, %rax
movq %rax, 0x10(%rsp)
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl %ecx, %ebp
callq 0xe9585
movl %ebp, %ecx
xorl %ebp, %ebp
testl %ebp, %ebp
je 0x4d62e
movq %rbx, %rdi
movq 0x18(%rsp), %rsi
callq 0x4e383
movl 0x34(%rsp), %esi
movq %rbx, %rdi
callq 0xe9595
movq 0x20(%r14), %rax
movq 0x50(%rsp), %r15
movl (%rax,%r15,4), %esi
movq %rbx, %rdi
leaq 0x28(%rsp), %rdx
callq 0xec15f
movq 0x28(%r14), %rax
movl (%rax,%r15,4), %esi
movq %rbx, %rdi
leaq 0x48(%rsp), %rdx
callq 0xec15f
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movslq 0xc(%r14), %rax
movq 0x58(%rsp), %rcx
movq %rcx, %r12
cmpq %rax, %rcx
jl 0x4d57b
jmp 0x4dc22
movb $0x1, 0x8(%r14)
movl 0x30(%rsp), %esi
movq %rbx, %rdi
callq 0xe9595
jmp 0x4d2c6