// File: /workspace/github_cpp_makefile_star2_O3/zeeev[P]DASVC/bamtools/src/api/internal/io/BamPipe_p.cpp
// Function: BamTools::Internal::BamPipe::Open(BamTools::IBamIODevice::OpenMode)
bool BamPipe::Open(const IBamIODevice::OpenMode mode) {

    // make sure we're starting with a fresh pipe
    Close();

    // open stdin/stdout depending on requested openmode
#if defined( SYSTEM_NODEJS ) && SYSTEM_NODEJS == 1
    if ( mode == IBamIODevice::ReadOnly )
        m_stream = stdin;
    else if ( mode == IBamIODevice::WriteOnly )
        m_stream = stdout;
#else
    if ( mode == IBamIODevice::ReadOnly )
        m_stream = freopen(0, "rb", stdin);
    else if ( mode == IBamIODevice::WriteOnly )
        m_stream = freopen(0, "wb", stdout);
#endif // SYSTEM_NODEJS

    else {
        const string errorType = string( (mode == IBamIODevice::ReadWrite) ? "unsupported"
                                                                           : "unknown" );
        const string message = errorType + " open mode requested";
        SetErrorString("BamPipe::Open", message);
        return false;
    }

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x60, %rsp
movl %esi, %ebp
movq %rdi, %rbx
movq (%rdi), %rax
callq *0x10(%rax)
cmpl $0x1, %ebp
jne 0x48a12
leaq 0xdef4(%rip), %rsi      # 0x568fd
movq 0x22558(%rip), %rax     # 0x6af68
jmp 0x48a29
cmpl $0x2, %ebp
jne 0x48ad9
leaq 0xdede(%rip), %rsi      # 0x56900
movq 0x224bf(%rip), %rax     # 0x6aee8
movq (%rax), %rdx
xorl %edi, %edi
callq 0x27550
movq %rax, 0x30(%rbx)
testq %rax, %rax
je 0x48a46
movl %ebp, 0x8(%rbx)
movb $0x1, %al
jmp 0x48b9b
leaq 0x30(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xe23a(%rip), %rsi      # 0x56c90
leaq 0xe24c(%rip), %rdx      # 0x56ca9
leaq 0x20(%rsp), %rdi
callq 0x26750
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
addq %rsi, %rdx
movq %rsp, %rdi
callq 0x267c0
cmpl $0x1, %ebp
leaq 0xde52(%rip), %rax      # 0x568e1
leaq 0xde51(%rip), %rsi      # 0x568e7
cmoveq %rax, %rsi
movq %rsp, %rdi
callq 0x29090
leaq 0x50(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xe1cf(%rip), %rsi      # 0x56c82
leaq 0xe1d5(%rip), %rdx      # 0x56c8f
leaq 0x40(%rsp), %rdi
callq 0x26750
leaq 0x40(%rsp), %rsi
movq %rsp, %rdx
movq %rbx, %rdi
callq 0x288b0
jmp 0x48b6d
xorl %eax, %eax
cmpl $0x3, %ebp
leaq 0xe191(%rip), %rcx      # 0x56c76
leaq 0xc69f(%rip), %rsi      # 0x5518b
cmoveq %rcx, %rsi
sete %al
leaq 0x30(%rsp), %r14
movq %r14, -0x10(%r14)
leaq (%rsi,%rax,4), %rdx
addq $0x7, %rdx
leaq 0x20(%rsp), %rdi
callq 0x26750
leaq 0x10(%rsp), %r15
movq %r15, -0x10(%r15)
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
addq %rsi, %rdx
movq %rsp, %rdi
callq 0x267c0
leaq 0xdde9(%rip), %rsi      # 0x5691c
movq %rsp, %rdi
callq 0x29090
leaq 0x50(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xe136(%rip), %rsi      # 0x56c82
leaq 0xe13c(%rip), %rdx      # 0x56c8f
leaq 0x40(%rsp), %rdi
callq 0x26750
leaq 0x40(%rsp), %rsi
movq %rsp, %rdx
movq %rbx, %rdi
callq 0x288b0
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0x48b7c
callq 0x27560
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x48b8a
callq 0x27560
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
je 0x48b99
callq 0x27560
xorl %eax, %eax
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x48bb2
jmp 0x48bc8
jmp 0x48bc8
jmp 0x48bdb
jmp 0x48bef
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0x48bcb
callq 0x27560
jmp 0x48bcb
jmp 0x48bc8
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x48bde
callq 0x27560
jmp 0x48bde
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
je 0x48bf2
callq 0x27560
jmp 0x48bf2
movq %rax, %rbx
movq %rbx, %rdi
callq 0x28c10