// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/misc3.c
// Function: de_run_arcv
static void de_run_arcv(deark *c, de_module_params *mparams)
{
	de_arch_lctx *d = NULL;
	UI ver_maj;

	d = de_arch_create_lctx(c);
	d->is_le = 1;
	d->input_encoding = de_get_input_encoding(c, NULL, DE_ENCODING_WINDOWS1252);

	d->fmtver = (int)de_getu16le(4);
	ver_maj = (UI)d->fmtver >> 8;
	de_dbg(c, "format ver: 0x%04x", (UI)d->fmtver);
	if(ver_maj==1) {
		do_arcv_v1(c, d);
	}
	else if(ver_maj==2) {
		do_arcv_v2(c, d);
	}
	else {
		d->need_errmsg = 1;
		goto done;
	}

done:
	if(d) {
		if(d->need_errmsg) {
			de_err(c, "Bad or unsupported ARCV file");
		}
		de_arch_destroy_lctx(c, d);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
callq 0xf16ce
movq %rax, %r14
movl $0x1, 0x10(%rax)
pushq $0x9
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0xe08d2
movl %eax, 0x18(%r14)
movq 0x18(%rbx), %rdi
pushq $0x4
popq %rsi
callq 0xe3fa3
movl %eax, 0x58(%r14)
movl %eax, %ebp
shrl $0x8, %ebp
leaq 0xad9cf(%rip), %rsi     # 0x119131
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
cmpl $0x2, %ebp
je 0x6b87d
cmpl $0x1, %ebp
jne 0x6b9db
leaq 0xc(%rsp), %rsi
movq %rbx, %rdi
callq 0xdebae
movq %rbx, %rdi
movq %r14, %rsi
callq 0xf1630
movq %rax, %r15
movq %rsp, %r13
movq $0x6, (%r13)
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe3fc4
movq %rax, %r12
leaq 0xad9a5(%rip), %rsi     # 0x119161
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe40bf
movl %eax, 0x60(%r14)
leaq 0xade4e(%rip), %rsi     # 0x11962e
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xde896
movq (%r13), %rcx
leaq 0x10(%rsp), %r8
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x6dd31
movq %r12, (%r13)
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe4071
cmpl $0x43484e4b, %eax       # imm = 0x43484E4B
jne 0x6b9e2
movq %rsp, %r13
addq $0x2, (%r13)
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe3fc4
movq %rax, %rbp
leaq 0xad937(%rip), %rsi     # 0x119173
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
addq $0x4, (%r13)
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xe40bf
addq %rbp, %r12
movq %r12, 0x40(%r15)
leaq 0xbef33(%rip), %rsi     # 0x12a79b
movq %rbx, %rdi
movq %r12, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0xde896
jmp 0x6b9e7
leaq 0xc(%rsp), %rsi
movq %rbx, %rdi
callq 0xdebae
movq 0x18(%rbx), %rdi
pushq $0x6
popq %rsi
callq 0xe3fa3
movq %rax, %rbp
leaq 0xad8c1(%rip), %rsi     # 0x119161
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq %rsp, %r12
movq %rbp, (%r12)
xorl %r15d, %r15d
andq $0x0, 0x10(%rsp)
movq 0x18(%rbx), %rax
cmpq 0x18(%rax), %rbp
jge 0x6ba15
movq %rbx, %rdi
leaq 0xc2f98(%rip), %rsi     # 0x12e86d
movq %rbp, %rdx
xorl %eax, %eax
callq 0xde896
testq %r15, %r15
je 0x6b8ef
movq %rbx, %rdi
movq %r15, %rsi
callq 0xf167c
movq %rbx, %rdi
movq %r14, %rsi
callq 0xf1630
movq %rax, %r15
movq (%rsp), %rax
movq %rax, 0x18(%r15)
movq %rbx, %rdi
pushq $0x1
popq %rsi
callq 0xdeba7
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xe4071
cmpl $0x424c434b, %eax       # imm = 0x424C434B
jne 0x6ba00
addq $0x2, (%rsp)
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xe3fc4
movq %rax, %rbp
movq %rbx, %rdi
leaq 0xad882(%rip), %rsi     # 0x1191c7
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
addq $0x4, (%rsp)
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xe40bf
movq %rax, %r13
movq %rbx, %rdi
leaq 0xad86d(%rip), %rsi     # 0x1191da
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x18(%r15), %rcx
addq $0x10, %rcx
movq %rcx, (%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
leaq 0x10(%rsp), %r8
callq 0x6dd31
movq (%rsp), %rdx
addq 0x10(%rsp), %rdx
movq %rdx, (%rsp)
movq %rdx, 0x40(%r15)
movq 0x30(%r15), %rcx
movq %rbx, %rdi
leaq 0xbede6(%rip), %rsi     # 0x12a79b
xorl %eax, %eax
callq 0xde896
addq %rbp, %r13
addq 0x18(%r15), %r13
movq %r13, (%rsp)
movq %rbx, %rdi
pushq $-0x1
popq %rsi
callq 0xdeba7
movq (%rsp), %rbp
jmp 0x6b8b7
movb $0x1, 0x14(%r14)
jmp 0x6ba36
movb $0x1, 0x14(%r14)
movl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0xdebb7
movq %rbx, %rdi
movq %r15, %rsi
callq 0xf167c
jmp 0x6ba36
movq 0x18(%r15), %rdx
leaq 0xad7a5(%rip), %rsi     # 0x1191b0
movq %rbx, %rdi
xorl %eax, %eax
callq 0xde896
movl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0xdebb7
testq %r15, %r15
je 0x6ba31
movq %rbx, %rdi
movq %r15, %rsi
callq 0xf167c
testq %r14, %r14
je 0x6ba59
cmpb $0x0, 0x14(%r14)
je 0x6ba4e
leaq 0xad700(%rip), %rsi     # 0x119144
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
movq %rbx, %rdi
movq %r14, %rsi
callq 0xf16e7
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq