// File: /workspace/github_c_makefile_star2_O3/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 0xfd4b2
movq %rax, %r14
movl $0x1, 0x10(%rax)
movq %rbx, %rdi
xorl %esi, %esi
movl $0xd, %edx
callq 0xeb220
movl %eax, 0x18(%r14)
movq 0x18(%rbx), %rdi
movl $0x1, %esi
callq 0xeead3
cmpb $0x50, %al
je 0x6e4ff
movzbl %al, %eax
cmpl $0x44, %eax
jne 0x6e637
movl $0x1, 0x58(%r14)
movq 0x18(%rbx), %rax
cmpq $0x21, 0x18(%rax)
jl 0x6e648
xorl %r13d, %r13d
xorl %r15d, %r15d
testq %r15, %r15
je 0x6e4a2
movq %rbx, %rdi
movq %r15, %rsi
callq 0xfd460
movq %rbx, %rdi
movq %r14, %rsi
callq 0xfd414
movq %rax, %r15
movq %r13, 0x18(%rax)
movq 0x18(%rbx), %rdi
leaq 0x4(%r13), %rsi
callq 0xeed61
movq %rax, %r12
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x71445
testl %eax, %eax
je 0x6e4ef
leaq (%r12,%r13), %rax
addq $0x40, %rax
addq %r12, %r13
addq $0x20, %r13
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jl 0x6e492
movq %rbx, %rdi
movq %r15, %rsi
callq 0xfd460
jmp 0x6e648
movl $0x2, 0x58(%r14)
movq 0x18(%rbx), %rdi
movl $0x8, %esi
callq 0xeead3
cmpb $0x2, %al
jne 0x6e637
cmpl $0x1, 0x58(%r14)
je 0x6e47d
movq %rsp, %r15
movq $0x2, (%r15)
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xeebeb
movq %rax, 0x20(%r14)
leaq 0xa61ee(%rip), %rsi     # 0x114737
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq 0x18(%rbx), %rdi
movq %r15, %rsi
callq 0xeed83
movq %rax, %r15
leaq 0xb1d13(%rip), %rsi     # 0x12027f
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe8617
movq %rbx, %rdi
movl $0x10, %esi
callq 0xeb499
movq %rax, 0x30(%r14)
leaq 0xcb654(%rip), %rsi     # 0x139be5
movl $0x10, %edx
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe8617
leaq 0x10(%r15), %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jg 0x6e648
movq $0x10, (%rsp)
cmpq $0x10, %r15
jl 0x6e648
cmpq $0x0, 0x20(%r14)
jle 0x6e648
movl $0x1, %ebp
xorl %r13d, %r13d
movq %rsp, %r12
testq %r13, %r13
je 0x6e5e6
movq %rbx, %rdi
movq %r13, %rsi
callq 0xfd460
movq %rbx, %rdi
movq %r14, %rsi
callq 0xfd414
movq %rax, %r13
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xeed83
movq %rax, 0x18(%r13)
movq %rbx, %rdi
movq %r14, %rsi
movq %r13, %rdx
callq 0x71445
movq (%rsp), %rax
addq $0xc, %rax
movq %rax, (%rsp)
cmpq 0x20(%r14), %rbp
jge 0x6e62c
incq %rbp
cmpq %r15, %rax
jle 0x6e5d6
movq %rbx, %rdi
movq %r13, %rsi
jmp 0x6e4f5
leaq 0xb7b2f(%rip), %rsi     # 0x12616d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9295
movq %rbx, %rdi
movq %r14, %rsi
callq 0xfd4cd
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq