// File: /workspace/github_c_makefile_star2_O3/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
movb (%rdx), %al
movq %rsi, 0x30(%rsp)
movq %rdi, 0x8(%rsp)
testb %al, %al
je 0x8888
movq 0x8(%rsp), %rsi
movq %rdx, %r15
movzbl %cl, %ecx
leaq 0x38(%rsp), %rbp
leaq 0x80(%rsp), %r12
movl %ecx, 0x14(%rsp)
leaq 0x158(%rsi), %rdx
movq %rdx, 0x28(%rsp)
movq %r15, %r14
incq %r15
testb %al, %al
je 0x86aa
movzbl %al, %eax
cmpl $0x3b, %eax
je 0x86a3
movb (%r15), %al
incq %r15
jmp 0x868f
movb $0x0, -0x1(%r15)
jmp 0x86ad
decq %r15
movq %rbp, %rdi
movl $0x8, %esi
movq %r12, %rdx
movl $0x400, %ecx            # imm = 0x400
xorl %r8d, %r8d
callq 0xe49a
movl $0x3a, %edi
movq %r14, %rsi
movq %rbp, %rdx
callq 0x81c6
movl 0x44(%rsp), %edx
cmpl $0x2, %edx
jne 0x87b0
movq %r12, %r13
leaq 0x20(%rsp), %r12
movq %rbp, %rdi
xorl %esi, %esi
movq %r12, %rdx
callq 0xe7d4
movq 0x20(%rsp), %rbx
movq %rbp, %rdi
movl $0x1, %esi
movq %r12, %rdx
movq %rbp, %r14
callq 0xe7d4
movq 0x20(%rsp), %rax
movq %rax, 0x18(%rsp)
callq 0x2290
movq (%rax), %rbp
decq %rbx
movq %rbx, %r12
incq %rbx
movsbq 0x1(%r12), %rax
testb $0x20, 0x1(%rbp,%rax,2)
jne 0x8724
testb %al, %al
je 0x8761
movq %rbx, %rdi
callq 0x20e0
addq %rax, %r12
movq %r12, %rax
cmpq %rbx, %r12
jbe 0x875d
movsbq (%rax), %rcx
leaq -0x1(%rax), %r12
testb $0x20, 0x1(%rbp,%rcx,2)
jne 0x8746
movb $0x0, 0x1(%rax)
movq %rbx, %rdi
callq 0x20e0
testl %eax, %eax
setne %cl
cmpl $0x20, %eax
setl %al
testb %al, %cl
jne 0x87e3
leaq 0xdb49(%rip), %rax      # 0x162c8
movq %r13, %r12
movq %r14, %rbp
cmpl $0x0, (%rax)
jle 0x8875
leaq 0xdb3b(%rip), %rax      # 0x162d0
movl $0x1, %edi
leaq 0x73a2(%rip), %rsi      # 0xfb43
movq %rbx, %rdx
movq (%rax), %rcx
xorl %eax, %eax
callq *%rcx
jmp 0x8875
leaq 0xdb11(%rip), %rax      # 0x162c8
cmpl $0x0, (%rax)
jle 0x8875
leaq 0xdb09(%rip), %rax      # 0x162d0
movl $0x1, %edi
leaq 0x73af(%rip), %rsi      # 0xfb82
movq %r14, %rcx
movq (%rax), %r8
xorl %eax, %eax
callq *%r8
jmp 0x8875
movq 0x18(%rsp), %rdi
callq 0x2440
testl %eax, %eax
movq %r13, %r12
js 0x883a
movl %eax, %ebp
movq 0x8(%rsp), %rax
movzwl 0x140(%rax), %eax
cmpl %eax, %ebp
jae 0x883a
movq 0x28(%rsp), %r13
movq %r13, %rdi
callq 0x23b0
movq 0x8(%rsp), %rdi
movq 0x30(%rsp), %rsi
movl 0x14(%rsp), %r8d
movzwl %bp, %ecx
movq %rbx, %rdx
callq 0x8a7e
movq %r13, %rdi
callq 0x2190
movq %r14, %rbp
jmp 0x8875
leaq 0xda87(%rip), %rax      # 0x162c8
movq %r14, %rbp
cmpl $0x0, (%rax)
jle 0x8875
leaq 0xda80(%rip), %rax      # 0x162d0
movl $0x1, %edi
leaq 0x7306(%rip), %rsi      # 0xfb62
movq (%rax), %r8
movq 0x8(%rsp), %rax
movq 0x18(%rsp), %rdx
movzwl 0x140(%rax), %ecx
xorl %eax, %eax
callq *%r8
movq %rbp, %rdi
callq 0xe580
movb (%r15), %al
testb %al, %al
jne 0x8689
addq $0x488, %rsp            # imm = 0x488
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop