// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/pklite.c
// Function: analyze_decompressor
static void analyze_decompressor(deark *c, lctx *d)
{
	i64 pos;
	i64 n;
	int saved_indent_level;

	de_dbg_indent_save(c, &saved_indent_level);

	if(!d->decompr_pos && d->data_before_decoder) {
		find_decompr_pos_beta(c, d);
	}

	pos = d->decompr_pos;
	if(!pos) {
		d->errflag = 1;
		goto done;
	}
	if(pos+200 > EPBYTES_LEN) {
		d->errflag = 1;
		goto done;
	}

	de_dbg(c, "decompressor at ep+%u", (UI)pos);
	de_dbg_indent(c, 1);

	if(pkl_memmatch(&d->epbytes[pos],
		(const u8*)"\xfd\x8c\xdb\x53\x83\xc3", 6, '?', 0))
	{
		d->decompr_class = DECOMPR_CLASS_COMMON;
		n = (i64)d->epbytes[pos+6];
		n *= 16;
		d->dparams.cmpr_data_pos = d->host_ei->entry_point + ip_to_eprel(d, n);
	}
	else if(pkl_memmatch(&d->epbytes[pos],
		(const u8*)"\xfd\x8c\xdb\x53\x81\xc3", 6, '?', 0))
	{
		d->decompr_class = DECOMPR_CLASS_115;
		n = de_getu16le_direct(&d->epbytes[pos+6]);
		n *= 16;
		d->dparams.cmpr_data_pos = d->host_ei->entry_point + ip_to_eprel(d, n);
	}
	else if(pkl_memmatch(&d->epbytes[pos],
		(const u8*)"\xfd\x5f\xc7\x85????\x4f\x4f\xbe??\x03\xf2"
		"\x8b\xca\xd1\xe9\xf3", 20, '?', 0))
	{
		d->decompr_class = DECOMPR_CLASS_120SMALL;
		n = de_getu16le_direct(&d->epbytes[pos+11]);
		d->dparams.cmpr_data_pos = d->host_ei->entry_point + 2 + ip_to_eprel(d, n);
	}

	else if(pkl_memmatch(&d->epbytes[pos],
		(const u8*)"\xfd\x5f\x4f\x4f\xbe??\x03\xf2\x8b\xca\xd1\xe9\xf3", 14, '?', 0))
	{
		d->decompr_class = DECOMPR_CLASS_120SMALL_OLD;
		n = de_getu16le_direct(&d->epbytes[pos+5]);
		d->dparams.cmpr_data_pos = d->host_ei->entry_point + 2 + ip_to_eprel(d, n);
	}


	else if(pkl_memmatch(&d->epbytes[pos],
		(const u8*)"\xfc\x8c\xc8\x2e\x2b\x06??\x8e\xd8\xbf", 11, '?', 0))
	{
		d->decompr_class = DECOMPR_CLASS_BETA;
		d->dparams.cmpr_data_pos = d->host_ei->start_of_dos_code;
	}

	if(!d->decompr_class) {
		d->errflag = 1;
		goto done;
	}

	de_dbg(c, "decompressor class: %u", (UI)d->decompr_class);
	de_dbg(c, "cmpr data pos: %"I64_FMT, d->dparams.cmpr_data_pos);

done:
	de_dbg_indent_restore(c, saved_indent_level);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x24(%rbp), %rsi
callq 0x15b580
movq -0x10(%rbp), %rax
cmpq $0x0, 0x70(%rax)
jne 0x1153d2
movq -0x10(%rbp), %rax
movzbl 0x6(%rax), %eax
cmpl $0x0, %eax
je 0x1153d2
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
callq 0x115e00
movq -0x10(%rbp), %rax
movq 0x70(%rax), %rax
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x1153f1
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
jmp 0x115708
movq -0x18(%rbp), %rax
addq $0xc8, %rax
cmpq $0x3e8, %rax            # imm = 0x3E8
jle 0x11540f
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
jmp 0x115708
movq -0x8(%rbp), %rdi
movq -0x18(%rbp), %rax
movl %eax, %edx
leaq 0xaedef(%rip), %rsi     # 0x1c420f
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x10(%rbp), %rdi
addq $0x10c, %rdi            # imm = 0x10C
addq -0x18(%rbp), %rdi
leaq 0xaedda(%rip), %rsi     # 0x1c4225
movl $0x6, %edx
movl $0x3f, %ecx
xorl %r8d, %r8d
callq 0x15f6b0
cmpl $0x0, %eax
je 0x1154be
movq -0x10(%rbp), %rax
movb $0x1, 0x80(%rax)
movq -0x10(%rbp), %rax
movq -0x18(%rbp), %rcx
movzbl 0x112(%rax,%rcx), %eax
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
shlq $0x4, %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x40(%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x115ce0
movq -0x30(%rbp), %rcx
addq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x1156bb
movq -0x10(%rbp), %rdi
addq $0x10c, %rdi            # imm = 0x10C
addq -0x18(%rbp), %rdi
leaq 0xaed58(%rip), %rsi     # 0x1c422c
movl $0x6, %edx
movl $0x3f, %ecx
xorl %r8d, %r8d
callq 0x15f6b0
cmpl $0x0, %eax
je 0x115552
movq -0x10(%rbp), %rax
movb $0xf, 0x80(%rax)
movq -0x10(%rbp), %rdi
addq $0x10c, %rdi            # imm = 0x10C
movq -0x18(%rbp), %rax
addq $0x6, %rax
addq %rax, %rdi
callq 0x165260
movq %rax, -0x20(%rbp)
movq -0x20(%rbp), %rax
shlq $0x4, %rax
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x40(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x115ce0
movq -0x38(%rbp), %rcx
addq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x1156b9
movq -0x10(%rbp), %rdi
addq $0x10c, %rdi            # imm = 0x10C
addq -0x18(%rbp), %rdi
leaq 0xaeccb(%rip), %rsi     # 0x1c4233
movl $0x14, %edx
movl $0x3f, %ecx
xorl %r8d, %r8d
callq 0x15f6b0
cmpl $0x0, %eax
je 0x1155de
movq -0x10(%rbp), %rax
movb $0x33, 0x80(%rax)
movq -0x10(%rbp), %rdi
addq $0x10c, %rdi            # imm = 0x10C
movq -0x18(%rbp), %rax
addq $0xb, %rax
addq %rax, %rdi
callq 0x165260
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x40(%rax), %rax
addq $0x2, %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x115ce0
movq -0x40(%rbp), %rcx
addq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x1156b7
movq -0x10(%rbp), %rdi
addq $0x10c, %rdi            # imm = 0x10C
addq -0x18(%rbp), %rdi
leaq 0xaec54(%rip), %rsi     # 0x1c4248
movl $0xe, %edx
movl $0x3f, %ecx
xorl %r8d, %r8d
callq 0x15f6b0
cmpl $0x0, %eax
je 0x115667
movq -0x10(%rbp), %rax
movb $0x32, 0x80(%rax)
movq -0x10(%rbp), %rdi
addq $0x10c, %rdi            # imm = 0x10C
movq -0x18(%rbp), %rax
addq $0x5, %rax
addq %rax, %rdi
callq 0x165260
movq %rax, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x40(%rax), %rax
addq $0x2, %rax
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x115ce0
movq -0x48(%rbp), %rcx
addq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x1156b5
movq -0x10(%rbp), %rdi
addq $0x10c, %rdi            # imm = 0x10C
addq -0x18(%rbp), %rdi
leaq 0xaebda(%rip), %rsi     # 0x1c4257
movl $0xb, %edx
movl $0x3f, %ecx
xorl %r8d, %r8d
callq 0x15f6b0
cmpl $0x0, %eax
je 0x1156b3
movq -0x10(%rbp), %rax
movb $0x9, 0x80(%rax)
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rax
movq 0x38(%rax), %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
jmp 0x1156b5
jmp 0x1156b7
jmp 0x1156b9
jmp 0x1156bb
movq -0x10(%rbp), %rax
cmpb $0x0, 0x80(%rax)
jne 0x1156d1
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
jmp 0x115708
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x80(%rax), %edx
leaq 0xaeb7c(%rip), %rsi     # 0x1c4263
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdx
leaq 0x9c768(%rip), %rsi     # 0x1b1e69
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl -0x24(%rbp), %esi
callq 0x15b5a0
addq $0x50, %rsp
popq %rbp
retq
nopw (%rax,%rax)