// File: /workspace/github_c_makefile_star2_O1/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 0xfdb0a
movq %rax, %r14
movl $0x1, 0x10(%rax)
movq %rbx, %rdi
xorl %esi, %esi
movl $0xd, %edx
callq 0xeb7d1
movl %eax, 0x18(%r14)
movq 0x18(%rbx), %rdi
movl $0x1, %esi
callq 0xef0d5
cmpb $0x50, %al
je 0x6e66b
movzbl %al, %eax
cmpl $0x44, %eax
jne 0x6e705
movl $0x1, %eax
xorl %ecx, %ecx
jmp 0x6e672
movl $0x2, %eax
movb $0x1, %cl
movl %eax, 0x58(%r14)
testb %cl, %cl
je 0x6e68c
movq 0x18(%rbx), %rdi
movl $0x8, %esi
callq 0xef0d5
cmpb $0x2, %al
jne 0x6e705
cmpl $0x1, 0x58(%r14)
jne 0x6e71b
xorl %r15d, %r15d
xorl %r13d, %r13d
leaq 0x20(%r13), %rbp
movq 0x18(%rbx), %rax
cmpq 0x18(%rax), %rbp
jge 0x6e6fa
testq %r15, %r15
je 0x6e6bb
movq %rbx, %rdi
movq %r15, %rsi
callq 0xfdab8
movq %rbx, %rdi
movq %r14, %rsi
callq 0xfda6c
movq %rax, %r15
movq %r13, 0x18(%rax)
movq 0x18(%rbx), %rdi
leaq 0x4(%r13), %rsi
callq 0xef37e
movq %rax, %r12
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x716f8
testl %eax, %eax
setne %al
je 0x6e6fc
addq %rbp, %r12
movq %r12, %r13
jmp 0x6e6fc
xorl %eax, %eax
testb %al, %al
jne 0x6e69d
jmp 0x6e7a6
leaq 0xb7831(%rip), %rsi     # 0x125f3d
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9df7
jmp 0x6e7b6
movq %rsp, %r12
movq $0x2, (%r12)
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xef1ed
movq %rax, 0x20(%r14)
leaq 0xa5f1f(%rip), %rsi     # 0x11465c
xorl %r15d, %r15d
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq 0x18(%rbx), %rdi
movq %r12, %rsi
callq 0xef3a0
movq %rax, %r12
leaq 0xb19f4(%rip), %rsi     # 0x120157
movq %rbx, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xe9226
movq %rbx, %rdi
movl $0x10, %esi
callq 0xeba56
movq %rax, 0x30(%r14)
leaq 0xcb0bd(%rip), %rsi     # 0x139845
movl $0x10, %edx
movq %rbx, %rdi
xorl %eax, %eax
callq 0xe9226
leaq 0x10(%r12), %rax
movq 0x18(%rbx), %rcx
cmpq 0x18(%rcx), %rax
jle 0x6e7d0
testq %r15, %r15
je 0x6e7b6
movq %rbx, %rdi
movq %r15, %rsi
callq 0xfdab8
movq %rbx, %rdi
movq %r14, %rsi
callq 0xfdb25
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq $0x10, (%rsp)
xorl %r15d, %r15d
cmpq $0x10, %r12
jl 0x6e7a6
cmpq $0x0, 0x20(%r14)
jle 0x6e7a6
movl $0x1, %ebp
xorl %r15d, %r15d
movq %rsp, %r13
testq %r15, %r15
je 0x6e803
movq %rbx, %rdi
movq %r15, %rsi
callq 0xfdab8
movq %rbx, %rdi
movq %r14, %rsi
callq 0xfda6c
movq %rax, %r15
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0xef3a0
movq %rax, 0x18(%r15)
movq %rbx, %rdi
movq %r14, %rsi
movq %r15, %rdx
callq 0x716f8
movq (%rsp), %rax
addq $0xc, %rax
movq %rax, (%rsp)
cmpq 0x20(%r14), %rbp
jge 0x6e7a6
incq %rbp
cmpq %r12, %rax
jle 0x6e7f3
jmp 0x6e7a6