#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*/ base64_stream_encode(char const *const, size_t, char *const,
                                        size_t *);
int /*<<< orphan*/ base64_stream_encode_final(char *const, size_t *);
int /*<<< orphan*/ base64_stream_encode_init();
void base64_encode(const char *const src, size_t srclen, char *const out,
                   size_t *outlen) {
  size_t s;
  size_t t;
  base64_stream_encode_init();
  base64_stream_encode(src, srclen, out, &s);
  base64_stream_encode_final(out + s, &t);
  *outlen = s + t;
}


x86 assembly (clang, -O0):
<base64_encode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    $0x0,%al
call   1040 <base64_stream_encode_init@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    -0x28(%rbp),%rcx
call   1050 <base64_stream_encode@plt>
mov    -0x18(%rbp),%rdi
add    -0x28(%rbp),%rdi
lea    -0x30(%rbp),%rsi
call   1030 <base64_stream_encode_final@plt>
mov    -0x28(%rbp),%rcx
add    -0x30(%rbp),%rcx
mov    -0x20(%rbp),%rax
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<base64_encode>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%r12
xor    %eax,%eax
call   1040 <base64_stream_encode_init@plt>
lea    0x8(%rsp),%rcx
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1050 <base64_stream_encode@plt>
add    0x8(%rsp),%rbx
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <base64_stream_encode_final@plt>
mov    0x10(%rsp),%rax
add    0x8(%rsp),%rax
mov    %rax,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @base64_encode(i8* %0, i64 %1, i8* %2, i64* %3) {
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i64*
%9 = alloca i64
%10 = alloca i64
store i8* %0, i8** %5
store i64 %1, i64* %6
store i8* %2, i8** %7
store i64* %3, i64** %8
%11 = call i32 (...) @base64_stream_encode_init()
%12 = load i8*, i8** %5
%13 = load i64, i64* %6
%14 = load i8*, i8** %7
%15 = call i32 @base64_stream_encode(i8* %12, i64 %13, i8* %14, i64* %9)
%16 = load i8*, i8** %7
%17 = load i64, i64* %9
%18 = getelementptr inbounds i8, i8* %16, i64 %17
%19 = call i32 @base64_stream_encode_final(i8* %18, i64* %10)
%20 = load i64, i64* %9
%21 = load i64, i64* %10
%22 = add i64 %20, %21
%23 = load i64*, i64** %8
store i64 %22, i64* %23
ret void
}

LLVM IR (-O2):
define void @base64_encode(i8* %0, i64 %1, i8* %2, i64* nocapture writeonly %3) {
%5 = alloca i64
%6 = alloca i64
%7 = bitcast i64* %5 to i8*
%8 = bitcast i64* %6 to i8*
%9 = tail call i32 (...) @base64_stream_encode_init()
%10 = call i32 @base64_stream_encode(i8* %0, i64 %1, i8* %2, i64* %5)
%11 = load i64, i64* %5
%12 = getelementptr inbounds i8, i8* %2, i64 %11
%13 = call i32 @base64_stream_encode_final(i8* %12, i64* %6)
%14 = load i64, i64* %5
%15 = load i64, i64* %6
%16 = add i64 %15, %14
store i64 %16, i64* %3
ret void
}