// File: /workspace/github_cpp_makefile_star2_O1/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, %r14
addq $0x230, %rdi            # imm = 0x230
movq %rdi, -0x40(%rbp)
callq 0x44d0
testl %eax, %eax
jne 0x86d0
movq 0x260(%r14), %rax
subq 0x258(%r14), %rax
sarq $0x3, %rax
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
imulq %rax, %rcx
movq %rcx, -0x38(%rbp)
movslq %ecx, %r15
movl $0x14, %ecx
movq %r15, %rax
mulq %rcx
movq $-0x1, %rdi
cmovnoq %rax, %rdi
callq 0x4030
movq %rax, %rdx
testl %r15d, %r15d
jle 0x85d2
leaq -0x78(%rbp), %r12
movq -0x38(%rbp), %rax
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
shlq $0x2, %rax
leaq (%rax,%rax,4), %rax
movq %rax, -0x48(%rbp)
xorl %r15d, %r15d
movl $0x6, (%rdx,%r15)
movq %rdx, %rbx
movb $-0x1, 0x4(%rdx,%r15)
movq %r14, %r13
movq 0x258(%r14), %rax
movq %r12, -0x88(%rbp)
movq (%rax,%r15,2), %rsi
movq 0x8(%rax,%r15,2), %rdx
addq %rsi, %rdx
leaq -0x88(%rbp), %r14
movq %r14, %rdi
callq 0x570a
movq %r14, %rdi
leaq -0x30(%rbp), %rsi
callq 0x1114c
movq -0x88(%rbp), %rdi
cmpq %r12, %rdi
je 0x859f
callq 0x4360
movl -0x30(%rbp), %eax
movq %rbx, %rdx
movl %eax, 0x5(%rbx,%r15)
movq %r13, %r14
movq 0x258(%r13), %rax
movl 0x20(%rax,%r15,2), %eax
movl %eax, 0xc(%rbx,%r15)
movb $0x0, 0x10(%rbx,%r15)
addq $0x14, %r15
cmpq %r15, -0x48(%rbp)
jne 0x8545
movq %rdx, %r13
movq -0x40(%rbp), %rdi
callq 0x42a0
leaq -0x9c(%rbp), %rsi
movq -0x38(%rbp), %rbx
movl %ebx, 0xc(%rsi)
movl $0x14, %edx
movl -0x2c(%rbp), %edi
callq 0x4170
testl %ebx, %ebx
jle 0x86b7
andl $0x7fffffff, %ebx       # imm = 0x7FFFFFFF
movq %r13, %r15
movl $0x14, %edx
movl -0x2c(%rbp), %edi
movq %r15, %rsi
callq 0x4170
movl $0x1b, %edx
movq %r14, %rdi
leaq 0xaf2e(%rip), %rsi      # 0x13557
callq 0x43f0
leaq 0x5(%r15), %rsi
leaq -0x68(%rbp), %rdi
callq 0x112b0
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq %r14, %rdi
callq 0x43f0
movq %rax, %r12
movl $0x1, %edx
movq %rax, %rdi
leaq 0xacc5(%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 0x86aa
callq 0x4360
addq $0x14, %r15
decq %rbx
jne 0x860a
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 %r12, %rdi
jne 0x86f8
jmp 0x86fd
movq %rax, %rbx
movq -0x68(%rbp), %rdi
leaq -0x58(%rbp), %rax
cmpq %rax, %rdi
je 0x86fd
callq 0x4360
movq %rbx, %rdi
callq 0x4630
nop