// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
xorl %eax, %eax
xorl %ecx, %ecx
xorl %r12d, %r12d
movsbl %al, %r13d
testb $0x1, %cl
je 0x31aa
cmpq %r14, %r15
je 0x31e5
movb (%r15), %al
jmp 0x31e7
cmpq %r14, %r15
je 0x322c
movb (%r15), %al
cmpl $0x2, %r12d
jg 0x3222
leal 0x5(%r12), %ebp
movsbl %al, %edi
movl %r12d, %esi
pushq $0x5
popq %rdx
callq 0x325f
movsbl %al, %edi
callq 0x329e
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2140
xorl %ecx, %ecx
movl %ebp, %r12d
jmp 0x319b
xorl %eax, %eax
movsbl %al, %esi
movl %r13d, %edi
movl %r12d, %edx
pushq $0x5
popq %rcx
callq 0x32ce
movsbl %al, %edi
callq 0x329e
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2140
addl $0x5, %r12d
movl %r12d, %eax
cltd
pushq $0x8
popq %rcx
idivl %ecx
xorl %ecx, %ecx
movl %edx, %r12d
jmp 0x319b
incq %r15
movb $0x1, %cl
jmp 0x3197
pushq $0x3d
popq %rbp
testl %r12d, %r12d
je 0x3250
movq %rbx, %rdi
movl %ebp, %esi
callq 0x2140
addl $0x5, %r12d
movl %r12d, %eax
cltd
pushq $0x8
popq %rcx
idivl %ecx
movl %edx, %r12d
jmp 0x322f
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq