void encrypt(char *output, char *input[]) {
  printf("\n    encrypt()\n");
  int keyLength = 32;
  char key[keyLength];
  genKey(key, keyLength);
  char encrypted_message[1024] = {'0'};
  char encoded_message[1024] = {'0'};
  printf("      Encrypt Input Test:\t%s\n", input);
  base64_encode(encoded_message, input);
  printf("      Encrypt Base64 Encoded Input:\t%s\n", encoded_message);
  AES128_CBC_encrypt_buffer(encrypted_message, encoded_message, key);
  base64_encode(output, encrypted_message);
}


x86 assembly (clang, -O0):
<encrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x840,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xe96(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movl   $0x20,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x838(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%esi
mov    $0x0,%al
call   1050 <genKey@plt>
lea    -0x430(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
movb   $0x30,-0x430(%rbp)
lea    -0x830(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
movb   $0x30,-0x830(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x830(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1060 <base64_encode@plt>
lea    -0x830(%rbp),%rsi
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x838(%rbp),%rdx
lea    -0x430(%rbp),%rdi
lea    -0x830(%rbp),%rsi
mov    $0x0,%al
call   1070 <AES128_CBC_encrypt_buffer@plt>
mov    -0x8(%rbp),%rdi
lea    -0x430(%rbp),%rsi
mov    $0x0,%al
call   1060 <base64_encode@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<encrypt>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x820,%rsp
mov    %rsi,%r13
mov    %rdi,%r15
lea    0xec9(%rip),%rdi
call   1030 <puts@plt>
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x20,%esi
xor    %eax,%eax
call   1060 <genKey@plt>
lea    0x420(%rsp),%r12
mov    $0x400,%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
movb   $0x30,0x420(%rsp)
30
lea    0x20(%rsp),%rbx
mov    $0x400,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
movb   $0x30,0x20(%rsp)
lea    0xe2d(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1070 <base64_encode@plt>
lea    0xe2d(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1080 <AES128_CBC_encrypt_buffer@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1070 <base64_encode@plt>
add    $0x820,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [16 x i8] c"\0A encrypt()\0A\00"
@.str.1 = [30 x i8] c" Encrypt Input Test:\09%s\0A\00"
@.str.2 = [40 x i8] c" Encrypt Base64 Encoded Input:\09%s\0A\00"
define void @encrypt(i8* %0, i8** %1) {
%3 = alloca i8*
%4 = alloca i8**
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca [1024 x i8]
%9 = alloca [1024 x i8]
store i8* %0, i8** %3
store i8** %1, i8*** %4
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i32 32, i32* %5
%11 = load i32, i32* %5
%12 = zext i32 %11 to i64
%13 = call i8* @llvm.stacksave()
store i8* %13, i8** %6
%14 = alloca i8, i64 %12
store i64 %12, i64* %7
%15 = load i32, i32* %5
%16 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @genKey to i32 (i8*, i32, ...)*)(i8* %14, i32 %15)
%17 = bitcast [1024 x i8]* %8 to i8*
%18 = bitcast i8* %17 to <{ i8, [1023 x i8] }>*
%19 = getelementptr inbounds <{ i8, [1023 x i8] }>, <{ i8, [1023 x i8] }>* %18, i32 0, i32 0
store i8 48, i8* %19
%20 = bitcast [1024 x i8]* %9 to i8*
%21 = bitcast i8* %20 to <{ i8, [1023 x i8] }>*
%22 = getelementptr inbounds <{ i8, [1023 x i8] }>, <{ i8, [1023 x i8] }>* %21, i32 0, i32 0
store i8 48, i8* %22
%23 = load i8**, i8*** %4
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8** %23)
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%26 = load i8**, i8*** %4
%27 = call i32 (i8*, i8**, ...) bitcast (i32 (...)* @base64_encode to i32 (i8*, i8**, ...)*)(i8* %25, i8** %26)
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%32 = call i32 (i8*, i8*, i8*, ...) bitcast (i32 (...)* @AES128_CBC_encrypt_buffer to i32 (i8*, i8*, i8*, ...)*)(i8* %30, i8* %31, i8* %14)
%33 = load i8*, i8** %3
%34 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%35 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @base64_encode to i32 (i8*, i8*, ...)*)(i8* %33, i8* %34)
%36 = load i8*, i8** %6
ret void
}

LLVM IR (-O2):
@.str.1 = [30 x i8] c" Encrypt Input Test:\09%s\0A\00"
@.str.2 = [40 x i8] c" Encrypt Base64 Encoded Input:\09%s\0A\00"
@str = [15 x i8] c"\0A encrypt()\00"
define void @encrypt(i8* %0, i8** %1) {
%3 = alloca [1024 x i8]
%4 = alloca [1024 x i8]
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%6 = alloca [32 x i8]
%7 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%8 = call i32 (i8*, i32, ...) bitcast (i32 (...)* @genKey to i32 (i8*, i32, ...)*)(i8* %7, i32 32)
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
store i8 48, i8* %9
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
store i8 48, i8* %10
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8** %1)
%12 = call i32 (i8*, i8**, ...) bitcast (i32 (...)* @base64_encode to i32 (i8*, i8**, ...)*)(i8* %10, i8** %1)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%14 = call i32 (i8*, i8*, i8*, ...) bitcast (i32 (...)* @AES128_CBC_encrypt_buffer to i32 (i8*, i8*, i8*, ...)*)(i8* %9, i8* %10, i8* %7)
%15 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @base64_encode to i32 (i8*, i8*, ...)*)(i8* %0, i8* %9)
ret void
}