// File: /workspace/github_c_makefile_star2_O1/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, %rbx
leaq 0x8(%rsp), %rdi
movl $0x1, %esi
movl $0x8, %edx
movq %rbx, %rcx
callq 0x1070
leaq 0x37b4(%rip), %r15      # 0x557b
cmpq $0x8, %rax
jne 0x1dde
movabsq $0xa3e686372613c21, %rax # imm = 0xA3E686372613C21
cmpq %rax, 0x8(%rsp)
je 0x1dfc
movq %r15, %rdi
callq 0x1060
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x10(%rsp), %rsi
movq %rbx, %rdi
callq 0x125c
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testl %eax, %eax
jne 0x1deb
leaq 0x10(%rsp), %rdi
callq 0x14fc
leaq 0x48(%rsp), %r14
movq %r14, %rdi
callq 0x1110
movq %rbx, %rdi
movl %eax, %esi
callq 0x17c0
testl %eax, %eax
jne 0x1deb
leaq 0x10(%rsp), %r12
leaq 0x371d(%rip), %r15      # 0x5560
movq %rbx, %rdi
movq %r12, %rsi
callq 0x125c
testl %eax, %eax
jne 0x1f26
movq %r12, %rdi
callq 0x14fc
movq %r14, %rdi
callq 0x1110
movl %eax, %r13d
movdqu 0x18(%rsp), %xmm0
pcmpeqb 0x3199(%rip), %xmm0     # 0x5010
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x1ed2
movdqu 0x18(%rsp), %xmm0
pcmpeqb 0x3190(%rip), %xmm0     # 0x5020
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x1edf
movdqu 0x18(%rsp), %xmm0
pcmpeqb 0x3187(%rip), %xmm0     # 0x5030
pmovmskb %xmm0, %eax
cmpl $0xffff, %eax           # imm = 0xFFFF
je 0x1f04
leaq 0x368f(%rip), %rdi      # 0x554a
callq 0x1060
movslq %r13d, %rsi
movq %rbx, %rdi
movl $0x1, %edx
callq 0x10f0
jmp 0x1ef2
movq %rbx, %rdi
movl %r13d, %esi
callq 0x19df
jmp 0x1eea
movq %rbx, %rdi
movl %r13d, %esi
callq 0x1b15
testl %eax, %eax
jne 0x1deb
cmpw $0xa60, 0x52(%rsp)      # imm = 0xA60
je 0x1e43
jmp 0x1dde
movq %rbx, %rdi
movl %r13d, %esi
callq 0x1cd8
testl %eax, %eax
je 0x1ef2
cmpl $-0x2, %eax
jne 0x1deb
movq %rbx, %rdi
callq 0x18ab
jmp 0x1ef2
xorl %ebp, %ebp
jmp 0x1deb