// File: /workspace/github_c_makefile_star2_O3/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 0xfd4b2
movq %rax, %r14
movl $0x1, 0x10(%rax)
movq %rbx, %rdi
xorl %esi, %esi
movl $0x9, %edx
callq 0xeb220
movl %eax, 0x18(%r14)
movq 0x18(%rbx), %rdi
movl $0x4, %esi
callq 0xeebc8
movl %eax, 0x58(%r14)
movl %eax, %ebp
shrl $0x8, %ebp
leaq 0xb6de1(%rip), %rsi     # 0x126331
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
cmpl $0x2, %ebp
je 0x6f66b
cmpl $0x1, %ebp
jne 0x6f7e6
leaq 0xc(%rsp), %rsi
movq %rbx, %rdi
callq 0xe8a1c
movq %rbx, %rdi
movq %r14, %rsi
callq 0xfd414
movq %rax, %r15
movq %rsp, %r13
movq $0x6, (%r13)
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeebeb
movq %rax, %r12
leaq 0xb6db7(%rip), %rsi     # 0x126361
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeed83
movl %eax, 0x60(%r14)
leaq 0xb7260(%rip), %rsi     # 0x12682e
movq %rbx, %rdi
movl %eax, %edx
xorl %eax, %eax
callq 0xe8617
movq (%r13), %rcx
leaq 0x10(%rsp), %r8
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x71bf8
movq %r12, (%r13)
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeed31
cmpl $0x43484e4b, %eax       # imm = 0x43484E4B
jne 0x6f7ed
movq %rsp, %r13
addq $0x2, (%r13)
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeebeb
movq %rax, %rbp
leaq 0xb6d49(%rip), %rsi     # 0x126373
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
addq $0x4, (%r13)
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeed83
addq %rbp, %r12
movq %r12, 0x40(%r15)
leaq 0xc8425(%rip), %rsi     # 0x137a7b
movq %rbx, %rdi
movq %r12, %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0xe8617
jmp 0x6f7f2
leaq 0xc(%rsp), %rsi
movq %rbx, %rdi
callq 0xe8a1c
movq 0x18(%rbx), %rdi
movl $0x6, %esi
callq 0xeebc8
movq %rax, %r12
leaq 0xb6cd1(%rip), %rsi     # 0x126361
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq %r12, (%rsp)
movq $0x0, 0x10(%rsp)
movq 0x18(%rbx), %rax
cmpq 0x18(%rax), %r12
jge 0x6f80b
movq %rsp, %r13
xorl %r15d, %r15d
movq %rbx, %rdi
leaq 0xcc495(%rip), %rsi     # 0x13bb5d
movq %r12, %rdx
xorl %eax, %eax
callq 0xe8617
testq %r15, %r15
je 0x6f6e2
movq %rbx, %rdi
movq %r15, %rsi
callq 0xfd460
movq %rbx, %rdi
movq %r14, %rsi
callq 0xfd414
movq %rax, %r15
movq (%rsp), %rax
movq %rax, 0x18(%r15)
movq %rbx, %rdi
movl $0x1, %esi
callq 0xe8a15
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeed31
cmpl $0x424c434b, %eax       # imm = 0x424C434B
jne 0x6f819
addq $0x2, (%rsp)
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeebeb
movq %rax, %r12
movq %rbx, %rdi
leaq 0xb6c8d(%rip), %rsi     # 0x1263c7
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
addq $0x4, (%rsp)
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xeed83
movq %rax, %rbp
movq %rbx, %rdi
leaq 0xb6c78(%rip), %rsi     # 0x1263da
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%r15), %rcx
addq $0x10, %rcx
movq %rcx, (%rsp)
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
leaq 0x10(%rsp), %r8
callq 0x71bf8
movq (%rsp), %rdx
addq 0x10(%rsp), %rdx
movq %rdx, (%rsp)
movq %rdx, 0x40(%r15)
movq 0x30(%r15), %rcx
movq %rbx, %rdi
leaq 0xc82d1(%rip), %rsi     # 0x137a7b
xorl %eax, %eax
callq 0xe8617
addq %r12, %rbp
addq 0x18(%r15), %rbp
movq %rbp, (%rsp)
movq %rbx, %rdi
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
callq 0xe8a15
movq $0x0, 0x10(%rsp)
movq (%rsp), %r12
movq 0x18(%rbx), %rax
cmpq 0x18(%rax), %r12
jl 0x6f6be
jmp 0x6f82e
movb $0x1, 0x14(%r14)
jmp 0x6f84a
movb $0x1, 0x14(%r14)
movl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0xe8a25
movq %rbx, %rdi
movq %r15, %rsi
callq 0xfd460
jmp 0x6f84a
movl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0xe8a25
jmp 0x6f84a
movq 0x18(%r15), %rdx
leaq 0xb6b8c(%rip), %rsi     # 0x1263b0
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
movl 0xc(%rsp), %esi
movq %rbx, %rdi
callq 0xe8a25
movq %rbx, %rdi
movq %r15, %rsi
callq 0xfd460
testq %r14, %r14
je 0x6f86d
cmpb $0x0, 0x14(%r14)
je 0x6f862
leaq 0xb6aec(%rip), %rsi     # 0x126344
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
movq %rbx, %rdi
movq %r14, %rsi
callq 0xfd4cd
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq