// File: /workspace/github_c_makefile_star2_O3/genometools[P]genometools/src/tools/gt_packedindex_mkctxmap.c
// Function: gt_packedindex_mkctxmap
extern int
gt_packedindex_mkctxmap(int argc, const char *argv[], GtError *err)
{
  struct mkCtxMapOptions params;
  const char *projectName;
  GtLogger *logger = NULL;
  BWTSeq *bwtSeq = NULL;
  SASeqSrc *src;
  int parsedArgs;
  bool had_err = false;
  bool saInitialized = false, saiInitialized = false;
  Suffixarray sa;
  SuffixarrayFileInterface sai;

  do {
    gt_error_check(err);
    {
      bool exitNow = false;
      switch (parseMkCtxMapOptions(&parsedArgs, argc, argv, &params, err))
      {
      case GT_OPTION_PARSER_OK:
        break;
      case GT_OPTION_PARSER_ERROR:
        had_err = true;
        exitNow = true;
        break;
      case GT_OPTION_PARSER_REQUESTS_EXIT:
        exitNow = true;
        break;
      }
      if (exitNow)
        break;
    }
    projectName = argv[parsedArgs];
    logger = gt_logger_new(params.verboseOutput,
                           GT_LOGGER_DEFLT_PREFIX, stdout);
    /* try to find appropriate suffix source */
    {
      GtUword len;
      if (streamsuffixarray(&sa, SARR_SUFTAB, projectName, logger, err))
      {
        gt_error_unset(err);
        if (streamsuffixarray(&sa, 0, projectName, logger, err))
        {
          had_err = true;
          break;
        }
        len = gt_encseq_total_length(sa.encseq) + 1;
        saInitialized = true;
        bwtSeq = gt_loadBWTSeqForSA(projectName, BWT_ON_BLOCK_ENC,
                                 BWTDEFOPT_MULTI_QUERY,
                                 gt_encseq_alphabet(sa.encseq), err);
        if (!(src = gt_BWTSeqNewSASeqSrc(bwtSeq, NULL)))
        {
          gt_error_set(err, "The project %s does not contain sufficient"
                       " information to regenerate the suffix array.",
                       projectName);
          had_err = true;
          break;
        }
      }
      else
      {
        len = gt_encseq_total_length(sa.encseq) + 1;
        saInitialized = true;
        gt_initSuffixarrayFileInterface(&sai, len, &sa);
        src = SAI2SASS(&sai);
        saiInitialized = true;
      }
      {
        SeqDataReader readSfxIdx = SASSCreateReader(src, SFX_REQUEST_SUFTAB);
        BWTSeqContextRetriever *bwtSeqCR;
        BWTSeqContextRetrieverFactory *bwtSeqCRF
          = gt_newBWTSeqContextRetrieverFactory(len, params.mapIntervalLog2);
        if (gt_BWTSCRFReadAdvance(bwtSeqCRF, len, readSfxIdx)
            != len)
        {
          gt_error_set(err, "Creation of context map unsuccessful: %s",
                    gt_error_get(err));
          had_err = true;
          gt_deleteBWTSeqContextRetrieverFactory(bwtSeqCRF);
          break;
        }
        bwtSeqCR = gt_BWTSCRFGet(bwtSeqCRF, bwtSeq, projectName);
        gt_deleteBWTSeqCR(bwtSeqCR);
        gt_deleteBWTSeqContextRetrieverFactory(bwtSeqCRF);
      }
    }
  } while (0);
  if (bwtSeq)
  {
    SASSDelete(src);
    gt_deleteBWTSeq(bwtSeq);
  }
  if (saiInitialized) gt_destructSuffixarrayFileInterface(&sai);;
  if (saInitialized) gt_freesuffixarray(&sa);
  if (logger) gt_logger_delete(logger);
  return had_err?-1:0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x208, %rsp            # imm = 0x208
movq %rdx, %r14
movq %rsi, %rbx
movl %edi, %ebp
testq %rdx, %rdx
je 0xb27a2
movq %r14, %rdi
callq 0xfcc32
testb %al, %al
jne 0xb29f4
leaq 0x4(%rsp), %rdi
leaq 0x18(%rsp), %rcx
movl %ebp, %esi
movq %rbx, %rdx
movq %r14, %r8
jmp 0xb27b4
leaq 0x4(%rsp), %rdi
leaq 0x18(%rsp), %rcx
movl %ebp, %esi
movq %rbx, %rdx
xorl %r8d, %r8d
callq 0xb29f9
cmpl $0x1, %eax
je 0xb27ca
cmpl $0x2, %eax
jne 0xb27d1
xorl %ebx, %ebx
jmp 0xb29bd
movb $0x1, %bl
jmp 0xb29bd
movslq 0x4(%rsp), %rax
movq (%rbx,%rax,8), %r13
movzbl 0x1c(%rsp), %edi
movq 0x4066f2(%rip), %rax    # 0x4b8ed8
movq (%rax), %rdx
leaq 0x2940e4(%rip), %rsi    # 0x3468d4
callq 0x103e40
movq %rax, %r15
leaq 0x28(%rsp), %rdi
movl $0x2, %esi
movq %r13, %rdx
movq %rax, %rcx
movq %r14, %r8
callq 0x1a1676
movl %eax, %r12d
testl %eax, %eax
je 0xb28a5
movq %r14, %rdi
callq 0xfcc44
leaq 0x28(%rsp), %rdi
xorl %esi, %esi
movq %r13, %rdx
movq %r15, %rcx
movq %r14, %r8
callq 0x1a1676
movb $0x1, %bl
testl %eax, %eax
jne 0xb29b0
movq 0x28(%rsp), %rdi
callq 0xe7b9c
movq %rax, %rbp
movq 0x28(%rsp), %rdi
callq 0xebcd9
movq %r13, %rdi
movl $0x2, %esi
movl $0x2, %edx
movq %rax, %rcx
movq %r14, %r8
callq 0x1990b6
movq %rax, %rbx
movq %rax, %rdi
xorl %esi, %esi
callq 0x19b730
movq %r13, %rdx
testq %rax, %rax
je 0xb29d4
movq %rax, %r13
movq %rbx, 0x8(%rsp)
movq %rdx, 0x20(%rsp)
movl %r12d, (%rsp)
movq %r15, 0x10(%rsp)
incq %rbp
jmp 0xb28e6
movq %r13, 0x20(%rsp)
movl %r12d, (%rsp)
movq %r15, 0x10(%rsp)
leaq 0x28(%rsp), %r12
movq (%r12), %rdi
callq 0xe7b9c
movq %rax, %rbp
incq %rbp
leaq 0x128(%rsp), %r13
movq %r13, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x19ecc9
movq $0x0, 0x8(%rsp)
movq %r13, %rdi
movl $0x1, %esi
callq *0x8(%r13)
movq %rax, %rbx
movq %rdx, %r15
movswl 0x18(%rsp), %esi
movq %rbp, %rdi
callq 0x199420
movq %rax, %r12
movq %rax, %rdi
movq %rbp, %rsi
movq %rbx, %rdx
movq %r15, %rcx
callq 0x1995ba
cmpq %rbp, %rax
jne 0xb293f
movq %r12, %rdi
movq 0x8(%rsp), %r14
movq %r14, %rsi
movq 0x20(%rsp), %rdx
callq 0x199729
movq %rax, %rdi
callq 0x199c73
xorl %ebx, %ebx
jmp 0xb2962
movq %r14, %rdi
callq 0xfcc5a
leaq 0x29f43f(%rip), %rsi    # 0x351d8d
movq %r14, %rdi
movq %rax, %rdx
xorl %eax, %eax
callq 0xfcb67
movb $0x1, %bl
movq 0x8(%rsp), %r14
movq %r12, %rdi
callq 0x19958f
testq %r14, %r14
je 0xb298e
movq 0x10(%rsp), %r15
movl (%rsp), %r12d
movq %r13, %rdi
callq *0x38(%r13)
movq %r14, %rdi
callq 0x19bd88
testl %r12d, %r12d
jne 0xb29a6
jmp 0xb2999
cmpl $0x0, (%rsp)
movq 0x10(%rsp), %r15
jne 0xb29a6
leaq 0x128(%rsp), %rdi
callq 0x19ef84
leaq 0x28(%rsp), %rdi
callq 0x1a1540
testq %r15, %r15
je 0xb29bd
movq %r15, %rdi
callq 0x1040e0
movzbl %bl, %eax
negl %eax
addq $0x208, %rsp            # imm = 0x208
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x29f35b(%rip), %rsi    # 0x351d36
xorl %r13d, %r13d
movq %r14, %rdi
xorl %eax, %eax
callq 0xfcb67
movq %rbx, %r14
movb $0x1, %bl
testq %r14, %r14
jne 0xb2978
jmp 0xb29a6
callq 0x1cff6