// File: /workspace/github_cpp_makefile_star2_O3/luisremis[P]SDFS/Membership.cpp
// Function: Membership::sendBackLocalList(int)
int Membership::sendBackLocalList(int connFd){
	membersLock.lock();

    int size = members.size();
    
    //prepare all the members
    Message * buffer = new Message[size];
    char addr[4];

    for(int i=0; i < size; i++){
    	buffer[i].type = MSG_JOIN;
		buffer[i].roundId = -1;
		ipString2Char4(members[i].ip_str, addr);
		for(int j=0; j < 4; j++)
			buffer[i].carrierAdd[j] = addr[j];
		buffer[i].timeStamp = members[i].timeStamp;
		buffer[i].TTL = 0;
    }
    
    membersLock.unlock();

    Message sizeMsg;
    sizeMsg.timeStamp = size;
    int ret = write(connFd, &sizeMsg, sizeof(Message) );

    for(int i=0; i < size; i++){
    	ret = write(connFd, buffer+i, sizeof(Message) );
    	logFile<<"sendBackLocalList: sending "<<char42String(buffer[i].carrierAdd)<<" "<<buffer[i].timeStamp<< std::endl;
    }
    delete [] buffer;
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %esi, -0x2c(%rbp)
movq %rdi, %rbx
leaq 0x230(%rdi), %r12
movq %r12, %rdi
callq 0x44d0
testl %eax, %eax
jne 0x8666
movq 0x258(%rbx), %r14
movq %rbx, -0x38(%rbp)
movq 0x260(%rbx), %rax
subq %r14, %rax
sarq $0x3, %rax
movabsq $-0x3333333333333333, %rbx # imm = 0xCCCCCCCCCCCCCCCD
imulq %rax, %rbx
movslq %ebx, %r15
movl $0x14, %ecx
movq %r15, %rax
mulq %rcx
movq $-0x1, %rdi
cmovnoq %rax, %rdi
callq 0x4030
movq %rax, %r13
testl %r15d, %r15d
jle 0x862e
movq %r12, -0x40(%rbp)
leaq -0x78(%rbp), %rcx
movl %ebx, %eax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shlq $0x2, %rax
leaq (%rax,%rax,4), %rax
movq %rax, -0x48(%rbp)
xorl %r15d, %r15d
leaq -0x88(%rbp), %r12
movl $0x6, (%r13,%r15)
movb $-0x1, 0x4(%r13,%r15)
movq %rcx, -0x88(%rbp)
movq (%r14,%r15,2), %rsi
movq 0x8(%r14,%r15,2), %rdx
addq %rsi, %rdx
movq %r12, %rdi
movq %rcx, %r14
callq 0x56fa
movq %r12, %rdi
leaq -0x30(%rbp), %rsi
callq 0x10fc0
movq -0x88(%rbp), %rdi
cmpq %r14, %rdi
movq %r14, %rcx
je 0x8519
movq %rcx, %r14
callq 0x4360
movq %r14, %rcx
movl -0x30(%rbp), %eax
movl %eax, 0x5(%r13,%r15)
movq -0x38(%rbp), %rax
movq 0x258(%rax), %r14
movl 0x20(%r14,%r15,2), %eax
movl %eax, 0xc(%r13,%r15)
movb $0x0, 0x10(%r13,%r15)
addq $0x14, %r15
cmpq %r15, -0x48(%rbp)
jne 0x84c6
movq -0x40(%rbp), %rdi
callq 0x42a0
leaq -0x9c(%rbp), %rsi
movl %ebx, 0xc(%rsi)
movl $0x14, %edx
movl -0x2c(%rbp), %r14d
movl %r14d, %edi
callq 0x4170
testl %ebx, %ebx
jle 0x864d
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
movq %r13, %r15
movl $0x14, %edx
movl %r14d, %edi
movq %r15, %rsi
callq 0x4170
movl $0x1b, %edx
movq -0x38(%rbp), %r12
movq %r12, %rdi
leaq 0xafb9(%rip), %rsi      # 0x13557
callq 0x43f0
leaq 0x5(%r15), %rsi
leaq -0x68(%rbp), %rdi
callq 0x11124
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq %r12, %rdi
callq 0x43f0
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0xad50(%rip), %rsi      # 0x13322
callq 0x43f0
movl 0xc(%r15), %esi
movq %r12, %rdi
callq 0x45f0
movq %rax, %r12
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x4380
movsbl %al, %esi
movq %r12, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4260
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x861f
callq 0x4360
addq $0x14, %r15
decq %rbx
jne 0x857b
jmp 0x864d
movq %r12, %rdi
callq 0x42a0
leaq -0x9c(%rbp), %rsi
movl %ebx, 0xc(%rsi)
movl $0x14, %edx
movl -0x2c(%rbp), %edi
callq 0x4170
movq %r13, %rdi
callq 0x4450
xorl %eax, %eax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %edi
callq 0x4240
movq %rax, %rbx
movq -0x88(%rbp), %rdi
cmpq %r14, %rdi
jne 0x868e
jmp 0x8693
movq %rax, %rbx
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x8693
callq 0x4360
movq %rbx, %rdi
callq 0x4630
nop