// File: /workspace/github_cpp_makefile_star2_O2/zeeev[P]DASVC/bamtools/src/api/internal/bam/BamRandomAccessController_p.cpp
// Function: BamTools::Internal::BamRandomAccessController::CreateIndex(BamTools::Internal::BamReaderPrivate*, BamTools::BamIndex::IndexType const&)
bool BamRandomAccessController::CreateIndex(BamReaderPrivate* reader,
                                            const BamIndex::IndexType& type)
{
    // skip if reader is invalid
    assert(reader);
    if ( !reader->IsOpen() ) {
        SetErrorString("BamRandomAccessController::CreateIndex",
                       "cannot create index for unopened reader");
        return false;
    }

    // create new index of requested type
    BamIndex* newIndex = BamIndexFactory::CreateIndexOfType(type, reader);
    if ( newIndex == 0 ) {
        stringstream s("");
        s << "could not create index of type: " << type;
        SetErrorString("BamRandomAccessController::CreateIndex", s.str());
        return false;
    }

    // attempt to build index from current BamReader file
    if ( !newIndex->Create() ) {
        const string indexError = newIndex->GetErrorString();
        const string message = "could not create index: \n\t" + indexError;
        SetErrorString("BamRandomAccessController::CreateIndex", message);
        return false;
    }

    // save new index & return success
    SetIndex(newIndex);
    return true;
}

// Assembly:
pushq %r15
pushq %r14
pushq %rbx
subq $0x1d0, %rsp            # imm = 0x1D0
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
movq %rsi, %rdi
callq 0x33780
testb %al, %al
je 0x432b1
movq %r14, %rdi
movq %r15, %rsi
callq 0x352f0
testq %rax, %rax
je 0x43308
movq %rax, %r15
movq (%rax), %rax
movq %r15, %rdi
callq *0x10(%rax)
testb %al, %al
je 0x433ad
movq %rbx, %rdi
movq %r15, %rsi
callq 0x338a0
movb $0x1, %al
jmp 0x4341d
leaq 0x18651(%rip), %rsi     # 0x5b909
leaq 0x48(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x31b30
leaq 0x18662(%rip), %rsi     # 0x5b930
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x31b30
leaq 0x48(%rsp), %rsi
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
callq 0x31560
leaq 0x8(%rsp), %rdi
callq 0x33a00
leaq 0x48(%rsp), %rdi
callq 0x33a00
jmp 0x4341b
leaq 0x18b55(%rip), %rsi     # 0x5be64
leaq 0x8(%rsp), %rdi
leaq 0x28(%rsp), %rdx
callq 0x31b30
leaq 0x48(%rsp), %rdi
leaq 0x8(%rsp), %rsi
pushq $0x18
popq %rdx
callq 0x34880
leaq 0x8(%rsp), %rdi
callq 0x33a00
leaq 0x58(%rsp), %rdi
leaq 0x18612(%rip), %rsi     # 0x5b958
callq 0x330f0
movl (%r14), %esi
movq %rax, %rdi
callq 0x34d10
leaq 0x185ac(%rip), %rsi     # 0x5b909
leaq 0x8(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x31b30
leaq 0x60(%rsp), %rsi
leaq 0x28(%rsp), %rdi
callq 0x34870
leaq 0x8(%rsp), %rsi
leaq 0x28(%rsp), %rdx
movq %rbx, %rdi
callq 0x31560
leaq 0x28(%rsp), %rdi
callq 0x33a00
leaq 0x8(%rsp), %rdi
callq 0x33a00
leaq 0x48(%rsp), %rdi
callq 0x32870
jmp 0x4341b
addq $0x10, %r15
leaq 0x48(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x33ff0
leaq 0x185b1(%rip), %rsi     # 0x5b979
leaq 0x8(%rsp), %rdi
movq %r14, %rdx
callq 0x32d90
leaq 0x1852d(%rip), %rsi     # 0x5b909
leaq 0x28(%rsp), %rdi
leaq 0x7(%rsp), %rdx
callq 0x31b30
leaq 0x28(%rsp), %rsi
leaq 0x8(%rsp), %rdx
movq %rbx, %rdi
callq 0x31560
leaq 0x28(%rsp), %rdi
callq 0x33a00
leaq 0x8(%rsp), %rdi
callq 0x33a00
leaq 0x48(%rsp), %rdi
callq 0x33a00
xorl %eax, %eax
addq $0x1d0, %rsp            # imm = 0x1D0
popq %rbx
popq %r14
popq %r15
retq
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x33a00
jmp 0x4345f
movq %rax, %rbx
leaq 0x28(%rsp), %rdi
callq 0x33a00
jmp 0x4347a
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x33a00
jmp 0x434b8
movq %rax, %rbx
jmp 0x43469
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x33a00
leaq 0x48(%rsp), %rdi
callq 0x33a00
jmp 0x434b8
jmp 0x43486
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x33a00
jmp 0x43489
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x32870
jmp 0x434b8
jmp 0x434a6
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x33a00
jmp 0x434ae
movq %rax, %rbx
jmp 0x434b8
movq %rax, %rbx
leaq 0x48(%rsp), %rdi
callq 0x33a00
movq %rbx, %rdi
callq 0x34ed0
movq %rax, %rdi
callq 0x39b2f