// File: /workspace/github_c_makefile_star2_O2/evanwire[P]GitClone/server.c
// Function: push
void push(char* command, int connfd){
  //lock the repository
  pthread_mutex_lock(&lock);

  //Parse message from client
  char message[strlen(command) - 1];
  memset(message, 0, sizeof(message));
  int i;
  for(i = 2; i < strlen(command); i++){
      if(command[i]){
        message[i - 2] = command[i];
      }
      
  }

  //Isolate project name
  char* saveptr = message;
  char* projectName = strtok_r(saveptr, " ", &saveptr);

  char numberStorage[10];
  memset(numberStorage, '\0', 10);
  char* token = strtok_r(saveptr, "$", &saveptr);
  sprintf(numberStorage, "%s", token);

  int numFiles = atoi(numberStorage);

  token = strtok_r(saveptr, "&", &saveptr);
  token = strtok_r(saveptr, "&", &saveptr);
  token = strtok_r(saveptr, "&", &saveptr);
  char* commitContents = strtok_r(saveptr, "$", &saveptr);
  
  char* sendbuff;

  //Search for a commit file that matches the one that the client sent
  char commits_path[strlen(projectName) + 10];
  memset(commits_path, 0, strlen(projectName) + 10);
  strcpy(commits_path, "./");
  strcat(commits_path, projectName);
  strcat(commits_path, "/Commits");
  DIR* dir = opendir(commits_path);

  int does_commit_exist = 0;
  char* activeCommit = malloc(256 * sizeof(char));
  memset(activeCommit, 0, 256);


  //If commits directory does not exist, alert client they must create one first
  if(dir == NULL){
    closedir(dir);
    sendbuff = "\nError: no commits exist on the server currently. Run the commit command before you push.";
    write(connfd, sendbuff, strlen(sendbuff));
    pthread_mutex_unlock(&lock);
    return;
  }else{
    struct dirent* ent;
    int newCommitName = 0;
    //for each dirent in the directory
    while((ent = readdir(dir)) != NULL){
      char* fname = ent->d_name;
      //if its a folder, skip over it
      if(strcmp(fname, ".") == 0 || strcmp(fname, "..") == 0 || ent->d_type  == DT_DIR){
        continue;

      //if it is not a folder, we can assume that the dirent is a file. Thus, we can open it and compare its contents to the message from the client
      }else{
        char pathOfCurrentCommit[strlen(projectName) + strlen(ent->d_name) + 9];
        strcpy(pathOfCurrentCommit, projectName);
        strcat(pathOfCurrentCommit, "/Commits/");
        strcat(pathOfCurrentCommit, ent->d_name);
        char* contents = readFile(pathOfCurrentCommit);
        if(strcmp(contents, commitContents) == 0){
          strcpy(activeCommit, "./");
          strcat(activeCommit, pathOfCurrentCommit);
          does_commit_exist = 1;
          break;
        }
      }
    }
  }
  closedir(dir);
  //If the commit exists on the server, delete all others
  if(does_commit_exist == 1){
    DIR* dir2 = opendir(commits_path);
    struct dirent* ent;
    char filepath[256];
    
    while((ent = readdir(dir2)) != NULL){
      if(ent->d_type == DT_DIR){
        continue;
      }
      sprintf(filepath, "%s/%s", commits_path, ent->d_name);
      if(strcmp(filepath, activeCommit) != 0){
        remove(filepath);
      }
      
    }
    closedir(dir2);

  //If the commit does not exist on the server, report that to the client
  }else{
    sendbuff = "\nError: no commit file exists on the server that matches the one you pushed. Please run the commit command before pushing.";
    write(connfd, sendbuff, strlen(sendbuff));
    pthread_mutex_unlock(&lock);
    return;
  }



  

  //Get the current project's version number to name the archive
  char manifestPath[strlen(projectName) + 10];
  strcpy(manifestPath, projectName);
  strcat(manifestPath, "/.Manifest");
  char* manifest_contents = readFile(manifestPath);
  char* aptr = manifest_contents;
  char* version_num = strtok_r(aptr, "\n", &aptr);
  char* aptr2 = version_num;
  version_num = strtok_r(aptr2, " ", &aptr2);
  version_num = strtok_r(aptr2, " ", &aptr2);
  //Store the current project in an archive
  char historyPath[strlen(projectName) + 100];
  strcpy(historyPath, projectName);
  strcat(historyPath, "/History");
  strcat(historyPath, "/");
  DIR* historydir = opendir(historyPath);
  if(historydir == NULL){
    int result = mkdir(historyPath, 0777);
  }
  char cmd[100];
  sprintf(cmd, "cp -avr %s %s", projectName, version_num);
  system(cmd);
  sprintf(cmd, "mv %s %s", version_num, historyPath);
  system(cmd);
  
  int vnum = atoi(version_num);
  vnum++;

  //prepare the write to the new manifest
  char manifestWrite[1000];
  memset(manifestWrite, '\0', 1000);
  sprintf(manifestWrite, "V %d\n", vnum);
  
  token = saveptr;
  int idx = 0;
  while(1){
    if(token[idx] == '\0' || idx > strlen(token)){
      break;
    }
    char file_name_sz[5];
    int subidx = 0;
    while(token[idx] != '&'){
      file_name_sz[subidx] = token[idx];
      idx++;
      subidx++;
    }
    idx++;
    int fn_size = atoi(file_name_sz);
    char file_name[fn_size + 1];
    memset(file_name, '\0', fn_size + 1);

    for(i = 0; i < fn_size; i++){
      file_name[i] = token[idx];
      idx++;
    }
    
    char file_sz[5];
    subidx = 0;
    idx++;
    while(token[idx] != '&'){
      file_sz[subidx] = token[idx];
      idx++;
      subidx++;
    }
    idx++;
    int file_size = atoi(file_sz);
    char file[file_size + 1];
    memset(file, '\0', file_size + 1);
    for(i = 0; i < file_size; i++){
      file[i] = token[idx];
      idx++;
    }
    idx++;


    if(file_name[0] == 'A'){
      char fn[strlen(file_name)+1];
      memset(fn, '\0', strlen(file_name) + 1);
      for(i = 1; i < strlen(file_name); i++){
        fn[i-1] = file_name[i];
      }
      fn[i] = '\0';

      int newFileFd = open(fn, O_WRONLY | O_CREAT, 0777);
      int b = write(newFileFd, file, strlen(file));
      close(newFileFd);

      strcat(manifestWrite, fn);
      strcat(manifestWrite, "~V:0~H:");
      strcat(manifestWrite, hashIt(file));
      strcat(manifestWrite, "\n");
    }else if(file_name[0] == 'D'){
      char fn[strlen(file_name)+1];
      memset(fn, '\0', strlen(file_name) + 1);
      for(i = 1; i < strlen(file_name); i++){
        fn[i-1] = file_name[i];
      }
      fn[i] = '\0';
      char cmdd[strlen(fn) + 8];
      strcpy(cmdd, "rm -rf ");
      strcat(cmdd, fn);
      system(cmdd);

    }else{
      char fn[strlen(file_name)+1];
      memset(fn, '\0', strlen(file_name) + 1);
      for(i = 1; i < strlen(file_name); i++){
        fn[i-1] = file_name[i];
      }
      fn[i] = '\0';

      int newFileFd = open(fn, O_WRONLY | O_CREAT, 0777);
      int b = write(newFileFd, file, strlen(file));
      close(newFileFd);

      char* idk = readFile(manifestPath);
      char* apointer = strstr(idk, fn);
      char* tokenizing = strtok_r(apointer, "~", &apointer);
      tokenizing = strtok_r(apointer, "~", &apointer);
      apointer = tokenizing;
      tokenizing = strtok_r(apointer, ":", &apointer);
      tokenizing = strtok_r(apointer, ":", &apointer);
      
      int newNum = atoi(tokenizing);
      newNum++;
      char buff[5];
      sprintf(buff, "%d", newNum);

      strcat(manifestWrite, fn);
      strcat(manifestWrite, "~V:");
      strcat(manifestWrite, buff);
      strcat(manifestWrite, "~H:");
      strcat(manifestWrite, hashIt(file));
      strcat(manifestWrite, "\n");

    }
    


  }
  

  int manfd = open(manifestPath, O_WRONLY | O_TRUNC);
  write(manfd, manifestWrite, strlen(manifestWrite));
  
  

  
  //Unlock the repository*/
  free(manifest_contents);
  closedir(historydir);
  sendbuff = "\nSuccessful push";
  write(connfd, sendbuff, strlen(sendbuff));
  pthread_mutex_unlock(&lock);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x4d8, %rsp            # imm = 0x4D8
movl %esi, -0x34(%rbp)
movq %rdi, %rbx
leaq 0x49ff(%rip), %rdi      # 0x6180
callq 0x1200
movq %rbx, %rdi
callq 0x10b0
movq %rax, %r14
leaq -0x1(%rax), %rdx
movq %rsp, %r15
addq $0xe, %rax
andq $-0x10, %rax
subq %rax, %r15
movq %r15, %rsp
movq %r15, %rdi
xorl %esi, %esi
callq 0x10d0
pushq $0x2
popq %rax
cmpq %rax, %r14
jbe 0x17c9
movb (%rbx,%rax), %cl
testb %cl, %cl
je 0x17c4
movb %cl, -0x2(%r15,%rax)
incq %rax
jmp 0x17b3
leaq -0x90(%rbp), %r14
movq %r15, (%r14)
leaq 0x2abc(%rip), %rsi      # 0x4296
movq %r15, %rdi
movq %r14, %rdx
callq 0x1290
movq %rax, %r12
movq (%r14), %rdi
leaq 0x2ae1(%rip), %rbx      # 0x42d3
movq %rbx, %rsi
movq %r14, %rdx
callq 0x1290
movq (%r14), %rdi
leaq 0x2ace(%rip), %r15      # 0x42d5
movq %r15, %rsi
movq %r14, %rdx
callq 0x1290
movq (%r14), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1290
movq (%r14), %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x1290
movq (%r14), %rdi
movq %rbx, %rsi
movq %r14, %rdx
callq 0x1290
movq %rax, -0x30(%rbp)
movq %r12, %rdi
callq 0x10b0
leaq 0xa(%rax), %rcx
leaq 0x19(%rax), %r14
andq $-0x10, %r14
movq %rsp, %r15
movq %r15, %r13
subq %r14, %r13
movq %r13, %rsp
addq $0x7, %rax
xorl %ebx, %ebx
cmpq $0x4, %rcx
movl $0x0, %edx
cmovaeq %rax, %rdx
leaq 0x3(%r13), %rdi
xorl %esi, %esi
callq 0x10d0
negq %r14
movb %bl, 0x2(%r15,%r14)
movw $0x2f2e, (%r13)         # imm = 0x2F2E
movq %r13, %rdi
movq %r12, %rsi
callq 0x1270
movq %r13, %rdi
callq 0x10b0
movabsq $0x7374696d6d6f432f, %rcx # imm = 0x7374696D6D6F432F
movq %rcx, (%rax,%r13)
movb %bl, 0x8(%rax,%r13)
movq %r13, -0x58(%rbp)
movq %r13, %rdi
callq 0x1210
movq %rax, %rbx
pushq $0x1
popq %rdi
movl $0x100, %esi            # imm = 0x100
callq 0x10f0
movq %rax, -0x40(%rbp)
testq %rbx, %rbx
je 0x19b9
movq %r12, -0x48(%rbp)
movq %rbx, -0x50(%rbp)
movq -0x48(%rbp), %r13
movq %rbx, %rdi
callq 0x1220
testq %rax, %rax
je 0x19a3
movq %rax, %r15
cmpb $0x2e, 0x13(%rax)
jne 0x1917
cmpb $0x0, 0x14(%r15)
je 0x18e8
cmpb $0x2e, 0x14(%r15)
jne 0x1917
cmpb $0x0, 0x15(%r15)
je 0x18e8
cmpb $0x4, 0x12(%r15)
je 0x18e8
leaq 0x13(%r15), %r12
movq %r13, %rdi
callq 0x10b0
movq %rax, %rbx
movq %r12, %rdi
callq 0x10b0
movq %rsp, %r14
addq %rbx, %rax
addq $0x18, %rax
andq $-0x10, %rax
movq %rsp, %rbx
subq %rax, %rbx
movq %rbx, %rsp
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1150
movq %rbx, %rdi
callq 0x10b0
movabsq $0x7374696d6d6f432f, %rcx # imm = 0x7374696D6D6F432F
movq %rcx, (%rax,%rbx)
movw $0x2f, 0x8(%rax,%rbx)
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1270
movq %rbx, %rdi
callq 0x320a
movq %rax, %rdi
movq -0x30(%rbp), %rsi
callq 0x11e0
testl %eax, %eax
je 0x19ce
movq %r14, %rsp
movq -0x50(%rbp), %rbx
jmp 0x18e8
movq %rbx, %rdi
callq 0x1260
leaq 0x2a9c(%rip), %rsi      # 0x444e
pushq $0x7a
jmp 0x1fda
xorl %edi, %edi
callq 0x1260
leaq 0x2a27(%rip), %rsi      # 0x43ee
pushq $0x59
jmp 0x1fda
movq -0x40(%rbp), %rdi
movb $0x0, 0x2(%rdi)
movw $0x2f2e, (%rdi)         # imm = 0x2F2E
movq %rbx, %rsi
callq 0x1270
movq %r14, %rsp
movq -0x50(%rbp), %rdi
callq 0x1260
testq %r15, %r15
je 0x19ab
movq -0x58(%rbp), %rdi
callq 0x1210
movq %rax, %r15
leaq 0x2a41(%rip), %r12      # 0x4448
leaq -0x490(%rbp), %r13
movq %r15, %rdi
callq 0x1220
testq %rax, %rax
je 0x1a53
cmpb $0x4, 0x12(%rax)
je 0x1a0e
addq $0x13, %rax
movq %r13, %rdi
movq %r12, %rsi
movq -0x58(%rbp), %rdx
movq %rax, %rcx
xorl %eax, %eax
callq 0x1060
movq %r13, %rdi
movq -0x40(%rbp), %rsi
callq 0x11e0
testl %eax, %eax
je 0x1a0e
movq %r13, %rdi
callq 0x1280
jmp 0x1a0e
movq %r15, %rdi
callq 0x1260
movq -0x48(%rbp), %r12
movq %r12, %rdi
callq 0x10b0
movq %rsp, %rbx
addq $0x19, %rax
andq $-0x10, %rax
subq %rax, %rbx
movq %rbx, %rsp
movq %rbx, %rdi
movq %r12, %rsi
callq 0x1150
movq %rbx, %rdi
callq 0x10b0
movabsq $0x6566696e614d2e2f, %rcx # imm = 0x6566696E614D2E2F
movq %rcx, (%rax,%rbx)
movl $0x747365, 0x7(%rax,%rbx) # imm = 0x747365
movq %rbx, -0x78(%rbp)
movq %rbx, %rdi
callq 0x320a
leaq -0xa8(%rbp), %rdx
movq %rax, (%rdx)
leaq 0x26d3(%rip), %rsi      # 0x4191
movq %rax, -0x88(%rbp)
movq %rax, %rdi
callq 0x1290
leaq -0xa0(%rbp), %rbx
movq %rax, (%rbx)
leaq 0x27b8(%rip), %r14      # 0x4296
movq %rax, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x1290
movq (%rbx), %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x1290
movq %rax, %r14
movq %r12, %rdi
callq 0x10b0
movq %rsp, %r15
addq $0x73, %rax
andq $-0x10, %rax
subq %rax, %r15
movq %r15, %rsp
movq %r15, %rdi
movq %r12, %rsi
callq 0x1150
movq %r15, %rdi
callq 0x10b0
movabsq $0x79726f747369482f, %rcx # imm = 0x79726F747369482F
movq %rcx, (%rax,%r15)
movb $0x0, 0x8(%rax,%r15)
movq %r15, %rdi
callq 0x10b0
movw $0x2f, (%rax,%r15)
movq %r15, %rdi
callq 0x1210
movq %rax, -0x80(%rbp)
testq %rax, %rax
jne 0x1b6a
movq %r15, %rdi
movl $0x1ff, %esi            # imm = 0x1FF
callq 0x10c0
leaq 0x2961(%rip), %rsi      # 0x44d2
leaq -0x500(%rbp), %rbx
movq %rbx, %rdi
movq %r12, %rdx
movq %r14, %rcx
xorl %eax, %eax
callq 0x1060
movq %rbx, %rdi
callq 0x1130
leaq 0x2949(%rip), %rsi      # 0x44e0
movq %rbx, %rdi
movq %r14, %rdx
movq %r15, %rcx
xorl %eax, %eax
callq 0x1060
movq %rbx, %rdi
callq 0x1130
movq %r14, %rdi
callq 0x1250
leal 0x1(%rax), %ebx
leaq -0x490(%rbp), %r14
movl $0x3e8, %edx            # imm = 0x3E8
movq %r14, %rdi
xorl %esi, %esi
callq 0x10d0
leaq 0x2912(%rip), %rsi      # 0x44e9
movq %r14, %rdi
movl %ebx, %edx
xorl %eax, %eax
callq 0x1060
movq -0x90(%rbp), %r14
leaq 0x1(%r14), %rax
xorl %r12d, %r12d
movq %r14, -0x50(%rbp)
movq %rax, -0x48(%rbp)
movslq %r12d, %r15
movb (%r14,%r15), %bl
testb %bl, %bl
je 0x1f8e
movq %r14, %rdi
callq 0x10b0
movq -0x48(%rbp), %rcx
cmpq %r15, %rax
jb 0x1f8e
leal 0x2(%r12), %r13d
addl $0x4, %r12d
leaq -0x6a(%rbp), %rax
cmpb $0x26, %bl
je 0x1c43
movb %bl, (%rax)
incl %r13d
movb (%rcx,%r15), %bl
incq %r15
incq %rax
incl %r12d
jmp 0x1c2a
leaq -0x6a(%rbp), %rdi
callq 0x1250
movl %eax, %r14d
movq %rsp, -0x40(%rbp)
leal 0x1(%r14), %eax
movq %rsp, %rdi
leaq 0xf(%rax), %rcx
andq $-0x10, %rcx
subq %rcx, %rdi
movq %rdi, -0x30(%rbp)
movq %rdi, %rsp
movslq %eax, %rdx
xorl %ebx, %ebx
xorl %esi, %esi
callq 0x10d0
movq -0x30(%rbp), %rdx
testl %r14d, %r14d
cmovlel %ebx, %r14d
addq -0x48(%rbp), %r15
xorl %eax, %eax
cmpq %rax, %r14
je 0x1c9f
movb (%r15,%rax), %cl
movb %cl, (%rdx,%rax)
incq %rax
decl %ebx
incl %r12d
jmp 0x1c89
subl %ebx, %r13d
movslq %r13d, %r13
leaq -0x65(%rbp), %rax
movq -0x50(%rbp), %rdx
movb (%rdx,%r13), %cl
cmpb $0x26, %cl
je 0x1cc3
movb %cl, (%rax)
incq %r13
incq %rax
incl %r12d
jmp 0x1cad
leaq -0x65(%rbp), %rdi
callq 0x1250
movl %eax, %r14d
leal 0x1(%r14), %eax
movq %rsp, %r15
leaq 0xf(%rax), %rcx
andq $-0x10, %rcx
subq %rcx, %r15
movq %r15, %rsp
movslq %eax, %rdx
movq %r15, %rdi
xorl %esi, %esi
callq 0x10d0
movq -0x30(%rbp), %rdi
testl %r14d, %r14d
movl $0x0, %eax
cmovlel %eax, %r14d
addq -0x48(%rbp), %r13
xorl %eax, %eax
cmpq %rax, %r14
je 0x1d1d
movb (%r13,%rax), %cl
movb %cl, (%r15,%rax)
incq %rax
incl %r12d
jmp 0x1d07
movzbl (%rdi), %ebx
callq 0x10b0
movq %rax, %r13
movq %rsp, -0x58(%rbp)
leaq 0x1(%rax), %rdx
movq %rsp, %r14
addq $0x10, %rax
andq $-0x10, %rax
subq %rax, %r14
movq %r14, %rsp
movq %r14, %rdi
xorl %esi, %esi
callq 0x10d0
pushq $0x1
popq %rax
cmpl $0x41, %ebx
je 0x1dc0
cmpl $0x44, %ebx
jne 0x1e3c
movq -0x40(%rbp), %r15
movq -0x30(%rbp), %rdx
cmpq %rax, %r13
jbe 0x1d76
movb (%rdx,%rax), %cl
movb %cl, -0x1(%r14,%rax)
incq %rax
jmp 0x1d64
movb $0x0, (%r14,%rax)
movq %r14, %rdi
callq 0x10b0
movq %rsp, %rcx
addq $0x17, %rax
andq $-0x10, %rax
movq %rcx, %rbx
subq %rax, %rbx
movq %rbx, %rsp
negq %rax
movabsq $0x2066722d206d72, %rdx # imm = 0x2066722D206D72
movq %rdx, (%rcx,%rax)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1270
movq %rbx, %rdi
callq 0x1130
jmp 0x1f7e
movq -0x30(%rbp), %rdx
cmpq %rax, %r13
jbe 0x1dd6
movb (%rdx,%rax), %cl
movb %cl, -0x1(%r14,%rax)
incq %rax
jmp 0x1dc4
movb $0x0, (%r14,%rax)
movq %r14, %rdi
pushq $0x41
popq %rsi
movl $0x1ff, %edx            # imm = 0x1FF
xorl %eax, %eax
callq 0x1100
movl %eax, %ebx
movq %r15, %rdi
callq 0x10b0
movl %ebx, %edi
movq %r15, %rsi
movq %rax, %rdx
callq 0x10a0
movl %ebx, %edi
callq 0x12b0
leaq -0x490(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1270
movq %rbx, %rdi
callq 0x10b0
movabsq $0x3a487e303a567e, %rcx # imm = 0x3A487E303A567E
movq %rcx, -0x490(%rbp,%rax)
jmp 0x1f55
movq -0x30(%rbp), %rdx
cmpq %rax, %r13
jbe 0x1e52
movb (%rdx,%rax), %cl
movb %cl, -0x1(%r14,%rax)
incq %rax
jmp 0x1e40
movb $0x0, (%r14,%rax)
movq %r14, %rdi
pushq $0x41
popq %rsi
movl $0x1ff, %edx            # imm = 0x1FF
xorl %eax, %eax
callq 0x1100
movl %eax, %ebx
movq %r15, %rdi
callq 0x10b0
movl %ebx, %edi
movq %r15, %rsi
movq %rax, %rdx
callq 0x10a0
movl %ebx, %edi
callq 0x12b0
movq -0x78(%rbp), %rdi
callq 0x320a
movq %rax, %rdi
movq %r14, %rsi
callq 0x1070
movq %rax, -0x60(%rbp)
movq %rax, %rdi
leaq 0x245f(%rip), %rbx      # 0x4308
movq %rbx, %rsi
leaq -0x60(%rbp), %r13
movq %r13, %rdx
callq 0x1290
movq -0x60(%rbp), %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x1290
movq %rax, -0x60(%rbp)
movq %rax, %rdi
leaq 0x261a(%rip), %rbx      # 0x44ef
movq %rbx, %rsi
movq %r13, %rdx
callq 0x1290
movq -0x60(%rbp), %rdi
movq %rbx, %rsi
movq %r13, %rdx
callq 0x1290
movq %rax, %rdi
callq 0x1250
leal 0x1(%rax), %edx
leaq -0x95(%rbp), %r13
movq %r13, %rdi
leaq 0x23fa(%rip), %rsi      # 0x4305
xorl %eax, %eax
callq 0x1060
leaq -0x490(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1270
movq %rbx, %rdi
callq 0x10b0
movl $0x3a567e, -0x490(%rbp,%rax) # imm = 0x3A567E
movq %rbx, %rdi
movq %r13, %rsi
callq 0x1270
movq %rbx, %rdi
callq 0x10b0
movl $0x3a487e, -0x490(%rbp,%rax) # imm = 0x3A487E
movq %r15, %rdi
callq 0x3292
movq %rbx, %rdi
movq %rax, %rsi
callq 0x1270
movq %rbx, %rdi
callq 0x10b0
movw $0xa, -0x490(%rbp,%rax)
movq -0x40(%rbp), %r15
movq -0x58(%rbp), %rsp
movq %r15, %rsp
movq -0x50(%rbp), %r14
jmp 0x1bf9
movq -0x78(%rbp), %rdi
movl $0x201, %esi            # imm = 0x201
xorl %eax, %eax
callq 0x1100
movl %eax, %ebx
leaq -0x490(%rbp), %r14
movq %r14, %rdi
callq 0x10b0
movl %ebx, %edi
movq %r14, %rsi
movq %rax, %rdx
callq 0x10a0
movq -0x88(%rbp), %rdi
callq 0x1190
movq -0x80(%rbp), %rdi
callq 0x1260
leaq 0x2519(%rip), %rsi      # 0x44f1
pushq $0x10
popq %rdx
movl -0x34(%rbp), %edi
callq 0x10a0
leaq 0x4196(%rip), %rdi      # 0x6180
callq 0x1110
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq