// File: /workspace/github_cpp_makefile_star2_O1/supragya[P]DirectorySync/DirectorySync.cpp
// Function: filewatcher(char*, char*, int)
void filewatcher(char *dirname, char *intermediate, int sock) {

    std::cout << "#### Began thread [FILEWATCHER]"<<std::endl;


    // Initialise FileWatcher
    int fd, wd;
    char workCMD[WORKCMDLEN];

    strcpy(workCMD, dirname);
    if(strlen(intermediate) > 0)
        strcat(workCMD, "/");
    strcat(workCMD, intermediate);

    fd = inotify_init();
    if ( fd < 0 ) {
        std::cout<<"[FW: inotify] Could not initialise inotify, quitting"<<std::endl;
        exit(1);
    }
    wd = inotify_add_watch(fd, workCMD, IN_CREATE | IN_MODIFY | IN_DELETE);
    if (wd == -1){
        std::cout<<"[FW: inotify] Could not add watch to ["<<workCMD<<"], quitting\n";
        exit(1);
    }
    else
        std::cout<<"[FW: inotify] Started watching ["<<workCMD<<"]"<<std::endl;


    // Actual FileWatch system
    char *FWINBuffer[INOTIFYBUFLEN];
    int length;
    while(1) {
        int i = 0;
        length = read(fd, FWINBuffer, INOTIFYBUFLEN);
        if (length < 0)
            std::cout << "[FILEWATCHER] Read Error \n";
        while (i < length) {
            struct inotify_event *event = (struct inotify_event *) &FWINBuffer[i];
            if (event->len) {
                if (event->mask & IN_CREATE) {
                    if (event->mask & IN_ISDIR) {
                        strcpy(workCMD, intermediate);
                        if(strlen(intermediate) > 0)
                            strcat(workCMD, "/");
                        strcat(workCMD, event->name);
                        std::cout << "[FW: inotify]\tCreated\tDIR\t" << workCMD << std::endl;
                        message *message_packet = FormMessage(workCMD, CREATE, DIRECTORY, 0);
                        if (!Transactions.is_recorded(*message_packet)) {
                            int sent = send(sock, message_packet, sizeof(message), 0);
                            std::cout << "[FW: inotify]\tSent request to create [" << event->name << "] Directory"
                                      << std::endl;

                            char *newintermediate = (char *)malloc(sizeof(char)*MAXFILENAMELEN);
                            strcpy(newintermediate, workCMD);
                            std::thread currentfilewatcher(filewatcher, dirname, intermediate, sock);
                            std::thread newfilewatcher(filewatcher, dirname, newintermediate, sock);
                            currentfilewatcher.join();
                            newfilewatcher.join();

                        } else {
                            std::cout << "[FW: inotify]\tDirectory [" << event->name
                                      << "]  created due to incoming request, skip request send" << std::endl;
                        }

                        free(message_packet);
                    }
                    else {
                        strcpy(workCMD, intermediate);
                        if(strlen(intermediate) > 0)
                            strcat(workCMD, "/");
                        strcat(workCMD, event->name);
                        std::cout << "[FW: inotify]\tCreated\tFIL\t" << workCMD << std::endl;
                        message *message_packet = FormMessage(workCMD, CREATE, _FILE, 0);

                        if (!Transactions.is_recorded(*message_packet)) {
                            int sent = send(sock, message_packet, sizeof(message), 0);
                            std::cout << "[FW: inotify]\tSent request to create [" << workCMD << "] file"
                                      << std::endl;
                        } else {
                            std::cout << "[FW: inotify]\tFile [" << event->name
                                      << "]  created due to incoming request, skip request send" << std::endl;
                        }

                        free(message_packet);
                    }
                }
                else if (event->mask & IN_MODIFY) {
                    if(!(event->mask & IN_ISDIR)){


                        FileAccess.lock();
                        strcpy(workCMD, dirname);
                        strcat(workCMD, "/");
                        strcat(workCMD, intermediate);
                        if(strlen(intermediate) > 0)
                            strcat(workCMD, "/");
                        strcat(workCMD, event->name);
                        std::ifstream file(workCMD, std::ios::binary);
                        file.seekg(0, file.end);
                        std::cout << "[FW: inotify]\tModified\tFIL\t" << workCMD << std::endl;
                        unsigned int filesize = file.tellg();
                        file.close();
                        FileAccess.unlock();
                        strcpy(workCMD, intermediate);
                        if(strlen(intermediate) > 0)
                            strcat(workCMD, "/");
                        strcat(workCMD, event->name);
                        message *message_packet = FormMessage(workCMD, MODIFY, _FILE, filesize);

                        if(!Transactions.is_recorded(*message_packet)){
                            int sent = send(sock, message_packet, sizeof(message), 0);

                            FileAccess.lock();
                            strcpy(workCMD, dirname);
                            strcat(workCMD, "/");
                            strcat(workCMD, intermediate);
                            if(strlen(intermediate) > 0)
                                strcat(workCMD, "/");
                            strcat(workCMD, event->name);
                            std::cout << "[FW: inotify]\tSent request to modify [" << workCMD << "] filesize = "<< filesize
                                      << std::endl;
                            file.open(workCMD, std::ios::binary);
                            file.seekg(0, file.beg);
                            char *filedata = (char*)malloc(filesize);
                            file.read(filedata, filesize);
                            FileAccess.unlock();
                            send(sock, filedata, filesize, 0);
                            free(filedata);

                        }else{
                            std::cout << "[FW: inotify]\tFile [" << workCMD
                                      << "]  modified due to incoming request, skip request send" << std::endl;
                        }
                    }
                }
                else if (event->mask & IN_DELETE) {
                    if (event->mask & IN_ISDIR) {
                        strcpy(workCMD, intermediate);
                        if(strlen(intermediate) > 0)
                            strcat(workCMD, "/");
                        strcat(workCMD, event->name);
                        std::cout << "[FW: inotify]\tDeleted\tDIR\t" << workCMD << std::endl;
                        message *message_packet = FormMessage(workCMD, DELETE, DIRECTORY, 0);
                        if (!Transactions.is_recorded(*message_packet)) {
                            int sent = send(sock, message_packet, sizeof(message), 0);
                            std::cout << "[FW: inotify]\tSent request to delete [" << workCMD << "] Directory"
                                      << std::endl;
                        } else {
                            std::cout << "[FW: inotify]\tDirectory [" << event->name
                                      << "]  deleted due to incoming request, skip request send" << std::endl;
                        }

                        free(message_packet);
                    }
                    else {
                        strcpy(workCMD, intermediate);
                        if(strlen(intermediate) > 0)
                            strcat(workCMD, "/");
                        strcat(workCMD, event->name);
                        std::cout << "[FW: inotify]\tDeleted\tFIL\t" << workCMD << std::endl;
                        message *message_packet = FormMessage(workCMD, DELETE, _FILE, 0);

                        if (!Transactions.is_recorded(*message_packet)) {
                            int sent = send(sock, message_packet, sizeof(message), 0);
                            std::cout << "[FW: inotify]\tSent request to delete [" << workCMD << "] file"
                                      << std::endl;
                        } else {
                            std::cout << "[FW: inotify]\tFile [" << event->name
                                      << "]  delete due to incoming request, skip request send" << std::endl;
                        }

                        free(message_packet);
                    }
                }
            }
            i += EVENT_SIZE + event->len;
        }
    }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4ca8, %rsp           # imm = 0x4CA8
movq %rdi, -0x50(%rbp)
movq %rsi, -0x40(%rbp)
movl %edx, -0x2c(%rbp)
movq 0x5229(%rip), %rbx      # 0x7fd0
leaq 0x29d0(%rip), %rsi      # 0x577e
movl $0x1f, %edx
movq %rbx, %rdi
callq 0x21e0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movq -0x50(%rbp), %rsi
leaq -0x2990(%rbp), %rdi
callq 0x2180
movq -0x40(%rbp), %r14
cmpb $0x0, (%r14)
je 0x2e12
leaq -0x2990(%rbp), %rdi
callq 0x20b0
movw $0x2f, -0x2990(%rbp,%rax)
leaq -0x2990(%rbp), %rdi
movq %r14, %rsi
callq 0x2300
callq 0x2320
testl %eax, %eax
js 0x3a17
leaq -0x2990(%rbp), %rsi
movl %eax, -0x5c(%rbp)
movl %eax, %edi
movl $0x302, %edx            # imm = 0x302
callq 0x20f0
cmpl $-0x1, %eax
je 0x3a34
leaq 0x29b3(%rip), %rsi      # 0x5807
movl $0x20, %edx
movq %rbx, %rdi
callq 0x21e0
leaq -0x2990(%rbp), %r12
movq %r12, %rdi
callq 0x20b0
movq %rbx, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x21e0
leaq 0x2917(%rip), %rsi      # 0x579c
movl $0x1, %edx
movq %rbx, %rdi
callq 0x21e0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movl $0x3e8, %edx            # imm = 0x3E8
movl -0x5c(%rbp), %edi
leaq -0x48d0(%rbp), %rsi
callq 0x2260
movq %rax, %r14
testl %r14d, %r14d
jns 0x2eed
movl $0x1a, %edx
movq 0x50ef(%rip), %rdi      # 0x7fd0
leaq 0x2940(%rip), %rsi      # 0x5828
callq 0x21e0
testl %r14d, %r14d
jle 0x2eb9
xorl %ebx, %ebx
movq %r14, -0x48(%rbp)
movslq %ebx, %rax
leaq -0x48d0(,%rax,8), %r13
addq %rbp, %r13
cmpl $0x0, 0xc(%r13)
je 0x36d8
movl 0x4(%r13), %r15d
btl $0x8, %r15d
jb 0x306f
testb $0x2, %r15b
jne 0x31a9
btl $0x9, %r15d
jae 0x36d8
movq -0x40(%rbp), %r14
movq %r12, %rdi
movq %r14, %rsi
callq 0x2180
btl $0x1e, %r15d
movb (%r14), %al
movq %r13, -0x38(%rbp)
jb 0x36ef
testb %al, %al
movq 0x5071(%rip), %r15      # 0x7fd0
je 0x2f73
movq %r12, %rdi
callq 0x20b0
movw $0x2f, -0x2990(%rbp,%rax)
addq $0x10, %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x2300
movl $0x1a, %edx
movq %r15, %rdi
leaq 0x2a87(%rip), %rsi      # 0x5a18
callq 0x21e0
movq %r12, %rdi
callq 0x20b0
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x21e0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movl $0x400, %edi            # imm = 0x400
callq 0x2230
movq %rax, %r14
leaq 0x4(%rax), %rdi
movq %r12, %rsi
callq 0x2180
movabsq $0x100000002, %rax      # imm = 0x100000002
movq %rax, 0x3ec(%r14)
movq $0x0, 0x3f8(%r14)
movl $0x1, (%r14)
movl $0x80, %ecx
movq %rsp, %rdi
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x51ac(%rip), %rdi      # 0x81d0
callq 0x40fe
testb %al, %al
je 0x3993
movl $0x14, %edx
movq %r15, %rdi
leaq 0x28c3(%rip), %rsi      # 0x5903
callq 0x21e0
movq %r13, %rdi
callq 0x20b0
movq %r15, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x21e0
movl $0x34, %edx
movq %r15, %rdi
leaq 0x29c9(%rip), %rsi      # 0x5a33
jmp 0x358f
movq -0x40(%rbp), %r14
movq %r12, %rdi
movq %r14, %rsi
callq 0x2180
btl $0x1e, %r15d
movb (%r14), %al
movq %r13, -0x38(%rbp)
jb 0x33f9
testb %al, %al
movq 0x4f37(%rip), %r15      # 0x7fd0
je 0x30ad
movq %r12, %rdi
callq 0x20b0
movw $0x2f, -0x2990(%rbp,%rax)
addq $0x10, %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x2300
movl $0x1a, %edx
movq %r15, %rdi
leaq 0x2816(%rip), %rsi      # 0x58e1
callq 0x21e0
movq %r12, %rdi
callq 0x20b0
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x21e0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movl $0x400, %edi            # imm = 0x400
callq 0x2230
movq %rax, %r14
leaq 0x4(%rax), %rdi
movq %r12, %rsi
callq 0x2180
movabsq $0x100000003, %rax      # imm = 0x100000003
movq %rax, 0x3ec(%r14)
movq $0x0, 0x3f8(%r14)
movl $0x1, (%r14)
movl $0x80, %ecx
movq %rsp, %rdi
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x5072(%rip), %rdi      # 0x81d0
callq 0x40fe
testb %al, %al
je 0x3544
movl $0x14, %edx
movq %r15, %rdi
leaq 0x2789(%rip), %rsi      # 0x5903
callq 0x21e0
movq %r13, %rdi
callq 0x20b0
movq %r15, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x21e0
movl $0x35, %edx
movq %r15, %rdi
leaq 0x2707(%rip), %rsi      # 0x58ab
jmp 0x358f
btl $0x1e, %r15d
jb 0x36d8
leaq 0x1e0a5(%rip), %rdi     # 0x21260
callq 0x2270
testl %eax, %eax
jne 0x3a09
movq -0x50(%rbp), %rsi
movq %r12, %rdi
callq 0x2180
movq %r12, %rdi
callq 0x20b0
movw $0x2f, -0x2990(%rbp,%rax)
movq -0x40(%rbp), %r14
movq %r12, %rdi
movq %r14, %rsi
callq 0x2300
cmpb $0x0, (%r14)
je 0x320d
movq %r12, %rdi
callq 0x20b0
movw $0x2f, -0x2990(%rbp,%rax)
movq %r12, %r14
leaq 0x10(%r13), %r12
movq %r14, %rdi
movq %r12, %rsi
callq 0x2300
leaq -0x280(%rbp), %r15
movq %r15, %rdi
movq %r14, %rsi
movl $0x4, %edx
callq 0x2330
movq %r15, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x2240
movq 0x4d84(%rip), %r14      # 0x7fd0
movl $0x1b, %edx
movq %r14, %rdi
leaq 0x26bd(%rip), %rsi      # 0x5918
callq 0x21e0
leaq -0x2990(%rbp), %r15
movq %r15, %rdi
callq 0x20b0
movq %r14, %rdi
movq %r15, %rsi
movq %rax, %rdx
callq 0x21e0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
leaq -0x280(%rbp), %r15
movq %r15, %rdi
callq 0x22e0
movq %rax, -0x68(%rbp)
movq %r15, %rdi
callq 0x2050
movq %r13, -0x38(%rbp)
leaq 0x1df96(%rip), %rdi     # 0x21260
callq 0x2140
movq -0x40(%rbp), %r15
leaq -0x2990(%rbp), %r13
movq %r13, %rdi
movq %r15, %rsi
callq 0x2180
cmpb $0x0, (%r15)
je 0x32fd
movq %r13, %rdi
callq 0x20b0
movw $0x2f, -0x2990(%rbp,%rax)
movq %r13, %rdi
movq %r12, %r14
movq %r12, %rsi
callq 0x2300
movl -0x68(%rbp), %r12d
movl $0x400, %edi            # imm = 0x400
callq 0x2230
movq %rax, %r15
leaq 0x4(%rax), %rdi
movq %r13, %rsi
callq 0x2180
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x3ec(%r15)
movq %r12, -0x78(%rbp)
movq %r12, 0x3f8(%r15)
movl $0x1, (%r15)
movl $0x80, %ecx
movq %rsp, %rdi
movq %r15, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x4e70(%rip), %rdi      # 0x81d0
callq 0x40fe
movq -0x38(%rbp), %r13
testb %al, %al
je 0x3808
movl $0x14, %edx
movq 0x4c53(%rip), %rdi      # 0x7fd0
leaq 0x257f(%rip), %rsi      # 0x5903
callq 0x21e0
leaq -0x2990(%rbp), %r14
movq %r14, %rdi
callq 0x20b0
movq 0x4c31(%rip), %rdi      # 0x7fd0
movq %r14, %rsi
movq %rax, %rdx
callq 0x21e0
movl $0x36, %edx
movq 0x4c1a(%rip), %rdi      # 0x7fd0
leaq 0x25ac(%rip), %rsi      # 0x5969
callq 0x21e0
movq 0x4c07(%rip), %rcx      # 0x7fd0
movq (%rcx), %rax
movq -0x18(%rax), %rdi
addq %rcx, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq 0x4be9(%rip), %rdi      # 0x7fd0
callq 0x2030
movq %rax, %rdi
callq 0x2130
jmp 0x3977
testb %al, %al
movq 0x4bce(%rip), %r15      # 0x7fd0
je 0x3416
movq %r12, %rdi
callq 0x20b0
movw $0x2f, -0x2990(%rbp,%rax)
leaq 0x10(%r13), %r14
movq %r12, %rdi
movq %r14, %rsi
callq 0x2300
movl $0x1a, %edx
movq %r15, %rdi
leaq 0x240f(%rip), %rsi      # 0x5843
callq 0x21e0
movq %r12, %rdi
callq 0x20b0
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x21e0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movl $0x400, %edi            # imm = 0x400
callq 0x2230
movq %r12, %r13
movq %rax, %r12
leaq 0x4(%rax), %rdi
movq %r13, %rsi
callq 0x2180
movabsq $0x200000003, %rax      # imm = 0x200000003
movq %rax, 0x3ec(%r12)
movq $0x0, 0x3f8(%r12)
movl $0x1, (%r12)
movl $0x80, %ecx
movq %rsp, %rdi
movq %r12, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x4d03(%rip), %rdi      # 0x81d0
callq 0x40fe
testb %al, %al
je 0x35c8
movl $0x19, %edx
movq %r15, %rdi
leaq 0x23a8(%rip), %rsi      # 0x5891
callq 0x21e0
movq %r14, %rdi
callq 0x20b0
movq %r15, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x21e0
movl $0x35, %edx
movq %r15, %rdi
leaq 0x2398(%rip), %rsi      # 0x58ab
callq 0x21e0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
jmp 0x36c1
movl -0x2c(%rbp), %edi
movl $0x400, %edx            # imm = 0x400
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x20e0
movl $0x26, %edx
movq %r15, %rdi
leaq 0x22f9(%rip), %rsi      # 0x585e
callq 0x21e0
movq %r12, %rdi
callq 0x20b0
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x21e0
movl $0x6, %edx
movq %r15, %rdi
leaq 0x236d(%rip), %rsi      # 0x58fc
callq 0x21e0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movq %r14, %rdi
callq 0x21f0
jmp 0x36d0
movl -0x2c(%rbp), %edi
movl $0x400, %edx            # imm = 0x400
movq %r12, %rsi
xorl %ecx, %ecx
callq 0x20e0
movl $0x26, %edx
movq %r15, %rdi
leaq 0x2275(%rip), %rsi      # 0x585e
callq 0x21e0
movq %r14, %rdi
callq 0x20b0
movq %r15, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x21e0
movl $0xb, %edx
movq %r15, %rdi
leaq 0x2272(%rip), %rsi      # 0x5885
callq 0x21e0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x2230
movq %rax, -0x280(%rbp)
movq %rax, %rdi
movq %r13, %rsi
callq 0x2180
leaq -0x70(%rbp), %r15
movq %r15, %rdi
leaq -0x8e8(%rip), %r14      # 0x2d81
movq %r14, %rsi
leaq -0x50(%rbp), %r13
movq %r13, %rdx
leaq -0x40(%rbp), %rcx
leaq -0x2c(%rbp), %r8
callq 0x404c
leaq -0x58(%rbp), %rdi
movq %r14, %rsi
movq %r13, %rdx
leaq -0x280(%rbp), %rcx
leaq -0x2c(%rbp), %r8
callq 0x404c
movq %r15, %rdi
callq 0x22b0
leaq -0x58(%rbp), %rdi
callq 0x22b0
cmpq $0x0, -0x58(%rbp)
jne 0x3a8a
cmpq $0x0, -0x70(%rbp)
jne 0x3a8a
movq %r12, %rdi
callq 0x21f0
leaq -0x2990(%rbp), %r12
movq -0x48(%rbp), %r14
movq -0x38(%rbp), %r13
movl 0xc(%r13), %eax
addl %eax, %ebx
addl $0x10, %ebx
cmpl %r14d, %ebx
jl 0x2ef8
jmp 0x2eb9
testb %al, %al
movq 0x48d8(%rip), %r15      # 0x7fd0
je 0x370c
movq %r12, %rdi
callq 0x20b0
movw $0x2f, -0x2990(%rbp,%rax)
addq $0x10, %r13
movq %r12, %rdi
movq %r13, %rsi
callq 0x2300
movl $0x1a, %edx
movq %r15, %rdi
leaq 0x2276(%rip), %rsi      # 0x59a0
callq 0x21e0
movq %r12, %rdi
callq 0x20b0
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x21e0
movq (%r15), %rax
movq -0x18(%rax), %rdi
addq %r15, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r15, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movl $0x400, %edi            # imm = 0x400
callq 0x2230
movq %rax, %r14
leaq 0x4(%rax), %rdi
movq %r12, %rsi
callq 0x2180
movabsq $0x200000002, %rax      # imm = 0x200000002
movq %rax, 0x3ec(%r14)
movq $0x0, 0x3f8(%r14)
movl $0x1, (%r14)
movl $0x80, %ecx
movq %rsp, %rdi
movq %r14, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x4a13(%rip), %rdi      # 0x81d0
callq 0x40fe
testb %al, %al
je 0x39b9
movl $0x19, %edx
movq %r15, %rdi
leaq 0x20b8(%rip), %rsi      # 0x5891
callq 0x21e0
movq %r13, %rdi
callq 0x20b0
movq %r15, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x21e0
movl $0x35, %edx
movq %r15, %rdi
leaq 0x21df(%rip), %rsi      # 0x59e2
jmp 0x358f
movl -0x2c(%rbp), %edi
movl $0x400, %edx            # imm = 0x400
movq %r15, %rsi
xorl %ecx, %ecx
callq 0x20e0
leaq 0x1da3f(%rip), %rdi     # 0x21260
callq 0x2270
testl %eax, %eax
jne 0x3a10
movq -0x50(%rbp), %rsi
leaq -0x2990(%rbp), %r13
movq %r13, %rdi
callq 0x2180
movq %r13, %rdi
callq 0x20b0
movw $0x2f, -0x2990(%rbp,%rax)
movq -0x40(%rbp), %r15
movq %r13, %rdi
movq %r15, %rsi
callq 0x2300
cmpb $0x0, (%r15)
je 0x387a
movq %r13, %rdi
callq 0x20b0
movw $0x2f, -0x2990(%rbp,%rax)
movq %r13, %rdi
movq %r14, %rsi
callq 0x2300
movl $0x26, %edx
movq 0x473f(%rip), %r15      # 0x7fd0
movq %r15, %rdi
leaq 0x2099(%rip), %rsi      # 0x5934
callq 0x21e0
movq -0x38(%rbp), %r13
leaq -0x2990(%rbp), %r12
movq %r12, %rdi
callq 0x20b0
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x21e0
movl $0xd, %edx
movq %r15, %rdi
leaq 0x208b(%rip), %rsi      # 0x595b
callq 0x21e0
movl -0x68(%rbp), %esi
movq %r15, %rdi
callq 0x2120
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
leaq -0x280(%rbp), %rdi
leaq -0x2990(%rbp), %rsi
movl $0x4, %edx
callq 0x2100
leaq -0x280(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2240
movq -0x78(%rbp), %r15
movq %r15, %rdi
callq 0x2230
movq %rax, %r14
leaq -0x280(%rbp), %rdi
movq %rax, %rsi
movq %r15, %rdx
callq 0x2210
leaq 0x1d906(%rip), %rdi     # 0x21260
callq 0x2140
movl -0x2c(%rbp), %edi
movq %r14, %rsi
movq %r15, %rdx
xorl %ecx, %ecx
callq 0x20e0
movq %r14, %rdi
callq 0x21f0
leaq -0x280(%rbp), %rdi
callq 0x2070
leaq -0x2990(%rbp), %r12
movq -0x48(%rbp), %r14
jmp 0x36d8
movl -0x2c(%rbp), %edi
movl $0x400, %edx            # imm = 0x400
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x20e0
movl $0x26, %edx
movq %r15, %rdi
leaq 0x2007(%rip), %rsi      # 0x59bb
jmp 0x3565
movl -0x2c(%rbp), %edi
movl $0x400, %edx            # imm = 0x400
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x20e0
movl $0x26, %edx
movq %r15, %rdi
leaq 0x1fe1(%rip), %rsi      # 0x59bb
callq 0x21e0
movq %r12, %rdi
callq 0x20b0
movq %r15, %rdi
movq %r12, %rsi
movq %rax, %rdx
callq 0x21e0
movl $0xb, %edx
movq %r15, %rdi
leaq 0x1e81(%rip), %rsi      # 0x5885
jmp 0x358f
movl %eax, %edi
callq 0x2110
movl %eax, %edi
callq 0x2110
movq 0x45b2(%rip), %rdi      # 0x7fd0
leaq 0x1d79(%rip), %rsi      # 0x579e
callq 0x21b0
movq %rax, %rdi
callq 0x20d0
jmp 0x3a65
movq 0x4595(%rip), %rdi      # 0x7fd0
leaq 0x1d91(%rip), %rsi      # 0x57d3
callq 0x21b0
leaq -0x2990(%rbp), %rsi
movq %rax, %rdi
callq 0x21b0
leaq 0x1d9d(%rip), %rsi      # 0x57fa
movq %rax, %rdi
callq 0x21b0
movl $0x1, %edi
callq 0x2200
jmp 0x3a93
jmp 0x3a80
jmp 0x3a93
jmp 0x3a93
jmp 0x3a93
cmpq $0x0, -0x58(%rbp)
jne 0x3a8a
movq %rax, %rbx
cmpq $0x0, -0x70(%rbp)
je 0x3aa2
callq 0x2080
jmp 0x3a93
jmp 0x3a93
movq %rax, %rbx
leaq -0x280(%rbp), %rdi
callq 0x2070
movq %rbx, %rdi
callq 0x22f0