#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*/ uint8_t;
typedef int /*<<< orphan*/ BIO;

/* Variables and functions */
int /*<<< orphan*/ BIO_FLAGS_BASE64_NO_NL;
int /*<<< orphan*/ BIO_f_base64();
int /*<<< orphan*/ BIO_flush(int /*<<< orphan*/ *);
int /*<<< orphan*/ BIO_free_all(int /*<<< orphan*/ *);
int /*<<< orphan*/ BIO_get_mem_data(int /*<<< orphan*/ *, char **);
int /*<<< orphan*/ *BIO_new(int /*<<< orphan*/);
int /*<<< orphan*/ BIO_push(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ BIO_s_mem();
int /*<<< orphan*/ BIO_set_flags(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ BIO_write(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ md5(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
void base64_md5(char passw[]) {
  BIO *b64, *mem;
  uint8_t dgst[16];
  char *base64_str;
  md5(passw, dgst);
  b64 = BIO_new(BIO_f_base64());
  BIO_set_flags(b64, BIO_FLAGS_BASE64_NO_NL);
  mem = BIO_new(BIO_s_mem());
  BIO_push(b64, mem);
  BIO_write(b64, dgst, 16);
  BIO_flush(b64);
  BIO_get_mem_data(b64, &base64_str);
  printf("\n  ACS Password : %s\n", base64_str);
  BIO_free_all(b64);
}


x86 assembly (clang, -O0):
<base64_md5>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x60(%rbp),%rsi
call   1090 <md5@plt>
mov    $0x0,%al
call   1040 <BIO_f_base64@plt>
mov    %eax,%edi
call   1070 <BIO_new@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2dfa(%rip),%rax
mov    (%rax),%esi
call   1060 <BIO_set_flags@plt>
mov    $0x0,%al
call   10b0 <BIO_s_mem@plt>
mov    %eax,%edi
call   1070 <BIO_new@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <BIO_push@plt>
mov    -0x10(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    $0x10,%edx
call   10a0 <BIO_write@plt>
mov    -0x10(%rbp),%rdi
call   10d0 <BIO_flush@plt>
mov    -0x10(%rbp),%rdi
lea    -0x68(%rbp),%rsi
call   10c0 <BIO_get_mem_data@plt>
mov    -0x68(%rbp),%rsi
lea    0xdc1(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1080 <BIO_free_all@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<base64_md5>:
push   %r14
push   %rbx
sub    $0x58,%rsp
lea    0x10(%rsp),%r14
mov    %r14,%rsi
call   1090 <md5@plt>
xor    %eax,%eax
call   1040 <BIO_f_base64@plt>
mov    %eax,%edi
call   1070 <BIO_new@plt>
mov    %rax,%rbx
mov    0x2e04(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1060 <BIO_set_flags@plt>
xor    %eax,%eax
call   10b0 <BIO_s_mem@plt>
mov    %eax,%edi
call   1070 <BIO_new@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <BIO_push@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x10,%edx
call   10a0 <BIO_write@plt>
mov    %rbx,%rdi
call   10d0 <BIO_flush@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   10c0 <BIO_get_mem_data@plt>
mov    0x8(%rsp),%rsi
lea    0xdd0(%rip),%rdi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1080 <BIO_free_all@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@BIO_FLAGS_BASE64_NO_NL = global i32 0
@.str = [22 x i8] c"\0A ACS Password : %s\0A\00"
define void @base64_md5(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca [16 x i32]
%6 = alloca i8*
store i8* %0, i8** %2
%7 = load i8*, i8** %2
%8 = getelementptr inbounds [16 x i32], [16 x i32]* %5, i64 0, i64 0
%9 = call i32 @md5(i8* %7, i32* %8)
%10 = call i32 (...) @BIO_f_base64()
%11 = call i32* @BIO_new(i32 %10)
store i32* %11, i32** %3
%12 = load i32*, i32** %3
%13 = load i32, i32* @BIO_FLAGS_BASE64_NO_NL
%14 = call i32 @BIO_set_flags(i32* %12, i32 %13)
%15 = call i32 (...) @BIO_s_mem()
%16 = call i32* @BIO_new(i32 %15)
store i32* %16, i32** %4
%17 = load i32*, i32** %3
%18 = load i32*, i32** %4
%19 = call i32 @BIO_push(i32* %17, i32* %18)
%20 = load i32*, i32** %3
%21 = getelementptr inbounds [16 x i32], [16 x i32]* %5, i64 0, i64 0
%22 = call i32 @BIO_write(i32* %20, i32* %21, i32 16)
%23 = load i32*, i32** %3
%24 = call i32 @BIO_flush(i32* %23)
%25 = load i32*, i32** %3
%26 = call i32 @BIO_get_mem_data(i32* %25, i8** %6)
%27 = load i8*, i8** %6
%28 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %27)
%29 = load i32*, i32** %3
%30 = call i32 @BIO_free_all(i32* %29)
ret void
}

LLVM IR (-O2):
@BIO_FLAGS_BASE64_NO_NL = global i32 0
@.str = [22 x i8] c"\0A ACS Password : %s\0A\00"
define void @base64_md5(i8* %0) {
%2 = alloca [16 x i32]
%3 = alloca i8*
%4 = bitcast [16 x i32]* %2 to i8*
%5 = bitcast i8** %3 to i8*
%6 = getelementptr inbounds [16 x i32], [16 x i32]* %2, i64 0, i64 0
%7 = call i32 @md5(i8* %0, i32* %6)
%8 = call i32 (...) @BIO_f_base64()
%9 = call i32* @BIO_new(i32 %8)
%10 = load i32, i32* @BIO_FLAGS_BASE64_NO_NL
%11 = call i32 @BIO_set_flags(i32* %9, i32 %10)
%12 = call i32 (...) @BIO_s_mem()
%13 = call i32* @BIO_new(i32 %12)
%14 = call i32 @BIO_push(i32* %9, i32* %13)
%15 = call i32 @BIO_write(i32* %9, i32* %6, i32 16)
%16 = call i32 @BIO_flush(i32* %9)
%17 = call i32 @BIO_get_mem_data(i32* %9, i8** %3)
%18 = load i8*, i8** %3
%19 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = call i32 @BIO_free_all(i32* %9)
ret void
}