// File: /workspace/github_c_makefile_star2_O0/sharpyfox[P]citrusleaf-client/src/cl_shm.c
// Function: cl_shm_update
static void
cl_shm_update(cl_cluster * asc)
{
	// Update the updater id in shared memory.
	g_shm_pt->updater_id = getpid();

	// Make copy of node names and addresses.
	pthread_mutex_lock(&asc->LOCK);
	int node_count = cf_vector_size(&asc->node_v);

	if (node_count <= 0) {
		pthread_mutex_unlock(&asc->LOCK);
		return;
	}

	cl_seed_node* seed_array = cl_shm_init_seed_array(node_count);

	for (int i = 0; i < node_count; i++) {
		cl_cluster_node* src = cf_vector_pointer_get(&asc->node_v, i);
		cl_seed_node* trg = &seed_array[i];
		cl_strncpy(trg->name, src->name, NODE_NAME_SIZE);

		trg->address_count = cf_vector_size(&src->sockaddr_in_v);

		if (trg->address_count > MAX_ADDRESSES_PER_NODE) {
			cf_debug("Node %s addresses truncated. Requested size=%d", src->name, trg->address_count);
			trg->address_count = MAX_ADDRESSES_PER_NODE;
		}

		for (int j = 0; j < trg->address_count ; j++) {
			struct sockaddr_in *sa_in = cf_vector_getp(&src->sockaddr_in_v, j);
			memcpy(&trg->address_array[j], sa_in, sizeof(struct sockaddr_in));
		}
	}
	pthread_mutex_unlock(&asc->LOCK);

	// Ping all nodes and update shared memory.
	for (int i = 0; i < node_count; i++) {
		cl_shm_node_ping(&seed_array[i]);
	}
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
callq 0x23d0
movslq %eax, %rcx
movq 0xeba8(%rip), %rax      # 0x20610
movq %rcx, (%rax)
movq 0x40(%rsp), %rdi
addq $0x158, %rdi            # imm = 0x158
callq 0x23e0
movq 0x40(%rsp), %rdi
addq $0xf8, %rdi
callq 0x11cf0
movl %eax, 0x3c(%rsp)
cmpl $0x0, 0x3c(%rsp)
jg 0x11aae
movq 0x40(%rsp), %rdi
addq $0x158, %rdi            # imm = 0x158
callq 0x21c0
jmp 0x11c39
movl 0x3c(%rsp), %edi
callq 0x11d00
movq %rax, 0x30(%rsp)
movl $0x0, 0x2c(%rsp)
movl 0x2c(%rsp), %eax
cmpl 0x3c(%rsp), %eax
jge 0x11bf3
movq 0x40(%rsp), %rdi
addq $0xf8, %rdi
movl 0x2c(%rsp), %esi
callq 0x11d50
movq %rax, 0x20(%rsp)
movq 0x30(%rsp), %rax
movslq 0x2c(%rsp), %rcx
imulq $0x58, %rcx, %rcx
addq %rcx, %rax
movq %rax, 0x18(%rsp)
movq 0x18(%rsp), %rdi
movq 0x20(%rsp), %rsi
movl $0x14, %edx
callq 0x12370
movq 0x20(%rsp), %rdi
addq $0x20, %rdi
callq 0x11cf0
movl %eax, %ecx
movq 0x18(%rsp), %rax
movl %ecx, 0x54(%rax)
movq 0x18(%rsp), %rax
cmpl $0x4, 0x54(%rax)
jle 0x11b7f
leaq 0xc798(%rip), %rax      # 0x1e2d8
movl (%rax), %ecx
movl $0x3, %eax
cmpl %ecx, %eax
jg 0x11b73
leaq 0xc78e(%rip), %rax      # 0x1e2e0
movq (%rax), %r8
movq 0x20(%rsp), %rdx
movq 0x18(%rsp), %rax
movl 0x54(%rax), %ecx
movl $0x3, %edi
leaq 0x7aa7(%rip), %rsi      # 0x19615
movb $0x0, %al
callq *%r8
movq 0x18(%rsp), %rax
movl $0x4, 0x54(%rax)
movl $0x0, 0x14(%rsp)
movl 0x14(%rsp), %eax
movq 0x18(%rsp), %rcx
cmpl 0x54(%rcx), %eax
jge 0x11be1
movq 0x20(%rsp), %rdi
addq $0x20, %rdi
movl 0x14(%rsp), %esi
callq 0x17340
movq %rax, 0x8(%rsp)
movq 0x18(%rsp), %rax
addq $0x14, %rax
movslq 0x14(%rsp), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rsp), %rcx
movq (%rcx), %rdx
movq %rdx, (%rax)
movq 0x8(%rcx), %rcx
movq %rcx, 0x8(%rax)
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x11b87
jmp 0x11be3
movl 0x2c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x2c(%rsp)
jmp 0x11ac4
movq 0x40(%rsp), %rdi
addq $0x158, %rdi            # imm = 0x158
callq 0x21c0
movl $0x0, 0x4(%rsp)
movl 0x4(%rsp), %eax
cmpl 0x3c(%rsp), %eax
jge 0x11c39
movq 0x30(%rsp), %rdi
movslq 0x4(%rsp), %rax
imulq $0x58, %rax, %rax
addq %rax, %rdi
callq 0x11d80
movl 0x4(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x4(%rsp)
jmp 0x11c0c
addq $0x48, %rsp
retq
nop