// File: supragya[P]DirectorySync/DirectorySync.cpp
// Function: main
int main( int argc, char **argv)
{
    if(argc != 5){
        std::cout<<"[MAIN] Usage: <programexec> <FolderName> <droid_IP> <SendPORT> <RecvPORT>"<<std::endl;
        exit(-1);
    }
    std::cout<<"    __________________________________________"<<std::endl;
    std::cout<<"  /_________________________________________ |"<<std::endl;
    std::cout<<" /----------------------------------------+ ||"<<std::endl;
    std::cout<<"|                                         | ||"<<std::endl;
    std::cout<<"|              DIRECTORY SYNC             | |+"<<std::endl;
    std::cout<<"|                                         |-+"<<std::endl;
    std::cout<<"+-----------------------------------------+"<<std::endl;

    std::cout<<"[MAIN] Setting up connections "<<std::endl;
    std::thread RConnect(set_reader_connection, atoi(argv[4]), argv[2]);
    std::thread FConnect(set_filewatcher_connection, atoi(argv[3]), argv[2]);
    RConnect.join();
    FConnect.join();
    std::cout<<"[MAIN] Connections setup!"<<std::endl;
    char empty[] = "";
    std::thread listener(reader, argv[1], RCsock);
    std::thread watcher(filewatcher, argv[1], empty, FCsock);
    std::thread closer(closeallsystems);
    listener.join();
    watcher.join();
    closer.join();
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x5, -0x8(%rbp)
je 0x2548
movq 0x8aad(%rip), %rdi      # 0xafd0
leaq 0x4ada(%rip), %rsi      # 0x7004
callq 0x21d0
movq %rax, %rdi
movq 0x8a7f(%rip), %rsi      # 0xafb8
callq 0x21f0
movl $0xffffffff, %edi       # imm = 0xFFFFFFFF
callq 0x2230
movq 0x8a81(%rip), %rdi      # 0xafd0
movq %rdi, -0x68(%rbp)
leaq 0x4af4(%rip), %rsi      # 0x704e
callq 0x21d0
movq %rax, %rdi
movq 0x8a4f(%rip), %rsi      # 0xafb8
movq %rsi, -0x60(%rbp)
callq 0x21f0
movq -0x68(%rbp), %rdi
leaq 0x4b00(%rip), %rsi      # 0x707d
callq 0x21d0
movq -0x60(%rbp), %rsi
movq %rax, %rdi
callq 0x21f0
movq -0x68(%rbp), %rdi
leaq 0x4b13(%rip), %rsi      # 0x70ac
callq 0x21d0
movq -0x60(%rbp), %rsi
movq %rax, %rdi
callq 0x21f0
movq -0x68(%rbp), %rdi
leaq 0x4b26(%rip), %rsi      # 0x70db
callq 0x21d0
movq -0x60(%rbp), %rsi
movq %rax, %rdi
callq 0x21f0
movq -0x68(%rbp), %rdi
leaq 0x4b39(%rip), %rsi      # 0x710a
callq 0x21d0
movq -0x60(%rbp), %rsi
movq %rax, %rdi
callq 0x21f0
movq -0x68(%rbp), %rdi
leaq 0x4b4c(%rip), %rsi      # 0x7139
callq 0x21d0
movq -0x60(%rbp), %rsi
movq %rax, %rdi
callq 0x21f0
movq -0x68(%rbp), %rdi
leaq 0x4b5e(%rip), %rsi      # 0x7167
callq 0x21d0
movq -0x60(%rbp), %rsi
movq %rax, %rdi
callq 0x21f0
movq -0x68(%rbp), %rdi
leaq 0x4b6e(%rip), %rsi      # 0x7193
callq 0x21d0
movq -0x60(%rbp), %rsi
movq %rax, %rdi
callq 0x21f0
movq -0x10(%rbp), %rax
movq 0x20(%rax), %rdi
callq 0x22f0
movl %eax, -0x1c(%rbp)
movq -0x10(%rbp), %rcx
addq $0x10, %rcx
leaq 0x1bb(%rip), %rsi       # 0x2810
leaq -0x18(%rbp), %rdi
leaq -0x1c(%rbp), %rdx
callq 0x49c0
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x22f0
movl %eax, -0x2c(%rbp)
movq -0x10(%rbp), %rcx
addq $0x10, %rcx
leaq 0x38f(%rip), %rsi       # 0x2a10
leaq -0x28(%rbp), %rdi
leaq -0x2c(%rbp), %rdx
callq 0x49c0
jmp 0x2690
leaq -0x18(%rbp), %rdi
callq 0x2300
jmp 0x269b
leaq -0x28(%rbp), %rdi
callq 0x2300
jmp 0x26a6
movq 0x8923(%rip), %rdi      # 0xafd0
leaq 0x4afe(%rip), %rsi      # 0x71b2
callq 0x21d0
movq %rax, -0x70(%rbp)
jmp 0x26bf
movq -0x70(%rbp), %rdi
movq 0x88ee(%rip), %rsi      # 0xafb8
callq 0x21f0
jmp 0x26d1
movb $0x0, -0x3d(%rbp)
movq -0x10(%rbp), %rdx
addq $0x8, %rdx
leaq 0x48c(%rip), %rsi       # 0x2b70
leaq 0x21bc9(%rip), %rcx     # 0x242b4
leaq -0x48(%rbp), %rdi
callq 0x4a80
jmp 0x26f6
movq -0x10(%rbp), %rdx
addq $0x8, %rdx
leaq 0xfbb(%rip), %rsi       # 0x36c0
leaq 0x21ba4(%rip), %r8      # 0x242b0
leaq -0x50(%rbp), %rdi
leaq -0x3d(%rbp), %rcx
callq 0x4b40
jmp 0x271b
leaq 0x1e0e(%rip), %rsi      # 0x4530
leaq -0x58(%rbp), %rdi
callq 0x4c10
jmp 0x272d
leaq -0x48(%rbp), %rdi
callq 0x2300
jmp 0x2738
leaq -0x50(%rbp), %rdi
callq 0x2300
jmp 0x2743
leaq -0x58(%rbp), %rdi
callq 0x2300
jmp 0x274e
movl $0x0, -0x4(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x4cc0
leaq -0x50(%rbp), %rdi
callq 0x4cc0
leaq -0x48(%rbp), %rdi
callq 0x4cc0
leaq -0x28(%rbp), %rdi
callq 0x4cc0
leaq -0x18(%rbp), %rdi
callq 0x4cc0
movl -0x4(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x27f3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x27ea
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x27e1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x27d8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x4cc0
leaq -0x50(%rbp), %rdi
callq 0x4cc0
leaq -0x48(%rbp), %rdi
callq 0x4cc0
leaq -0x28(%rbp), %rdi
callq 0x4cc0
leaq -0x18(%rbp), %rdi
callq 0x4cc0
movq -0x38(%rbp), %rdi
callq 0x2340
nopw %cs:(%rax,%rax)