// File: /workspace/github_cpp_makefile_star2_O1/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 0x48aee
leaq 0xde18(%rip), %rsi      # 0x568fd
movq 0x2247c(%rip), %rax     # 0x6af68
jmp 0x48b05
cmpl $0x2, %ebp
jne 0x48bb5
leaq 0xde02(%rip), %rsi      # 0x56900
movq 0x223e3(%rip), %rax     # 0x6aee8
movq (%rax), %rdx
xorl %edi, %edi
callq 0x27550
movq %rax, 0x30(%rbx)
testq %rax, %rax
je 0x48b22
movl %ebp, 0x8(%rbx)
movb $0x1, %al
jmp 0x48c77
leaq 0x30(%rsp), %r14
movq %r14, -0x10(%r14)
leaq 0xe15e(%rip), %rsi      # 0x56c90
leaq 0xe170(%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 0xdd76(%rip), %rax      # 0x568e1
leaq 0xdd75(%rip), %rsi      # 0x568e7
cmoveq %rax, %rsi
movq %rsp, %rdi
callq 0x290a0
leaq 0x50(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xe0f3(%rip), %rsi      # 0x56c82
leaq 0xe0f9(%rip), %rdx      # 0x56c8f
leaq 0x40(%rsp), %rdi
callq 0x26750
leaq 0x40(%rsp), %rsi
movq %rsp, %rdx
movq %rbx, %rdi
callq 0x288c0
jmp 0x48c49
xorl %eax, %eax
cmpl $0x3, %ebp
leaq 0xe0b5(%rip), %rcx      # 0x56c76
leaq 0xc5c3(%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 0xdd0d(%rip), %rsi      # 0x5691c
movq %rsp, %rdi
callq 0x290a0
leaq 0x50(%rsp), %r12
movq %r12, -0x10(%r12)
leaq 0xe05a(%rip), %rsi      # 0x56c82
leaq 0xe060(%rip), %rdx      # 0x56c8f
leaq 0x40(%rsp), %rdi
callq 0x26750
leaq 0x40(%rsp), %rsi
movq %rsp, %rdx
movq %rbx, %rdi
callq 0x288c0
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0x48c58
callq 0x27560
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x48c66
callq 0x27560
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
je 0x48c75
callq 0x27560
xorl %eax, %eax
addq $0x60, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x48c8e
jmp 0x48ca4
jmp 0x48ca4
jmp 0x48cb7
jmp 0x48ccb
movq %rax, %rbx
movq 0x40(%rsp), %rdi
cmpq %r12, %rdi
je 0x48ca7
callq 0x27560
jmp 0x48ca7
jmp 0x48ca4
movq %rax, %rbx
movq (%rsp), %rdi
cmpq %r15, %rdi
je 0x48cba
callq 0x27560
jmp 0x48cba
movq %rax, %rbx
movq 0x20(%rsp), %rdi
cmpq %r14, %rdi
je 0x48cce
callq 0x27560
jmp 0x48cce
movq %rax, %rbx
movq %rbx, %rdi
callq 0x28c20