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

	de_dbg_indent_save(c, &saved_indent_level);

	de_dbg(c, "intro at ep+0");
	de_dbg_indent(c, 1);

	// FIXME: We shouldn't print these opaque "class" identifiers in the
	// debug info, but for now it's better than nothing.
	de_dbg(c, "intro class/prelim: %u", d->intro_class_fmtutil);

	// Initial DX register is sometimes used as a key.
	if(pkl_memmatch(&d->epbytes[0], (const u8*)"\xb8??\xba", 4, '?', 0)) {
		d->initial_key = (UI)de_getu16le_direct(&d->epbytes[4]);
	}
	else if(pkl_memmatch(&d->epbytes[0], (const u8*)"\x50\xb8??\xba", 5, '?', 0)) {
		d->initial_key = (UI)de_getu16le_direct(&d->epbytes[5]);
	}

	if(d->intro_class_fmtutil==90) {
		d->intro_class = INTRO_CLASS_BETA;
		d->data_before_decoder = 1;
	}
	else if(d->intro_class_fmtutil==91) {
		d->intro_class = INTRO_CLASS_BETA_LH;
		d->data_before_decoder = 1;
		d->load_high = 1;
	}
	else if(d->intro_class_fmtutil==100) {
		d->intro_class = INTRO_CLASS_100;
		d->position2 = 16;
	}
	else if(d->intro_class_fmtutil==112) {
		if(d->epbytes[13]==0x73) {
			d->intro_class = INTRO_CLASS_112;
			d->position2 = 15;
		}
		else if(d->epbytes[13]==0x72) {
			d->intro_class = INTRO_CLASS_114;
			d->position2 = read_and_follow_1byte_jump(d, 14);
		}
	}
	else if(d->intro_class_fmtutil==150) {
		if(d->epbytes[14]==0x72) {
			d->intro_class = INTRO_CLASS_150;
			d->position2 = read_and_follow_1byte_jump(d, 15);
		}
	}
	else if(d->intro_class_fmtutil==250) {
		d->intro_class = INTRO_CLASS_UN2PACK;
		d->position2 = 34;
	}
	else if(d->intro_class_fmtutil==251) {
		if(d->epbytes[13]==0x72) {
			d->intro_class = INTRO_CLASS_MEGALITE;
			d->position2 = read_and_follow_1byte_jump(d, 14);
		}
	}

	if(d->data_before_decoder) return;

	if(!d->intro_class || !d->position2) {
		d->errflag = 1;
	}
	if(!d->errflag) {
		de_dbg(c, "intro class: %u", (UI)d->intro_class);
		de_dbg(c, "after intro: ep+%"I64_FMT, d->position2);
	}

	de_dbg_indent_restore(c, saved_indent_level);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x8(%rbp), %rdi
leaq -0x14(%rbp), %rsi
callq 0x15b580
movq -0x8(%rbp), %rdi
leaq 0xafa7c(%rip), %rsi     # 0x1c4054
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl $0x1, %esi
callq 0x15b560
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movl 0x30(%rax), %edx
leaq 0xafa63(%rip), %rsi     # 0x1c4062
movb $0x0, %al
callq 0x15b0d0
movq -0x10(%rbp), %rdi
addq $0x10c, %rdi            # imm = 0x10C
leaq 0xafa62(%rip), %rsi     # 0x1c407a
movl $0x4, %edx
movl $0x3f, %ecx
xorl %r8d, %r8d
callq 0x15f6b0
cmpl $0x0, %eax
je 0x11464e
movq -0x10(%rbp), %rdi
addq $0x10c, %rdi            # imm = 0x10C
addq $0x4, %rdi
callq 0x165260
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x38(%rax)
jmp 0x114696
movq -0x10(%rbp), %rdi
addq $0x10c, %rdi            # imm = 0x10C
leaq 0xafa19(%rip), %rsi     # 0x1c4079
movl $0x5, %edx
movl $0x3f, %ecx
xorl %r8d, %r8d
callq 0x15f6b0
cmpl $0x0, %eax
je 0x114694
movq -0x10(%rbp), %rdi
addq $0x10c, %rdi            # imm = 0x10C
addq $0x5, %rdi
callq 0x165260
movl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x38(%rax)
jmp 0x114696
movq -0x10(%rbp), %rax
cmpl $0x5a, 0x30(%rax)
jne 0x1146b5
movq -0x10(%rbp), %rax
movb $0x8, 0x34(%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x6(%rax)
jmp 0x114816
movq -0x10(%rbp), %rax
cmpl $0x5b, 0x30(%rax)
jne 0x1146dc
movq -0x10(%rbp), %rax
movb $0x9, 0x34(%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x6(%rax)
movq -0x10(%rbp), %rax
movb $0x1, 0x7(%rax)
jmp 0x114814
movq -0x10(%rbp), %rax
cmpl $0x64, 0x30(%rax)
jne 0x1146ff
movq -0x10(%rbp), %rax
movb $0xa, 0x34(%rax)
movq -0x10(%rbp), %rax
movq $0x10, 0x40(%rax)
jmp 0x114812
movq -0x10(%rbp), %rax
cmpl $0x70, 0x30(%rax)
jne 0x114767
movq -0x10(%rbp), %rax
movzbl 0x119(%rax), %eax
cmpl $0x73, %eax
jne 0x11472f
movq -0x10(%rbp), %rax
movb $0xc, 0x34(%rax)
movq -0x10(%rbp), %rax
movq $0xf, 0x40(%rax)
jmp 0x114762
movq -0x10(%rbp), %rax
movzbl 0x119(%rax), %eax
cmpl $0x72, %eax
jne 0x114760
movq -0x10(%rbp), %rax
movb $0xe, 0x34(%rax)
movq -0x10(%rbp), %rdi
movl $0xe, %esi
callq 0x115c90
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
jmp 0x114762
jmp 0x114810
movq -0x10(%rbp), %rax
cmpl $0x96, 0x30(%rax)
jne 0x1147a7
movq -0x10(%rbp), %rax
movzbl 0x11a(%rax), %eax
cmpl $0x72, %eax
jne 0x1147a5
movq -0x10(%rbp), %rax
movb $0x32, 0x34(%rax)
movq -0x10(%rbp), %rdi
movl $0xf, %esi
callq 0x115c90
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
jmp 0x11480e
movq -0x10(%rbp), %rax
cmpl $0xfa, 0x30(%rax)
jne 0x1147ca
movq -0x10(%rbp), %rax
movb $0x64, 0x34(%rax)
movq -0x10(%rbp), %rax
movq $0x22, 0x40(%rax)
jmp 0x11480c
movq -0x10(%rbp), %rax
cmpl $0xfb, 0x30(%rax)
jne 0x11480a
movq -0x10(%rbp), %rax
movzbl 0x119(%rax), %eax
cmpl $0x72, %eax
jne 0x114808
movq -0x10(%rbp), %rax
movb $0x65, 0x34(%rax)
movq -0x10(%rbp), %rdi
movl $0xe, %esi
callq 0x115c90
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x40(%rax)
jmp 0x11480a
jmp 0x11480c
jmp 0x11480e
jmp 0x114810
jmp 0x114812
jmp 0x114814
jmp 0x114816
movq -0x10(%rbp), %rax
cmpb $0x0, 0x6(%rax)
je 0x114822
jmp 0x114887
movq -0x10(%rbp), %rax
cmpb $0x0, 0x34(%rax)
je 0x114837
movq -0x10(%rbp), %rax
cmpq $0x0, 0x40(%rax)
jne 0x11483e
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
movq -0x10(%rbp), %rax
cmpb $0x0, (%rax)
jne 0x11487b
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movzbl 0x34(%rax), %edx
leaq 0xaf825(%rip), %rsi     # 0x1c407f
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rax
movq 0x40(%rax), %rdx
leaq 0xaf81b(%rip), %rsi     # 0x1c408f
movb $0x0, %al
callq 0x15b0d0
movq -0x8(%rbp), %rdi
movl -0x14(%rbp), %esi
callq 0x15b5a0
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)