// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x48, %rsp
movq %rdi, 0x38(%rsp)
movq %rsi, 0x30(%rsp)
movq %rdx, 0x28(%rsp)
movq %rcx, 0x20(%rsp)
movq 0x38(%rsp), %rax
movl 0xa4(%rax), %eax
movl %eax, 0x1c(%rsp)
movl $0x0, 0x18(%rsp)
movq 0x20(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x38(%rsp), %rax
xorl %ecx, %ecx
movl %ecx, %edi
callq *0x18(%rax)
movq %rax, %rcx
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
jae 0x2ac2f
movl $0x0, 0x44(%rsp)
jmp 0x2adf8
movq 0x28(%rsp), %rsi
movq 0x20(%rsp), %rdx
movq 0x30(%rsp), %rcx
leaq 0x1a153(%rip), %rdi     # 0x44d98
callq 0x13d60
cmpl $0x0, %eax
je 0x2ac92
movl $0x1, 0x18(%rsp)
leaq 0x1a13a(%rip), %rdi     # 0x44d98
callq 0x13e00
cmpl $0x0, %eax
jne 0x2ac86
movq 0x30(%rsp), %rsi
movl $0x26, %edi
movb $0x0, %al
callq 0x8c00
movl $0xffffffff, 0x44(%rsp) # imm = 0xFFFFFFFF
jmp 0x2adf8
movq 0x1a233(%rip), %rax     # 0x44ec0
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rdi
callq 0x7a00
shrl $0x10, %eax
andl $0x3ff, %eax            # imm = 0x3FF
cmpl 0x1c(%rsp), %eax
jne 0x2adf0
movq 0x28(%rsp), %rdi
callq 0x7a00
andl $0xffff, %eax           # imm = 0xFFFF
movl %eax, 0x14(%rsp)
movq 0x28(%rsp), %rdi
callq 0x7a00
shrl $0x1a, %eax
andl $0x3f, %eax
andl $0x30, %eax
movl %eax, 0x10(%rsp)
cmpl $0x107, 0x14(%rsp)      # imm = 0x107
je 0x2ad04
cmpl $0x108, 0x14(%rsp)      # imm = 0x108
je 0x2ad04
cmpl $0x10b, 0x14(%rsp)      # imm = 0x10B
je 0x2ad04
cmpl $0xcc, 0x14(%rsp)
jne 0x2adee
movl 0x14(%rsp), %eax
movl %eax, 0x4(%rsp)
subl $0xcc, %eax
je 0x2addb
jmp 0x2ad19
movl 0x4(%rsp), %eax
subl $0x107, %eax            # imm = 0x107
je 0x2ad43
jmp 0x2ad26
movl 0x4(%rsp), %eax
subl $0x108, %eax            # imm = 0x108
je 0x2ad60
jmp 0x2ad33
movl 0x4(%rsp), %eax
subl $0x10b, %eax            # imm = 0x10B
je 0x2ad60
jmp 0x2adec
movl 0x18(%rsp), %edx
movl $0x1, %eax
movl $0x8, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, 0x44(%rsp)
jmp 0x2adf8
cmpl $0x0, 0x18(%rsp)
je 0x2adb2
cmpl $0x20, 0x10(%rsp)
sete %al
andb $0x1, %al
movzbl %al, %eax
orl $0x10, %eax
cmpl $0x0, %eax
je 0x2ad97
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rax
movq (%rax), %rdx
movl $0x27, %edi
movb $0x0, %al
callq 0x8c00
jmp 0x2adb0
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rax
movq (%rax), %rdx
movl $0x28, %edi
movb $0x0, %al
callq 0x8c00
jmp 0x2adb2
cmpl $0x20, 0x10(%rsp)
sete %al
andb $0x1, %al
movzbl %al, %eax
orl $0x10, %eax
cmpl $0x0, %eax
je 0x2add1
movl $0x4, 0x44(%rsp)
jmp 0x2adf8
movl $0x2, 0x44(%rsp)
jmp 0x2adf8
movq 0x30(%rsp), %rsi
movl $0x54, %edi
movb $0x0, %al
callq 0x8c00
jmp 0x2adee
jmp 0x2adf0
movl $0x0, 0x44(%rsp)
movl 0x44(%rsp), %eax
addq $0x48, %rsp
retq
nopw %cs:(%rax,%rax)