// File: /workspace/github_cpp_makefile_star2_O2/tenup-coin[P]seeder/util.cpp
// Function: EncodeBase32[abi:cxx11](unsigned char const*, unsigned long)
string EncodeBase32(const unsigned char* pch, size_t len)
{
    static const char *pbase32 = "abcdefghijklmnopqrstuvwxyz234567";

    string strRet="";
    strRet.reserve((len+4)/5*8);

    int mode=0, left=0;
    const unsigned char *pchEnd = pch+len;

    while (pch<pchEnd)
    {
        int enc = *(pch++);
        switch (mode)
        {
            case 0: // we have no bits
                strRet += pbase32[enc >> 3];
                left = (enc & 7) << 2;
                mode = 1;
                break;

            case 1: // we have three bits
                strRet += pbase32[left | (enc >> 6)];
                strRet += pbase32[(enc >> 1) & 31];
                left = (enc & 1) << 4;
                mode = 2;
                break;

            case 2: // we have one bit
                strRet += pbase32[left | (enc >> 4)];
                left = (enc & 15) << 1;
                mode = 3;
                break;

            case 3: // we have four bits
                strRet += pbase32[left | (enc >> 7)];
                strRet += pbase32[(enc >> 2) & 31];
                left = (enc & 3) << 3;
                mode = 4;
                break;

            case 4: // we have two bits
                strRet += pbase32[left | (enc >> 5)];
                strRet += pbase32[enc & 31];
                mode = 0;
        }
    }

    static const int nPadding[5] = {0, 6, 4, 3, 1};
    if (mode)
    {
        strRet += pbase32[left];
        for (int n=0; n<nPadding[mode]; n++)
             strRet += '=';
    }

    return strRet;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x179c(%rip), %rsi      # 0x12715
leaq 0x7(%rsp), %rdx
callq 0x3180
leaq 0x4(%r14), %rax
xorl %r12d, %r12d
pushq $0x5
popq %rcx
xorl %edx, %edx
divq %rcx
leaq (,%rax,8), %rsi
movq %rbx, %rdi
callq 0x3610
addq %r15, %r14
xorl %ebp, %ebp
movl %r12d, %r13d
cmpq %r14, %r15
jae 0x11105
incq %r15
cmpl $0x4, %r12d
ja 0x10faa
leaq 0x22dd(%rip), %rcx      # 0x132a0
movslq (%rcx,%r13,4), %rax
addq %rcx, %rax
jmpq *%rax
movzbl -0x1(%r15), %ebp
movl %ebp, %eax
shrl $0x3, %eax
leaq 0x2743(%rip), %rcx      # 0x13720
movsbl (%rax,%rcx), %esi
movq %rbx, %rdi
callq 0x3380
shll $0x2, %ebp
andl $0x1c, %ebp
pushq $0x1
popq %rax
movl %eax, %r12d
jmp 0x10fa7
movzbl -0x1(%r15), %r12d
movl %r12d, %eax
shrl $0x5, %eax
orl %ebp, %eax
leaq 0x2715(%rip), %rcx      # 0x13720
movsbl (%rax,%rcx), %esi
movq %rbx, %rdi
callq 0x3380
andl $0x1f, %r12d
leaq 0x26fe(%rip), %rax      # 0x13720
movsbl (%r12,%rax), %esi
xorl %r12d, %r12d
movq %rbx, %rdi
callq 0x3380
jmp 0x10fa7
movzbl -0x1(%r15), %r13d
movl %r13d, %eax
shrl $0x4, %eax
orl %ebp, %eax
leaq 0x26d5(%rip), %rcx      # 0x13720
movsbl (%rax,%rcx), %esi
movq %rbx, %rdi
callq 0x3380
addl %r13d, %r13d
andl $0x1e, %r13d
pushq $0x3
popq %rax
movl %eax, %r12d
movl %r13d, %ebp
jmp 0x10fa7
movzbl -0x1(%r15), %r13d
movl %r13d, %eax
shrl $0x7, %eax
orl %ebp, %eax
leaq 0x26a0(%rip), %rcx      # 0x13720
movsbl (%rax,%rcx), %esi
movq %rbx, %rdi
callq 0x3380
movl %r13d, %eax
shrl $0x2, %eax
andl $0x1f, %eax
leaq 0x2684(%rip), %rcx      # 0x13720
movsbl (%rax,%rcx), %esi
movq %rbx, %rdi
callq 0x3380
shll $0x3, %r13d
andl $0x18, %r13d
pushq $0x4
jmp 0x110f9
movzbl -0x1(%r15), %r13d
movl %r13d, %eax
shrl $0x6, %eax
orl %ebp, %eax
leaq 0x2658(%rip), %rcx      # 0x13720
movsbl (%rax,%rcx), %esi
movq %rbx, %rdi
callq 0x3380
movl %r13d, %eax
shrl %eax
andl $0x1f, %eax
leaq 0x263d(%rip), %rcx      # 0x13720
movsbl (%rax,%rcx), %esi
movq %rbx, %rdi
callq 0x3380
shll $0x4, %r13d
andl $0x10, %r13d
pushq $0x2
popq %rax
movl %eax, %r12d
movl %r13d, %ebp
jmp 0x10fa7
testl %r12d, %r12d
je 0x11148
movl %ebp, %eax
leaq 0x260d(%rip), %rcx      # 0x13720
movsbl (%rax,%rcx), %esi
movq %rbx, %rdi
callq 0x3380
leaq 0x21da(%rip), %rax      # 0x13300
movl (%rax,%r13,4), %eax
xorl %r14d, %r14d
testl %eax, %eax
cmovgl %eax, %r14d
pushq $0x3d
popq %rbp
subl $0x1, %r14d
jb 0x11148
movq %rbx, %rdi
movl %ebp, %esi
callq 0x3380
jmp 0x11136
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x11162
jmp 0x11162
jmp 0x11162
jmp 0x11162
movq %rax, %r14
movq %rbx, %rdi
callq 0x31d0
movq %r14, %rdi
callq 0x3690