#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int to_uchar(char const);
void base32_encode(const char *restrict in, size_t inlen, char *restrict out,
                   size_t outlen) {
  static const char b32str[32] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
  while (inlen && outlen) {
    *out++ = b32str[(to_uchar(in[0]) >> 3) & 0x1f];
    if (!--outlen)
      break;
    *out++ =
        b32str[((to_uchar(in[0]) << 2) + (--inlen ? to_uchar(in[1]) >> 6 : 0)) &
               0x1f];
    if (!--outlen)
      break;
    *out++ = (inlen ? b32str[(to_uchar(in[1]) >> 1) & 0x1f] : '=');
    if (!--outlen)
      break;
    *out++ = (inlen ? b32str[((to_uchar(in[1]) << 4) +
                              (--inlen ? to_uchar(in[2]) >> 4 : 0)) &
                             0x1f]
                    : '=');
    if (!--outlen)
      break;
    *out++ = (inlen ? b32str[((to_uchar(in[2]) << 1) +
                              (--inlen ? to_uchar(in[3]) >> 7 : 0)) &
                             0x1f]
                    : '=');
    if (!--outlen)
      break;
    *out++ = (inlen ? b32str[(to_uchar(in[3]) >> 2) & 0x1f] : '=');
    if (!--outlen)
      break;
    *out++ = (inlen ? b32str[((to_uchar(in[3]) << 3) +
                              (--inlen ? to_uchar(in[4]) >> 5 : 0)) &
                             0x1f]
                    : '=');
    if (!--outlen)
      break;
    *out++ = inlen ? b32str[to_uchar(in[4]) & 0x1f] : '=';
    if (!--outlen)
      break;
    if (inlen)
      inlen--;
    if (inlen)
      in += 5;
  }
  if (outlen)
    *out = '\0';
}


x86 assembly (clang, -O0):
<base32_encode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x21(%rbp)
je     1143 <base32_encode+0x33>
cmpq   $0x0,-0x20(%rbp)
setne  %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
jne    1153 <base32_encode+0x43>
jmp    15d1 <base32_encode+0x4c1>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <to_uchar@plt>
sar    $0x3,%eax
and    $0x1f,%eax
movslq %eax,%rcx
lea    0xe91(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    119e <base32_encode+0x8e>
jmp    15d1 <base32_encode+0x4c1>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <to_uchar@plt>
shl    $0x2,%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11de <base32_encode+0xce>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <to_uchar@plt>
sar    $0x6,%eax
mov    %eax,-0x2c(%rbp)
jmp    11e8 <base32_encode+0xd8>
xor    %eax,%eax
mov    %eax,-0x2c(%rbp)
jmp    11e8 <base32_encode+0xd8>
mov    -0x28(%rbp),%eax
mov    -0x2c(%rbp),%ecx
add    %ecx,%eax
and    $0x1f,%eax
movslq %eax,%rcx
lea    0xe03(%rip),%rax
mov    (%rax,%rcx,1),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    122c <base32_encode+0x11c>
jmp    15d1 <base32_encode+0x4c1>
cmpq   $0x0,-0x10(%rbp)
je     1260 <base32_encode+0x150>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <to_uchar@plt>
sar    $0x1,%eax
and    $0x1f,%eax
movslq %eax,%rcx
lea    0xdac(%rip),%rax
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x30(%rbp)
jmp    126d <base32_encode+0x15d>
mov    $0x3d,%eax
mov    %eax,-0x30(%rbp)
jmp    126d <base32_encode+0x15d>
mov    -0x30(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    129e <base32_encode+0x18e>
jmp    15d1 <base32_encode+0x4c1>
cmpq   $0x0,-0x10(%rbp)
je     1315 <base32_encode+0x205>
mov    -0x8(%rbp),%rax
movsbl 0x1(%rax),%edi
call   1030 <to_uchar@plt>
shl    $0x4,%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     12ea <base32_encode+0x1da>
mov    -0x8(%rbp),%rax
movsbl 0x2(%rax),%edi
call   1030 <to_uchar@plt>
sar    $0x4,%eax
mov    %eax,-0x38(%rbp)
jmp    12f4 <base32_encode+0x1e4>
xor    %eax,%eax
mov    %eax,-0x38(%rbp)
jmp    12f4 <base32_encode+0x1e4>
mov    -0x34(%rbp),%eax
mov    -0x38(%rbp),%ecx
add    %ecx,%eax
and    $0x1f,%eax
movslq %eax,%rcx
lea    0xcf7(%rip),%rax
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x3c(%rbp)
jmp    1322 <base32_encode+0x212>
mov    $0x3d,%eax
mov    %eax,-0x3c(%rbp)
jmp    1322 <base32_encode+0x212>
mov    -0x3c(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1353 <base32_encode+0x243>
jmp    15d1 <base32_encode+0x4c1>
cmpq   $0x0,-0x10(%rbp)
je     13ca <base32_encode+0x2ba>
mov    -0x8(%rbp),%rax
movsbl 0x2(%rax),%edi
call   1030 <to_uchar@plt>
shl    $0x1,%eax
mov    %eax,-0x40(%rbp)
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     139f <base32_encode+0x28f>
mov    -0x8(%rbp),%rax
movsbl 0x3(%rax),%edi
call   1030 <to_uchar@plt>
sar    $0x7,%eax
mov    %eax,-0x44(%rbp)
jmp    13a9 <base32_encode+0x299>
xor    %eax,%eax
mov    %eax,-0x44(%rbp)
jmp    13a9 <base32_encode+0x299>
mov    -0x40(%rbp),%eax
mov    -0x44(%rbp),%ecx
add    %ecx,%eax
and    $0x1f,%eax
movslq %eax,%rcx
lea    0xc42(%rip),%rax
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x48(%rbp)
jmp    13d7 <base32_encode+0x2c7>
mov    $0x3d,%eax
mov    %eax,-0x48(%rbp)
jmp    13d7 <base32_encode+0x2c7>
mov    -0x48(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    1408 <base32_encode+0x2f8>
jmp    15d1 <base32_encode+0x4c1>
cmpq   $0x0,-0x10(%rbp)
je     143c <base32_encode+0x32c>
mov    -0x8(%rbp),%rax
movsbl 0x3(%rax),%edi
call   1030 <to_uchar@plt>
sar    $0x2,%eax
and    $0x1f,%eax
movslq %eax,%rcx
lea    0xbd0(%rip),%rax
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x4c(%rbp)
jmp    1449 <base32_encode+0x339>
mov    $0x3d,%eax
mov    %eax,-0x4c(%rbp)
jmp    1449 <base32_encode+0x339>
mov    -0x4c(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    147a <base32_encode+0x36a>
jmp    15d1 <base32_encode+0x4c1>
cmpq   $0x0,-0x10(%rbp)
je     14f1 <base32_encode+0x3e1>
mov    -0x8(%rbp),%rax
movsbl 0x3(%rax),%edi
call   1030 <to_uchar@plt>
shl    $0x3,%eax
mov    %eax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     14c6 <base32_encode+0x3b6>
mov    -0x8(%rbp),%rax
movsbl 0x4(%rax),%edi
call   1030 <to_uchar@plt>
sar    $0x5,%eax
mov    %eax,-0x54(%rbp)
jmp    14d0 <base32_encode+0x3c0>
xor    %eax,%eax
mov    %eax,-0x54(%rbp)
jmp    14d0 <base32_encode+0x3c0>
mov    -0x50(%rbp),%eax
mov    -0x54(%rbp),%ecx
add    %ecx,%eax
and    $0x1f,%eax
movslq %eax,%rcx
lea    0xb1b(%rip),%rax
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x58(%rbp)
jmp    14fe <base32_encode+0x3ee>
mov    $0x3d,%eax
mov    %eax,-0x58(%rbp)
jmp    14fe <base32_encode+0x3ee>
mov    -0x58(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    152f <base32_encode+0x41f>
jmp    15d1 <base32_encode+0x4c1>
cmpq   $0x0,-0x10(%rbp)
je     1560 <base32_encode+0x450>
mov    -0x8(%rbp),%rax
movsbl 0x4(%rax),%edi
call   1030 <to_uchar@plt>
and    $0x1f,%eax
movslq %eax,%rcx
lea    0xaac(%rip),%rax
movsbl (%rax,%rcx,1),%eax
mov    %eax,-0x5c(%rbp)
jmp    156d <base32_encode+0x45d>
mov    $0x3d,%eax
mov    %eax,-0x5c(%rbp)
jmp    156d <base32_encode+0x45d>
mov    -0x5c(%rbp),%eax
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    159e <base32_encode+0x48e>
jmp    15d1 <base32_encode+0x4c1>
cmpq   $0x0,-0x10(%rbp)
je     15b5 <base32_encode+0x4a5>
mov    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     15cc <base32_encode+0x4bc>
mov    -0x8(%rbp),%rax
add    $0x5,%rax
mov    %rax,-0x8(%rbp)
jmp    1128 <base32_encode+0x18>
cmpq   $0x0,-0x20(%rbp)
je     15e3 <base32_encode+0x4d3>
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<base32_encode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rdx,%r15
test   %rsi,%rsi
je     13fb <base32_encode+0x2eb>
test   %rcx,%rcx
je     13fb <base32_encode+0x2eb>
mov    %rsi,%r13
mov    %rdi,%r12
lea    -0x7(%rcx),%rax
mov    %rax,0x8(%rsp)
lea    -0x4(%rcx),%rax
mov    %rax,0x10(%rsp)
lea    -0x8(%rcx),%rax
mov    %rax,0x30(%rsp)
lea    -0x1(%rcx),%rax
mov    %rax,0x40(%rsp)
lea    -0x2(%rcx),%rax
mov    %rax,0x28(%rsp)
lea    -0x3(%rcx),%rax
mov    %rax,0x20(%rsp)
lea    -0x5(%rcx),%rax
mov    %rax,0x38(%rsp)
add    $0xfffffffffffffffa,%rcx
mov    %rcx,0x18(%rsp)
add    $0x4,%r12
xor    %ebp,%ebp
lea    0xe72(%rip),%rbx
movsbl -0x4(%r12),%edi
call   1030 <to_uchar@plt>
shr    $0x3,%eax
and    $0x1f,%eax
movzbl (%rax,%rbx,1),%eax
mov    %al,(%r15,%rbp,1)
cmp    %rbp,0x40(%rsp)
je     1404 <base32_encode+0x2f4>
mov    %rbx,%r14
movsbl -0x4(%r12),%edi
call   1030 <to_uchar@plt>
mov    %eax,%ebx
shl    $0x2,%ebx
cmp    $0x1,%r13
jne    1210 <base32_encode+0x100>
and    $0x1c,%ebx
mov    %r14,%rcx
movzbl (%rbx,%r14,1),%eax
mov    %al,0x1(%r15,%rbp,1)
cmp    %rbp,0x28(%rsp)
je     1404 <base32_encode+0x2f4>
movb   $0x3d,0x2(%r15,%rbp,1)
cmp    %rbp,0x20(%rsp)
je     1404 <base32_encode+0x2f4>
movb   $0x3d,0x3(%r15,%rbp,1)
cmp    %rbp,0x10(%rsp)
jne    1291 <base32_encode+0x181>
jmp    1404 <base32_encode+0x2f4>
nopl   (%rax)
movsbl -0x3(%r12),%edi
call   1030 <to_uchar@plt>
shr    $0x6,%eax
add    %ebx,%eax
and    $0x1f,%eax
movzbl (%rax,%r14,1),%eax
mov    %al,0x1(%r15,%rbp,1)
cmp    %rbp,0x28(%rsp)
je     1404 <base32_encode+0x2f4>
mov    %r14,%rbx
movsbl -0x3(%r12),%edi
call   1030 <to_uchar@plt>
shr    %eax
and    $0x1f,%eax
movzbl (%rax,%r14,1),%eax
mov    %al,0x2(%r15,%rbp,1)
cmp    %rbp,0x20(%rsp)
je     1404 <base32_encode+0x2f4>
movsbl -0x3(%r12),%edi
call   1030 <to_uchar@plt>
mov    %eax,%ebx
shl    $0x4,%ebx
cmp    $0x2,%r13
jne    12a0 <base32_encode+0x190>
and    $0x10,%ebx
mov    %r14,%rcx
movzbl (%rbx,%r14,1),%eax
mov    %al,0x3(%r15,%rbp,1)
cmp    %rbp,0x10(%rsp)
je     1404 <base32_encode+0x2f4>
mov    %r14,%rbx
mov    $0x3d,%al
xor    %r13d,%r13d
jmp    12ff <base32_encode+0x1ef>
nopl   0x0(%rax,%rax,1)
movsbl -0x2(%r12),%edi
call   1030 <to_uchar@plt>
shr    $0x4,%eax
add    %ebx,%eax
and    $0x1f,%eax
mov    %r14,%rcx
movzbl (%rax,%r14,1),%eax
mov    %al,0x3(%r15,%rbp,1)
cmp    %rbp,0x10(%rsp)
je     1404 <base32_encode+0x2f4>
movsbl -0x2(%r12),%edi
call   1030 <to_uchar@plt>
mov    %eax,%ebx
add    %eax,%ebx
add    $0xfffffffffffffffd,%r13
je     12f0 <base32_encode+0x1e0>
movsbl -0x1(%r12),%edi
call   1030 <to_uchar@plt>
sar    $0x7,%eax
jmp    12f2 <base32_encode+0x1e2>
xor    %eax,%eax
add    %ebx,%eax
and    $0x1f,%eax
mov    %r14,%rbx
movzbl (%rax,%r14,1),%eax
mov    %al,0x4(%r15,%rbp,1)
cmp    %rbp,0x38(%rsp)
je     1404 <base32_encode+0x2f4>
test   %r13,%r13
je     1390 <base32_encode+0x280>
movsbl -0x1(%r12),%edi
call   1030 <to_uchar@plt>
shr    $0x2,%eax
and    $0x1f,%eax
movzbl (%rax,%rbx,1),%eax
mov    %al,0x5(%r15,%rbp,1)
cmp    %rbp,0x18(%rsp)
je     1404 <base32_encode+0x2f4>
movsbl -0x1(%r12),%edi
call   1030 <to_uchar@plt>
mov    %eax,%ebx
shl    $0x3,%ebx
add    $0xffffffffffffffff,%r13
je     13ac <base32_encode+0x29c>
movsbl (%r12),%edi
call   1030 <to_uchar@plt>
shr    $0x5,%eax
add    %ebx,%eax
and    $0x1f,%eax
movzbl (%rax,%r14,1),%eax
mov    %al,0x6(%r15,%rbp,1)
cmp    %rbp,0x8(%rsp)
je     1404 <base32_encode+0x2f4>
mov    %r14,%rbx
movsbl (%r12),%edi
call   1030 <to_uchar@plt>
and    $0x1f,%eax
movzbl (%rax,%r14,1),%ecx
xor    %eax,%eax
jmp    13ca <base32_encode+0x2ba>
nop
movb   $0x3d,0x5(%r15,%rbp,1)
cmp    %rbp,0x18(%rsp)
je     1404 <base32_encode+0x2f4>
movb   $0x3d,0x6(%r15,%rbp,1)
cmp    %rbp,0x8(%rsp)
jne    13c3 <base32_encode+0x2b3>
jmp    1404 <base32_encode+0x2f4>
and    $0x18,%ebx
movzbl (%rbx,%r14,1),%eax
mov    %al,0x6(%r15,%rbp,1)
cmp    %rbp,0x8(%rsp)
je     1404 <base32_encode+0x2f4>
mov    %r14,%rbx
mov    $0x3d,%cl
mov    $0x1,%al
xor    %r13d,%r13d
mov    %cl,0x7(%r15,%rbp,1)
cmp    %rbp,0x30(%rsp)
je     1404 <base32_encode+0x2f4>
add    $0xffffffffffffffff,%r13
test   %al,%al
mov    $0x0,%eax
cmovne %rax,%r13
add    $0x8,%rbp
add    $0x5,%r12
test   %r13,%r13
jne    118e <base32_encode+0x7e>
add    %rbp,%r15
jmp    1400 <base32_encode+0x2f0>
test   %rcx,%rcx
je     1404 <base32_encode+0x2f4>
movb   $0x0,(%r15)
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@base32_encode.b32str = internal constant [32 x i8] c"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"
define void @base32_encode(i8* noalias %0, i64 %1, i8* noalias %2, i64 %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i64
store i8* %0, i8** %5
store i64 %1, i64* %6
store i8* %2, i8** %7
store i64 %3, i64* %8
br label %9
9: ; preds = %256, %4
%10 = load i64, i64* %6
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i64, i64* %8
%14 = icmp ne i64 %13, 0
br label %15
15: ; preds = %12, %9
%16 = phi i1 [ false, %9 ], [ %14, %12 ]
br i1 %16, label %17, label %257
17: ; preds = %15
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i64 0
%20 = load i8, i8* %19
%21 = call i32 @to_uchar(i8 signext %20)
%22 = ashr i32 %21, 3
%23 = and i32 %22, 31
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [32 x i8], [32 x i8]* @base32_encode.b32str, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = load i8*, i8** %7
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %7
store i8 %26, i8* %27
%29 = load i64, i64* %8
%30 = add i64 %29, -1
store i64 %30, i64* %8
%31 = icmp ne i64 %30, 0
br i1 %31, label %33, label %32
32: ; preds = %17
br label %257
33: ; preds = %17
%34 = load i8*, i8** %5
%35 = getelementptr inbounds i8, i8* %34, i64 0
%36 = load i8, i8* %35
%37 = call i32 @to_uchar(i8 signext %36)
%38 = shl i32 %37, 2
%39 = load i64, i64* %6
%40 = add i64 %39, -1
store i64 %40, i64* %6
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %48
42: ; preds = %33
%43 = load i8*, i8** %5
%44 = getelementptr inbounds i8, i8* %43, i64 1
%45 = load i8, i8* %44
%46 = call i32 @to_uchar(i8 signext %45)
%47 = ashr i32 %46, 6
br label %49
48: ; preds = %33
br label %49
49: ; preds = %48, %42
%50 = phi i32 [ %47, %42 ], [ 0, %48 ]
%51 = add nsw i32 %38, %50
%52 = and i32 %51, 31
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [32 x i8], [32 x i8]* @base32_encode.b32str, i64 0, i64 %53
%55 = load i8, i8* %54
%56 = load i8*, i8** %7
%57 = getelementptr inbounds i8, i8* %56, i32 1
store i8* %57, i8** %7
store i8 %55, i8* %56
%58 = load i64, i64* %8
%59 = add i64 %58, -1
store i64 %59, i64* %8
%60 = icmp ne i64 %59, 0
br i1 %60, label %62, label %61
61: ; preds = %49
br label %257
62: ; preds = %49
%63 = load i64, i64* %6
%64 = icmp ne i64 %63, 0
br i1 %64, label %65, label %76
65: ; preds = %62
%66 = load i8*, i8** %5
%67 = getelementptr inbounds i8, i8* %66, i64 1
%68 = load i8, i8* %67
%69 = call i32 @to_uchar(i8 signext %68)
%70 = ashr i32 %69, 1
%71 = and i32 %70, 31
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds [32 x i8], [32 x i8]* @base32_encode.b32str, i64 0, i64 %72
%74 = load i8, i8* %73
%75 = sext i8 %74 to i32
br label %77
76: ; preds = %62
br label %77
77: ; preds = %76, %65
%78 = phi i32 [ %75, %65 ], [ 61, %76 ]
%79 = trunc i32 %78 to i8
%80 = load i8*, i8** %7
%81 = getelementptr inbounds i8, i8* %80, i32 1
store i8* %81, i8** %7
store i8 %79, i8* %80
%82 = load i64, i64* %8
%83 = add i64 %82, -1
store i64 %83, i64* %8
%84 = icmp ne i64 %83, 0
br i1 %84, label %86, label %85
85: ; preds = %77
br label %257
86: ; preds = %77
%87 = load i64, i64* %6
%88 = icmp ne i64 %87, 0
br i1 %88, label %89, label %113
89: ; preds = %86
%90 = load i8*, i8** %5
%91 = getelementptr inbounds i8, i8* %90, i64 1
%92 = load i8, i8* %91
%93 = call i32 @to_uchar(i8 signext %92)
%94 = shl i32 %93, 4
%95 = load i64, i64* %6
%96 = add i64 %95, -1
store i64 %96, i64* %6
%97 = icmp ne i64 %96, 0
br i1 %97, label %98, label %104
98: ; preds = %89
%99 = load i8*, i8** %5
%100 = getelementptr inbounds i8, i8* %99, i64 2
%101 = load i8, i8* %100
%102 = call i32 @to_uchar(i8 signext %101)
%103 = ashr i32 %102, 4
br label %105
104: ; preds = %89
br label %105
105: ; preds = %104, %98
%106 = phi i32 [ %103, %98 ], [ 0, %104 ]
%107 = add nsw i32 %94, %106
%108 = and i32 %107, 31
%109 = sext i32 %108 to i64
%110 = getelementptr inbounds [32 x i8], [32 x i8]* @base32_encode.b32str, i64 0, i64 %109
%111 = load i8, i8* %110
%112 = sext i8 %111 to i32
br label %114
113: ; preds = %86
br label %114
114: ; preds = %113, %105
%115 = phi i32 [ %112, %105 ], [ 61, %113 ]
%116 = trunc i32 %115 to i8
%117 = load i8*, i8** %7
%118 = getelementptr inbounds i8, i8* %117, i32 1
store i8* %118, i8** %7
store i8 %116, i8* %117
%119 = load i64, i64* %8
%120 = add i64 %119, -1
store i64 %120, i64* %8
%121 = icmp ne i64 %120, 0
br i1 %121, label %123, label %122
122: ; preds = %114
br label %257
123: ; preds = %114
%124 = load i64, i64* %6
%125 = icmp ne i64 %124, 0
br i1 %125, label %126, label %150
126: ; preds = %123
%127 = load i8*, i8** %5
%128 = getelementptr inbounds i8, i8* %127, i64 2
%129 = load i8, i8* %128
%130 = call i32 @to_uchar(i8 signext %129)
%131 = shl i32 %130, 1
%132 = load i64, i64* %6
%133 = add i64 %132, -1
store i64 %133, i64* %6
%134 = icmp ne i64 %133, 0
br i1 %134, label %135, label %141
135: ; preds = %126
%136 = load i8*, i8** %5
%137 = getelementptr inbounds i8, i8* %136, i64 3
%138 = load i8, i8* %137
%139 = call i32 @to_uchar(i8 signext %138)
%140 = ashr i32 %139, 7
br label %142
141: ; preds = %126
br label %142
142: ; preds = %141, %135
%143 = phi i32 [ %140, %135 ], [ 0, %141 ]
%144 = add nsw i32 %131, %143
%145 = and i32 %144, 31
%146 = sext i32 %145 to i64
%147 = getelementptr inbounds [32 x i8], [32 x i8]* @base32_encode.b32str, i64 0, i64 %146
%148 = load i8, i8* %147
%149 = sext i8 %148 to i32
br label %151
150: ; preds = %123
br label %151
151: ; preds = %150, %142
%152 = phi i32 [ %149, %142 ], [ 61, %150 ]
%153 = trunc i32 %152 to i8
%154 = load i8*, i8** %7
%155 = getelementptr inbounds i8, i8* %154, i32 1
store i8* %155, i8** %7
store i8 %153, i8* %154
%156 = load i64, i64* %8
%157 = add i64 %156, -1
store i64 %157, i64* %8
%158 = icmp ne i64 %157, 0
br i1 %158, label %160, label %159
159: ; preds = %151
br label %257
160: ; preds = %151
%161 = load i64, i64* %6
%162 = icmp ne i64 %161, 0
br i1 %162, label %163, label %174
163: ; preds = %160
%164 = load i8*, i8** %5
%165 = getelementptr inbounds i8, i8* %164, i64 3
%166 = load i8, i8* %165
%167 = call i32 @to_uchar(i8 signext %166)
%168 = ashr i32 %167, 2
%169 = and i32 %168, 31
%170 = sext i32 %169 to i64
%171 = getelementptr inbounds [32 x i8], [32 x i8]* @base32_encode.b32str, i64 0, i64 %170
%172 = load i8, i8* %171
%173 = sext i8 %172 to i32
br label %175
174: ; preds = %160
br label %175
175: ; preds = %174, %163
%176 = phi i32 [ %173, %163 ], [ 61, %174 ]
%177 = trunc i32 %176 to i8
%178 = load i8*, i8** %7
%179 = getelementptr inbounds i8, i8* %178, i32 1
store i8* %179, i8** %7
store i8 %177, i8* %178
%180 = load i64, i64* %8
%181 = add i64 %180, -1
store i64 %181, i64* %8
%182 = icmp ne i64 %181, 0
br i1 %182, label %184, label %183
183: ; preds = %175
br label %257
184: ; preds = %175
%185 = load i64, i64* %6
%186 = icmp ne i64 %185, 0
br i1 %186, label %187, label %211
187: ; preds = %184
%188 = load i8*, i8** %5
%189 = getelementptr inbounds i8, i8* %188, i64 3
%190 = load i8, i8* %189
%191 = call i32 @to_uchar(i8 signext %190)
%192 = shl i32 %191, 3
%193 = load i64, i64* %6
%194 = add i64 %193, -1
store i64 %194, i64* %6
%195 = icmp ne i64 %194, 0
br i1 %195, label %196, label %202
196: ; preds = %187
%197 = load i8*, i8** %5
%198 = getelementptr inbounds i8, i8* %197, i64 4
%199 = load i8, i8* %198
%200 = call i32 @to_uchar(i8 signext %199)
%201 = ashr i32 %200, 5
br label %203
202: ; preds = %187
br label %203
203: ; preds = %202, %196
%204 = phi i32 [ %201, %196 ], [ 0, %202 ]
%205 = add nsw i32 %192, %204
%206 = and i32 %205, 31
%207 = sext i32 %206 to i64
%208 = getelementptr inbounds [32 x i8], [32 x i8]* @base32_encode.b32str, i64 0, i64 %207
%209 = load i8, i8* %208
%210 = sext i8 %209 to i32
br label %212
211: ; preds = %184
br label %212
212: ; preds = %211, %203
%213 = phi i32 [ %210, %203 ], [ 61, %211 ]
%214 = trunc i32 %213 to i8
%215 = load i8*, i8** %7
%216 = getelementptr inbounds i8, i8* %215, i32 1
store i8* %216, i8** %7
store i8 %214, i8* %215
%217 = load i64, i64* %8
%218 = add i64 %217, -1
store i64 %218, i64* %8
%219 = icmp ne i64 %218, 0
br i1 %219, label %221, label %220
220: ; preds = %212
br label %257
221: ; preds = %212
%222 = load i64, i64* %6
%223 = icmp ne i64 %222, 0
br i1 %223, label %224, label %234
224: ; preds = %221
%225 = load i8*, i8** %5
%226 = getelementptr inbounds i8, i8* %225, i64 4
%227 = load i8, i8* %226
%228 = call i32 @to_uchar(i8 signext %227)
%229 = and i32 %228, 31
%230 = sext i32 %229 to i64
%231 = getelementptr inbounds [32 x i8], [32 x i8]* @base32_encode.b32str, i64 0, i64 %230
%232 = load i8, i8* %231
%233 = sext i8 %232 to i32
br label %235
234: ; preds = %221
br label %235
235: ; preds = %234, %224
%236 = phi i32 [ %233, %224 ], [ 61, %234 ]
%237 = trunc i32 %236 to i8
%238 = load i8*, i8** %7
%239 = getelementptr inbounds i8, i8* %238, i32 1
store i8* %239, i8** %7
store i8 %237, i8* %238
%240 = load i64, i64* %8
%241 = add i64 %240, -1
store i64 %241, i64* %8
%242 = icmp ne i64 %241, 0
br i1 %242, label %244, label %243
243: ; preds = %235
br label %257
244: ; preds = %235
%245 = load i64, i64* %6
%246 = icmp ne i64 %245, 0
br i1 %246, label %247, label %250
247: ; preds = %244
%248 = load i64, i64* %6
%249 = add i64 %248, -1
store i64 %249, i64* %6
br label %250
250: ; preds = %247, %244
%251 = load i64, i64* %6
%252 = icmp ne i64 %251, 0
br i1 %252, label %253, label %256
253: ; preds = %250
%254 = load i8*, i8** %5
%255 = getelementptr inbounds i8, i8* %254, i64 5
store i8* %255, i8** %5
br label %256
256: ; preds = %253, %250
br label %9
257: ; preds = %243, %220, %183, %159, %122, %85, %61, %32, %15
%258 = load i64, i64* %8
%259 = icmp ne i64 %258, 0
br i1 %259, label %260, label %262
260: ; preds = %257
%261 = load i8*, i8** %7
store i8 0, i8* %261
br label %262
262: ; preds = %260, %257
ret void
}

LLVM IR (-O2):
@base32_encode.b32str = internal unnamed_addr constant [32 x i8] c"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"
define void @base32_encode(i8* noalias nocapture %0, i64 %1, i8* noalias nocapture writeonly %2, i64 %3) {
%5 = icmp ne i64 %1, 0
%6 = icmp ne i64 %3, 0
%7 = and i1 %5, %6
br i1 %7, label %8, label %171
8: ; preds = %4, %164
%9 = phi i64 [ %162, %164 ], [ %3, %4 ]
%10 = phi i8* [ %165, %164 ], [ %2, %4 ]
%11 = phi i64 [ %167, %164 ], [ %1, %4 ]
%12 = phi i8* [ %170, %164 ], [ %0, %4 ]
%13 = load i8, i8* %12
%14 = tail call i32 @to_uchar(i8 signext %13)
%15 = lshr i32 %14, 3
%16 = and i32 %15, 31
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds [32 x i8], [32 x i8]* @base32_encode.b32str, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = getelementptr inbounds i8, i8* %10, i64 1
store i8 %19, i8* %10
%21 = icmp eq i64 %9, 1
br i1 %21, label %175, label %22
22: ; preds = %8
%23 = load i8, i8* %12
%24 = tail call i32 @to_uchar(i8 signext %23)
%25 = shl i32 %24, 2
%26 = icmp eq i64 %11, 1
br i1 %26, label %27, label %33
27: ; preds = %22
%28 = and i32 %25, 28
%29 = zext i32 %28 to i64
%30 = getelementptr inbounds [32 x i8], [32 x i8]* @base32_encode.b32str, i64 0, i64 %29
%31 = load i8, i8* %30
store i8 %31, i8* %20
%32 = icmp eq i64 %9, 2
br i1 %32, label %175, label %44
33: ; preds = %22
%34 = getelementptr inbounds i8, i8* %12, i64 1
%35 = load i8, i8* %34
%36 = tail call i32 @to_uchar(i8 signext %35)
%37 = lshr i32 %36, 6
%38 = add i32 %37, %25
%39 = and i32 %38, 31
%40 = zext i32 %39 to i64
%41 = getelementptr inbounds [32 x i8], [32 x i8]* @base32_encode.b32str, i64 0, i64 %40
%42 = load i8, i8* %41
store i8 %42, i8* %20
%43 = icmp eq i64 %9, 2
br i1 %43, label %175, label %47
44: ; preds = %27
%45 = getelementptr inbounds i8, i8* %10, i64 2
store i8 61, i8* %45
%46 = icmp eq i64 %9, 3
br i1 %46, label %175, label %80
47: ; preds = %33
%48 = getelementptr inbounds i8, i8* %10, i64 2
%49 = load i8, i8* %34
%50 = tail call i32 @to_uchar(i8 signext %49)
%51 = lshr i32 %50, 1
%52 = and i32 %51, 31
%53 = zext i32 %52 to i64
%54 = getelementptr inbounds [32 x i8], [32 x i8]* @base32_encode.b32str, i64 0, i64 %53
%55 = load i8, i8* %54
%56 = getelementptr inbounds i8, i8* %10, i64 3
store i8 %55, i8* %48
%57 = icmp eq i64 %9, 3
br i1 %57, label %175, label %58
58: ; preds = %47
%59 = load i8, i8* %34
%60 = tail call i32 @to_uchar(i8 signext %59)
%61 = shl i32 %60, 4
%62 = icmp eq i64 %11, 2
br i1 %62, label %63, label %69
63: ; preds = %58
%64 = and i32 %61, 16
%65 = zext i32 %64 to i64
%66 = getelementptr inbounds [32 x i8], [32 x i8]* @base32_encode.b32str, i64 0, i64 %65
%67 = load i8, i8* %66
store i8 %67, i8* %56
%68 = icmp eq i64 %9, 4
br i1 %68, label %175, label %102
69: ; preds = %58
%70 = getelementptr inbounds i8, i8* %12, i64 2
%71 = load i8, i8* %70
%72 = tail call i32 @to_uchar(i8 signext %71)
%73 = lshr i32 %72, 4
%74 = add i32 %73, %61
%75 = and i32 %74, 31
%76 = zext i32 %75 to i64
%77 = getelementptr inbounds [32 x i8], [32 x i8]* @base32_encode.b32str, i64 0, i64 %76
%78 = load i8, i8* %77
store i8 %78, i8* %56
%79 = icmp eq i64 %9, 4
br i1 %79, label %175, label %83
80: ; preds = %44
%81 = getelementptr inbounds i8, i8* %10, i64 3
store i8 61, i8* %81
%82 = icmp eq i64 %9, 4
br i1 %82, label %175, label %102
83: ; preds = %69
%84 = getelementptr inbounds i8, i8* %12, i64 2
%85 = load i8, i8* %84
%86 = tail call i32 @to_uchar(i8 signext %85)
%87 = shl i32 %86, 1
%88 = add i64 %11, -3
%89 = icmp eq i64 %88, 0
br i1 %89, label %95, label %90
90: ; preds = %83
%91 = getelementptr inbounds i8, i8* %12, i64 3
%92 = load i8, i8* %91
%93 = tail call i32 @to_uchar(i8 signext %92)
%94 = ashr i32 %93, 7
br label %95
95: ; preds = %83, %90
%96 = phi i32 [ %94, %90 ], [ 0, %83 ]
%97 = add nsw i32 %96, %87
%98 = and i32 %97, 31
%99 = zext i32 %98 to i64
%100 = getelementptr inbounds [32 x i8], [32 x i8]* @base32_encode.b32str, i64 0, i64 %99
%101 = load i8, i8* %100
br label %102
102: ; preds = %63, %80, %95
%103 = phi i64 [ %88, %95 ], [ 0, %80 ], [ 0, %63 ]
%104 = phi i8 [ %101, %95 ], [ 61, %80 ], [ 61, %63 ]
%105 = getelementptr inbounds i8, i8* %10, i64 4
%106 = getelementptr inbounds i8, i8* %10, i64 5
store i8 %104, i8* %105
%107 = icmp eq i64 %9, 5
br i1 %107, label %175, label %108
108: ; preds = %102
%109 = icmp eq i64 %103, 0
br i1 %109, label %110, label %112
110: ; preds = %108
store i8 61, i8* %106
%111 = icmp eq i64 %9, 6
br i1 %111, label %175, label %146
112: ; preds = %108
%113 = getelementptr inbounds i8, i8* %12, i64 3
%114 = load i8, i8* %113
%115 = tail call i32 @to_uchar(i8 signext %114)
%116 = lshr i32 %115, 2
%117 = and i32 %116, 31
%118 = zext i32 %117 to i64
%119 = getelementptr inbounds [32 x i8], [32 x i8]* @base32_encode.b32str, i64 0, i64 %118
%120 = load i8, i8* %119
%121 = getelementptr inbounds i8, i8* %10, i64 6
store i8 %120, i8* %106
%122 = icmp eq i64 %9, 6
br i1 %122, label %175, label %123
123: ; preds = %112
%124 = load i8, i8* %113
%125 = tail call i32 @to_uchar(i8 signext %124)
%126 = shl i32 %125, 3
%127 = add i64 %103, -1
%128 = icmp eq i64 %127, 0
br i1 %128, label %129, label %135
129: ; preds = %123
%130 = and i32 %126, 24
%131 = zext i32 %130 to i64
%132 = getelementptr inbounds [32 x i8], [32 x i8]* @base32_encode.b32str, i64 0, i64 %131
%133 = load i8, i8* %132
store i8 %133, i8* %121
%134 = icmp eq i64 %9, 7
br i1 %134, label %175, label %157
135: ; preds = %123
%136 = getelementptr inbounds i8, i8* %12, i64 4
%137 = load i8, i8* %136
%138 = tail call i32 @to_uchar(i8 signext %137)
%139 = lshr i32 %138, 5
%140 = add i32 %139, %126
%141 = and i32 %140, 31
%142 = zext i32 %141 to i64
%143 = getelementptr inbounds [32 x i8], [32 x i8]* @base32_encode.b32str, i64 0, i64 %142
%144 = load i8, i8* %143
store i8 %144, i8* %121
%145 = icmp eq i64 %9, 7
br i1 %145, label %175, label %149
146: ; preds = %110
%147 = getelementptr inbounds i8, i8* %10, i64 6
store i8 61, i8* %147
%148 = icmp eq i64 %9, 7
br i1 %148, label %175, label %157
149: ; preds = %135
%150 = getelementptr inbounds i8, i8* %12, i64 4
%151 = load i8, i8* %150
%152 = tail call i32 @to_uchar(i8 signext %151)
%153 = and i32 %152, 31
%154 = zext i32 %153 to i64
%155 = getelementptr inbounds [32 x i8], [32 x i8]* @base32_encode.b32str, i64 0, i64 %154
%156 = load i8, i8* %155
br label %157
157: ; preds = %129, %146, %149
%158 = phi i1 [ false, %149 ], [ true, %146 ], [ true, %129 ]
%159 = phi i64 [ %127, %149 ], [ 0, %146 ], [ 0, %129 ]
%160 = phi i8 [ %156, %149 ], [ 61, %146 ], [ 61, %129 ]
%161 = getelementptr inbounds i8, i8* %10, i64 7
store i8 %160, i8* %161
%162 = add i64 %9, -8
%163 = icmp eq i64 %162, 0
br i1 %163, label %175, label %164
164: ; preds = %157
%165 = getelementptr inbounds i8, i8* %10, i64 8
%166 = add i64 %159, -1
%167 = select i1 %158, i64 0, i64 %166
%168 = icmp eq i64 %167, 0
%169 = select i1 %168, i64 0, i64 5
%170 = getelementptr i8, i8* %12, i64 %169
br i1 %168, label %173, label %8
171: ; preds = %4
%172 = icmp eq i64 %3, 0
br i1 %172, label %175, label %173
173: ; preds = %164, %171
%174 = phi i8* [ %2, %171 ], [ %165, %164 ]
store i8 0, i8* %174
br label %175
175: ; preds = %146, %112, %80, %47, %33, %8, %27, %44, %63, %102, %110, %129, %157, %69, %135, %173, %171
ret void
}