LLM4Binary/decompile-bench-makefile huggingface dataset:
// File: /workspace/github_cpp_makefile_star2_O2/luisremis[P]SDFS/Membership.cpp
// Function: MemberUpdateMsg::operator=(MemberUpdateMsg const&)
MemberUpdateMsg & MemberUpdateMsg::operator=( MemberUpdateMsg const & msg){
    this->type = msg.type;
    this->node = msg.node;
    this->fileSystemRead = msg.fileSystemRead;
    return *this;   
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rsi, %rbx
movq %rdi, %r14
movl (%rsi), %eax
movl %eax, (%rdi)
addq $0x8, %rsi
addq $0x8, %rdi
callq 0x8898
movb 0x30(%rbx), %al
movb %al, 0x30(%r14)
movq %r14, %rax
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r15
movq %rdi, %rbx
addq $0x370, %rsi            # imm = 0x370
leaq -0x38(%rbp), %r12
movq %r12, %rdi
callq 0x8948
leaq 0x358(%r15), %r14
leaq 0x398(%r15), %r13
movq 0x358(%r15), %rsi
cmpq %rsi, 0x360(%r15)
jne 0x855b
movq %r13, %rdi
movq %r12, %rsi
callq 0x4130
jmp 0x853e
movq %rbx, %rdi
callq 0x847c
movq (%r14), %rsi
movq %r14, %rdi
callq 0x89be
leaq -0x38(%rbp), %rdi
callq 0x89a4
movq %rbx, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %r14
addq $0x8, %rbx
movq %rbx, %rdi
callq 0x41b0
jmp 0x859d
movq %rax, %r14
leaq -0x38(%rbp), %rdi
callq 0x89a4
movq %r14, %rdi
callq 0x45d0
// File: /workspace/github_cpp_makefile_star2_O2/luisremis[P]SDFS/Membership.cpp
// Function: Membership::emptyFileSysQueue()
bool Membership::emptyFileSysQueue(){
    fileSysMsgQueueLock.lock();
    bool ret = fileSysMsgQueue.size();
    fileSysMsgQueueLock.unlock();
    return ret;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
movq %rdi, %rbx
leaq 0x370(%rdi), %r14
movq %r14, %rdi
callq 0x8608
movq 0x360(%rbx), %rax
cmpq 0x358(%rbx), %rax
setne %bl
movq %r14, %rdi
callq 0x4290
movl %ebx, %eax
popq %rbx
popq %r14
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 0x4570
movl %r15d, 0x200(%rbx)
movq %r14, 0x208(%rbx)
leaq 0x210(%rbx), %r14
movq %r14, 0x218(%rbx)
movq %r14, 0x210(%rbx)
leaq 0x2a8(%rbx), %rax
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 %rax, 0x298(%rbx)
andq $0x0, 0x2a0(%rbx)
xorl %eax, %eax
movb %al, 0x2a8(%rbx)
leaq 0x2d0(%rbx), %rcx
movq %rcx, 0x2c0(%rbx)
andq $0x0, 0x2c8(%rbx)
movb %al, 0x2d0(%rbx)
leaq 0x2e8(%rbx), %r15
movups %xmm0, 0x2e8(%rbx)
leaq 0x6394(%rip), %rsi      # 0xfa53
pushq $0x10
popq %rdx
movq %rbx, %rdi
callq 0x4050
leaq 0xf7(%rip), %rax        # 0x97c8
leaq -0x60(%rbp), %rsi
movq %rax, (%rsi)
andq $0x0, 0x8(%rsi)
leaq -0x40(%rbp), %rdx
movq %rbx, (%rdx)
leaq -0x30(%rbp), %rdi
callq 0xc90a
movq 0x2f0(%rbx), %rax
movq -0x30(%rbp), %rcx
movq %rcx, 0x2f0(%rbx)
leaq 0x238(%rip), %rcx       # 0x993e
leaq -0x60(%rbp), %rsi
movq %rcx, (%rsi)
andq $0x0, 0x8(%rsi)
movq %rax, -0x30(%rbp)
leaq -0x50(%rbp), %rdx
movq %rbx, (%rdx)
leaq -0x40(%rbp), %rdi
callq 0xc90a
movq (%r15), %rax
leaq -0x40(%rbp), %rdi
movq (%rdi), %rcx
movq %rcx, (%r15)
movq %rax, (%rdi)
callq 0x5204
leaq -0x30(%rbp), %rdi
callq 0x5204
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, -0x38(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x5204
jmp 0x9768
jmp 0x9764
movq %rax, -0x38(%rbp)
leaq 0x298(%rbx), %r13
leaq 0x2c0(%rbx), %r12
leaq 0x2f0(%rbx), %rdi
leaq 0x250(%rbx), %rax
movq %rax, -0x48(%rbp)
callq 0x5204
movq %r15, %rdi
callq 0x5204
movq %r12, %rdi
callq 0x41b0
movq %r13, %rdi
callq 0x41b0
movq -0x48(%rbp), %rdi
callq 0xc988
movq %r14, %rdi
callq 0xcbc4
movq %rbx, %rdi
callq 0x4678
movq -0x38(%rbp), %rdi
callq 0x45d0
nop
// File: /workspace/github_cpp_makefile_star2_O2/luisremis[P]SDFS/FileSystem.cpp
// Function: FileSystem::updateThread()
void FileSystem::updateThread(){
    myNode = membership.getMyNode();
    myself.ip_str = myNode.ip_str;
    myself.key = hashString( myself.ip_str );

    while(true){

        MemberUpdateMsg msg = membership.pullMsgFromFileSysQueue();
        
        if(msg.type == MSG_JOIN){
            // cout<<"recv join msg: "<<msg.node.ip_str<<endl;
            //if(msg.node.ip_str.compare(myNode.ip_str) != 0)
                detectJoin( msg.node );
            //else
                //myselfJoin( msg.node );
        }
        else if(msg.type == MSG_JOIN_FINISH){
            myJoinFinished( );
        }
        else if(msg.type == MSG_LEAVE || msg.type == MSG_FAIL ){
            // cout<<"recv leave msg: "<<msg.node.ip_str<<endl;
            if( msg.node.ip_str.compare(myNode.ip_str) != 0 )
                detectLeave( msg.node );
            else
                myselfLeave( msg.node );
        }
        //printVirtualRing();
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xd8, %rsp
movq %rdi, %r14
movq 0x208(%rdi), %rsi
leaq -0xb8(%rbp), %r15
movq %r15, %rdi
callq 0x85e8
leaq 0x2c0(%r14), %r12
movq %r12, %rdi
movq %r15, %rsi
callq 0x910e
movq %r15, %rdi
callq 0x41b0
leaq 0x298(%r14), %rbx
movq %rbx, %rdi
movq %r12, -0x30(%rbp)
movq %r12, %rsi
callq 0x4200
leaq -0x100(%rbp), %r12
movq %r12, %rdi
movq %rbx, %rsi
callq 0x4450
movq %r12, %rdi
callq 0x95d4
movl %eax, 0x2b8(%r14)
movq %r12, %rdi
callq 0x41b0
leaq -0xb0(%rbp), %rbx
leaq -0xe0(%rbp), %r13
movq 0x208(%r14), %rsi
movq %r15, %rdi
callq 0x8506
movl -0xb8(%rbp), %eax
cmpl $0x8, %eax
je 0x9896
cmpl $0x6, %eax
jne 0x98a0
movq %r13, %rdi
movq %rbx, %rsi
callq 0x8734
movq %r14, %rdi
movq %r13, %rsi
callq 0xc2fa
movq %r13, %rdi
jmp 0x98f6
movq %r14, %rdi
callq 0xbe0c
jmp 0x98fb
andl $-0x3, %eax
cmpl $0x5, %eax
jne 0x98fb
movq %rbx, %rdi
movq -0x30(%rbp), %rsi
callq 0x4040
testl %eax, %eax
je 0x98d8
leaq -0x80(%rbp), %rdi
movq %rbx, %rsi
callq 0x8734
movq %r14, %rdi
leaq -0x80(%rbp), %r12
movq %r12, %rsi
callq 0xc348
movq %r12, %rdi
jmp 0x98f6
leaq -0x58(%rbp), %rdi
movq %rbx, %rsi
callq 0x8734
movq %r14, %rdi
leaq -0x58(%rbp), %r12
movq %r12, %rsi
callq 0xc876
movq %r12, %rdi
callq 0x41b0
movq %rbx, %rdi
callq 0x41b0
jmp 0x985c
movq %rax, %r14
leaq -0x58(%rbp), %rdi
jmp 0x9924
movq %rax, %r14
leaq -0x80(%rbp), %rdi
jmp 0x9924
movq %rax, %r14
leaq -0xe0(%rbp), %rdi
callq 0x41b0
jmp 0x992e
movq %rax, %r14
movq %rbx, %rdi
callq 0x41b0
movq %r14, %rdi
callq 0x45d0
// File: /workspace/github_cpp_makefile_star2_O2/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 0x8608
movq 0x250(%r15), %rcx
movq 0x258(%r15), %rax
subq %rcx, %rax
pushq $0x28
popq %rsi
cqto
idivq %rsi
addq $0x20, %rcx
xorl %r15d, %r15d
xorl %edx, %edx
cmpq %rdx, %rax
jbe 0x9c69
cmpl %r14d, (%rcx)
jge 0x9c66
incq %rdx
addq $0x28, %rcx
jmp 0x9c53
movl %edx, %r15d
movq %rbx, %rdi
callq 0x4290
movl %r15d, %eax
addq $0x8, %rsp
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 0x5b41(%rip), %rsi      # 0xfc19
callq 0x4370
movq %rax, %rdi
movq %r14, %rsi
callq 0x4300
leaq 0x56c9(%rip), %rsi      # 0xf7b8
movq %rax, %rdi
callq 0x4370
movq %rax, %rdi
callq 0x41d0
movq (%r14), %rdi
movl 0x200(%r12), %esi
leaq -0x24(%rbp), %rdx
callq 0xddff
movl %eax, %ebx
testl %eax, %eax
je 0xa162
leaq 0x5ad2(%rip), %r15      # 0xfbf2
movq %r12, %rdi
movq %r15, %rsi
callq 0x4370
movq %rax, %rdi
movq %r14, %rsi
callq 0x4300
movq %rax, %rdi
callq 0x41d0
movq 0xbe7b(%rip), %rdi      # 0x15fc0
movq %r15, %rsi
callq 0x4370
movq %rax, %rdi
movq %r14, %rsi
callq 0x4300
movq %rax, %rdi
callq 0x41d0
jmp 0xa1be
leaq -0x104(%rbp), %r14
movl $0x2, -0x4(%r14)
movl $0xc8, %edx
movq %r14, %rdi
xorl %esi, %esi
callq 0x4210
movq 0x8(%r15), %rdx
movq %r15, %rdi
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x4090
movq 0x8(%r15), %rax
leaq -0x108(%rbp), %rsi
movb $0x0, 0x5(%rax,%rsi)
andq $0x0, 0xcc(%r14)
movl -0x24(%rbp), %edi
movl $0xe0, %edx
callq 0x4150
movl -0x24(%rbp), %edi
callq 0x4650
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_O2/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 -0x48(%rbp), %r14
movq %r14, %rdi
callq 0x4450
movq %r14, %rdi
callq 0x95d4
movl %eax, %r15d
movq %r14, %rdi
callq 0x41b0
movq %rbx, %rdi
movl %r15d, %esi
callq 0x9c12
movl %eax, %r15d
movq 0xb7c4(%rip), %r14      # 0x15fc0
leaq 0x5275(%rip), %rsi      # 0xfa78
movq %r14, %rdi
callq 0x4370
movslq %r15d, %r12
imulq $0x28, %r12, %rsi
addq 0x250(%rbx), %rsi
movq %rax, %rdi
callq 0x4300
movq %rax, %rdi
callq 0x41d0
leaq 0x5259(%rip), %r15      # 0xfa89
movq %r14, %rdi
movq %r15, %rsi
callq 0x4370
movq %rax, %rdi
leal 0x1(%r12), %eax
movslq %eax, %rcx
movq 0x250(%rbx), %r8
movq 0x258(%rbx), %rax
subq %r8, %rax
pushq $0x28
popq %r13
cqto
idivq %r13
movq %rax, %rsi
movq %rcx, %rax
xorl %edx, %edx
divq %rsi
imulq $0x28, %rdx, %rsi
addq %r8, %rsi
callq 0x4300
movq %rax, %rdi
callq 0x41d0
movq %r14, %rdi
movq %r15, %rsi
callq 0x4370
movq %rax, %rdi
addl $0x2, %r12d
movslq %r12d, %rcx
movq 0x250(%rbx), %r8
movq 0x258(%rbx), %rax
subq %r8, %rax
cqto
idivq %r13
movq %rax, %rsi
movq %rcx, %rax
xorl %edx, %edx
divq %rsi
imulq $0x28, %rdx, %rsi
addq %r8, %rsi
callq 0x4300
movq %rax, %rdi
callq 0x41d0
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/luisremis[P]SDFS/FileSystem.cpp
// Function: FileSystem::deleteFromFS(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void FileSystem::deleteFromFS(std::string remoteFile)
{
    // hashing function to find the machine/s where to store the file;
    
    int fileKey = hashString(remoteFile);
    int position = findPositionByKey(fileKey);

    // cout<<"delete " << fileKey << " from "<<position<<" "<<virtualRing[position].ip_str<<" "<<virtualRing[position].key<<endl;

    bool attempt = deleteFromNode( position, remoteFile );
    if( !attempt)
    {
        std::cout << "Problem removing at position " << position << std::endl;
    }
    
    attempt = deleteFromNode( position+1, remoteFile );
    //if(attempt)
        //return;
    
    attempt = deleteFromNode( position+2, remoteFile );
    //if(attempt)
        //return;


    //std::string destAddress = "localhost";
    //put(destAddress, localFile, remoteFile);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x88, %rsp
movq %rsi, %r14
movq %rdi, %rbx
leaq -0xa8(%rbp), %r15
movq %r15, %rdi
callq 0x4450
movq %r15, %rdi
callq 0x95d4
movl %eax, %r12d
movq %r15, %rdi
callq 0x41b0
movq %rbx, %rdi
movl %r12d, %esi
callq 0x9c12
movl %eax, %r15d
leaq -0x88(%rbp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x4450
movq %rbx, %rdi
movl %r15d, %esi
movq %r12, %rdx
callq 0x9fe0
movl %eax, %r13d
leaq -0x88(%rbp), %rdi
callq 0x41b0
testb %r13b, %r13b
jne 0xaf5c
movq 0xb083(%rip), %rdi      # 0x15fc0
leaq 0x4bab(%rip), %rsi      # 0xfaef
callq 0x4370
movq %rax, %rdi
movl %r15d, %esi
callq 0x45a0
movq %rax, %rdi
callq 0x41d0
leal 0x1(%r15), %r13d
leaq -0x68(%rbp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x4450
movq %rbx, %rdi
movl %r13d, %esi
movq %r12, %rdx
callq 0x9fe0
leaq -0x68(%rbp), %rdi
callq 0x41b0
addl $0x2, %r15d
leaq -0x48(%rbp), %r12
movq %r12, %rdi
movq %r14, %rsi
callq 0x4450
movq %rbx, %rdi
movl %r15d, %esi
movq %r12, %rdx
callq 0x9fe0
leaq -0x48(%rbp), %rdi
callq 0x41b0
addq $0x88, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xafc6
jmp 0xafc6
movq %rax, %rbx
movq %r12, %rdi
callq 0x41b0
movq %rbx, %rdi
callq 0x45d0
nop
// File: /workspace/github_cpp_makefile_star2_O2/luisremis[P]SDFS/FileSystem.cpp
// Function: FileSystem::readFile(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, char**)
size_t FileSystem::readFile(std::string filename, char** buffer)
{
    std::string root = "files/";
    std::ifstream file(root + filename, std::ifstream::binary);

    if (!file.good())
    {
        std::cout << "readFile: Could not open file: " << filename << std::endl;
        logFile << "readFile: Could not open file: " << filename << std::endl;
        return 0;
    }

    file.seekg (0, file.end);
    size_t length = file.tellg();
    file.seekg (0, file.beg);        

    *buffer = new char [length];

    file.read (*buffer,length);
    file.close();

    logFile << "readFile " << root + filename << " read" << std::endl;
    // std::cout << "readFile " << root + filename << " read" << std::endl;

    return length;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x250, %rsp            # imm = 0x250
movq %rdx, %r12
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x496d(%rip), %rsi      # 0xfb69
leaq -0x60(%rbp), %r15
leaq -0x268(%rbp), %rdx
movq %r15, %rdi
callq 0x4170
leaq -0x40(%rbp), %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0xcad3
leaq -0x268(%rbp), %rdi
leaq -0x40(%rbp), %rsi
pushq $0x4
popq %rdx
callq 0x4530
leaq -0x40(%rbp), %rdi
callq 0x41b0
movq -0x268(%rbp), %rax
movq -0x18(%rax), %rax
cmpl $0x0, -0x248(%rbp,%rax)
je 0xb29f
movq 0xad6a(%rip), %rdi      # 0x15fc0
leaq 0x4924(%rip), %rsi      # 0xfb81
callq 0x4370
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4300
movq %rax, %rdi
callq 0x41d0
leaq 0x4905(%rip), %rsi      # 0xfb81
movq %r14, %rdi
callq 0x4370
movq %rax, %rdi
movq %rbx, %rsi
callq 0x4300
movq %rax, %rdi
callq 0x41d0
xorl %r15d, %r15d
jmp 0xb347
leaq -0x268(%rbp), %rdi
pushq $0x2
popq %rdx
xorl %esi, %esi
callq 0x4440
leaq -0x268(%rbp), %rdi
callq 0x45b0
movq %rax, %r15
leaq -0x268(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x4440
movq %r15, %rdi
callq 0x4030
movq %rax, (%r12)
leaq -0x268(%rbp), %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x43e0
leaq -0x268(%rbp), %rdi
callq 0x40d0
leaq 0x48a1(%rip), %rsi      # 0xfba1
movq %r14, %rdi
callq 0x4370
movq %rax, %r14
leaq -0x40(%rbp), %rdi
leaq -0x60(%rbp), %rsi
movq %rbx, %rdx
callq 0xcad3
leaq -0x40(%rbp), %rsi
movq %r14, %rdi
callq 0x4300
leaq 0x487d(%rip), %rsi      # 0xfbab
movq %rax, %rdi
callq 0x4370
movq %rax, %rdi
callq 0x41d0
leaq -0x40(%rbp), %rdi
callq 0x41b0
leaq -0x268(%rbp), %rdi
callq 0x40f0
leaq -0x60(%rbp), %rdi
callq 0x41b0
movq %r15, %rax
addq $0x250, %rsp            # imm = 0x250
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0xb396
jmp 0xb396
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x41b0
jmp 0xb3a5
movq %rax, %rbx
jmp 0xb3a5
movq %rax, %rbx
leaq -0x40(%rbp), %rdi
callq 0x41b0
jmp 0xb399
jmp 0xb396
movq %rax, %rbx
leaq -0x268(%rbp), %rdi
callq 0x40f0
leaq -0x60(%rbp), %rdi
callq 0x41b0
movq %rbx, %rdi
callq 0x45d0
// File: /workspace/github_cpp_makefile_star2_O2/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 0xb706
cmpl %edi, %esi
setl %cl
cmpl %edx, %edi
setle %al
jmp 0xb724
testl %edi, %edi
setns %cl
cmpl %edx, %edi
setle %dl
movb $0x1, %al
testb %dl, %cl
jne 0xb726
cmpl %edi, %esi
setl %cl
cmpl $0x3e9, %edi            # imm = 0x3E9
setl %al
andb %cl, %al
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/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, %rbx
movq %rdi, %r14
leaq -0x1b8(%rbp), %rdi
callq 0x4260
movq %rbx, %rdi
callq 0xa8d8
leaq 0x228(%rbx), %r15
movq %r15, %rdi
callq 0x8608
movq %r14, -0x30(%rbp)
addq $0x210, %rbx            # imm = 0x210
leaq -0x1a8(%rbp), %r12
leaq 0x3ba4(%rip), %r13      # 0xf322
movq %rbx, %r14
movq (%r14), %r14
cmpq %rbx, %r14
je 0xb7b6
leaq 0x10(%r14), %rsi
movq %r12, %rdi
callq 0x4300
movq %rax, %rdi
movq %r13, %rsi
callq 0x4370
movl 0x30(%r14), %esi
movq %rax, %rdi
callq 0x45a0
movq %rax, %rdi
callq 0x41d0
jmp 0xb781
movq %r15, %rdi
callq 0x4290
leaq -0x1a0(%rbp), %rsi
movq -0x30(%rbp), %rbx
movq %rbx, %rdi
callq 0x4510
leaq -0x1b8(%rbp), %rdi
callq 0x4280
movq %rbx, %rax
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xb7f4
movq %rax, %rbx
leaq -0x1b8(%rbp), %rdi
callq 0x4280
movq %rbx, %rdi
callq 0x45d0
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 %r12
pushq %rbx
subq $0x50, %rsp
movq %rdi, %rbx
leaq -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x48(%rbp), %rdi
callq 0x4200
leaq -0x68(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x4450
leaq -0x68(%rbp), %r14
movq %r14, %rdi
callq 0x95d4
movl %eax, -0x28(%rbp)
movq %r14, %rdi
callq 0x41b0
leaq 0x268(%rbx), %r14
movq %r14, %rdi
callq 0x8608
leaq 0x250(%rbx), %rdi
leaq -0x48(%rbp), %rsi
callq 0xcb1c
movq 0x250(%rbx), %rdi
movq 0x258(%rbx), %rsi
callq 0xd020
movq 0x250(%rbx), %rdi
movq 0x258(%rbx), %rsi
leaq 0x298(%rbx), %rdx
callq 0xd72a
movq 0x250(%rbx), %rdi
movq 0x258(%rbx), %rsi
subq %rdi, %rax
pushq $0x28
popq %r12
cqto
idivq %r12
movl %eax, 0x290(%rbx)
leaq -0x48(%rbp), %rdx
callq 0xd72a
subq 0x250(%rbx), %rax
cqto
idivq %r12
movq %rax, %r15
movq %r14, %rdi
callq 0x4290
subl 0x290(%rbx), %r15d
jns 0xbbcb
movq 0x258(%rbx), %rax
subq 0x250(%rbx), %rax
cqto
idivq %r12
addl %eax, %r15d
incl %r15d
leaq -0x48(%rbp), %rdi
callq 0x41b0
movl %r15d, %eax
addq $0x50, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0xbbe8
jmp 0xbbe8
movq %rax, %rbx
leaq -0x48(%rbp), %rdi
callq 0x41b0
movq %rbx, %rdi
callq 0x45d0
// File: /workspace/github_cpp_makefile_star2_O2/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)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq -0x50(%rbp), %rdi
callq 0x4200
leaq -0x70(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x4450
leaq -0x70(%rbp), %r14
movq %r14, %rdi
callq 0x95d4
movl %eax, -0x30(%rbp)
movq %r14, %rdi
callq 0x41b0
leaq 0x268(%rbx), %r14
movq %r14, %rdi
callq 0x8608
movl 0x290(%rbx), %r13d
movq 0x250(%rbx), %rdi
movq 0x258(%rbx), %rsi
leaq -0x50(%rbp), %rdx
callq 0xd72a
leaq 0x250(%rbx), %r12
movq (%r12), %rcx
subq %rcx, %rax
pushq $0x28
popq %rsi
cqto
idivq %rsi
movq %rax, %r15
movslq %r15d, %rax
imulq $0x28, %rax, %rsi
addq %rcx, %rsi
movq %r12, %rdi
callq 0xcb58
cmpl %r13d, %r15d
jne 0xbcaf
pushq $-0x1
popq %rax
jmp 0xbcd5
movq 0x250(%rbx), %rdi
movq 0x258(%rbx), %rsi
leaq 0x298(%rbx), %rdx
callq 0xd72a
subq (%r12), %rax
cqto
pushq $0x28
popq %rcx
idivq %rcx
movl %eax, 0x290(%rbx)
movq %r14, %rdi
callq 0x4290
subl %r13d, %r15d
jns 0xbd04
movq 0x258(%rbx), %rax
subq 0x250(%rbx), %rax
cqto
pushq $0x28
popq %rcx
idivq %rcx
addl %eax, %r15d
incl %r15d
leaq -0x50(%rbp), %rdi
callq 0x41b0
movl %r15d, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0xbd25
jmp 0xbd25
jmp 0xbd25
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x41b0
movq %rbx, %rdi
callq 0x45d0
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 0x8608
xorl %ebx, %ebx
movq 0xa25c(%rip), %r15      # 0x15fc0
leaq 0x35b7(%rip), %r12      # 0xf322
xorl %r13d, %r13d
movq 0x250(%r14), %rsi
movq 0x258(%r14), %rax
subq %rsi, %rax
cqto
pushq $0x28
popq %rcx
idivq %rcx
cmpq %r13, %rax
jbe 0xbde9
addq %rbx, %rsi
movq %r15, %rdi
callq 0x4300
movq %rax, %rdi
movq %r12, %rsi
callq 0x4370
movq 0x250(%r14), %rcx
movl 0x20(%rcx,%rbx), %esi
movq %rax, %rdi
callq 0x45a0
movq 0x250(%r14), %rax
movl 0x20(%rax,%rbx), %eax
cmpl 0x2b8(%r14), %eax
jne 0xbdd8
movq %r15, %rdi
leaq 0x3f15(%rip), %rsi      # 0xfce8
callq 0x4370
movq %r15, %rdi
callq 0x41d0
incq %r13
addq $0x28, %rbx
jmp 0xbd6e
movq 0xa1d0(%rip), %rdi      # 0x15fc0
callq 0x41d0
movq -0x30(%rbp), %rdi
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x4290
// File: /workspace/github_cpp_makefile_star2_O2/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 %rbx
pushq %rax
movl %edx, %r8d
movq %rsi, %rax
movq %rdi, %rbx
movq 0x250(%rsi), %rsi
movq 0x258(%rax), %rax
subq %rsi, %rax
pushq $0x28
popq %rdi
cqto
idivq %rdi
addl %ecx, %r8d
subl %eax, %r8d
addl %eax, %r8d
js 0xc278
movslq %r8d, %rcx
movl %ecx, %r8d
subl %eax, %r8d
cmpq %rcx, %rax
jbe 0xc27d
imulq $0x28, %rcx, %rax
addq %rax, %rsi
movq %rbx, %rdi
callq 0xcb84
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/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 %rbx
pushq %rax
movl %edx, %r8d
movq %rsi, %rax
movq %rdi, %rbx
movq 0x250(%rsi), %rsi
movq 0x258(%rax), %rax
subq %rsi, %rax
pushq $0x28
popq %rdi
cqto
idivq %rdi
subl %r8d, %ecx
subl %eax, %ecx
addl %eax, %ecx
js 0xc2d1
movslq %ecx, %rdx
movl %edx, %ecx
subl %eax, %ecx
cmpq %rdx, %rax
jbe 0xc2d5
imulq $0x28, %rdx, %rax
addq %rax, %rsi
movq %rbx, %rdi
callq 0xcb84
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %rbp
retq
// File: /workspace/github_cpp_makefile_star2_O2/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 %r14
pushq %rbx
subq $0x30, %rsp
movq %rdi, %rbx
leaq -0x38(%rbp), %r14
movq %r14, %rdi
callq 0x8734
movq %rbx, %rdi
movq %r14, %rsi
callq 0xbbfc
leaq -0x38(%rbp), %rdi
callq 0x41b0
leaq 0x228(%rbx), %r14
movq %r14, %rdi
callq 0x8608
addq $0x210, %rbx            # imm = 0x210
movq %rbx, %rdi
callq 0xcba2
movq %r14, %rdi
callq 0x4290
movb $0x1, %al
addq $0x30, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq %rax, %rbx
leaq -0x38(%rbp), %rdi
callq 0x41b0
movq %rbx, %rdi
callq 0x45d0
nop
// File: /workspace/github_cpp_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
subq $0x198, %rsp            # imm = 0x198
movq %rsi, %rbx
movq %rdi, %r14
leaq 0x1f1d(%rip), %r15      # 0xf7ba
movq %r15, %rsi
xorl %edx, %edx
callq 0x4660
leaq 0x1a74(%rip), %r12      # 0xf322
pushq $0x1
popq %r13
movq %r14, %rdi
movq %rax, %rsi
movq %r13, %rdx
movq %r12, %rcx
callq 0x4220
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x4660
movq %r14, %rdi
movq %rax, %rsi
movq %r13, %rdx
movq %r12, %rcx
callq 0x4220
movq %r14, %rdi
movq %r15, %rsi
xorl %edx, %edx
callq 0x4660
movq %r14, %rdi
movq %rax, %rsi
movq %r13, %rdx
movq %r12, %rcx
callq 0x4220
leaq -0x1b8(%rbp), %r15
pushq $0x18
popq %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x4520
leaq -0x2c(%rbp), %rsi
movq %r15, %rdi
callq 0x4230
leaq -0x2c(%rbp), %rsi
movb (%rsi), %al
movb %al, (%rbx)
leaq -0x1b8(%rbp), %rdi
callq 0x4230
leaq -0x2c(%rbp), %rsi
movb (%rsi), %al
movb %al, 0x1(%rbx)
leaq -0x1b8(%rbp), %rdi
callq 0x4230
leaq -0x2c(%rbp), %rsi
movb (%rsi), %al
movb %al, 0x2(%rbx)
leaq -0x1b8(%rbp), %rdi
callq 0x4230
movb -0x2c(%rbp), %al
movb %al, 0x3(%rbx)
leaq -0x1b8(%rbp), %rdi
callq 0x4280
addq $0x198, %rsp            # imm = 0x198
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x1b8(%rbp), %rdi
callq 0x4280
movq %rbx, %rdi
callq 0x45d0
// File: /workspace/github_cpp_makefile_star2_O2/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 0x4260
leaq -0x190(%rbp), %r15
movzbl (%r14), %esi
movq %r15, %rdi
callq 0x4250
leaq 0x1de5(%rip), %rsi      # 0xf7ba
movq %rax, %rdi
callq 0x4370
movzbl 0x1(%r14), %esi
movq %r15, %rdi
callq 0x4250
leaq 0x1dc9(%rip), %rsi      # 0xf7ba
movq %rax, %rdi
callq 0x4370
movzbl 0x2(%r14), %esi
movq %r15, %rdi
callq 0x4250
leaq 0x1dad(%rip), %rsi      # 0xf7ba
movq %rax, %rdi
callq 0x4370
movzbl 0x3(%r14), %esi
movq %r15, %rdi
callq 0x4250
leaq -0x188(%rbp), %rsi
movq %rbx, %rdi
callq 0x4510
leaq -0x1a0(%rbp), %rdi
callq 0x4280
movq %rbx, %rax
addq $0x188, %rsp            # imm = 0x188
popq %rbx
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0x1a0(%rbp), %rdi
callq 0x4280
movq %rbx, %rdi
callq 0x45d0
// File: /workspace/github_cpp_makefile_star2_O2/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
leaq -0x30(%rbp), %r14
andq $0x0, (%r14)
movq %r14, %rdi
callq 0x4610
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
andq $0x0, 0x8(%rbx)
movb $0x0, 0x10(%rbx)
xorl %eax, %eax
pushq $0x2
popq %rdi
leaq -0x40(%rbp), %r12
pushq $0x10
popq %rcx
movq (%r14), %r14
testq %r14, %r14
je 0xdae8
movq 0x18(%r14), %rsi
testq %rsi, %rsi
je 0xdaa5
incl %eax
cmpl $0x4, %eax
jne 0xdaa5
addq $0x4, %rsi
movq %r12, %rdx
movl %ecx, %r15d
callq 0x4390
movq %rbx, %rdi
movq %r12, %r13
movq %r12, %rsi
callq 0x4620
pushq $0x4
popq %rax
pushq $0x2
popq %rdi
movl %r15d, %ecx
movq %r13, %r12
jmp 0xdaa5
movq -0x30(%rbp), %rdi
testq %rdi, %rdi
je 0xdaf6
callq 0x45c0
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
callq 0x41b0
movq %r14, %rdi
callq 0x45d0
// File: /workspace/github_cpp_makefile_star2_O2/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
pushq $0x2
popq %rdi
movl %edi, %esi
xorl %edx, %edx
callq 0x40e0
testl %eax, %eax
js 0xdb88
movl %eax, %ebx
leaq -0x20(%rbp), %rsi
andq $0x0, 0x8(%rsi)
movw $0x2, (%rsi)
andl $0x0, 0x4(%rsi)
rolw $0x8, %r14w
movw %r14w, 0x2(%rsi)
pushq $0x10
popq %rdx
movl %eax, %edi
callq 0x40a0
testl %eax, %eax
js 0xdb98
movl %ebx, %eax
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq 0x8431(%rip), %rdi      # 0x15fc0
leaq 0x21dc(%rip), %rsi      # 0xfd72
jmp 0xdba6
movq 0x8421(%rip), %rdi      # 0x15fc0
leaq 0x21df(%rip), %rsi      # 0xfd85
callq 0x4370
movq %rax, %rdi
callq 0x41d0
pushq $0x1
popq %rdi
callq 0x43c0
// File: /workspace/github_cpp_makefile_star2_O2/luisremis[P]SDFS/connections.cpp
// Function: receiveUDP(int, char*, unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>&)
int receiveUDP(int sockfd, char* buf, uint32_t len, std::string& sender)
{
    struct sockaddr addr;
    socklen_t fromlen = sizeof addr;

    int byte_count = recvfrom(sockfd, buf, len, 0, &addr, &fromlen);

    if (byte_count == -1)
    {
        printf("ERROR RECEIVING!!!\n");
        exit(-1);
    }

    struct sockaddr_in *sin = (struct sockaddr_in *) &addr;

    sender = inet_ntoa(sin->sin_addr);

    UDPreceived++;

    return byte_count;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r14
pushq %rbx
subq $0x20, %rsp
movq %rcx, %rbx
leaq -0x14(%rbp), %r9
movl $0x10, (%r9)
movl %edx, %edx
leaq -0x24(%rbp), %r8
xorl %ecx, %ecx
callq 0x42a0
movq %rax, %r14
cmpl $-0x1, %r14d
je 0xdc0f
movl -0x20(%rbp), %edi
callq 0x41a0
movq %rbx, %rdi
movq %rax, %rsi
callq 0x4620
incl 0x8969(%rip)            # 0x1656c
movl %r14d, %eax
addq $0x20, %rsp
popq %rbx
popq %r14
popq %rbp
retq
leaq 0x21e3(%rip), %rdi      # 0xfdf9
callq 0x44e0
pushq $-0x1
popq %rdi
callq 0x43c0
// File: /workspace/github_cpp_makefile_star2_O2/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 0x43b0
testq %rax, %rax
je 0xdcbf
leaq -0x34(%rbp), %r13
andl $0x0, 0x8(%r13)
andq $0x0, (%r13)
movw $0x2, -0x4(%r13)
movq 0x18(%rax), %rcx
movq (%rcx), %rsi
movslq 0x14(%rax), %rdx
movq %r13, %rdi
callq 0x42c0
rolw $0x8, %r12w
movw %r12w, -0x2(%r13)
movl %r15d, %edx
leaq -0x38(%rbp), %r8
pushq $0x10
popq %r9
movl %r14d, %edi
movq %rbx, %rsi
xorl %ecx, %ecx
callq 0x4060
cmpl $-0x1, %eax
jne 0xdcaa
leaq 0x2169(%rip), %rdi      # 0xfe0c
callq 0x44e0
jmp 0xdcb0
incl 0x88b8(%rip)            # 0x16568
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x82fa(%rip), %rdi      # 0x15fc0
leaq 0x20d1(%rip), %rsi      # 0xfd9e
callq 0x4370
movq %rax, %rdi
callq 0x41d0
pushq $0x1
popq %rdi
callq 0x43c0
// File: /workspace/github_cpp_makefile_star2_O2/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 %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x20, %rsp
movl %edi, %r14d
pushq $0x2
popq %r15
pushq $0x1
popq %r12
movl %r15d, %edi
movl %r12d, %esi
xorl %edx, %edx
callq 0x40e0
movl %eax, %ebx
leaq -0x24(%rbp), %rcx
movl $0x1, (%rcx)
pushq $0x4
popq %r8
movl %eax, %edi
movl %r12d, %esi
movl %r15d, %edx
callq 0x45e0
cmpl $-0x1, %eax
je 0xdd68
testl %ebx, %ebx
js 0xdd76
leaq -0x34(%rbp), %rsi
andq $0x0, 0x8(%rsi)
movw $0x2, (%rsi)
andl $0x0, 0x4(%rsi)
rolw $0x8, %r14w
movw %r14w, 0x2(%rsi)
pushq $0x10
popq %rdx
movl %ebx, %edi
callq 0x40a0
testl %eax, %eax
js 0xdd86
movl %ebx, %eax
addq $0x20, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
leaq 0x20bb(%rip), %rdi      # 0xfe2a
callq 0x44e0
jmp 0xdda1
movq 0x8243(%rip), %rdi      # 0x15fc0
leaq 0x1fee(%rip), %rsi      # 0xfd72
jmp 0xdd94
movq 0x8233(%rip), %rdi      # 0x15fc0
leaq 0x1ff1(%rip), %rsi      # 0xfd85
callq 0x4370
movq %rax, %rdi
callq 0x41d0
pushq $0x1
popq %rdi
callq 0x43c0
// File: /workspace/github_cpp_makefile_star2_O2/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
pushq $0x5
popq %rsi
callq 0x43a0
leaq -0xc(%rbp), %rdx
movl $0x10, (%rdx)
leaq -0x1c(%rbp), %rsi
movl %ebx, %edi
callq 0x4140
testl %eax, %eax
js 0xdddc
addq $0x18, %rsp
popq %rbx
popq %rbp
retq
movq 0x81dd(%rip), %rdi      # 0x15fc0
leaq 0x1fc8(%rip), %rsi      # 0xfdb2
callq 0x4370
movq %rax, %rdi
callq 0x41d0
pushq $0x1
popq %rdi
callq 0x43c0
// File: /workspace/github_cpp_makefile_star2_O2/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 %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %esi, %r14d
leal -0x10000(%r14), %eax
cmpl $0xffff07cf, %eax       # imm = 0xFFFF07CF
jbe 0xdec0
movq %rdx, %rbx
movq %rdi, %r15
pushq $0x2
popq %r12
pushq $0x1
popq %r13
movl %r12d, %edi
movl %r13d, %esi
xorl %edx, %edx
callq 0x40e0
movl %eax, (%rbx)
leaq -0x2c(%rbp), %rcx
movl $0x1, (%rcx)
pushq $0x4
popq %r8
movl %eax, %edi
movl %r13d, %esi
movl %r12d, %edx
callq 0x45e0
cmpl $0x0, (%rbx)
js 0xded0
movq %r15, %rdi
callq 0x43b0
testq %rax, %rax
je 0xdee0
leaq -0x38(%rbp), %r15
andl $0x0, 0x8(%r15)
andq $0x0, (%r15)
movw $0x2, -0x4(%r15)
movq 0x18(%rax), %rcx
movq (%rcx), %rsi
movslq 0x14(%rax), %rdx
movq %r15, %rdi
callq 0x42c0
rolw $0x8, %r14w
movw %r14w, -0x2(%r15)
movl (%rbx), %edi
leaq -0x3c(%rbp), %rsi
pushq $0x10
popq %rdx
callq 0x42d0
sarl $0x1f, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x80f9(%rip), %rdi      # 0x15fc0
leaq 0x1efd(%rip), %rsi      # 0xfdcb
jmp 0xdeee
movq 0x80e9(%rip), %rdi      # 0x15fc0
leaq 0x1e94(%rip), %rsi      # 0xfd72
jmp 0xdeee
movq 0x80d9(%rip), %rdi      # 0x15fc0
leaq 0x1eb0(%rip), %rsi      # 0xfd9e
callq 0x4370
movq %rax, %rdi
callq 0x41d0
pushq $0x1
popq %rdi
callq 0x43c0
// File: /workspace/github_cpp_makefile_star2_O2/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
movl %edx, %r14d
movq %rsi, %r15
movl %edi, %r12d
movl %edx, %r13d
xorl %ebx, %ebx
cmpl %r14d, %ebx
jge 0xdf4b
movl %r12d, %edi
movq %r15, %rsi
movq %r13, %rdx
callq 0x4490
testl %eax, %eax
jle 0xdf45
movl %eax, %ecx
andl $0x7fffffff, %ecx       # imm = 0x7FFFFFFF
addq %rcx, %r15
addl %eax, %ebx
jmp 0xdf1f
pushq $-0xa
popq %rax
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_O2/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
movl %edx, %ebx
movq %rsi, %r14
movl %edi, %r15d
movl %edx, %r12d
xorl %r13d, %r13d
cmpl %ebx, %r13d
jge 0xdfae
movl %r15d, %edi
movq %r14, %rsi
movq %r12, %rdx
callq 0x4150
testl %eax, %eax
jg 0xdfa1
movl %r13d, %eax
pushq $-0x1
popq %rcx
cmovsl %ecx, %eax
js 0xdfb1
cmpl %ebx, %r13d
jl 0xdf7d
jmp 0xdfb1
addl %eax, %r13d
andl $0x7fffffff, %eax       # imm = 0x7FFFFFFF
addq %rax, %r14
jmp 0xdf78
movl %r13d, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq