// File: /workspace/github_c_makefile_star2_O0/negge[P]xlink/src/xlink.c
// Function: xlink_file_load_omf_library
xlink_library *xlink_file_load_omf_library(xlink_file *file,
 unsigned int flags) {
  xlink_library *lib;
  int done;
  lib = xlink_malloc(sizeof(xlink_library));
  done = 0;
  while (file->size > 0 && !done) {
    switch (file->buf[file->pos]) {
      case OMF_LIBHDR : {
        xlink_omf_record rec;
        xlink_file_load_omf_record(file, &rec);
        lib->page_size = rec.size + 3;
        break;
      }
      case OMF_LIBEND : {
        done = 1;
        break;
      }
      case OMF_THEADR :
      case OMF_LHEADR : {
        int mask;
        int skip;
        xlink_module *mod;
        /* TODO: Find embedded module name in dictionary, set file->name here */
        mod = xlink_file_load_omf_module(file, flags);
        XLINK_LIST_ADD(library, module, lib, mod);
        /* Page size is always a power of two */
        mask = lib->page_size - 1;
        /* Compute the number of bytes to skip to reach the next page */
        skip = ((file->pos + mask) & ~mask) - file->pos;
        file->pos += skip;
        file->size -= skip;
        break;
      }
      default : {
        XLINK_ERROR(1, ("Unknown record type %02X", file->buf[file->pos]));
      }
    }
  }
  XLINK_ERROR(!done, ("Got EOF before reading LIBEND in %s", file->name));
  return lib;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl $0x30, %edi
callq 0xae70
movq %rax, -0x18(%rbp)
movl $0x0, -0x1c(%rbp)
movq -0x8(%rbp), %rcx
xorl %eax, %eax
cmpl $0x0, 0x8(%rcx)
movb %al, -0x41(%rbp)
jbe 0x783f
cmpl $0x0, -0x1c(%rbp)
setne %al
xorb $-0x1, %al
movb %al, -0x41(%rbp)
movb -0x41(%rbp), %al
testb $0x1, %al
jne 0x784b
jmp 0x796c
movq -0x8(%rbp), %rcx
movq 0x10(%rcx), %rax
movl 0xc(%rcx), %ecx
movzbl (%rax,%rcx), %eax
movl %eax, -0x48(%rbp)
subl $0x80, %eax
je 0x78b9
jmp 0x7866
movl -0x48(%rbp), %eax
subl $0x82, %eax
je 0x78b9
jmp 0x7872
movl -0x48(%rbp), %eax
subl $0xf0, %eax
je 0x788d
jmp 0x787e
movl -0x48(%rbp), %eax
subl $0xf1, %eax
je 0x78ad
jmp 0x793a
movq -0x8(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x7610
movzwl -0x22(%rbp), %ecx
addl $0x3, %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x18(%rax)
jmp 0x7967
movl $0x1, -0x1c(%rbp)
jmp 0x7967
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x6290
movq %rax, -0x40(%rbp)
movq -0x18(%rbp), %rax
movl 0x28(%rax), %ecx
addl $0x1, %ecx
movq -0x40(%rbp), %rax
movl %ecx, 0x8(%rax)
movq -0x18(%rbp), %rcx
movq -0x40(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x18(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0x3e80
movq -0x18(%rbp), %rax
movl 0x18(%rax), %eax
subl $0x1, %eax
movl %eax, -0x34(%rbp)
movq -0x8(%rbp), %rax
movl 0xc(%rax), %eax
addl -0x34(%rbp), %eax
movl -0x34(%rbp), %ecx
xorl $-0x1, %ecx
andl %ecx, %eax
movq -0x8(%rbp), %rcx
subl 0xc(%rcx), %eax
movl %eax, -0x38(%rbp)
movl -0x38(%rbp), %ecx
movq -0x8(%rbp), %rax
addl 0xc(%rax), %ecx
movl %ecx, 0xc(%rax)
movl -0x38(%rbp), %edx
movq -0x8(%rbp), %rax
movl 0x8(%rax), %ecx
subl %edx, %ecx
movl %ecx, 0x8(%rax)
jmp 0x7967
jmp 0x793c
movq -0x8(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rcx
movl 0xc(%rcx), %ecx
movzbl (%rax,%rcx), %esi
leaq 0x7725(%rip), %rdi      # 0xf07b
movb $0x0, %al
callq 0xad90
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21c0
jmp 0x7824
jmp 0x796e
cmpl $0x0, -0x1c(%rbp)
jne 0x7993
movq -0x8(%rbp), %rax
movq (%rax), %rsi
leaq 0x7712(%rip), %rdi      # 0xf094
movb $0x0, %al
callq 0xad90
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x21c0
jmp 0x7995
movq -0x18(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nop