// File: /workspace/github_cpp_makefile_star2_O2/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 0x1a132
leaq 0x25ba3(%rip), %rsi     # 0x50bce
movq %r12, %rdi
callq 0x19be0
movl %eax, %ebp
movq %r12, %rdi
callq 0xb230
testb %bpl, %bpl
je 0x2b061
movq 0x8(%rbx), %rax
testq %rax, %rax
je 0x2b0d6
movq (%rbx), %rdi
pushq $0x4
popq %rsi
leaq 0x8(%rsp), %rdx
callq *%rax
testq %rax, %rax
je 0x2b0d6
leaq 0x10(%rsp), %rbx
leaq 0x7(%rsp), %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1a132
leaq 0x27950(%rip), %rsi     # 0x529cd
movq %rbx, %rdi
callq 0x19be0
testb %al, %al
je 0x2b0a5
pushq $0x70
popq %rdi
callq 0xb540
movq %rax, %rbx
movq 0x30(%r15), %rsi
movq %rax, %rdi
callq 0x46f16
jmp 0x2b16a
leaq 0x27926(%rip), %rsi     # 0x529d2
leaq 0x10(%rsp), %rdi
callq 0x19be0
testb %al, %al
je 0x2b13e
pushq $0x78
popq %rdi
callq 0xb540
movq %rax, %rbx
movq %rax, %rdi
callq 0x47952
jmp 0x2b16a
leaq 0x4a4a3(%rip), %rbx     # 0x75580
movq (%rbx), %rdi
cmpq $0x0, 0x8(%rdi)
je 0x2b299
addq $0x20, %rdi
callq 0xb800
movq (%rbx), %rax
movq 0x8(%rax), %rdi
leaq 0x26086(%rip), %rsi     # 0x51188
callq 0xb520
leaq 0x27876(%rip), %rsi     # 0x52984
movq %rax, %rdi
callq 0xb520
leaq 0x27887(%rip), %rsi     # 0x529a4
movq %rax, %rdi
callq 0xb520
movq %rax, %rdi
callq 0xb270
movq (%rbx), %rdi
addq $0x20, %rdi
callq 0xb3e0
jmp 0x2b299
leaq 0x27896(%rip), %rsi     # 0x529db
leaq 0x10(%rsp), %rdi
callq 0x19be0
testb %al, %al
je 0x2b205
pushq $0x78
popq %rdi
callq 0xb540
movq %rax, %rbx
movq %rax, %rdi
callq 0x48252
movq 0x8(%rsp), %rsi
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x10(%rax)
testb %al, %al
je 0x2b19b
movq %r15, 0x38(%rbx)
movb $0x1, %bpl
movq 0x8(%rsp), %rdx
movq %r15, %rdi
movq %r14, %rsi
movq %rbx, %rcx
callq 0x2ae38
jmp 0x2b284
leaq 0x4a3de(%rip), %r14     # 0x75580
movq (%r14), %rdi
cmpq $0x0, 0x8(%rdi)
je 0x2b1fa
addq $0x20, %rdi
callq 0xb800
movq (%r14), %rax
movq 0x8(%rax), %rdi
leaq 0x25fc5(%rip), %rsi     # 0x51188
callq 0xb520
leaq 0x277b5(%rip), %rsi     # 0x52984
movq %rax, %rdi
callq 0xb520
leaq 0x27817(%rip), %rsi     # 0x529f5
movq %rax, %rdi
callq 0xb520
movq %rax, %rdi
callq 0xb270
movq (%r14), %rdi
addq $0x20, %rdi
callq 0xb3e0
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
jmp 0x2b282
leaq 0x4a374(%rip), %rbx     # 0x75580
movq (%rbx), %rdi
cmpq $0x0, 0x18(%rdi)
je 0x2b280
addq $0x20, %rdi
callq 0xb800
movq (%rbx), %rax
movq 0x18(%rax), %rdi
leaq 0x2625b(%rip), %rsi     # 0x51488
callq 0xb520
leaq 0x2774b(%rip), %rsi     # 0x52984
movq %rax, %rdi
callq 0xb520
leaq 0x2779c(%rip), %rsi     # 0x529e4
movq %rax, %rdi
callq 0xb520
leaq 0x10(%rsp), %rsi
movq %rax, %rdi
callq 0xb490
leaq 0x280ff(%rip), %rsi     # 0x53363
movq %rax, %rdi
callq 0xb520
movq %rax, %rdi
callq 0xb270
movq (%rbx), %rdi
addq $0x20, %rdi
callq 0xb3e0
xorl %ebx, %ebx
xorl %ebp, %ebp
leaq 0x10(%rsp), %rdi
callq 0xb230
testb %bpl, %bpl
je 0x2b299
incq 0x28(%rbx)
jmp 0x2b29b
xorl %ebx, %ebx
movq %rbx, %rax
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2b2ad
movq %rax, %r14
pushq $0x78
jmp 0x2b2b9
movq %rax, %r14
pushq $0x70
popq %rsi
movq %rbx, %rdi
callq 0xb550
jmp 0x2b2c7
movq %rax, %r14
leaq 0x10(%rsp), %rdi
callq 0xb230
movq %r14, %rdi
callq 0xb9a0
nop