// File: /workspace/github_c_makefile_star2_O1/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 $0x488, %rsp            # imm = 0x488
movq %rsi, 0x30(%rsp)
movq %rdi, 0x8(%rsp)
cmpb $0x0, (%rdx)
je 0x8acf
movq %rdx, %rbx
movq 0x8(%rsp), %rax
addq $0x158, %rax            # imm = 0x158
movq %rax, 0x28(%rsp)
leaq 0x38(%rsp), %r13
leaq 0x80(%rsp), %r12
movzbl %cl, %eax
movl %eax, 0x14(%rsp)
movq %rbx, %r15
movzbl (%rbx), %eax
testl %eax, %eax
je 0x8902
cmpl $0x3b, %eax
je 0x88fc
incq %rbx
jmp 0x88eb
movb $0x0, (%rbx)
incq %rbx
movq %r13, %rdi
movl $0x8, %esi
movq %r12, %rdx
movl $0x400, %ecx            # imm = 0x400
xorl %r8d, %r8d
callq 0xe924
movl $0x3a, %edi
movq %r15, %rsi
movq %r13, %rdx
callq 0x83c5
movl 0x44(%rsp), %edx
cmpl $0x2, %edx
jne 0x89ff
movq %r12, %r15
movq %r13, %rdi
xorl %esi, %esi
leaq 0x20(%rsp), %r12
movq %r12, %rdx
callq 0xec6f
movq 0x20(%rsp), %r14
movq %r13, %rdi
movl $0x1, %esi
movq %r12, %rdx
callq 0xec6f
movq 0x20(%rsp), %rax
movq %rax, 0x18(%rsp)
callq 0x2290
movq (%rax), %rbp
decq %r14
movq %r14, %r12
incq %r14
movsbq 0x1(%r12), %rax
testb $0x20, 0x1(%rbp,%rax,2)
jne 0x8976
testb %al, %al
je 0x89b3
movq %r14, %rdi
callq 0x20e0
addq %rax, %r12
movq %r12, %rax
cmpq %r14, %r12
jbe 0x89af
movsbq (%rax), %rcx
leaq -0x1(%rax), %r12
testb $0x20, 0x1(%rbp,%rcx,2)
jne 0x8998
movb $0x0, 0x1(%rax)
movq %r14, %rdi
callq 0x20e0
testl %eax, %eax
setne %cl
cmpl $0x20, %eax
setl %al
testb %al, %cl
jne 0x8a32
leaq 0xe8f7(%rip), %rax      # 0x172c8
cmpl $0x0, (%rax)
movq %r15, %r12
jle 0x8abe
leaq 0xe8ec(%rip), %rax      # 0x172d0
movq (%rax), %rcx
movl $0x1, %edi
leaq 0x8132(%rip), %rsi      # 0x10b25
movq %r14, %rdx
xorl %eax, %eax
callq *%rcx
jmp 0x8abe
leaq 0xe8c2(%rip), %rax      # 0x172c8
cmpl $0x0, (%rax)
jle 0x8abe
leaq 0xe8ba(%rip), %rax      # 0x172d0
movq (%rax), %r8
movl $0x1, %edi
leaq 0x813f(%rip), %rsi      # 0x10b64
movq %r15, %rcx
xorl %eax, %eax
callq *%r8
jmp 0x8abe
movq 0x18(%rsp), %rdi
callq 0x2440
testl %eax, %eax
movq %r15, %r12
js 0x8a86
movl %eax, %ebp
movq 0x8(%rsp), %rax
movzwl 0x140(%rax), %eax
cmpl %eax, %ebp
jge 0x8a86
movq 0x28(%rsp), %r15
movq %r15, %rdi
callq 0x23b0
movzwl %bp, %ecx
movq 0x8(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq %r14, %rdx
movl 0x14(%rsp), %r8d
callq 0x8cdc
movq %r15, %rdi
callq 0x2190
jmp 0x8abe
leaq 0xe83b(%rip), %rax      # 0x172c8
cmpl $0x0, (%rax)
jle 0x8abe
leaq 0xe837(%rip), %rax      # 0x172d0
movq (%rax), %r8
movq 0x8(%rsp), %rax
movzwl 0x140(%rax), %ecx
movl $0x1, %edi
leaq 0x8090(%rip), %rsi      # 0x10b44
movq 0x18(%rsp), %rdx
xorl %eax, %eax
callq *%r8
movq %r13, %rdi
callq 0xea0d
cmpb $0x0, (%rbx)
jne 0x88e8
addq $0x488, %rsp            # imm = 0x488
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)