#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 *Base64Decode(char *, int /*<<< orphan*/, size_t *);
char *Base64Encode(char *, int /*<<< orphan*/, size_t *);
int /*<<< orphan*/ Base64StringFree(char *);
int /*<<< orphan*/ printf(char *, char *, size_t);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ strlen(char *);
int main() {
  char str[] = "This is Base64 Encode and Decode Info\0";
  char bs[512] = {0};
  size_t out = 0;
  char *p = NULL;
  if ((p = Base64Encode(str, strlen(str), &out)) != NULL) {
    printf("Base64Encode: %s Length:%d\n", p, out);
    snprintf(bs, 511, "%s", p);
    Base64StringFree(p);
    if ((p = Base64Decode(bs, strlen(bs), &out)) != NULL) {
      printf("Base64Decode: %s Length:%d\n", p, out);
      Base64StringFree(p);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x250,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xe63(%rip),%rsi
mov    $0x27,%edx
call   1080 <memcpy@plt>
lea    -0x230(%rbp),%rdi
xor    %esi,%esi
mov    $0x200,%edx
call   1070 <memset@plt>
movq   $0x0,-0x238(%rbp)
movq   $0x0,-0x240(%rbp)
lea    -0x30(%rbp),%rax
mov    %rax,-0x248(%rbp)
lea    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x248(%rbp),%rdi
mov    %eax,%esi
lea    -0x238(%rbp),%rdx
call   1030 <Base64Encode@plt>
mov    %rax,-0x240(%rbp)
cmp    $0x0,%rax
je     12ba <main+0x13a>
mov    -0x240(%rbp),%rsi
mov    -0x238(%rbp),%rdx
lea    0xe08(%rip),%rdi
call   1050 <printf@plt>
lea    -0x230(%rbp),%rdi
mov    -0x240(%rbp),%rcx
mov    $0x1ff,%esi
lea    0xe05(%rip),%rdx
call   1060 <snprintf@plt>
mov    -0x240(%rbp),%rdi
call   10a0 <Base64StringFree@plt>
lea    -0x230(%rbp),%rax
mov    %rax,-0x250(%rbp)
lea    -0x230(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x250(%rbp),%rdi
mov    %eax,%esi
lea    -0x238(%rbp),%rdx
call   1090 <Base64Decode@plt>
mov    %rax,-0x240(%rbp)
cmp    $0x0,%rax
je     12b5 <main+0x135>
mov    -0x240(%rbp),%rsi
mov    -0x238(%rbp),%rdx
lea    0xda2(%rip),%rdi
call   1050 <printf@plt>
mov    -0x240(%rbp),%rdi
call   10a0 <Base64StringFree@plt>
jmp    12ba <main+0x13a>
xor    %eax,%eax
add    $0x250,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x248,%rsp
movaps 0xe8f(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe73(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movabs $0x6f666e492065,%rax
mov    %rax,0x2f(%rsp)
lea    0x40(%rsp),%rdi
mov    $0x200,%edx
xor    %esi,%esi
call   1070 <memset@plt>
movq   $0x0,0x8(%rsp)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1040 <strlen@plt>
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <Base64Encode@plt>
test   %rax,%rax
je     1252 <main+0xe2>
mov    %rax,%rbx
mov    0x8(%rsp),%rdx
lea    0xe3c(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
lea    0xe49(%rip),%rdx
lea    0x40(%rsp),%r14
mov    %r14,%rdi
mov    $0x1ff,%esi
mov    %rbx,%rcx
call   1060 <snprintf@plt>
mov    %rbx,%rdi
call   1090 <Base64StringFree@plt>
mov    %r14,%rdi
call   1040 <strlen@plt>
lea    0x8(%rsp),%rdx
mov    %r14,%rdi
mov    %eax,%esi
call   1080 <Base64Decode@plt>
test   %rax,%rax
je     1252 <main+0xe2>
mov    %rax,%rbx
mov    0x8(%rsp),%rdx
lea    0xe04(%rip),%rdi
mov    %rax,%rsi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1090 <Base64StringFree@plt>
xor    %eax,%eax
add    $0x248,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.str = [39 x i8] c"This is Base64 Encode and Decode Info\00\00"
@.str = [28 x i8] c"Base64Encode: %s Length:%d\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [28 x i8] c"Base64Decode: %s Length:%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [39 x i8]
%3 = alloca [512 x i8]
%4 = alloca i64
%5 = alloca i8*
store i32 0, i32* %1
%6 = bitcast [39 x i8]* %2 to i8*
%7 = bitcast [512 x i8]* %3 to i8*
store i64 0, i64* %4
store i8* null, i8** %5
%8 = getelementptr inbounds [39 x i8], [39 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [39 x i8], [39 x i8]* %2, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
%11 = call i8* @Base64Encode(i8* %8, i32 %10, i64* %4)
store i8* %11, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %13, label %34
13: ; preds = %0
%14 = load i8*, i8** %5
%15 = load i64, i64* %4
%16 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %14, i64 %15)
%17 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%18 = load i8*, i8** %5
%19 = call i32 @snprintf(i8* %17, i32 511, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %18)
%20 = load i8*, i8** %5
%21 = call i32 @Base64StringFree(i8* %20)
%22 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%23 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%24 = call i32 @strlen(i8* %23)
%25 = call i8* @Base64Decode(i8* %22, i32 %24, i64* %4)
store i8* %25, i8** %5
%26 = icmp ne i8* %25, null
br i1 %26, label %27, label %33
27: ; preds = %13
%28 = load i8*, i8** %5
%29 = load i64, i64* %4
%30 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %28, i64 %29)
%31 = load i8*, i8** %5
%32 = call i32 @Base64StringFree(i8* %31)
br label %33
33: ; preds = %27, %13
br label %34
34: ; preds = %33, %0
ret i32 0
}

LLVM IR (-O2):
@__const.main.str = [39 x i8] c"This is Base64 Encode and Decode Info\00\00"
@.str = [28 x i8] c"Base64Encode: %s Length:%d\0A\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [28 x i8] c"Base64Decode: %s Length:%d\0A\00"
define i32 @main() {
%1 = alloca [39 x i8]
%2 = alloca [512 x i8]
%3 = alloca i64
%4 = getelementptr inbounds [39 x i8], [39 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%6 = bitcast i64* %3 to i8*
store i64 0, i64* %3
%7 = call i32 @strlen(i8* %4)
%8 = call i8* @Base64Encode(i8* %4, i32 %7, i64* %3)
%9 = icmp eq i8* %8, null
br i1 %9, label %22, label %10
10: ; preds = %0
%11 = load i64, i64* %3
%12 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* %8, i64 %11)
%13 = call i32 @snprintf(i8* %5, i32 511, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%14 = call i32 @Base64StringFree(i8* %8)
%15 = call i32 @strlen(i8* %5)
%16 = call i8* @Base64Decode(i8* %5, i32 %15, i64* %3)
%17 = icmp eq i8* %16, null
br i1 %17, label %22, label %18
18: ; preds = %10
%19 = load i64, i64* %3
%20 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* %16, i64 %19)
%21 = call i32 @Base64StringFree(i8* %16)
br label %22
22: ; preds = %10, %18, %0
ret i32 0
}