// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x10(%rbp)
leaq -0x18(%rbp), %rdi
movq -0x10(%rbp), %rcx
movl $0x1, %esi
movl $0x8, %edx
callq 0x1050
cmpq $0x8, %rax
jne 0x21b8
leaq -0x18(%rbp), %rax
movq (%rax), %rax
movabsq $0xa3e686372613c21, %rcx # imm = 0xA3E686372613C21
subq %rcx, %rax
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0x21d2
leaq 0x432a(%rip), %rdi      # 0x64e9
movb $0x0, %al
callq 0x1070
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x23ab
movq -0x10(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x1240
cmpl $0x0, %eax
je 0x21f0
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x23ab
leaq -0x60(%rbp), %rdi
callq 0x1680
leaq -0x60(%rbp), %rdi
addq $0x38, %rdi
callq 0x10f0
movl %eax, -0x64(%rbp)
movq -0x10(%rbp), %rdi
movl -0x64(%rbp), %esi
callq 0x1a50
cmpl $0x0, %eax
je 0x2226
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x23ab
jmp 0x2228
movq -0x10(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x1240
cmpl $0x0, %eax
je 0x223f
jmp 0x23a4
leaq -0x60(%rbp), %rdi
callq 0x1680
leaq -0x60(%rbp), %rdi
addq $0x38, %rdi
callq 0x10f0
movl %eax, -0x64(%rbp)
leaq -0x60(%rbp), %rax
addq $0x8, %rax
movups (%rax), %xmm0
movaps 0x3da6(%rip), %xmm1     # 0x6010
pcmpeqb %xmm1, %xmm0
pmovmskb %xmm0, %eax
subl $0xffff, %eax           # imm = 0xFFFF
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x22a4
movq -0x10(%rbp), %rdi
movl -0x64(%rbp), %esi
callq 0x1cc0
cmpl $0x0, %eax
je 0x229f
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x23ab
jmp 0x236e
leaq -0x60(%rbp), %rax
addq $0x8, %rax
movups (%rax), %xmm0
movaps 0x3d6a(%rip), %xmm1     # 0x6020
pcmpeqb %xmm1, %xmm0
pmovmskb %xmm0, %eax
subl $0xffff, %eax           # imm = 0xFFFF
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x22ed
movq -0x10(%rbp), %rdi
movl -0x64(%rbp), %esi
callq 0x1e50
cmpl $0x0, %eax
je 0x22eb
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x23ab
jmp 0x236c
leaq -0x60(%rbp), %rax
addq $0x8, %rax
movups (%rax), %xmm0
movaps 0x3d31(%rip), %xmm1     # 0x6030
pcmpeqb %xmm1, %xmm0
pmovmskb %xmm0, %eax
subl $0xffff, %eax           # imm = 0xFFFF
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
jne 0x234a
movq -0x10(%rbp), %rdi
movl -0x64(%rbp), %esi
callq 0x2070
movl %eax, -0x68(%rbp)
cmpl $-0x2, -0x68(%rbp)
jne 0x2337
movq -0x10(%rbp), %rdi
callq 0x1b80
jmp 0x2348
cmpl $0x0, -0x68(%rbp)
je 0x2346
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x23ab
jmp 0x2348
jmp 0x236a
leaq 0x41ff(%rip), %rdi      # 0x6550
movb $0x0, %al
callq 0x1070
movq -0x10(%rbp), %rdi
movslq -0x64(%rbp), %rsi
movl $0x1, %edx
callq 0x10d0
jmp 0x236c
jmp 0x236e
leaq -0x60(%rbp), %rax
addq $0x42, %rax
movw (%rax), %ax
subw $0xa60, %ax             # imm = 0xA60
setne %al
movzbl %al, %eax
cmpl $0x0, %eax
je 0x239f
leaq 0x41db(%rip), %rdi      # 0x656a
movb $0x0, %al
callq 0x1070
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x23ab
jmp 0x2228
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)