// File: /workspace/github_cpp_makefile_star2_O1/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 0x1bdd6
leaq 0x36adb(%rip), %rsi     # 0x69bce
movq %r12, %rdi
callq 0xb110
movl %eax, %ebp
movq (%r12), %rdi
leaq 0x20(%rsp), %r12
cmpq %r12, %rdi
je 0x33118
movq 0x20(%rsp), %rsi
incq %rsi
callq 0xb510
testl %ebp, %ebp
je 0x33242
leaq 0x10(%rsp), %rbx
leaq 0x7(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1bdd6
leaq 0x388e1(%rip), %rsi     # 0x6ba1d
movq %rbx, %rdi
callq 0xb110
testl %eax, %eax
je 0x332fc
leaq 0x388cf(%rip), %rsi     # 0x6ba22
leaq 0x10(%rsp), %rdi
callq 0xb110
testl %eax, %eax
je 0x33317
leaq 0x388bf(%rip), %rsi     # 0x6ba2b
leaq 0x10(%rsp), %rdi
callq 0xb110
testl %eax, %eax
je 0x3332e
leaq 0x593eb(%rip), %r14     # 0x8c570
movq (%r14), %rdi
cmpq $0x0, 0x18(%rdi)
je 0x3323b
addq $0x20, %rdi
callq 0xb7d0
movq (%r14), %rax
movq 0x18(%rax), %rbx
leaq 0x372de(%rip), %rsi     # 0x6a488
movl $0xc, %edx
movq %rbx, %rdi
callq 0xb5f0
leaq 0x38816(%rip), %rsi     # 0x6b9d4
movl $0xf, %edx
movq %rbx, %rdi
callq 0xb5f0
leaq 0x38862(%rip), %rsi     # 0x6ba34
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 0x39160(%rip), %rsi     # 0x6c35b
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 0x3340d
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x33263
movq (%rbx), %rdi
leaq 0x8(%rsp), %rdx
movl $0x4, %esi
callq *%rax
testq %rax, %rax
jne 0x33120
leaq 0x59306(%rip), %r14     # 0x8c570
movq (%r14), %rdi
cmpq $0x0, 0x8(%rdi)
je 0x33431
addq $0x20, %rdi
callq 0xb7d0
movq (%r14), %rax
movq 0x8(%rax), %rbx
leaq 0x36ef9(%rip), %rsi     # 0x6a188
movl $0xb, %edx
movq %rbx, %rdi
callq 0xb5f0
leaq 0x38731(%rip), %rsi     # 0x6b9d4
movl $0xf, %edx
movq %rbx, %rdi
callq 0xb5f0
leaq 0x3873d(%rip), %rsi     # 0x6b9f4
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 0x33431
movl $0x70, %edi
callq 0xb500
movq %rax, %rbx
movq 0x30(%r15), %rsi
movq %rax, %rdi
callq 0x5c40a
jmp 0x33343
movl $0x78, %edi
callq 0xb500
movq %rax, %rbx
movq %rax, %rdi
callq 0x5d0ec
jmp 0x33343
movl $0x78, %edi
callq 0xb500
movq %rax, %rbx
movq %rax, %rdi
callq 0x5dc32
movq 0x8(%rsp), %rsi
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
testb %al, %al
je 0x33374
movq %r15, 0x38(%rbx)
movb $0x1, %bpl
movq 0x8(%rsp), %rdx
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rcx
callq 0x32e60
jmp 0x3340f
leaq 0x591f5(%rip), %r15     # 0x8c570
movq (%r15), %rdi
cmpq $0x0, 0x8(%rdi)
je 0x33404
addq $0x20, %rdi
callq 0xb7d0
movq (%r15), %rax
movq 0x8(%rax), %r14
leaq 0x36dec(%rip), %rsi     # 0x6a188
movl $0xb, %edx
movq %r14, %rdi
callq 0xb5f0
leaq 0x38624(%rip), %rsi     # 0x6b9d4
movl $0xf, %edx
movq %r14, %rdi
callq 0xb5f0
leaq 0x38681(%rip), %rsi     # 0x6ba45
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 0x33426
movq 0x20(%rsp), %rsi
incq %rsi
callq 0xb510
testb %bpl, %bpl
je 0x33431
incq 0x28(%rbx)
jmp 0x33433
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x33445
movq %rax, %r14
movl $0x78, %esi
jmp 0x33457
movq %rax, %r14
movl $0x70, %esi
movq %rbx, %rdi
callq 0xb510
jmp 0x33464
movq %rax, %r14
movq 0x10(%rsp), %rdi
cmpq %r12, %rdi
je 0x3347b
movq 0x20(%rsp), %rsi
incq %rsi
callq 0xb510
movq %r14, %rdi
callq 0xb9c0
nop