// File: /workspace/github_c_makefile_star2_O1/deplinenoise[P]vlink/t_elf32.c
// Function: elf32_identify
int elf32_identify(struct FFFuncs *ff,char *name,struct Elf32_Ehdr *p,
                   unsigned long plen,unsigned char class,
                   unsigned char endian,uint16_t machine,uint32_t ver)
/* check a possible ELF file against the requirements, then */
/* return its type (object, library, shared object) */
{
  bool arflag = FALSE;
  bool be = (endian == ELFDATA2MSB);
  struct ar_info ai;

  if (plen < sizeof(struct Elf32_Ehdr))
    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 Elf32_Ehdr *)ai.data;
  }

  if (!strncmp(p->e_ident,ELFid,4)) {
    /* ELF identification found */
    if (p->e_ident[EI_CLASS]==class && p->e_ident[EI_DATA]==endian &&
        p->e_ident[EI_VERSION]==(unsigned char)ver &&
        read32(be,p->e_version)==ver && read16(be,p->e_machine)==machine) {
      switch (read16(be,p->e_type)) {
        case ET_REL:
          return arflag ? ID_LIBARCH : ID_OBJECT;
        case ET_EXEC:
          if (arflag) /* no executables in library archives */
            error(40,name,ff->tname);
          return ID_EXECUTABLE;
        case ET_DYN:
          if (arflag) /* no shared objects in library archives */
            error(39,name,ff->tname);
          return ID_SHAREDOBJ;
        default:
          error(41,name,ff->tname);  /* illegal fmt. / file corrupted */
          break;
      }
    }
  }

  return ID_UNKNOWN;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x148, %rsp            # imm = 0x148
cmpl $0x2, %r9d
sete %r12b
xorl %ebx, %ebx
cmpq $0x34, %rcx
jb 0x13fd5
movl %r9d, %r15d
movl %r8d, %ebp
movq %rdx, %r13
movq %rsi, %r14
movq %rdi, 0x8(%rsp)
leaq 0x10(%rsp), %rdi
movq %rdx, %rsi
movq %rcx, %rdx
movq %r14, %rcx
callq 0xcf08
movl %eax, 0x4(%rsp)
testl %eax, %eax
je 0x13f1f
leaq 0x10(%rsp), %rdi
callq 0xcf75
testl %eax, %eax
je 0x13fc1
movq 0x138(%rsp), %r13
leaq 0x1b95a(%rip), %rsi     # 0x2f880
movl $0x4, %edx
movq %r13, %rdi
callq 0x5070
testl %eax, %eax
jne 0x13fd5
cmpb %bpl, 0x4(%r13)
jne 0x13fd5
cmpb %r15b, 0x5(%r13)
jne 0x13fd5
movl 0x188(%rsp), %ebp
cmpb %bpl, 0x6(%r13)
jne 0x13fd5
xorl %r15d, %r15d
movb %r12b, %r15b
leaq 0x14(%r13), %rsi
movl %r15d, %edi
callq 0x69b3
cmpl %ebp, %eax
jne 0x13fd5
movzwl 0x180(%rsp), %ebp
leaq 0x12(%r13), %rsi
movl %r15d, %edi
callq 0x6993
cmpw %bp, %ax
jne 0x13fd5
addq $0x10, %r13
movl %r15d, %edi
movq %r13, %rsi
callq 0x6993
cmpw $0x3, %ax
je 0x14004
movzwl %ax, %eax
cmpl $0x2, %eax
je 0x13fe9
cmpl $0x1, %eax
jne 0x1401f
cmpl $0x0, 0x4(%rsp)
movl $0x1, %eax
movl $0x8, %ebx
cmovel %eax, %ebx
jmp 0x13fd5
movl $0x26, %edi
movq %r14, %rsi
xorl %eax, %eax
callq 0x6f84
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x2, %ebx
cmpl $0x0, 0x4(%rsp)
je 0x13fd5
movq 0x8(%rsp), %rax
movq (%rax), %rdx
movl $0x28, %edi
jmp 0x1402e
movl $0x4, %ebx
cmpl $0x0, 0x4(%rsp)
je 0x13fd5
movq 0x8(%rsp), %rax
movq (%rax), %rdx
movl $0x27, %edi
jmp 0x1402e
movq 0x8(%rsp), %rax
movq (%rax), %rdx
xorl %ebx, %ebx
movl $0x29, %edi
movq %r14, %rsi
xorl %eax, %eax
callq 0x6f84
jmp 0x13fd5