// File: zeeev[P]DASVC/bamtools/src/api/internal/bam/BamReader_p.cpp
// Function: BamTools::Internal::BamReaderPrivate::CreateIndex(BamTools::BamIndex::IndexType const&)
bool BamReaderPrivate::CreateIndex(const BamIndex::IndexType& type) {

    // skip if BAM file not open
    if ( !IsOpen() ) {
        SetErrorString("BamReader::CreateIndex", "cannot create index on unopened BAM file");
        return false;
    }

    // attempt to create index
    if ( m_randomAccessController.CreateIndex(this, type) )
        return true;
    else {
        const string bracError = m_randomAccessController.GetErrorString();
        const string message = string("could not create index: \n\t") + bracError;
        SetErrorString("BamReader::CreateIndex", message);
        return false;
    }
}

// Assembly:
subq $0x138, %rsp            # imm = 0x138
movq %rdi, 0x128(%rsp)
movq %rsi, 0x120(%rsp)
movq 0x128(%rsp), %rdi
movq %rdi, 0x28(%rsp)
callq 0x77980
testb $0x1, %al
jne 0xaa26d
leaq 0xff(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x7b5f0
movq 0x20(%rsp), %rdx
leaq 0x40b25(%rip), %rsi     # 0xeac74
leaq 0x100(%rsp), %rdi
callq 0x78e70
jmp 0xaa15e
leaq 0xc7(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x7b5f0
movq 0x18(%rsp), %rdx
leaq 0x40b0f(%rip), %rsi     # 0xeac8b
leaq 0xc8(%rsp), %rdi
callq 0x78e70
jmp 0xaa18b
movq 0x28(%rsp), %rdi
leaq 0x100(%rsp), %rsi
leaq 0xc8(%rsp), %rdx
callq 0x774d0
jmp 0xaa1a7
leaq 0xc8(%rsp), %rdi
callq 0x7cce8
jmp 0xaa1b6
leaq 0xc7(%rsp), %rdi
callq 0x76f80
leaq 0x100(%rsp), %rdi
callq 0x7cce8
jmp 0xaa1d2
leaq 0xff(%rsp), %rdi
callq 0x76f80
movb $0x0, 0x137(%rsp)
jmp 0xaa44b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
jmp 0xaa25b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
jmp 0xaa23d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
leaq 0xc8(%rsp), %rdi
callq 0x7cce8
jmp 0xaa23b
jmp 0xaa23d
leaq 0xc7(%rsp), %rdi
callq 0x76f80
leaq 0x100(%rsp), %rdi
callq 0x7cce8
jmp 0xaa259
jmp 0xaa25b
leaq 0xff(%rsp), %rdi
callq 0x76f80
jmp 0xaa45c
movq 0x28(%rsp), %rsi
movq %rsi, %rdi
addq $0x1a8, %rdi            # imm = 0x1A8
movq 0x120(%rsp), %rdx
callq 0x772c0
testb $0x1, %al
jne 0xaa28f
jmp 0xaa29c
movb $0x1, 0x137(%rsp)
jmp 0xaa44b
movq 0x28(%rsp), %rsi
addq $0x1a8, %rsi            # imm = 0x1A8
leaq 0xa0(%rsp), %rdi
callq 0x7a020
leaq 0x5f(%rsp), %rdi
movq %rdi, 0x10(%rsp)
callq 0x7b5f0
movq 0x10(%rsp), %rdx
leaq 0x40839(%rip), %rsi     # 0xeab09
leaq 0x60(%rsp), %rdi
callq 0x78e70
jmp 0xaa2dc
leaq 0x80(%rsp), %rdi
leaq 0x60(%rsp), %rsi
leaq 0xa0(%rsp), %rdx
callq 0x7c720
jmp 0xaa2f8
leaq 0x60(%rsp), %rdi
callq 0x7cce8
jmp 0xaa304
leaq 0x5f(%rsp), %rdi
callq 0x76f80
leaq 0x37(%rsp), %rdi
movq %rdi, 0x8(%rsp)
callq 0x7b5f0
movq 0x8(%rsp), %rdx
leaq 0x4094b(%rip), %rsi     # 0xeac74
leaq 0x38(%rsp), %rdi
callq 0x78e70
jmp 0xaa335
movq 0x28(%rsp), %rdi
leaq 0x38(%rsp), %rsi
leaq 0x80(%rsp), %rdx
callq 0x774d0
jmp 0xaa34e
leaq 0x38(%rsp), %rdi
callq 0x7cce8
jmp 0xaa35a
leaq 0x37(%rsp), %rdi
callq 0x76f80
movb $0x0, 0x137(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x7cce8
jmp 0xaa413
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
jmp 0xaa3b6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
leaq 0x60(%rsp), %rdi
callq 0x7cce8
jmp 0xaa3b4
jmp 0xaa3b6
leaq 0x5f(%rsp), %rdi
callq 0x76f80
jmp 0xaa43a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
jmp 0xaa3fa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
leaq 0x38(%rsp), %rdi
callq 0x7cce8
jmp 0xaa3f8
jmp 0xaa3fa
leaq 0x37(%rsp), %rdi
callq 0x76f80
leaq 0x80(%rsp), %rdi
callq 0x7cce8
jmp 0xaa438
leaq 0xa0(%rsp), %rdi
callq 0x7cce8
jmp 0xaa44b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xf0(%rsp)
movl %eax, 0xec(%rsp)
jmp 0xaa43a
jmp 0xaa43a
leaq 0xa0(%rsp), %rdi
callq 0x7cce8
jmp 0xaa449
jmp 0xaa45c
movb 0x137(%rsp), %al
andb $0x1, %al
addq $0x138, %rsp            # imm = 0x138
retq
movq 0xf0(%rsp), %rdi
callq 0x7b550
movq %rax, %rdi
callq 0x88ef0
nopw %cs:(%rax,%rax)