#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 */
typedef int /*<<< orphan*/ enc;
typedef int /*<<< orphan*/ dec;

/* Variables and functions */
int base64_dec(char *, int, char *, int);
int base64_enc(char *, int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ printf(char *, int, char *);
int main(int argc, char **argv) {
  char enc[4096], dec[4096];
  int i;
  i = base64_enc(argv[1], 0, enc, sizeof(enc));
  printf("base64_enc: i=%d buf=%s\n", i, enc);
  i = base64_dec(enc, i, dec, sizeof(dec));
  printf("base64_dec: i=%d buf=%s\n", i, dec);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2020,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    -0x1010(%rbp),%rdx
xor    %esi,%esi
mov    $0x1000,%ecx
call   1030 <base64_enc@plt>
mov    %eax,-0x2014(%rbp)
mov    -0x2014(%rbp),%esi
lea    -0x1010(%rbp),%rdx
lea    0xe82(%rip),%rdi
call   1040 <printf@plt>
lea    -0x1010(%rbp),%rdi
mov    -0x2014(%rbp),%esi
lea    -0x2010(%rbp),%rdx
mov    $0x1000,%ecx
call   1050 <base64_dec@plt>
mov    %eax,-0x2014(%rbp)
mov    -0x2014(%rbp),%esi
lea    -0x2010(%rbp),%rdx
lea    0xe5e(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x2020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x2000,%rsp
mov    0x8(%rsi),%rdi
lea    0x1000(%rsp),%rbx
xor    %esi,%esi
mov    %rbx,%rdx
mov    $0x1000,%ecx
call   1030 <base64_enc@plt>
mov    %eax,%ebp
lea    0xea1(%rip),%rdi
mov    %eax,%esi
mov    %rbx,%rdx
call   1040 <printf@plt>
mov    %rsp,%r14
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %r14,%rdx
mov    $0x1000,%ecx
call   1050 <base64_dec@plt>
lea    0xe94(%rip),%rdi
mov    %eax,%esi
mov    %r14,%rdx
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x2000,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"base64_enc: i=%d buf=%s\0A\00"
@.str.1 = [25 x i8] c"base64_dec: i=%d buf=%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [4096 x i8]
%7 = alloca [4096 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%13 = call i32 @base64_enc(i8* %11, i32 0, i8* %12, i32 4096)
store i32 %13, i32* %8
%14 = load i32, i32* %8
%15 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%16 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %14, i8* %15)
%17 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%18 = load i32, i32* %8
%19 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%20 = call i32 @base64_dec(i8* %17, i32 %18, i8* %19, i32 4096)
store i32 %20, i32* %8
%21 = load i32, i32* %8
%22 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%23 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %21, i8* %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [25 x i8] c"base64_enc: i=%d buf=%s\0A\00"
@.str.1 = [25 x i8] c"base64_dec: i=%d buf=%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4096 x i8]
%4 = alloca [4096 x i8]
%5 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = call i32 @base64_enc(i8* %8, i32 0, i8* %5, i32 4096)
%10 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i32 %9, i8* %5)
%11 = call i32 @base64_dec(i8* %5, i32 %9, i8* %6, i32 4096)
%12 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i32 %11, i8* %6)
ret i32 0
}