// File: /workspace/github_c_makefile_star2_O1/stfwi[P]duktape-cc/build/duktape/mod/ext/app_attachment/././app_attachment.hh
// Function: int sw::util::detail::basic_executable_attachment<void>::patch_application<void>(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
static inline int patch_application(std::string path, bool verbose=false, std::string attachment_contents="")
    {
      using namespace std;

      // hexdump
      auto hexdump = [](const vector<char>& data, std::ostream& os) {
        size_t n = 0;
        for(auto e:data) {
          if(!(n & 63)) os << "\n" << hex << setw(8) << setfill('0') << n << ": ";
          os << hex << setw(2) << setfill('0') << ((int)(e&0xff));
          ++n;
        }
        os << dec << "\n";
      };

      // file size using stat to double check later read
      size_t filesize = 0;
      {
        struct ::stat st;
        if(::stat(path.c_str(), &st) != 0) {
          cerr << "stat failed for " << path << "\n";
          return 1;
        } else {
          filesize = st.st_size;
          if(verbose) {
            cerr << "File size: " << dec << ((long)filesize) << " (0x" << hex << ((long)filesize) << ")\n";
          }
        }
      }

      // same placeholder as in the application
      vector<char> reverse_boundary_key(256);
      std::copy_n(
        basic_executable_attachment<void>::boundary_marker,
        sizeof(basic_executable_attachment<void>::boundary_marker),
        reverse_boundary_key.begin()
      );

      if(verbose) {
        cerr << "----------------------\n";
        cerr << "reverse_boundary_key:\n";
        hexdump(reverse_boundary_key, cerr);
        cerr << "----------------------\n";
      }

      // Read whole application
      vector<char> contents;
      {
        std::ifstream fis(path.c_str(), std::ios::in|std::ios::binary);
        contents.assign((std::istreambuf_iterator<char>(fis)), std::istreambuf_iterator<char>());
        if(contents.size() != filesize) {
          cerr << "file size mismatch\n"
              << "- file size : " << filesize << "\n"
              << "- file size read: " << contents.size() << "\n";
          return 1;
        }
      }

      if(verbose) {
        std::ofstream fos((path+".unpatched.tmp").c_str(), std::ios::out|std::ios::binary);
        hexdump(contents, fos);
        fos.close();
      }

      // Fill up the file until it has 4k size (app checks the start of each read 4k block to save time).
      while((contents.size() & (4095u)) != 0) contents.push_back(0);
      if(verbose) cerr << "File size after alignment fill: " << dec << ((long)contents.size()) << " (0x" << hex << ((long)contents.size()) << ")\n";

      // Find placeholder
      auto key_patch_position_it = std::search(contents.begin(), contents.end(), reverse_boundary_key.begin(), reverse_boundary_key.end());
      {
        if(key_patch_position_it == contents.end()) {
          cerr << "reverse boundary placeholder not found\n";
          return 1;
        }
        if(verbose) {
          size_t pos = static_cast<size_t>(key_patch_position_it - contents.begin()) / sizeof(decltype(contents)::iterator::difference_type);
          cerr << "Boundary placeholder at: " << pos << "\n";
        }
      }

      // Make random boundary key, check that it is unique in the whole file.
      vector<char> patch_key;
      {
        int retries = 10;
        const std::string ofs = std::string("[<") + std::to_string(long(contents.size())) + ">]";
        while(--retries) {
          patch_key.clear();
          patch_key.reserve(reverse_boundary_key.size());
          default_random_engine rd(std::chrono::high_resolution_clock::now().time_since_epoch().count());
          mt19937 mt(rd());
          uniform_int_distribution<char> db(33, 124);
          while(patch_key.size() < reverse_boundary_key.size()) patch_key.push_back(char(db(mt)));
          reverse(patch_key.begin(), patch_key.end());
          std::copy(ofs.begin(), ofs.end(), patch_key.begin());
          auto check_it = std::search(contents.begin(), contents.end(), patch_key.begin(), patch_key.end());
          auto check_sym = patch_key;
          reverse(check_sym.begin(), check_sym.end());
          if((check_it == contents.end()) && (check_sym != patch_key)) break;
        }
        if(!retries) {
          cerr << "failed to generate collisionless boundary\n";
          return 1;
        }
        if(verbose) {
          cerr << "----------------------\n";
          cerr << "patch key:'" << ofs << "'\n";
          hexdump(patch_key, cerr);
          cerr << "----------------------\n";
        }
      }
      // Patch the placeholder position with the generated key.
      std::copy_n(patch_key.begin(), patch_key.size(), key_patch_position_it);
      // Reverse the key and write it at the end.
      reverse(patch_key.begin(), patch_key.end());
      for(auto e:patch_key) contents.push_back(e);
      if(verbose) cerr << "File size after adding the boundary: " << dec << ((long)contents.size()) << " (0x" << hex << ((long)contents.size()) << ")\n";
      std::ofstream fos(path.c_str(), ofstream::out|ofstream::binary);
      if(!fos.write(contents.data(), contents.size())) { cerr << "failed to write file\n" ; return 1; }
      if(verbose) {
        std::ofstream dump_fos((path+".patched.tmp").c_str(), std::ios::out|std::ios::binary);
        hexdump(contents, dump_fos);
        dump_fos.close();
      }
      if(!attachment_contents.empty()) {
        if(verbose) cerr << "[verb] Attaching " << long(attachment_contents.size()>>10) << "kb data ...\n";
        reverse(patch_key.begin(), patch_key.end());
        const auto wdata = basic_executable_attachment<void>::serialize<vector<char>, string>(attachment_contents, patch_key.data());
        copy(wdata.begin(), wdata.end(), ostreambuf_iterator<char>(fos));
      }
      return 0;
    }

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1678, %rsp           # imm = 0x1678
movq %rdx, %r12
movl %esi, %r13d
movq %rdi, %r14
movq (%rdi), %rdi
leaq -0x1698(%rbp), %rsi
callq 0x2140
movl %eax, %r15d
testl %eax, %eax
movq %r14, -0xb8(%rbp)
je 0x2bf8
movq 0x6437(%rip), %rbx      # 0x8ff0
leaq 0x3531(%rip), %rsi      # 0x60f1
movl $0x10, %edx
movq %rbx, %rdi
callq 0x21c0
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0x21c0
leaq 0x349b(%rip), %rsi      # 0x607e
movl $0x1, %edx
movq %rax, %rdi
callq 0x21c0
xorl %r14d, %r14d
jmp 0x2c8e
movq -0x1668(%rbp), %r14
testb %r13b, %r13b
je 0x2c8e
movq 0x63e1(%rip), %rbx      # 0x8ff0
leaq 0x34ec(%rip), %rsi      # 0x6102
movl $0xb, %edx
movq %rbx, %rdi
callq 0x21c0
movq (%rbx), %rax
movq -0x18(%rax), %rax
movl 0x18(%rbx,%rax), %ecx
andl $-0x4b, %ecx
orl $0x2, %ecx
movl %ecx, 0x18(%rbx,%rax)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2150
movq %rax, %rbx
leaq 0x34c1(%rip), %rsi      # 0x610e
movl $0x4, %edx
movq %rax, %rdi
callq 0x21c0
movq (%rbx), %rax
movq -0x18(%rax), %rax
movl 0x18(%rbx,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x18(%rbx,%rax)
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2150
leaq 0x3492(%rip), %rsi      # 0x6113
movl $0x2, %edx
movq %rax, %rdi
callq 0x21c0
movl $0x1, %ebx
testl %r15d, %r15d
jne 0x38bb
xorps %xmm0, %xmm0
movaps %xmm0, -0xb0(%rbp)
movq $0x0, -0xa0(%rbp)
movl $0x100, %edi            # imm = 0x100
callq 0x2170
movq %rax, -0xb0(%rbp)
leaq 0x100(%rax), %rcx
movq %rcx, -0xa0(%rbp)
movq %rcx, -0xa8(%rbp)
leaq 0x3602(%rip), %rsi      # 0x62e0
movl $0x100, %edx            # imm = 0x100
movq %rax, %rdi
callq 0x2110
testb %r13b, %r13b
je 0x2d4f
movq 0x62f9(%rip), %rdi      # 0x8ff0
leaq 0x3418(%rip), %rsi      # 0x6116
movl $0x17, %edx
callq 0x21c0
movq 0x62e1(%rip), %rdi      # 0x8ff0
leaq 0x3418(%rip), %rsi      # 0x612e
movl $0x16, %edx
callq 0x21c0
movq 0x62c9(%rip), %rdx      # 0x8ff0
leaq -0x29(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x4854
movq 0x62b2(%rip), %rdi      # 0x8ff0
leaq 0x33d1(%rip), %rsi      # 0x6116
movl $0x17, %edx
callq 0x21c0
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
movq -0xb8(%rbp), %rax
movq (%rax), %rsi
leaq -0x1698(%rbp), %rdi
movl $0xc, %edx
callq 0x2290
movq -0x1698(%rbp), %rax
movq -0x18(%rax), %rax
movq -0x15b0(%rbp,%rax), %rsi
leaq -0x50(%rbp), %rdi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
movl $0xffffffff, %r8d       # imm = 0xFFFFFFFF
callq 0x4a68
movq -0x48(%rbp), %rax
subq -0x50(%rbp), %rax
cmpq %r14, %rax
jne 0x309d
leaq -0x1698(%rbp), %rdi
callq 0x2050
leaq -0x300(%rbp), %r14
testb %r13b, %r13b
je 0x2e8b
leaq -0x310(%rbp), %rdi
movq %r14, (%rdi)
movq -0xb8(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
callq 0x3eb6
leaq 0x3385(%rip), %rsi      # 0x617b
leaq -0x310(%rbp), %rdi
callq 0x22a0
movq -0x310(%rbp), %rsi
leaq -0x1698(%rbp), %rdi
movl $0x14, %edx
callq 0x21a0
movq -0x310(%rbp), %rdi
cmpq %r14, %rdi
je 0x2e35
movq -0x300(%rbp), %rsi
incq %rsi
callq 0x2180
leaq -0x29(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x1698(%rbp), %rdx
callq 0x4854
leaq -0x1698(%rbp), %rdi
callq 0x21f0
movq 0x6174(%rip), %rax      # 0x8fd0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x1690(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x1698(%rbp,%rcx)
callq 0x2120
leaq -0x15a0(%rbp), %rdi
callq 0x2090
movq -0x48(%rbp), %rsi
movl -0x50(%rbp), %eax
movl %esi, %ecx
subl %eax, %ecx
testl $0xfff, %ecx            # imm = 0xFFF
je 0x2edd
leaq -0x50(%rbp), %rbx
leaq -0x1698(%rbp), %r14
movb $0x0, -0x1698(%rbp)
cmpq -0x40(%rbp), %rsi
je 0x2ebf
movb $0x0, (%rsi)
incq -0x48(%rbp)
jmp 0x2eca
movq %rbx, %rdi
movq %r14, %rdx
callq 0x500a
movq -0x48(%rbp), %rsi
movl -0x50(%rbp), %eax
movl %esi, %ecx
subl %eax, %ecx
testl $0xfff, %ecx            # imm = 0xFFF
jne 0x2ea9
testb %r13b, %r13b
je 0x2f76
movq 0x6103(%rip), %rbx      # 0x8ff0
leaq 0x3296(%rip), %rsi      # 0x618a
movl $0x20, %edx
movq %rbx, %rdi
callq 0x21c0
movq (%rbx), %rax
movq -0x18(%rax), %rax
movl 0x18(%rbx,%rax), %ecx
andl $-0x4b, %ecx
orl $0x2, %ecx
movl %ecx, 0x18(%rbx,%rax)
movq -0x48(%rbp), %rsi
subq -0x50(%rbp), %rsi
movq %rbx, %rdi
callq 0x2150
movq %rax, %rbx
leaq 0x31de(%rip), %rsi      # 0x610e
movl $0x4, %edx
movq %rax, %rdi
callq 0x21c0
movq (%rbx), %rax
movq -0x18(%rax), %rax
movl 0x18(%rbx,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x18(%rbx,%rax)
movq -0x48(%rbp), %rsi
subq -0x50(%rbp), %rsi
movq %rbx, %rdi
callq 0x2150
leaq 0x31aa(%rip), %rsi      # 0x6113
movl $0x2, %edx
movq %rax, %rdi
callq 0x21c0
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0xb0(%rbp), %rdx
movq -0xa8(%rbp), %rcx
callq 0x54c7
movq %rax, %r14
cmpq -0x48(%rbp), %rax
je 0x3141
testb %r13b, %r13b
je 0x2fe9
movq -0x50(%rbp), %rbx
movq 0x6042(%rip), %rdi      # 0x8ff0
leaq 0x321e(%rip), %rsi      # 0x61d3
movl $0x19, %edx
callq 0x21c0
movq %r14, %rsi
subq %rbx, %rsi
shrq $0x3, %rsi
movq 0x6020(%rip), %rdi      # 0x8ff0
callq 0x20e0
leaq 0x30a2(%rip), %rsi      # 0x607e
movl $0x1, %edx
movq %rax, %rdi
callq 0x21c0
movq %r14, -0xf8(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x70(%rbp)
movq $0x0, -0x60(%rbp)
leaq -0x80(%rbp), %rax
movq %rax, -0x10(%rax)
leaq 0x31df(%rip), %rsi      # 0x61ed
leaq 0x31da(%rip), %rdx      # 0x61ef
leaq -0x90(%rbp), %rdi
callq 0x3f50
movq -0x48(%rbp), %rbx
subq -0x50(%rbp), %rbx
movq %rbx, %r14
negq %r14
cmovsq %rbx, %r14
movl $0x1, %r15d
cmpq $0xa, %r14
jb 0x316c
movl $0x4, %r15d
movabsq $0x346dc5d63886594b, %rsi # imm = 0x346DC5D63886594B
movq %r14, %rcx
cmpq $0x63, %rcx
jbe 0x3163
cmpq $0x3e7, %rcx            # imm = 0x3E7
jbe 0x3169
cmpq $0x2710, %rcx           # imm = 0x2710
jb 0x316c
movq %rcx, %rax
mulq %rsi
shrq $0xb, %rdx
addl $0x4, %r15d
cmpq $0x1869f, %rcx          # imm = 0x1869F
movq %rdx, %rcx
ja 0x3056
addl $-0x3, %r15d
jmp 0x316c
movq 0x5f4c(%rip), %rdi      # 0x8ff0
leaq 0x309a(%rip), %rsi      # 0x6145
movl $0x13, %edx
callq 0x21c0
movq 0x5f34(%rip), %rdi      # 0x8ff0
leaq 0x3096(%rip), %rsi      # 0x6159
movl $0xe, %edx
callq 0x21c0
movq 0x5f1c(%rip), %rdi      # 0x8ff0
movq %r14, %rsi
callq 0x20e0
movq %rax, %rbx
leaq 0x2f98(%rip), %rsi      # 0x607e
movl $0x1, %edx
movq %rax, %rdi
callq 0x21c0
leaq 0x306e(%rip), %rsi      # 0x6168
movl $0x12, %edx
movq %rbx, %rdi
callq 0x21c0
movq -0x48(%rbp), %rsi
subq -0x50(%rbp), %rsi
movq %rbx, %rdi
callq 0x20e0
leaq 0x2f60(%rip), %rsi      # 0x607e
movl $0x1, %edx
movq %rax, %rdi
callq 0x21c0
leaq -0x1698(%rbp), %rdi
callq 0x2050
movl $0x1, %ebx
jmp 0x388b
movl $0x1, %ebx
movq 0x5ea3(%rip), %rdi      # 0x8ff0
leaq 0x3057(%rip), %rsi      # 0x61ab
movl $0x27, %edx
callq 0x21c0
jmp 0x388b
addl $-0x2, %r15d
jmp 0x316c
decl %r15d
movq %r12, -0xc0(%rbp)
shrq $0x3f, %rbx
leal (%rbx,%r15), %esi
leaq -0xd8(%rbp), %r12
movq %r12, -0x10(%r12)
leaq -0xe8(%rbp), %rdi
movl $0x2d, %edx
callq 0x21d0
addq -0xe8(%rbp), %rbx
movq %rbx, %rdi
movl %r15d, %esi
movq %r14, %rdx
callq 0x5627
movq -0x90(%rbp), %rcx
movq -0x88(%rbp), %r8
movq -0xe0(%rbp), %rdx
leaq (%rdx,%r8), %rax
movl $0xf, %esi
leaq -0x80(%rbp), %rdi
cmpq %rdi, %rcx
je 0x31d8
movq -0x80(%rbp), %rsi
cmpq %rsi, %rax
leaq -0x300(%rbp), %r15
jbe 0x31fe
movl $0xf, %esi
cmpq %r12, -0xe8(%rbp)
je 0x31f9
movq -0xd8(%rbp), %rsi
cmpq %rsi, %rax
jbe 0x3213
movq -0xe8(%rbp), %rsi
leaq -0x90(%rbp), %rdi
callq 0x2080
jmp 0x3223
leaq -0xe8(%rbp), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x21b0
leaq -0x1688(%rbp), %rdx
movq %rdx, -0x10(%rdx)
movq (%rax), %rsi
leaq 0x10(%rax), %rcx
cmpq %rcx, %rsi
je 0x324d
movq %rsi, -0x1698(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x1688(%rbp)
jmp 0x3253
movups (%rcx), %xmm0
movups %xmm0, (%rdx)
movq %rax, %rdx
addq $0x8, %rdx
movq 0x8(%rax), %rsi
movq %rsi, -0x1690(%rbp)
movq %rcx, (%rax)
movq $0x0, (%rdx)
movb $0x0, (%rcx)
leaq 0x2f77(%rip), %rsi      # 0x61f0
leaq -0x1698(%rbp), %rdi
callq 0x22a0
movq %r15, -0x310(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x32ae
movq %rdx, -0x310(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x300(%rbp)
jmp 0x32b5
movups (%rcx), %xmm0
movups %xmm0, (%r15)
movq 0x8(%rax), %rdx
movq %rdx, -0x308(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
leaq -0x1688(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x32ee
movq -0x1688(%rbp), %rsi
incq %rsi
callq 0x2180
movq -0xe8(%rbp), %rdi
cmpq %r12, %rdi
je 0x3309
movq -0xd8(%rbp), %rsi
incq %rsi
callq 0x2180
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x3325
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x2180
movl $0xa, %r12d
leaq 0x2ec1(%rip), %rax      # 0x61f3
movq %rax, -0xf0(%rbp)
leaq -0x90(%rbp), %rbx
movl %r13d, -0xc4(%rbp)
decl %r12d
je 0x35cf
movq -0x70(%rbp), %rax
cmpq %rax, -0x68(%rbp)
je 0x335e
movq %rax, -0x68(%rbp)
movq -0xa8(%rbp), %rsi
subq -0xb0(%rbp), %rsi
leaq -0x70(%rbp), %r14
movq %r14, %rdi
callq 0x49c4
leaq -0x1698(%rbp), %r13
callq 0x2030
movq %rax, %rcx
movabsq $0x200000005, %rdx      # imm = 0x200000005
mulq %rdx
movq %rcx, %rax
subq %rdx, %rax
shrq %rax
addq %rdx, %rax
shrq $0x1e, %rax
movq %rax, %rdx
shlq $0x1f, %rdx
subq %rdx, %rax
leaq (%rcx,%rax), %rdx
cmpq $0x1, %rdx
adcq %rcx, %rax
imulq $0x41a7, %rax, %rcx     # imm = 0x41A7
movq %rcx, %rax
movabsq $0x400000008001, %rdx   # imm = 0x400000008001
mulq %rdx
shrl $0xd, %edx
movq %rdx, %rax
shlq $0x1f, %rax
subq %rax, %rdx
addq %rcx, %rdx
movq %rdx, -0x1698(%rbp)
movl $0x1, %eax
movq %rdx, %rcx
shrq $0x1e, %rcx
xorl %edx, %ecx
imull $0x6c078965, %ecx, %edx # imm = 0x6C078965
addl %eax, %edx
movq %rdx, -0x1698(%rbp,%rax,8)
incq %rax
cmpq $0x270, %rax            # imm = 0x270
jne 0x33ec
movq $0x270, -0x318(%rbp) # imm = 0x270
movw $0x7c21, -0x90(%rbp)    # imm = 0x7C21
movq -0x70(%rbp), %rax
movq -0x68(%rbp), %rcx
movq %rcx, %rdx
subq %rax, %rdx
movq -0xa8(%rbp), %rsi
subq -0xb0(%rbp), %rsi
cmpq %rsi, %rdx
jae 0x347c
movq %rbx, %rdi
movq %r13, %rsi
movq %rbx, %rdx
callq 0x56a8
movb %al, -0xe8(%rbp)
movq -0x68(%rbp), %rsi
cmpq -0x60(%rbp), %rsi
je 0x346b
movb %al, (%rsi)
incq -0x68(%rbp)
jmp 0x3424
movq %r14, %rdi
leaq -0xe8(%rbp), %rdx
callq 0x500a
jmp 0x3424
cmpq %rcx, %rax
setne %dl
decq %rcx
cmpq %rax, %rcx
seta %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x34b3
incq %rax
movb -0x1(%rax), %dl
movb (%rcx), %sil
movb %sil, -0x1(%rax)
movb %dl, (%rcx)
decq %rcx
leaq 0x1(%rax), %rdx
cmpq %rcx, %rax
movq %rdx, %rax
jb 0x3498
movq -0x308(%rbp), %rdx
testq %rdx, %rdx
je 0x34cf
movq -0x310(%rbp), %rsi
movq -0x70(%rbp), %rdi
callq 0x2240
movq -0x50(%rbp), %rdi
movq -0x48(%rbp), %rsi
movq -0x70(%rbp), %rdx
movq -0x68(%rbp), %rcx
callq 0x54c7
movq %rax, -0x108(%rbp)
movq -0x68(%rbp), %r13
subq -0x70(%rbp), %r13
movl %r12d, -0xc8(%rbp)
movq %r13, -0x100(%rbp)
je 0x3516
js 0x3b0b
movq %r13, %rdi
callq 0x2170
movq %rax, %r14
jmp 0x3519
xorl %r14d, %r14d
movq -0x70(%rbp), %r15
movq -0x68(%rbp), %r12
movq %r12, %r13
subq %r15, %r13
je 0x3537
movq %r14, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x2240
cmpq %r15, %r12
je 0x3567
leaq (%r14,%r13), %rax
decq %rax
cmpq %r14, %rax
jbe 0x3567
leaq 0x1(%r14), %rcx
movb -0x1(%rcx), %dl
movb (%rax), %sil
movb %sil, -0x1(%rcx)
movb %dl, (%rax)
decq %rax
leaq 0x1(%rcx), %rdx
cmpq %rax, %rcx
movq %rdx, %rcx
jb 0x354c
movq -0x108(%rbp), %rax
cmpq -0x48(%rbp), %rax
je 0x3579
movb $0x1, %r15b
jmp 0x3585
movq -0x70(%rbp), %rsi
cmpq %r15, %rsi
je 0x35b9
xorl %r15d, %r15d
testq %r14, %r14
movl -0xc4(%rbp), %r13d
movl -0xc8(%rbp), %r12d
je 0x35a7
movq %r14, %rdi
movq -0x100(%rbp), %rsi
callq 0x2180
testb %r15b, %r15b
leaq -0x300(%rbp), %r15
jne 0x3347
jmp 0x35d9
cmpq %r15, %r12
je 0x3574
movq %r14, %rdi
movq %r13, %rdx
callq 0x2190
testl %eax, %eax
jne 0x3582
jmp 0x3574
movl $0x2a, %ebx
jmp 0x3660
testb %r13b, %r13b
je 0x3676
movq 0x5a07(%rip), %rdi      # 0x8ff0
leaq 0x2b26(%rip), %rsi      # 0x6116
movl $0x17, %edx
movq %rsi, -0xf0(%rbp)
callq 0x21c0
movq 0x59e8(%rip), %rdi      # 0x8ff0
leaq 0x2c0f(%rip), %rsi      # 0x621e
movl $0xb, %edx
callq 0x21c0
movq -0x310(%rbp), %rsi
movq -0x308(%rbp), %rdx
movq 0x59c2(%rip), %rdi      # 0x8ff0
callq 0x21c0
leaq 0x2a43(%rip), %rsi      # 0x607d
movl $0x2, %edx
movq %rax, %rdi
callq 0x21c0
movl $0x17, %ebx
movq 0x599d(%rip), %rdx      # 0x8ff0
leaq -0x29(%rbp), %rdi
leaq -0x70(%rbp), %rsi
callq 0x4854
movq 0x5989(%rip), %rdi      # 0x8ff0
movq -0xf0(%rbp), %rsi
movq %rbx, %rdx
callq 0x21c0
movq -0x310(%rbp), %rdi
cmpq %r15, %rdi
je 0x3691
movq -0x300(%rbp), %rsi
incq %rsi
callq 0x2180
testl %r12d, %r12d
movq -0xf8(%rbp), %rdi
je 0x3871
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
subq %rsi, %rdx
je 0x36b3
callq 0x2240
movq -0x70(%rbp), %rax
movq -0x68(%rbp), %rcx
cmpq %rcx, %rax
setne %dl
decq %rcx
cmpq %rax, %rcx
seta %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x36f2
incq %rax
movb -0x1(%rax), %dl
movb (%rcx), %sil
movb %sil, -0x1(%rax)
movb %dl, (%rcx)
decq %rcx
leaq 0x1(%rax), %rdx
cmpq %rcx, %rax
movq %rdx, %rax
jb 0x36d7
movq -0x70(%rbp), %r15
movq -0x68(%rbp), %r12
cmpq %r12, %r15
je 0x3738
leaq -0x50(%rbp), %rbx
leaq -0x1698(%rbp), %r14
movb (%r15), %al
movb %al, -0x1698(%rbp)
movq -0x48(%rbp), %rsi
cmpq -0x40(%rbp), %rsi
je 0x3725
movb %al, (%rsi)
incq -0x48(%rbp)
jmp 0x3730
movq %rbx, %rdi
movq %r14, %rdx
callq 0x58e8
incq %r15
cmpq %r12, %r15
jne 0x370a
testb %r13b, %r13b
je 0x37d1
movq 0x58a8(%rip), %rbx      # 0x8ff0
leaq 0x2adb(%rip), %rsi      # 0x622a
movl $0x25, %edx
movq %rbx, %rdi
callq 0x21c0
movq (%rbx), %rax
movq -0x18(%rax), %rax
movl 0x18(%rbx,%rax), %ecx
andl $-0x4b, %ecx
orl $0x2, %ecx
movl %ecx, 0x18(%rbx,%rax)
movq -0x48(%rbp), %rsi
subq -0x50(%rbp), %rsi
movq %rbx, %rdi
callq 0x2150
movq %rax, %rbx
leaq 0x2983(%rip), %rsi      # 0x610e
movl $0x4, %edx
movq %rax, %rdi
callq 0x21c0
movq (%rbx), %rax
movq -0x18(%rax), %rax
movl 0x18(%rbx,%rax), %ecx
andl $-0x4b, %ecx
orl $0x8, %ecx
movl %ecx, 0x18(%rbx,%rax)
movq -0x48(%rbp), %rsi
subq -0x50(%rbp), %rsi
movq %rbx, %rdi
callq 0x2150
leaq 0x294f(%rip), %rsi      # 0x6113
movl $0x2, %edx
movq %rax, %rdi
callq 0x21c0
movq -0xb8(%rbp), %rax
movq (%rax), %rsi
leaq -0x1698(%rbp), %rdi
movl $0x14, %edx
callq 0x21a0
movq -0xc0(%rbp), %r14
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
subq %rsi, %rdx
leaq -0x1698(%rbp), %rdi
callq 0x21e0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
je 0x38cf
movl $0x1, %ebx
movq 0x57c8(%rip), %rdi      # 0x8ff0
leaq 0x2a21(%rip), %rsi      # 0x6250
movl $0x15, %edx
callq 0x21c0
movq 0x5790(%rip), %rax      # 0x8fd0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x1690(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x1698(%rbp,%rcx)
callq 0x2120
leaq -0x15a0(%rbp), %rdi
callq 0x2090
jmp 0x3876
movl $0x1, %ebx
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x388b
movq -0x60(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x38a0
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
movq -0xb0(%rbp), %rdi
testq %rdi, %rdi
je 0x38bb
movq -0xa0(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
movl %ebx, %eax
addq $0x1678, %rsp           # imm = 0x1678
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
testb %r13b, %r13b
je 0x3999
leaq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
movq %rax, (%rdi)
movq -0xb8(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
callq 0x3eb6
leaq 0x2963(%rip), %rsi      # 0x6266
leaq -0x90(%rbp), %rdi
callq 0x22a0
movq -0x90(%rbp), %rsi
leaq -0x310(%rbp), %rdi
movl $0x14, %edx
callq 0x21a0
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x3943
movq -0x80(%rbp), %rsi
incq %rsi
callq 0x2180
leaq -0x29(%rbp), %rdi
leaq -0x50(%rbp), %rsi
leaq -0x310(%rbp), %rdx
callq 0x4854
leaq -0x310(%rbp), %rdi
callq 0x21f0
movq 0x5666(%rip), %rax      # 0x8fd0
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x308(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x310(%rbp,%rcx)
callq 0x2120
leaq -0x218(%rbp), %rdi
callq 0x2090
xorl %ebx, %ebx
cmpq $0x0, 0x8(%r14)
je 0x3839
testb %r13b, %r13b
je 0x39eb
movq 0x563e(%rip), %rdi      # 0x8ff0
leaq 0x28ba(%rip), %rsi      # 0x6273
movl $0x11, %edx
callq 0x21c0
movq 0x8(%r14), %rsi
shrq $0xa, %rsi
movq 0x561e(%rip), %rdi      # 0x8ff0
callq 0x2150
leaq 0x28a7(%rip), %rsi      # 0x6285
movl $0xc, %edx
movq %rax, %rdi
callq 0x21c0
movq -0x70(%rbp), %rax
movq -0x68(%rbp), %rcx
cmpq %rcx, %rax
setne %dl
decq %rcx
cmpq %rax, %rcx
seta %sil
andb %dl, %sil
cmpb $0x1, %sil
jne 0x3a2a
incq %rax
movb -0x1(%rax), %dl
movb (%rcx), %sil
movb %sil, -0x1(%rax)
movb %dl, (%rcx)
decq %rcx
leaq 0x1(%rax), %rdx
cmpq %rcx, %rax
movq %rdx, %rax
jb 0x3a0f
movq -0x70(%rbp), %r12
xorps %xmm0, %xmm0
leaq -0x310(%rbp), %rdi
movaps %xmm0, (%rdi)
movq $0x0, 0x10(%rdi)
movq -0xc0(%rbp), %r14
movq 0x8(%r14), %rsi
callq 0x49c4
cmpq $0x0, 0x8(%r14)
je 0x3ab3
xorl %r13d, %r13d
leaq -0x90(%rbp), %r15
movzbl %r13b, %eax
movb (%r12,%rax), %al
movq (%r14), %rcx
xorb (%rcx,%r13), %al
movb %al, -0x90(%rbp)
movq -0x308(%rbp), %rsi
cmpq -0x300(%rbp), %rsi
je 0x3a94
movb %al, (%rsi)
incq -0x308(%rbp)
jmp 0x3aa3
leaq -0x310(%rbp), %rdi
movq %r15, %rdx
callq 0x500a
incq %r13
movq -0xc0(%rbp), %r14
cmpq 0x8(%r14), %r13
jb 0x3a64
movq -0x310(%rbp), %rsi
movq -0x308(%rbp), %rdx
subq %rsi, %rdx
testq %rdx, %rdx
jle 0x3ae7
movq -0x1698(%rbp), %rax
movq -0x18(%rax), %rax
movq -0x15b0(%rbp,%rax), %rdi
testq %rdi, %rdi
je 0x3ae7
movq (%rdi), %rax
callq *0x60(%rax)
movq -0x310(%rbp), %rdi
testq %rdi, %rdi
je 0x3839
movq -0x300(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
jmp 0x3839
callq 0x20a0
jmp 0x3bec
jmp 0x3b17
movq %rax, %rbx
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x3c0f
movq -0x80(%rbp), %rsi
incq %rsi
jmp 0x3c05
jmp 0x3c0c
jmp 0x3bec
movq %rax, %rbx
leaq -0x310(%rbp), %rdi
callq 0x2210
jmp 0x3c0f
jmp 0x3c3a
jmp 0x3b5f
movq %rax, %rbx
movq -0x310(%rbp), %rdi
cmpq %r14, %rdi
je 0x3c95
movq -0x300(%rbp), %rsi
incq %rsi
jmp 0x3c90
jmp 0x3c46
movq %rax, %rbx
leaq -0x1688(%rbp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x3bad
movq -0x1688(%rbp), %rsi
incq %rsi
callq 0x2180
jmp 0x3bad
movq %rax, %rbx
movq -0xe8(%rbp), %rdi
cmpq %r12, %rdi
je 0x3bcd
movq -0xd8(%rbp), %rsi
incq %rsi
callq 0x2180
jmp 0x3bcd
movq %rax, %rbx
movq -0x90(%rbp), %rdi
leaq -0x80(%rbp), %rax
cmpq %rax, %rdi
je 0x3c80
movq -0x80(%rbp), %rsi
jmp 0x3c78
jmp 0x3c3a
movq %rax, %rbx
movq -0x310(%rbp), %rdi
testq %rdi, %rdi
je 0x3c0f
movq -0x300(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
jmp 0x3c0f
movq %rax, %rbx
leaq -0x1698(%rbp), %rdi
callq 0x2210
jmp 0x3c80
jmp 0x3c46
jmp 0x3c3a
movq %rax, %rbx
leaq -0x1698(%rbp), %rdi
callq 0x2210
jmp 0x3c95
jmp 0x3c62
jmp 0x3c46
jmp 0x3c46
jmp 0x3c46
movq %rax, %rbx
jmp 0x3c80
movq %rax, %rbx
jmp 0x3caa
jmp 0x3c62
movq %rax, %rbx
jmp 0x3c95
movq %rax, %rbx
leaq -0x1698(%rbp), %rdi
callq 0x2050
jmp 0x3c95
jmp 0x3c62
jmp 0x3c62
jmp 0x3c62
movq %rax, %rbx
movq -0x310(%rbp), %rdi
cmpq %r15, %rdi
je 0x3c80
movq -0x300(%rbp), %rsi
incq %rsi
callq 0x2180
movq -0x70(%rbp), %rdi
testq %rdi, %rdi
je 0x3c95
movq -0x60(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
movq -0x50(%rbp), %rdi
testq %rdi, %rdi
je 0x3caa
movq -0x40(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
movq -0xb0(%rbp), %rdi
testq %rdi, %rdi
je 0x3cc5
movq -0xa0(%rbp), %rsi
subq %rdi, %rsi
callq 0x2180
movq %rbx, %rdi
callq 0x2270
nop