#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 */
char *base64_decode(char *);
char *base64_encode(char *, int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, ...);
int main(void) {
  char *test_string = "abcdefghijklmn";
  int i = 8;
  char *result;
  for (i = 0; i < 8; i++) {
    result = base64_encode(test_string, i);
    printf("test string size: %d, result: %s\n", i, result);
    printf("decode result: %s\n", base64_decode(result));
    free(result);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x8,-0x14(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x8,-0x14(%rbp)
jge    11c8 <main+0x88>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1050 <base64_encode@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1060 <base64_decode@plt>
mov    %rax,%rsi
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1168 <main+0x28>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xeb1(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
call   1050 <base64_encode@plt>
mov    %rax,%rbx
lea    0xeac(%rip),%r15
mov    %r15,%rdi
xor    %esi,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <base64_decode@plt>
lea    0xeb0(%rip),%r12
mov    %r12,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    $0x1,%esi
call   1050 <base64_encode@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    $0x1,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <base64_decode@plt>
mov    %r12,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    $0x2,%esi
call   1050 <base64_encode@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    $0x2,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <base64_decode@plt>
mov    %r12,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    $0x3,%esi
call   1050 <base64_encode@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    $0x3,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <base64_decode@plt>
mov    %r12,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    $0x4,%esi
call   1050 <base64_encode@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    $0x4,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <base64_decode@plt>
mov    %r12,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    $0x5,%esi
call   1050 <base64_encode@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    $0x5,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <base64_decode@plt>
mov    %r12,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    $0x6,%esi
call   1050 <base64_encode@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    $0x6,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <base64_decode@plt>
mov    %r12,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r14,%rdi
mov    $0x7,%esi
call   1050 <base64_encode@plt>
mov    %rax,%rbx
mov    %r15,%rdi
mov    $0x7,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1060 <base64_decode@plt>
mov    %r12,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [15 x i8] c"abcdefghijklmn\00"
@.str.1 = [34 x i8] c"test string size: %d, result: %s\0A\00"
@.str.2 = [19 x i8] c"decode result: %s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8** %2
store i32 8, i32* %3
store i32 0, i32* %3
br label %5
5: ; preds = %20, %0
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 8
br i1 %7, label %8, label %23
8: ; preds = %5
%9 = load i8*, i8** %2
%10 = load i32, i32* %3
%11 = call i8* @base64_encode(i8* %9, i32 %10)
store i8* %11, i8** %4
%12 = load i32, i32* %3
%13 = load i8*, i8** %4
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 %12, i8* %13)
%15 = load i8*, i8** %4
%16 = call i8* @base64_decode(i8* %15)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %16)
%18 = load i8*, i8** %4
%19 = call i32 @free(i8* %18)
br label %20
20: ; preds = %8
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %5
23: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"abcdefghijklmn\00"
@.str.1 = [34 x i8] c"test string size: %d, result: %s\0A\00"
@.str.2 = [19 x i8] c"decode result: %s\0A\00"
define i32 @main() {
%1 = tail call i8* @base64_encode(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 0)
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 0, i8* %1)
%3 = tail call i8* @base64_decode(i8* %1)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%5 = tail call i32 @free(i8* %1)
%6 = tail call i8* @base64_encode(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 1)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 1, i8* %6)
%8 = tail call i8* @base64_decode(i8* %6)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %8)
%10 = tail call i32 @free(i8* %6)
%11 = tail call i8* @base64_encode(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 2)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 2, i8* %11)
%13 = tail call i8* @base64_decode(i8* %11)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %13)
%15 = tail call i32 @free(i8* %11)
%16 = tail call i8* @base64_encode(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 3)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 3, i8* %16)
%18 = tail call i8* @base64_decode(i8* %16)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %18)
%20 = tail call i32 @free(i8* %16)
%21 = tail call i8* @base64_encode(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 4)
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 4, i8* %21)
%23 = tail call i8* @base64_decode(i8* %21)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %23)
%25 = tail call i32 @free(i8* %21)
%26 = tail call i8* @base64_encode(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 5)
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 5, i8* %26)
%28 = tail call i8* @base64_decode(i8* %26)
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = tail call i32 @free(i8* %26)
%31 = tail call i8* @base64_encode(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 6)
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 6, i8* %31)
%33 = tail call i8* @base64_decode(i8* %31)
%34 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %33)
%35 = tail call i32 @free(i8* %31)
%36 = tail call i8* @base64_encode(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 7)
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 7, i8* %36)
%38 = tail call i8* @base64_decode(i8* %36)
%39 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %38)
%40 = tail call i32 @free(i8* %36)
ret i32 0
}