// File: /workspace/github_c_makefile_star2_O2/jsummers[P]deark/modules/misc3.c
// Function: de_run_qip
static void de_run_qip(deark *c, de_module_params *mparams)
{
	de_arch_lctx *d = NULL;
	u8 b;
	int unsupp_flag = 0;

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

	b = de_getbyte(1);
	if(b=='P') {
		d->fmtver = 2;
	}
	else if(b=='D') {
		d->fmtver = 1;
	}
	else {
		unsupp_flag = 1;
		goto done;
	}

	if(d->fmtver==2) {
		if(de_getbyte(8)!=0x02) {
			unsupp_flag = 1;
			goto done;
		}
	}

	if(d->fmtver==1) {
		qip_do_v1(c, d);
	}
	else {
		qip_do_v2(c, d);
	}

done:
	if(unsupp_flag) {
		de_err(c, "Not a supported QIP format");
	}
	de_arch_destroy_lctx(c, d);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
callq 0xf16ce
movq %rax, %r14
movl $0x1, 0x10(%rax)
pushq $0xd
popq %rdx
movq %rbx, %rdi
xorl %esi, %esi
callq 0xe08d2
movl %eax, 0x18(%r14)
movq 0x18(%rbx), %rdi
pushq $0x1
popq %rsi
callq 0xe3eb4
cmpb $0x50, %al
je 0x6a7b0
movzbl %al, %eax
cmpl $0x44, %eax
jne 0x6a8d0
movl $0x1, 0x58(%r14)
xorl %r15d, %r15d
xorl %r12d, %r12d
leaq 0x20(%r12), %r13
movq 0x18(%rbx), %rax
cmpq 0x18(%rax), %r13
jge 0x6a8e3
testq %r15, %r15
je 0x6a771
movq %rbx, %rdi
movq %r15, %rsi
callq 0xf167c
movq %rbx, %rdi
movq %r14, %rsi
callq 0xf1630
movq %rax, %r15
movq %r12, 0x18(%rax)
movq 0x18(%rbx), %rdi
addq $0x4, %r12
movq %r12, %rsi
callq 0xe409f
movq %rax, %r12
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x6d56a
addq %r13, %r12
testl %eax, %eax
jne 0x6a74e
jmp 0x6a8e8
movl $0x2, 0x58(%r14)
movq 0x18(%rbx), %rdi
pushq $0x8
popq %rsi
callq 0xe3eb4
cmpb $0x2, %al
jne 0x6a8d0
cmpl $0x1, 0x58(%r14)
je 0x6a748
movq %rsp, %r15
movq $0x2, (%r15)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe3fc4
movq %rax, 0x20(%r14)
leaq 0x9ceb4(%rip), %rsi     # 0x1076ac
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xe40bf
movq %rax, %r15
leaq 0xa8972(%rip), %rsi     # 0x11318d
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xde896
pushq $0x10
popq %rsi
movq %rbx, %rdi
callq 0xe0ae9
movq %rax, 0x30(%r14)
leaq 0xc2097(%rip), %rsi     # 0x12c8d5
pushq $0x10
popq %rbp
movq %rbx, %rdi
movq %rbp, %rdx
xorl %eax, %eax
callq 0xde896
leaq 0x10(%r15), %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jg 0x6a8f3
movq %rsp, %rax
movq $0x10, (%rax)
xorl %r12d, %r12d
xorl %r13d, %r13d
cmpq 0x20(%r14), %r12
jge 0x6a90d
cmpq %r15, %rbp
jg 0x6a90d
testq %r13, %r13
je 0x6a893
movq %rbx, %rdi
movq %r13, %rsi
callq 0xf167c
movq %rbx, %rdi
movq %r14, %rsi
callq 0xf1630
movq %rax, %r13
movq 0x18(%rbx), %rdi
movq %rsp, %rsi
callq 0xe40bf
movq %rax, 0x18(%r13)
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x6d56a
movq (%rsp), %rbp
addq $0xc, %rbp
movq %rbp, (%rsp)
incq %r12
jmp 0x6a870
leaq 0xae696(%rip), %rsi     # 0x118f6d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xdf2a5
jmp 0x6a8f3
testq %r15, %r15
je 0x6a8f3
movq %rbx, %rdi
movq %r15, %rsi
callq 0xf167c
movq %rbx, %rdi
movq %r14, %rsi
callq 0xf16e7
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testq %r13, %r13
je 0x6a8f3
movq %rbx, %rdi
movq %r13, %rsi
jmp 0x6a8ee