// File: /workspace/github_c_makefile_star2_O1/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %edx, 0x1c(%rsp)
movq %rsi, %rbx
movq %rdi, %r13
movq 0x18(%rdi), %rdi
leaq 0xd(%rsp), %r15
movl $0x3, %ecx
movq %r15, %rsi
xorl %edx, %edx
callq 0xeeee8
movzbl (%r15), %eax
addl $0xffffff45, %eax       # imm = 0xFFFFFF45
cmpl $0x30, %eax
ja 0x63b9d
movabsq $0x1600000000001, %rcx  # imm = 0x1600000000001
btq %rax, %rcx
jae 0x63b9d
movq %rbx, 0x20(%rsp)
xorl %r15d, %r15d
leaq 0xc01bf(%rip), %r12     # 0x123c50
xorl %ebp, %ebp
movq %r13, 0x10(%rsp)
movb (%r15,%r12), %al
cmpb %al, 0xd(%rsp)
jne 0x63b2d
movb 0xe(%rsp), %cl
cmpb 0x1(%r15,%r12), %cl
jne 0x63b2d
cmpb $-0x15, %al
je 0x63ac0
movb 0xf(%rsp), %al
cmpb 0x2(%r15,%r12), %al
jne 0x63b2d
leaq (%r12,%r15), %rbx
movzbl 0x3(%r15,%r12), %r14d
movl %r14d, %eax
andl $0x3, %eax
cmpl $0x2, %eax
je 0x63b0c
cmpl $0x1, %eax
jne 0x63b2d
movq 0x18(%r13), %rdi
movzwl 0x4(%r15,%r12), %r13d
movl $0xc, %ecx
movq %r13, %rsi
leaq 0xbfe95(%rip), %rdx     # 0x123988
callq 0xf025e
testl %eax, %eax
jne 0x63b05
testb $0x40, %r14b
jne 0x63b48
movq %rbx, %rbp
movq 0x10(%rsp), %r13
jmp 0x63b2d
movq 0x18(%r13), %rdi
movzwl 0x4(%r15,%r12), %esi
movl $0x7, %ecx
leaq 0xbfe73(%rip), %rdx     # 0x123995
callq 0xf025e
testl %eax, %eax
cmoveq %rbx, %rbp
testq %rbp, %rbp
jne 0x63b71
leaq 0xc(%r15), %rax
cmpq $0x174, %r15            # imm = 0x174
movq %rax, %r15
jne 0x63a98
jmp 0x63b71
movq 0x10(%rsp), %rax
movq 0x18(%rax), %rdi
addq $-0x2, %r13
movq %r13, %rsi
movq %rax, %r13
callq 0xef1ca
addq $-0x100, %rax
movzwl 0x6(%r15,%r12), %ecx
cmpq %rcx, %rax
jmp 0x63b29
testq %rbp, %rbp
movq 0x20(%rsp), %rcx
je 0x63b9d
movb $0x1, (%rcx)
cmpl $0x0, 0x1c(%rsp)
jne 0x63b9d
movzwl 0x6(%rbp), %eax
movq %rax, 0x8(%rcx)
movl 0x8(%rbp), %eax
movl %eax, 0x4(%rcx)
cmpb $0x0, 0x3(%rbp)
jns 0x63b9d
movb $0x1, 0x1(%rcx)
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq