// File: /workspace/github_c_makefile_star2_O1/deplinenoise[P]vlink/t_aout.c
// Function: aout_identify
int aout_identify(struct FFFuncs *ff,char *name,struct aout_hdr *p,
                  unsigned long plen)
/* check a possible a.out file against the requirements, then */
/* return its type (object, library, shared object) */
{
  uint32_t mid = ff->id;
  bool arflag = FALSE;

  if (plen < ff->headersize(0))  /* @@@ gv-ptr is not needed for a.out ! */
    return (ID_UNKNOWN);

  if (ar_init(&ai,(char *)p,plen,name)) {
    /* library archive detected, extract 1st archive member */
    arflag = TRUE;
    if (!(ar_extract(&ai))) {
      error(38,name);  /* Empty archive ignored */
      return (ID_IGNORE);
    }
    p = (struct aout_hdr *)ai.data;
  }

  if (GETMID(p) == mid) {
    uint32_t mag = GETMAGIC(p);
    int fl = GETFLAGS(p) & EX_DPMASK;

    if (mag==OMAGIC || mag==NMAGIC || mag==ZMAGIC || mag==QMAGIC) {
      /* valid a.out format for this machine detected! */
      switch (mag) {
        case OMAGIC:
          return (arflag ? ID_LIBARCH : ID_OBJECT);
        case NMAGIC:
        case ZMAGIC:
          if (arflag) {
            if (fl == EX_DYNAMIC|EX_PIC)
              error(39,name,ff->tname); /* no shared objects in lib archives */
            else
              error(40,name,ff->tname); /* no executables in lib archives */
          }
          if (fl == EX_DYNAMIC|EX_PIC)
            return (ID_SHAREDOBJ);
          return (ID_EXECUTABLE);
        case QMAGIC:
          error(84,name); /* QMAGIC is deprecated */
          break;
      }
    }
  }
  return (ID_UNKNOWN);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rcx, %r13
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r14
movl 0xa4(%rdi), %ebp
xorl %r15d, %r15d
xorl %edi, %edi
callq *0x18(%r14)
cmpq %r13, %rax
ja 0x1b2e0
leaq 0x187d2(%rip), %rdi     # 0x339c8
movq %r12, %rsi
movq %r13, %rdx
movq %rbx, %rcx
callq 0xcf08
movl %eax, %r13d
testl %eax, %eax
je 0x1b222
leaq 0x187b6(%rip), %rdi     # 0x339c8
callq 0xcf75
testl %eax, %eax
je 0x1b27d
movq 0x188ce(%rip), %r12     # 0x33af0
movq %r12, %rdi
callq 0x695d
shrl $0x10, %eax
andl $0x3ff, %eax            # imm = 0x3FF
cmpl %ebp, %eax
jne 0x1b2dd
movq %r12, %rdi
callq 0x695d
movl %eax, %r15d
movq %r12, %rdi
callq 0x695d
movzwl %r15w, %eax
movb $0x1, %r12b
cmpl $0x107, %eax            # imm = 0x107
jg 0x1b294
cmpl $0xcc, %eax
je 0x1b2c9
cmpl $0x107, %eax            # imm = 0x107
jne 0x1b2d8
testl %r13d, %r13d
movl $0x1, %eax
movl $0x8, %r15d
cmovel %eax, %r15d
jmp 0x1b2c4
movl $0x26, %edi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x6f84
movl $0xffffffff, %r15d      # imm = 0xFFFFFFFF
jmp 0x1b2e0
cmpl $0x108, %eax            # imm = 0x108
je 0x1b2a2
cmpl $0x10b, %eax            # imm = 0x10B
jne 0x1b2d8
movl $0x4, %r15d
testl %r13d, %r13d
je 0x1b2c4
movq (%r14), %rdx
xorl %r12d, %r12d
movl $0x27, %edi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x6f84
jmp 0x1b2d8
xorl %r12d, %r12d
jmp 0x1b2d8
movl $0x54, %edi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x6f84
testb %r12b, %r12b
je 0x1b2e0
xorl %r15d, %r15d
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq