// File: /workspace/github_c_makefile_star2_O3/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 $0x38, %rsp
movl %ecx, %ebp
movq %rdx, %r12
movq %rsi, %r15
movq %rdi, %r13
movq %rsi, %rdi
callq 0x6929
cmpl $0x3e7, %eax            # imm = 0x3E7
je 0x124d0
cmpl $0x3fa, %eax            # imm = 0x3FA
je 0x124c6
xorl %ecx, %ecx
cmpl $0x3f3, %eax            # imm = 0x3F3
jne 0x128c2
movl $0xc, %edi
movq %r13, %rsi
xorl %eax, %eax
callq 0x6f14
movl $0x2, %ecx
jmp 0x128c2
movl $0x8, %ecx
jmp 0x128c2
movl $0x8, %ecx
testl %ebp, %ebp
je 0x12838
movl %ecx, 0xc(%rsp)
leaq 0x10(%rsp), %r14
movq %r15, (%r14)
movq %r15, 0x8(%r14)
movq %r12, 0x10(%r14)
movq %r13, 0x18(%r14)
movq %r15, %rdi
callq 0x6929
xorl %ecx, %ecx
cmpl $0x3f3, %eax            # imm = 0x3F3
sete %cl
movl %ecx, 0x20(%r14)
leaq 0x10a8e(%rip), %rbx     # 0x22fa0
movq %r15, %rdi
callq 0x6929
andl $0x3fffffff, %eax       # imm = 0x3FFFFFFF
leal -0x3e7(%rax), %ecx
cmpl $0x17, %ecx
ja 0x1256f
movslq (%rbx,%rcx,4), %rax
addq %rbx, %rax
jmpq *%rax
leaq 0x4(%r15), %rdi
callq 0x6929
movl %eax, %r13d
addl $0x2, %r13d
shlq $0x2, %r13
subq %r13, %r12
movq %r12, 0x20(%rsp)
jns 0x12562
movq 0x28(%rsp), %rsi
movl $0xd, %edi
xorl %eax, %eax
callq 0x6f14
addq %r13, %r15
movq %r15, 0x18(%rsp)
jmp 0x126fd
cmpl $0x4ec, %eax            # imm = 0x4EC
je 0x126b3
cmpl $0x4e9, %eax            # imm = 0x4E9
je 0x12533
movq 0x28(%rsp), %rsi
movl $0xd, %edi
xorl %eax, %eax
callq 0x6f14
jmp 0x126fd
movq %r14, %rdi
callq 0x128dd
movq %r14, %rdi
callq 0x128dd
testl %eax, %eax
je 0x126fd
movl %eax, %r15d
leal (,%r15,4), %r12d
andl $0x3fffffc, %r12d       # imm = 0x3FFFFFC
testl %r15d, %r15d
js 0x125cc
addl $0x4, %r12d
jmp 0x12627
movl %r12d, %r12d
subq %r12, 0x20(%rsp)
jns 0x125e7
movq 0x28(%rsp), %rsi
movl $0xd, %edi
xorl %eax, %eax
callq 0x6f14
addq %r12, 0x18(%rsp)
movl %r15d, %eax
shrl $0x18, %eax
cmpl $0x82, %eax
je 0x12610
cmpl $0x89, %eax
je 0x12610
addl $0x30000000, %r15d      # imm = 0x30000000
cmpl $0x2ffffff, %r15d       # imm = 0x2FFFFFF
ja 0x12618
movq %r14, %rdi
callq 0x128dd
movq %r14, %rdi
callq 0x128dd
movl %eax, %r12d
shlq $0x2, %r12
subq %r12, 0x20(%rsp)
jns 0x1263f
movq 0x28(%rsp), %rsi
movl $0xd, %edi
xorl %eax, %eax
callq 0x6f14
addq %r12, 0x18(%rsp)
movq %r14, %rdi
callq 0x128dd
movl %eax, %r15d
testl %eax, %eax
jne 0x125b2
jmp 0x126fd
movq %r14, %rdi
callq 0x128dd
jmp 0x126fd
cmpl $0x0, 0x30(%rsp)
je 0x126b3
movq %r14, %rdi
callq 0x128dd
movq %r14, %rdi
callq 0x12908
testw %ax, %ax
je 0x12731
movzwl %ax, %eax
leaq 0x2(,%rax,2), %r15
subq %r15, 0x20(%rsp)
jns 0x126ac
movq 0x28(%rsp), %rsi
movl $0xd, %edi
xorl %eax, %eax
callq 0x6f14
addq %r15, 0x18(%rsp)
jmp 0x12678
movq %r14, %rdi
callq 0x128dd
movq %r14, %rdi
callq 0x128dd
testl %eax, %eax
je 0x126fd
movl %eax, %r15d
incl %r15d
shlq $0x2, %r15
subq %r15, 0x20(%rsp)
jns 0x126e9
movq 0x28(%rsp), %rsi
movl $0xd, %edi
xorl %eax, %eax
callq 0x6f14
addq %r15, 0x18(%rsp)
movq %r14, %rdi
callq 0x128dd
movl %eax, %r15d
testl %eax, %eax
jne 0x126ca
movq 0x20(%rsp), %r12
cmpq $0x4, %r12
jb 0x1282f
movq 0x18(%rsp), %r15
movq %r15, %rdi
callq 0x6929
testl %eax, %eax
je 0x1282f
cmpl $0x4e9, %eax            # imm = 0x4E9
jne 0x12512
jmp 0x128bc
movq 0x18(%rsp), %r15
movl 0x10(%rsp), %eax
movl %r15d, %ecx
subl %eax, %ecx
testb $0x2, %cl
je 0x126fd
movq 0x20(%rsp), %rax
leaq -0x2(%rax), %rcx
movq %rcx, 0x20(%rsp)
cmpq $0x1, %rax
jg 0x12769
movq 0x28(%rsp), %rsi
movl $0xd, %edi
xorl %eax, %eax
callq 0x6f14
addq $0x2, %r15
jmp 0x12565
leaq 0x4(%r15), %rdi
callq 0x6929
movl %eax, %r13d
addl $0x3, %r13d
jmp 0x12543
leaq -0x8(%r12), %rax
movq %rax, 0x20(%rsp)
cmpq $0x7, %r12
jg 0x127a8
movq 0x28(%rsp), %rsi
movl $0xd, %edi
xorl %eax, %eax
callq 0x6f14
addq $0x8, %r15
jmp 0x12565
movq %r14, %rdi
callq 0x128dd
movq %r14, %rdi
callq 0x128dd
movl %eax, %r15d
addl $0x2, %r15d
shlq $0x2, %r15
subq %r15, 0x20(%rsp)
jns 0x127e4
movq 0x28(%rsp), %rsi
movl $0xd, %edi
xorl %eax, %eax
callq 0x6f14
addq %r15, 0x18(%rsp)
movq %r14, %rdi
callq 0x128dd
movl %eax, %r15d
movq %r14, %rdi
callq 0x128dd
movl %eax, %ebp
subl %r15d, %eax
cmpl $-0x1, %eax
je 0x126fd
notl %ebp
addl %r15d, %ebp
movq %r14, %rdi
callq 0x128dd
cmpl $0xc0000000, %eax       # imm = 0xC0000000
jb 0x12826
movq %r14, %rdi
callq 0x128dd
incl %ebp
jne 0x1280f
jmp 0x126fd
movl 0xc(%rsp), %ecx
jmp 0x128c2
movq %r13, %rdi
callq 0x50e0
movq %rax, %r14
addl $-0x4, %eax
movl $0x1, %ecx
testl %eax, %eax
jle 0x124dd
movl %eax, %eax
cmpb $0x2e, (%r13,%rax)
jne 0x124dd
movl $0xfffffffd, %ebx       # imm = 0xFFFFFFFD
callq 0x5030
movq (%rax), %rax
leal (%r14,%rbx), %ecx
movzbl (%r13,%rcx), %ecx
cmpl $0x4c, (%rax,%rcx,4)
jne 0x128d3
leal (%rbx,%r14), %ecx
incl %ecx
movzbl (%r13,%rcx), %ecx
cmpl $0x49, (%rax,%rcx,4)
movl $0x1, %ecx
jne 0x124dd
leal (%rbx,%r14), %ecx
addl $0x2, %ecx
movzbl (%r13,%rcx), %ecx
cmpl $0x42, (%rax,%rcx,4)
movl $0x8, %eax
movl $0x1, %ecx
cmovel %eax, %ecx
jmp 0x124dd
movl 0xc(%rsp), %ecx
negl %ecx
movl %ecx, %eax
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x1, %ecx
jmp 0x124dd