#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*/ AES128_CBC_decrypt_buffer(char *, char *, char *);
int /*<<< orphan*/ base64_decode(char *, char *);
int /*<<< orphan*/ genKey(char *, int);
int /*<<< orphan*/ printf(char *, ...);
void decrypt(char *output, char *input) {
  printf("\n    decrypt()\n");
  int keyLength = 32;
  char key[keyLength];
  genKey(key, keyLength);
  char decoded_encrypted_message[1024] = {'\0'};
  char decoded_decrypted_encoded_message[1024] = {'\0'};
  printf("      Decrypt Input Test:\t%s\n", input);
  base64_decode(decoded_encrypted_message, input);
  AES128_CBC_decrypt_buffer(decoded_decrypted_encoded_message,
                            decoded_encrypted_message, key);
  base64_decode(output, decoded_decrypted_encoded_message);
}


x86 assembly (clang, -O0):
<decrypt>:
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
call   1060 <genKey@plt>
lea    -0x430(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
lea    -0x830(%rbp),%rdi
xor    %esi,%esi
mov    $0x400,%edx
call   1040 <memset@plt>
mov    -0x10(%rbp),%rsi
lea    0xe36(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x430(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1070 <base64_decode@plt>
mov    -0x838(%rbp),%rdx
lea    -0x830(%rbp),%rdi
lea    -0x430(%rbp),%rsi
call   1050 <AES128_CBC_decrypt_buffer@plt>
mov    -0x8(%rbp),%rdi
lea    -0x830(%rbp),%rsi
call   1070 <base64_decode@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
@.str = [16 x i8] c"\0A decrypt()\0A\00"
@.str.1 = [30 x i8] c" Decrypt Input Test:\09%s\0A\00"
define void @decrypt(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 @genKey(i8* %14, i32 %15)
%17 = bitcast [1024 x i8]* %8 to i8*
%18 = bitcast [1024 x i8]* %9 to i8*
%19 = load i8*, i8** %4
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%22 = load i8*, i8** %4
%23 = call i32 @base64_decode(i8* %21, i8* %22)
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%26 = call i32 @AES128_CBC_decrypt_buffer(i8* %24, i8* %25, i8* %14)
%27 = load i8*, i8** %3
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%29 = call i32 @base64_decode(i8* %27, i8* %28)
%30 = load i8*, i8** %6
ret void
}

LLVM IR (-O2):
@.str.1 = [30 x i8] c" Decrypt Input Test:\09%s\0A\00"
@str = [15 x i8] c"\0A decrypt()\00"
define void @decrypt(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 @genKey(i8* %7, i32 32)
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%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 @base64_decode(i8* %9, i8* %1)
%13 = call i32 @AES128_CBC_decrypt_buffer(i8* %10, i8* %9, i8* %7)
%14 = call i32 @base64_decode(i8* %0, i8* %10)
ret void
}