// File: luisremis[P]SDFS/FileSystem.cpp
// Function: FileSystem::myJoinFinished()
bool FileSystem::myJoinFinished( ){
    
    virtualRingLock.lock();

    int minKey, maxKey;
    bool success;

    VirtualNode target = nNodeLater(3, myPosition);
    if(target != myself ){
        minKey = nNodeBefore(1, myPosition).key;
        maxKey = nNodeBefore(0, myPosition).key;
        success = pullFileFromRange(  target.ip_str, minKey, maxKey, true);
        // cout<<success<<" pull key from "<<minKey<<" to "<<maxKey<<" from "<<target.ip_str<<" "<<target.key<<endl;
        logFile<<success<<" myJoinFinished pull key from "<<minKey<<" to "<<maxKey<<" from "<<target.ip_str<<" "<<target.key<<endl;
    }
    
    target = nNodeLater(2, myPosition);
    if(target != myself ){
        minKey = nNodeBefore(2, myPosition).key;
        maxKey = nNodeBefore(1, myPosition).key;
        success = pullFileFromRange(  target.ip_str, minKey, maxKey, true);
        // cout<<success<<" pull key from "<<minKey<<" to "<<maxKey<<" from "<<target.ip_str<<" "<<target.key<<endl;
        logFile<<success<<" myJoinFinished pull key from "<<minKey<<" to "<<maxKey<<" from "<<target.ip_str<<" "<<target.key<<endl;
    }

    target = nNodeLater(1, myPosition);
    if(target != myself ){
        minKey = nNodeBefore(3, myPosition).key;
        maxKey = nNodeBefore(2, myPosition).key;
        success = pullFileFromRange(  target.ip_str, minKey, maxKey, true);
        // cout<<success<<" pull key from "<<minKey<<" to "<<maxKey<<" from "<<target.ip_str<<" "<<target.key<<endl;
        logFile<<success<<" myJoinFinished pull key from "<<minKey<<" to "<<maxKey<<" from "<<target.ip_str<<" "<<target.key<<endl;
    }

    virtualRingLock.unlock();

    return success;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2f0, %rsp            # imm = 0x2F0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x1f8(%rbp)
addq $0x268, %rdi            # imm = 0x268
callq 0xb5f0
movq -0x1f8(%rbp), %rsi
movl 0x290(%rsi), %ecx
leaq -0x40(%rbp), %rdi
movl $0x3, %edx
callq 0x155e0
movq -0x1f8(%rbp), %rsi
addq $0x298, %rsi            # imm = 0x298
leaq -0x40(%rbp), %rdi
callq 0x14490
testb $0x1, %al
jne 0x14f41
jmp 0x1511e
movq -0x1f8(%rbp), %rsi
movl 0x290(%rsi), %ecx
leaq -0x68(%rbp), %rdi
movl $0x1, %edx
callq 0x156b0
jmp 0x14f5e
movl -0x48(%rbp), %eax
movl %eax, -0xc(%rbp)
leaq -0x68(%rbp), %rdi
callq 0x163d0
movq -0x1f8(%rbp), %rsi
movl 0x290(%rsi), %ecx
leaq -0xa0(%rbp), %rdi
xorl %edx, %edx
callq 0x156b0
jmp 0x14f8a
movl -0x80(%rbp), %eax
movl %eax, -0x10(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x163d0
leaq -0xc0(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x41e0
jmp 0x14fae
movq -0x1f8(%rbp), %rdi
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
leaq -0xc0(%rbp), %rsi
movl $0x1, %r8d
callq 0x144c0
movb %al, -0x1f9(%rbp)
jmp 0x14fd5
movb -0x1f9(%rbp), %al
andb $0x1, %al
movb %al, -0x11(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x42a0
movq -0x1f8(%rbp), %rdi
movzbl -0x11(%rbp), %esi
andl $0x1, %esi
callq 0x46c0
movq %rax, -0x208(%rbp)
jmp 0x15008
movq -0x208(%rbp), %rdi
leaq 0x7ce7(%rip), %rsi      # 0x1ccfd
callq 0x43f0
movq %rax, -0x210(%rbp)
jmp 0x15024
movq -0x210(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x4670
movq %rax, -0x218(%rbp)
jmp 0x1503c
movq -0x218(%rbp), %rdi
leaq 0x7742(%rip), %rsi      # 0x1c78c
callq 0x43f0
movq %rax, -0x220(%rbp)
jmp 0x15058
movq -0x220(%rbp), %rdi
movl -0x10(%rbp), %esi
callq 0x4670
movq %rax, -0x228(%rbp)
jmp 0x15070
movq -0x228(%rbp), %rdi
leaq 0x7c97(%rip), %rsi      # 0x1cd15
callq 0x43f0
movq %rax, -0x230(%rbp)
jmp 0x1508c
movq -0x230(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x4370
movq %rax, -0x238(%rbp)
jmp 0x150a5
movq -0x238(%rbp), %rdi
leaq 0x726f(%rip), %rsi      # 0x1c322
callq 0x43f0
movq %rax, -0x240(%rbp)
jmp 0x150c1
movq -0x240(%rbp), %rdi
movl -0x20(%rbp), %esi
callq 0x4670
movq %rax, -0x248(%rbp)
jmp 0x150d9
movq -0x248(%rbp), %rdi
movq 0x11ec1(%rip), %rsi     # 0x26fa8
callq 0x4410
jmp 0x150ee
jmp 0x1511e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
jmp 0x155c1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0xc0(%rbp), %rdi
callq 0x42a0
jmp 0x155c1
movq -0x1f8(%rbp), %rsi
movl 0x290(%rsi), %ecx
leaq -0xe8(%rbp), %rdi
movl $0x2, %edx
callq 0x155e0
jmp 0x1513e
leaq -0x40(%rbp), %rdi
leaq -0xe8(%rbp), %rsi
callq 0x16ba0
leaq -0xe8(%rbp), %rdi
callq 0x163d0
movq -0x1f8(%rbp), %rsi
addq $0x298, %rsi            # imm = 0x298
leaq -0x40(%rbp), %rdi
callq 0x14490
testb $0x1, %al
jne 0x1517a
jmp 0x15355
movq -0x1f8(%rbp), %rsi
movl 0x290(%rsi), %ecx
leaq -0x110(%rbp), %rdi
movl $0x2, %edx
callq 0x156b0
jmp 0x1519a
movl -0xf0(%rbp), %eax
movl %eax, -0xc(%rbp)
leaq -0x110(%rbp), %rdi
callq 0x163d0
movq -0x1f8(%rbp), %rsi
movl 0x290(%rsi), %ecx
leaq -0x138(%rbp), %rdi
movl $0x1, %edx
callq 0x156b0
jmp 0x151cf
movl -0x118(%rbp), %eax
movl %eax, -0x10(%rbp)
leaq -0x138(%rbp), %rdi
callq 0x163d0
leaq -0x158(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x41e0
jmp 0x151f6
movq -0x1f8(%rbp), %rdi
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
leaq -0x158(%rbp), %rsi
movl $0x1, %r8d
callq 0x144c0
movb %al, -0x249(%rbp)
jmp 0x1521d
movb -0x249(%rbp), %al
andb $0x1, %al
movb %al, -0x11(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x42a0
movq -0x1f8(%rbp), %rdi
movzbl -0x11(%rbp), %esi
andl $0x1, %esi
callq 0x46c0
movq %rax, -0x258(%rbp)
jmp 0x15250
movq -0x258(%rbp), %rdi
leaq 0x7a9f(%rip), %rsi      # 0x1ccfd
callq 0x43f0
movq %rax, -0x260(%rbp)
jmp 0x1526c
movq -0x260(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x4670
movq %rax, -0x268(%rbp)
jmp 0x15284
movq -0x268(%rbp), %rdi
leaq 0x74fa(%rip), %rsi      # 0x1c78c
callq 0x43f0
movq %rax, -0x270(%rbp)
jmp 0x152a0
movq -0x270(%rbp), %rdi
movl -0x10(%rbp), %esi
callq 0x4670
movq %rax, -0x278(%rbp)
jmp 0x152b8
movq -0x278(%rbp), %rdi
leaq 0x7a4f(%rip), %rsi      # 0x1cd15
callq 0x43f0
movq %rax, -0x280(%rbp)
jmp 0x152d4
movq -0x280(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x4370
movq %rax, -0x288(%rbp)
jmp 0x152ed
movq -0x288(%rbp), %rdi
leaq 0x7027(%rip), %rsi      # 0x1c322
callq 0x43f0
movq %rax, -0x290(%rbp)
jmp 0x15309
movq -0x290(%rbp), %rdi
movl -0x20(%rbp), %esi
callq 0x4670
movq %rax, -0x298(%rbp)
jmp 0x15321
movq -0x298(%rbp), %rdi
movq 0x11c79(%rip), %rsi     # 0x26fa8
callq 0x4410
jmp 0x15336
jmp 0x15355
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x42a0
jmp 0x155c1
movq -0x1f8(%rbp), %rsi
movl 0x290(%rsi), %ecx
leaq -0x180(%rbp), %rdi
movl $0x1, %edx
callq 0x155e0
jmp 0x15375
leaq -0x40(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0x16ba0
leaq -0x180(%rbp), %rdi
callq 0x163d0
movq -0x1f8(%rbp), %rsi
addq $0x298, %rsi            # imm = 0x298
leaq -0x40(%rbp), %rdi
callq 0x14490
testb $0x1, %al
jne 0x153b1
jmp 0x15589
movq -0x1f8(%rbp), %rsi
movl 0x290(%rsi), %ecx
leaq -0x1a8(%rbp), %rdi
movl $0x3, %edx
callq 0x156b0
jmp 0x153d1
movl -0x188(%rbp), %eax
movl %eax, -0xc(%rbp)
leaq -0x1a8(%rbp), %rdi
callq 0x163d0
movq -0x1f8(%rbp), %rsi
movl 0x290(%rsi), %ecx
leaq -0x1d0(%rbp), %rdi
movl $0x2, %edx
callq 0x156b0
jmp 0x15406
movl -0x1b0(%rbp), %eax
movl %eax, -0x10(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0x163d0
leaq -0x1f0(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x41e0
jmp 0x1542d
movq -0x1f8(%rbp), %rdi
movl -0xc(%rbp), %edx
movl -0x10(%rbp), %ecx
leaq -0x1f0(%rbp), %rsi
movl $0x1, %r8d
callq 0x144c0
movb %al, -0x299(%rbp)
jmp 0x15454
movb -0x299(%rbp), %al
andb $0x1, %al
movb %al, -0x11(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x42a0
movq -0x1f8(%rbp), %rdi
movzbl -0x11(%rbp), %esi
andl $0x1, %esi
callq 0x46c0
movq %rax, -0x2a8(%rbp)
jmp 0x15487
movq -0x2a8(%rbp), %rdi
leaq 0x7868(%rip), %rsi      # 0x1ccfd
callq 0x43f0
movq %rax, -0x2b0(%rbp)
jmp 0x154a3
movq -0x2b0(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0x4670
movq %rax, -0x2b8(%rbp)
jmp 0x154bb
movq -0x2b8(%rbp), %rdi
leaq 0x72c3(%rip), %rsi      # 0x1c78c
callq 0x43f0
movq %rax, -0x2c0(%rbp)
jmp 0x154d7
movq -0x2c0(%rbp), %rdi
movl -0x10(%rbp), %esi
callq 0x4670
movq %rax, -0x2c8(%rbp)
jmp 0x154ef
movq -0x2c8(%rbp), %rdi
leaq 0x7818(%rip), %rsi      # 0x1cd15
callq 0x43f0
movq %rax, -0x2d0(%rbp)
jmp 0x1550b
movq -0x2d0(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x4370
movq %rax, -0x2d8(%rbp)
jmp 0x15524
movq -0x2d8(%rbp), %rdi
leaq 0x6df0(%rip), %rsi      # 0x1c322
callq 0x43f0
movq %rax, -0x2e0(%rbp)
jmp 0x15540
movq -0x2e0(%rbp), %rdi
movl -0x20(%rbp), %esi
callq 0x4670
movq %rax, -0x2e8(%rbp)
jmp 0x15558
movq -0x2e8(%rbp), %rdi
movq 0x11a42(%rip), %rsi     # 0x26fa8
callq 0x4410
jmp 0x1556d
jmp 0x15589
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x70(%rbp)
movl %eax, -0x74(%rbp)
leaq -0x1f0(%rbp), %rdi
callq 0x42a0
jmp 0x155c1
movq -0x1f8(%rbp), %rdi
addq $0x268, %rdi            # imm = 0x268
callq 0xb620
jmp 0x1559e
movb -0x11(%rbp), %al
movb %al, -0x2e9(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x163d0
movb -0x2e9(%rbp), %al
andb $0x1, %al
addq $0x2f0, %rsp            # imm = 0x2F0
popq %rbp
retq
leaq -0x40(%rbp), %rdi
callq 0x163d0
movq -0x70(%rbp), %rdi
callq 0x46a0
nopw %cs:(%rax,%rax)