// File: /workspace/github_c_makefile_star2_O1/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 0xfdb0a
movq %rax, %r14
movl $0x1, 0x10(%rax)
movq %rbx, %rdi
xorl %esi, %esi
movl $0x9, %edx
callq 0xeb7d1
movl %eax, 0x18(%r14)
movq 0x18(%rbx), %rdi
movl $0x4, %esi
callq 0xef1ca
movl %eax, 0x58(%r14)
movl %eax, %ebp
shrl $0x8, %ebp
leaq 0xb696b(%rip), %rsi     # 0x126101
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
cmpl $0x2, %ebp
je 0x6f8bc
cmpl $0x1, %ebp
jne 0x6fa6f
leaq 0x10(%rsp), %r13
movq $0x0, (%r13)
leaq 0xc(%rsp), %rsi
movq %rbx, %rdi
callq 0xe958c
movq %rbx, %rdi
movq %r14, %rsi
callq 0xfda6c
movq %rax, %r15
movq %rsp, %rbp
movq $0x6, (%rbp)
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xef1ed
movq %rax, %r12
leaq 0xb6934(%rip), %rsi     # 0x126131
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xef3a0
movl %eax, 0x60(%r14)
leaq 0xb6ddd(%rip), %rsi     # 0x1265fe
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe9226
movq (%rbp), %rcx
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
movq %r13, %r8
callq 0x71e97
movq %r12, (%rbp)
movq 0x18(%rbx), %rdi
movq %rbp, %rsi
callq 0xef34e
cmpl $0x43484e4b, %eax       # imm = 0x43484E4B
jne 0x6fa76
movq %rsp, %r13
addq $0x2, (%r13)
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xef1ed
movq %rax, %rbp
leaq 0xb68c8(%rip), %rsi     # 0x126143
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
addq $0x4, (%r13)
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xef3a0
addq %rbp, %r12
movq %r12, 0x40(%r15)
leaq 0xc7e4c(%rip), %rsi     # 0x1376f3
movq %rbx, %rdi
movq %r12, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0xe9226
jmp 0x6fa7b
movq %rsp, %r15
movq $0x0, (%r15)
leaq 0xc(%rsp), %rsi
movq %rbx, %rdi
callq 0xe958c
movq 0x18(%rbx), %rdi
movl $0x6, %esi
callq 0xef1ca
movq %rax, %r12
leaq 0xb6846(%rip), %rsi     # 0x126131
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq %r12, (%r15)
leaq 0xcbee1(%rip), %r12     # 0x13b7e3
xorl %r13d, %r13d
movq $0x0, 0x10(%rsp)
movq (%rsp), %rdx
movq 0x18(%rbx), %rax
cmpq 0x18(%rax), %rdx
jge 0x6fa32
movq %rbx, %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0xe9226
testq %r13, %r13
je 0x6f93d
movq %rbx, %rdi
movq %r13, %rsi
callq 0xfdab8
movq %rbx, %rdi
movq %r14, %rsi
callq 0xfda6c
movq %rax, %r13
movq (%rsp), %rax
movq %rax, 0x18(%r13)
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe9585
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xef34e
cmpl $0x424c434b, %eax       # imm = 0x424C434B
jne 0x6fa36
addq $0x2, (%rsp)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xef1ed
movq %rax, %rbp
movq %rbx, %rdi
leaq 0xb6802(%rip), %rsi     # 0x126197
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
addq $0x4, (%rsp)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xef3a0
movq %r12, %r15
movq %rax, %r12
movq %rbx, %rdi
leaq 0xb67ea(%rip), %rsi     # 0x1261aa
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%r13), %rcx
addq $0x10, %rcx
movq %rcx, (%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
leaq 0x10(%rsp), %r8
callq 0x71e97
movq (%rsp), %rdx
addq 0x10(%rsp), %rdx
movq %rdx, (%rsp)
movq %rdx, 0x40(%r13)
movq 0x30(%r13), %rcx
movq %rbx, %rdi
leaq 0xc7ceb(%rip), %rsi     # 0x1376f3
xorl %eax, %eax
callq 0xe9226
addq %rbp, %r12
addq 0x18(%r13), %r12
movq %r12, (%rsp)
movq %r15, %r12
movq %rsp, %r15
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe9585
movb $0x1, %bpl
jmp 0x6fa4d
xorl %ebp, %ebp
jmp 0x6fa4d
movq 0x18(%r13), %rdx
xorl %ebp, %ebp
movq %rbx, %rdi
leaq 0xb673a(%rip), %rsi     # 0x126180
xorl %eax, %eax
callq 0xe9226
testb %bpl, %bpl
jne 0x6f905
movl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0xe9595
testq %r13, %r13
je 0x6fa92
movq %rbx, %rdi
movq %r13, %rsi
jmp 0x6fa8d
movb $0x1, 0x14(%r14)
jmp 0x6fa92
movb $0x1, 0x14(%r14)
movl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0xe9595
movq %rbx, %rdi
movq %r15, %rsi
callq 0xfdab8
testq %r14, %r14
je 0x6faba
cmpb $0x0, 0x14(%r14)
je 0x6faaf
leaq 0xb666f(%rip), %rsi     # 0x126114
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9df7
movq %rbx, %rdi
movq %r14, %rsi
callq 0xfdb25
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq