// File: 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
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x58(%rbp)
movq %rdi, %rax
movq %rax, -0x60(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movb $0x0, -0x19(%rbp)
leaq -0x1a(%rbp), %rdi
movq %rdi, -0x50(%rbp)
callq 0x4800
movq -0x58(%rbp), %rdi
movq -0x50(%rbp), %rdx
leaq 0x2166(%rip), %rsi      # 0x33725
callq 0x4690
jmp 0x315c6
leaq -0x1a(%rbp), %rdi
callq 0x4520
movq -0x58(%rbp), %rdi
movq -0x18(%rbp), %rax
addq $0x4, %rax
movabsq $-0x3333333333333333, %rcx # imm = 0xCCCCCCCCCCCCCCCD
mulq %rcx
movq %rdx, %rsi
addq %rsi, %rsi
andq $-0x8, %rsi
callq 0x4750
jmp 0x315f9
movl $0x0, -0x30(%rbp)
movl $0x0, -0x34(%rbp)
movq -0x10(%rbp), %rax
addq -0x18(%rbp), %rax
movq %rax, -0x40(%rbp)
movq -0x10(%rbp), %rax
cmpq -0x40(%rbp), %rax
jae 0x317fe
movq -0x10(%rbp), %rax
movq %rax, %rcx
incq %rcx
movq %rcx, -0x10(%rbp)
movzbl (%rax), %eax
movl %eax, -0x44(%rbp)
movl -0x30(%rbp), %eax
movq %rax, -0x68(%rbp)
subq $0x4, %rax
ja 0x317f9
movq -0x68(%rbp), %rax
leaq 0x2cdf(%rip), %rcx      # 0x34330
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x1a(%rbp), %rdi
callq 0x4520
jmp 0x31874
movq -0x58(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x42f0
jmp 0x31874
movq -0x58(%rbp), %rdi
movq 0x18e4f(%rip), %rax     # 0x4a4e8
movl -0x44(%rbp), %ecx
sarl $0x3, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %esi
callq 0x4310
jmp 0x316ad
movl -0x44(%rbp), %eax
andl $0x7, %eax
shll $0x2, %eax
movl %eax, -0x34(%rbp)
movl $0x1, -0x30(%rbp)
jmp 0x317f9
movq -0x58(%rbp), %rdi
movq 0x18e18(%rip), %rax     # 0x4a4e8
movl -0x34(%rbp), %ecx
movl -0x44(%rbp), %edx
sarl $0x6, %edx
orl %edx, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %esi
callq 0x4310
jmp 0x316e9
movq -0x58(%rbp), %rdi
movq 0x18df4(%rip), %rax     # 0x4a4e8
movl -0x44(%rbp), %ecx
shrl %ecx
andl $0x1f, %ecx
movsbl (%rax,%rcx), %esi
callq 0x4310
jmp 0x31707
movl -0x44(%rbp), %eax
andl $0x1, %eax
shll $0x4, %eax
movl %eax, -0x34(%rbp)
movl $0x2, -0x30(%rbp)
jmp 0x317f9
movq -0x58(%rbp), %rdi
movq 0x18dbe(%rip), %rax     # 0x4a4e8
movl -0x34(%rbp), %ecx
movl -0x44(%rbp), %edx
sarl $0x4, %edx
orl %edx, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %esi
callq 0x4310
jmp 0x31743
movl -0x44(%rbp), %eax
andl $0xf, %eax
shll %eax
movl %eax, -0x34(%rbp)
movl $0x3, -0x30(%rbp)
jmp 0x317f9
movq -0x58(%rbp), %rdi
movq 0x18d83(%rip), %rax     # 0x4a4e8
movl -0x34(%rbp), %ecx
movl -0x44(%rbp), %edx
sarl $0x7, %edx
orl %edx, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %esi
callq 0x4310
jmp 0x3177e
movq -0x58(%rbp), %rdi
movq 0x18d5f(%rip), %rax     # 0x4a4e8
movl -0x44(%rbp), %ecx
shrl $0x2, %ecx
andl $0x1f, %ecx
movsbl (%rax,%rcx), %esi
callq 0x4310
jmp 0x3179d
movl -0x44(%rbp), %eax
andl $0x3, %eax
shll $0x3, %eax
movl %eax, -0x34(%rbp)
movl $0x4, -0x30(%rbp)
jmp 0x317f9
movq -0x58(%rbp), %rdi
movq 0x18d2b(%rip), %rax     # 0x4a4e8
movl -0x34(%rbp), %ecx
movl -0x44(%rbp), %edx
sarl $0x5, %edx
orl %edx, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %esi
callq 0x4310
jmp 0x317d6
movq -0x58(%rbp), %rdi
movq 0x18d07(%rip), %rax     # 0x4a4e8
movl -0x44(%rbp), %ecx
andl $0x1f, %ecx
movsbl (%rax,%rcx), %esi
callq 0x4310
jmp 0x317f2
movl $0x0, -0x30(%rbp)
jmp 0x31613
cmpl $0x0, -0x30(%rbp)
je 0x31857
movq -0x58(%rbp), %rdi
movq 0x18cd9(%rip), %rax     # 0x4a4e8
movslq -0x34(%rbp), %rcx
movsbl (%rax,%rcx), %esi
callq 0x4310
jmp 0x3181e
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
movslq -0x30(%rbp), %rdx
leaq 0x2b5d(%rip), %rcx      # 0x34390
cmpl (%rcx,%rdx,4), %eax
jge 0x31855
movq -0x58(%rbp), %rdi
movl $0x3d, %esi
callq 0x4310
jmp 0x31848
jmp 0x3184a
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x31825
jmp 0x31857
movb $0x1, -0x19(%rbp)
testb $0x1, -0x19(%rbp)
jne 0x3186a
movq -0x58(%rbp), %rdi
callq 0x42f0
movq -0x60(%rbp), %rax
addq $0x70, %rsp
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x47f0
nopl (%rax)