// File: /workspace/github_cpp_makefile_star2_O2/jflemer[P]boost-chat-server/chat_client.cpp
// Function: main
int main(int argc, char* argv[])
{
  try
  {
    if (argc != 3)
    {
      std::cerr << "Usage: chat_client <host> <port>\n";
      return 1;
    }

    boost::asio::io_service io_service;

    tcp::resolver resolver(io_service);
    tcp::resolver::query query(argv[1], argv[2]);
    tcp::resolver::iterator iterator = resolver.resolve(query);

    chat_client<> c(io_service, iterator);

    boost::thread t(boost::bind(&boost::asio::io_service::run, &io_service));

    char line[chat_message::max_body_length + 1];
    while (std::cin.getline(line, chat_message::max_body_length + 1))
    {
      using namespace std; // For strlen and memcpy.
      chat_message msg;
      msg.body_length(strlen(line));
      memcpy(msg.body(), line, msg.body_length());
      msg.encode_header();
      c.write(msg);
    }

    c.close();
    t.join();
  }
  catch (std::exception& e)
  {
    std::cerr << "Exception: " << e.what() << "\n";
  }

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x7e8, %rsp            # imm = 0x7E8
cmpl $0x3, %edi
jne 0x69bb
movq %rsi, %rbx
movq %rsp, %rdi
callq 0x6cc8
leaq 0x58(%rsp), %rdi
movq %rsp, %rsi
xorl %edx, %edx
callq 0x9a54
movq 0x8(%rbx), %rsi
leaq 0x110(%rsp), %rdi
leaq 0x5e0(%rsp), %rdx
callq 0x6d2c
movq 0x10(%rbx), %rsi
leaq 0x3d0(%rsp), %rdi
leaq 0x20(%rsp), %rdx
callq 0x6d2c
leaq 0xa0(%rsp), %rdi
leaq 0x110(%rsp), %rsi
leaq 0x3d0(%rsp), %rdx
pushq $0x20
popq %rcx
callq 0x6d68
leaq 0x3d0(%rsp), %rdi
callq 0x6160
leaq 0x110(%rsp), %rdi
callq 0x6160
leaq 0x110(%rsp), %rdi
leaq 0x58(%rsp), %rsi
leaq 0xa0(%rsp), %rdx
callq 0x6dd4
leaq 0x28(%rsp), %rcx
leaq 0x118(%rsp), %rdi
movaps -0x8(%rdi), %xmm0
xorps %xmm1, %xmm1
movq 0x8(%rdi), %rax
movups %xmm1, (%rdi)
movaps %xmm0, -0x8(%rcx)
andq $0x0, -0x8(%rdi)
movq %rax, 0x8(%rcx)
callq 0x8f3e
leaq 0x40(%rsp), %r15
leaq 0x20(%rsp), %rsi
movq %r15, %rdi
callq 0x6e3e
leaq 0x110(%rsp), %rdi
movq %rsp, %r14
movq %r14, %rsi
movq %r15, %rdx
callq 0x6e5e
leaq 0x48(%rsp), %rdi
callq 0x8f3e
leaq 0x5ed(%rip), %rax       # 0x6f06
leaq 0x3d0(%rsp), %rsi
movq %rax, (%rsi)
andq $0x0, 0x8(%rsi)
movq %r14, 0x10(%rsi)
leaq 0x10(%rsp), %rdi
callq 0x6f46
leaq 0x3d4(%rsp), %r14
movq 0x1868a(%rip), %r15     # 0x1efd0
leaq 0x5e0(%rsp), %r12
movl $0x200, %ebx            # imm = 0x200
leaq 0x3d0(%rsp), %r13
leaq 0x110(%rsp), %rbp
movl $0x201, %edx            # imm = 0x201
movq %r15, %rdi
movq %r12, %rsi
callq 0x60e0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x69d3
movq %r12, %rdi
callq 0x6150
cmpq %rbx, %rax
cmovaeq %rbx, %rax
movq %rax, 0x5d8(%rsp)
movq %r14, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x6280
movq %r13, %rdi
callq 0x6f90
movq %rbp, %rdi
movq %r13, %rsi
callq 0x6fc8
jmp 0x6963
movq 0x18626(%rip), %rdi     # 0x1efe8
leaq 0xb6b3(%rip), %rsi      # 0x1207c
callq 0x6300
pushq $0x1
popq %rax
jmp 0x6a2c
leaq 0x110(%rsp), %rdi
callq 0x701a
leaq 0x10(%rsp), %rdi
callq 0x7044
leaq 0x10(%rsp), %rdi
callq 0x70a6
leaq 0x110(%rsp), %rdi
callq 0x70c4
leaq 0x28(%rsp), %rdi
callq 0x8f3e
leaq 0xa0(%rsp), %rdi
callq 0x70e2
leaq 0x58(%rsp), %rdi
callq 0xb69e
movq %rsp, %rdi
callq 0x70fc
xorl %eax, %eax
addq $0x7e8, %rsp            # imm = 0x7E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rdx, %r15
movq %rax, %r14
jmp 0x6ab8
movq %rdx, %r15
movq %rax, %r14
leaq 0x48(%rsp), %rdi
callq 0x8f3e
jmp 0x6ac5
movq %rdx, %r15
movq %rax, %r14
jmp 0x6acf
movq %rdx, %r15
movq %rax, %r14
leaq 0x3d0(%rsp), %rdi
callq 0x6160
jmp 0x6a7b
movq %rdx, %r15
movq %rax, %r14
leaq 0x110(%rsp), %rdi
callq 0x6160
jmp 0x6adc
movq %rdx, %r15
movq %rax, %r14
jmp 0x6adc
movq %rdx, %r15
movq %rax, %r14
jmp 0x6ae6
jmp 0x6a9c
movq %rdx, %r15
movq %rax, %r14
jmp 0x6aee
jmp 0x6aa8
jmp 0x6aa8
movq %rdx, %r15
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0x70a6
leaq 0x110(%rsp), %rdi
callq 0x70c4
leaq 0x28(%rsp), %rdi
callq 0x8f3e
leaq 0xa0(%rsp), %rdi
callq 0x70e2
leaq 0x58(%rsp), %rdi
callq 0xb69e
movq %rsp, %rdi
callq 0x70fc
cmpl $0x1, %r15d
jne 0x6b4a
movq %r14, %rdi
callq 0x6140
movq %rax, %rbx
movq 0x184e2(%rip), %rdi     # 0x1efe8
leaq 0xb591(%rip), %rsi      # 0x1209e
callq 0x6300
movq %rax, %r14
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
movq %r14, %rdi
movq %rax, %rsi
callq 0x6300
leaq 0xb56c(%rip), %rsi      # 0x1209c
movq %rax, %rdi
callq 0x6300
callq 0x6530
jmp 0x6a2a
movq %rax, %r14
callq 0x6530
movq %r14, %rdi
callq 0x6560
movq %rax, %rdi
callq 0x6c15