// File: /workspace/github_cpp_makefile_star2_O3/mh0fm4[P]SCDC/src/components/node/nodeconn_pool.cc
// Function: scdc_nodeconn_pool::open(char const*, char const*, scdc_args*)
scdc_nodeconn *scdc_nodeconn_pool::open(const char *scheme, const char *authority, scdc_args *args)
{
  SCDC_TRACE("open: scheme: '" << scheme << "', authority: '" << authority << "'");

  if (string(authority) == "%s")
  {
    if (!args->get<const char *>(SCDC_ARGS_TYPE_CSTR, &authority))
    {
      SCDC_FAIL("open: failed to get authority parameter!");
      return 0;
    }
    SCDC_TRACE("open: authority: '" << authority << "'");
  }

  scdc_nodeconn *nodeconn = 0;

#if NODECONN_CACHE_CONNECTIONS
  if (!nodeconn) nodeconn = lookup_cache(scheme, authority);
#endif
#if NODECONN_SHARE_CONNECTIONS
  if (!nodeconn) nodeconn = lookup_idle(scheme, authority);
#endif

  if (nodeconn)
  {
    SCDC_TRACE("open: reusing existing connection '" << nodeconn << "'");

  } else
  {
    SCDC_TRACE("open: creating new connection");

    string s(scheme);

#if USE_NODE_DIRECT
    if (s == SCDC_NODE_DIRECT_SCHEME) nodeconn = new scdc_nodeconn_direct(nodeport_pool);
    else
#endif
#if USE_NODE_TCP
    if (s == SCDC_NODE_TCP_SCHEME) nodeconn = new scdc_nodeconn_tcp();
    else
#endif
#if USE_NODE_UDS
    if (s == SCDC_NODE_UDS_SCHEME) nodeconn = new scdc_nodeconn_uds();
    else
#endif
#if USE_NODE_MPI
    if (s == SCDC_NODE_MPI_SCHEME) nodeconn = new scdc_nodeconn_mpi();
    else
#endif
    {
      SCDC_ERROR("unknown scheme '" << s << "'");
      return 0;
    }

    if (!nodeconn->open(authority))
    {
      SCDC_FAIL("open: nodeconn open failed");
      delete nodeconn;
      return 0;
    }

    nodeconn->nodeconn_pool = this;

    add(scheme, authority, nodeconn);
  }

  ++nodeconn->ref;

  SCDC_TRACE("open: nodeconn: '" << nodeconn << "', ref: " << nodeconn->ref);

  return nodeconn;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
movq %rcx, %rbx
movq %rsi, %r14
movq %rdi, %r15
movq %rdx, 0x8(%rsp)
leaq 0x10(%rsp), %r12
leaq 0x7(%rsp), %rax
movq %r12, %rdi
movq %rdx, %rsi
movq %rax, %rdx
callq 0x1bd28
leaq 0x36e8f(%rip), %rsi     # 0x69bee
movq %r12, %rdi
callq 0xb110
movl %eax, %ebp
movq (%r12), %rdi
leaq 0x20(%rsp), %r12
cmpq %r12, %rdi
je 0x32d84
movq 0x20(%rsp), %rsi
incq %rsi
callq 0xb510
testl %ebp, %ebp
je 0x32eae
leaq 0x10(%rsp), %rbx
leaq 0x7(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1bd28
leaq 0x38c95(%rip), %rsi     # 0x6ba3d
movq %rbx, %rdi
callq 0xb110
testl %eax, %eax
je 0x32f68
leaq 0x38c83(%rip), %rsi     # 0x6ba42
leaq 0x10(%rsp), %rdi
callq 0xb110
testl %eax, %eax
je 0x32f83
leaq 0x38c73(%rip), %rsi     # 0x6ba4b
leaq 0x10(%rsp), %rdi
callq 0xb110
testl %eax, %eax
je 0x32f9a
leaq 0x5977f(%rip), %r14     # 0x8c570
movq (%r14), %rdi
cmpq $0x0, 0x18(%rdi)
je 0x32ea7
addq $0x20, %rdi
callq 0xb7d0
movq (%r14), %rax
movq 0x18(%rax), %rbx
leaq 0x37692(%rip), %rsi     # 0x6a4a8
movl $0xc, %edx
movq %rbx, %rdi
callq 0xb5f0
leaq 0x38bca(%rip), %rsi     # 0x6b9f4
movl $0xf, %edx
movq %rbx, %rdi
callq 0xb5f0
leaq 0x38c16(%rip), %rsi     # 0x6ba54
movl $0x10, %edx
movq %rbx, %rdi
callq 0xb5f0
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %rbx, %rdi
callq 0xb5f0
movq %rax, %rbx
leaq 0x3956c(%rip), %rsi     # 0x6c3d3
movl $0x1, %edx
movq %rax, %rdi
callq 0xb5f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0xb4d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0xb050
movq %rax, %rdi
callq 0xb340
movq (%r14), %rdi
addq $0x20, %rdi
callq 0xb3b0
xorl %ebx, %ebx
jmp 0x33079
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x32ecf
movq (%rbx), %rdi
leaq 0x8(%rsp), %rdx
movl $0x4, %esi
callq *%rax
testq %rax, %rax
jne 0x32d8c
leaq 0x5969a(%rip), %r14     # 0x8c570
movq (%r14), %rdi
cmpq $0x0, 0x8(%rdi)
je 0x3309d
addq $0x20, %rdi
callq 0xb7d0
movq (%r14), %rax
movq 0x8(%rax), %rbx
leaq 0x372ad(%rip), %rsi     # 0x6a1a8
movl $0xb, %edx
movq %rbx, %rdi
callq 0xb5f0
leaq 0x38ae5(%rip), %rsi     # 0x6b9f4
movl $0xf, %edx
movq %rbx, %rdi
callq 0xb5f0
leaq 0x38af1(%rip), %rsi     # 0x6ba14
movl $0x28, %edx
movq %rbx, %rdi
callq 0xb5f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0xb4d0
movsbl %al, %esi
movq %rbx, %rdi
callq 0xb050
movq %rax, %rdi
callq 0xb340
movq (%r14), %rdi
addq $0x20, %rdi
callq 0xb3b0
jmp 0x3309d
movl $0x70, %edi
callq 0xb500
movq %rax, %rbx
movq 0x30(%r15), %rsi
movq %rax, %rdi
callq 0x5bfc8
jmp 0x32faf
movl $0x78, %edi
callq 0xb500
movq %rax, %rbx
movq %rax, %rdi
callq 0x5cc54
jmp 0x32faf
movl $0x78, %edi
callq 0xb500
movq %rax, %rbx
movq %rax, %rdi
callq 0x5d778
movq 0x8(%rsp), %rsi
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
testb %al, %al
je 0x32fe0
movq %r15, 0x38(%rbx)
movb $0x1, %bpl
movq 0x8(%rsp), %rdx
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rcx
callq 0x32ad4
jmp 0x3307b
leaq 0x59589(%rip), %r15     # 0x8c570
movq (%r15), %rdi
cmpq $0x0, 0x8(%rdi)
je 0x33070
addq $0x20, %rdi
callq 0xb7d0
movq (%r15), %rax
movq 0x8(%rax), %r14
leaq 0x371a0(%rip), %rsi     # 0x6a1a8
movl $0xb, %edx
movq %r14, %rdi
callq 0xb5f0
leaq 0x389d8(%rip), %rsi     # 0x6b9f4
movl $0xf, %edx
movq %r14, %rdi
callq 0xb5f0
leaq 0x38a35(%rip), %rsi     # 0x6ba65
movl $0x1a, %edx
movq %r14, %rdi
callq 0xb5f0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0xb4d0
movsbl %al, %esi
movq %r14, %rdi
callq 0xb050
movq %rax, %rdi
callq 0xb340
movq (%r15), %rdi
addq $0x20, %rdi
callq 0xb3b0
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
xorl %ebp, %ebp
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x33092
movq 0x20(%rsp), %rsi
incq %rsi
callq 0xb510
testb %bpl, %bpl
je 0x3309d
incq 0x28(%rbx)
jmp 0x3309f
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x330b1
movq %rax, %r14
movl $0x78, %esi
jmp 0x330c3
movq %rax, %r14
movl $0x70, %esi
movq %rbx, %rdi
callq 0xb510
jmp 0x330d0
movq %rax, %r14
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x330e7
movq 0x20(%rsp), %rsi
incq %rsi
callq 0xb510
movq %r14, %rdi
callq 0xb9c0
nop