// File: hinrikHelga[P]Botnet/server.cpp
// Function: inputCommand(int, fd_set*, int*, char*)
int inputCommand(int clientSocket, fd_set *openSockets, int *maxfds,
                  char *buffer)
{
  std::vector<std::string> tokens;
  std::string token;

  // Split command from client into tokens for parsing
  std::stringstream stream(buffer);

  while(stream >> token)
      tokens.push_back(token);

  if((tokens[0].compare("ID") == 0) && (tokens.size() == 1))
  {
      send(clientSocket, myName.c_str(), myName.length(), 0);
  }

  if((tokens[0].compare("CONNECT") == 0) && (tokens.size() == 2))
  {
     connectedServers[clientSocket]->name = tokens[1];
  }

  else if((tokens[0].compare("CONNECT_OTHER") == 0) && (tokens.size() == 3))
  {
      int sock, set = 1, count = 1;
      struct addrinfo sk_addr, *svr;


      /* Create the socket. */
      sk_addr.ai_family   = AF_INET;            // IPv4 only addresses
      sk_addr.ai_socktype = SOCK_STREAM;
      sk_addr.ai_flags    = AI_PASSIVE;

      memset(&sk_addr,   0, sizeof(sk_addr));

      if(getaddrinfo(tokens[1].c_str(), tokens[2].c_str(), &sk_addr, &svr) != 0)
      {
          perror("getaddrinfo failed: ");
          exit(0);
      }

      sock = socket(svr->ai_family, svr->ai_socktype, svr->ai_protocol);

      // Connect to the other server.
      if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &set, sizeof(set)) < 0)
      {
          printf("Failed to set SO_REUSEADDR for port %s\n", tokens[2].c_str());
          perror("setsockopt failed: ");
      }

      if(connect(sock, svr->ai_addr, svr->ai_addrlen )< 0)
      {
          printf("Failed to open socket to server: %s\n", tokens[1].c_str());
          perror("Connect failed: ");
          exit(0);
      }

      else
      {
          // Extracting ip address and port number from sk_addr
          u_short portNo;
          struct sockaddr_in *sin = (struct sockaddr_in *) svr-> ai_addr;
          char ipAddress[INET_ADDRSTRLEN];
          portNo = sin->sin_port;
          inet_ntop(AF_INET, &(sin->sin_addr), ipAddress, INET_ADDRSTRLEN);

          printf("The ip address of the new connection is: %s\n", ipAddress);
          printf("The port number of the new connection is: %d\n", portNo);

          return(sock);
      }
  }

  else if(tokens[0].compare("LISTSERVERS") == 0)
  {
      std::cout << "The connected servers are: " << std::endl;
      std::string msg;
      if(connectedServers.empty())
      {
          printf("List is empty");
          exit(0);
      }
      else
      {
        for(auto const& names : connectedServers)
        {
           msg += names.second->name + ",";
           msg += names.second->host_ip + ",";
           msg += names.second->port + ",";
           msg += ";";
        }
        std::cout << msg << std::endl;
        send(clientSocket, msg.c_str(), msg.length()-1, 0);
      }
  }
  else if(tokens[0].compare("LEAVE") == 0)
  {
      // Close the socket, and leave the socket handling
      // code to deal with tidying up connectedServers etc. when
      // select() detects the OS has torn down the connection.

      closeClient(clientSocket, openSockets, maxfds);
  }
  else if(tokens[0].compare("WHO") == 0)
  {
     std::cout << "Who is logged on" << std::endl;
     std::string msg;

     for(auto const& names : connectedServers)
     {
        msg += names.second->name + ",";
     }
     // Reducing the msg length by 1 loses the excess "," - which
     // granted is totally cheating.
     send(clientSocket, msg.c_str(), msg.length()-1, 0);

  }
  // This is slightly fragile, since it's relying on the order
  // of evaluation of the if statement.
  else if((tokens[0].compare("MSG") == 0) && (tokens[1].compare("ALL") == 0))
  {
      std::string msg;
      for(auto i = tokens.begin()+2;i != tokens.end();i++)
      {
          msg += *i + " ";
      }

      for(auto const& pair : connectedServers)
      {
          send(pair.second->sock, msg.c_str(), msg.length(),0);
      }
  }
  else if(tokens[0].compare("MSG") == 0)
  {
      for(auto const& pair : connectedServers)
      {
          if(pair.second->name.compare(tokens[1]) == 0)
          {
              std::string msg;
              for(auto i = tokens.begin()+2;i != tokens.end();i++)
              {
                  msg += *i + " ";
              }
              send(pair.second->sock, msg.c_str(), msg.length(),0);
          }
      }
  }
  else
  {
      std::cout << "Unknown command from client:" << buffer << std::endl;
  }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x580, %rsp            # imm = 0x580
movl %edi, -0x4(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x3cb0
leaq -0x58(%rbp), %rdi
callq 0x2310
movq -0x20(%rbp), %rax
movq %rax, -0x470(%rbp)
leaq -0x201(%rbp), %rdi
movq %rdi, -0x468(%rbp)
callq 0x23b0
movq -0x470(%rbp), %rsi
movq -0x468(%rbp), %rdx
leaq -0x200(%rbp), %rdi
callq 0x2300
jmp 0x28b6
movl $0x10, %edi
movl $0x8, %esi
callq 0x3cd0
movl %eax, -0x474(%rbp)
jmp 0x28cd
movl -0x474(%rbp), %edx
leaq -0x1e0(%rbp), %rdi
leaq -0x200(%rbp), %rsi
callq 0x2380
jmp 0x28e8
leaq -0x200(%rbp), %rdi
callq 0x23f8
leaq -0x201(%rbp), %rdi
callq 0x2270
leaq -0x1e0(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x22d0
movq %rax, -0x480(%rbp)
jmp 0x2919
movq -0x480(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x22c0
movb %al, -0x481(%rbp)
jmp 0x2937
movb -0x481(%rbp), %al
testb $0x1, %al
jne 0x2943
jmp 0x29ae
leaq -0x38(%rbp), %rdi
leaq -0x58(%rbp), %rsi
callq 0x3cf0
jmp 0x2952
jmp 0x2900
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x210(%rbp)
movl %eax, -0x214(%rbp)
jmp 0x2986
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x210(%rbp)
movl %eax, -0x214(%rbp)
leaq -0x200(%rbp), %rdi
callq 0x23f8
leaq -0x201(%rbp), %rdi
callq 0x2270
jmp 0x36e5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x210(%rbp)
movl %eax, -0x214(%rbp)
jmp 0x36d9
leaq -0x38(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3d60
movq %rax, %rdi
leaq 0x46ba(%rip), %rsi      # 0x707f
callq 0x20b0
cmpl $0x0, %eax
jne 0x2a28
leaq -0x38(%rbp), %rdi
callq 0x3d80
cmpq $0x1, %rax
jne 0x2a28
movl -0x4(%rbp), %eax
movl %eax, -0x494(%rbp)
leaq 0x8862(%rip), %rdi      # 0xb250
movq %rdi, -0x4a0(%rbp)
callq 0x2100
movq -0x4a0(%rbp), %rdi
movq %rax, -0x490(%rbp)
callq 0x2350
movl -0x494(%rbp), %edi
movq -0x490(%rbp), %rsi
movq %rax, %rdx
xorl %ecx, %ecx
callq 0x2120
jmp 0x2a26
jmp 0x2a28
leaq -0x38(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3d60
movq %rax, %rdi
leaq 0x4643(%rip), %rsi      # 0x7082
callq 0x20b0
cmpl $0x0, %eax
jne 0x2aa7
leaq -0x38(%rbp), %rdi
callq 0x3d80
cmpq $0x2, %rax
jne 0x2aa7
leaq -0x38(%rbp), %rdi
movl $0x1, %esi
callq 0x3d60
movq %rax, -0x4b0(%rbp)
leaq 0x87ac(%rip), %rdi      # 0xb220
leaq -0x4(%rbp), %rsi
callq 0x3da0
movq %rax, -0x4a8(%rbp)
jmp 0x2a86
movq -0x4b0(%rbp), %rsi
movq -0x4a8(%rbp), %rax
movq (%rax), %rdi
addq $0x8, %rdi
callq 0x2040
jmp 0x2aa2
jmp 0x36d7
leaq -0x38(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3d60
movq %rax, %rdi
leaq 0x45cc(%rip), %rsi      # 0x708a
callq 0x20b0
cmpl $0x0, %eax
jne 0x2d51
leaq -0x38(%rbp), %rdi
callq 0x3d80
cmpq $0x3, %rax
jne 0x2d51
movl $0x1, -0x21c(%rbp)
movl $0x1, -0x220(%rbp)
movl $0x2, -0x24c(%rbp)
movl $0x1, -0x248(%rbp)
movl $0x1, -0x250(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x230(%rbp)
movaps %xmm0, -0x240(%rbp)
movaps %xmm0, -0x250(%rbp)
leaq -0x38(%rbp), %rdi
movq %rdi, -0x4c8(%rbp)
movl $0x1, %esi
callq 0x3d60
movq %rax, %rdi
callq 0x2100
movq -0x4c8(%rbp), %rdi
movq %rax, -0x4c0(%rbp)
movl $0x2, %esi
callq 0x3d60
movq %rax, %rdi
callq 0x2100
movq -0x4c0(%rbp), %rdi
movq %rax, %rsi
leaq -0x250(%rbp), %rdx
leaq -0x258(%rbp), %rcx
callq 0x22b0
movl %eax, -0x4b4(%rbp)
jmp 0x2b8b
movl -0x4b4(%rbp), %eax
cmpl $0x0, %eax
je 0x2bab
leaq 0x44fb(%rip), %rdi      # 0x7098
callq 0x21c0
jmp 0x2ba4
xorl %edi, %edi
callq 0x22a0
movq -0x258(%rbp), %rax
movl 0x4(%rax), %edi
movq -0x258(%rbp), %rax
movl 0x8(%rax), %esi
movq -0x258(%rbp), %rax
movl 0xc(%rax), %edx
callq 0x2090
movl %eax, -0x218(%rbp)
movl -0x218(%rbp), %edi
movl $0x1, %esi
movl $0x2, %edx
leaq -0x21c(%rbp), %rcx
movl $0x4, %r8d
callq 0x23c0
cmpl $0x0, %eax
jge 0x2c34
leaq -0x38(%rbp), %rdi
movl $0x2, %esi
callq 0x3d60
movq %rax, %rdi
callq 0x2100
movq %rax, %rsi
leaq 0x4492(%rip), %rdi      # 0x70ad
xorl %eax, %eax
callq 0x2050
jmp 0x2c24
leaq 0x44aa(%rip), %rdi      # 0x70d5
callq 0x21c0
jmp 0x2c32
jmp 0x2c34
movl -0x218(%rbp), %edi
movq -0x258(%rbp), %rax
movq 0x18(%rax), %rsi
movl 0x10(%rax), %edx
callq 0x21b0
movl %eax, -0x4cc(%rbp)
jmp 0x2c55
movl -0x4cc(%rbp), %eax
cmpl $0x0, %eax
jge 0x2c9e
leaq -0x38(%rbp), %rdi
movl $0x1, %esi
callq 0x3d60
movq %rax, %rdi
callq 0x2100
movq %rax, %rsi
leaq 0x4469(%rip), %rdi      # 0x70e9
xorl %eax, %eax
callq 0x2050
jmp 0x2c89
leaq 0x447e(%rip), %rdi      # 0x710e
callq 0x21c0
jmp 0x2c97
xorl %edi, %edi
callq 0x22a0
movq -0x258(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x268(%rbp)
movq -0x268(%rbp), %rax
movw 0x2(%rax), %ax
movw %ax, -0x25a(%rbp)
movq -0x268(%rbp), %rsi
addq $0x4, %rsi
movl $0x2, %edi
leaq -0x280(%rbp), %rdx
movq %rdx, -0x4d8(%rbp)
movl $0x10, %ecx
callq 0x2260
movq -0x4d8(%rbp), %rsi
leaq 0x4427(%rip), %rdi      # 0x711f
xorl %eax, %eax
callq 0x2050
jmp 0x2d01
movzwl -0x25a(%rbp), %esi
leaq 0x443d(%rip), %rdi      # 0x714c
xorl %eax, %eax
callq 0x2050
jmp 0x2d18
movl -0x218(%rbp), %eax
movl %eax, -0x4dc(%rbp)
leaq -0x1e0(%rbp), %rdi
callq 0x2180
leaq -0x58(%rbp), %rdi
callq 0x23f8
leaq -0x38(%rbp), %rdi
callq 0x4060
movl -0x4dc(%rbp), %eax
addq $0x580, %rsp            # imm = 0x580
popq %rbp
retq
leaq -0x38(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3d60
movq %rax, %rdi
leaq 0x4412(%rip), %rsi      # 0x717a
callq 0x20b0
cmpl $0x0, %eax
jne 0x3015
movq 0x825b(%rip), %rdi      # 0xafd8
leaq 0x4402(%rip), %rsi      # 0x7186
callq 0x2220
movq %rax, -0x4e8(%rbp)
jmp 0x2d92
movq -0x4e8(%rbp), %rdi
movq 0x8220(%rip), %rsi      # 0xafc0
callq 0x2250
jmp 0x2da7
leaq -0x2a0(%rbp), %rdi
callq 0x2310
leaq 0x8466(%rip), %rdi      # 0xb220
callq 0x3e80
testb $0x1, %al
jne 0x2dc5
jmp 0x2df3
leaq 0x43d6(%rip), %rdi      # 0x71a2
xorl %eax, %eax
callq 0x2050
jmp 0x2dd5
xorl %edi, %edi
callq 0x22a0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x210(%rbp)
movl %eax, -0x214(%rbp)
jmp 0x3004
leaq 0x8426(%rip), %rax      # 0xb220
movq %rax, -0x2a8(%rbp)
leaq 0x8418(%rip), %rdi      # 0xb220
callq 0x3b90
movq %rax, -0x2b0(%rbp)
leaq 0x8405(%rip), %rdi      # 0xb220
callq 0x3bc0
movq %rax, -0x2b8(%rbp)
leaq -0x2b0(%rbp), %rdi
leaq -0x2b8(%rbp), %rsi
callq 0x3bf0
testb $0x1, %al
jne 0x2e43
jmp 0x2f75
leaq -0x2b0(%rbp), %rdi
callq 0x3c20
movq %rax, -0x2c0(%rbp)
movq -0x2c0(%rbp), %rax
movq 0x8(%rax), %rsi
addq $0x8, %rsi
leaq 0x4344(%rip), %rdx      # 0x71b0
leaq -0x2e0(%rbp), %rdi
callq 0x3ea0
jmp 0x2e7a
leaq -0x2a0(%rbp), %rdi
leaq -0x2e0(%rbp), %rsi
callq 0x22e0
jmp 0x2e8f
leaq -0x2e0(%rbp), %rdi
callq 0x23f8
movq -0x2c0(%rbp), %rax
movq 0x8(%rax), %rsi
addq $0x28, %rsi
leaq 0x42ff(%rip), %rdx      # 0x71b0
leaq -0x300(%rbp), %rdi
callq 0x3ea0
jmp 0x2ebf
leaq -0x2a0(%rbp), %rdi
leaq -0x300(%rbp), %rsi
callq 0x22e0
jmp 0x2ed4
leaq -0x300(%rbp), %rdi
callq 0x23f8
movq -0x2c0(%rbp), %rax
movq 0x8(%rax), %rax
movzwl 0x48(%rax), %eax
leaq 0x42ba(%rip), %rsi      # 0x71b0
addq %rax, %rsi
leaq -0x2a0(%rbp), %rdi
callq 0x2210
jmp 0x2f07
leaq 0x42a4(%rip), %rsi      # 0x71b2
leaq -0x2a0(%rbp), %rdi
callq 0x2210
jmp 0x2f1c
jmp 0x2f1e
leaq -0x2b0(%rbp), %rdi
callq 0x3c80
jmp 0x2e27
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x210(%rbp)
movl %eax, -0x214(%rbp)
leaq -0x2e0(%rbp), %rdi
callq 0x23f8
jmp 0x3004
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x210(%rbp)
movl %eax, -0x214(%rbp)
leaq -0x300(%rbp), %rdi
callq 0x23f8
jmp 0x3004
movq 0x805c(%rip), %rdi      # 0xafd8
leaq -0x2a0(%rbp), %rsi
callq 0x21e0
movq %rax, -0x4f0(%rbp)
jmp 0x2f91
movq -0x4f0(%rbp), %rdi
movq 0x8021(%rip), %rsi      # 0xafc0
callq 0x2250
jmp 0x2fa6
movl -0x4(%rbp), %eax
movl %eax, -0x4fc(%rbp)
leaq -0x2a0(%rbp), %rdi
movq %rdi, -0x508(%rbp)
callq 0x2100
movq -0x508(%rbp), %rdi
movq %rax, -0x4f8(%rbp)
callq 0x2350
movl -0x4fc(%rbp), %edi
movq -0x4f8(%rbp), %rsi
movq %rax, %rdx
decq %rdx
xorl %ecx, %ecx
callq 0x2120
jmp 0x2ff1
jmp 0x2ff3
leaq -0x2a0(%rbp), %rdi
callq 0x23f8
jmp 0x36d3
leaq -0x2a0(%rbp), %rdi
callq 0x23f8
jmp 0x36d9
leaq -0x38(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3d60
movq %rax, %rdi
leaq 0x4188(%rip), %rsi      # 0x71b4
callq 0x20b0
cmpl $0x0, %eax
jne 0x304d
movl -0x4(%rbp), %edi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x2620
jmp 0x3048
jmp 0x36d1
leaq -0x38(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3d60
movq %rax, %rdi
leaq 0x4156(%rip), %rsi      # 0x71ba
callq 0x20b0
cmpl $0x0, %eax
jne 0x3209
movq 0x7f5f(%rip), %rdi      # 0xafd8
leaq 0x413e(%rip), %rsi      # 0x71be
callq 0x2220
movq %rax, -0x510(%rbp)
jmp 0x308e
movq -0x510(%rbp), %rdi
movq 0x7f24(%rip), %rsi      # 0xafc0
callq 0x2250
jmp 0x30a3
leaq -0x320(%rbp), %rdi
callq 0x2310
leaq 0x816a(%rip), %rax      # 0xb220
movq %rax, -0x328(%rbp)
leaq 0x815c(%rip), %rdi      # 0xb220
callq 0x3b90
movq %rax, -0x330(%rbp)
leaq 0x8149(%rip), %rdi      # 0xb220
callq 0x3bc0
movq %rax, -0x338(%rbp)
leaq -0x330(%rbp), %rdi
leaq -0x338(%rbp), %rsi
callq 0x3bf0
testb $0x1, %al
jne 0x30ff
jmp 0x319c
leaq -0x330(%rbp), %rdi
callq 0x3c20
movq %rax, -0x340(%rbp)
movq -0x340(%rbp), %rax
movq 0x8(%rax), %rsi
addq $0x8, %rsi
leaq 0x4088(%rip), %rdx      # 0x71b0
leaq -0x360(%rbp), %rdi
callq 0x3ea0
jmp 0x3136
leaq -0x320(%rbp), %rdi
leaq -0x360(%rbp), %rsi
callq 0x22e0
jmp 0x314b
leaq -0x360(%rbp), %rdi
callq 0x23f8
leaq -0x330(%rbp), %rdi
callq 0x3c80
jmp 0x30e3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x210(%rbp)
movl %eax, -0x214(%rbp)
jmp 0x31f8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x210(%rbp)
movl %eax, -0x214(%rbp)
leaq -0x360(%rbp), %rdi
callq 0x23f8
jmp 0x31f8
movl -0x4(%rbp), %eax
movl %eax, -0x51c(%rbp)
leaq -0x320(%rbp), %rdi
movq %rdi, -0x528(%rbp)
callq 0x2100
movq -0x528(%rbp), %rdi
movq %rax, -0x518(%rbp)
callq 0x2350
movl -0x51c(%rbp), %edi
movq -0x518(%rbp), %rsi
movq %rax, %rdx
decq %rdx
xorl %ecx, %ecx
callq 0x2120
jmp 0x31e7
leaq -0x320(%rbp), %rdi
callq 0x23f8
jmp 0x36cf
leaq -0x320(%rbp), %rdi
callq 0x23f8
jmp 0x36d9
leaq -0x38(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3d60
movq %rax, %rdi
leaq 0x3faf(%rip), %rsi      # 0x71cf
callq 0x20b0
cmpl $0x0, %eax
jne 0x3434
leaq -0x38(%rbp), %rdi
movl $0x1, %esi
callq 0x3d60
movq %rax, %rdi
leaq 0x3f8d(%rip), %rsi      # 0x71d3
callq 0x20b0
cmpl $0x0, %eax
jne 0x3434
leaq -0x380(%rbp), %rdi
callq 0x2310
leaq -0x38(%rbp), %rdi
callq 0x3f20
movq %rax, -0x390(%rbp)
leaq -0x390(%rbp), %rdi
movl $0x2, %esi
callq 0x3f50
movq %rax, -0x388(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x3fd0
movq %rax, -0x398(%rbp)
leaq -0x388(%rbp), %rdi
leaq -0x398(%rbp), %rsi
callq 0x3f90
testb $0x1, %al
jne 0x32b4
jmp 0x334d
leaq -0x388(%rbp), %rdi
callq 0x4000
movq %rax, %rsi
leaq 0x3de1(%rip), %rdx      # 0x70ab
leaq -0x3b8(%rbp), %rdi
callq 0x3ea0
jmp 0x32d8
leaq -0x380(%rbp), %rdi
leaq -0x3b8(%rbp), %rsi
callq 0x22e0
jmp 0x32ed
leaq -0x3b8(%rbp), %rdi
callq 0x23f8
leaq -0x388(%rbp), %rdi
xorl %esi, %esi
callq 0x4020
movq %rax, -0x3c0(%rbp)
jmp 0x3288
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x210(%rbp)
movl %eax, -0x214(%rbp)
jmp 0x3423
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x210(%rbp)
movl %eax, -0x214(%rbp)
leaq -0x3b8(%rbp), %rdi
callq 0x23f8
jmp 0x3423
leaq 0x7ecc(%rip), %rax      # 0xb220
movq %rax, -0x3c8(%rbp)
leaq 0x7ebe(%rip), %rdi      # 0xb220
callq 0x3b90
movq %rax, -0x3d0(%rbp)
leaq 0x7eab(%rip), %rdi      # 0xb220
callq 0x3bc0
movq %rax, -0x3d8(%rbp)
leaq -0x3d0(%rbp), %rdi
leaq -0x3d8(%rbp), %rsi
callq 0x3bf0
testb $0x1, %al
jne 0x339a
jmp 0x3412
leaq -0x3d0(%rbp), %rdi
callq 0x3c20
movq %rax, -0x3e0(%rbp)
movq -0x3e0(%rbp), %rax
movq 0x8(%rax), %rax
movl (%rax), %eax
movl %eax, -0x534(%rbp)
leaq -0x380(%rbp), %rdi
movq %rdi, -0x540(%rbp)
callq 0x2100
movq -0x540(%rbp), %rdi
movq %rax, -0x530(%rbp)
callq 0x2350
movl -0x534(%rbp), %edi
movq -0x530(%rbp), %rsi
movq %rax, %rdx
xorl %ecx, %ecx
callq 0x2120
jmp 0x33ff
jmp 0x3401
leaq -0x3d0(%rbp), %rdi
callq 0x3c80
jmp 0x3381
leaq -0x380(%rbp), %rdi
callq 0x23f8
jmp 0x36cd
leaq -0x380(%rbp), %rdi
callq 0x23f8
jmp 0x36d9
leaq -0x38(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x3d60
movq %rax, %rdi
leaq 0x3d84(%rip), %rsi      # 0x71cf
callq 0x20b0
cmpl $0x0, %eax
jne 0x367f
leaq 0x7dc0(%rip), %rax      # 0xb220
movq %rax, -0x3e8(%rbp)
leaq 0x7db2(%rip), %rdi      # 0xb220
callq 0x3b90
movq %rax, -0x3f0(%rbp)
leaq 0x7d9f(%rip), %rdi      # 0xb220
callq 0x3bc0
movq %rax, -0x3f8(%rbp)
leaq -0x3f0(%rbp), %rdi
leaq -0x3f8(%rbp), %rsi
callq 0x3bf0
testb $0x1, %al
jne 0x34a9
jmp 0x367d
leaq -0x3f0(%rbp), %rdi
callq 0x3c20
movq %rax, -0x400(%rbp)
movq -0x400(%rbp), %rax
movq 0x8(%rax), %rax
addq $0x8, %rax
movq %rax, -0x550(%rbp)
leaq -0x38(%rbp), %rdi
movl $0x1, %esi
callq 0x3d60
movq -0x550(%rbp), %rdi
movq %rax, %rsi
callq 0x2030
movl %eax, -0x544(%rbp)
jmp 0x34f7
movl -0x544(%rbp), %eax
cmpl $0x0, %eax
jne 0x366a
leaq -0x420(%rbp), %rdi
callq 0x2310
leaq -0x38(%rbp), %rdi
callq 0x3f20
movq %rax, -0x430(%rbp)
leaq -0x430(%rbp), %rdi
movl $0x2, %esi
callq 0x3f50
movq %rax, -0x428(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x3fd0
movq %rax, -0x438(%rbp)
leaq -0x428(%rbp), %rdi
leaq -0x438(%rbp), %rsi
callq 0x3f90
testb $0x1, %al
jne 0x3566
jmp 0x35fc
leaq -0x428(%rbp), %rdi
callq 0x4000
movq %rax, %rsi
leaq 0x3b2f(%rip), %rdx      # 0x70ab
leaq -0x458(%rbp), %rdi
callq 0x3ea0
jmp 0x358a
leaq -0x420(%rbp), %rdi
leaq -0x458(%rbp), %rsi
callq 0x22e0
jmp 0x359f
leaq -0x458(%rbp), %rdi
callq 0x23f8
leaq -0x428(%rbp), %rdi
xorl %esi, %esi
callq 0x4020
movq %rax, -0x460(%rbp)
jmp 0x353a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x210(%rbp)
movl %eax, -0x214(%rbp)
jmp 0x365c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x210(%rbp)
movl %eax, -0x214(%rbp)
leaq -0x458(%rbp), %rdi
callq 0x23f8
jmp 0x365c
movq -0x400(%rbp), %rax
movq 0x8(%rax), %rax
movl (%rax), %eax
movl %eax, -0x55c(%rbp)
leaq -0x420(%rbp), %rdi
movq %rdi, -0x568(%rbp)
callq 0x2100
movq -0x568(%rbp), %rdi
movq %rax, -0x558(%rbp)
callq 0x2350
movl -0x55c(%rbp), %edi
movq -0x558(%rbp), %rsi
movq %rax, %rdx
xorl %ecx, %ecx
callq 0x2120
jmp 0x364e
leaq -0x420(%rbp), %rdi
callq 0x23f8
jmp 0x366a
leaq -0x420(%rbp), %rdi
callq 0x23f8
jmp 0x36d9
jmp 0x366c
leaq -0x3f0(%rbp), %rdi
callq 0x3c80
jmp 0x348d
jmp 0x36cb
movq 0x7952(%rip), %rdi      # 0xafd8
leaq 0x3b4a(%rip), %rsi      # 0x71d7
callq 0x2220
movq %rax, -0x570(%rbp)
jmp 0x369b
movq -0x570(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x2220
movq %rax, -0x578(%rbp)
jmp 0x36b4
movq -0x578(%rbp), %rdi
movq 0x78fe(%rip), %rsi      # 0xafc0
callq 0x2250
jmp 0x36c9
jmp 0x36cb
jmp 0x36cd
jmp 0x36cf
jmp 0x36d1
jmp 0x36d3
jmp 0x36d5
jmp 0x36d7
ud2
leaq -0x1e0(%rbp), %rdi
callq 0x2180
leaq -0x58(%rbp), %rdi
callq 0x23f8
leaq -0x38(%rbp), %rdi
callq 0x4060
movq -0x210(%rbp), %rdi
callq 0x23a0
nopw %cs:(%rax,%rax)