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

    BT_ASSERT_X(m_commandSocket, "null command socket?");

    // connect to FTP server
    if ( !m_commandSocket->ConnectToHost(m_hostname, m_port, m_mode) ) {
        SetErrorString("BamFtp::ConnectCommandSocket", "could not connect to host - ");
        return false;
    }

    // receive initial reply from host
    if ( !ReceiveReply() ) {
        Close();
        return false;
    }

    // send USER command
    string userCommand = USER_CMD + CMD_SEPARATOR + m_username + FTP_NEWLINE;
    if ( !SendCommand(userCommand, true) ) {
        Close();
        return false;
    }

    // send PASS command
    string passwordCommand = PASS_CMD + CMD_SEPARATOR + m_password + FTP_NEWLINE;
    if ( !SendCommand(passwordCommand, true) ) {
        Close();
        return false;
    }

    // send TYPE command
    string typeCommand = TYPE_CMD + CMD_SEPARATOR + 'I' + FTP_NEWLINE;
    if ( !SendCommand(typeCommand, true) ) {
        Close();
        return false;
    }

    // return success
    return true;
}

// Assembly:
subq $0x1c8, %rsp            # imm = 0x1C8
movq %rdi, 0x1b8(%rsp)
movq 0x1b8(%rsp), %rax
movq %rax, 0x28(%rsp)
callq 0x761a0
movq 0x28(%rsp), %rcx
movq 0x30(%rcx), %rdi
movq %rcx, %rsi
addq $0x40, %rsi
movw 0x60(%rcx), %ax
movl 0x8(%rcx), %ecx
movzwl %ax, %edx
callq 0x78770
testb $0x1, %al
jne 0xc7274
leaq 0x197(%rsp), %rdi
movq %rdi, 0x20(%rsp)
callq 0x7b5f0
movq 0x20(%rsp), %rdx
leaq 0x24ab8(%rip), %rsi     # 0xebc0e
leaq 0x198(%rsp), %rdi
callq 0x78e70
jmp 0xc7165
leaq 0x15f(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x7b5f0
movq 0x18(%rsp), %rdx
leaq 0x24aa8(%rip), %rsi     # 0xebc2b
leaq 0x160(%rsp), %rdi
callq 0x78e70
jmp 0xc7192
movq 0x28(%rsp), %rdi
leaq 0x198(%rsp), %rsi
leaq 0x160(%rsp), %rdx
callq 0x7ab60
jmp 0xc71ae
leaq 0x160(%rsp), %rdi
callq 0x7cce8
jmp 0xc71bd
leaq 0x15f(%rsp), %rdi
callq 0x76f80
leaq 0x198(%rsp), %rdi
callq 0x7cce8
jmp 0xc71d9
leaq 0x197(%rsp), %rdi
callq 0x76f80
movb $0x0, 0x1c7(%rsp)
jmp 0xc7678
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
jmp 0xc7262
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
jmp 0xc7244
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
leaq 0x160(%rsp), %rdi
callq 0x7cce8
jmp 0xc7242
jmp 0xc7244
leaq 0x15f(%rsp), %rdi
callq 0x76f80
leaq 0x198(%rsp), %rdi
callq 0x7cce8
jmp 0xc7260
jmp 0xc7262
leaq 0x197(%rsp), %rdi
callq 0x76f80
jmp 0xc7689
movq 0x28(%rsp), %rdi
callq 0x77950
testb $0x1, %al
jne 0xc729a
movq 0x28(%rsp), %rdi
movq (%rdi), %rax
callq *0x10(%rax)
movb $0x0, 0x1c7(%rsp)
jmp 0xc7678
leaq 0x519af(%rip), %rsi     # 0x118c50
leaq 0xf8(%rsp), %rdi
movq %rdi, 0x10(%rsp)
movl $0x20, %edx
callq 0x74830
movq 0x28(%rsp), %rdx
movq 0x10(%rsp), %rsi
addq $0xb0, %rdx
leaq 0x118(%rsp), %rdi
callq 0x7c720
jmp 0xc72d8
leaq 0x518f1(%rip), %rdx     # 0x118bd0
leaq 0x138(%rsp), %rdi
leaq 0x118(%rsp), %rsi
callq 0x7c720
jmp 0xc72f6
leaq 0x118(%rsp), %rdi
callq 0x7cce8
jmp 0xc7305
leaq 0xf8(%rsp), %rdi
callq 0x7cce8
movq 0x28(%rsp), %rdi
leaq 0x138(%rsp), %rsi
movl $0x1, %edx
callq 0x798e0
movb %al, 0xf(%rsp)
jmp 0xc732f
movb 0xf(%rsp), %al
testb $0x1, %al
jne 0xc73cd
jmp 0xc733d
movq 0x28(%rsp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
jmp 0xc734d
movb $0x0, 0x1c7(%rsp)
movl $0x1, 0xf4(%rsp)
jmp 0xc7658
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
jmp 0xc73a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
leaq 0x118(%rsp), %rdi
callq 0x7cce8
jmp 0xc739e
jmp 0xc73a0
leaq 0xf8(%rsp), %rdi
callq 0x7cce8
jmp 0xc73af
jmp 0xc7689
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
jmp 0xc7667
leaq 0x5189c(%rip), %rsi     # 0x118c70
leaq 0x90(%rsp), %rdi
movl $0x20, %edx
callq 0x74830
jmp 0xc73e8
movq 0x28(%rsp), %rdx
addq $0xd0, %rdx
leaq 0xb0(%rsp), %rdi
leaq 0x90(%rsp), %rsi
callq 0x7c720
jmp 0xc740b
leaq 0x517be(%rip), %rdx     # 0x118bd0
leaq 0xd0(%rsp), %rdi
leaq 0xb0(%rsp), %rsi
callq 0x7c720
jmp 0xc7429
leaq 0xb0(%rsp), %rdi
callq 0x7cce8
jmp 0xc7438
leaq 0x90(%rsp), %rdi
callq 0x7cce8
jmp 0xc7447
movq 0x28(%rsp), %rdi
leaq 0xd0(%rsp), %rsi
movl $0x1, %edx
callq 0x798e0
movb %al, 0xe(%rsp)
jmp 0xc7464
movb 0xe(%rsp), %al
testb $0x1, %al
jne 0xc7502
jmp 0xc7472
movq 0x28(%rsp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
jmp 0xc7482
movb $0x0, 0x1c7(%rsp)
movl $0x1, 0xf4(%rsp)
jmp 0xc7636
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
jmp 0xc74d5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
leaq 0xb0(%rsp), %rdi
callq 0x7cce8
jmp 0xc74d3
jmp 0xc74d5
leaq 0x90(%rsp), %rdi
callq 0x7cce8
jmp 0xc74e4
jmp 0xc7667
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
jmp 0xc7647
leaq 0x51807(%rip), %rsi     # 0x118d10
leaq 0x30(%rsp), %rdi
movl $0x20, %edx
callq 0x74830
jmp 0xc751a
leaq 0x50(%rsp), %rdi
leaq 0x30(%rsp), %rsi
movl $0x49, %edx
callq 0x74830
jmp 0xc7530
leaq 0x51699(%rip), %rdx     # 0x118bd0
leaq 0x70(%rsp), %rdi
leaq 0x50(%rsp), %rsi
callq 0x7c720
jmp 0xc7548
leaq 0x50(%rsp), %rdi
callq 0x7cce8
jmp 0xc7554
leaq 0x30(%rsp), %rdi
callq 0x7cce8
jmp 0xc7560
movq 0x28(%rsp), %rdi
leaq 0x70(%rsp), %rsi
movl $0x1, %edx
callq 0x798e0
movb %al, 0xd(%rsp)
jmp 0xc757a
movb 0xd(%rsp), %al
testb $0x1, %al
jne 0xc7613
jmp 0xc7588
movq 0x28(%rsp), %rdi
movq (%rdi), %rax
movq 0x10(%rax), %rax
callq *%rax
jmp 0xc7598
movb $0x0, 0x1c7(%rsp)
movl $0x1, 0xf4(%rsp)
jmp 0xc7626
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
jmp 0xc75e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
leaq 0x50(%rsp), %rdi
callq 0x7cce8
jmp 0xc75e3
jmp 0xc75e5
leaq 0x30(%rsp), %rdi
callq 0x7cce8
jmp 0xc75f1
jmp 0xc7647
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x188(%rsp)
movl %eax, 0x184(%rsp)
leaq 0x70(%rsp), %rdi
callq 0x7cce8
jmp 0xc7634
movb $0x1, 0x1c7(%rsp)
movl $0x1, 0xf4(%rsp)
leaq 0x70(%rsp), %rdi
callq 0x7cce8
jmp 0xc7632
jmp 0xc7636
jmp 0xc7647
leaq 0xd0(%rsp), %rdi
callq 0x7cce8
jmp 0xc7645
jmp 0xc7658
leaq 0xd0(%rsp), %rdi
callq 0x7cce8
jmp 0xc7656
jmp 0xc7667
leaq 0x138(%rsp), %rdi
callq 0x7cce8
jmp 0xc7678
leaq 0x138(%rsp), %rdi
callq 0x7cce8
jmp 0xc7676
jmp 0xc7689
movb 0x1c7(%rsp), %al
andb $0x1, %al
addq $0x1c8, %rsp            # imm = 0x1C8
retq
movq 0x188(%rsp), %rdi
callq 0x7b550
movq %rax, %rdi
callq 0x88ef0
nop