// File: /workspace/github_cpp_makefile_star2_O3/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 %rsi, %r14
movq %rdi, %r15
movq %rdi, -0x58(%rbp)
movq %rsi, -0x48(%rbp)
movl %edx, -0x2c(%rbp)
movq 0x521a(%rip), %rbx      # 0x7fd0
leaq 0x29a5(%rip), %rsi      # 0x5762
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
leaq -0x2990(%rbp), %rdi
movq %r15, %rsi
callq 0x2180
cmpb $0x0, (%r14)
je 0x2e1c
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 0x3a04
leaq -0x2990(%rbp), %rsi
movl %eax, -0x5c(%rbp)
movl %eax, %edi
movl $0x302, %edx            # imm = 0x302
callq 0x20f0
cmpl $-0x1, %eax
je 0x3a21
leaq 0x298d(%rip), %rsi      # 0x57eb
movl $0x20, %edx
movq %rbx, %rdi
callq 0x21e0
leaq -0x2990(%rbp), %r14
movq %r14, %rdi
callq 0x20b0
movq %rbx, %rdi
movq %r14, %rsi
movq %rax, %rdx
callq 0x21e0
leaq 0x28f1(%rip), %rsi      # 0x5780
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, %rbx
testl %ebx, %ebx
js 0x39d9
je 0x2ec3
xorl %r15d, %r15d
movq %rbx, -0x40(%rbp)
movslq %r15d, %rax
leaq -0x48d0(,%rax,8), %rax
addq %rbp, %rax
cmpl $0x0, 0xc(%rax)
je 0x35b1
movl 0x4(%rax), %r12d
btl $0x8, %r12d
movq %rax, -0x38(%rbp)
jb 0x3071
testb $0x2, %r12b
jne 0x31b7
btl $0x9, %r12d
jae 0x35b1
movq -0x48(%rbp), %r14
leaq -0x2990(%rbp), %rdi
movq %r14, %rsi
callq 0x2180
btl $0x1e, %r12d
movb (%r14), %al
jb 0x36d4
testb %al, %al
movq 0x507b(%rip), %r12      # 0x7fd0
leaq -0x2990(%rbp), %rbx
movq -0x38(%rbp), %r14
je 0x2f74
movq %rbx, %rdi
callq 0x20b0
movw $0x2f, -0x2990(%rbp,%rax)
leaq 0x10(%r14), %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2300
movl $0x1a, %edx
movq %r12, %rdi
leaq 0x2a6a(%rip), %rsi      # 0x59fc
callq 0x21e0
movq %rbx, %rdi
callq 0x20b0
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x21e0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movl $0x400, %edi            # imm = 0x400
callq 0x2230
movq %rax, %r14
leaq 0x4(%rax), %rdi
movq %rbx, %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 0x51aa(%rip), %rdi      # 0x81d0
callq 0x409c
testb %al, %al
je 0x3963
movl $0x14, %edx
movq %r12, %rdi
leaq 0x28a5(%rip), %rsi      # 0x58e7
callq 0x21e0
movq %r13, %rdi
callq 0x20b0
movq %r12, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x21e0
movl $0x34, %edx
movq %r12, %rdi
leaq 0x29ab(%rip), %rsi      # 0x5a17
jmp 0x3574
movq -0x48(%rbp), %r14
leaq -0x2990(%rbp), %rdi
movq %r14, %rsi
callq 0x2180
btl $0x1e, %r12d
movb (%r14), %al
jb 0x33f9
testb %al, %al
movq 0x4f35(%rip), %r12      # 0x7fd0
leaq -0x2990(%rbp), %rbx
movq -0x38(%rbp), %r14
je 0x30ba
movq %rbx, %rdi
callq 0x20b0
movw $0x2f, -0x2990(%rbp,%rax)
leaq 0x10(%r14), %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2300
movl $0x1a, %edx
movq %r12, %rdi
leaq 0x27ed(%rip), %rsi      # 0x58c5
callq 0x21e0
movq %rbx, %rdi
callq 0x20b0
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x21e0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movl $0x400, %edi            # imm = 0x400
callq 0x2230
movq %rax, %r14
leaq 0x4(%rax), %rdi
movq %rbx, %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 0x5064(%rip), %rdi      # 0x81d0
callq 0x409c
testb %al, %al
je 0x3529
movl $0x14, %edx
movq %r12, %rdi
leaq 0x275f(%rip), %rsi      # 0x58e7
callq 0x21e0
movq %r13, %rdi
callq 0x20b0
movq %r12, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x21e0
movl $0x35, %edx
movq %r12, %rdi
leaq 0x26dd(%rip), %rsi      # 0x588f
jmp 0x3574
btl $0x1e, %r12d
jb 0x35b1
leaq 0x1e097(%rip), %rdi     # 0x21260
callq 0x2270
testl %eax, %eax
jne 0x39f6
movq -0x58(%rbp), %rsi
leaq -0x2990(%rbp), %rbx
movq %rbx, %rdi
callq 0x2180
movq %rbx, %rdi
callq 0x20b0
movw $0x2f, -0x2990(%rbp,%rax)
movq -0x48(%rbp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2300
cmpb $0x0, (%r14)
je 0x3222
movq %rbx, %rdi
callq 0x20b0
movw $0x2f, -0x2990(%rbp,%rax)
movq -0x38(%rbp), %rax
leaq 0x10(%rax), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2300
leaq -0x278(%rbp), %r12
movq %r12, %rdi
movq %rbx, %rsi
movl $0x4, %edx
callq 0x2330
movq %r12, %rdi
xorl %esi, %esi
movl $0x2, %edx
callq 0x2240
movq 0x4d6e(%rip), %r12      # 0x7fd0
movl $0x1b, %edx
movq %r12, %rdi
leaq 0x268b(%rip), %rsi      # 0x58fc
callq 0x21e0
movq %rbx, %rdi
callq 0x20b0
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x21e0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
leaq -0x278(%rbp), %rbx
movq %rbx, %rdi
callq 0x22e0
movq %rax, %r13
movq %rbx, %rdi
callq 0x2050
leaq 0x1df8b(%rip), %rdi     # 0x21260
callq 0x2140
movq -0x48(%rbp), %r12
leaq -0x2990(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rsi
callq 0x2180
cmpb $0x0, (%r12)
je 0x3309
movq %rbx, %rdi
callq 0x20b0
movw $0x2f, -0x2990(%rbp,%rax)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2300
movl %r13d, %r13d
movl $0x400, %edi            # imm = 0x400
callq 0x2230
movq %rax, %r12
leaq 0x4(%rax), %rdi
movq %rbx, %rsi
callq 0x2180
movabsq $0x100000001, %rax      # imm = 0x100000001
movq %rax, 0x3ec(%r12)
movq %r13, 0x3f8(%r12)
movl $0x1, (%r12)
movl $0x80, %ecx
movq %rsp, %rdi
movq %r12, %rsi
rep  movsq (%rsi), %es:(%rdi)
leaq 0x4e69(%rip), %rdi      # 0x81d0
callq 0x409c
testb %al, %al
je 0x37f9
movl $0x14, %edx
movq 0x4c50(%rip), %rdi      # 0x7fd0
leaq 0x2560(%rip), %rsi      # 0x58e7
callq 0x21e0
movq %rbx, %rdi
callq 0x20b0
movq 0x4c35(%rip), %rdi      # 0x7fd0
movq %rbx, %rsi
movq -0x40(%rbp), %rbx
movq %rax, %rdx
callq 0x21e0
movl $0x36, %edx
movq 0x4c1a(%rip), %rdi      # 0x7fd0
leaq 0x2590(%rip), %rsi      # 0x594d
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 0x3952
testb %al, %al
movq 0x4bce(%rip), %r12      # 0x7fd0
movq -0x38(%rbp), %r14
je 0x341e
leaq -0x2990(%rbp), %rdi
callq 0x20b0
movw $0x2f, -0x2990(%rbp,%rax)
leaq 0x10(%r14), %rsi
leaq -0x2990(%rbp), %r13
movq %r13, %rdi
movq %rsi, -0x68(%rbp)
callq 0x2300
movl $0x1a, %edx
movq %r12, %rdi
leaq 0x23e3(%rip), %rsi      # 0x5827
callq 0x21e0
movq %r13, %rdi
callq 0x20b0
movq %r12, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x21e0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movl $0x400, %edi            # imm = 0x400
callq 0x2230
movq %rax, %r14
leaq 0x4(%rax), %rdi
movq %r13, %rsi
callq 0x2180
movabsq $0x200000003, %rax      # imm = 0x200000003
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 0x4cf8(%rip), %rdi      # 0x81d0
callq 0x409c
testb %al, %al
je 0x35c9
movl $0x19, %edx
movq %r12, %rdi
leaq 0x2381(%rip), %rsi      # 0x5875
callq 0x21e0
movq -0x68(%rbp), %r13
movq %r13, %rdi
callq 0x20b0
movq %r12, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x21e0
movl $0x35, %edx
movq %r12, %rdi
leaq 0x236d(%rip), %rsi      # 0x588f
callq 0x21e0
jmp 0x357d
movl -0x2c(%rbp), %edi
movl $0x400, %edx            # imm = 0x400
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x20e0
movl $0x26, %edx
movq %r12, %rdi
leaq 0x22f8(%rip), %rsi      # 0x5842
callq 0x21e0
movq %rbx, %rdi
callq 0x20b0
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x21e0
movl $0x6, %edx
movq %r12, %rdi
leaq 0x236c(%rip), %rsi      # 0x58e0
callq 0x21e0
movq -0x40(%rbp), %rbx
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movq %r14, %rdi
callq 0x21f0
movq -0x38(%rbp), %rax
movl 0xc(%rax), %eax
addl %eax, %r15d
addl $0x10, %r15d
cmpl %ebx, %r15d
jl 0x2eeb
jmp 0x2ec3
movl -0x2c(%rbp), %edi
movl $0x400, %edx            # imm = 0x400
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x20e0
movl $0x26, %edx
movq %r12, %rdi
leaq 0x2258(%rip), %rsi      # 0x5842
callq 0x21e0
movq -0x68(%rbp), %rbx
movq %rbx, %rdi
callq 0x20b0
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x21e0
movl $0xb, %edx
movq %r12, %rdi
leaq 0x2251(%rip), %rsi      # 0x5869
callq 0x21e0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movl $0x3e8, %edi            # imm = 0x3E8
callq 0x2230
movq %rax, -0x278(%rbp)
movq %rax, %rdi
leaq -0x2990(%rbp), %rsi
callq 0x2180
leaq -0x70(%rbp), %r12
movq %r12, %rdi
leaq -0x8e9(%rip), %rbx      # 0x2d8a
movq %rbx, %rsi
leaq -0x58(%rbp), %r13
movq %r13, %rdx
leaq -0x48(%rbp), %rcx
leaq -0x2c(%rbp), %r8
callq 0x3ffa
leaq -0x50(%rbp), %rdi
movq %rbx, %rsi
movq %r13, %rdx
leaq -0x278(%rbp), %rcx
leaq -0x2c(%rbp), %r8
callq 0x3ffa
movq %r12, %rdi
callq 0x22b0
leaq -0x50(%rbp), %rdi
callq 0x22b0
cmpq $0x0, -0x50(%rbp)
jne 0x3a77
cmpq $0x0, -0x70(%rbp)
jne 0x3a77
movq -0x40(%rbp), %rbx
jmp 0x35a5
testb %al, %al
movq 0x48f3(%rip), %r12      # 0x7fd0
leaq -0x2990(%rbp), %rbx
movq -0x38(%rbp), %r14
je 0x36fc
movq %rbx, %rdi
callq 0x20b0
movw $0x2f, -0x2990(%rbp,%rax)
leaq 0x10(%r14), %r13
movq %rbx, %rdi
movq %r13, %rsi
callq 0x2300
movl $0x1a, %edx
movq %r12, %rdi
leaq 0x226a(%rip), %rsi      # 0x5984
callq 0x21e0
movq %rbx, %rdi
callq 0x20b0
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x21e0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x21a0
movsbl %al, %esi
movq %r12, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x2130
movl $0x400, %edi            # imm = 0x400
callq 0x2230
movq %rax, %r14
leaq 0x4(%rax), %rdi
movq %rbx, %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 0x4a22(%rip), %rdi      # 0x81d0
callq 0x409c
testb %al, %al
je 0x3989
movl $0x19, %edx
movq %r12, %rdi
leaq 0x20ab(%rip), %rsi      # 0x5875
callq 0x21e0
movq %r13, %rdi
callq 0x20b0
movq %r12, %rdi
movq %r13, %rsi
movq %rax, %rdx
callq 0x21e0
movl $0x35, %edx
movq %r12, %rdi
leaq 0x21d2(%rip), %rsi      # 0x59c6
jmp 0x3574
movl -0x2c(%rbp), %edi
movl $0x400, %edx            # imm = 0x400
movq %r12, %rsi
xorl %ecx, %ecx
callq 0x20e0
leaq 0x1da4e(%rip), %rdi     # 0x21260
callq 0x2270
testl %eax, %eax
jne 0x39fd
movq -0x58(%rbp), %rsi
movq %rbx, %rdi
callq 0x2180
movq %rbx, %rdi
callq 0x20b0
movw $0x2f, -0x2990(%rbp,%rax)
movq -0x48(%rbp), %r12
leaq -0x2990(%rbp), %rdi
movq %r12, %rsi
callq 0x2300
cmpb $0x0, (%r12)
je 0x3869
movq %rbx, %rdi
callq 0x20b0
movw $0x2f, -0x2990(%rbp,%rax)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2300
movl $0x26, %edx
movq 0x4750(%rip), %r14      # 0x7fd0
movq %r14, %rdi
leaq 0x208e(%rip), %rsi      # 0x5918
callq 0x21e0
leaq -0x278(%rbp), %r12
movq %rbx, %rdi
callq 0x20b0
movq %r14, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x21e0
movl $0xd, %edx
movq %r14, %rdi
leaq 0x2084(%rip), %rsi      # 0x593f
callq 0x21e0
movq %r14, %rdi
movq %r13, %rsi
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
movq %r12, %rdi
movq %rbx, %rsi
movl $0x4, %edx
callq 0x2100
movq %r12, %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2240
movq %r13, %rdi
callq 0x2230
movq %rax, %r14
movq %r12, %rdi
movq %rax, %rsi
movq %r13, %rdx
callq 0x2210
movq -0x40(%rbp), %rbx
leaq 0x1d92b(%rip), %rdi     # 0x21260
callq 0x2140
movl -0x2c(%rbp), %edi
movq %r14, %rsi
movq %r13, %rdx
xorl %ecx, %ecx
callq 0x20e0
movq %r14, %rdi
callq 0x21f0
leaq -0x278(%rbp), %rdi
callq 0x2070
jmp 0x35ad
movl -0x2c(%rbp), %edi
movl $0x400, %edx            # imm = 0x400
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x20e0
movl $0x26, %edx
movq %r12, %rdi
leaq 0x201b(%rip), %rsi      # 0x599f
jmp 0x354a
movl -0x2c(%rbp), %edi
movl $0x400, %edx            # imm = 0x400
movq %r14, %rsi
xorl %ecx, %ecx
callq 0x20e0
movl $0x26, %edx
movq %r12, %rdi
leaq 0x1ff5(%rip), %rsi      # 0x599f
callq 0x21e0
movq %rbx, %rdi
callq 0x20b0
movq %r12, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0x21e0
movl $0xb, %edx
movq %r12, %rdi
leaq 0x1e95(%rip), %rsi      # 0x5869
jmp 0x3574
movl $0x1a, %edx
movq 0x45eb(%rip), %rdi      # 0x7fd0
leaq 0x1e20(%rip), %rsi      # 0x580c
callq 0x21e0
jmp 0x2ec3
movl %eax, %edi
callq 0x2110
movl %eax, %edi
callq 0x2110
movq 0x45c5(%rip), %rdi      # 0x7fd0
leaq 0x1d70(%rip), %rsi      # 0x5782
callq 0x21b0
movq %rax, %rdi
callq 0x20d0
jmp 0x3a52
movq 0x45a8(%rip), %rdi      # 0x7fd0
leaq 0x1d88(%rip), %rsi      # 0x57b7
callq 0x21b0
leaq -0x2990(%rbp), %rsi
movq %rax, %rdi
callq 0x21b0
leaq 0x1d94(%rip), %rsi      # 0x57de
movq %rax, %rdi
callq 0x21b0
movl $0x1, %edi
callq 0x2200
jmp 0x3a80
jmp 0x3a80
jmp 0x3a80
jmp 0x3a80
jmp 0x3a6d
cmpq $0x0, -0x50(%rbp)
jne 0x3a77
movq %rax, %rbx
cmpq $0x0, -0x70(%rbp)
je 0x3a8f
callq 0x2080
jmp 0x3a80
jmp 0x3a80
movq %rax, %rbx
leaq -0x278(%rbp), %rdi
callq 0x2070
movq %rbx, %rdi
callq 0x22f0