#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*/ BIO;

/* Variables and functions */
int /*<<< orphan*/ BIO_FLAGS_BASE64_NO_NL;
int /*<<< orphan*/ BIO_f_base64();
int /*<<< orphan*/ BIO_free_all(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BIO_new(int /*<<< orphan*/);
int /*<<< orphan*/ *BIO_new_mem_buf(unsigned char *, int);
int /*<<< orphan*/ *BIO_push(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int BIO_read(int /*<<< orphan*/ *, unsigned char *, int);
int /*<<< orphan*/ BIO_set_flags(int /*<<< orphan*/ *, int /*<<< orphan*/);
void b64_dec(unsigned char *in, int in_len, unsigned char *out, int *out_len) {
  BIO *bio, *b64;
  bio = BIO_new_mem_buf(in, in_len);
  b64 = BIO_new(BIO_f_base64());
  bio = BIO_push(b64, bio);
  BIO_set_flags(bio, BIO_FLAGS_BASE64_NO_NL);
  *out_len = BIO_read(bio, out, in_len);
  BIO_free_all(bio);
}


x86 assembly (clang, -O0):
<b64_dec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1070 <BIO_new_mem_buf@plt>
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1050 <BIO_f_base64@plt>
mov    %eax,%edi
call   1080 <BIO_new@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <BIO_push@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    0x2e1b(%rip),%rax
mov    (%rax),%esi
call   1060 <BIO_set_flags@plt>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0xc(%rbp),%edx
call   1040 <BIO_read@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rdi
call   1090 <BIO_free_all@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<b64_dec>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %esi,%ebp
call   1070 <BIO_new_mem_buf@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1050 <BIO_f_base64@plt>
mov    %eax,%edi
call   1080 <BIO_new@plt>
mov    %rax,%rdi
mov    %rbx,%rsi
call   1030 <BIO_push@plt>
mov    %rax,%rbx
mov    0x2e36(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1060 <BIO_set_flags@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1040 <BIO_read@plt>
mov    %eax,(%r14)
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <BIO_free_all@plt>

LLVM IR (-O0):
@BIO_FLAGS_BASE64_NO_NL = global i32 0
define void @b64_dec(i8* %0, i32 %1, i8* %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32*
store i8* %0, i8** %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i32* %3, i32** %8
%11 = load i8*, i8** %5
%12 = load i32, i32* %6
%13 = call i32* @BIO_new_mem_buf(i8* %11, i32 %12)
store i32* %13, i32** %9
%14 = call i32 (...) @BIO_f_base64()
%15 = call i32* @BIO_new(i32 %14)
store i32* %15, i32** %10
%16 = load i32*, i32** %10
%17 = load i32*, i32** %9
%18 = call i32* @BIO_push(i32* %16, i32* %17)
store i32* %18, i32** %9
%19 = load i32*, i32** %9
%20 = load i32, i32* @BIO_FLAGS_BASE64_NO_NL
%21 = call i32 @BIO_set_flags(i32* %19, i32 %20)
%22 = load i32*, i32** %9
%23 = load i8*, i8** %7
%24 = load i32, i32* %6
%25 = call i32 @BIO_read(i32* %22, i8* %23, i32 %24)
%26 = load i32*, i32** %8
store i32 %25, i32* %26
%27 = load i32*, i32** %9
%28 = call i32 @BIO_free_all(i32* %27)
ret void
}

LLVM IR (-O2):
@BIO_FLAGS_BASE64_NO_NL = global i32 0
define void @b64_dec(i8* %0, i32 %1, i8* %2, i32* nocapture writeonly %3) {
%5 = tail call i32* @BIO_new_mem_buf(i8* %0, i32 %1)
%6 = tail call i32 (...) @BIO_f_base64()
%7 = tail call i32* @BIO_new(i32 %6)
%8 = tail call i32* @BIO_push(i32* %7, i32* %5)
%9 = load i32, i32* @BIO_FLAGS_BASE64_NO_NL
%10 = tail call i32 @BIO_set_flags(i32* %8, i32 %9)
%11 = tail call i32 @BIO_read(i32* %8, i8* %2, i32 %1)
store i32 %11, i32* %3
%12 = tail call i32 @BIO_free_all(i32* %8)
ret void
}