// File: zeeev[P]DASVC/bamtools/src/api/internal/io/BamFtp_p.cpp
// Function: BamTools::Internal::BamFtp::ParsePassiveResponse()
bool BamFtp::ParsePassiveResponse(void) {

    // fail if empty
    if ( m_response.empty() )
        return false;

    // find parentheses
    const size_t leftParenFound  = m_response.find(PASV_REPLY_PREFIX);
    const size_t rightParenFound = m_response.find(PASV_REPLY_SUFFIX);
    if ( leftParenFound == string::npos || rightParenFound == string::npos )
        return false;

    // grab everything between ( should be "h1,h2,h3,h4,p1,p2" )
    string::const_iterator responseBegin = m_response.begin();
    const string hostAndPort(responseBegin+leftParenFound+1, responseBegin+rightParenFound);

    // parse into string fields
    vector<string> fields = split(hostAndPort, PASV_REPLY_SEPARATOR);
    if ( fields.size() != 6 )
        return false;

    // fetch passive connection IP
    m_dataHostname = fields[0] + IP_SEPARATOR +
                     fields[1] + IP_SEPARATOR +
                     fields[2] + IP_SEPARATOR +
                     fields[3];

    // fetch passive connection port
    const uint8_t portUpper = static_cast<uint8_t>(atoi(fields[4].c_str()));
    const uint8_t portLower = static_cast<uint8_t>(atoi(fields[5].c_str()));
    m_dataPort = ( portUpper<<8 ) + portLower;

    // return success
    return true;
}

// Assembly:
subq $0x1c8, %rsp            # imm = 0x1C8
movq %rdi, 0x1b8(%rsp)
movq 0x1b8(%rsp), %rdi
movq %rdi, 0x58(%rsp)
addq $0xf0, %rdi
callq 0x7aba0
testb $0x1, %al
jne 0xc851e
jmp 0xc852b
movb $0x0, 0x1c7(%rsp)
jmp 0xc8a40
movq 0x58(%rsp), %rdi
addq $0xf0, %rdi
movl $0x28, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x787f0
movq 0x58(%rsp), %rdi
movq %rax, 0x1b0(%rsp)
addq $0xf0, %rdi
movl $0x29, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x787f0
movq %rax, 0x1a8(%rsp)
cmpq $-0x1, 0x1b0(%rsp)
je 0xc8585
cmpq $-0x1, 0x1a8(%rsp)
jne 0xc8592
movb $0x0, 0x1c7(%rsp)
jmp 0xc8a40
movq 0x58(%rsp), %rdi
addq $0xf0, %rdi
callq 0x75b90
movq %rax, 0x198(%rsp)
leaq 0x1a0(%rsp), %rdi
movq %rdi, 0x48(%rsp)
leaq 0x198(%rsp), %rsi
callq 0x720f0
movq 0x48(%rsp), %rdi
movq 0x1b0(%rsp), %rsi
callq 0x7b530
movq %rax, 0x168(%rsp)
leaq 0x168(%rsp), %rdi
movl $0x1, %esi
callq 0x7b530
movq 0x48(%rsp), %rdi
movq %rax, 0x170(%rsp)
movq 0x1a8(%rsp), %rsi
callq 0x7b530
movq %rax, 0x160(%rsp)
leaq 0x15f(%rsp), %rdi
movq %rdi, 0x50(%rsp)
callq 0x7b5f0
movq 0x50(%rsp), %rcx
movq 0x170(%rsp), %rsi
movq 0x160(%rsp), %rdx
leaq 0x178(%rsp), %rdi
callq 0x71720
jmp 0xc8649
leaq 0x15f(%rsp), %rdi
callq 0x76f80
leaq 0x130(%rsp), %rdi
leaq 0x178(%rsp), %rsi
movl $0x2c, %edx
callq 0xc8c90
jmp 0xc8672
leaq 0x130(%rsp), %rdi
callq 0x7bb00
movq %rax, 0x40(%rsp)
jmp 0xc8686
movq 0x40(%rsp), %rax
cmpq $0x6, %rax
je 0xc8701
movb $0x0, 0x1c7(%rsp)
movl $0x1, 0x12c(%rsp)
jmp 0xc8a00
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
leaq 0x15f(%rsp), %rdi
callq 0x76f80
jmp 0xc8a51
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
jmp 0xc8a2f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
jmp 0xc8a1e
xorl %eax, %eax
movl %eax, %esi
leaq 0x130(%rsp), %rdi
callq 0x7bba0
movq %rax, 0x38(%rsp)
jmp 0xc8719
movq 0x38(%rsp), %rsi
leaq 0x68(%rsp), %rdi
movl $0x2e, %edx
callq 0x74830
jmp 0xc872f
leaq 0x130(%rsp), %rdi
movl $0x1, %esi
callq 0x7bba0
movq %rax, 0x30(%rsp)
jmp 0xc8748
movq 0x30(%rsp), %rdx
leaq 0x88(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x7c720
jmp 0xc8761
leaq 0xa8(%rsp), %rdi
leaq 0x88(%rsp), %rsi
movl $0x2e, %edx
callq 0x74830
jmp 0xc877d
leaq 0x130(%rsp), %rdi
movl $0x2, %esi
callq 0x7bba0
movq %rax, 0x28(%rsp)
jmp 0xc8796
movq 0x28(%rsp), %rdx
leaq 0xc8(%rsp), %rdi
leaq 0xa8(%rsp), %rsi
callq 0x7c720
jmp 0xc87b2
leaq 0xe8(%rsp), %rdi
leaq 0xc8(%rsp), %rsi
movl $0x2e, %edx
callq 0x74830
jmp 0xc87ce
leaq 0x130(%rsp), %rdi
movl $0x3, %esi
callq 0x7bba0
movq %rax, 0x20(%rsp)
jmp 0xc87e7
movq 0x20(%rsp), %rdx
leaq 0x108(%rsp), %rdi
leaq 0xe8(%rsp), %rsi
callq 0x7c720
jmp 0xc8803
movq 0x58(%rsp), %rdi
addq $0x68, %rdi
leaq 0x108(%rsp), %rsi
callq 0x71240
jmp 0xc881b
leaq 0x108(%rsp), %rdi
callq 0x7cce8
jmp 0xc882a
leaq 0xe8(%rsp), %rdi
callq 0x7cce8
jmp 0xc8839
leaq 0xc8(%rsp), %rdi
callq 0x7cce8
jmp 0xc8848
leaq 0xa8(%rsp), %rdi
callq 0x7cce8
jmp 0xc8857
leaq 0x88(%rsp), %rdi
callq 0x7cce8
jmp 0xc8866
leaq 0x68(%rsp), %rdi
callq 0x7cce8
jmp 0xc8872
leaq 0x130(%rsp), %rdi
movl $0x4, %esi
callq 0x7bba0
movq %rax, 0x18(%rsp)
jmp 0xc888b
movq 0x18(%rsp), %rdi
callq 0x73020
movq %rax, 0x10(%rsp)
jmp 0xc889c
movq 0x10(%rsp), %rdi
callq 0x7a180
movb %al, 0x67(%rsp)
leaq 0x130(%rsp), %rdi
movl $0x5, %esi
callq 0x7bba0
movq %rax, 0x8(%rsp)
jmp 0xc88c3
movq 0x8(%rsp), %rdi
callq 0x73020
movq %rax, (%rsp)
jmp 0xc88d3
movq (%rsp), %rdi
callq 0x7a180
movl %eax, %ecx
movq 0x58(%rsp), %rax
movb %cl, 0x66(%rsp)
movzbl 0x67(%rsp), %ecx
shll $0x8, %ecx
movzbl 0x66(%rsp), %edx
addl %edx, %ecx
movw %cx, 0x88(%rax)
movb $0x1, 0x1c7(%rsp)
movl $0x1, 0x12c(%rsp)
jmp 0xc8a00
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
jmp 0xc89f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
jmp 0xc89e1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
jmp 0xc89d0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
jmp 0xc89bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
jmp 0xc89ae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x150(%rsp)
movl %eax, 0x14c(%rsp)
leaq 0x108(%rsp), %rdi
callq 0x7cce8
jmp 0xc89ac
jmp 0xc89ae
leaq 0xe8(%rsp), %rdi
callq 0x7cce8
jmp 0xc89bd
jmp 0xc89bf
leaq 0xc8(%rsp), %rdi
callq 0x7cce8
jmp 0xc89ce
jmp 0xc89d0
leaq 0xa8(%rsp), %rdi
callq 0x7cce8
jmp 0xc89df
jmp 0xc89e1
leaq 0x88(%rsp), %rdi
callq 0x7cce8
jmp 0xc89f0
jmp 0xc89f2
leaq 0x68(%rsp), %rdi
callq 0x7cce8
jmp 0xc89fe
jmp 0xc8a1e
leaq 0x130(%rsp), %rdi
callq 0x74e60
jmp 0xc8a0f
leaq 0x178(%rsp), %rdi
callq 0x7cce8
jmp 0xc8a40
leaq 0x130(%rsp), %rdi
callq 0x74e60
jmp 0xc8a2d
jmp 0xc8a2f
leaq 0x178(%rsp), %rdi
callq 0x7cce8
jmp 0xc8a3e
jmp 0xc8a51
movb 0x1c7(%rsp), %al
andb $0x1, %al
addq $0x1c8, %rsp            # imm = 0x1C8
retq
movq 0x150(%rsp), %rdi
callq 0x7b550
movq %rax, %rdi
callq 0x88ef0
nopw %cs:(%rax,%rax)