#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 /*<<< orphan*/ BIO_read(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ BIO_set_flags(int /*<<< orphan*/ *, int /*<<< orphan*/);
scalar_t__ malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
char *base64_to_sha256_binary(unsigned char *input) {
  BIO *b64, *bmem;
  int length = 44;
  char *buffer = (char *)malloc(length);
  memset(buffer, 0, length);
  b64 = BIO_new(BIO_f_base64());
  BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
  bmem = BIO_new_mem_buf(input, length);
  bmem = BIO_push(b64, bmem);
  BIO_read(bmem, buffer, length);
  BIO_free_all(bmem);
  return buffer;
}


x86 assembly (clang, -O0):
<base64_to_sha256_binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x2c,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   1090 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%edx
xor    %esi,%esi
call   1060 <memset@plt>
mov    $0x0,%al
call   1050 <BIO_f_base64@plt>
mov    %eax,%edi
call   10a0 <BIO_new@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e06(%rip),%rax
mov    (%rax),%esi
call   1070 <BIO_set_flags@plt>
mov    -0x8(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1080 <BIO_new_mem_buf@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <BIO_push@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <BIO_read@plt>
mov    -0x18(%rbp),%rdi
call   10b0 <BIO_free_all@plt>
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<base64_to_sha256_binary>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
mov    $0x2c,%edi
call   1090 <malloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x2c,%edx
call   1060 <memset@plt>
xor    %eax,%eax
call   1050 <BIO_f_base64@plt>
mov    %eax,%edi
call   10a0 <BIO_new@plt>
mov    %rax,%rbx
mov    0x2e14(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1070 <BIO_set_flags@plt>
mov    %r14,%rdi
mov    $0x2c,%esi
call   1080 <BIO_new_mem_buf@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <BIO_push@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
mov    $0x2c,%edx
call   1040 <BIO_read@plt>
mov    %rbx,%rdi
call   10b0 <BIO_free_all@plt>
mov    %r15,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@BIO_FLAGS_BASE64_NO_NL = global i32 0
define i8* @base64_to_sha256_binary(i8* %0) {
%2 = tail call i64 @malloc(i32 44)
%3 = inttoptr i64 %2 to i8*
%4 = tail call i32 @memset(i8* %3, i32 0, i32 44)
%5 = tail call i32 (...) @BIO_f_base64()
%6 = tail call i32* @BIO_new(i32 %5)
%7 = load i32, i32* @BIO_FLAGS_BASE64_NO_NL
%8 = tail call i32 @BIO_set_flags(i32* %6, i32 %7)
%9 = tail call i32* @BIO_new_mem_buf(i8* %0, i32 44)
%10 = tail call i32* @BIO_push(i32* %6, i32* %9)
%11 = tail call i32 @BIO_read(i32* %10, i8* %3, i32 44)
%12 = tail call i32 @BIO_free_all(i32* %10)
ret i8* %3
}