LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O3/luisremis[P]SDFS/Membership.cpp
// Function: Membership::pullMsgFromFileSysQueue()
MemberUpdateMsg Membership::pullMsgFromFileSysQueue(){
    std::unique_lock<std::mutex> locker( fileSysMsgQueueLock );

    while( fileSysMsgQueue.size()==0 ){
        this->fileSysMsgQueueCV.wait( locker );
    }
    
    MemberUpdateMsg msg = fileSysMsgQueue[ 0 ];
    fileSysMsgQueue.erase( fileSysMsgQueue.begin() );
    
    return msg;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x10, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq 0x370(%rsi), %rax
leaq -0x30(%rbp), %r15
movq %rax, (%r15)
movb $0x0, 0x8(%r15)
movq %r15, %rdi
callq 0xae10
movb $0x1, 0x8(%r15)
movq 0x358(%r14), %rsi
cmpq %rsi, 0x360(%r14)
jne 0xa04d
leaq 0x398(%r14), %r15
leaq -0x30(%rbp), %r12
movq %r15, %rdi
movq %r12, %rsi
callq 0x4130
movq 0x358(%r14), %rsi
cmpq %rsi, 0x360(%r14)
je 0xa032
movq %rbx, %rdi
callq 0x9f42
addq $0x358, %r14            # imm = 0x358
movq (%r14), %rsi
movq %r14, %rdi
callq 0xb128
leaq -0x30(%rbp), %rdi
callq 0xa56a
movq %rbx, %rax
addq $0x10, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq 0x8(%rbx), %rdi
addq $0x18, %rbx
cmpq %rbx, %rdi
je 0xa09a
callq 0x4360
jmp 0xa09a
movq %rax, %r14
leaq -0x30(%rbp), %rdi
callq 0xa56a
movq %r14, %rdi
callq 0x4630
nop
// File: /workspace/github_cpp_makefile_star2_O3/luisremis[P]SDFS/FileSystem.cpp
// Function: FileSystem::FileSystem(int, Membership&)
FileSystem::FileSystem(int port, Membership& m) :
    membership(m), port(port)
{
	logFile.open("logFileSystem.log"); // we can make all the logs going to a single file, but nah.

    std::thread th2(&FileSystem::updateThread, this);
    ringUpdating.swap(th2);

    std::thread th1(&FileSystem::listeningThread, this);
    listening.swap(th1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rdx, %r14
movl %esi, %r15d
movq %rdi, %rbx
callq 0x45c0
movl %r15d, 0x200(%rbx)
movq %r14, 0x208(%rbx)
leaq 0x210(%rbx), %r14
movq %r14, 0x218(%rbx)
movq %r14, 0x210(%rbx)
leaq 0x2a8(%rbx), %r12
xorps %xmm0, %xmm0
movups %xmm0, 0x220(%rbx)
movups %xmm0, 0x230(%rbx)
movups %xmm0, 0x240(%rbx)
movups %xmm0, 0x250(%rbx)
movups %xmm0, 0x260(%rbx)
movups %xmm0, 0x270(%rbx)
movups %xmm0, 0x280(%rbx)
movq %r12, 0x298(%rbx)
xorl %eax, %eax
movq %rax, 0x2a0(%rbx)
movb %al, 0x2a8(%rbx)
leaq 0x2d0(%rbx), %r13
movq %r13, 0x2c0(%rbx)
movq %rax, 0x2c8(%rbx)
movb %al, 0x2d0(%rbx)
leaq 0x2e8(%rbx), %r15
movups %xmm0, 0x2e8(%rbx)
leaq 0x87a4(%rip), %rsi      # 0x13a7b
movq %rbx, %rdi
movl $0x10, %edx
callq 0x4060
leaq 0xf7(%rip), %rax        # 0xb3e2
leaq -0x58(%rbp), %rsi
movq %rax, (%rsi)
movq $0x0, 0x8(%rsi)
leaq -0x40(%rbp), %rdx
movq %rbx, (%rdx)
leaq -0x30(%rbp), %rdi
callq 0xfe1c
movq 0x2f0(%rbx), %rax
movq -0x30(%rbp), %rcx
movq %rcx, 0x2f0(%rbx)
movq %rax, -0x30(%rbp)
leaq 0x341(%rip), %rax       # 0xb668
leaq -0x58(%rbp), %rsi
movq %rax, (%rsi)
movq $0x0, 0x8(%rsi)
leaq -0x48(%rbp), %rdx
movq %rbx, (%rdx)
leaq -0x40(%rbp), %rdi
callq 0xfe1c
movq (%r15), %rax
movq -0x40(%rbp), %rcx
movq %rcx, (%r15)
movq %rax, -0x40(%rbp)
testq %rax, %rax
jne 0xb3dd
cmpq $0x0, -0x30(%rbp)
jne 0xb3dd
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, -0x38(%rbp)
cmpq $0x0, -0x30(%rbp)
je 0xb386
jmp 0xb3dd
jmp 0xb382
movq %rax, -0x38(%rbp)
cmpq $0x0, 0x2f0(%rbx)
jne 0xb3dd
cmpq $0x0, (%r15)
jne 0xb3dd
movq 0x2c0(%rbx), %rdi
cmpq %r13, %rdi
je 0xb3a7
callq 0x4360
movq 0x298(%rbx), %rdi
cmpq %r12, %rdi
je 0xb3b8
callq 0x4360
leaq 0x250(%rbx), %rdi
callq 0xfe9e
movq %r14, %rdi
callq 0x100de
movq %rbx, %rdi
callq 0x46c8
movq -0x38(%rbp), %rdi
callq 0x4630
callq 0x4110
// File: /workspace/github_cpp_makefile_star2_O3/luisremis[P]SDFS/FileSystem.cpp
// Function: FileSystem::findPositionByKey(int)
int FileSystem::findPositionByKey( int key ){
    int position = 0;
    virtualRingLock.lock();
    for(int i=0; i < virtualRing.size(); i++){
        if(virtualRing[i].key >= key ){ //find the first virtual node with n.key >= key. If not, return the first Node.
            position = i;
            break;
        }
    }
    virtualRingLock.unlock();
    return position;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movl %esi, %r14d
movq %rdi, %r15
leaq 0x268(%rdi), %rbx
movq %rbx, %rdi
callq 0x44d0
testl %eax, %eax
jne 0xbb03
movq 0x250(%r15), %rax
movq 0x258(%r15), %rdx
subq %rax, %rdx
je 0xbaea
sarq $0x3, %rdx
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
imulq %rdx, %rcx
cmpq $0x1, %rcx
adcq $0x0, %rcx
addq $0x20, %rax
xorl %r15d, %r15d
cmpl %r14d, (%rax)
jge 0xbaed
incq %r15
addq $0x28, %rax
cmpq %r15, %rcx
jne 0xbad9
xorl %r15d, %r15d
movq %rbx, %rdi
callq 0x42a0
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %edi
callq 0x4240
// File: /workspace/github_cpp_makefile_star2_O3/luisremis[P]SDFS/FileSystem.cpp
// Function: FileSystem::deleteFromAddress(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
bool FileSystem::deleteFromAddress(std::string address, std::string remoteFile)
{
    int connectionToServer; //TCP connect to introducer/other nodes

    // printf("Local file: %s\n", localFile.c_str());
    // printf("Remote file: %s\n", remoteFile.c_str());

    logFile << "Deleting -  Connecting to "<< address << "..." << std::endl;

    int ret = connect_to_server(address.c_str(), port, &connectionToServer);
    if(ret!=0)
    {
        logFile <<"ERROR putToAddress: Cannot connect to "<<address<< std::endl;
        std::cout <<"ERROR putToAddress: Cannot connect to "<<address<< std::endl;
        return false;
    }
    else{

        Message_fs msg;
        msg.type = MSG_DELETE;

        memset(msg.filename, '\0', 200);
        remoteFile.copy(msg.filename, remoteFile.length());
        msg.filename[remoteFile.length()+1] = '\0';
        msg.size = 0;

        write(connectionToServer, &msg, sizeof(Message_fs) );   

        close(connectionToServer);
        return true;
    }   
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0xf0, %rsp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %r12
leaq 0x7af9(%rip), %rsi      # 0x13c41
movl $0x1a, %edx
callq 0x43f0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %r12, %rdi
callq 0x43f0
movq %rax, %rbx
leaq 0x7675(%rip), %rsi      # 0x137e0
movl $0x3, %edx
movq %rax, %rdi
callq 0x43f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4380
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4260
movq (%r14), %rdi
movl 0x200(%r12), %esi
leaq -0x24(%rbp), %rdx
callq 0x1161a
movl %eax, %ebx
testl %eax, %eax
je 0xc25f
leaq 0x7a56(%rip), %r15      # 0x13c1a
movl $0x26, %edx
movq %r12, %rdi
movq %r15, %rsi
callq 0x43f0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %r12, %rdi
callq 0x43f0
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 0xcdac(%rip), %r12      # 0x18fc0
movl $0x26, %edx
movq %r12, %rdi
movq %r15, %rsi
callq 0x43f0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %r12, %rdi
callq 0x43f0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4380
movsbl %al, %esi
movq %r14, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4260
jmp 0xc2be
leaq -0x104(%rbp), %r14
movl $0x2, -0x4(%r14)
movl $0xc8, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x4220
movq 0x8(%r15), %rdx
movq %r15, %rdi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x40a0
movq 0x8(%r15), %rax
leaq -0x108(%rbp), %rsi
movb $0x0, 0x5(%rax,%rsi)
movq $0x0, 0xcc(%r14)
movl -0x24(%rbp), %edi
movl $0xe0, %edx
callq 0x4170
movl -0x24(%rbp), %edi
callq 0x46b0
testl %ebx, %ebx
sete %al
addq $0xf0, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/luisremis[P]SDFS/FileSystem.cpp
// Function: FileSystem::where(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void FileSystem::where(std::string remoteFile)
{    
    int fileKey = hashString(remoteFile);
    int position = findPositionByKey(fileKey);

    std::cout<< "Master Replica: " << virtualRing[position].ip_str << std::endl;
    std::cout<< "Second Replica: " << virtualRing[ (position+1) % virtualRing.size()].ip_str << std::endl;
    std::cout<< "Second Replica: " << virtualRing[ (position+2) % virtualRing.size()].ip_str << std::endl;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
leaq -0x38(%rbp), %r15
movq %r15, -0x10(%r15)
movq (%rsi), %rax
movq 0x8(%rsi), %rdx
addq %rax, %rdx
leaq -0x48(%rbp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x56fa
movq (%r14), %rdi
movq 0x8(%r14), %rsi
movl $0xc70f6907, %edx       # imm = 0xC70F6907
callq 0x40c0
movq %rax, %r14
movq -0x48(%rbp), %rdi
cmpq %r15, %rdi
je 0xcc29
callq 0x4360
movl %r14d, %eax
imulq $0x10624dd3, %rax, %rax # imm = 0x10624DD3
shrq $0x26, %rax
imull $0x3e8, %eax, %eax      # imm = 0x3E8
subl %eax, %r14d
movq %rbx, %rdi
movl %r14d, %esi
callq 0xba82
movl %eax, %r15d
movq 0xc36b(%rip), %r14      # 0x18fc0
leaq 0x6e44(%rip), %rsi      # 0x13aa0
movl $0x10, %edx
movq %r14, %rdi
callq 0x43f0
movslq %r15d, %r13
movq 0x250(%rbx), %rax
leaq (,%r13,4), %rcx
addq %r13, %rcx
movq (%rax,%rcx,8), %rsi
movq 0x8(%rax,%rcx,8), %rdx
movq %r14, %rdi
callq 0x43f0
movq %rax, %r15
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x4380
movsbl %al, %esi
movq %r15, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4260
leaq 0x6df1(%rip), %rsi      # 0x13ab1
movl $0x10, %edx
movq %r14, %rdi
callq 0x43f0
leal 0x1(%r13), %eax
cltq
movq 0x250(%rbx), %rcx
movq 0x258(%rbx), %rsi
subq %rcx, %rsi
sarq $0x3, %rsi
movabsq $-0x3333333333333333, %r15 # imm = 0xCCCCCCCCCCCCCCCD
imulq %r15, %rsi
xorl %edx, %edx
divq %rsi
leaq (%rdx,%rdx,4), %rax
movq (%rcx,%rax,8), %rsi
movq 0x8(%rcx,%rax,8), %rdx
movq %r14, %rdi
callq 0x43f0
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
movl $0x10, %edx
movq %r14, %rdi
leaq 0x6d68(%rip), %rsi      # 0x13ab1
callq 0x43f0
addl $0x2, %r13d
movslq %r13d, %rax
movq 0x250(%rbx), %rcx
movq 0x258(%rbx), %rsi
subq %rcx, %rsi
sarq $0x3, %rsi
imulq %r15, %rsi
xorl %edx, %edx
divq %rsi
leaq (%rdx,%rdx,4), %rax
movq (%rcx,%rax,8), %rsi
movq 0x8(%rcx,%rax,8), %rdx
movq %r14, %rdi
callq 0x43f0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4380
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4260
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rdi
callq 0xa583
nop
// File: /workspace/github_cpp_makefile_star2_O3/luisremis[P]SDFS/FileSystem.cpp
// Function: inRange(int, int, int)
bool inRange(int key, int min, int max){
    if(min < max)
        return (min<key && key<=max);
    else
        return ( (0 <= key && key <= max) || (min < key && key <= RING_SIZE)  );
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
cmpl %edx, %esi
jge 0xe3eb
cmpl %edi, %esi
setl %cl
cmpl %edx, %edi
setle %al
jmp 0xe409
testl %edi, %edi
setns %cl
cmpl %edx, %edi
setle %dl
movb $0x1, %al
testb %dl, %cl
jne 0xe40b
cmpl %edi, %esi
setl %cl
cmpl $0x3e9, %edi            # imm = 0x3E9
setl %al
andb %cl, %al
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O3/luisremis[P]SDFS/FileSystem.cpp
// Function: FileSystem::getFileList[abi:cxx11]()
std::string FileSystem::getFileList()
{
    std::stringstream ss;

    checkFiles();

    filesLock.lock();
    for (std::list<FileEntry>::iterator it=files.begin(); it != files.end(); ++it)
    {
        ss << (*it).filename << " " << (*it).key << std::endl;
    }
    filesLock.unlock();

    return ss.str();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
movq %rsi, %r15
movq %rdi, %rbx
leaq -0x1c0(%rbp), %rdi
callq 0x4270
movq %r15, %rdi
callq 0xcdca
movq %rbx, -0x38(%rbp)
leaq 0x228(%r15), %rdi
movq %rdi, -0x30(%rbp)
callq 0x44d0
testl %eax, %eax
jne 0xe523
addq $0x210, %r15            # imm = 0x210
leaq -0x1b0(%rbp), %r12
leaq 0x4eb5(%rip), %r13      # 0x13322
movq %r15, %r14
movq (%r14), %r14
cmpq %r15, %r14
je 0xe4d3
movq 0x10(%r14), %rsi
movq 0x18(%r14), %rdx
movq %r12, %rdi
callq 0x43f0
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x43f0
movl 0x30(%r14), %esi
movq %rbx, %rdi
callq 0x45f0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x4380
movsbl %al, %esi
movq %rbx, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4260
jmp 0xe470
movq -0x30(%rbp), %rdi
callq 0x42a0
leaq -0x1a8(%rbp), %rsi
movq -0x38(%rbp), %rbx
movq %rbx, %rdi
callq 0x4540
movq 0xaaaa(%rip), %rsi      # 0x18fa0
leaq -0x1c0(%rbp), %rdi
callq 0x4290
leaq -0x140(%rbp), %rdi
callq 0x4160
movq %rbx, %rax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %edi
callq 0x4240
jmp 0xe52c
movq %rax, %rbx
movq 0xaa6a(%rip), %rsi      # 0x18fa0
leaq -0x1c0(%rbp), %rdi
callq 0x4290
leaq -0x140(%rbp), %rdi
callq 0x4160
movq %rbx, %rdi
callq 0x4630
// File: /workspace/github_cpp_makefile_star2_O3/luisremis[P]SDFS/FileSystem.cpp
// Function: FileSystem::addToVirtualRing(Node)
int FileSystem::addToVirtualRing( Node n ){
    VirtualNode newNode;
    newNode.ip_str = n.ip_str;
    newNode.key = hashString(newNode.ip_str);

    virtualRingLock.lock();
    
    virtualRing.push_back(newNode);
    std::sort(virtualRing.begin(), virtualRing.end());
    myPosition = find( virtualRing.begin(), virtualRing.end(), myself ) - virtualRing.begin();
    int joinPosition = find( virtualRing.begin(), virtualRing.end(), newNode ) - virtualRing.begin();

    virtualRingLock.unlock();

    int positionClock = joinPosition - myPosition;
    if(positionClock < 0) 
        positionClock += virtualRing.size() + 1;

    return positionClock;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
leaq -0x40(%rbp), %r13
movq %r13, -0x10(%r13)
movq $0x0, -0x8(%r13)
movb $0x0, (%r13)
leaq -0x50(%rbp), %rdi
callq 0x4210
leaq -0x60(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq %rsi, %rdx
leaq -0x70(%rbp), %rdi
callq 0x56fa
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rsi
movl $0xc70f6907, %edx       # imm = 0xC70F6907
callq 0x40c0
movl %eax, %ecx
imulq $0x10624dd3, %rcx, %rcx # imm = 0x10624DD3
shrq $0x26, %rcx
imull $0x3e8, %ecx, %ecx      # imm = 0x3E8
subl %ecx, %eax
movl %eax, -0x30(%rbp)
movq -0x70(%rbp), %rdi
cmpq %r14, %rdi
je 0xe9c8
callq 0x4360
leaq 0x268(%rbx), %r14
movq %r14, %rdi
callq 0x44d0
testl %eax, %eax
jne 0xeae8
leaq 0x250(%rbx), %rdi
leaq -0x50(%rbp), %rsi
callq 0x1007c
movq 0x250(%rbx), %r12
movq 0x258(%rbx), %r15
cmpq %r15, %r12
je 0xea4b
movq %r15, %rax
subq %r12, %rax
sarq $0x3, %rax
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
imulq %rax, %rcx
bsrq %rcx, %rdx
xorl $0x3f, %edx
addl %edx, %edx
xorq $0x7e, %rdx
movq %r12, %rdi
movq %r15, %rsi
callq 0x10416
movq %r12, %rdi
movq %r15, %rsi
callq 0x104f4
movq 0x250(%rbx), %r12
movq 0x258(%rbx), %r15
leaq 0x298(%rbx), %rdx
movq %r12, %rdi
movq %r15, %rsi
callq 0x10e54
movq 0x250(%rbx), %rdi
movq 0x258(%rbx), %rsi
subq %rdi, %rax
shrq $0x3, %rax
imull $0xcccccccd, %eax, %eax # imm = 0xCCCCCCCD
movl %eax, 0x290(%rbx)
leaq -0x50(%rbp), %rdx
callq 0x10e54
subq 0x250(%rbx), %rax
shrq $0x3, %rax
imull $0xcccccccd, %eax, %r15d # imm = 0xCCCCCCCD
movq %r14, %rdi
callq 0x42a0
subl 0x290(%rbx), %r15d
jns 0xeac8
movq 0x258(%rbx), %rax
subq 0x250(%rbx), %rax
shrq $0x3, %rax
imull $0xcccccccd, %eax, %eax # imm = 0xCCCCCCCD
addl %eax, %r15d
incl %r15d
movq -0x50(%rbp), %rdi
cmpq %r13, %rdi
je 0xead6
callq 0x4360
movl %r15d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %edi
callq 0x4240
jmp 0xeafb
jmp 0xeafb
movq %rax, %rdi
callq 0xa583
movq %rax, %rbx
movq -0x50(%rbp), %rdi
cmpq %r13, %rdi
je 0xeb0c
callq 0x4360
movq %rbx, %rdi
callq 0x4630
// File: /workspace/github_cpp_makefile_star2_O3/luisremis[P]SDFS/FileSystem.cpp
// Function: FileSystem::deleteFromVirtualRing(Node)
int FileSystem::deleteFromVirtualRing( Node n ){
    // cout<<"detect leave: "<<n.ip_str<<endl;

    VirtualNode changeNode;
    changeNode.ip_str = n.ip_str;
    changeNode.key = hashString(changeNode.ip_str);

    // cout<<"leave virtual node: "<<changeNode.ip_str<<" "<<changeNode.key<<endl;

    virtualRingLock.lock();
    
    int myOldPosition = myPosition;

    int leavePosition = find( virtualRing.begin(), virtualRing.end(), changeNode ) - virtualRing.begin();

    // cout<<"leave node position: "<<leavePosition<<endl;

    virtualRing.erase( virtualRing.begin() + leavePosition );

    if( leavePosition == myOldPosition )
        myPosition = -1;
    else
        myPosition = find( virtualRing.begin(), virtualRing.end(), myself ) - virtualRing.begin();
    
    virtualRingLock.unlock();

    int positionClock = leavePosition - myOldPosition;
    if(positionClock < 0) 
        positionClock += virtualRing.size() + 1;

    return positionClock;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x50(%rbp), %rdi
callq 0x4210
leaq -0x60(%rbp), %r14
movq %r14, -0x10(%r14)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
addq %rsi, %rdx
leaq -0x70(%rbp), %rdi
callq 0x56fa
movq -0x70(%rbp), %rdi
movq -0x68(%rbp), %rsi
movl $0xc70f6907, %edx       # imm = 0xC70F6907
callq 0x40c0
movl %eax, %ecx
imulq $0x10624dd3, %rcx, %rcx # imm = 0x10624DD3
shrq $0x26, %rcx
imull $0x3e8, %ecx, %ecx      # imm = 0x3E8
subl %ecx, %eax
movl %eax, -0x30(%rbp)
movq -0x70(%rbp), %rdi
cmpq %r14, %rdi
je 0xeb98
callq 0x4360
leaq 0x268(%rbx), %r15
movq %r15, %rdi
callq 0x44d0
testl %eax, %eax
jne 0xec87
movl 0x290(%rbx), %r13d
movq 0x250(%rbx), %rdi
movq 0x258(%rbx), %rsi
leaq -0x50(%rbp), %rdx
callq 0x10e54
leaq 0x250(%rbx), %r12
movq (%r12), %rcx
subq %rcx, %rax
sarq $0x3, %rax
movabsq $-0x3333333333333333, %r14 # imm = 0xCCCCCCCCCCCCCCCD
imulq %rax, %r14
movslq %r14d, %rax
leaq (%rax,%rax,4), %rax
leaq (%rcx,%rax,8), %rsi
movq %r12, %rdi
callq 0x10f24
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
cmpl %r13d, %r14d
je 0xec32
movq 0x250(%rbx), %rdi
movq 0x258(%rbx), %rsi
leaq 0x298(%rbx), %rdx
callq 0x10e54
subq (%r12), %rax
shrq $0x3, %rax
imull $0xcccccccd, %eax, %eax # imm = 0xCCCCCCCD
movl %eax, 0x290(%rbx)
movq %r15, %rdi
callq 0x42a0
subl %r13d, %r14d
jns 0xec63
movq 0x258(%rbx), %rax
subq 0x250(%rbx), %rax
shrq $0x3, %rax
imull $0xcccccccd, %eax, %eax # imm = 0xCCCCCCCD
addl %eax, %r14d
incl %r14d
leaq -0x40(%rbp), %rax
movq -0x50(%rbp), %rdi
cmpq %rax, %rdi
je 0xec75
callq 0x4360
movl %r14d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %edi
callq 0x4240
jmp 0xec9c
jmp 0xec9c
jmp 0xec9c
movq %rax, %rdi
callq 0xa583
movq %rax, %rbx
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0xecb1
callq 0x4360
movq %rbx, %rdi
callq 0x4630
nop
// File: /workspace/github_cpp_makefile_star2_O3/luisremis[P]SDFS/FileSystem.cpp
// Function: FileSystem::printVirtualRing()
void FileSystem::printVirtualRing()
{
    virtualRingLock.lock();
    for(int i=0; i < virtualRing.size(); i++)
    {
        std::cout << virtualRing[i].ip_str << " " << virtualRing[i].key;
        if (virtualRing[i].key == myself.key)
            std::cout << " X ";
        std::cout << std::endl;
    }
    std::cout<<std::endl;
    virtualRingLock.unlock();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %r14
addq $0x268, %rdi            # imm = 0x268
movq %rdi, -0x30(%rbp)
callq 0x44d0
testl %eax, %eax
jne 0xee08
movq 0x250(%r14), %rax
cmpq %rax, 0x258(%r14)
je 0xedc3
xorl %r13d, %r13d
movq 0xa2bf(%rip), %r15      # 0x18fc0
xorl %r12d, %r12d
movq (%rax,%r13), %rsi
movq 0x8(%rax,%r13), %rdx
movq %r15, %rdi
callq 0x43f0
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
leaq 0x45fb(%rip), %rsi      # 0x13322
callq 0x43f0
movq 0x250(%r14), %rax
movl 0x20(%rax,%r13), %esi
movq %rbx, %rdi
callq 0x45f0
movq 0x250(%r14), %rax
movl 0x20(%rax,%r13), %eax
cmpl 0x2b8(%r14), %eax
jne 0xed69
movl $0x3, %edx
movq %r15, %rdi
leaq 0x4fac(%rip), %rsi      # 0x13d10
callq 0x43f0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x4380
movsbl %al, %esi
movq %r15, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4260
incq %r12
movq 0x250(%r14), %rax
movq 0x258(%r14), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movabsq $-0x3333333333333333, %rdx # imm = 0xCCCCCCCCCCCCCCCD
imulq %rdx, %rcx
addq $0x28, %r13
cmpq %r12, %rcx
ja 0xed04
movq 0xa1f6(%rip), %r14      # 0x18fc0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x4380
movsbl %al, %esi
movq %r14, %rdi
callq 0x4040
movq %rax, %rdi
callq 0x4260
movq -0x30(%rbp), %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x42a0
movl %eax, %edi
callq 0x4240
nop
// File: /workspace/github_cpp_makefile_star2_O3/luisremis[P]SDFS/FileSystem.cpp
// Function: FileSystem::nNodeLater(int, int)
FileSystem::VirtualNode FileSystem::nNodeLater(int n, int current)
{
    int position = current + n;
    while(position < 0)
        position += virtualRing.size();
    while(position >= virtualRing.size())
        position -= virtualRing.size();
    
    return virtualRing[position];
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
addl %ecx, %edx
js 0xf42a
movq 0x250(%rsi), %r14
movq 0x258(%rsi), %rcx
subq %r14, %rcx
sarq $0x3, %rcx
movabsq $-0x3333333333333333, %rax # imm = 0xCCCCCCCCCCCCCCCD
imulq %rcx, %rax
jmp 0xf451
movq 0x250(%rsi), %r14
movq 0x258(%rsi), %rcx
subq %r14, %rcx
sarq $0x3, %rcx
movabsq $-0x3333333333333333, %rax # imm = 0xCCCCCCCCCCCCCCCD
imulq %rcx, %rax
addl %eax, %edx
js 0xf44d
movslq %edx, %rcx
movl %ecx, %edx
subl %eax, %edx
cmpq %rcx, %rax
jbe 0xf451
leaq (%rcx,%rcx,4), %r15
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movq (%r14,%r15,8), %rsi
movq 0x8(%r14,%r15,8), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x56fa
movl 0x20(%r14,%r15,8), %eax
movl %eax, 0x20(%rbx)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/luisremis[P]SDFS/FileSystem.cpp
// Function: FileSystem::nNodeBefore(int, int)
FileSystem::VirtualNode FileSystem::nNodeBefore(int n, int current)
{
    int position = current - n;
    while(position < 0)
        position += virtualRing.size();
    while(position >= virtualRing.size())
        position -= virtualRing.size();
    
    return virtualRing[position];
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
pushq %rax
movq %rdi, %rbx
subl %edx, %ecx
js 0xf4c8
movq 0x250(%rsi), %r14
movq 0x258(%rsi), %rdx
subq %r14, %rdx
sarq $0x3, %rdx
movabsq $-0x3333333333333333, %rax # imm = 0xCCCCCCCCCCCCCCCD
imulq %rdx, %rax
jmp 0xf4ef
movq 0x250(%rsi), %r14
movq 0x258(%rsi), %rdx
subq %r14, %rdx
sarq $0x3, %rdx
movabsq $-0x3333333333333333, %rax # imm = 0xCCCCCCCCCCCCCCCD
imulq %rdx, %rax
addl %eax, %ecx
js 0xf4eb
movslq %ecx, %rdx
movl %edx, %ecx
subl %eax, %ecx
cmpq %rdx, %rax
jbe 0xf4ef
leaq (%rdx,%rdx,4), %r15
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movq (%r14,%r15,8), %rsi
movq 0x8(%r14,%r15,8), %rdx
addq %rsi, %rdx
movq %rbx, %rdi
callq 0x56fa
movl 0x20(%r14,%r15,8), %eax
movl %eax, 0x20(%rbx)
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/luisremis[P]SDFS/FileSystem.cpp
// Function: FileSystem::myselfLeave(Node)
bool FileSystem::myselfLeave( Node myNodeToChange ){
    deleteFromVirtualRing( myNodeToChange );
    
    filesLock.lock();
    files.clear();
    //system("rm files/*");
    filesLock.unlock();

    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq -0x38(%rbp), %r12
movq %r12, -0x10(%r12)
movq (%rsi), %rsi
movq 0x8(%r14), %rdx
addq %rsi, %rdx
leaq -0x48(%rbp), %r15
movq %r15, %rdi
callq 0x56fa
movq 0x20(%r14), %rax
movq %rax, 0x20(%r15)
movq %rbx, %rdi
movq %r15, %rsi
callq 0xeb14
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0xfd89
callq 0x4360
leaq 0x228(%rbx), %r14
movq %r14, %rdi
callq 0x44d0
testl %eax, %eax
jne 0xfddb
leaq 0x210(%rbx), %r15
movq %r15, %rdi
callq 0x100de
movq %r15, 0x218(%rbx)
movq %r15, 0x210(%rbx)
movq $0x0, 0x220(%rbx)
movq %r14, %rdi
callq 0x42a0
movb $0x1, %al
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl %eax, %edi
callq 0x4240
movq %rax, %rbx
movq -0x48(%rbp), %rdi
cmpq %r12, %rdi
je 0xfdf3
callq 0x4360
movq %rbx, %rdi
callq 0x4630
nop
// File: /workspace/github_cpp_makefile_star2_O3/luisremis[P]SDFS/connections.cpp
// Function: ipString2Char4(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, char*)
void ipString2Char4(std::string ip, char* buf) // buf must be size 4
{
    ip.replace(ip.find("."),1," ");
    ip.replace(ip.find("."),1," ");
    ip.replace(ip.find("."),1," ");
    
    std::stringstream ssip(ip);
    int a;
    ssip >> a; buf[0] = (char)a; 
    ssip >> a; buf[1] = (char)a; 
    ssip >> a; buf[2] = (char)a; 
    ssip >> a; buf[3] = (char)a; 
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x190, %rsp            # imm = 0x190
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x2803(%rip), %r15      # 0x137e2
movl $0x1, %ecx
movq %r15, %rsi
xorl %edx, %edx
callq 0x4610
leaq 0x232d(%rip), %r12      # 0x13322
movl $0x1, %edx
movl $0x1, %r8d
movq %r14, %rdi
movq %rax, %rsi
movq %r12, %rcx
callq 0x43d0
movl $0x1, %ecx
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x4610
movl $0x1, %edx
movl $0x1, %r8d
movq %r14, %rdi
movq %rax, %rsi
movq %r12, %rcx
callq 0x43d0
movl $0x1, %ecx
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x4610
movl $0x1, %edx
movl $0x1, %r8d
movq %r14, %rdi
movq %rax, %rsi
movq %r12, %rcx
callq 0x43d0
leaq -0x1b0(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
movl $0x18, %edx
callq 0x4550
leaq -0x24(%rbp), %rsi
movq %r15, %rdi
callq 0x4230
leaq -0x24(%rbp), %rsi
movb (%rsi), %al
movb %al, (%rbx)
leaq -0x1b0(%rbp), %rdi
callq 0x4230
leaq -0x24(%rbp), %rsi
movb (%rsi), %al
movb %al, 0x1(%rbx)
leaq -0x1b0(%rbp), %rdi
callq 0x4230
leaq -0x24(%rbp), %rsi
movb (%rsi), %al
movb %al, 0x2(%rbx)
leaq -0x1b0(%rbp), %rdi
callq 0x4230
movb -0x24(%rbp), %al
movb %al, 0x3(%rbx)
movq 0x7ece(%rip), %rsi      # 0x18fa0
leaq -0x1b0(%rbp), %rdi
callq 0x4290
leaq -0x130(%rbp), %rdi
callq 0x4160
addq $0x190, %rsp            # imm = 0x190
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x7e9c(%rip), %rsi      # 0x18fa0
leaq -0x1b0(%rbp), %rdi
callq 0x4290
leaq -0x130(%rbp), %rdi
callq 0x4160
movq %rbx, %rdi
callq 0x4630
// File: /workspace/github_cpp_makefile_star2_O3/luisremis[P]SDFS/connections.cpp
// Function: char42String[abi:cxx11](char*)
std::string char42String(char* buf) // buf must be size 4
{
    std::stringstream aux;
    aux << (unsigned int) ((uint8_t)buf[0]) << ".";
    aux << (unsigned int) ((uint8_t)buf[1]) << ".";
    aux << (unsigned int) ((uint8_t)buf[2]) << ".";
    aux << (unsigned int) ((uint8_t)buf[3]);

    return aux.str();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x188, %rsp            # imm = 0x188
movq %rsi, %r14
movq %rdi, %rbx
leaq -0x1a0(%rbp), %rdi
callq 0x4270
leaq -0x190(%rbp), %r15
movzbl (%r14), %esi
movq %r15, %rdi
callq 0x4250
leaq 0x2682(%rip), %rsi      # 0x137e2
movl $0x1, %edx
movq %rax, %rdi
callq 0x43f0
movzbl 0x1(%r14), %esi
movq %r15, %rdi
callq 0x4250
leaq 0x2661(%rip), %rsi      # 0x137e2
movl $0x1, %edx
movq %rax, %rdi
callq 0x43f0
movzbl 0x2(%r14), %esi
movq %r15, %rdi
callq 0x4250
leaq 0x2640(%rip), %rsi      # 0x137e2
movl $0x1, %edx
movq %rax, %rdi
callq 0x43f0
movzbl 0x3(%r14), %esi
movq %r15, %rdi
callq 0x4250
leaq -0x188(%rbp), %rsi
movq %rbx, %rdi
callq 0x4540
movq 0x7dce(%rip), %rsi      # 0x18fa0
leaq -0x1a0(%rbp), %rdi
callq 0x4290
leaq -0x120(%rbp), %rdi
callq 0x4160
movq %rbx, %rax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movq 0x7d9b(%rip), %rsi      # 0x18fa0
leaq -0x1a0(%rbp), %rdi
callq 0x4290
leaq -0x120(%rbp), %rdi
callq 0x4160
movq %rbx, %rdi
callq 0x4630
// File: /workspace/github_cpp_makefile_star2_O3/luisremis[P]SDFS/connections.cpp
// Function: getOwnIPAddr[abi:cxx11]()
std::string getOwnIPAddr(){
    struct ifaddrs * ifAddrStruct=NULL;
    struct ifaddrs * ifa=NULL;
    void * tmpAddrPtr=NULL;

    getifaddrs(&ifAddrStruct);
    std::string result;

    int i=0;
    for (ifa = ifAddrStruct; ifa != NULL; ifa = ifa->ifa_next) {
        if (!ifa->ifa_addr) {
            continue;
        }
        i++;
        if(i==4){
            tmpAddrPtr=&((struct sockaddr_in *)ifa->ifa_addr)->sin_addr;
            char addressBuffer[INET_ADDRSTRLEN];
            inet_ntop(AF_INET, tmpAddrPtr, addressBuffer, INET_ADDRSTRLEN);
            result = addressBuffer;
        }
    }
    
    if (ifAddrStruct!=NULL) freeifaddrs(ifAddrStruct);
    return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
xorl %r15d, %r15d
leaq -0x30(%rbp), %r14
movq %r15, (%r14)
movq %r14, %rdi
callq 0x4690
leaq 0x10(%rbx), %r12
movq %r12, (%rbx)
movq %r15, 0x8(%rbx)
movb $0x0, 0x10(%rbx)
movq (%r14), %r13
testq %r13, %r13
je 0x112ca
leaq -0x40(%rbp), %r14
movq 0x18(%r13), %rsi
testq %rsi, %rsi
je 0x112b3
incl %r15d
cmpl $0x4, %r15d
jne 0x112b3
addq $0x4, %rsi
movl $0x2, %edi
movq %r14, %rdx
movl $0x10, %ecx
callq 0x43b0
movq 0x8(%rbx), %r15
movq %r14, %rdi
callq 0x41a0
movq %rbx, %rdi
xorl %esi, %esi
movq %r15, %rdx
movq %r14, %rcx
movq %rax, %r8
callq 0x4510
movl $0x4, %r15d
movq (%r13), %r13
testq %r13, %r13
jne 0x11266
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0x112ca
callq 0x4620
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
movq (%rbx), %rdi
cmpq %r12, %rdi
je 0x112ec
callq 0x4360
movq %r14, %rdi
callq 0x4630
// File: /workspace/github_cpp_makefile_star2_O3/luisremis[P]SDFS/connections.cpp
// Function: bindSocket(int)
int bindSocket(int port)
{
    struct sockaddr_in svrAdd, clntAdd;
    
    //create socket
    int sockfd = socket(AF_INET, SOCK_DGRAM, 0);

    if(sockfd < 0)
    {
        std::cout << "Cannot open socket" << std::endl;
        exit(1);
    }
    
    memset((char*) &svrAdd,0, sizeof(svrAdd));
    
    svrAdd.sin_family = AF_INET;
    svrAdd.sin_addr.s_addr = INADDR_ANY;
    svrAdd.sin_port = htons(port);
    
    //bind socket
    int ret = ::bind(sockfd, (struct sockaddr *)&svrAdd, sizeof(svrAdd));
    if( ret < 0)
    {
        std::cout << "open_socket: Cannot bind" << std::endl;
        exit(1);
    }
    // printf("UDP Listening at port %d...\n", port);

    return sockfd;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movl %edi, %r14d
movl $0x2, %edi
movl $0x2, %esi
xorl %edx, %edx
callq 0x40e0
testl %eax, %eax
js 0x1136e
movl %eax, %ebx
leaq -0x20(%rbp), %rsi
movq $0x0, 0x8(%rsi)
movw $0x2, (%rsi)
movl $0x0, 0x4(%rsi)
rolw $0x8, %r14w
movw %r14w, 0x2(%rsi)
movl %eax, %edi
movl $0x10, %edx
callq 0x40b0
testl %eax, %eax
js 0x1137e
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq 0x7c4b(%rip), %rdi      # 0x18fc0
leaq 0x2a1e(%rip), %rsi      # 0x13d9a
jmp 0x1138c
movq 0x7c3b(%rip), %rdi      # 0x18fc0
leaq 0x2a21(%rip), %rsi      # 0x13dad
callq 0x4390
movq %rax, %rdi
callq 0x41e0
movl $0x1, %edi
callq 0x4400
// File: /workspace/github_cpp_makefile_star2_O3/luisremis[P]SDFS/connections.cpp
// Function: sendUDP(int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&, int, char*, unsigned int)
void sendUDP(int sockfd, std::string& add, int port, char* buf, uint32_t len)
{
    struct sockaddr_in servaddr,cliaddr;
    struct hostent *server;

    server = gethostbyname(add.c_str());

    if(server == NULL)
    {
        std::cout << "Host does not exist" << std::endl;
        exit(1);
    }

    memset((char *) &servaddr,0, sizeof(servaddr));
    servaddr.sin_family = AF_INET;
    memcpy((char *) &servaddr.sin_addr.s_addr,(char *) server -> h_addr, server -> h_length);
    servaddr.sin_port = htons(port);
/*
    //int random = rand() % 100;
    //if ((random) <= 10 ) return; 

    static int counter = 1;
    if ((counter++) % 4 == 0 ){
        //std::cout << "Drop message: " << (unsigned int) (((Message* )(buf))->type) << " " << add << std::endl;
        return; 
    } 
*/

    int ret = sendto(sockfd,buf, len, 0, (struct sockaddr *)&servaddr,sizeof(servaddr));

    if (ret == -1)
    {
        printf("Error in sendUDP: cannot send\n");
        return;
    }
    UDPsent++;
    //printf("Message sent\n");
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r8d, %r15d
movq %rcx, %rbx
movl %edx, %r12d
movl %edi, %r14d
movq (%rsi), %rdi
callq 0x43e0
testq %rax, %rax
je 0x114d0
leaq -0x34(%rbp), %r13
movl $0x0, 0x8(%r13)
movq $0x0, (%r13)
movw $0x2, -0x4(%r13)
movq 0x18(%rax), %rcx
movq (%rcx), %rsi
movslq 0x14(%rax), %rdx
movq %r13, %rdi
callq 0x42d0
rolw $0x8, %r12w
movw %r12w, -0x2(%r13)
movl %r15d, %edx
leaq -0x38(%rbp), %r8
movl %r14d, %edi
movq %rbx, %rsi
xorl %ecx, %ecx
movl $0x10, %r9d
callq 0x4070
cmpl $-0x1, %eax
jne 0x114bb
leaq 0x2980(%rip), %rdi      # 0x13e34
callq 0x4500
jmp 0x114c1
incl 0x80cf(%rip)            # 0x19590
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x7ae9(%rip), %rdi      # 0x18fc0
leaq 0x28e8(%rip), %rsi      # 0x13dc6
callq 0x4390
movq %rax, %rdi
callq 0x41e0
movl $0x1, %edi
callq 0x4400
// File: /workspace/github_cpp_makefile_star2_O3/luisremis[P]SDFS/connections.cpp
// Function: open_socket(int)
int open_socket(int port)
{
    struct sockaddr_in svrAdd, clntAdd;
    int listenFd;
    
    //create socket
    listenFd = socket(AF_INET, SOCK_STREAM, 0);
    int yes = 1;

    if (setsockopt(listenFd, SOL_SOCKET, SO_REUSEADDR, &yes, sizeof(yes)) == -1) 
    {
        printf("setsockopt\n");
        exit(1);
    }
    
    if(listenFd < 0)
    {
        std::cout << "Cannot open socket" << std::endl;
        exit(1);
    }
    
    memset((char*) &svrAdd,0, sizeof(svrAdd));
    
    svrAdd.sin_family = AF_INET;
    svrAdd.sin_addr.s_addr = INADDR_ANY;
    svrAdd.sin_port = htons(port);
    
    //bind socket

    int ret = ::bind(listenFd, (struct sockaddr *)&svrAdd, sizeof(svrAdd));
    if(ret < 0)
    {
        std::cout << "open_socket: Cannot bind" << std::endl;
        exit(1);
    }
    // printf("TCP Listening at port %d...\n", port);

    return listenFd;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movl %edi, %r14d
movl $0x2, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x40e0
movl %eax, %ebx
leaq -0x14(%rbp), %rcx
movl $0x1, (%rcx)
movl %eax, %edi
movl $0x1, %esi
movl $0x2, %edx
movl $0x4, %r8d
callq 0x4640
cmpl $-0x1, %eax
je 0x1157d
testl %ebx, %ebx
js 0x1158b
leaq -0x24(%rbp), %rsi
movq $0x0, 0x8(%rsi)
movw $0x2, (%rsi)
movl $0x0, 0x4(%rsi)
rolw $0x8, %r14w
movw %r14w, 0x2(%rsi)
movl %ebx, %edi
movl $0x10, %edx
callq 0x40b0
testl %eax, %eax
js 0x1159b
movl %ebx, %eax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x28ce(%rip), %rdi      # 0x13e52
callq 0x4500
jmp 0x115b6
movq 0x7a2e(%rip), %rdi      # 0x18fc0
leaq 0x2801(%rip), %rsi      # 0x13d9a
jmp 0x115a9
movq 0x7a1e(%rip), %rdi      # 0x18fc0
leaq 0x2804(%rip), %rsi      # 0x13dad
callq 0x4390
movq %rax, %rdi
callq 0x41e0
movl $0x1, %edi
callq 0x4400
// File: /workspace/github_cpp_makefile_star2_O3/luisremis[P]SDFS/connections.cpp
// Function: listen_socket(int)
int listen_socket(int listenFd)
{

    socklen_t len; //store size of the address
    int connFd;
    struct sockaddr_in clntAdd;

    listen(listenFd, 5);
    
    len = sizeof(clntAdd);

    //this is where client connects. svr will hang in this mode until client conn
    connFd = accept(listenFd, (struct sockaddr *)&clntAdd, &len);

    if (connFd < 0)
    {
        std::cout << "Cannot accept connection" << std::endl;
        exit(1);
    }
    else
    {
        //std::cout << "Server Connection successful " << std::endl;
    }

    return connFd;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %rbx
subq $0x18, %rsp
movl %edi, %ebx
movl $0x5, %esi
callq 0x43c0
leaq -0xc(%rbp), %rdx
movl $0x10, (%rdx)
leaq -0x1c(%rbp), %rsi
movl %ebx, %edi
callq 0x4150
testl %eax, %eax
js 0x115f5
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
movq 0x79c4(%rip), %rdi      # 0x18fc0
leaq 0x27d7(%rip), %rsi      # 0x13dda
callq 0x4390
movq %rax, %rdi
callq 0x41e0
movl $0x1, %edi
callq 0x4400
// File: /workspace/github_cpp_makefile_star2_O3/luisremis[P]SDFS/connections.cpp
// Function: connect_to_server(char const*, int, int*)
int connect_to_server(const char* add, int port, int* connectionFd)
{
    struct sockaddr_in svrAdd;
    struct hostent *server;
    
    if((port > 65535) || (port < 2000))
    {
        std::cout<<"Please enter port number between 2000 - 65535"<<std::endl;
        exit(1);
    }       
    
    //create client skt
    *connectionFd = socket(AF_INET, SOCK_STREAM, 0);
        int iSetOption = 1;
    setsockopt(*connectionFd, SOL_SOCKET, SO_REUSEADDR, (char*)&iSetOption,
        sizeof(iSetOption));
    
    if(*connectionFd < 0)
    {
        std::cout << "Cannot open socket" << std::endl;
        exit(1);
    }
    else{
        //std::cout << "Socket opened" << std::endl;
    }
    
    server = gethostbyname(add);
    
    if(server == NULL)
    {
        std::cout << "Host does not exist" << std::endl;
        exit(1);
    }
    
    memset((char *) &svrAdd,0, sizeof(svrAdd));
    svrAdd.sin_family = AF_INET;
    
    memcpy((char *) &svrAdd.sin_addr.s_addr,(char *) server -> h_addr, server -> h_length);
    
    svrAdd.sin_port = htons(port);
    
    int checker = connect(*connectionFd,(struct sockaddr *) &svrAdd, sizeof(svrAdd));
    
    if (checker < 0)
    {
        //printf("Cannot connect to: %s \n",add);
        return -1;
        //exit(1);
    }
    else{
        return 0;
        //std::cout << "Client Connection Successful" << std::endl;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %rbx
subq $0x18, %rsp
movl %esi, %r14d
leal -0x10000(%r14), %eax
cmpl $0xffff07cf, %eax       # imm = 0xFFFF07CF
jbe 0x116dd
movq %rdx, %rbx
movq %rdi, %r15
movl $0x2, %edi
movl $0x1, %esi
xorl %edx, %edx
callq 0x40e0
movl %eax, (%rbx)
leaq -0x1c(%rbp), %rcx
movl $0x1, (%rcx)
movl %eax, %edi
movl $0x1, %esi
movl $0x2, %edx
movl $0x4, %r8d
callq 0x4640
cmpl $0x0, (%rbx)
js 0x116ed
movq %r15, %rdi
callq 0x43e0
testq %rax, %rax
je 0x116fd
leaq -0x28(%rbp), %r15
movl $0x0, 0x8(%r15)
movq $0x0, (%r15)
movw $0x2, -0x4(%r15)
movq 0x18(%rax), %rcx
movq (%rcx), %rsi
movslq 0x14(%rax), %rdx
movq %r15, %rdi
callq 0x42d0
rolw $0x8, %r14w
movw %r14w, -0x2(%r15)
movl (%rbx), %edi
leaq -0x2c(%rbp), %rsi
movl $0x10, %edx
callq 0x42e0
sarl $0x1f, %eax
addq $0x18, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq 0x78dc(%rip), %rdi      # 0x18fc0
leaq 0x2708(%rip), %rsi      # 0x13df3
jmp 0x1170b
movq 0x78cc(%rip), %rdi      # 0x18fc0
leaq 0x269f(%rip), %rsi      # 0x13d9a
jmp 0x1170b
movq 0x78bc(%rip), %rdi      # 0x18fc0
leaq 0x26bb(%rip), %rsi      # 0x13dc6
callq 0x4390
movq %rax, %rdi
callq 0x41e0
movl $0x1, %edi
callq 0x4400
// File: /workspace/github_cpp_makefile_star2_O3/luisremis[P]SDFS/connections.cpp
// Function: robustRead(int, char*, int)
int robustRead(int connFd, char * buffer, int length){
    int count = 0, add = 0;
    while(count < length){
        if( (add = read(connFd, buffer, length)) > 0 ){
            count += add;
            buffer += add;
        }
        else if( add < 0 ){
            return -10;
        }
        else if(add == 0){
            break;
        }
    }
    return count;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testl %edx, %edx
jle 0x11768
movl %edx, %r14d
movq %rsi, %r15
movl %edi, %r12d
movl %edx, %r13d
xorl %ebx, %ebx
movl %r12d, %edi
movq %r15, %rsi
movq %r13, %rdx
callq 0x44b0
testl %eax, %eax
jle 0x1176c
movl %eax, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
addq %rcx, %r15
addl %eax, %ebx
cmpl %r14d, %ebx
jl 0x11742
jmp 0x11774
xorl %ebx, %ebx
jmp 0x11774
movl $0xfffffff6, %eax       # imm = 0xFFFFFFF6
cmovnel %eax, %ebx
movl %ebx, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/luisremis[P]SDFS/connections.cpp
// Function: robustWrite(int, char*, int)
int robustWrite(int connFd, char * buffer, int length){
    int count = 0, add = 0;
    while(count < length){
        if( ( add = write(connFd, buffer, length)) > 0 ){
            count += add;
            buffer += add;
        }
        else if( add < 0 ){
            return -1;
        }
    }
    return count;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
testl %edx, %edx
jle 0x117cd
movl %edx, %ebx
movq %rsi, %r15
movl %edi, %r12d
movl %edx, %r13d
xorl %r14d, %r14d
movl %r12d, %edi
movq %r15, %rsi
movq %r13, %rdx
callq 0x4170
testl %eax, %eax
jle 0x117c4
addl %eax, %r14d
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addq %rax, %r15
jmp 0x117c6
js 0x117d2
cmpl %ebx, %r14d
jl 0x117a5
jmp 0x117d8
xorl %r14d, %r14d
jmp 0x117d8
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movl %r14d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/luisremis[P]SDFS/connections.cpp
// Function: splitWrite(int, char*, unsigned long)
size_t splitWrite( int connFd, char * data, size_t size ){
    
    int msg_num = size / BUFFER_MAX + 1;
    int rest = size % ((int)BUFFER_MAX);
    
    //store the should-be message sizes
    message *msgs = new message[msg_num];
    for(int i=1; i < msg_num; i++){
        msgs[i].begin = msgs[i-1].begin + BUFFER_MAX;
    }
    msgs[msg_num-1].length = rest;

    char writeSuccess = 0;
    for(int i=0; i < msg_num; i++){
        //write each message, max size is BUFFER_MAX
        robustWrite( connFd, data + msgs[i].begin, msgs[i].length );
        
        //cout<<"Server: sent " << msgs[i].length << endl;
        //usleep(200*1000);
        
        //make sure client do got the data
        robustRead( connFd, &writeSuccess, 1 );
        
        //cout<<"Server: recv "<<(int)writeSuccess<<endl;
        //usleep(200*1000);

        //if package failed, send again
        if(writeSuccess==0) i--;
    }
    return size;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, -0x40(%rbp)
movl %edi, %r15d
movq %rdx, %r13
shrq $0x17, %r13
leal 0x1(%r13), %eax
movq %rdx, -0x38(%rbp)
movl %edx, %ebx
andl $0x7fffff, %ebx         # imm = 0x7FFFFF
movl %eax, -0x30(%rbp)
movslq %eax, %r14
leaq (,%r14,8), %rax
testl %r14d, %r14d
movq $-0x1, %rdi
cmovnsq %rax, %rdi
callq 0x4030
movq %rax, %r12
movl %r13d, %eax
incl %eax
jne 0x11851
movslq %r13d, %rax
movl %ebx, 0x4(%r12,%rax,8)
jmp 0x118fb
leaq (%r12,%r14,8), %rax
movabsq $0x80000000000000, %rcx # imm = 0x80000000000000
movq %r12, %rdx
movq %rcx, (%rdx)
addq $0x8, %rdx
cmpq %rax, %rdx
jne 0x11862
cmpl $0x2, -0x30(%rbp)
jl 0x11891
movl $0x1, %eax
movl $0x800000, %ecx         # imm = 0x800000
movl -0x8(%r12,%rax,8), %edx
addl %ecx, %edx
movl %edx, (%r12,%rax,8)
incq %rax
cmpq %rax, %r14
jne 0x1187e
movslq %r13d, %rax
movl %ebx, 0x4(%r12,%rax,8)
movb $0x0, -0x29(%rbp)
cmpl $0x7ffffffe, %r13d      # imm = 0x7FFFFFFE
ja 0x118fb
xorl %r14d, %r14d
movslq %r14d, %rax
movslq (%r12,%rax,8), %rsi
addq -0x40(%rbp), %rsi
movl 0x4(%r12,%rax,8), %edx
movl %r15d, %edi
callq 0x11785
xorl %ebx, %ebx
leaq -0x29(%rbp), %r13
movl $0x1, %edx
movl %r15d, %edi
movq %r13, %rsi
callq 0x44b0
testl %eax, %eax
jle 0x118ea
movl %eax, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
addq %rcx, %r13
addl %eax, %ebx
jle 0x118c7
cmpb $0x1, -0x29(%rbp)
sbbl $0x0, %r14d
incl %r14d
cmpl -0x30(%rbp), %r14d
jl 0x118a9
movq -0x38(%rbp), %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O3/luisremis[P]SDFS/connections.cpp
// Function: splitRead(int, char*, unsigned long)
size_t splitRead( int connFd, char * data, size_t size ){
    
    int msg_num = size / BUFFER_MAX + 1;
    int rest = size % ((int)BUFFER_MAX);
    
    //store the should-be message sizes
    message *msgs = new message[msg_num];
    for(int i=1; i < msg_num; i++){
        msgs[i].begin = msgs[i-1].begin + BUFFER_MAX;
    }
    msgs[msg_num-1].length = rest;

    char readSuccess = 0;
    int readSize;

    for(int i=0; i < msg_num; i++){

        //read message from socket. max size BUFFER_MAX
        readSize = robustRead( connFd, data + msgs[i].begin, msgs[i].length );
        
        //cout<<"client recv size :" << readSize << endl;
        //usleep(200*1000);

        //check if reading success or not
        if(readSize == msgs[i].length)  readSuccess = 1;
        else    readSuccess = 0;

        //tell server the data transmission status (good or fail)
        robustWrite( connFd, &readSuccess, 1);
        
        //cout<<"Client: sent "<<endl;
        //usleep(200*1000);
        
        //if reading faile, read again
        if(readSuccess==0) i--;
    }
    return size;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rsi, -0x50(%rbp)
movl %edi, %r15d
movq %rdx, %rbx
shrq $0x17, %rbx
leal 0x1(%rbx), %eax
movq %rdx, -0x40(%rbp)
movl %edx, %r14d
andl $0x7fffff, %r14d        # imm = 0x7FFFFF
movl %eax, -0x30(%rbp)
movslq %eax, %r13
leaq (,%r13,8), %rax
testl %r13d, %r13d
movq $-0x1, %rdi
cmovnsq %rax, %rdi
callq 0x4030
movq %rax, %r12
movl %ebx, %eax
incl %eax
jne 0x11975
movslq %ebx, %rax
movl %r14d, 0x4(%r12,%rax,8)
jmp 0x11a3b
leaq (%r12,%r13,8), %rax
movabsq $0x80000000000000, %rcx # imm = 0x80000000000000
movq %r12, %rdx
movq %rcx, (%rdx)
addq $0x8, %rdx
cmpq %rax, %rdx
jne 0x11986
cmpl $0x2, -0x30(%rbp)
jl 0x119b5
movl $0x1, %eax
movl $0x800000, %ecx         # imm = 0x800000
movl -0x8(%r12,%rax,8), %edx
addl %ecx, %edx
movl %edx, (%r12,%rax,8)
incq %rax
cmpq %rax, %r13
jne 0x119a2
movslq %ebx, %rax
movl %r14d, 0x4(%r12,%rax,8)
cmpl $0x7ffffffe, %ebx       # imm = 0x7FFFFFFE
ja 0x11a3b
xorl %r14d, %r14d
movq %r12, -0x48(%rbp)
movslq %r14d, %rbx
movslq (%r12,%rbx,8), %rsi
addq -0x50(%rbp), %rsi
movl 0x4(%r12,%rbx,8), %edx
movl %r15d, %edi
callq 0x11722
movl 0x4(%r12,%rbx,8), %r12d
movl %eax, -0x34(%rbp)
cmpl %r12d, %eax
sete -0x29(%rbp)
xorl %r13d, %r13d
leaq -0x29(%rbp), %rbx
movl $0x1, %edx
movl %r15d, %edi
movq %rbx, %rsi
callq 0x4170
testl %eax, %eax
jle 0x11a1b
addl %eax, %r13d
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addq %rax, %rbx
jmp 0x11a1d
js 0x11a22
testl %r13d, %r13d
jle 0x119fa
xorl %eax, %eax
cmpl %r12d, -0x34(%rbp)
setne %al
subl %eax, %r14d
incl %r14d
cmpl -0x30(%rbp), %r14d
movq -0x48(%rbp), %r12
jl 0x119cc
movq -0x40(%rbp), %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop