// File: jorbs[P]stellar-keypair-tool/keypair.cpp
// Function: process(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, bool (*)(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&))
void process(const std::string &term, bool (*matches)(const std::string &input, const std::string &suffix)) {
  std::vector<uint8_t> pk(crypto_sign_PUBLICKEYBYTES);
  std::vector<uint8_t> sk(crypto_sign_SECRETKEYBYTES);

  for (;!found; count++) {
    crypto_sign_keypair(pk.data(), sk.data());

    std::string encodedPk = encode(PUBLIC_KEY, pk);

    if (matches(encodedPk, term)) {
      std::vector<uint8_t> seed(crypto_sign_SEEDBYTES);

      crypto_sign_ed25519_sk_to_seed(seed.data(), sk.data());

      if (!found) {
        found = true;
        std::cout << "FOUND!\n\n"
                  << encodedPk << std::endl
                  << encode(SEED, seed) << "\n\n\a";
      }

      break;
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x29(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x46f0
movq -0xd8(%rbp), %rdx
leaq -0x28(%rbp), %rdi
movl $0x20, %esi
callq 0x4710
jmp 0x38ba
leaq -0x29(%rbp), %rdi
callq 0x4780
leaq -0x59(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x46f0
movq -0xe0(%rbp), %rdx
leaq -0x58(%rbp), %rdi
movl $0x40, %esi
callq 0x4710
jmp 0x38ea
leaq -0x59(%rbp), %rdi
callq 0x4780
leaq 0xa956(%rip), %rdi      # 0xe250
callq 0x47a0
xorb $-0x1, %al
testb $0x1, %al
jne 0x390a
jmp 0x3bb9
leaq -0x28(%rbp), %rdi
callq 0x4500
movq %rax, -0xe8(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x4500
movq -0xe8(%rbp), %rdi
movq %rax, %rsi
callq 0x3180
jmp 0x3934
movb $0x30, -0x81(%rbp)
leaq -0x80(%rbp), %rdi
leaq -0x81(%rbp), %rsi
leaq -0x28(%rbp), %rdx
callq 0x36d0
jmp 0x3951
movq -0x10(%rbp), %rax
movq -0x8(%rbp), %rsi
leaq -0x80(%rbp), %rdi
callq *%rax
movb %al, -0xe9(%rbp)
jmp 0x3967
movb -0xe9(%rbp), %al
testb $0x1, %al
jne 0x3976
jmp 0x3b78
leaq -0xa1(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0x46f0
movq -0xf8(%rbp), %rdx
leaq -0xa0(%rbp), %rdi
movl $0x20, %esi
callq 0x4710
jmp 0x39a3
leaq -0xa1(%rbp), %rdi
callq 0x4780
leaq -0xa0(%rbp), %rdi
callq 0x4500
movq %rax, -0x100(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x4500
movq -0x100(%rbp), %rdi
movq %rax, %rsi
callq 0x3310
jmp 0x39dc
leaq 0xa86d(%rip), %rdi      # 0xe250
callq 0x47a0
testb $0x1, %al
jne 0x3b52
leaq 0xa859(%rip), %rdi      # 0xe250
movl $0x1, %esi
callq 0x4830
movq 0xa5c0(%rip), %rdi      # 0xdfc8
leaq 0x569f(%rip), %rsi      # 0x90ae
callq 0x3200
movq %rax, -0x108(%rbp)
jmp 0x3a1d
movq -0x108(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x31c0
movq %rax, -0x110(%rbp)
jmp 0x3a36
movq -0x110(%rbp), %rdi
movq 0xa55c(%rip), %rsi      # 0xdfa0
callq 0x3240
movq %rax, -0x118(%rbp)
jmp 0x3a52
movb $-0x70, -0xc9(%rbp)
leaq -0xc8(%rbp), %rdi
leaq -0xc9(%rbp), %rsi
leaq -0xa0(%rbp), %rdx
callq 0x36d0
jmp 0x3a75
movq -0x118(%rbp), %rdi
leaq -0xc8(%rbp), %rsi
callq 0x31c0
movq %rax, -0x120(%rbp)
jmp 0x3a91
movq -0x120(%rbp), %rdi
leaq 0x5618(%rip), %rsi      # 0x90b7
callq 0x3200
jmp 0x3aa6
leaq -0xc8(%rbp), %rdi
callq 0x3418
jmp 0x3b52
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x29(%rbp), %rdi
callq 0x4780
jmp 0x3be6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x59(%rbp), %rdi
callq 0x4780
jmp 0x3bdd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x3bd4
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x3bae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xa1(%rbp), %rdi
callq 0x4780
jmp 0x3bae
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x3b6a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xc8(%rbp), %rdi
callq 0x3418
jmp 0x3b6a
movl $0x2, -0xd0(%rbp)
leaq -0xa0(%rbp), %rdi
callq 0x4690
jmp 0x3b82
leaq -0xa0(%rbp), %rdi
callq 0x4690
jmp 0x3bae
movl $0x0, -0xd0(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x3418
movl -0xd0(%rbp), %eax
testl %eax, %eax
je 0x3b99
jmp 0x3b97
jmp 0x3bb9
jmp 0x3b9b
leaq 0xa6b2(%rip), %rdi      # 0xe254
xorl %esi, %esi
callq 0x4860
jmp 0x38f3
leaq -0x80(%rbp), %rdi
callq 0x3418
jmp 0x3bd4
leaq -0x58(%rbp), %rdi
callq 0x4690
leaq -0x28(%rbp), %rdi
callq 0x4690
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
leaq -0x58(%rbp), %rdi
callq 0x4690
leaq -0x28(%rbp), %rdi
callq 0x4690
movq -0x38(%rbp), %rdi
callq 0x3390
nop