// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/pklite.c
// Function: analyze_detect_extra_cmpr
static void analyze_detect_extra_cmpr(deark *c, lctx *d)
{
	int ret;
	i64 foundpos;

	if(d->decompr_pos==0 || d->approx_end_of_decompressor==0) {
		d->errflag = 1;
		goto done;
	}

	ret = pkl_search_match(d->epbytes, EPBYTES_LEN,
		d->decompr_pos, d->approx_end_of_decompressor,
		(const u8*)"\xad\x95\xb2\x10\x72\x08\xa4\xd1\xed\x4a\x74", 11, 0x3f,
		0, &foundpos);
	if(ret) {
		d->dparams.extra_cmpr = 0;
		goto done;
	}

	ret = pkl_search_match(d->epbytes, EPBYTES_LEN,
		d->decompr_pos, d->approx_end_of_decompressor,
		(const u8*)"\xad\x95\xb2\x10\x72\x0b\xac??\xaa\xd1\xed\x4a\x74", 14, 0x3f,
		0, &foundpos);
	if(ret) {
		if(d->epbytes[foundpos+7]==0x32 && d->epbytes[foundpos+8]==0xc2) {
			d->dparams.extra_cmpr = 1;
			goto done;
		}
		else if(d->epbytes[foundpos+7]==0xf6 && d->epbytes[foundpos+8]==0xd0) {
			// Customized "v1.23" format seen in files from RemoteAccess v1.11
			// BBS software by Andrew Milner / Continental Software.
			//  http://cd.textfiles.com/librisbritannia/
			//  https://archive.org/details/LibrisBritannia
			//   ... COMMUNIC/BULLETIN/3220A.ZIP
			//   ... COMMUNIC/BULLETIN/3220B.ZIP
			d->dparams.extra_cmpr = 2;
			goto done;
		}
	}

	d->errflag = 1;

done:
	if(!d->errflag) {
		de_dbg(c, "extra cmpr: %u", (UI)d->dparams.extra_cmpr);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x70(%rax)
je 0x115746
movq -0x10(%rbp), %rax
cmpq $0x0, 0x78(%rax)
jne 0x115752
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
jmp 0x115882
movq -0x10(%rbp), %rdi
addq $0x10c, %rdi            # imm = 0x10C
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rdx
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rcx
movl $0x3e8, %esi            # imm = 0x3E8
leaq 0xaeb2f(%rip), %r8      # 0x1c42a8
movl $0xb, %r9d
xorl %eax, %eax
leaq -0x20(%rbp), %rax
movl $0x3f, (%rsp)
movl $0x0, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x115d30
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x1157b4
movq -0x10(%rbp), %rax
movb $0x0, 0x18(%rax)
jmp 0x115882
movq -0x10(%rbp), %rdi
addq $0x10c, %rdi            # imm = 0x10C
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rdx
movq -0x10(%rbp), %rax
movq 0x78(%rax), %rcx
movl $0x3e8, %esi            # imm = 0x3E8
leaq 0xaead9(%rip), %r8      # 0x1c42b4
movl $0xe, %r9d
xorl %eax, %eax
leaq -0x20(%rbp), %rax
movl $0x3f, (%rsp)
movl $0x0, 0x8(%rsp)
movq %rax, 0x10(%rsp)
callq 0x115d30
movl %eax, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0x11587b
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movzbl 0x113(%rax,%rcx), %eax
cmpl $0x32, %eax
jne 0x11583f
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movzbl 0x114(%rax,%rcx), %eax
cmpl $0xc2, %eax
jne 0x11583f
movq -0x10(%rbp), %rax
movb $0x1, 0x18(%rax)
jmp 0x115882
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movzbl 0x113(%rax,%rcx), %eax
cmpl $0xf6, %eax
jne 0x115877
movq -0x10(%rbp), %rax
movq -0x20(%rbp), %rcx
movzbl 0x114(%rax,%rcx), %eax
cmpl $0xd0, %eax
jne 0x115877
movq -0x10(%rbp), %rax
movb $0x2, 0x18(%rax)
jmp 0x115882
jmp 0x115879
jmp 0x11587b
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
movq -0x10(%rbp), %rax
cmpb $0x0, (%rax)
jne 0x1158a5
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x18(%rax), %edx
leaq 0xaea25(%rip), %rsi     # 0x1c42c3
movb $0x0, %al
callq 0x15b0d0
addq $0x40, %rsp
popq %rbp
retq
nopl (%rax,%rax)