// File: jBlinden[P]private-codis/ProtocolClient.cpp
// Function: StartClient(char const*, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void StartClient(const char *address, int port, string pArgsFile, string clientDataDir)
{
  CSocket *socket = new CSocket();

  if (Connect(socket, address, port))
  {
    ClientLog("successfully connected to server");
  }
  else
  {
    stringstream ss;
    ss << "unable to connect to port " << port << " on address " << address;
    ClientLog(ss.str());
    return;
  }

  auto t_start = chrono::high_resolution_clock::now();

  RunClientProtocol(socket, pArgsFile, clientDataDir);

  auto t_end = chrono::high_resolution_clock::now();
  chrono::duration<float> duration = t_end - t_start;

  ClientLog("protocol execution completed");

  cout << "protocol execution time: " << duration.count() << " seconds" << endl;
  cout << "total bytes sent: " << socket->GetBytesSent() << endl;
  cout << "total bytes received: " << socket->GetBytesReceived() << endl;
  cout << "total bytes communicated (received + sent): " << socket->GetBytesSent() + socket->GetBytesReceived() << endl;


  socket->Close();

  delete socket;
}

// Assembly:
subq $0x308, %rsp            # imm = 0x308
movq %rdx, 0x60(%rsp)
movq %rcx, 0x68(%rsp)
movq %rdi, 0x300(%rsp)
movl %esi, 0x2fc(%rsp)
movq %rdx, 0x2f0(%rsp)
movq %rcx, 0x2e8(%rsp)
movl $0x20, %edi
callq 0x32c0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, 0x70(%rsp)
callq 0x5390
jmp 0x499c
movq 0x70(%rsp), %rax
movq %rax, 0x2e0(%rsp)
movq 0x2e0(%rsp), %rdi
movq 0x300(%rsp), %rsi
movl 0x2fc(%rsp), %edx
callq 0x59d0
testb $0x1, %al
jne 0x49ce
jmp 0x4a95
leaq 0x2af(%rsp), %rdi
movq %rdi, 0x58(%rsp)
callq 0x3470
movq 0x58(%rsp), %rdx
leaq 0x565f(%rip), %rsi      # 0xa04b
leaq 0x2b0(%rsp), %rdi
callq 0x33a0
jmp 0x49fb
leaq 0x2b0(%rsp), %rdi
callq 0x48b0
jmp 0x4a0a
leaq 0x2b0(%rsp), %rdi
callq 0x31a0
leaq 0x2af(%rsp), %rdi
callq 0x3300
jmp 0x4b8f
movq 0x70(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
callq 0x3270
jmp 0x4e7c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
jmp 0x4a83
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
leaq 0x2b0(%rsp), %rdi
callq 0x31a0
leaq 0x2af(%rsp), %rdi
callq 0x3300
jmp 0x4e7c
leaq 0x120(%rsp), %rdi
callq 0x31c0
leaq 0x130(%rsp), %rdi
leaq 0x55bb(%rip), %rsi      # 0xa06c
callq 0x32a0
movq %rax, 0x50(%rsp)
jmp 0x4abd
movq 0x50(%rsp), %rdi
movl 0x2fc(%rsp), %esi
callq 0x3450
movq %rax, 0x48(%rsp)
jmp 0x4ad5
movq 0x48(%rsp), %rdi
leaq 0x55a6(%rip), %rsi      # 0xa087
callq 0x32a0
movq %rax, 0x40(%rsp)
jmp 0x4aed
movq 0x40(%rsp), %rdi
movq 0x300(%rsp), %rsi
callq 0x32a0
jmp 0x4b01
leaq 0x100(%rsp), %rdi
leaq 0x120(%rsp), %rsi
callq 0x3290
jmp 0x4b18
leaq 0x100(%rsp), %rdi
callq 0x48b0
jmp 0x4b27
leaq 0x100(%rsp), %rdi
callq 0x31a0
leaq 0x120(%rsp), %rdi
callq 0x31e0
jmp 0x4ded
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
jmp 0x4b7d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
leaq 0x100(%rsp), %rdi
callq 0x31a0
leaq 0x120(%rsp), %rdi
callq 0x31e0
jmp 0x4e7c
callq 0x3050
movq 0x60(%rsp), %rsi
movq %rax, 0xf8(%rsp)
movq 0x2e0(%rsp), %rax
movq %rax, 0x38(%rsp)
leaq 0xd8(%rsp), %rdi
callq 0x3130
movq 0x68(%rsp), %rsi
leaq 0xb8(%rsp), %rdi
callq 0x3130
jmp 0x4bcf
movq 0x38(%rsp), %rdi
leaq 0xd8(%rsp), %rsi
leaq 0xb8(%rsp), %rdx
callq 0x36b0
jmp 0x4beb
leaq 0xb8(%rsp), %rdi
callq 0x31a0
leaq 0xd8(%rsp), %rdi
callq 0x31a0
callq 0x3050
movq %rax, 0xb0(%rsp)
leaq 0xb0(%rsp), %rdi
leaq 0xf8(%rsp), %rsi
callq 0x53c0
movq %rax, 0xa0(%rsp)
leaq 0xac(%rsp), %rdi
leaq 0xa0(%rsp), %rsi
callq 0x5410
leaq 0x7f(%rsp), %rdi
movq %rdi, 0x30(%rsp)
callq 0x3470
movq 0x30(%rsp), %rdx
leaq 0x5435(%rip), %rsi      # 0xa094
leaq 0x80(%rsp), %rdi
callq 0x33a0
jmp 0x4c6e
leaq 0x80(%rsp), %rdi
callq 0x48b0
jmp 0x4c7d
leaq 0x80(%rsp), %rdi
callq 0x31a0
leaq 0x7f(%rsp), %rdi
callq 0x3300
movq 0x833d(%rip), %rdi      # 0xcfd8
leaq 0x540f(%rip), %rsi      # 0xa0b1
callq 0x32a0
movq %rax, (%rsp)
leaq 0xac(%rsp), %rdi
callq 0x5450
movq (%rsp), %rdi
callq 0x31d0
movq %rax, %rdi
leaq 0x5400(%rip), %rsi      # 0xa0cb
callq 0x32a0
movq %rax, %rdi
movq 0x82e6(%rip), %rsi      # 0xcfc0
callq 0x32f0
movq 0x82f2(%rip), %rdi      # 0xcfd8
leaq 0x53e7(%rip), %rsi      # 0xa0d4
callq 0x32a0
movq %rax, 0x8(%rsp)
movq 0x2e0(%rsp), %rdi
callq 0x5460
movq 0x8(%rsp), %rdi
movq %rax, %rsi
callq 0x30a0
movq %rax, %rdi
movq 0x82a5(%rip), %rsi      # 0xcfc0
callq 0x32f0
movq 0x82b1(%rip), %rdi      # 0xcfd8
leaq 0x53b9(%rip), %rsi      # 0xa0e7
callq 0x32a0
movq %rax, 0x10(%rsp)
movq 0x2e0(%rsp), %rdi
callq 0x5470
movq 0x10(%rsp), %rdi
movq %rax, %rsi
callq 0x30a0
movq %rax, %rdi
movq 0x8264(%rip), %rsi      # 0xcfc0
callq 0x32f0
movq 0x8270(%rip), %rdi      # 0xcfd8
leaq 0x538f(%rip), %rsi      # 0xa0fe
callq 0x32a0
movq %rax, 0x20(%rsp)
movq 0x2e0(%rsp), %rdi
callq 0x5460
movq %rax, 0x18(%rsp)
movq 0x2e0(%rsp), %rdi
callq 0x5470
movq 0x18(%rsp), %rsi
movq 0x20(%rsp), %rdi
addq %rax, %rsi
callq 0x30a0
movq %rax, %rdi
movq 0x820c(%rip), %rsi      # 0xcfc0
callq 0x32f0
movq 0x2e0(%rsp), %rdi
callq 0x5480
movq 0x2e0(%rsp), %rax
movq %rax, 0x28(%rsp)
cmpq $0x0, %rax
je 0x4ded
movq 0x28(%rsp), %rdi
callq 0x54d0
movq 0x28(%rsp), %rdi
callq 0x3270
addq $0x308, %rsp            # imm = 0x308
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
jmp 0x4e2c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
leaq 0xb8(%rsp), %rdi
callq 0x31a0
leaq 0xd8(%rsp), %rdi
callq 0x31a0
jmp 0x4e7c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
jmp 0x4e72
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x2d8(%rsp)
movl %eax, 0x2d4(%rsp)
leaq 0x80(%rsp), %rdi
callq 0x31a0
leaq 0x7f(%rsp), %rdi
callq 0x3300
movq 0x2d8(%rsp), %rdi
callq 0x3460
nopl (%rax)