// File: /workspace/github_c_makefile_star2_O2/sharpyfox[P]citrusleaf-client/src/cl_cluster.c
// Function: cl_cluster_get_node_names_byhostportlist
int
cl_cluster_get_node_names_byhostportlist(cl_cluster *asc, char *list_nodes, int *n_nodes, char **node_names)
{
	//get vector containing host:port
	cf_vector_define(host_str_v, sizeof(void *), 0);// host_str_v is vector of addr:port
	str_split(';', list_nodes, &host_str_v);

	uint size = cf_vector_size(&host_str_v);
	*n_nodes = size;
	*node_names = malloc(NODE_NAME_SIZE * size);
	if (*node_names == 0) {
		return(0);
	}

	char *nptr = *node_names;
	for (uint i=0; i<size; i++) {
		char *host_str = cf_vector_pointer_get(&host_str_v, i);
		cf_vector_define(host_port_v, sizeof(void *), 0);
		str_split(':', host_str, &host_port_v);
		if (cf_vector_size(&host_port_v) == 2) {
			char *host_s = cf_vector_pointer_get(&host_port_v, 0);
			char *port_s = cf_vector_pointer_get(&host_port_v, 1);
			uint port = atoi(port_s);
			cf_debug("host-port:%s:%d, ", host_s, port);
			char *info_name;
			char *value;
			if (0 == citrusleaf_info(host_s, port, "node", &info_name, 3000)) {
				citrusleaf_info_parse_single(info_name, &value);
				cf_debug("node-name:%s\n", value);
				memcpy(nptr, value, NODE_NAME_SIZE);
				nptr += (NODE_NAME_SIZE);
			} else {
				cf_debug("%s:%u is not accessible or timed out. \n", host_s, port);
				return (-2);
			}
			free(info_name);
		} else {
				cf_debug("Command line input format error for option l\n");
				return (-1);
		}
		cf_vector_destroy(&host_port_v);
	}
	cf_vector_destroy(&host_str_v);
	return(0);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x8a8, %rsp            # imm = 0x8A8
movq %rcx, %r13
movq %rdx, %rbx
movq %rsi, %r15
leaq 0x10(%rsp), %r12
pushq $0x8
popq %rsi
leaq 0x4a0(%rsp), %rdx
movq %r12, %rdi
movl $0x400, %ecx            # imm = 0x400
xorl %r8d, %r8d
xorl %ebp, %ebp
callq 0xd641
pushq $0x3b
popq %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x7b1c
movl 0xc(%r12), %r14d
imull $0x14, %r14d, %edi
movl %r14d, (%rbx)
callq 0x22e0
testq %rax, %rax
movq %rax, (%r13)
je 0x7b08
movq %rax, %rbx
leaq 0x58(%rsp), %r15
xorl %r12d, %r12d
leaq 0x10(%rsp), %rdi
cmpl %r12d, %r14d
je 0x7aa5
movl %r12d, %esi
callq 0x66c2
movq %rax, %r13
movq %r15, %rdi
pushq $0x8
popq %rsi
leaq 0xa0(%rsp), %rdx
movl $0x400, %ecx            # imm = 0x400
xorl %r8d, %r8d
callq 0xd641
pushq $0x3a
popq %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x7b1c
cmpl $0x2, 0x64(%rsp)
jne 0x7aae
movq %r15, %rdi
xorl %esi, %esi
callq 0x66c2
movq %rax, %r13
movq %r15, %rdi
pushq $0x1
popq %rsi
callq 0x66c2
movq %rax, %rdi
callq 0x2440
movl %eax, %ebp
leaq 0xd8da(%rip), %rax      # 0x152c8
movl (%rax), %eax
cmpl $0x3, %eax
jl 0x7a13
leaq 0xd8d4(%rip), %rax      # 0x152d0
movq (%rax), %r8
pushq $0x3
popq %rdi
leaq 0x6fe6(%rip), %rsi      # 0xe9ef
movq %r13, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq *%r8
movswl %bp, %esi
movq %r13, %rdi
leaq 0x74bc(%rip), %rdx      # 0xeedc
leaq 0x8(%rsp), %rcx
movl $0xbb8, %r8d            # imm = 0xBB8
callq 0xde5c
testl %eax, %eax
jne 0x7ad9
movq 0x8(%rsp), %rdi
movq %rsp, %rsi
callq 0xdba4
leaq 0xd87c(%rip), %rax      # 0x152c8
movl (%rax), %eax
cmpl $0x3, %eax
jl 0x7a6f
leaq 0xd876(%rip), %rax      # 0x152d0
movq (%rax), %rcx
movq (%rsp), %rdx
pushq $0x3
popq %rdi
leaq 0x6f96(%rip), %rsi      # 0xea01
xorl %eax, %eax
callq *%rcx
movq (%rsp), %rax
movq 0x8(%rsp), %rdi
movl 0x10(%rax), %ecx
movl %ecx, 0x10(%rbx)
movq (%rax), %rcx
movq 0x8(%rax), %rax
movq %rax, 0x8(%rbx)
movq %rcx, (%rbx)
addq $0x14, %rbx
callq 0x22c0
movq %r15, %rdi
callq 0xd724
incl %r12d
jmp 0x7978
callq 0xd724
xorl %ebp, %ebp
jmp 0x7b08
leaq 0xd813(%rip), %rax      # 0x152c8
movl (%rax), %eax
pushq $-0x1
popq %rbp
cmpl $0x3, %eax
jl 0x7b08
leaq 0xd80a(%rip), %rax      # 0x152d0
leaq 0x6f6a(%rip), %rsi      # 0xea37
movq (%rax), %rcx
pushq $0x3
popq %rdi
xorl %eax, %eax
callq *%rcx
jmp 0x7b08
leaq 0xd7e8(%rip), %rax      # 0x152c8
movl (%rax), %eax
cmpl $0x3, %eax
jl 0x7b05
leaq 0xd7e2(%rip), %rax      # 0x152d0
leaq 0x6f1a(%rip), %rsi      # 0xea0f
movq (%rax), %r8
pushq $0x3
popq %rdi
movq %r13, %rdx
movl %ebp, %ecx
xorl %eax, %eax
callq *%r8
pushq $-0x2
popq %rbp
movl %ebp, %eax
addq $0x8a8, %rsp            # imm = 0x8A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq