// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/bintext.c
// Function: de_identify_thedraw_com
static int de_identify_thedraw_com(deark *c)
{
	u8 n1, n2;

	if(c->infile->len>65280) return 0;
	n1 = de_getbyte(0);
	if(n1!=0xeb) return 0;

	n1 = de_getbyte(1);
	n2 = de_getbyte(6);
	// Check format subtype & viewer start position.
	if((n2==0 && n1==0x3d) ||
		(n2==1 && n1==0x18) ||
		(n2==2 && n1==0x3d))
	{
		;
	}
	else {
		return 0;
	}

	if(!dbuf_memcmp(c->infile, 9, (const void*)"TheDraw COM file", 16)) {
		return 100;
	}

	if(n2==0) {
		if(!dbuf_memcmp(c->infile, 0x3f,
			(const void*)"\xb4\x0f\xcd\x10\x8c\xcb\x8e\xdb\xbb\x00", 10))
		{
			// An extra check to defend against lookalike formats, particularly
			// P-Screen (search for pscrn_55.zip).
			if(de_getbyte(0x3f+76)==0xad) {
				return 40;
			}
		}
	}
	else if(n2==1) {
		if(!dbuf_memcmp(c->infile, 0x1a,
			(const void*)"\xb4\x0f\xcd\x10\x8b\x3e\x07\x01\xbe\x5e", 10))
		{
			return 40;
		}
	}
	else if(n2==2) {
		if(!dbuf_memcmp(c->infile, 0x3f,
			(const void*)"\xb4\x0f\xcd\x10\xbb\x00\xb8\x3c\x02\x74", 10))
		{
			return 40;
		}
	}

	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x20, %rsp
movq %rdi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rax
cmpq $0xff00, 0x18(%rax)     # imm = 0xFF00
jle 0x3fe9a
movl $0x0, -0x4(%rbp)
jmp 0x40030
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x165060
movb %al, -0x11(%rbp)
movzbl -0x11(%rbp), %eax
cmpl $0xeb, %eax
je 0x3fec5
movl $0x0, -0x4(%rbp)
jmp 0x40030
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movl $0x1, %esi
callq 0x165060
movb %al, -0x11(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movl $0x6, %esi
callq 0x165060
movb %al, -0x12(%rbp)
movzbl -0x12(%rbp), %eax
cmpl $0x0, %eax
jne 0x3ff01
movzbl -0x11(%rbp), %eax
cmpl $0x3d, %eax
je 0x3ff25
movzbl -0x12(%rbp), %eax
cmpl $0x1, %eax
jne 0x3ff13
movzbl -0x11(%rbp), %eax
cmpl $0x18, %eax
je 0x3ff25
movzbl -0x12(%rbp), %eax
cmpl $0x2, %eax
jne 0x3ff27
movzbl -0x11(%rbp), %eax
cmpl $0x3d, %eax
jne 0x3ff27
jmp 0x3ff33
movl $0x0, -0x4(%rbp)
jmp 0x40030
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movl $0x9, %esi
leaq 0x162f5f(%rip), %rdx    # 0x1a2ea6
movl $0x10, %ecx
callq 0x166ab0
cmpl $0x0, %eax
jne 0x3ff62
movl $0x64, -0x4(%rbp)
jmp 0x40030
movzbl -0x12(%rbp), %eax
cmpl $0x0, %eax
jne 0x3ffb7
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movl $0x3f, %esi
leaq 0x162e35(%rip), %rdx    # 0x1a2db4
movl $0xa, %ecx
callq 0x166ab0
cmpl $0x0, %eax
jne 0x3ffb5
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movl $0x8b, %esi
callq 0x165060
movzbl %al, %eax
cmpl $0xad, %eax
jne 0x3ffb3
movl $0x28, -0x4(%rbp)
jmp 0x40030
jmp 0x3ffb5
jmp 0x40029
movzbl -0x12(%rbp), %eax
cmpl $0x1, %eax
jne 0x3ffee
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movl $0x1a, %esi
leaq 0x163300(%rip), %rdx    # 0x1a32d4
movl $0xa, %ecx
callq 0x166ab0
cmpl $0x0, %eax
jne 0x3ffec
movl $0x28, -0x4(%rbp)
jmp 0x40030
jmp 0x40027
movzbl -0x12(%rbp), %eax
cmpl $0x2, %eax
jne 0x40025
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movl $0x3f, %esi
leaq 0x162db4(%rip), %rdx    # 0x1a2dbf
movl $0xa, %ecx
callq 0x166ab0
cmpl $0x0, %eax
jne 0x40023
movl $0x28, -0x4(%rbp)
jmp 0x40030
jmp 0x40025
jmp 0x40027
jmp 0x40029
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x20, %rsp
popq %rbp
retq
nopl (%rax)