// File: /workspace/github_cpp_makefile_star2_O3/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 $0x148, %rsp            # imm = 0x148
movq %rsi, %r14
movl %edi, %r15d
leaq -0x25(%rip), %rbx       # 0x82ec
movl $0x2, %edi
movq %rbx, %rsi
callq 0x7380
movl $0xf, %edi
movq %rbx, %rsi
callq 0x7380
movl $0x6, %edi
movq %rbx, %rsi
callq 0x7380
cmpl $0x4, %r15d
jg 0x838a
movq 0x1bca3(%rip), %rbx     # 0x23fe8
leaq 0xecf4(%rip), %rsi      # 0x17040
movl $0x5f, %edx
movq %rbx, %rdi
callq 0x7360
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x7310
movsbl %al, %esi
movq %rbx, %rdi
callq 0x7040
movq %rax, %rdi
callq 0x7230
movl $0x1, %ebx
jmp 0x8511
movq 0x10(%r14), %rdi
callq 0x74d0
movl %eax, %ebx
movq 0x20(%r14), %rdi
callq 0x74d0
movl %eax, %ebp
cmpl $0x5, %r15d
jne 0x83ab
xorl %r15d, %r15d
jmp 0x83b7
movq 0x28(%r14), %rdi
callq 0x74d0
movl %eax, %r15d
movq 0x8(%r14), %rsi
leaq 0x50(%rsp), %rdi
leaq 0x70(%rsp), %rdx
callq 0x7160
movq 0x18(%r14), %rsi
leaq 0x30(%rsp), %rdi
leaq 0x70(%rsp), %rdx
callq 0x7160
leaq 0x10(%rsp), %rdi
callq 0x8858
movzwl %bp, %eax
movl %eax, (%rsp)
movzwl %r15w, %edx
movzwl %bx, %r8d
leaq 0x70(%rsp), %rdi
leaq 0x10(%rsp), %rsi
leaq 0x50(%rsp), %rcx
leaq 0x30(%rsp), %r9
callq 0x8960
leaq 0x70(%rsp), %rdi
callq 0x8a3e
leaq 0x20(%rsp), %rdi
callq 0xaa32
movq 0x18(%rsp), %rdi
leaq 0x20(%rsp), %rsi
callq 0xaa5e
cmpb $0x1, 0x24(%rsp)
je 0x8526
leaq 0xf8(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8452
callq 0x7300
movq 0xd8(%rsp), %rbx
testq %rbx, %rbx
je 0x847d
lock
decl 0x8(%rbx)
jne 0x847d
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
lock
decl 0xc(%rbx)
jne 0x847d
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x18(%rax)
leaq 0x80(%rsp), %rdi
callq 0xc2bc
xorl %ebx, %ebx
movq 0x10(%rsp), %r14
movq 0x38(%r14), %r15
testq %r15, %r15
je 0x84da
movq (%r15), %rax
movq %r15, %rdi
callq *0x10(%rax)
movq 0x20(%r15), %r15
testq %r15, %r15
jne 0x849a
movq 0x10(%rsp), %r14
movq 0x38(%r14), %r15
testq %r15, %r15
je 0x84da
movq %r15, %rdi
movq (%r15), %rax
movq 0x20(%r15), %r15
callq *0x8(%rax)
movq %r15, 0x38(%r14)
testq %r15, %r15
jne 0x84ba
movq 0x10(%rsp), %r14
testq %r14, %r14
je 0x8521
leaq 0x8(%r14), %rdi
callq 0x7370
movq %r14, %rdi
callq 0x7300
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x84fe
callq 0x7300
leaq 0x60(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8511
callq 0x7300
movl %ebx, %eax
addq $0x148, %rsp            # imm = 0x148
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
xorl %r14d, %r14d
jmp 0x84e3
movq 0x20(%rsp), %rsi
movq 0x28(%rsp), %rdx
leaq 0x108(%rsp), %rdi
callq 0xbaca
leaq 0x108(%rsp), %rdi
callq 0x923b
movq %rdx, %r14
movq %rax, %rbx
leaq 0x80(%rsp), %rdi
callq 0xc2bc
jmp 0x85a6
jmp 0x8617
movq %rdx, %r14
movq %rax, %rbx
leaq 0x108(%rsp), %rdi
callq 0x8dc0
jmp 0x859c
jmp 0x8621
movq %rax, %rbx
jmp 0x8637
movq %rax, %rbx
jmp 0x864a
movq %rdx, %r14
movq %rax, %rbx
jmp 0x85a6
movq %rdx, %r14
movq %rax, %rbx
leaq 0x70(%rsp), %rdi
callq 0x8bae
cmpl $0x1, %r14d
jne 0x860b
movq %rbx, %rdi
callq 0x7170
movq %rax, %rbx
movq 0x1ba2a(%rip), %rdi     # 0x23fe8
leaq 0xeadb(%rip), %rsi      # 0x170a0
movl $0x7, %edx
callq 0x7360
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
movq 0x1ba09(%rip), %rdi     # 0x23fe8
movq %rax, %rsi
callq 0x7320
movq %rax, %rdi
callq 0x71a0
movl $0x1, %ebx
callq 0x74f0
jmp 0x848c
movq %rax, %rbx
jmp 0x860b
movq %rax, %rbx
callq 0x74f0
leaq 0x10(%rsp), %rdi
callq 0x8c06
jmp 0x8624
movq %rax, %rdi
callq 0x882e
jmp 0x8621
movq %rax, %rbx
leaq 0x40(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x8637
callq 0x7300
leaq 0x60(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x864a
callq 0x7300
movq %rbx, %rdi
callq 0x7520