#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 /*<<< orphan*/ assert(int);
int base64length(unsigned char);
int /*<<< orphan*/ printf(char *, ...);
void test_base64length(void) {
  const unsigned char E[] = {0,  2,  3,  4,  6,  7,  8,  10, 11, 12, 14,
                             15, 16, 18, 19, 20, 22, 23, 24, 26, 27};
  unsigned char x;
  printf("\nb64size:\n");
  printf("--------\n\n");
  for (x = 0; x < sizeof E / sizeof E[0]; x++) {
    int result = base64length(x);
    printf("\tin: %2d out: %2d expected: %2d\n", x, result, E[x]);
    assert(E[x] == result);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<test_base64length>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xec1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xebe(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xebc(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xeb7(%rip),%al
mov    %al,-0xc(%rbp)
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movb   $0x0,-0x21(%rbp)
movzbl -0x21(%rbp),%eax
cmp    $0x15,%rax
jae    11de <test_base64length+0xae>
movzbl -0x21(%rbp),%edi
call   1050 <base64length@plt>
mov    %eax,-0x28(%rbp)
movzbl -0x21(%rbp),%esi
mov    -0x28(%rbp),%edx
movzbl -0x21(%rbp),%eax
movzbl -0x20(%rbp,%rax,1),%ecx
lea    0xe7a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movzbl -0x21(%rbp),%eax
movzbl -0x20(%rbp,%rax,1),%eax
cmp    -0x28(%rbp),%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x21(%rbp),%al
add    $0x1,%al
mov    %al,-0x21(%rbp)
jmp    1180 <test_base64length+0x50>
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_base64length>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
lea    0xed7(%rip),%rdi
call   1040 <puts@plt>
lea    0xed5(%rip),%rdi
call   1040 <puts@plt>
lea    0xe89(%rip),%r12
lea    0xe97(%rip),%r14
xor    %ebx,%ebx
movzbl %bl,%edi
call   1070 <base64length@plt>
mov    %eax,%r15d
movzbl (%rbx,%r12,1),%ebp
mov    %r14,%rdi
mov    %ebx,%esi
mov    %eax,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
cmp    %ebp,%r15d
sete   %dil
call   1060 <assert@plt>
add    $0x1,%rbx
cmp    $0x15,%rbx
jne    1180 <test_base64length+0x30>
mov    $0xa,%edi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <putchar@plt>

LLVM IR (-O0):
@__const.test_base64length.E = [21 x i8] c"\00\02\03\04\06\07\08\0A\0B\0C\0E\0F\10\12\13\14\16\17\18\1A\1B"
@.str = [11 x i8] c"\0Ab64size:\0A\00"
@.str.1 = [11 x i8] c"--------\0A\0A\00"
@.str.2 = [33 x i8] c"\09in: %2d out: %2d expected: %2d\0A\00"
@.str.3 = [2 x i8] c"\0A\00"
define void @test_base64length() {
%1 = alloca [21 x i8]
%2 = alloca i8
%3 = alloca i32
%4 = bitcast [21 x i8]* %1 to i8*
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i8 0, i8* %2
br label %7
7: ; preds = %32, %0
%8 = load i8, i8* %2
%9 = zext i8 %8 to i64
%10 = icmp ult i64 %9, 21
br i1 %10, label %11, label %35
11: ; preds = %7
%12 = load i8, i8* %2
%13 = call i32 @base64length(i8 zeroext %12)
store i32 %13, i32* %3
%14 = load i8, i8* %2
%15 = zext i8 %14 to i32
%16 = load i32, i32* %3
%17 = load i8, i8* %2
%18 = zext i8 %17 to i64
%19 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = zext i8 %20 to i32
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %15, i32 %16, i32 %21)
%23 = load i8, i8* %2
%24 = zext i8 %23 to i64
%25 = getelementptr inbounds [21 x i8], [21 x i8]* %1, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = load i32, i32* %3
%29 = icmp eq i32 %27, %28
%30 = zext i1 %29 to i32
%31 = call i32 @assert(i32 %30)
br label %32
32: ; preds = %11
%33 = load i8, i8* %2
%34 = add i8 %33, 1
store i8 %34, i8* %2
br label %7
35: ; preds = %7
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@__const.test_base64length.E = [21 x i8] c"\00\02\03\04\06\07\08\0A\0B\0C\0E\0F\10\12\13\14\16\17\18\1A\1B"
@.str.2 = [33 x i8] c"\09in: %2d out: %2d expected: %2d\0A\00"
@str = [10 x i8] c"\0Ab64size:\00"
@str.4 = [10 x i8] c"--------\0A\00"
define void @test_base64length() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.4, i64 0, i64 0))
br label %3
3: ; preds = %0, %3
%4 = phi i64 [ 0, %0 ], [ %15, %3 ]
%5 = trunc i64 %4 to i8
%6 = tail call i32 @base64length(i8 zeroext %5)
%7 = trunc i64 %4 to i32
%8 = getelementptr inbounds [21 x i8], [21 x i8]* @__const.test_base64length.E, i64 0, i64 %4
%9 = load i8, i8* %8
%10 = zext i8 %9 to i32
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0), i32 %7, i32 %6, i32 %10)
%12 = icmp eq i32 %6, %10
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
%15 = add nuw nsw i64 %4, 1
%16 = icmp eq i64 %15, 21
br i1 %16, label %17, label %3
17: ; preds = %3
%18 = tail call i32 @putchar(i32 10)
ret void
}