#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 */
int /*<<< orphan*/ EVP_CIPHER_CTX_cleanup(int /*<<< orphan*/ *);
int /*<<< orphan*/ EVP_CIPHER_CTX_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *EVP_CIPHER_CTX_new();
int /*<<< orphan*/ EVP_CIPHER_CTX_set_padding(int /*<<< orphan*/ *,
                                              int /*<<< orphan*/);
int /*<<< orphan*/ EVP_EncryptInit(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                   unsigned char const *,
                                   unsigned char const *);
int /*<<< orphan*/ EVP_aes_128_ecb();
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char const *, int);
int /*<<< orphan*/ memxor(unsigned char *, unsigned char const *, int);
int /*<<< orphan*/ mixoaep_unpad(int /*<<< orphan*/ *, unsigned char *,
                                 unsigned char *, int);
void mixdecrypt_bimacroblock_oaep_recursive(const unsigned char *bimacro,
                                            unsigned char *out,
                                            unsigned char *buffer,
                                            const unsigned char *key,
                                            const unsigned char *iv) {
  EVP_CIPHER_CTX *gctx = EVP_CIPHER_CTX_new();
  EVP_EncryptInit(gctx, EVP_aes_128_ecb(), key, iv);
  EVP_CIPHER_CTX_set_padding(gctx, 0);
  memcpy(out, bimacro, (2 * (4 * 4096)));
  mixoaep_unpad(gctx, out, buffer, (2 * (4 * 4096)));
  memxor(out, iv, 16);
  EVP_CIPHER_CTX_cleanup(gctx);
  EVP_CIPHER_CTX_free(gctx);
}


x86 assembly (clang, -O0):
<mixdecrypt_bimacroblock_oaep_recursive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    $0x0,%al
call   1090 <EVP_CIPHER_CTX_new@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    $0x0,%al
call   1060 <EVP_aes_128_ecb@plt>
mov    -0x38(%rbp),%rdi
mov    %eax,%esi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
call   10a0 <EVP_EncryptInit@plt>
mov    -0x30(%rbp),%rdi
xor    %esi,%esi
call   1070 <EVP_CIPHER_CTX_set_padding@plt>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x8000,%edx
call   1050 <memcpy@plt>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    $0x8000,%ecx
call   1080 <mixoaep_unpad@plt>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    $0x10,%edx
call   1030 <memxor@plt>
mov    -0x30(%rbp),%rdi
call   10b0 <EVP_CIPHER_CTX_cleanup@plt>
mov    -0x30(%rbp),%rdi
call   1040 <EVP_CIPHER_CTX_free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mixdecrypt_bimacroblock_oaep_recursive>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%r13
mov    %rdx,%r12
mov    %rsi,%r15
mov    %rdi,%rbp
xor    %eax,%eax
call   1090 <EVP_CIPHER_CTX_new@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   1060 <EVP_aes_128_ecb@plt>
mov    %rbx,%rdi
mov    %eax,%esi
mov    %r13,%rdx
mov    %r14,%rcx
call   10a0 <EVP_EncryptInit@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1070 <EVP_CIPHER_CTX_set_padding@plt>
mov    %r15,%rdi
mov    %rbp,%rsi
mov    $0x8000,%edx
call   1050 <memcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    $0x8000,%ecx
call   1080 <mixoaep_unpad@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    $0x10,%edx
call   1030 <memxor@plt>
mov    %rbx,%rdi
call   10b0 <EVP_CIPHER_CTX_cleanup@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <EVP_CIPHER_CTX_free@plt>

LLVM IR (-O0):
define void @mixdecrypt_bimacroblock_oaep_recursive(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32*
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%12 = call i32* (...) @EVP_CIPHER_CTX_new()
store i32* %12, i32** %11
%13 = load i32*, i32** %11
%14 = call i32 (...) @EVP_aes_128_ecb()
%15 = load i8*, i8** %9
%16 = load i8*, i8** %10
%17 = call i32 @EVP_EncryptInit(i32* %13, i32 %14, i8* %15, i8* %16)
%18 = load i32*, i32** %11
%19 = call i32 @EVP_CIPHER_CTX_set_padding(i32* %18, i32 0)
%20 = load i8*, i8** %7
%21 = load i8*, i8** %6
%22 = call i32 @memcpy(i8* %20, i8* %21, i32 32768)
%23 = load i32*, i32** %11
%24 = load i8*, i8** %7
%25 = load i8*, i8** %8
%26 = call i32 @mixoaep_unpad(i32* %23, i8* %24, i8* %25, i32 32768)
%27 = load i8*, i8** %7
%28 = load i8*, i8** %10
%29 = call i32 @memxor(i8* %27, i8* %28, i32 16)
%30 = load i32*, i32** %11
%31 = call i32 @EVP_CIPHER_CTX_cleanup(i32* %30)
%32 = load i32*, i32** %11
%33 = call i32 @EVP_CIPHER_CTX_free(i32* %32)
ret void
}

LLVM IR (-O2):
define void @mixdecrypt_bimacroblock_oaep_recursive(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = tail call i32* (...) @EVP_CIPHER_CTX_new()
%7 = tail call i32 (...) @EVP_aes_128_ecb()
%8 = tail call i32 @EVP_EncryptInit(i32* %6, i32 %7, i8* %3, i8* %4)
%9 = tail call i32 @EVP_CIPHER_CTX_set_padding(i32* %6, i32 0)
%10 = tail call i32 @memcpy(i8* %1, i8* %0, i32 32768)
%11 = tail call i32 @mixoaep_unpad(i32* %6, i8* %1, i8* %2, i32 32768)
%12 = tail call i32 @memxor(i8* %1, i8* %4, i32 16)
%13 = tail call i32 @EVP_CIPHER_CTX_cleanup(i32* %6)
%14 = tail call i32 @EVP_CIPHER_CTX_free(i32* %6)
ret void
}