// File: jorbs[P]stellar-keypair-tool/./lib/basen.h
// Function: void bn::impl::encode<bn::impl::b32_conversion_traits, __gnu_cxx::__normal_iterator<unsigned char const*, std::vector<unsigned char, std::allocator<unsigned char>>>, std::back_insert_iterator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>(__gnu_cxx::__normal_iterator<unsigned char const*, std::vector<unsigned char, std::allocator<unsigned char>>>, __gnu_cxx::__normal_iterator<unsigned char const*, std::vector<unsigned char, std::allocator<unsigned char>>>, std::back_insert_iterator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>)
void encode(Iter1 start, Iter1 end, Iter2 out)
{
    Iter1 iter = start;
    int start_bit = 0;
    bool has_backlog = false;
    char backlog = 0;

    while (has_backlog || iter != end) {
        if (!has_backlog) {
            if (start_bit + ConversionTraits::group_length() < 8) {
                // the value fits within single byte, so we can extract it
                // directly
                char v = extract_partial_bits(*iter, start_bit, ConversionTraits::group_length());
                *out++ = ConversionTraits::encode(v);
                // since we know that start_bit + ConversionTraits::group_length() < 8 we don't need to go
                // to the next byte
                start_bit += ConversionTraits::group_length();
            }
            else {
                // our bits are spanning across byte border; we need to keep the
                // starting point and move over to next byte.
                backlog = *iter++;
                has_backlog = true;
            }
        }
        else {
            // encode value which is made from bits spanning across byte
            // boundary
            char v = extract_overlapping_bits(backlog, (iter != end) ? *iter : 0, start_bit, ConversionTraits::group_length());
            *out++ = ConversionTraits::encode(v);
            has_backlog = false;
            start_bit = (start_bit + ConversionTraits::group_length()) % 8;
        }
    }
    while (start_bit != 0)
    {
        *out++ = '=';
        start_bit = (start_bit + ConversionTraits::group_length()) % 8;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movb $0x0, -0x25(%rbp)
movb $0x0, -0x26(%rbp)
movb $0x1, %al
testb $0x1, -0x25(%rbp)
movb %al, -0x59(%rbp)
jne 0x7179
leaq -0x20(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x7340
movb %al, -0x59(%rbp)
movb -0x59(%rbp), %al
testb $0x1, %al
jne 0x7185
jmp 0x72e8
testb $0x1, -0x25(%rbp)
jne 0x7235
movl -0x24(%rbp), %eax
movl %eax, -0x60(%rbp)
callq 0x7380
movl %eax, %ecx
movl -0x60(%rbp), %eax
addl %ecx, %eax
cmpl $0x8, %eax
jge 0x720f
leaq -0x20(%rbp), %rdi
callq 0x7410
movb (%rax), %al
movb %al, -0x61(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x68(%rbp)
callq 0x7380
movl -0x68(%rbp), %esi
movl %eax, %edx
movb -0x61(%rbp), %al
movsbl %al, %edi
callq 0x7390
movb %al, -0x27(%rbp)
movsbl -0x27(%rbp), %edi
callq 0x7430
movb %al, -0x28(%rbp)
leaq -0x18(%rbp), %rdi
xorl %esi, %esi
callq 0x7480
movq %rax, -0x30(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x74a0
movq %rax, %rdi
leaq -0x28(%rbp), %rsi
callq 0x74b0
callq 0x7380
addl -0x24(%rbp), %eax
movl %eax, -0x24(%rbp)
jmp 0x7230
leaq -0x20(%rbp), %rdi
xorl %esi, %esi
callq 0x74f0
movq %rax, -0x38(%rbp)
leaq -0x38(%rbp), %rdi
callq 0x7410
movb (%rax), %al
movb %al, -0x26(%rbp)
movb $0x1, -0x25(%rbp)
jmp 0x72e3
movb -0x26(%rbp), %al
movb %al, -0x69(%rbp)
leaq -0x20(%rbp), %rdi
leaq -0x10(%rbp), %rsi
callq 0x7340
testb $0x1, %al
jne 0x724e
jmp 0x725f
leaq -0x20(%rbp), %rdi
callq 0x7410
movzbl (%rax), %eax
movl %eax, -0x70(%rbp)
jmp 0x7266
xorl %eax, %eax
movl %eax, -0x70(%rbp)
jmp 0x7266
movl -0x70(%rbp), %eax
movb %al, -0x75(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x7c(%rbp)
callq 0x7380
movb -0x69(%rbp), %sil
movl -0x7c(%rbp), %edx
movl %eax, %ecx
movb -0x75(%rbp), %al
movsbl %sil, %edi
movsbl %al, %esi
callq 0x7530
movb %al, -0x39(%rbp)
movsbl -0x39(%rbp), %edi
callq 0x7430
movb %al, -0x3a(%rbp)
leaq -0x18(%rbp), %rdi
xorl %esi, %esi
callq 0x7480
movq %rax, -0x48(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x74a0
movq %rax, %rdi
leaq -0x3a(%rbp), %rsi
callq 0x74b0
movb $0x0, -0x25(%rbp)
movl -0x24(%rbp), %eax
movl %eax, -0x74(%rbp)
callq 0x7380
movl %eax, %ecx
movl -0x74(%rbp), %eax
addl %ecx, %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %edx, -0x24(%rbp)
jmp 0x715e
jmp 0x72ea
cmpl $0x0, -0x24(%rbp)
je 0x7337
movb $0x3d, -0x49(%rbp)
leaq -0x18(%rbp), %rdi
xorl %esi, %esi
callq 0x7480
movq %rax, -0x58(%rbp)
leaq -0x58(%rbp), %rdi
callq 0x74a0
movq %rax, %rdi
leaq -0x49(%rbp), %rsi
callq 0x74b0
movl -0x24(%rbp), %eax
movl %eax, -0x80(%rbp)
callq 0x7380
movl %eax, %ecx
movl -0x80(%rbp), %eax
addl %ecx, %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %edx, -0x24(%rbp)
jmp 0x72ea
addq $0x80, %rsp
popq %rbp
retq