// File: /workspace/github_c_makefile_star2_O3/mikeakohn[P]print_pe/build/../src/print_lib.c
// Function: read_lib
int read_lib(FILE *in)
{
  char signature[8];
  struct file_header_t file_header;
  int size;

  if (fread(signature, 1, 8, in) != 8 ||
      memcmp(signature, "!<arch>\n", 8) != 0)
  {
    printf("Error: Missing !<arch> signature, not a .lib file.\n");
    return -1;
  }

  if (read_file_header(in, &file_header) != 0) { return -1; }
  print_file_header(&file_header);

  size = atoi(file_header.size);
  if (print_symbol_offsets(in, size) != 0) { return -1; }

  while (1)
  {
    if (read_file_header(in, &file_header) != 0) { break; }
    print_file_header(&file_header);

    size = atoi(file_header.size);

    if (memcmp(file_header.name, "/               ", 16) == 0)
    {
      if (print_public_symbols(in, size) != 0) { return -1; }
    }
      else
    if (memcmp(file_header.name, "//              ", 16) == 0)
    {
      if (print_name(in, size) != 0) { return -1; }
    }
      else
    if (memcmp(file_header.name, "/0              ", 16) == 0)
    {
      int result = print_section(in, size);

      if (result == -2)
      {
        print_symbol_header(in);
      }
        else
      if (result != 0)
      {
        return -1;
      }
    }
      else
    {
      printf("Unknown section type.\n");
      fseek(in, size, SEEK_CUR);
    }

    if (memcmp(file_header.end, "`\n", 2) != 0)
    {
      printf("Error: Invalid end marker.\n");
      return -1;
    }
  }

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdi, %r14
leaq 0x8(%rsp), %rdi
movl $0x1, %esi
movl $0x8, %edx
movq %r14, %rcx
callq 0x1070
cmpq $0x8, %rax
jne 0x1def
movabsq $0xa3e686372613c21, %rax # imm = 0xA3E686372613C21
cmpq %rax, 0x8(%rsp)
je 0x1e11
leaq 0x3785(%rip), %rdi      # 0x557b
callq 0x1060
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x125c
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x1e00
leaq 0x10(%rsp), %rdi
callq 0x14fc
leaq 0x48(%rsp), %r15
movq %r15, %rdi
callq 0x1110
movq %r14, %rdi
movl %eax, %esi
callq 0x17c0
testl %eax, %eax
jne 0x1e00
leaq 0x10(%rsp), %r12
leaq 0x36f2(%rip), %r13      # 0x554a
movq %r14, %rdi
movq %r12, %rsi
callq 0x125c
testl %eax, %eax
jne 0x1f30
movq %r12, %rdi
callq 0x14fc
movq %r15, %rdi
callq 0x1110
movl %eax, %ebp
movdqu 0x18(%rsp), %xmm0
pcmpeqb 0x3185(%rip), %xmm0     # 0x5010
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x1ee2
movdqu 0x18(%rsp), %xmm0
pcmpeqb 0x317c(%rip), %xmm0     # 0x5020
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x1eee
movdqu 0x18(%rsp), %xmm0
pcmpeqb 0x3173(%rip), %xmm0     # 0x5030
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x1f0f
movq %r13, %rdi
callq 0x1060
movslq %ebp, %rsi
movq %r14, %rdi
movl $0x1, %edx
callq 0x10f0
jmp 0x1f00
movq %r14, %rdi
movl %ebp, %esi
callq 0x19e9
jmp 0x1ef8
movq %r14, %rdi
movl %ebp, %esi
callq 0x1b25
testl %eax, %eax
jne 0x1e00
cmpw $0xa60, 0x52(%rsp)      # imm = 0xA60
je 0x1e58
jmp 0x1f37
movq %r14, %rdi
movl %ebp, %esi
callq 0x1cf0
testl %eax, %eax
je 0x1f00
cmpl $-0x2, %eax
jne 0x1e00
movq %r14, %rdi
callq 0x18b5
jmp 0x1f00
xorl %ebx, %ebx
jmp 0x1e00
leaq 0x3622(%rip), %rdi      # 0x5560
callq 0x1060
jmp 0x1e00