// File: /workspace/github_c_makefile_star2_O2/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
pushq $0x1
popq %rsi
pushq $0x8
popq %rdx
movq %r14, %rcx
callq 0x1070
cmpq $0x8, %rax
jne 0x1d91
movabsq $0xa3e686372613c21, %rax # imm = 0xA3E686372613C21
cmpq %rax, 0x8(%rsp)
je 0x1db1
leaq 0x27e3(%rip), %rdi      # 0x457b
callq 0x1060
pushq $-0x1
popq %rbx
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
pushq $-0x1
popq %rbx
testl %eax, %eax
jne 0x1da0
leaq 0x10(%rsp), %rdi
callq 0x14d5
leaq 0x48(%rsp), %r15
movq %r15, %rdi
callq 0x1110
movq %r14, %rdi
movl %eax, %esi
callq 0x1787
testl %eax, %eax
jne 0x1da0
leaq 0x18(%rsp), %rbp
leaq 0x10(%rsp), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x125c
testl %eax, %eax
jne 0x1ecf
movq %r12, %rdi
callq 0x14d5
movq %r15, %rdi
callq 0x1110
movl %eax, %r13d
movdqu (%rbp), %xmm0
pcmpeqb 0x21e9(%rip), %xmm0     # 0x4010
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x1e7e
movdqu (%rbp), %xmm0
pcmpeqb 0x21e1(%rip), %xmm0     # 0x4020
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x1e8b
movdqu (%rbp), %xmm0
pcmpeqb 0x21d9(%rip), %xmm0     # 0x4030
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x1ead
leaq 0x26e1(%rip), %rdi      # 0x454a
callq 0x1060
movslq %r13d, %rsi
movq %r14, %rdi
pushq $0x1
popq %rdx
callq 0x10f0
jmp 0x1e9e
movq %r14, %rdi
movl %r13d, %esi
callq 0x19a8
jmp 0x1e96
movq %r14, %rdi
movl %r13d, %esi
callq 0x1ae3
testl %eax, %eax
jne 0x1da0
cmpw $0xa60, 0x52(%rsp)      # imm = 0xA60
je 0x1df4
jmp 0x1ed6
movq %r14, %rdi
movl %r13d, %esi
callq 0x1c98
testl %eax, %eax
je 0x1e9e
cmpl $-0x2, %eax
jne 0x1da0
movq %r14, %rdi
callq 0x1876
jmp 0x1e9e
xorl %ebx, %ebx
jmp 0x1da0
leaq 0x2683(%rip), %rdi      # 0x4560
callq 0x1060
jmp 0x1da0