// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/exectext.c
// Function: asc2com_identify
static void asc2com_identify(deark *c, struct asc2com_detection_data *idd, UI idmode)
{
	u8 buf[3];
	size_t k;
	const struct asc2com_idinfo *found_item = NULL;

	dbuf_read(c->infile, buf, 0, 3);
	if(buf[0]!=0xe8 && buf[0]!=0xe9 && buf[0]!=0xbb && buf[0]!=0xeb) return;

	for(k=0; k<DE_ARRAYCOUNT(asc2com_idinfo_arr); k++) {
		const struct asc2com_idinfo *t;
		u8 sig_type;

		t = &asc2com_idinfo_arr[k];

		if(buf[0]==t->sig1[0] && buf[1]==t->sig1[1] &&
			(t->sig1[0]==0xeb || (buf[2]==t->sig1[2])))
		{

			sig_type = t->flags & 0x03;
			if(sig_type==1) {
				if(!dbuf_memcmp(c->infile, (i64)t->sig2pos,
					(const void*)"\x49\xe3\x0e\x33\xd2\x8a\x14\xfe\xc2\x03\xf2\x49", 12))
				{
					if(t->flags & 0x40) {
						i64 tmptxtpos;

						tmptxtpos = de_getu16le((i64)t->sig2pos-2) - 0x100;
						if(tmptxtpos == t->txtpos) {
							found_item = t;
						}
					}
					else {
						found_item = t;
					}
				}
			}
			else if(sig_type==2) {
				if(!dbuf_memcmp(c->infile, (i64)t->sig2pos,
					(const void*)"ASC2COM", 7))
				{
					found_item = t;
				}
			}
		}

		if(found_item) {
			break;
		}
	}
	if(!found_item) return;
	idd->found = 1;
	if(idmode) return;

	idd->tpos = (i64)found_item->txtpos;
	idd->fmtcode = found_item->fmtcode;
	if(found_item->flags & 0x80) {
		idd->is_compressed = 1;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq $0x0, -0x28(%rbp)
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x17(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
movl $0x3, %ecx
callq 0x164d10
movzbl -0x17(%rbp), %eax
cmpl $0xe8, %eax
je 0x8e876
movzbl -0x17(%rbp), %eax
cmpl $0xe9, %eax
je 0x8e876
movzbl -0x17(%rbp), %eax
cmpl $0xbb, %eax
je 0x8e876
movzbl -0x17(%rbp), %eax
cmpl $0xeb, %eax
je 0x8e876
jmp 0x8ea31
movq $0x0, -0x20(%rbp)
cmpq $0x20, -0x20(%rbp)
jae 0x8e9df
leaq 0x120ed0(%rip), %rax    # 0x1af760
imulq $0xc, -0x20(%rbp), %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movzbl -0x17(%rbp), %eax
movq -0x30(%rbp), %rcx
movzbl (%rcx), %ecx
cmpl %ecx, %eax
jne 0x8e9c3
movzbl -0x16(%rbp), %eax
movq -0x30(%rbp), %rcx
movzbl 0x1(%rcx), %ecx
cmpl %ecx, %eax
jne 0x8e9c3
movq -0x30(%rbp), %rax
movzbl (%rax), %eax
cmpl $0xeb, %eax
je 0x8e8e5
movzbl -0x15(%rbp), %eax
movq -0x30(%rbp), %rcx
movzbl 0x2(%rcx), %ecx
cmpl %ecx, %eax
jne 0x8e9c3
movq -0x30(%rbp), %rax
movzbl 0x3(%rax), %eax
andl $0x3, %eax
movb %al, -0x31(%rbp)
movzbl -0x31(%rbp), %eax
cmpl $0x1, %eax
jne 0x8e984
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x30(%rbp), %rax
movzwl 0x4(%rax), %eax
movl %eax, %esi
leaq 0x120b80(%rip), %rdx    # 0x1af499
movl $0xc, %ecx
callq 0x166ab0
cmpl $0x0, %eax
jne 0x8e982
movq -0x30(%rbp), %rax
movzbl 0x3(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x8e978
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x30(%rbp), %rax
movzwl 0x4(%rax), %eax
movl %eax, %esi
subq $0x2, %rsi
callq 0x165280
subq $0x100, %rax            # imm = 0x100
movq %rax, -0x40(%rbp)
movq -0x40(%rbp), %rax
movq -0x30(%rbp), %rcx
movzwl 0x6(%rcx), %ecx
cmpq %rcx, %rax
jne 0x8e976
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x8e980
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x8e982
jmp 0x8e9c1
movzbl -0x31(%rbp), %eax
cmpl $0x2, %eax
jne 0x8e9bf
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x30(%rbp), %rax
movzwl 0x4(%rax), %eax
movl %eax, %esi
leaq 0x120b00(%rip), %rdx    # 0x1af4a6
movl $0x7, %ecx
callq 0x166ab0
cmpl $0x0, %eax
jne 0x8e9bd
movq -0x30(%rbp), %rax
movq %rax, -0x28(%rbp)
jmp 0x8e9bf
jmp 0x8e9c1
jmp 0x8e9c3
cmpq $0x0, -0x28(%rbp)
je 0x8e9cc
jmp 0x8e9df
jmp 0x8e9ce
movq -0x20(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x20(%rbp)
jmp 0x8e87e
cmpq $0x0, -0x28(%rbp)
jne 0x8e9e8
jmp 0x8ea31
movq -0x10(%rbp), %rax
movb $0x1, (%rax)
cmpl $0x0, -0x14(%rbp)
je 0x8e9f7
jmp 0x8ea31
movq -0x28(%rbp), %rax
movzwl 0x6(%rax), %eax
movl %eax, %ecx
movq -0x10(%rbp), %rax
movq %rcx, 0x8(%rax)
movq -0x28(%rbp), %rax
movl 0x8(%rax), %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x4(%rax)
movq -0x28(%rbp), %rax
movzbl 0x3(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x8ea31
movq -0x10(%rbp), %rax
movb $0x1, 0x1(%rax)
addq $0x40, %rsp
popq %rbp
retq
nopw (%rax,%rax)