// File: /workspace/github_c_makefile_star2_O0/genometools[P]genometools/src/match/eis-bwtseq-context.c
// Function: BWTSeqCRMapOpen
static inline bool
BWTSeqCRMapOpen(unsigned short mapIntervalLog2,
                unsigned short bitsPerUlong,
                GtUword seqLen,
                const char *projectName,
                bool createMapFile,
                BWTSeqContextRetriever *gt_newBWTSeqCR)
{
  FILE *mapFile = NULL;
  BitString mapMap = NULL;
  GtStr *mapName = NULL;
  gt_assert(projectName);
  do {
    size_t headerBitElems = bitElemsAllocSize(2 * HEADER_ENTRY_BITS),
      headerSize = headerBitElems * sizeof (BitElem),
      mapSize = headerSize + sizeof (BitElem)
      * bitElemsAllocSize(bitsPerUlong * numMapEntries(
                            seqLen, mapIntervalLog2));
    mapName = gt_str_new_cstr(projectName);
    {
      char buf[1 + 4 + 3 + 3];
      snprintf(buf, sizeof (buf), ".%ucxm", (unsigned)mapIntervalLog2);
      gt_str_append_cstr(mapName, buf);
      if (createMapFile)
      {
        /* write header information, for reference to verify noone
         * toyed with the file name */
        BitElem headerBuf[headerBitElems];
        if (!(mapFile = gt_fa_fopen(gt_str_get(mapName), "w+b", NULL)))
          break;
        gt_bsStoreUInt16(headerBuf, 0, HEADER_ENTRY_BITS, mapIntervalLog2);
        gt_bsStoreUInt16(headerBuf, HEADER_ENTRY_BITS, HEADER_ENTRY_BITS,
                      bitsPerUlong);
        gt_xfwrite(headerBuf,  sizeof (headerBuf), 1, mapFile);
        if (fseeko(mapFile, mapSize - 1, SEEK_SET))
          break;
        /* write one byte so mmap works for full file */
        gt_xfwrite(&buf, 1, 1, mapFile);
        gt_xfflush(mapFile);
      }
      else
      {
        /* read header information, for reference to verify noone
         * toyed with the file name */
        BitElem headerBuf[headerBitElems];
        if (!(mapFile = gt_fa_fopen(gt_str_get(mapName), "rb", NULL)))
          break;
        if (fread(headerBuf,  sizeof (headerBuf), 1, mapFile) != 1)
          break;
        if (gt_bsGetUInt16(headerBuf, 0, HEADER_ENTRY_BITS) != mapIntervalLog2
            || (gt_bsGetUInt16(headerBuf, HEADER_ENTRY_BITS, HEADER_ENTRY_BITS)
                != bitsPerUlong))
        {
          fprintf(stderr, "error: context map file %s contains corrupted "
                  "data.\n", gt_str_get(mapName));
          break;
        }
      }
    }
    mapMap = gt_fa_mmap_generic_fd(fileno(mapFile), gt_str_get(mapName),
                                   mapSize, 0, createMapFile, false, NULL);
    gt_newBWTSeqCR->revMap = (gt_newBWTSeqCR->revMapMMap = mapMap) + headerSize;
  } while (0);
  if (mapName) gt_str_delete(mapName);
  if (mapFile) gt_fa_xfclose(mapFile);
  return mapMap != NULL;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xd0, %rsp
movb %r8b, %al
movw %di, -0x2(%rbp)
movw %si, -0x4(%rbp)
movq %rdx, -0x10(%rbp)
movq %rcx, -0x18(%rbp)
andb $0x1, %al
movb %al, -0x19(%rbp)
movq %r9, -0x28(%rbp)
movq $0x0, -0x30(%rbp)
movq $0x0, -0x38(%rbp)
movq $0x0, -0x40(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x21fd7e
movq 0x41c253(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x2f62bc(%rip), %rsi    # 0x516013
leaq 0x354949(%rip), %rdx    # 0x5746a7
leaq 0x354abf(%rip), %rcx    # 0x574824
leaq 0x354886(%rip), %r8     # 0x5745f2
movl $0x119, %r9d            # imm = 0x119
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x21fd80
jmp 0x21fd82
movl $0x20, %edi
callq 0x220d50
movq %rax, -0x48(%rbp)
movq -0x48(%rbp), %rax
shlq $0x0, %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movq %rax, -0x98(%rbp)
movzwl -0x4(%rbp), %eax
movq %rax, -0xa0(%rbp)
movq -0x10(%rbp), %rdi
movzwl -0x2(%rbp), %esi
callq 0x220c10
movq -0xa0(%rbp), %rdi
imulq %rax, %rdi
callq 0x220d50
movq %rax, %rcx
movq -0x98(%rbp), %rax
shlq $0x0, %rcx
addq %rcx, %rax
movq %rax, -0x58(%rbp)
movq -0x18(%rbp), %rdi
callq 0x11d510
movq %rax, -0x40(%rbp)
leaq -0x63(%rbp), %rdi
movzwl -0x2(%rbp), %ecx
movl $0xb, %esi
leaq 0x354a2f(%rip), %rdx    # 0x574834
movb $0x0, %al
callq 0x19b90
movq -0x40(%rbp), %rdi
leaq -0x63(%rbp), %rsi
callq 0x11d550
testb $0x1, -0x19(%rbp)
je 0x21ff42
movq -0x48(%rbp), %rax
movq %rax, -0xb0(%rbp)
movq %rsp, %rcx
movq %rcx, -0x70(%rbp)
movq %rax, %rdx
addq $0xf, %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0xa8(%rbp)
movq %rcx, %rsp
movq %rax, -0x78(%rbp)
movq -0x40(%rbp), %rdi
callq 0x11dee0
movq %rax, %rdi
leaq 0x3549d4(%rip), %rsi    # 0x57483b
leaq 0x354784(%rip), %rdx    # 0x5745f2
movl $0x12a, %ecx            # imm = 0x12A
xorl %eax, %eax
movl %eax, %r8d
callq 0xd8df0
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0x21fe93
movl $0x4, -0x7c(%rbp)
jmp 0x21ff28
movq -0xa8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x10, %edx
movzwl -0x2(%rbp), %ecx
callq 0x470fd0
movq -0xa8(%rbp), %rdi
movl $0x10, %esi
movl $0x10, %edx
movzwl -0x4(%rbp), %ecx
callq 0x470fd0
movq -0xa8(%rbp), %rdi
movq -0xb0(%rbp), %rsi
movq -0x30(%rbp), %rcx
movl $0x1, %edx
callq 0x126d30
movq -0x30(%rbp), %rdi
movq -0x58(%rbp), %rsi
subq $0x1, %rsi
xorl %edx, %edx
callq 0x19c10
cmpl $0x0, %eax
je 0x21ff03
movl $0x4, -0x7c(%rbp)
jmp 0x21ff28
movq -0x30(%rbp), %rcx
leaq -0x63(%rbp), %rdi
movl $0x1, %edx
movq %rdx, %rsi
callq 0x126d30
movq -0x30(%rbp), %rdi
callq 0x1269c0
movl $0x0, -0x7c(%rbp)
movq -0x70(%rbp), %rax
movq %rax, %rsp
movl -0x7c(%rbp), %eax
testl %eax, %eax
je 0x21ff3d
jmp 0x21ff38
jmp 0x2200fd
jmp 0x220080
movq -0x48(%rbp), %rax
movq %rax, -0xc0(%rbp)
movq %rsp, %rcx
movq %rcx, -0x88(%rbp)
movq %rax, %rdx
addq $0xf, %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0xb8(%rbp)
movq %rcx, %rsp
movq %rax, -0x90(%rbp)
movq -0x40(%rbp), %rdi
callq 0x11dee0
movq %rax, %rdi
leaq 0x357f59(%rip), %rsi    # 0x577ee5
leaq 0x35465f(%rip), %rdx    # 0x5745f2
movl $0x13b, %ecx            # imm = 0x13B
xorl %eax, %eax
movl %eax, %r8d
callq 0xd8df0
movq %rax, -0x30(%rbp)
cmpq $0x0, %rax
jne 0x21ffb8
movl $0x4, -0x7c(%rbp)
jmp 0x220069
movq -0xc0(%rbp), %rsi
movq -0xb8(%rbp), %rdi
movq -0x30(%rbp), %rcx
movl $0x1, %edx
callq 0x19a70
cmpq $0x1, %rax
je 0x21ffe6
movl $0x4, -0x7c(%rbp)
jmp 0x220069
movq -0xb8(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x10, %edx
callq 0x470da0
movzwl %ax, %eax
movzwl -0x2(%rbp), %ecx
cmpl %ecx, %eax
jne 0x220027
movq -0xb8(%rbp), %rdi
movl $0x10, %esi
movl $0x10, %edx
callq 0x470da0
movzwl %ax, %eax
movzwl -0x4(%rbp), %ecx
cmpl %ecx, %eax
je 0x220062
movq 0x41bf72(%rip), %rax    # 0x63bfa0
movq (%rax), %rax
movq %rax, -0xc8(%rbp)
movq -0x40(%rbp), %rdi
callq 0x11dee0
movq -0xc8(%rbp), %rdi
movq %rax, %rdx
leaq 0x3547ed(%rip), %rsi    # 0x57483f
movb $0x0, %al
callq 0x199f0
movl $0x4, -0x7c(%rbp)
jmp 0x220069
movl $0x0, -0x7c(%rbp)
movq -0x88(%rbp), %rax
movq %rax, %rsp
movl -0x7c(%rbp), %eax
testl %eax, %eax
je 0x22007e
jmp 0x22007c
jmp 0x2200fd
jmp 0x220080
movq -0x30(%rbp), %rdi
callq 0x197a0
movl %eax, -0xcc(%rbp)
movq -0x40(%rbp), %rdi
callq 0x11dee0
movl -0xcc(%rbp), %edi
movq %rax, %rsi
movq -0x58(%rbp), %rdx
movb -0x19(%rbp), %r8b
xorl %eax, %eax
movl %eax, %ecx
xorl %r9d, %r9d
leaq 0x35453b(%rip), %rax    # 0x5745f2
andb $0x1, %r8b
subq $0x20, %rsp
movzbl %r8b, %r8d
movq %rax, (%rsp)
movl $0x14a, 0x8(%rsp)       # imm = 0x14A
movq $0x0, 0x10(%rsp)
callq 0xda1e0
addq $0x20, %rsp
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x18(%rax)
addq -0x50(%rbp), %rcx
movq -0x28(%rbp), %rax
movq %rcx, 0x20(%rax)
cmpq $0x0, -0x40(%rbp)
je 0x22010d
movq -0x40(%rbp), %rdi
callq 0x11f560
cmpq $0x0, -0x30(%rbp)
je 0x22011d
movq -0x30(%rbp), %rdi
callq 0xd9570
cmpq $0x0, -0x38(%rbp)
setne %al
andb $0x1, %al
movq %rbp, %rsp
popq %rbp
retq
nopl (%rax)