// File: /workspace/github_cpp_makefile_star2_O2/kn-sumanth[P]tcpproxy_server/tcpproxy_server.cpp
// Function: main
int main(int argc, char* argv[])
{
   signal(SIGINT,sig_handler);
   signal(SIGTERM,sig_handler);
   signal(SIGABRT,sig_handler);

   if (argc < 5)
   {
      std::cerr << "usage: tcpproxy_server <local host ip> <local port> <forward host ip> <forward port> <delay_ms>" << std::endl;
      return 1;
   }

   unsigned short delay = 0;
   const unsigned short local_port   = static_cast<unsigned short>(::atoi(argv[2]));
   const unsigned short forward_port = static_cast<unsigned short>(::atoi(argv[4]));
   if (argc > 5)
   {
     delay = static_cast<unsigned short>(::atoi(argv[5]));
   }
   const std::string local_host      = argv[1];
   const std::string forward_host    = argv[3];

   boost::asio::io_service ios;

   try
   {
      tcp_proxy::bridge::acceptor acceptor(ios, delay,
                                           local_host, local_port,
                                           forward_host, forward_port);

      acceptor.accept_connections();

      ios.run();
   }
   catch(std::exception& e)
   {
      std::cerr << "Error: " << e.what() << std::endl;
      return 1;
   }

   return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0xf8, %rsp
movq %rsi, %rbx
movl %edi, %r15d
leaq -0x23(%rip), %r14       # 0x78dc
pushq $0x2
popq %rdi
movq %r14, %rsi
callq 0x7320
pushq $0xf
popq %rdi
movq %r14, %rsi
callq 0x7320
pushq $0x6
popq %rdi
movq %r14, %rsi
callq 0x7320
cmpl $0x4, %r15d
jg 0x7949
movq 0x196bb(%rip), %rdi     # 0x20fe8
leaq 0xb70c(%rip), %rsi      # 0x13040
callq 0x72d0
movq %rax, %rdi
callq 0x7170
pushq $0x1
popq %rbx
jmp 0x7a0d
movq 0x10(%rbx), %rdi
callq 0x7480
movl %eax, %ebp
movq 0x20(%rbx), %rdi
callq 0x7480
movl %eax, %r14d
cmpl $0x5, %r15d
jne 0x796b
xorl %r15d, %r15d
jmp 0x7977
movq 0x28(%rbx), %rdi
callq 0x7480
movl %eax, %r15d
movq 0x8(%rbx), %rsi
leaq 0x40(%rsp), %rdi
leaq 0x60(%rsp), %rdx
callq 0x7140
movq 0x18(%rbx), %rsi
leaq 0x20(%rsp), %rdi
leaq 0x60(%rsp), %rdx
callq 0x7140
leaq 0x10(%rsp), %rdi
callq 0x7d2c
movzwl %r14w, %eax
movl %eax, (%rsp)
movzwl %r15w, %edx
movzwl %bp, %r8d
leaq 0x60(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0x40(%rsp), %rcx
leaq 0x20(%rsp), %r9
callq 0x7d94
leaq 0x60(%rsp), %rdi
callq 0x7e58
leaq 0x10(%rsp), %rdi
callq 0x7f74
leaq 0x60(%rsp), %rdi
callq 0x7fb8
xorl %ebx, %ebx
leaq 0x10(%rsp), %rdi
callq 0x8012
leaq 0x20(%rsp), %rdi
callq 0x7350
leaq 0x40(%rsp), %rdi
callq 0x7350
movl %ebx, %eax
addq $0xf8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7a1f
movq %rax, %rbx
jmp 0x7abd
movq %rax, %rbx
jmp 0x7ac7
movq %rdx, %r14
movq %rax, %rbx
jmp 0x7a47
movq %rdx, %r14
movq %rax, %rbx
leaq 0x60(%rsp), %rdi
callq 0x7fb8
cmpl $0x1, %r14d
jne 0x7aa4
movq %rbx, %rdi
callq 0x7150
movq %rax, %rbx
movq 0x19589(%rip), %rdi     # 0x20fe8
leaq 0xb63a(%rip), %rsi      # 0x130a0
callq 0x72d0
movq %rax, %r14
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
movq %r14, %rdi
movq %rax, %rsi
callq 0x72d0
movq %rax, %rdi
callq 0x7170
callq 0x74a0
pushq $0x1
popq %rbx
jmp 0x79ef
movq %rax, %rbx
jmp 0x7aa4
movq %rax, %rbx
callq 0x74a0
leaq 0x10(%rsp), %rdi
callq 0x8012
jmp 0x7ab3
movq %rax, %rbx
leaq 0x20(%rsp), %rdi
callq 0x7350
leaq 0x40(%rsp), %rdi
callq 0x7350
movq %rbx, %rdi
callq 0x74d0
movq %rax, %rdi
callq 0x7c40
nop