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

/* Variables and functions */
scalar_t__ AES_BLOCK_SIZE;
int /*<<< orphan*/ EVP_DecryptFinal_ex(int /*<<< orphan*/ *, unsigned char *,
                                       int *);
int /*<<< orphan*/ EVP_DecryptInit_ex(int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *);
int /*<<< orphan*/ EVP_DecryptUpdate(int /*<<< orphan*/ *, unsigned char *,
                                     int *, unsigned char *, int);
unsigned char *malloc(scalar_t__);
unsigned char *_decrypt(EVP_CIPHER_CTX *e, unsigned char *ciphertext,
                        int *len) {
  int p_len = *len, f_len = 0;
  unsigned char *plaintext = malloc(p_len + AES_BLOCK_SIZE);
  EVP_DecryptInit_ex(e, NULL, NULL, NULL, NULL);
  EVP_DecryptUpdate(e, plaintext, &p_len, ciphertext, *len);
  EVP_DecryptFinal_ex(e, plaintext + p_len, &f_len);
  *len = p_len + f_len;
  return plaintext;
}


x86 assembly (clang, -O0):
<_decrypt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movslq -0x1c(%rbp),%rdi
mov    0x2e79(%rip),%rax
add    (%rax),%rdi
call   1040 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rsi
mov    %r8,%rdx
mov    %r8,%rcx
call   1050 <EVP_DecryptInit_ex@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    (%rax),%r8d
lea    -0x1c(%rbp),%rdx
call   1060 <EVP_DecryptUpdate@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
movslq -0x1c(%rbp),%rax
add    %rax,%rsi
lea    -0x20(%rbp),%rdx
call   1030 <EVP_DecryptFinal_ex@plt>
mov    -0x1c(%rbp),%ecx
add    -0x20(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_decrypt>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
movslq (%rdx),%rdi
mov    %edi,(%rsp)
movl   $0x0,0x4(%rsp)
mov    0x2e82(%rip),%rax
add    (%rax),%rdi
call   1040 <malloc@plt>
mov    %rax,%rbx
mov    %r15,%rdi
xor    %esi,%esi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1050 <EVP_DecryptInit_ex@plt>
mov    (%r14),%r8d
mov    %rsp,%rdx
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r12,%rcx
call   1060 <EVP_DecryptUpdate@plt>
movslq (%rsp),%rsi
add    %rbx,%rsi
lea    0x4(%rsp),%rdx
mov    %r15,%rdi
call   1030 <EVP_DecryptFinal_ex@plt>
mov    0x4(%rsp),%eax
add    (%rsp),%eax
mov    %eax,(%r14)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@AES_BLOCK_SIZE = global i64 0
define i8* @_decrypt(i32* %0, i8* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
%10 = load i32*, i32** %6
%11 = load i32, i32* %10
store i32 %11, i32* %7
store i32 0, i32* %8
%12 = load i32, i32* %7
%13 = sext i32 %12 to i64
%14 = load i64, i64* @AES_BLOCK_SIZE
%15 = add nsw i64 %13, %14
%16 = call i8* @malloc(i64 %15)
store i8* %16, i8** %9
%17 = load i32*, i32** %4
%18 = call i32 @EVP_DecryptInit_ex(i32* %17, i32* null, i32* null, i32* null, i32* null)
%19 = load i32*, i32** %4
%20 = load i8*, i8** %9
%21 = load i8*, i8** %5
%22 = load i32*, i32** %6
%23 = load i32, i32* %22
%24 = call i32 @EVP_DecryptUpdate(i32* %19, i8* %20, i32* %7, i8* %21, i32 %23)
%25 = load i32*, i32** %4
%26 = load i8*, i8** %9
%27 = load i32, i32* %7
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = call i32 @EVP_DecryptFinal_ex(i32* %25, i8* %29, i32* %8)
%31 = load i32, i32* %7
%32 = load i32, i32* %8
%33 = add nsw i32 %31, %32
%34 = load i32*, i32** %6
store i32 %33, i32* %34
%35 = load i8*, i8** %9
ret i8* %35
}

LLVM IR (-O2):
@AES_BLOCK_SIZE = global i64 0
define i8* @_decrypt(i32* %0, i8* %1, i32* nocapture %2) {
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %4 to i8*
%7 = load i32, i32* %2
store i32 %7, i32* %4
%8 = bitcast i32* %5 to i8*
store i32 0, i32* %5
%9 = sext i32 %7 to i64
%10 = load i64, i64* @AES_BLOCK_SIZE
%11 = add nsw i64 %10, %9
%12 = tail call i8* @malloc(i64 %11)
%13 = tail call i32 @EVP_DecryptInit_ex(i32* %0, i32* null, i32* null, i32* null, i32* null)
%14 = load i32, i32* %2
%15 = call i32 @EVP_DecryptUpdate(i32* %0, i8* %12, i32* %4, i8* %1, i32 %14)
%16 = load i32, i32* %4
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %12, i64 %17
%19 = call i32 @EVP_DecryptFinal_ex(i32* %0, i8* %18, i32* %5)
%20 = load i32, i32* %4
%21 = load i32, i32* %5
%22 = add nsw i32 %21, %20
store i32 %22, i32* %2
ret i8* %12
}