// File: /workspace/github_cpp_makefile_star2_O2/PepiJK[P]Mail-Server-Client/src/myserver.cpp
// Function: serverThread(MyHelper, MySocket&, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void serverThread(MyHelper helper, MySocket &serverSocket, int new_socket, string argDir)
{
   string command, buffer;
   do
   {
      command = serverSocket.recvMessage(new_socket);

      if (command == "SEND\n")
      {
         string sender = serverSocket.recvMessage(new_socket);
         string receiver = serverSocket.recvMessage(new_socket);
         string subject = serverSocket.recvMessage(new_socket);
         string message = serverSocket.recvMessage(new_socket);

         // read message part of mail till .\n occours
         while (1)
         {
            buffer = serverSocket.recvMessage(new_socket);
            if (buffer == ".\n")
            {
               break;
            }
            message += buffer;
         }

         // check for length violations, +1 because of \n
         if (sender.length() > 9 || receiver.length() > 9 || subject.length() > 81)
         {
            serverSocket.sendMessage("ERR - sender or reveiver or subject length is too long\0", new_socket);
         }
         else
         {
            // write file with data in directory of user who reveivces the mail
            string fullDir = argDir + '/' + receiver.substr(0, receiver.length() - 1);
            int mailId;

            if (access(fullDir.c_str(), F_OK) == -1)
            {
               mkdir(fullDir.c_str(), 0700);
               cout << "created directory " << fullDir << endl;
            }

            // critical section because filename gets created and saved on disk
            // could otherwise cause one file overwriting the other
            mtx.lock();

            // get number of files in directory, + 1 for new index
            mailId = helper.filesInDirectory(fullDir) + 1;
            string filename = fullDir + '/' + to_string(mailId) + '_' + subject.substr(0, subject.length() - 1) + ".txt";

            // check if filename exists -> increment index till filename is unique
            // it can happend that the filename with the same index and subjects exists when a file before gets deleted
            // solution would be the use of a UUID, however this is not implemented in standard c+++
            // so this rather "ugly" solution is used
            while (1)
            {
               if (helper.fileExists(filename))
               {
                  mailId++;
                  filename = fullDir + '/' + to_string(mailId) + '_' + subject.substr(0, subject.length() - 1) + ".txt";
               }
               else
               {
                  break;
               }
            }

            // create file, write mail data to file
            ofstream file;
            file.open(filename.c_str(), ios::out);
            file << sender + receiver + subject + message + ".\n\0";
            cout << "Mail " << subject.substr(0, subject.length() - 1) << " from user "
                 << sender.substr(0, sender.length() - 1) << " safed to " << filename << endl;
            serverSocket.sendMessage("OK\0", new_socket);
            file.close();
            mtx.unlock();
         }
      }

      else if (command == "LIST\n")
      {
         string user = serverSocket.recvMessage(new_socket);
         string dirPath = argDir + '/' + user.substr(0, user.length() - 1);

         // check if user exists
         if (access(dirPath.c_str(), F_OK) == -1)
         {
            buffer = "0 mails for user " + user;
            serverSocket.sendMessage(buffer.c_str(), new_socket);
         }
         else
         {
            vector<string> mails;

            // get every mail subject from directory and send to client
            mails = helper.subjectsInDirectory(dirPath);
            buffer = to_string(mails.size()) + " mails for user " + user;
            serverSocket.sendMessage(buffer.c_str(), new_socket);

            // at least 1 message lies in direcotry -> send list of messages to client
            if (mails.size() > 0)
            {
               cout << "Sent list of mails from user " << user.substr(0, user.length() - 1) << " to client" << endl;
               for (unsigned int i = 0; i < mails.size(); i++)
               {
                  // check if client is ready to recv message, without this check weird things happen
                  buffer = serverSocket.recvMessage(new_socket);
                  if (buffer == "OK")
                  {
                     serverSocket.sendMessage(mails[i].c_str(), new_socket);
                  }
               }
            }
         }
      }

      else if (command == "READ\n")
      {
         string user = serverSocket.recvMessage(new_socket);
         string mailNumber = serverSocket.recvMessage(new_socket);
         ofstream file;

         user = user.substr(0, user.length() - 1);

         if (helper.stringIsInt(mailNumber))
         {
            unsigned int mailIndex = stoi(mailNumber.substr(0, mailNumber.length() - 1)) - 1;
            string line, fulldir, dirPath = argDir + '/' + user;
            ifstream file;
            vector<string> mails;

            // check if user exists
            if (access(dirPath.c_str(), F_OK) == -1)
            {
               serverSocket.sendMessage("ERR - user does not exist\0", new_socket);
            }
            else
            {
               // get every file from directory
               mails = helper.filenamesInDirecotry(dirPath);

               // check if requested mail actually exists
               if (mailIndex < mails.size())
               {
                  fulldir = dirPath + '/' + mails[mailIndex];
                  mtx.lock();
                  file.open(fulldir.c_str());
                  if (file.is_open())
                  {
                     cout << "Sent email " << mails[mailIndex] << " informaiton from user " << user << " to client" << endl;
                     serverSocket.sendMessage("OK\0", new_socket);
                     while (getline(file, line))
                     {
                        line = line + '\n';
                        // check if client is ready to recv message, without this check weird things happen
                        buffer = serverSocket.recvMessage(new_socket);
                        if (buffer == "OK")
                        {
                           serverSocket.sendMessage(line.c_str(), new_socket);
                        }
                     }
                  }
                  else
                  {
                     serverSocket.sendMessage("ERR - cannot open mail file\0", new_socket);
                  }
                  file.close();
                  mtx.unlock();
               }
               else
               {
                  serverSocket.sendMessage("ERR - mail does not exist\0", new_socket);
               }
            }
         }
         else
         {
            serverSocket.sendMessage("ERR - mail number is not an integer\0", new_socket);
         }
      }

      else if (command == "DEL\n")
      {
         string user = serverSocket.recvMessage(new_socket);
         string mailNumber = serverSocket.recvMessage(new_socket);
         ofstream file;

         user = user.substr(0, user.length() - 1);

         if (helper.stringIsInt(mailNumber))
         {
            unsigned int mailIndex = stoi(mailNumber.substr(0, mailNumber.length() - 1)) - 1;
            string fulldir, dirPath = argDir + '/' + user;
            ifstream file;
            vector<string> mails;

            // check if user exists
            if (access(dirPath.c_str(), F_OK) == -1)
            {
               serverSocket.sendMessage("ERR - user does not exist\0", new_socket);
            }
            else
            {
               // get every file from directory
               mails = helper.filenamesInDirecotry(dirPath);

               // check if requested mail actually exists
               if (mailIndex < mails.size())
               {
                  fulldir = dirPath + '/' + mails[mailIndex];
                  mtx.lock();
                  if (remove(fulldir.c_str()) == 0)
                  {
                     cout << "Deleted mail " + mails[mailIndex] << " from user " << user << endl;
                     serverSocket.sendMessage("OK\0", new_socket);
                  }
                  else
                  {
                     serverSocket.sendMessage("ERR - cannot delete mail\0", new_socket);
                  }
                  mtx.unlock();
               }
               else
               {
                  serverSocket.sendMessage("ERR - mail does not exist\0", new_socket);
               }
            }
         }
         else
         {
            serverSocket.sendMessage("ERR - mail number is not an integer\0", new_socket);
         }
      }

   } while (command != "QUIT\n");
   cout << "Client disconnected" << endl;
   close(new_socket);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x6c8, %rsp            # imm = 0x6C8
movq %rcx, -0xf8(%rbp)
movl %edx, -0x2c(%rbp)
movq %rsi, -0x38(%rbp)
movq %rdi, -0x68(%rbp)
leaq -0x1d0(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
xorl %ecx, %ecx
movb %cl, (%rax)
leaq -0x1b0(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb %cl, (%rax)
leaq -0x1c0(%rbp), %r12
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x4216
leaq -0x1e0(%rbp), %r14
movq %r14, %rdi
movq %rax, %rsi
callq 0x34a0
movq %r14, %rdi
leaq 0x2e55(%rip), %rsi      # 0x7190
callq 0x3d9b
testb %al, %al
je 0x440f
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x4216
leaq -0x6e8(%rbp), %rdi
movq %rax, %rsi
leaq -0x468(%rbp), %rdx
callq 0x3110
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x4216
leaq -0x88(%rbp), %rdi
movq %rax, %rsi
leaq -0x468(%rbp), %rdx
callq 0x3110
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x4216
leaq -0xa8(%rbp), %rdi
movq %rax, %rsi
leaq -0x468(%rbp), %rdx
callq 0x3110
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x4216
leaq -0xc8(%rbp), %rdi
movq %rax, %rsi
leaq -0x468(%rbp), %rdx
callq 0x3110
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x4216
movq %r12, %rdi
movq %rax, %rsi
callq 0x34a0
movq %r12, %rdi
leaq 0x2da5(%rip), %rsi      # 0x7196
callq 0x3d9b
testb %al, %al
jne 0x465f
leaq -0xc8(%rbp), %rdi
movq %r12, %rsi
callq 0x34b0
jmp 0x43d0
movq %r14, %rdi
leaq 0x2da9(%rip), %rsi      # 0x71c2
callq 0x3d9b
testb %al, %al
je 0x498d
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x4216
leaq -0x468(%rbp), %rdi
movq %rax, %rsi
leaq -0x6e8(%rbp), %rdx
callq 0x3110
leaq -0x88(%rbp), %rdi
movq -0xf8(%rbp), %rsi
pushq $0x2f
popq %rdx
callq 0x5a26
movq -0x460(%rbp), %rcx
decq %rcx
leaq -0xa8(%rbp), %r13
movq %r13, %rdi
leaq -0x468(%rbp), %rsi
xorl %edx, %edx
callq 0x32d0
leaq -0x6e8(%rbp), %rdi
leaq -0x88(%rbp), %r14
movq %r14, %rsi
movq %r13, %rdx
callq 0x59b5
movq %r13, %rdi
callq 0x3150
movq %r14, %rdi
callq 0x3150
movq -0x6e8(%rbp), %rdi
xorl %esi, %esi
callq 0x3420
cmpl $-0x1, %eax
je 0x5230
xorps %xmm0, %xmm0
movaps %xmm0, -0x60(%rbp)
andq $0x0, -0x50(%rbp)
leaq -0x4c8(%rbp), %rbx
movq %rbx, %rdi
leaq -0x6e8(%rbp), %rsi
callq 0x3350
movq %r14, %rdi
movq -0x68(%rbp), %rsi
movq %rbx, %rdx
callq 0x3a74
leaq -0x60(%rbp), %rdi
movq %r14, %rsi
callq 0x5e50
movq %r14, %rdi
callq 0x3c16
movq %rbx, %rdi
callq 0x3150
movq -0x58(%rbp), %rsi
subq -0x60(%rbp), %rsi
sarq $0x5, %rsi
leaq -0xc8(%rbp), %r14
movq %r14, %rdi
callq 0x5c04
movq %r13, %rdi
movq %r14, %rsi
leaq 0x2c94(%rip), %rdx      # 0x71c9
callq 0x5a78
leaq -0x88(%rbp), %r14
movq %r14, %rdi
movq %r13, %rsi
leaq -0x468(%rbp), %rdx
callq 0x5b2d
movq %r12, %rdi
movq %r14, %rsi
callq 0x3330
movq %r14, %rdi
callq 0x3150
movq %r13, %rdi
callq 0x3150
leaq -0xc8(%rbp), %rdi
callq 0x3150
movq -0x1c0(%rbp), %rsi
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %edx
callq 0x426c
movq -0x58(%rbp), %rax
cmpq -0x60(%rbp), %rax
je 0x4f3b
movq 0x5a2e(%rip), %rdi      # 0x9fd0
leaq 0x2c31(%rip), %rsi      # 0x71da
callq 0x32a0
movq %rax, %r13
movq -0x460(%rbp), %rcx
decq %rcx
movq %r14, %rdi
leaq -0x468(%rbp), %rsi
xorl %edx, %edx
callq 0x32d0
movq %r13, %rdi
movq %r14, %rsi
callq 0x3260
movq %rax, %rdi
leaq 0x2c17(%rip), %rsi      # 0x71f8
callq 0x32a0
movq %rax, %rdi
callq 0x3180
leaq -0x88(%rbp), %rdi
callq 0x3150
xorl %r14d, %r14d
movl %r14d, %r14d
movq -0x58(%rbp), %rax
subq -0x60(%rbp), %rax
sarq $0x5, %rax
cmpq %r14, %rax
jbe 0x4f3b
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x4216
movq %r12, %rdi
movq %rax, %rsi
callq 0x34a0
movq %r12, %rdi
leaq 0x2bcd(%rip), %rsi      # 0x7203
callq 0x3d9b
testb %al, %al
je 0x465a
movq -0x60(%rbp), %rax
movq %r14, %rcx
shlq $0x5, %rcx
movq (%rax,%rcx), %rsi
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %edx
callq 0x426c
incl %r14d
jmp 0x45fd
cmpq $0x9, -0x6e0(%rbp)
ja 0x4d2a
cmpq $0x9, -0x80(%rbp)
ja 0x4d2a
cmpq $0x52, -0xa0(%rbp)
jae 0x4d2a
leaq -0x468(%rbp), %rdi
movq -0xf8(%rbp), %rsi
pushq $0x2f
popq %rdx
callq 0x5a26
movq -0x80(%rbp), %rcx
decq %rcx
leaq -0x118(%rbp), %rbx
movq %rbx, %rdi
leaq -0x88(%rbp), %rsi
xorl %edx, %edx
callq 0x32d0
leaq -0x60(%rbp), %rdi
leaq -0x468(%rbp), %r14
movq %r14, %rsi
movq %rbx, %rdx
callq 0x59b5
movq %rbx, %rdi
callq 0x3150
movq %r14, %rdi
callq 0x3150
movq -0x60(%rbp), %rdi
xorl %esi, %esi
callq 0x3420
cmpl $-0x1, %eax
jne 0x4726
movq -0x60(%rbp), %rdi
movl $0x1c0, %esi            # imm = 0x1C0
callq 0x3170
movq 0x58ca(%rip), %rdi      # 0x9fd0
leaq 0x2a8c(%rip), %rsi      # 0x7199
callq 0x32a0
movq %rax, %rdi
leaq -0x60(%rbp), %rsi
callq 0x3260
movq %rax, %rdi
callq 0x3180
leaq 0x5b73(%rip), %rdi      # 0xa2a0
callq 0x5a62
leaq -0x260(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x3350
movq -0x68(%rbp), %rdi
leaq -0x260(%rbp), %rbx
movq %rbx, %rsi
callq 0x3940
movl %eax, %r13d
movq %rbx, %rdi
callq 0x3150
leaq -0x140(%rbp), %rdi
leaq -0x60(%rbp), %rsi
pushq $0x2f
popq %rdx
callq 0x5a26
leal 0x1(%r13), %esi
leaq -0x180(%rbp), %rbx
movq %rbx, %rdi
callq 0x5acd
leaq -0xf0(%rbp), %r14
movq %r14, %rdi
leaq -0x140(%rbp), %rsi
movq %rbx, %rdx
callq 0x59b5
leaq -0x160(%rbp), %rdi
movq %r14, %rsi
pushq $0x5f
popq %rdx
callq 0x5aa1
movq -0xa0(%rbp), %rcx
decq %rcx
leaq -0x1a0(%rbp), %rbx
movq %rbx, %rdi
leaq -0xa8(%rbp), %rsi
xorl %edx, %edx
callq 0x32d0
leaq -0x468(%rbp), %r14
movq %r14, %rdi
leaq -0x160(%rbp), %rsi
movq %rbx, %rdx
callq 0x59b5
leaq -0x118(%rbp), %rdi
movq %r14, %rsi
leaq 0x29af(%rip), %rdx      # 0x71ac
callq 0x5a78
movq %r14, %rdi
callq 0x3150
leaq -0x1a0(%rbp), %rdi
callq 0x3150
leaq -0x160(%rbp), %rdi
callq 0x3150
leaq -0xf0(%rbp), %rdi
callq 0x3150
leaq -0x180(%rbp), %rdi
callq 0x3150
leaq -0x140(%rbp), %rdi
callq 0x3150
addl $0x2, %r13d
leaq -0x118(%rbp), %rbx
leaq -0x4e8(%rbp), %r15
movq %r15, %rdi
movq %rbx, %rsi
callq 0x3350
movq -0x68(%rbp), %rdi
movq %r15, %rsi
callq 0x3b5c
movl %eax, %r14d
movq %r15, %rdi
callq 0x3150
testb %r14b, %r14b
je 0x4d42
leaq -0x180(%rbp), %rdi
leaq -0x60(%rbp), %rsi
pushq $0x2f
popq %rdx
callq 0x5a26
leaq -0x1a0(%rbp), %r14
movq %r14, %rdi
movl %r13d, %esi
callq 0x5acd
leaq -0x140(%rbp), %rbx
movq %rbx, %rdi
leaq -0x180(%rbp), %rsi
movq %r14, %rdx
callq 0x59b5
leaq -0xf0(%rbp), %rdi
movq %rbx, %rsi
pushq $0x5f
popq %rdx
callq 0x5aa1
movq -0xa0(%rbp), %rcx
decq %rcx
leaq -0x240(%rbp), %rbx
movq %rbx, %rdi
leaq -0xa8(%rbp), %rsi
xorl %edx, %edx
callq 0x32d0
leaq -0x160(%rbp), %r15
movq %r15, %rdi
leaq -0xf0(%rbp), %rsi
movq %rbx, %rdx
callq 0x59b5
leaq -0x468(%rbp), %r14
movq %r14, %rdi
movq %r15, %rsi
leaq 0x288a(%rip), %rdx      # 0x71ac
callq 0x5a78
leaq -0x118(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x3330
movq %r14, %rdi
callq 0x3150
movq %r15, %rdi
callq 0x3150
leaq -0x240(%rbp), %rdi
callq 0x3150
leaq -0xf0(%rbp), %rdi
callq 0x3150
leaq -0x140(%rbp), %rdi
callq 0x3150
leaq -0x1a0(%rbp), %rdi
callq 0x3150
leaq -0x180(%rbp), %rdi
callq 0x3150
incl %r13d
jmp 0x4851
movq %r14, %rdi
leaq 0x286f(%rip), %rsi      # 0x7206
callq 0x3d9b
testb %al, %al
je 0x4f49
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x4216
leaq -0x88(%rbp), %rdi
movq %rax, %rsi
leaq -0x468(%rbp), %rdx
callq 0x3110
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x4216
leaq -0xa8(%rbp), %rdi
movq %rax, %rsi
leaq -0x468(%rbp), %rdx
callq 0x3110
leaq -0x6e8(%rbp), %rdi
callq 0x3440
movq -0x80(%rbp), %rcx
decq %rcx
leaq -0x468(%rbp), %r14
movq %r14, %rdi
leaq -0x88(%rbp), %r13
movq %r13, %rsi
xorl %edx, %edx
callq 0x32d0
movq %r13, %rdi
movq %r14, %rsi
callq 0x3330
movq %r14, %rdi
callq 0x3150
leaq -0x220(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x3350
movq -0x68(%rbp), %rdi
leaq -0x220(%rbp), %rbx
movq %rbx, %rsi
callq 0x37cc
movl %eax, %r13d
movq %rbx, %rdi
callq 0x3150
testb %r13b, %r13b
je 0x5284
movq -0xa0(%rbp), %rcx
decq %rcx
movq %r14, %rdi
leaq -0xa8(%rbp), %rsi
xorl %edx, %edx
callq 0x32d0
movq %r14, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x3bc3
movl %eax, %r13d
movq %r14, %rdi
callq 0x3150
leaq -0xb8(%rbp), %rax
movq %rax, -0xc8(%rbp)
andq $0x0, -0xc0(%rbp)
xorl %eax, %eax
movb %al, -0xb8(%rbp)
leaq -0x50(%rbp), %rcx
movq %rcx, -0x60(%rbp)
andq $0x0, -0x58(%rbp)
movb %al, -0x50(%rbp)
movq %r14, %rdi
movq -0xf8(%rbp), %rsi
pushq $0x2f
popq %rdx
callq 0x5a26
leaq -0x118(%rbp), %rdi
movq %r14, %rsi
leaq -0x88(%rbp), %rdx
callq 0x5b2d
movq %r14, %rdi
callq 0x3150
movq %r14, %rdi
callq 0x3300
xorps %xmm0, %xmm0
movaps %xmm0, -0x140(%rbp)
andq $0x0, -0x130(%rbp)
movq -0x118(%rbp), %rdi
xorl %esi, %esi
callq 0x3420
leaq 0x278d(%rip), %rsi      # 0x72b0
cmpl $-0x1, %eax
je 0x529c
leaq -0x4a8(%rbp), %r14
movq %r14, %rdi
leaq -0x118(%rbp), %rsi
callq 0x3350
leaq -0x160(%rbp), %rbx
movq %rbx, %rdi
movq -0x68(%rbp), %rsi
movq %r14, %rdx
callq 0x39c4
decl %r13d
leaq -0x140(%rbp), %rdi
movq %rbx, %rsi
callq 0x5e50
movq %rbx, %rdi
callq 0x3c16
movq %r14, %rdi
callq 0x3150
movq -0x138(%rbp), %rax
subq -0x140(%rbp), %rax
movl %r13d, %r13d
sarq $0x5, %rax
leaq 0x2752(%rip), %rsi      # 0x72e8
cmpq %r13, %rax
jbe 0x529c
leaq -0xf0(%rbp), %rbx
movq %rbx, %rdi
leaq -0x118(%rbp), %rsi
pushq $0x2f
popq %rdx
callq 0x5a26
shlq $0x5, %r13
movq -0x140(%rbp), %rdx
addq %r13, %rdx
leaq -0x160(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
callq 0x5b2d
leaq -0x60(%rbp), %rdi
movq %r14, %rsi
callq 0x3330
movq %r14, %rdi
callq 0x3150
movq %rbx, %rdi
callq 0x3150
leaq 0x56a5(%rip), %rdi      # 0xa2a0
callq 0x5a62
movq -0x60(%rbp), %rsi
leaq -0x468(%rbp), %rdi
pushq $0x8
popq %rdx
callq 0x31c0
leaq -0x3f0(%rbp), %rdi
callq 0x3090
testb %al, %al
je 0x52e8
movq 0x53a2(%rip), %rdi      # 0x9fd0
leaq 0x25d7(%rip), %rsi      # 0x720c
callq 0x32a0
addq -0x140(%rbp), %r13
movq %rax, %rdi
movq %r13, %rsi
callq 0x3260
movq %rax, %rdi
leaq 0x25c2(%rip), %rsi      # 0x7218
callq 0x32a0
movq %rax, %rdi
leaq -0x88(%rbp), %rsi
callq 0x3260
movq %rax, %rdi
leaq 0x2584(%rip), %rsi      # 0x71f8
callq 0x32a0
movq %rax, %rdi
callq 0x3180
movq -0x38(%rbp), %rdi
leaq 0x26ba(%rip), %rsi      # 0x7346
movl -0x2c(%rbp), %edx
callq 0x426c
leaq -0x468(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x3070
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x52fb
leaq -0x160(%rbp), %rbx
movq %rbx, %rdi
leaq -0xc8(%rbp), %r14
movq %r14, %rsi
pushq $0xa
popq %rdx
callq 0x5a26
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3330
movq %rbx, %rdi
callq 0x3150
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x4216
movq %r12, %rdi
movq %rax, %rsi
callq 0x34a0
movq %r12, %rdi
leaq 0x24fa(%rip), %rsi      # 0x7203
callq 0x3d9b
testb %al, %al
je 0x4c94
movq -0xc8(%rbp), %rsi
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %edx
callq 0x426c
jmp 0x4c94
movq -0x38(%rbp), %rdi
leaq 0x2543(%rip), %rsi      # 0x7278
movl -0x2c(%rbp), %edx
callq 0x426c
jmp 0x4f0b
leaq -0x468(%rbp), %r14
movq %r14, %rdi
callq 0x3440
movq -0x118(%rbp), %rsi
movq %r14, %rdi
pushq $0x10
popq %rdx
callq 0x3040
leaq -0x180(%rbp), %r14
movq %r14, %rdi
leaq -0x6e8(%rbp), %rsi
leaq -0x88(%rbp), %rdx
callq 0x5b56
leaq -0x140(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
leaq -0xa8(%rbp), %rdx
callq 0x5b2d
leaq -0xf0(%rbp), %r14
movq %r14, %rdi
movq %rbx, %rsi
leaq -0xc8(%rbp), %rdx
callq 0x5b2d
leaq -0x160(%rbp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
leaq 0x257c(%rip), %rdx      # 0x7342
callq 0x5a78
leaq -0x468(%rbp), %rdi
movq %rbx, %rsi
callq 0x3260
movq %rbx, %rdi
callq 0x3150
leaq -0xf0(%rbp), %rdi
callq 0x3150
leaq -0x140(%rbp), %rdi
callq 0x3150
leaq -0x180(%rbp), %rdi
callq 0x3150
movq 0x51c3(%rip), %rdi      # 0x9fd0
leaq 0x239d(%rip), %rsi      # 0x71b1
callq 0x32a0
movq %rax, %r13
movq -0xa0(%rbp), %rcx
decq %rcx
movq %rbx, %rdi
leaq -0xa8(%rbp), %rsi
xorl %edx, %edx
callq 0x32d0
movq %r13, %rdi
movq %rbx, %rsi
callq 0x3260
movq %rax, %rdi
leaq 0x23d8(%rip), %rsi      # 0x7224
callq 0x32a0
movq %rax, %r13
movq -0x6e0(%rbp), %rcx
decq %rcx
leaq -0xf0(%rbp), %rbx
movq %rbx, %rdi
leaq -0x6e8(%rbp), %rsi
xorl %edx, %edx
callq 0x32d0
movq %r13, %rdi
movq %rbx, %rsi
callq 0x3260
movq %rax, %rdi
leaq 0x232c(%rip), %rsi      # 0x71b7
callq 0x32a0
movq %rax, %rdi
leaq -0x118(%rbp), %rsi
callq 0x3260
movq %rax, %rdi
callq 0x3180
leaq -0xf0(%rbp), %rdi
callq 0x3150
leaq -0x160(%rbp), %rdi
callq 0x3150
movq -0x38(%rbp), %rdi
leaq 0x247c(%rip), %rsi      # 0x7346
movl -0x2c(%rbp), %edx
callq 0x426c
leaq -0x468(%rbp), %rdi
callq 0x3360
leaq 0x53bb(%rip), %rdi      # 0xa2a0
callq 0x3200
leaq -0x468(%rbp), %rdi
callq 0x33a0
leaq -0x118(%rbp), %rdi
callq 0x3150
leaq -0x60(%rbp), %rdi
callq 0x3150
leaq -0xc8(%rbp), %rdi
callq 0x3150
leaq -0xa8(%rbp), %rdi
callq 0x3150
leaq -0x88(%rbp), %rdi
callq 0x3150
leaq -0x6e8(%rbp), %rdi
jmp 0x536b
leaq -0x60(%rbp), %rdi
callq 0x3c16
jmp 0x526c
movq %r14, %rdi
leaq 0x22dd(%rip), %rsi      # 0x7230
callq 0x3d9b
testb %al, %al
je 0x5370
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x4216
leaq -0x88(%rbp), %rdi
movq %rax, %rsi
leaq -0x468(%rbp), %rdx
callq 0x3110
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %esi
callq 0x4216
leaq -0xa8(%rbp), %rdi
movq %rax, %rsi
leaq -0x468(%rbp), %rdx
callq 0x3110
leaq -0x6e8(%rbp), %rdi
callq 0x3440
movq -0x80(%rbp), %rcx
decq %rcx
leaq -0x468(%rbp), %r14
movq %r14, %rdi
leaq -0x88(%rbp), %r13
movq %r13, %rsi
xorl %edx, %edx
callq 0x32d0
movq %r13, %rdi
movq %r14, %rsi
callq 0x3330
movq %r14, %rdi
callq 0x3150
leaq -0x200(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x3350
movq -0x68(%rbp), %rdi
leaq -0x200(%rbp), %rbx
movq %rbx, %rsi
callq 0x37cc
movl %eax, %r13d
movq %rbx, %rdi
callq 0x3150
testb %r13b, %r13b
je 0x52aa
movq -0xa0(%rbp), %rcx
decq %rcx
movq %r14, %rdi
leaq -0xa8(%rbp), %rsi
xorl %edx, %edx
callq 0x32d0
movq %r14, %rdi
xorl %esi, %esi
pushq $0xa
popq %rdx
callq 0x3bc3
movl %eax, %r13d
movq %r14, %rdi
callq 0x3150
leaq -0xb8(%rbp), %rax
movq %rax, -0xc8(%rbp)
andq $0x0, -0xc0(%rbp)
movb $0x0, -0xb8(%rbp)
movq %r14, %rdi
movq -0xf8(%rbp), %rsi
pushq $0x2f
popq %rdx
callq 0x5a26
leaq -0x60(%rbp), %rdi
movq %r14, %rsi
leaq -0x88(%rbp), %rdx
callq 0x5b2d
movq %r14, %rdi
callq 0x3150
movq %r14, %rdi
callq 0x3300
xorps %xmm0, %xmm0
movaps %xmm0, -0xf0(%rbp)
andq $0x0, -0xe0(%rbp)
movq -0x60(%rbp), %rdi
xorl %esi, %esi
callq 0x3420
leaq 0x21e8(%rip), %rsi      # 0x72b0
cmpl $-0x1, %eax
je 0x52c2
leaq -0x488(%rbp), %r14
movq %r14, %rdi
leaq -0x60(%rbp), %rsi
callq 0x3350
leaq -0x118(%rbp), %rbx
movq %rbx, %rdi
movq -0x68(%rbp), %rsi
movq %r14, %rdx
callq 0x39c4
decl %r13d
leaq -0xf0(%rbp), %rdi
movq %rbx, %rsi
callq 0x5e50
movq %rbx, %rdi
callq 0x3c16
movq %r14, %rdi
callq 0x3150
movq -0xe8(%rbp), %rax
subq -0xf0(%rbp), %rax
movl %r13d, %r13d
sarq $0x5, %rax
leaq 0x21b0(%rip), %rsi      # 0x72e8
cmpq %r13, %rax
jbe 0x52c2
leaq -0x160(%rbp), %r14
movq %r14, %rdi
leaq -0x60(%rbp), %rsi
pushq $0x2f
popq %rdx
callq 0x5a26
shlq $0x5, %r13
movq -0xf0(%rbp), %rdx
addq %r13, %rdx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x5b2d
leaq -0xc8(%rbp), %rdi
movq %rbx, %rsi
callq 0x3330
movq %rbx, %rdi
callq 0x3150
movq %r14, %rdi
callq 0x3150
leaq 0x510a(%rip), %rdi      # 0xa2a0
callq 0x5a62
movq -0xc8(%rbp), %rdi
callq 0x3480
leaq 0x217a(%rip), %rsi      # 0x7328
testl %eax, %eax
jne 0x5213
addq -0xf0(%rbp), %r13
movq %rbx, %rdi
leaq 0x2072(%rip), %rsi      # 0x7235
movq %r13, %rdx
callq 0x5b8e
movq 0x4dfe(%rip), %rdi      # 0x9fd0
movq %rbx, %rsi
callq 0x3260
movq %rax, %rdi
leaq 0x2040(%rip), %rsi      # 0x7224
callq 0x32a0
movq %rax, %rdi
leaq -0x88(%rbp), %rsi
callq 0x3260
movq %rax, %rdi
callq 0x3180
leaq -0x118(%rbp), %rdi
callq 0x3150
leaq 0x2133(%rip), %rsi      # 0x7346
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %edx
callq 0x426c
leaq 0x507a(%rip), %rdi      # 0xa2a0
callq 0x3200
jmp 0x52ce
movq %r14, %rdi
leaq 0x1f8e(%rip), %rsi      # 0x71c8
leaq -0x468(%rbp), %rdx
callq 0x5b8e
movq %r12, %rdi
movq %r14, %rsi
callq 0x3330
movq %r14, %rdi
callq 0x3150
movq -0x1c0(%rbp), %rsi
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %edx
callq 0x426c
leaq -0x6e8(%rbp), %rdi
callq 0x3150
leaq -0x468(%rbp), %rdi
jmp 0x536b
movq -0x38(%rbp), %rdi
leaq 0x2074(%rip), %rsi      # 0x7303
movl -0x2c(%rbp), %edx
callq 0x426c
jmp 0x534c
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %edx
callq 0x426c
jmp 0x5313
movq -0x38(%rbp), %rdi
leaq 0x204e(%rip), %rsi      # 0x7303
movl -0x2c(%rbp), %edx
callq 0x426c
jmp 0x534c
movq -0x38(%rbp), %rdi
movl -0x2c(%rbp), %edx
callq 0x426c
leaq -0xf0(%rbp), %rdi
callq 0x3c16
leaq -0x468(%rbp), %rdi
callq 0x30b0
jmp 0x5337
movq -0x38(%rbp), %rdi
leaq 0x1fd8(%rip), %rsi      # 0x72cb
movl -0x2c(%rbp), %edx
callq 0x426c
leaq -0x468(%rbp), %rdi
callq 0x3080
leaq 0x4f92(%rip), %rdi      # 0xa2a0
callq 0x3200
leaq -0x140(%rbp), %rdi
callq 0x3c16
leaq -0x468(%rbp), %rdi
callq 0x30b0
leaq -0x118(%rbp), %rdi
callq 0x3150
leaq -0x60(%rbp), %rdi
callq 0x3150
leaq -0xc8(%rbp), %rdi
callq 0x3150
leaq -0x6e8(%rbp), %rdi
callq 0x33a0
leaq -0xa8(%rbp), %rdi
callq 0x3150
leaq -0x88(%rbp), %rdi
callq 0x3150
leaq -0x1e0(%rbp), %rdi
leaq 0x1ec5(%rip), %rsi      # 0x7243
callq 0x3bdf
testb %al, %al
jne 0x4313
movq 0x4c3e(%rip), %rdi      # 0x9fd0
leaq 0x1eb0(%rip), %rsi      # 0x7249
callq 0x32a0
movq %rax, %rdi
callq 0x3180
movl -0x2c(%rbp), %edi
callq 0x34c0
leaq -0x1c0(%rbp), %rdi
callq 0x3150
leaq -0x1e0(%rbp), %rdi
callq 0x3150
addq $0x6c8, %rsp            # imm = 0x6C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5454
movq %rax, %rbx
leaq -0x160(%rbp), %rdi
jmp 0x53fe
jmp 0x5454
movq %rax, %rbx
leaq -0x118(%rbp), %rdi
jmp 0x53fe
movq %rax, %rbx
leaq -0x488(%rbp), %rdi
callq 0x3150
jmp 0x5457
jmp 0x5454
movq %rax, %rbx
leaq -0xf0(%rbp), %rdi
jmp 0x544a
jmp 0x56ff
movq %rax, %rbx
jmp 0x572f
jmp 0x554c
movq %rax, %rbx
leaq -0x468(%rbp), %rdi
jmp 0x572a
jmp 0x5474
jmp 0x54bc
jmp 0x56ff
movq %rax, %rbx
leaq -0x4a8(%rbp), %rdi
callq 0x3150
jmp 0x5702
movq %rax, %rbx
leaq -0xf0(%rbp), %rdi
callq 0x3c16
leaq -0x468(%rbp), %rdi
callq 0x30b0
jmp 0x5726
movq %rax, %rbx
leaq -0x468(%rbp), %rdi
jmp 0x5736
movq %rax, %rbx
leaq -0x200(%rbp), %rdi
jmp 0x5736
jmp 0x554c
jmp 0x575f
movq %rax, %rbx
jmp 0x571a
jmp 0x5506
jmp 0x54e3
movq %rax, %rbx
leaq -0x468(%rbp), %rdi
jmp 0x5721
jmp 0x554c
movq %rax, %rbx
jmp 0x5726
jmp 0x54e3
jmp 0x575f
jmp 0x575f
jmp 0x54d4
jmp 0x554c
movq %rax, %rbx
jmp 0x5773
jmp 0x5767
jmp 0x54e3
movq %rax, %rbx
jmp 0x5753
jmp 0x575f
movq %rax, %rbx
leaq -0x220(%rbp), %rdi
jmp 0x5736
jmp 0x554c
jmp 0x575f
movq %rax, %rbx
jmp 0x5747
movq %rax, %rbx
jmp 0x5531
movq %rax, %rbx
leaq -0x4c8(%rbp), %rdi
jmp 0x568d
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x3150
leaq -0xc8(%rbp), %rdi
jmp 0x568d
jmp 0x5767
jmp 0x5767
jmp 0x56ff
movq %rax, %rbx
jmp 0x573b
movq %rax, %rbx
jmp 0x5568
movq %rax, %rbx
leaq -0x160(%rbp), %rdi
callq 0x3150
leaq -0xf0(%rbp), %rdi
callq 0x3150
jmp 0x557e
jmp 0x5699
movq %rax, %rbx
leaq -0x140(%rbp), %rdi
callq 0x3150
jmp 0x559e
jmp 0x56eb
jmp 0x56eb
jmp 0x57ff
movq %rax, %rbx
leaq -0x180(%rbp), %rdi
jmp 0x56e4
jmp 0x5819
movq %rax, %rbx
jmp 0x5620
movq %rax, %rbx
leaq -0x260(%rbp), %rdi
jmp 0x5809
movq %rax, %rbx
jmp 0x55f7
movq %rax, %rbx
jmp 0x5603
jmp 0x5819
movq %rax, %rbx
leaq -0x468(%rbp), %rdi
callq 0x3150
jmp 0x55eb
movq %rax, %rbx
jmp 0x5640
movq %rax, %rbx
leaq -0x1a0(%rbp), %rdi
callq 0x3150
leaq -0x160(%rbp), %rdi
callq 0x3150
leaq -0xf0(%rbp), %rdi
callq 0x3150
jmp 0x5614
movq %rax, %rbx
leaq -0x180(%rbp), %rdi
callq 0x3150
leaq -0x140(%rbp), %rdi
jmp 0x5809
jmp 0x56c6
movq %rax, %rbx
leaq -0x118(%rbp), %rdi
callq 0x3150
leaq -0x468(%rbp), %rdi
jmp 0x5812
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
callq 0x3150
jmp 0x566d
movq %rax, %rbx
jmp 0x577f
jmp 0x575f
movq %rax, %rbx
leaq -0x88(%rbp), %rdi
jmp 0x577a
jmp 0x575f
jmp 0x5767
movq %rax, %rbx
leaq -0x88(%rbp), %rdi
callq 0x3150
jmp 0x576a
jmp 0x56ff
movq %rax, %rbx
jmp 0x56dd
jmp 0x56a0
movq %rax, %rbx
jmp 0x5828
jmp 0x575f
jmp 0x56be
jmp 0x575f
jmp 0x56b6
movq %rax, %rbx
jmp 0x5840
movq %rax, %rbx
jmp 0x5834
movq %rax, %rbx
jmp 0x580e
movq %rax, %rbx
leaq -0xf0(%rbp), %rdi
callq 0x3150
leaq -0x160(%rbp), %rdi
callq 0x3150
jmp 0x56ee
movq %rax, %rbx
leaq -0x468(%rbp), %rdi
callq 0x33a0
jmp 0x5802
movq %rax, %rbx
leaq -0x140(%rbp), %rdi
callq 0x3c16
leaq -0x468(%rbp), %rdi
callq 0x30b0
leaq -0x118(%rbp), %rdi
callq 0x3150
leaq -0x60(%rbp), %rdi
callq 0x3150
leaq -0xc8(%rbp), %rdi
callq 0x3150
leaq -0x6e8(%rbp), %rdi
callq 0x33a0
leaq -0xa8(%rbp), %rdi
callq 0x3150
leaq -0x88(%rbp), %rdi
jmp 0x5847
movq %rax, %rbx
jmp 0x584c
movq %rax, %rbx
leaq -0x60(%rbp), %rdi
callq 0x3c16
leaq -0x6e8(%rbp), %rdi
callq 0x3150
leaq -0x468(%rbp), %rdi
jmp 0x5847
movq %rax, %rbx
jmp 0x57d9
jmp 0x57ff
movq %rax, %rbx
jmp 0x57c1
movq %rax, %rbx
jmp 0x57cd
movq %rax, %rbx
jmp 0x57e5
movq %rax, %rbx
leaq -0x160(%rbp), %rdi
callq 0x3150
jmp 0x57b5
movq %rax, %rbx
leaq -0x240(%rbp), %rdi
callq 0x3150
leaq -0xf0(%rbp), %rdi
callq 0x3150
leaq -0x140(%rbp), %rdi
callq 0x3150
leaq -0x1a0(%rbp), %rdi
callq 0x3150
leaq -0x180(%rbp), %rdi
callq 0x3150
jmp 0x5802
movq %rax, %rbx
leaq -0x4e8(%rbp), %rdi
jmp 0x57ec
movq %rax, %rbx
leaq -0x118(%rbp), %rdi
callq 0x3150
leaq -0x60(%rbp), %rdi
callq 0x3150
jmp 0x581c
movq %rax, %rbx
leaq -0xc8(%rbp), %rdi
callq 0x3150
leaq -0xa8(%rbp), %rdi
callq 0x3150
leaq -0x88(%rbp), %rdi
callq 0x3150
leaq -0x6e8(%rbp), %rdi
callq 0x3150
leaq -0x1c0(%rbp), %rdi
callq 0x3150
leaq -0x1e0(%rbp), %rdi
callq 0x3150
movq %rbx, %rdi
callq 0x3460