// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x58, %rsp
movq %rdi, 0x48(%rsp)
movq %rsi, 0x40(%rsp)
movq %rdx, 0x38(%rsp)
movl %ecx, 0x34(%rsp)
movq 0x40(%rsp), %rdi
callq 0x7a00
movl %eax, 0x30(%rsp)
cmpl $0x3f3, 0x30(%rsp)      # imm = 0x3F3
jne 0x1c9fd
movq 0x48(%rsp), %rsi
movl $0xc, %edi
movb $0x0, %al
callq 0x8c00
movl $0x2, 0x54(%rsp)
jmp 0x1cb26
cmpl $0x3e7, 0x30(%rsp)      # imm = 0x3E7
je 0x1ca1e
cmpl $0x3fa, 0x30(%rsp)      # imm = 0x3FA
je 0x1ca1e
movl $0x0, 0x54(%rsp)
jmp 0x1cb26
jmp 0x1ca20
cmpl $0x3fa, 0x30(%rsp)      # imm = 0x3FA
jne 0x1ca37
movl $0x8, 0x54(%rsp)
jmp 0x1cb26
cmpl $0x0, 0x34(%rsp)
jne 0x1cad2
movl $0x1, 0x4(%rsp)
movq 0x48(%rsp), %rdi
callq 0x50c0
subq $0x4, %rax
movl %eax, (%rsp)
cmpl $0x0, %eax
jle 0x1cad0
movq 0x48(%rsp), %rax
movslq (%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2e, %eax
jne 0x1cace
movq 0x48(%rsp), %rax
movl (%rsp), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %edi
callq 0x5070
cmpl $0x4c, %eax
jne 0x1cace
movq 0x48(%rsp), %rax
movl (%rsp), %ecx
addl $0x2, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %edi
callq 0x5070
cmpl $0x49, %eax
jne 0x1cace
movq 0x48(%rsp), %rax
movl (%rsp), %ecx
addl $0x3, %ecx
movslq %ecx, %rcx
movzbl (%rax,%rcx), %edi
callq 0x5070
cmpl $0x42, %eax
jne 0x1cace
movl $0x8, 0x4(%rsp)
jmp 0x1cad0
jmp 0x1cada
movl $0x8, 0x4(%rsp)
movq 0x48(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq 0x38(%rsp), %rcx
leaq 0x8(%rsp), %rdi
callq 0x1cb30
leaq 0x8(%rsp), %rdi
callq 0x1cba0
movl %eax, 0x30(%rsp)
cmpl $0x0, %eax
je 0x1cb1e
cmpl $0x4e9, 0x30(%rsp)      # imm = 0x4E9
jne 0x1cb1c
xorl %eax, %eax
subl 0x4(%rsp), %eax
movl %eax, 0x54(%rsp)
jmp 0x1cb26
jmp 0x1caf3
movl 0x4(%rsp), %eax
movl %eax, 0x54(%rsp)
movl 0x54(%rsp), %eax
addq $0x58, %rsp
retq
nop