// File: /workspace/github_c_makefile_star2_O0/jsummers[P]deark/modules/lha.c
// Function: de_identify_lha
static int de_identify_lha(deark *c)
{
	int has_ext = 0;
	u8 b[22];
	struct cmpr_meth_info cmi;

	de_read(b, 0, sizeof(b));
	if(b[20]>3) return 0; // header level

	if(!is_possible_cmpr_meth(&b[2])) return 0;
	if(is_swg_sig(&b[2])) return 0; // Handled by the swg module

	if(b[20]==0) {
		if(b[0]<22) return 0;
		if(22 + (int)b[21] + 2 > 2 + (int)b[0]) return 0;
	}
	else if(b[20]==1) {
		if(b[0]<25) return 0;
		if(22 + (int)b[21] + 5 > 2 + (int)b[0]) return 0;
	}
	else if(b[20]==2) {
		i64 hsize = de_getu16le_direct(&b[0]);
		if(hsize < 26) return 0;
	}
	else if(b[20]==3) {
		if((b[0]!=4 && b[0]!=8) || b[1]!=0) return 0;
	}

	de_zeromem(&cmi, sizeof(struct cmpr_meth_info));
	get_cmpr_meth_info(&b[2], BASEFMT_LHA, &cmi);
	if(!cmi.is_recognized) {
		return 0;
	}

	if(de_input_file_has_ext(c, "lzh") ||
		de_input_file_has_ext(c, "lha") ||
		((b[4]=='z') && de_input_file_has_ext(c, "lzs")))
	{
		has_ext = 1;
	}

	if(has_ext) return 100;
	return 80; // Must be less than car_lha
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq %rdi, -0x10(%rbp)
movl $0x0, -0x14(%rbp)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x30(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
movl $0x16, %ecx
callq 0x164d10
movzbl -0x1c(%rbp), %eax
cmpl $0x3, %eax
jle 0xc1575
movl $0x0, -0x4(%rbp)
jmp 0xc173f
leaq -0x30(%rbp), %rdi
addq $0x2, %rdi
callq 0xc4d80
cmpl $0x0, %eax
jne 0xc1593
movl $0x0, -0x4(%rbp)
jmp 0xc173f
leaq -0x30(%rbp), %rdi
addq $0x2, %rdi
callq 0xc6350
cmpl $0x0, %eax
je 0xc15b1
movl $0x0, -0x4(%rbp)
jmp 0xc173f
movzbl -0x1c(%rbp), %eax
cmpl $0x0, %eax
jne 0xc15f5
movzbl -0x30(%rbp), %eax
cmpl $0x16, %eax
jge 0xc15cf
movl $0x0, -0x4(%rbp)
jmp 0xc173f
movzbl -0x1b(%rbp), %eax
addl $0x16, %eax
addl $0x2, %eax
movzbl -0x30(%rbp), %ecx
addl $0x2, %ecx
cmpl %ecx, %eax
jle 0xc15f0
movl $0x0, -0x4(%rbp)
jmp 0xc173f
jmp 0xc169f
movzbl -0x1c(%rbp), %eax
cmpl $0x1, %eax
jne 0xc1636
movzbl -0x30(%rbp), %eax
cmpl $0x19, %eax
jge 0xc1613
movl $0x0, -0x4(%rbp)
jmp 0xc173f
movzbl -0x1b(%rbp), %eax
addl $0x16, %eax
addl $0x5, %eax
movzbl -0x30(%rbp), %ecx
addl $0x2, %ecx
cmpl %ecx, %eax
jle 0xc1634
movl $0x0, -0x4(%rbp)
jmp 0xc173f
jmp 0xc169d
movzbl -0x1c(%rbp), %eax
cmpl $0x2, %eax
jne 0xc1667
leaq -0x30(%rbp), %rdi
callq 0x165260
movq %rax, -0xa8(%rbp)
cmpq $0x1a, -0xa8(%rbp)
jge 0xc1665
movl $0x0, -0x4(%rbp)
jmp 0xc173f
jmp 0xc169b
movzbl -0x1c(%rbp), %eax
cmpl $0x3, %eax
jne 0xc1699
movzbl -0x30(%rbp), %eax
cmpl $0x4, %eax
je 0xc1682
movzbl -0x30(%rbp), %eax
cmpl $0x8, %eax
jne 0xc168b
movzbl -0x2f(%rbp), %eax
cmpl $0x0, %eax
je 0xc1697
movl $0x0, -0x4(%rbp)
jmp 0xc173f
jmp 0xc1699
jmp 0xc169b
jmp 0xc169d
jmp 0xc169f
leaq -0xa0(%rbp), %rdi
xorl %esi, %esi
movl $0x70, %edx
callq 0x19140
leaq -0x30(%rbp), %rdi
addq $0x2, %rdi
xorl %esi, %esi
leaq -0xa0(%rbp), %rdx
callq 0xc39d0
cmpb $0x0, -0xa0(%rbp)
jne 0xc16da
movl $0x0, -0x4(%rbp)
jmp 0xc173f
movq -0x10(%rbp), %rdi
leaq 0x10f4bd(%rip), %rsi    # 0x1d0ba2
callq 0x15d180
cmpl $0x0, %eax
jne 0xc1722
movq -0x10(%rbp), %rdi
leaq 0xf6050(%rip), %rsi     # 0x1b774a
callq 0x15d180
cmpl $0x0, %eax
jne 0xc1722
movzbl -0x2c(%rbp), %eax
cmpl $0x7a, %eax
jne 0xc1729
movq -0x10(%rbp), %rdi
leaq 0xf68e4(%rip), %rsi     # 0x1b7ffc
callq 0x15d180
cmpl $0x0, %eax
je 0xc1729
movl $0x1, -0x14(%rbp)
cmpl $0x0, -0x14(%rbp)
je 0xc1738
movl $0x64, -0x4(%rbp)
jmp 0xc173f
movl $0x50, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopl (%rax,%rax)