#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 */
unsigned char uchar(char const);
int base32_encode(char *dest, const char *src, unsigned int srclen,
                  unsigned int outlen) {
  const char table[32] = "ybndrfg8ejkmcpqxot1uwisza345h769";
  unsigned int i = 0;
  unsigned int j = 0;
  unsigned char a = 0;
  unsigned char b = 0;
  unsigned char c = 0;
  unsigned char d = 0;
  unsigned char e = 0;
  unsigned char leftover_bytes = (srclen % 5);
  unsigned char replace_bytes = 0;
  const char padding[1] = "=";
  unsigned int iters = (srclen / 5);
  while (i < srclen && j < outlen) {
    a = i < srclen ? uchar(src[i++]) : 0;
    b = i < srclen ? uchar(src[i++]) : 0;
    c = i < srclen ? uchar(src[i++]) : 0;
    d = i < srclen ? uchar(src[i++]) : 0;
    e = i < srclen ? uchar(src[i++]) : 0;
    dest[j++] = table[(a >> 3)];
    dest[j++] = table[(((a & 0x07) << 2) | (b >> 6))];
    dest[j++] = table[(((b & 0x3F) >> 1))];
    dest[j++] = table[(((b & 0x01) << 4) | (c >> 4))];
    dest[j++] = table[(((c & 0x0F) << 1) | (d >> 7))];
    dest[j++] = table[(((d & 0x7F) >> 2))];
    dest[j++] = table[(((d & 0x03) << 3) | (e >> 5))];
    dest[j++] = table[(((e & 0x1F)))];
  }
  if (leftover_bytes == 1)
    replace_bytes = 6;
  else if (leftover_bytes == 2)
    replace_bytes = 4;
  else if (leftover_bytes == 3)
    replace_bytes = 3;
  else if (leftover_bytes == 4)
    replace_bytes = 1;
  j--;
  for (i = 0; i < replace_bytes; i++) {
    dest[j--] = padding[0];
  }
  return 0;
}


x86 assembly (clang, -O0):
<base32_encode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    0xed3(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xed0(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xecd(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xeca(%rip),%rax
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
movb   $0x0,-0x49(%rbp)
movb   $0x0,-0x4a(%rbp)
movb   $0x0,-0x4b(%rbp)
movb   $0x0,-0x4c(%rbp)
movb   $0x0,-0x4d(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x5,%ecx
xor    %edx,%edx
div    %ecx
mov    %dl,%al
mov    %al,-0x4e(%rbp)
movb   $0x0,-0x4f(%rbp)
mov    0xe91(%rip),%al
mov    %al,-0x50(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x5,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x54(%rbp)
mov    -0x44(%rbp),%ecx
xor    %eax,%eax
cmp    -0x14(%rbp),%ecx
mov    %al,-0x55(%rbp)
jae    11be <base32_encode+0xae>
mov    -0x48(%rbp),%eax
cmp    -0x18(%rbp),%eax
setb   %al
mov    %al,-0x55(%rbp)
mov    -0x55(%rbp),%al
test   $0x1,%al
jne    11ce <base32_encode+0xbe>
jmp    1456 <base32_encode+0x346>
mov    -0x44(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    11ff <base32_encode+0xef>
mov    -0x10(%rbp),%rax
mov    -0x44(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x44(%rbp)
mov    %ecx,%ecx
movsbl (%rax,%rcx,1),%edi
call   1030 <uchar@plt>
movzbl %al,%eax
mov    %eax,-0x5c(%rbp)
jmp    1209 <base32_encode+0xf9>
xor    %eax,%eax
mov    %eax,-0x5c(%rbp)
jmp    1209 <base32_encode+0xf9>
mov    -0x5c(%rbp),%eax
mov    %al,-0x49(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    1240 <base32_encode+0x130>
mov    -0x10(%rbp),%rax
mov    -0x44(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x44(%rbp)
mov    %ecx,%ecx
movsbl (%rax,%rcx,1),%edi
call   1030 <uchar@plt>
movzbl %al,%eax
mov    %eax,-0x60(%rbp)
jmp    124a <base32_encode+0x13a>
xor    %eax,%eax
mov    %eax,-0x60(%rbp)
jmp    124a <base32_encode+0x13a>
mov    -0x60(%rbp),%eax
mov    %al,-0x4a(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    1281 <base32_encode+0x171>
mov    -0x10(%rbp),%rax
mov    -0x44(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x44(%rbp)
mov    %ecx,%ecx
movsbl (%rax,%rcx,1),%edi
call   1030 <uchar@plt>
movzbl %al,%eax
mov    %eax,-0x64(%rbp)
jmp    128b <base32_encode+0x17b>
xor    %eax,%eax
mov    %eax,-0x64(%rbp)
jmp    128b <base32_encode+0x17b>
mov    -0x64(%rbp),%eax
mov    %al,-0x4b(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    12c2 <base32_encode+0x1b2>
mov    -0x10(%rbp),%rax
mov    -0x44(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x44(%rbp)
mov    %ecx,%ecx
movsbl (%rax,%rcx,1),%edi
call   1030 <uchar@plt>
movzbl %al,%eax
mov    %eax,-0x68(%rbp)
jmp    12cc <base32_encode+0x1bc>
xor    %eax,%eax
mov    %eax,-0x68(%rbp)
jmp    12cc <base32_encode+0x1bc>
mov    -0x68(%rbp),%eax
mov    %al,-0x4c(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x14(%rbp),%eax
jae    1303 <base32_encode+0x1f3>
mov    -0x10(%rbp),%rax
mov    -0x44(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x44(%rbp)
mov    %ecx,%ecx
movsbl (%rax,%rcx,1),%edi
call   1030 <uchar@plt>
movzbl %al,%eax
mov    %eax,-0x6c(%rbp)
jmp    130d <base32_encode+0x1fd>
xor    %eax,%eax
mov    %eax,-0x6c(%rbp)
jmp    130d <base32_encode+0x1fd>
mov    -0x6c(%rbp),%eax
mov    %al,-0x4d(%rbp)
movzbl -0x49(%rbp),%eax
sar    $0x3,%eax
cltq
mov    -0x40(%rbp,%rax,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x48(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x48(%rbp)
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
movzbl -0x49(%rbp),%eax
and    $0x7,%eax
shl    $0x2,%eax
movzbl -0x4a(%rbp),%ecx
sar    $0x6,%ecx
or     %ecx,%eax
cltq
mov    -0x40(%rbp,%rax,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x48(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x48(%rbp)
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
movzbl -0x4a(%rbp),%eax
and    $0x3f,%eax
sar    $0x1,%eax
cltq
mov    -0x40(%rbp,%rax,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x48(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x48(%rbp)
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
movzbl -0x4a(%rbp),%eax
and    $0x1,%eax
shl    $0x4,%eax
movzbl -0x4b(%rbp),%ecx
sar    $0x4,%ecx
or     %ecx,%eax
cltq
mov    -0x40(%rbp,%rax,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x48(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x48(%rbp)
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
movzbl -0x4b(%rbp),%eax
and    $0xf,%eax
shl    $0x1,%eax
movzbl -0x4c(%rbp),%ecx
sar    $0x7,%ecx
or     %ecx,%eax
cltq
mov    -0x40(%rbp,%rax,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x48(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x48(%rbp)
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
movzbl -0x4c(%rbp),%eax
and    $0x7f,%eax
sar    $0x2,%eax
cltq
mov    -0x40(%rbp,%rax,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x48(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x48(%rbp)
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
movzbl -0x4c(%rbp),%eax
and    $0x3,%eax
shl    $0x3,%eax
movzbl -0x4d(%rbp),%ecx
sar    $0x5,%ecx
or     %ecx,%eax
cltq
mov    -0x40(%rbp,%rax,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x48(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x48(%rbp)
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
movzbl -0x4d(%rbp),%eax
and    $0x1f,%eax
cltq
mov    -0x40(%rbp,%rax,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x48(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x48(%rbp)
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
jmp    11a1 <base32_encode+0x91>
movzbl -0x4e(%rbp),%eax
cmp    $0x1,%eax
jne    146c <base32_encode+0x35c>
movb   $0x6,-0x4f(%rbp)
jmp    14b8 <base32_encode+0x3a8>
movzbl -0x4e(%rbp),%eax
cmp    $0x2,%eax
jne    1482 <base32_encode+0x372>
movb   $0x4,-0x4f(%rbp)
jmp    14b3 <base32_encode+0x3a3>
movzbl -0x4e(%rbp),%eax
cmp    $0x3,%eax
jne    1498 <base32_encode+0x388>
movb   $0x3,-0x4f(%rbp)
jmp    14ae <base32_encode+0x39e>
movzbl -0x4e(%rbp),%eax
cmp    $0x4,%eax
jne    14a9 <base32_encode+0x399>
movb   $0x1,-0x4f(%rbp)
jmp    14ae <base32_encode+0x39e>
jmp    14b3 <base32_encode+0x3a3>
jmp    14b8 <base32_encode+0x3a8>
mov    -0x48(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x48(%rbp)
movl   $0x0,-0x44(%rbp)
mov    -0x44(%rbp),%eax
movzbl -0x4f(%rbp),%ecx
cmp    %ecx,%eax
jae    14fc <base32_encode+0x3ec>
mov    -0x50(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    -0x48(%rbp),%ecx
mov    %ecx,%esi
add    $0xffffffff,%esi
mov    %esi,-0x48(%rbp)
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    14c8 <base32_encode+0x3b8>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<base32_encode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %ecx,%ebp
mov    %rdi,%r15
mov    %edx,%eax
mov    $0xcccccccd,%ecx
imul   %rax,%rcx
shr    $0x22,%rcx
lea    (%rcx,%rcx,4),%eax
mov    %edx,%ecx
sub    %eax,%ecx
mov    %ecx,0x20(%rsp)
xor    %r12d,%r12d
mov    %edx,0xc(%rsp)
test   %edx,%edx
je     130d <base32_encode+0x1fd>
mov    %rsi,0x18(%rsp)
test   %ebp,%ebp
je     130d <base32_encode+0x1fd>
xor    %r13d,%r13d
xor    %r12d,%r12d
mov    %ebp,0x24(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13d,%r14d
mov    0x18(%rsp),%rbx
movsbl (%rbx,%r14,1),%edi
add    $0x1,%r14
call   1030 <uchar@plt>
mov    %al,0xb(%rsp)
cmp    0xc(%rsp),%r14d
jae    11d0 <base32_encode+0xc0>
add    $0x2,%r13d
movsbl (%rbx,%r14,1),%edi
call   1030 <uchar@plt>
mov    %eax,0x10(%rsp)
mov    %r13d,%r14d
cmp    0xc(%rsp),%r14d
jb     11df <base32_encode+0xcf>
movl   $0x0,0x14(%rsp)
mov    0x18(%rsp),%rbx
cmp    0xc(%rsp),%r14d
jb     11ff <base32_encode+0xef>
xor    %ebp,%ebp
cmp    0xc(%rsp),%r14d
jb     1218 <base32_encode+0x108>
xor    %eax,%eax
jmp    1228 <base32_encode+0x118>
xchg   %ax,%ax
movl   $0x0,0x10(%rsp)
cmp    0xc(%rsp),%r14d
jae    11ad <base32_encode+0x9d>
mov    %r14d,%eax
add    $0x1,%r14d
mov    0x18(%rsp),%rbx
movsbl (%rbx,%rax,1),%edi
call   1030 <uchar@plt>
mov    %eax,0x14(%rsp)
cmp    0xc(%rsp),%r14d
jae    11c1 <base32_encode+0xb1>
mov    %r14d,%eax
add    $0x1,%r14d
movsbl (%rbx,%rax,1),%edi
call   1030 <uchar@plt>
mov    %eax,%ebp
cmp    0xc(%rsp),%r14d
jae    11ca <base32_encode+0xba>
mov    %r14d,%eax
add    $0x1,%r14d
movsbl (%rbx,%rax,1),%edi
call   1030 <uchar@plt>
mov    %r14d,%r13d
movzbl 0xb(%rsp),%edx
mov    %rdx,%rcx
shr    $0x3,%rcx
lea    0xdc2(%rip),%rbx
movzbl (%rcx,%rbx,1),%ecx
lea    0x1(%r12),%esi
mov    %r12d,%edi
mov    %cl,(%r15,%rdi,1)
and    $0x7,%edx
movzbl 0x10(%rsp),%ecx
mov    %ecx,%edi
shr    $0x6,%edi
lea    (%rdi,%rdx,4),%edx
movzbl (%rdx,%rbx,1),%edx
lea    0x2(%r12),%edi
mov    %dl,(%r15,%rsi,1)
mov    %ecx,%edx
shr    %edx
and    $0x1f,%edx
movzbl (%rdx,%rbx,1),%edx
lea    0x3(%r12),%esi
mov    %dl,(%r15,%rdi,1)
shl    $0x4,%ecx
and    $0x10,%ecx
movzbl 0x14(%rsp),%edx
mov    %edx,%edi
shr    $0x4,%edi
or     %ecx,%edi
movzbl (%rdi,%rbx,1),%ecx
lea    0x4(%r12),%edi
mov    %cl,(%r15,%rsi,1)
and    $0xf,%edx
movzbl %bpl,%ecx
mov    %ecx,%esi
shr    $0x7,%esi
lea    (%rsi,%rdx,2),%edx
movzbl (%rdx,%rbx,1),%edx
lea    0x5(%r12),%esi
mov    %dl,(%r15,%rdi,1)
mov    %ecx,%edx
shr    $0x2,%edx
and    $0x1f,%edx
movzbl (%rdx,%rbx,1),%edx
lea    0x6(%r12),%edi
mov    %dl,(%r15,%rsi,1)
and    $0x3,%ecx
movzbl %al,%eax
mov    %eax,%edx
shr    $0x5,%edx
lea    (%rdx,%rcx,8),%ecx
movzbl (%rcx,%rbx,1),%ecx
lea    0x7(%r12),%edx
mov    %cl,(%r15,%rdi,1)
and    $0x1f,%eax
movzbl (%rax,%rbx,1),%eax
add    $0x8,%r12d
mov    %al,(%r15,%rdx,1)
cmp    0xc(%rsp),%r14d
jae    130d <base32_encode+0x1fd>
mov    0x24(%rsp),%ebp
cmp    %ebp,%r12d
jb     1170 <base32_encode+0x60>
mov    0x20(%rsp),%esi
add    $0xffffffff,%esi
cmp    $0x3,%esi
ja     1391 <base32_encode+0x281>
movslq %esi,%rax
lea    0xcfd(%rip),%rcx
mov    (%rcx,%rax,4),%eax
lea    -0x1(%rax),%ecx
cmp    $0x3,%ecx
jb     136c <base32_encode+0x25c>
mov    %eax,%ecx
and    $0xfffffffc,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
lea    -0x1(%r12),%edx
movb   $0x3d,(%r15,%rdx,1)
lea    -0x2(%r12),%edx
movb   $0x3d,(%r15,%rdx,1)
lea    -0x3(%r12),%edx
movb   $0x3d,(%r15,%rdx,1)
add    $0xfffffffc,%r12d
movb   $0x3d,(%r15,%r12,1)
add    $0xfffffffc,%ecx
jne    1340 <base32_encode+0x230>
cmp    $0x1,%esi
je     1391 <base32_encode+0x281>
and    $0x3,%eax
add    $0xffffffff,%r12d
nopl   0x0(%rax,%rax,1)
mov    %r12d,%ecx
movb   $0x3d,(%r15,%rcx,1)
add    $0xffffffff,%r12d
add    $0xffffffff,%eax
jne    1380 <base32_encode+0x270>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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