// File: /workspace/github_c_makefile_star2_O3/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 0x13e65
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 0xce54
movl %eax, 0x4(%rsp)
testl %eax, %eax
je 0x13daf
leaq 0x10(%rsp), %rdi
callq 0xcec0
testl %eax, %eax
je 0x13e51
movq 0x138(%rsp), %r13
leaq 0x1baca(%rip), %rsi     # 0x2f880
movl $0x4, %edx
movq %r13, %rdi
callq 0x5070
testl %eax, %eax
jne 0x13e65
cmpb %bpl, 0x4(%r13)
jne 0x13e65
cmpb %r15b, 0x5(%r13)
jne 0x13e65
movl 0x188(%rsp), %ebp
cmpb %bpl, 0x6(%r13)
jne 0x13e65
xorl %r15d, %r15d
movb %r12b, %r15b
leaq 0x14(%r13), %rsi
movl %r15d, %edi
callq 0x696f
cmpl %ebp, %eax
jne 0x13e65
movzwl 0x180(%rsp), %ebp
leaq 0x12(%r13), %rsi
movl %r15d, %edi
callq 0x695f
cmpw %bp, %ax
jne 0x13e65
addq $0x10, %r13
movl %r15d, %edi
movq %r13, %rsi
callq 0x695f
cmpw $0x3, %ax
je 0x13e94
movzwl %ax, %eax
cmpl $0x2, %eax
je 0x13e79
cmpl $0x1, %eax
jne 0x13eaf
cmpl $0x0, 0x4(%rsp)
movl $0x1, %eax
movl $0x8, %ebx
cmovel %eax, %ebx
jmp 0x13e65
movl $0x26, %edi
movq %r14, %rsi
xorl %eax, %eax
callq 0x6f14
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 0x13e65
movq 0x8(%rsp), %rax
movq (%rax), %rdx
movl $0x28, %edi
jmp 0x13ebe
movl $0x4, %ebx
cmpl $0x0, 0x4(%rsp)
je 0x13e65
movq 0x8(%rsp), %rax
movq (%rax), %rdx
movl $0x27, %edi
jmp 0x13ebe
movq 0x8(%rsp), %rax
movq (%rax), %rdx
xorl %ebx, %ebx
movl $0x29, %edi
movq %r14, %rsi
xorl %eax, %eax
callq 0x6f14
jmp 0x13e65