// File: /workspace/github_c_makefile_star2_O2/sharpyfox[P]citrusleaf-client/src/cl_cluster.c
// Function: cluster_partitions_process
static void
cluster_partitions_process(cl_cluster *asc, cl_cluster_node *cn, char *partitions, bool write) 
{
	// Partitions format: <namespace1>:<partition id1>;<namespace2>:<partition id2>; ...
	// Warning: This method walks on partitions string argument.
	char *p = partitions;

	while (*p)
	{
		char *partition_str = p;
		// loop till split and set it to null
		while ((*p) && (*p != ';')) {
			p++;
		}
		if (*p == ';'){
			*p = 0;
			p++;
		}
		cf_vector_define(partition_v, sizeof(void *), 0);
		str_split(':', partition_str, &partition_v);

		unsigned int vsize = cf_vector_size(&partition_v);
		if (vsize == 2) {
			char *namespace_s = cf_vector_pointer_get(&partition_v,0);
			char *partid_s = cf_vector_pointer_get(&partition_v,1);

			// it's coming over the wire, so validate it
			char *ns = trim(namespace_s);
			int len = strlen(ns);

			if (len == 0 || len > 31) {
				cf_warn("Invalid partition namespace %s", ns);
				goto Next;
			}

			int partid = atoi(partid_s);

			if (partid < 0 || partid >= (int)asc->n_partitions) {
				cf_warn("Invalid partition id %s. max=%u", partid_s, asc->n_partitions);
				goto Next;
			}
				
			pthread_mutex_lock(&asc->LOCK);
			cl_partition_table_set(asc, cn, ns, partid, write);
			pthread_mutex_unlock(&asc->LOCK);
		}
		else {
			cf_warn("Invalid partition vector size %u. element=%s", vsize, partition_str);
		}
Next:
		cf_vector_destroy(&partition_v);
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x478, %rsp            # imm = 0x478
leaq 0x158(%rdi), %rax
movq %rdx, %r13
leaq 0x28(%rsp), %r12
movq %rsi, 0x20(%rsp)
movq %rdi, (%rsp)
movq %rax, 0x18(%rsp)
pushq $0x8
popq %rbp
leaq 0x70(%rsp), %r15
movzbl %cl, %eax
movl %eax, 0xc(%rsp)
movb (%r13), %al
testb %al, %al
je 0x8197
movq %r13, %rbx
incq %r13
testb %al, %al
je 0x7fdd
movzbl %al, %eax
cmpl $0x3b, %eax
je 0x7fd6
movb (%r13), %al
incq %r13
jmp 0x7fc1
movb $0x0, -0x1(%r13)
jmp 0x7fe0
decq %r13
movq %r12, %rdi
movl %ebp, %esi
movq %r15, %rdx
movl $0x400, %ecx            # imm = 0x400
xorl %r8d, %r8d
callq 0xd641
pushq $0x3a
popq %rdi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x7b1c
movl 0x34(%rsp), %edx
cmpl $0x2, %edx
jne 0x80c6
movq %r12, %rdi
xorl %esi, %esi
movl %ebp, %ebx
callq 0x66c2
movq %rax, %r14
movq %r12, %rdi
pushq $0x1
popq %rsi
callq 0x66c2
movq %rax, 0x10(%rsp)
callq 0x2290
movq (%rax), %r15
decq %r14
movq %r14, %rbp
incq %r14
movsbq 0x1(%rbp), %rax
testb $0x20, 0x1(%r15,%rax,2)
jne 0x803a
testb %al, %al
je 0x8078
movq %r14, %rdi
callq 0x20e0
addq %rax, %rbp
movq %rbp, %rax
cmpq %r14, %rbp
jbe 0x8074
movsbq (%rax), %rcx
leaq -0x1(%rax), %rbp
testb $0x20, 0x1(%r15,%rcx,2)
jne 0x805c
movb $0x0, 0x1(%rax)
movq %r14, %rdi
callq 0x20e0
testl %eax, %eax
setne %cl
cmpl $0x20, %eax
setl %al
testb %al, %cl
jne 0x80f7
leaq 0xd232(%rip), %rax      # 0x152c8
movl %ebx, %ebp
leaq 0x70(%rsp), %r15
cmpl $0x0, (%rax)
jle 0x818a
leaq 0xd223(%rip), %rax      # 0x152d0
movq (%rax), %rcx
pushq $0x1
popq %rdi
leaq 0x6a89(%rip), %rsi      # 0xeb43
movq %r14, %rdx
xorl %eax, %eax
callq *%rcx
jmp 0x818a
leaq 0xd1fb(%rip), %rax      # 0x152c8
cmpl $0x0, (%rax)
jle 0x818a
leaq 0xd1f3(%rip), %rax      # 0x152d0
movq (%rax), %r8
pushq $0x1
popq %rdi
leaq 0x6a98(%rip), %rsi      # 0xeb82
movq %rbx, %rcx
xorl %eax, %eax
callq *%r8
jmp 0x818a
movq 0x10(%rsp), %rdi
callq 0x2440
testl %eax, %eax
movl %ebx, %ebp
js 0x8150
movl %eax, %r15d
movq (%rsp), %rax
movzwl 0x140(%rax), %eax
cmpl %eax, %r15d
jae 0x8150
movq 0x18(%rsp), %rbx
movq %rbx, %rdi
callq 0x23b0
movq (%rsp), %rdi
movq 0x20(%rsp), %rsi
movl 0xc(%rsp), %r8d
movzwl %r15w, %ecx
movq %r14, %rdx
callq 0x8379
movq %rbx, %rdi
callq 0x2190
leaq 0x70(%rsp), %r15
jmp 0x818a
leaq 0xd171(%rip), %rax      # 0x152c8
leaq 0x70(%rsp), %r15
cmpl $0x0, (%rax)
jle 0x818a
leaq 0xd168(%rip), %rax      # 0x152d0
movq (%rax), %r8
movq (%rsp), %rax
movzwl 0x140(%rax), %ecx
pushq $0x1
popq %rdi
movq 0x10(%rsp), %rdx
leaq 0x69dd(%rip), %rsi      # 0xeb62
xorl %eax, %eax
callq *%r8
movq %r12, %rdi
callq 0xd724
jmp 0x7faf
addq $0x478, %rsp            # imm = 0x478
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)