// File: /workspace/github_c_makefile_star2_O1/deplinenoise[P]vlink/t_amigahunk.c
// Function: identify
static int identify(char *name,uint8_t *p,unsigned long plen,bool lib)
/* Identify AmigaDOS or extended hunk format */
{
  uint32_t w = read32be(p);
  struct HunkInfo hi;
  int type;

  if (w == HUNK_HEADER) {
    error(12,name);  /* file is already an executable */
    return (ID_EXECUTABLE);  /* EHF-executables don't exist! */
  }
  else if (w!=HUNK_UNIT && w!=HUNK_LIB)
    return (ID_UNKNOWN);

  /* @@@ EHF will never be in HUNK_LIB format, because HUNK_PPC_CODE */
  /* (0x4e9) conflicts with HUNK_CODE|(MEMB_CHIP<<14) = 0x7e9. @@@   */
  if (w == HUNK_LIB)
    return (ID_LIBARCH);  /* SAS/C-style library */

  if (!lib) {
    /* Check, by comparing the suffix with ".LIB", if the units */
    /* of this object file have to be handled as part of an object */
    /* or library archive.  Yes, this is the only way... */
    int l;

    type = ID_OBJECT;
    if ((l = strlen(name)-4) > 0) {
      if (name[l]=='.' &&
          toupper((unsigned char)name[l+1])=='L' &&
          toupper((unsigned char)name[l+2])=='I' &&
          toupper((unsigned char)name[l+3])=='B')
        type = ID_LIBARCH;
    }
  }
  else
    type = ID_LIBARCH;  /* given with -l, will be regarded as a library */

  /* Now check if any unit contains EHF hunks */
  init_hunkinfo(&hi,name,p,plen);
  while (w = skiphunk(&hi)) {
    if (w == HUNK_PPC_CODE)
      return (-type);  /* it's an EHF object/library, containing PPC code */
  }
  return (type);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movl %ecx, %ebp
movq %rdx, %r13
movq %rsi, %r12
movq %rdi, %r15
movq %rsi, %rdi
callq 0x695d
cmpl $0x3e7, %eax            # imm = 0x3E7
je 0x12665
cmpl $0x3fa, %eax            # imm = 0x3FA
je 0x1265b
xorl %ebx, %ebx
cmpl $0x3f3, %eax            # imm = 0x3F3
jne 0x129c5
movl $0xc, %edi
movq %r15, %rsi
xorl %eax, %eax
callq 0x6f84
movl $0x2, %ebx
jmp 0x129c5
movl $0x8, %ebx
jmp 0x129c5
movl $0x8, %ebx
testl %ebp, %ebp
je 0x129d6
movq %rsp, %r14
movq %r12, (%r14)
movq %r12, 0x8(%r14)
movq %r13, 0x10(%r14)
movq %r15, 0x18(%r14)
movq %r12, %rdi
callq 0x695d
xorl %ecx, %ecx
cmpl $0x3f3, %eax            # imm = 0x3F3
sete %cl
movl %ecx, 0x20(%r14)
leaq 0x1091f(%rip), %r12     # 0x22fc0
movq 0x8(%rsp), %rdi
callq 0x695d
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
leal -0x3e7(%rax), %ecx
cmpl $0x17, %ecx
ja 0x126ff
movslq (%r12,%rcx,4), %rax
addq %r12, %rax
jmpq *%rax
movq 0x8(%rsp), %rdi
addq $0x4, %rdi
callq 0x695d
movl %eax, %r15d
addl $0x2, %r15d
shlq $0x2, %r15
subq %r15, 0x10(%rsp)
jns 0x126f5
movq 0x18(%rsp), %rsi
movl $0xd, %edi
xorl %eax, %eax
callq 0x6f84
addq %r15, 0x8(%rsp)
jmp 0x1288d
cmpl $0x4ec, %eax            # imm = 0x4EC
je 0x12843
cmpl $0x4e9, %eax            # imm = 0x4E9
je 0x126c4
movq 0x18(%rsp), %rsi
movl $0xd, %edi
xorl %eax, %eax
callq 0x6f84
jmp 0x1288d
movq %r14, %rdi
callq 0x12a55
movq %r14, %rdi
callq 0x12a55
testl %eax, %eax
je 0x1288d
movl %eax, %r15d
leal (,%r15,4), %r13d
andl $0x3fffffc, %r13d       # imm = 0x3FFFFFC
testl %r15d, %r15d
js 0x1275c
addl $0x4, %r13d
jmp 0x127b7
movl %r13d, %r13d
subq %r13, 0x10(%rsp)
jns 0x12777
movq 0x18(%rsp), %rsi
movl $0xd, %edi
xorl %eax, %eax
callq 0x6f84
addq %r13, 0x8(%rsp)
movl %r15d, %eax
shrl $0x18, %eax
cmpl $0x82, %eax
je 0x127a0
cmpl $0x89, %eax
je 0x127a0
addl $0x30000000, %r15d      # imm = 0x30000000
cmpl $0x2ffffff, %r15d       # imm = 0x2FFFFFF
ja 0x127a8
movq %r14, %rdi
callq 0x12a55
movq %r14, %rdi
callq 0x12a55
movl %eax, %r13d
shlq $0x2, %r13
subq %r13, 0x10(%rsp)
jns 0x127cf
movq 0x18(%rsp), %rsi
movl $0xd, %edi
xorl %eax, %eax
callq 0x6f84
addq %r13, 0x8(%rsp)
movq %r14, %rdi
callq 0x12a55
movl %eax, %r15d
testl %eax, %eax
jne 0x12742
jmp 0x1288d
movq %r14, %rdi
callq 0x12a55
jmp 0x1288d
cmpl $0x0, 0x20(%rsp)
je 0x12843
movq %r14, %rdi
callq 0x12a55
movq %r14, %rdi
callq 0x12a80
testw %ax, %ax
je 0x128b9
movzwl %ax, %eax
leaq 0x2(,%rax,2), %r15
subq %r15, 0x10(%rsp)
jns 0x1283c
movq 0x18(%rsp), %rsi
movl $0xd, %edi
xorl %eax, %eax
callq 0x6f84
addq %r15, 0x8(%rsp)
jmp 0x12808
movq %r14, %rdi
callq 0x12a55
movq %r14, %rdi
callq 0x12a55
testl %eax, %eax
je 0x1288d
movl %eax, %r15d
incl %r15d
shlq $0x2, %r15
subq %r15, 0x10(%rsp)
jns 0x12879
movq 0x18(%rsp), %rsi
movl $0xd, %edi
xorl %eax, %eax
callq 0x6f84
addq %r15, 0x8(%rsp)
movq %r14, %rdi
callq 0x12a55
movl %eax, %r15d
testl %eax, %eax
jne 0x1285a
xorl %eax, %eax
cmpq $0x4, 0x10(%rsp)
jb 0x128a1
movq 0x8(%rsp), %rdi
callq 0x695d
testl %eax, %eax
je 0x129c5
cmpl $0x4e9, %eax            # imm = 0x4E9
jne 0x126a1
jmp 0x129c3
movq 0x8(%rsp), %r15
movl (%rsp), %eax
movl %r15d, %ecx
subl %eax, %ecx
testb $0x2, %cl
je 0x1288d
movq 0x10(%rsp), %rax
leaq -0x2(%rax), %rcx
movq %rcx, 0x10(%rsp)
cmpq $0x1, %rax
jg 0x128f0
movq 0x18(%rsp), %rsi
movl $0xd, %edi
xorl %eax, %eax
callq 0x6f84
addq $0x2, %r15
movq %r15, 0x8(%rsp)
jmp 0x1288d
movq 0x8(%rsp), %rdi
addq $0x4, %rdi
callq 0x695d
movl %eax, %r15d
addl $0x3, %r15d
jmp 0x126d9
movq 0x10(%rsp), %rax
leaq -0x8(%rax), %rcx
movq %rcx, 0x10(%rsp)
cmpq $0x7, %rax
jg 0x1293a
movq 0x18(%rsp), %rsi
movl $0xd, %edi
xorl %eax, %eax
callq 0x6f84
addq $0x8, 0x8(%rsp)
jmp 0x1288d
movq %r14, %rdi
callq 0x12a55
movq %r14, %rdi
callq 0x12a55
movl %eax, %r15d
addl $0x2, %r15d
shlq $0x2, %r15
subq %r15, 0x10(%rsp)
jns 0x12978
movq 0x18(%rsp), %rsi
movl $0xd, %edi
xorl %eax, %eax
callq 0x6f84
addq %r15, 0x8(%rsp)
movq %r14, %rdi
callq 0x12a55
movl %eax, %r15d
movq %r14, %rdi
callq 0x12a55
movl %eax, %ebp
subl %r15d, %eax
cmpl $-0x1, %eax
je 0x1288d
notl %ebp
addl %r15d, %ebp
movq %r14, %rdi
callq 0x12a55
cmpl $0xc0000000, %eax       # imm = 0xC0000000
jb 0x129ba
movq %r14, %rdi
callq 0x12a55
incl %ebp
jne 0x129a3
jmp 0x1288d
negl %ebx
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %r15, %rdi
callq 0x50e0
movq %rax, %r14
addl $-0x4, %eax
movl $0x1, %ebx
testl %eax, %eax
jle 0x12672
movl %eax, %eax
cmpb $0x2e, (%r15,%rax)
jne 0x12672
movl $0xfffffffd, %ebp       # imm = 0xFFFFFFFD
callq 0x5030
movq (%rax), %rax
leal (%r14,%rbp), %ecx
movzbl (%r15,%rcx), %ecx
cmpl $0x4c, (%rax,%rcx,4)
jne 0x12672
leal (%r14,%rbp), %ecx
incl %ecx
movzbl (%r15,%rcx), %ecx
cmpl $0x49, (%rax,%rcx,4)
jne 0x12672
leal (%r14,%rbp), %ecx
addl $0x2, %ecx
movzbl (%r15,%rcx), %ecx
cmpl $0x42, (%rax,%rcx,4)
movl $0x8, %eax
movl $0x1, %ebx
cmovel %eax, %ebx
jmp 0x12672