// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x278, %rsp            # imm = 0x278
movl %edi, 0x274(%rsp)
movq %rsi, 0x268(%rsp)
movq %rdx, 0x260(%rsp)
movq $0x0, 0x248(%rsp)
movq $0x0, 0x240(%rsp)
movb $0x0, 0x233(%rsp)
movb $0x0, 0x232(%rsp)
movb $0x0, 0x231(%rsp)
jmp 0x495e0
cmpq $0x0, 0x260(%rsp)
je 0x49636
movq 0x260(%rsp), %rdi
callq 0xd8a60
testb $0x1, %al
jne 0x495fe
jmp 0x49636
movq 0x5f299b(%rip), %rax    # 0x63bfa0
movq (%rax), %rdi
leaq 0x4cca04(%rip), %rsi    # 0x516013
leaq 0x4ccba9(%rip), %rdx    # 0x5161bf
leaq 0x4d975d(%rip), %rcx    # 0x522d7a
leaq 0x4d976e(%rip), %r8     # 0x522d92
movl $0x38, %r9d
movb $0x0, %al
callq 0x199f0
callq 0x19370
jmp 0x49638
movb $0x0, 0x4f(%rsp)
movl 0x274(%rsp), %esi
movq 0x268(%rsp), %rdx
movq 0x260(%rsp), %r8
leaq 0x234(%rsp), %rdi
leaq 0x258(%rsp), %rcx
callq 0x499c0
movl %eax, %ecx
movl %ecx, 0x1c(%rsp)
testl %eax, %eax
je 0x4968b
jmp 0x49675
movl 0x1c(%rsp), %eax
subl $0x1, %eax
je 0x4968d
jmp 0x49680
movl 0x1c(%rsp), %eax
subl $0x2, %eax
je 0x4969c
jmp 0x496a1
jmp 0x496a1
movb $0x1, 0x233(%rsp)
movb $0x1, 0x4f(%rsp)
jmp 0x496a1
movb $0x1, 0x4f(%rsp)
testb $0x1, 0x4f(%rsp)
je 0x496ad
jmp 0x4992f
movq 0x268(%rsp), %rax
movslq 0x234(%rsp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x250(%rsp)
movb 0x25c(%rsp), %al
movq 0x5f2861(%rip), %rcx    # 0x63bf38
movq (%rcx), %rdx
leaq 0x4ce20b(%rip), %rsi    # 0x5178ec
andb $0x1, %al
movzbl %al, %edi
callq 0xe7870
movq %rax, 0x248(%rsp)
movq 0x250(%rsp), %rdx
movq 0x248(%rsp), %rcx
movq 0x260(%rsp), %r8
leaq 0x130(%rsp), %rdi
movl $0x2, %esi
callq 0x233500
cmpl $0x0, %eax
je 0x49814
movq 0x260(%rsp), %rdi
callq 0xd8ac0
movq 0x250(%rsp), %rdx
movq 0x248(%rsp), %rcx
movq 0x260(%rsp), %r8
leaq 0x130(%rsp), %rdi
xorl %esi, %esi
callq 0x233500
cmpl $0x0, %eax
je 0x4976c
movb $0x1, 0x233(%rsp)
jmp 0x4992f
movq 0x130(%rsp), %rdi
callq 0xa9d00
addq $0x1, %rax
movq %rax, 0x40(%rsp)
movb $0x1, 0x232(%rsp)
movq 0x250(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x130(%rsp), %rdi
callq 0xb0f00
movq 0x10(%rsp), %rdi
movq %rax, %rcx
movq 0x260(%rsp), %r8
movl $0x2, %edx
movl %edx, %esi
callq 0x21ee10
movq %rax, 0x240(%rsp)
movq 0x240(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x224e90
movq %rax, 0x238(%rsp)
cmpq $0x0, %rax
jne 0x49812
movq 0x260(%rsp), %rdi
movq 0x250(%rsp), %rdx
leaq 0x4d95b8(%rip), %rsi    # 0x522db6
movb $0x0, %al
callq 0xd88c0
movb $0x1, 0x233(%rsp)
jmp 0x4992f
jmp 0x49863
movq 0x130(%rsp), %rdi
callq 0xa9d00
addq $0x1, %rax
movq %rax, 0x40(%rsp)
movb $0x1, 0x232(%rsp)
movq 0x40(%rsp), %rsi
leaq 0x50(%rsp), %rdi
leaq 0x130(%rsp), %rdx
callq 0x22d190
leaq 0x50(%rsp), %rdi
callq 0x49ae0
movq %rax, 0x238(%rsp)
movb $0x1, 0x231(%rsp)
movq 0x238(%rsp), %rdi
movl $0x1, %esi
callq 0x49af0
movq %rax, 0x30(%rsp)
movq %rdx, 0x38(%rsp)
movq 0x40(%rsp), %rdi
movl 0x258(%rsp), %eax
movswl %ax, %esi
callq 0x21f570
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rdi
movq 0x40(%rsp), %rsi
movq 0x30(%rsp), %rdx
movq 0x38(%rsp), %rcx
callq 0x21f830
cmpq 0x40(%rsp), %rax
je 0x498fc
movq 0x260(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x260(%rsp), %rdi
callq 0xd8b20
movq 0x8(%rsp), %rdi
movq %rax, %rdx
leaq 0x4d952c(%rip), %rsi    # 0x522e0d
movb $0x0, %al
callq 0xd88c0
movb $0x1, 0x233(%rsp)
movq 0x20(%rsp), %rdi
callq 0x21f7d0
jmp 0x4992f
movq 0x20(%rsp), %rdi
movq 0x240(%rsp), %rsi
movq 0x250(%rsp), %rdx
callq 0x21fb90
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rdi
callq 0x2204c0
movq 0x20(%rsp), %rdi
callq 0x21f7d0
cmpq $0x0, 0x240(%rsp)
je 0x49954
movq 0x238(%rsp), %rdi
callq 0x49b30
movq 0x240(%rsp), %rdi
callq 0x2261a0
testb $0x1, 0x231(%rsp)
je 0x49968
leaq 0x50(%rsp), %rdi
callq 0x22d740
testb $0x1, 0x232(%rsp)
je 0x4997f
leaq 0x130(%rsp), %rdi
callq 0x233320
cmpq $0x0, 0x248(%rsp)
je 0x49997
movq 0x248(%rsp), %rdi
callq 0xe7ed0
movb 0x233(%rsp), %dl
xorl %eax, %eax
movl $0xffffffff, %ecx       # imm = 0xFFFFFFFF
testb $0x1, %dl
cmovnel %ecx, %eax
addq $0x278, %rsp            # imm = 0x278
retq
nopw %cs:(%rax,%rax)