// File: /workspace/github_cpp_makefile_star2_O2/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 $0x98, %rsp
movl %esi, -0x34(%rbp)
movq %rdi, %rbx
addq $0x230, %rdi            # imm = 0x230
movq %rdi, -0x58(%rbp)
callq 0x8608
movq 0x258(%rbx), %r15
movq %rbx, -0x40(%rbp)
movq 0x260(%rbx), %rax
subq %r15, %rax
pushq $0x28
popq %rcx
cqto
idivq %rcx
movq %rax, %rbx
movslq %ebx, %r14
pushq $0x14
popq %rcx
movq %r14, %rax
mulq %rcx
pushq $-0x1
popq %rdi
cmovnoq %rax, %rdi
callq 0x4030
movq %r15, %rsi
xorl %edx, %edx
testl %r14d, %r14d
movl $0x0, %ecx
movq %rbx, -0x50(%rbp)
cmovgl %ebx, %ecx
movq %rcx, -0x48(%rbp)
movq %rax, -0x30(%rbp)
leaq 0x5(%rax), %r13
leaq -0xa0(%rbp), %r14
movq -0x30(%rbp), %rbx
cmpq -0x48(%rbp), %rdx
je 0x729f
imulq $0x14, %rdx, %r12
movl $0x6, (%rbx,%r12)
movb $-0x1, 0x4(%rbx,%r12)
movq %rdx, %r15
imulq $0x28, %rdx, %rcx
movq %rcx, -0x60(%rbp)
addq %rcx, %rsi
movq %r14, %rdi
callq 0x4450
movq %r14, %rdi
leaq -0x38(%rbp), %rsi
callq 0xd87c
addq %rbx, %r12
movq %r14, %rdi
callq 0x41b0
xorl %eax, %eax
movq %r15, %rdx
cmpq $0x4, %rax
je 0x7275
movb -0x38(%rbp,%rax), %cl
movb %cl, (%r13,%rax)
incq %rax
jmp 0x7261
movq -0x40(%rbp), %rax
movq 0x258(%rax), %rsi
movq -0x60(%rbp), %rax
movl 0x20(%rsi,%rax), %eax
movl %eax, 0xc(%r12)
movb $0x0, 0x10(%r12)
incq %rdx
addq $0x14, %r13
jmp 0x7213
movq -0x58(%rbp), %rdi
callq 0x4290
leaq -0xb4(%rbp), %rsi
movq -0x50(%rbp), %rax
movl %eax, 0xc(%rsi)
pushq $0x14
popq %rdx
movl -0x34(%rbp), %r14d
movl %r14d, %edi
movq %rdx, %r13
callq 0x4150
leaq -0x80(%rbp), %rbx
movq -0x30(%rbp), %r15
subq $0x1, -0x48(%rbp)
jb 0x7340
movl %r14d, %edi
movq %r15, %rsi
movq %r13, %rdx
callq 0x4150
movq -0x40(%rbp), %rdi
leaq 0x823f(%rip), %rsi      # 0xf52f
callq 0x4370
movq %rax, %r12
leaq 0x5(%r15), %rsi
movq %rbx, %rdi
callq 0xd999
movq %r12, %rdi
movq %rbx, %rsi
callq 0x4300
movq %rax, %rdi
leaq 0x8009(%rip), %rsi      # 0xf322
callq 0x4370
movl 0xc(%r15), %esi
movq %rax, %rdi
callq 0x45a0
movq %rax, %rdi
callq 0x41d0
movq %rbx, %rdi
callq 0x41b0
addq $0x14, %r15
jmp 0x72d0
movq -0x30(%rbp), %rdi
callq 0x4410
xorl %eax, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
jmp 0x7370
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x41b0
movq %rbx, %rdi
callq 0x45d0
nop