#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*/ msg;
typedef unsigned char EVP_PKEY;
typedef unsigned char EVP_CIPHER_CTX;
typedef int /*<<< orphan*/ EVP_CIPHER;

/* Variables and functions */
int /*<<< orphan*/ EVP_CIPHER_CTX_free(unsigned char *);
unsigned char *EVP_CIPHER_CTX_new();
int EVP_MAX_IV_LENGTH;
scalar_t__ EVP_OpenFinal(unsigned char *, unsigned char *, int *);
scalar_t__ EVP_OpenInit(unsigned char *, int /*<<< orphan*/ const *,
                        unsigned char *, int, unsigned char *, unsigned char *);
scalar_t__ EVP_OpenUpdate(unsigned char *, unsigned char *, int *,
                          unsigned char *, int);
int /*<<< orphan*/ EVP_PKEY_free(unsigned char *);
int /*<<< orphan*/ EVP_PKEY_size(unsigned char *);
scalar_t__ EVP_SealFinal(unsigned char *, unsigned char *, int *);
scalar_t__ EVP_SealInit(unsigned char *, int /*<<< orphan*/ const *,
                        unsigned char **, int *, unsigned char *,
                        unsigned char **, int);
scalar_t__ EVP_SealUpdate(unsigned char *, unsigned char *, int *,
                          unsigned char const *, int);
int /*<<< orphan*/ *EVP_aes_256_cbc();
int /*<<< orphan*/ OPENSSL_free(unsigned char *);
unsigned char *OPENSSL_zalloc(int /*<<< orphan*/);
unsigned char *load_example_rsa_key();
int /*<<< orphan*/ test_mem_eq(char *, int, char *, char *,
                               unsigned char const *, int, unsigned char *,
                               int);
int /*<<< orphan*/ test_ptr(char *, int, char *, unsigned char *);
int /*<<< orphan*/ test_true(char *, int, char *, int);
int test_EVP_Enveloped(void) {
  int ret = 0;
  EVP_CIPHER_CTX *ctx = NULL;
  EVP_PKEY *keypair = NULL;
  unsigned char *kek = NULL;
  unsigned char iv[EVP_MAX_IV_LENGTH];
  static const unsigned char msg[] = {1, 2, 3, 4, 5, 6, 7, 8};
  int len, kek_len, ciphertext_len, plaintext_len;
  unsigned char ciphertext[32], plaintext[16];
  const EVP_CIPHER *type = EVP_aes_256_cbc();
  if (!test_ptr("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/"
                "refs/heads/master/Src/OSF/OpenSSL-111/test/evp_extra_test.c",
                387, "keypair = load_example_rsa_key()",
                keypair = load_example_rsa_key()) ||
      !test_ptr("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/"
                "refs/heads/master/Src/OSF/OpenSSL-111/test/evp_extra_test.c",
                388, "kek = OPENSSL_zalloc(EVP_PKEY_size(keypair))",
                kek = OPENSSL_zalloc(EVP_PKEY_size(keypair))) ||
      !test_ptr("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/"
                "refs/heads/master/Src/OSF/OpenSSL-111/test/evp_extra_test.c",
                389, "ctx = EVP_CIPHER_CTX_new()",
                ctx = EVP_CIPHER_CTX_new()) ||
      !test_true(
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/"
          "master/Src/OSF/OpenSSL-111/test/evp_extra_test.c",
          390, "EVP_SealInit(ctx, type, &kek, &kek_len, iv, &keypair, 1)",
          (EVP_SealInit(ctx, type, &kek, &kek_len, iv, &keypair, 1)) != 0) ||
      !test_true(
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/"
          "master/Src/OSF/OpenSSL-111/test/evp_extra_test.c",
          392,
          "EVP_SealUpdate(ctx, ciphertext, &ciphertext_len, msg, sizeof(msg))",
          (EVP_SealUpdate(ctx, ciphertext, &ciphertext_len, msg,
                          sizeof(msg))) != 0) ||
      !test_true(
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/"
          "master/Src/OSF/OpenSSL-111/test/evp_extra_test.c",
          394, "EVP_SealFinal(ctx, ciphertext + ciphertext_len, &len)",
          (EVP_SealFinal(ctx, ciphertext + ciphertext_len, &len)) != 0))
    goto err;
  ciphertext_len += len;
  if (!test_true(
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/"
          "master/Src/OSF/OpenSSL-111/test/evp_extra_test.c",
          400, "EVP_OpenInit(ctx, type, kek, kek_len, iv, keypair)",
          (EVP_OpenInit(ctx, type, kek, kek_len, iv, keypair)) != 0) ||
      !test_true(
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/"
          "master/Src/OSF/OpenSSL-111/test/evp_extra_test.c",
          401,
          "EVP_OpenUpdate(ctx, plaintext, &plaintext_len, ciphertext, "
          "ciphertext_len)",
          (EVP_OpenUpdate(ctx, plaintext, &plaintext_len, ciphertext,
                          ciphertext_len)) != 0) ||
      !test_true(
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/"
          "master/Src/OSF/OpenSSL-111/test/evp_extra_test.c",
          403, "EVP_OpenFinal(ctx, plaintext + plaintext_len, &len)",
          (EVP_OpenFinal(ctx, plaintext + plaintext_len, &len)) != 0))
    goto err;
  plaintext_len += len;
  if (!test_mem_eq(
          "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
          "2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/"
          "master/Src/OSF/OpenSSL-111/test/evp_extra_test.c",
          407, "msg", "plaintext", msg, sizeof(msg), plaintext, plaintext_len))
    goto err;
  ret = 1;
err:
  OPENSSL_free(kek);
  EVP_PKEY_free(keypair);
  EVP_CIPHER_CTX_free(ctx);
  return ret;
}


x86 assembly (clang, -O0):
<test_EVP_Enveloped>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    0x2da7(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x80(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1050 <EVP_aes_256_cbc@plt>
mov    %rax,-0x78(%rbp)
mov    $0x0,%al
call   1120 <load_example_rsa_key@plt>
mov    %rax,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xd82(%rip),%rdi
mov    $0x183,%esi
lea    0xe28(%rip),%rdx
call   1070 <test_ptr@plt>
cmp    $0x0,%eax
je     13f0 <test_EVP_Enveloped+0x1e0>
mov    -0x18(%rbp),%rdi
call   10d0 <EVP_PKEY_size@plt>
mov    %eax,%edi
call   1090 <OPENSSL_zalloc@plt>
mov    %rax,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xd4a(%rip),%rdi
mov    $0x184,%esi
lea    0xe11(%rip),%rdx
call   1070 <test_ptr@plt>
cmp    $0x0,%eax
je     13f0 <test_EVP_Enveloped+0x1e0>
mov    $0x0,%al
call   10e0 <EVP_CIPHER_CTX_new@plt>
mov    %rax,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xd1b(%rip),%rdi
mov    $0x185,%esi
lea    0xe0f(%rip),%rdx
call   1070 <test_ptr@plt>
cmp    $0x0,%eax
je     13f0 <test_EVP_Enveloped+0x1e0>
mov    -0x80(%rbp),%r8
mov    -0x10(%rbp),%rdi
mov    -0x78(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x38(%rbp),%rcx
lea    -0x18(%rbp),%r9
sub    $0x10,%rsp
movl   $0x1,(%rsp)
call   1080 <EVP_SealInit@plt>
add    $0x10,%rsp
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%ecx
lea    0xcc2(%rip),%rdi
mov    $0x186,%esi
lea    0xdd1(%rip),%rdx
call   1030 <test_true@plt>
cmp    $0x0,%eax
je     13f0 <test_EVP_Enveloped+0x1e0>
mov    -0x10(%rbp),%rdi
lea    -0x60(%rbp),%rsi
lea    -0x3c(%rbp),%rdx
lea    0xc8d(%rip),%rcx
mov    $0x8,%r8d
call   1100 <EVP_SealUpdate@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%ecx
lea    0xc77(%rip),%rdi
mov    $0x188,%esi
lea    0xdbf(%rip),%rdx
call   1030 <test_true@plt>
cmp    $0x0,%eax
je     13f0 <test_EVP_Enveloped+0x1e0>
mov    -0x10(%rbp),%rdi
lea    -0x60(%rbp),%rsi
movslq -0x3c(%rbp),%rax
add    %rax,%rsi
lea    -0x34(%rbp),%rdx
call   1040 <EVP_SealFinal@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%ecx
lea    0xc32(%rip),%rdi
mov    $0x18a,%esi
lea    0xdbd(%rip),%rdx
call   1030 <test_true@plt>
cmp    $0x0,%eax
jne    13f5 <test_EVP_Enveloped+0x1e5>
jmp    1538 <test_EVP_Enveloped+0x328>
mov    -0x80(%rbp),%r8
mov    -0x34(%rbp),%eax
add    -0x3c(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x78(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x38(%rbp),%ecx
mov    -0x18(%rbp),%r9
call   10c0 <EVP_OpenInit@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%ecx
lea    0xbdb(%rip),%rdi
mov    $0x190,%esi
lea    0xd9c(%rip),%rdx
call   1030 <test_true@plt>
cmp    $0x0,%eax
je     14d2 <test_EVP_Enveloped+0x2c2>
mov    -0x10(%rbp),%rdi
lea    -0x70(%rbp),%rsi
lea    -0x60(%rbp),%rcx
mov    -0x3c(%rbp),%r8d
lea    -0x40(%rbp),%rdx
call   10b0 <EVP_OpenUpdate@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%ecx
lea    0xb95(%rip),%rdi
mov    $0x191,%esi
lea    0xd89(%rip),%rdx
call   1030 <test_true@plt>
cmp    $0x0,%eax
je     14d2 <test_EVP_Enveloped+0x2c2>
mov    -0x10(%rbp),%rdi
lea    -0x70(%rbp),%rsi
movslq -0x40(%rbp),%rax
add    %rax,%rsi
lea    -0x34(%rbp),%rdx
call   1130 <EVP_OpenFinal@plt>
cmp    $0x0,%rax
setne  %al
and    $0x1,%al
movzbl %al,%ecx
lea    0xb50(%rip),%rdi
mov    $0x193,%esi
lea    0xd8f(%rip),%rdx
call   1030 <test_true@plt>
cmp    $0x0,%eax
jne    14d7 <test_EVP_Enveloped+0x2c7>
jmp    1538 <test_EVP_Enveloped+0x328>
mov    -0x34(%rbp),%eax
add    -0x40(%rbp),%eax
mov    %eax,-0x40(%rbp)
lea    -0x70(%rbp),%r10
mov    -0x40(%rbp),%eax
lea    0xb1a(%rip),%rdi
mov    $0x197,%esi
lea    0xd8d(%rip),%rdx
lea    0xd8a(%rip),%rcx
lea    0xaf8(%rip),%r8
mov    $0x8,%r9d
sub    $0x10,%rsp
mov    %r10,(%rsp)
mov    %eax,0x8(%rsp)
call   10f0 <test_mem_eq@plt>
add    $0x10,%rsp
cmp    $0x0,%eax
jne    1531 <test_EVP_Enveloped+0x321>
jmp    1538 <test_EVP_Enveloped+0x328>
movl   $0x1,-0x4(%rbp)
mov    -0x20(%rbp),%rdi
call   1110 <OPENSSL_free@plt>
mov    -0x18(%rbp),%rdi
call   1060 <EVP_PKEY_free@plt>
mov    -0x10(%rbp),%rdi
call   10a0 <EVP_CIPHER_CTX_free@plt>
mov    -0x4(%rbp),%eax
mov    -0x28(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_EVP_Enveloped>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %rsp,%r12
movq   $0x0,-0x40(%rbp)
mov    0x2db5(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r13
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r13
mov    %r13,%rsp
xor    %r14d,%r14d
xor    %eax,%eax
call   1050 <EVP_aes_256_cbc@plt>
mov    %rax,%r15
xor    %eax,%eax
call   1120 <load_example_rsa_key@plt>
mov    %rax,%rbx
mov    %rax,-0x48(%rbp)
lea    0xda0(%rip),%rdi
lea    0xe4b(%rip),%rdx
mov    $0x183,%esi
mov    %rax,%rcx
call   1070 <test_ptr@plt>
test   %eax,%eax
je     14ca <test_EVP_Enveloped+0x2ba>
mov    %rbx,%rdi
call   10d0 <EVP_PKEY_size@plt>
mov    %eax,%edi
call   1090 <OPENSSL_zalloc@plt>
mov    %rax,-0x40(%rbp)
lea    0xd6a(%rip),%rdi
lea    0xe36(%rip),%rdx
mov    $0x184,%esi
mov    %rax,%rcx
call   1070 <test_ptr@plt>
test   %eax,%eax
je     14cf <test_EVP_Enveloped+0x2bf>
mov    %r15,%rbx
xor    %r14d,%r14d
xor    %eax,%eax
call   10e0 <EVP_CIPHER_CTX_new@plt>
mov    %rax,%r15
lea    0xd37(%rip),%rdi
lea    0xe30(%rip),%rdx
mov    $0x185,%esi
mov    %rax,%rcx
call   1070 <test_ptr@plt>
test   %eax,%eax
je     14d5 <test_EVP_Enveloped+0x2c5>
sub    $0x8,%rsp
lea    -0x40(%rbp),%rdx
lea    -0x4c(%rbp),%rcx
lea    -0x48(%rbp),%r9
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r13,%r8
push   $0x1
call   1080 <EVP_SealInit@plt>
add    $0x10,%rsp
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    0xce8(%rip),%rdi
lea    0xdfc(%rip),%rdx
mov    $0x186,%esi
call   1030 <test_true@plt>
test   %eax,%eax
je     14d5 <test_EVP_Enveloped+0x2c5>
lea    0xcc0(%rip),%rcx
lea    -0x80(%rbp),%rsi
lea    -0x30(%rbp),%rdx
mov    %r15,%rdi
mov    $0x8,%r8d
call   1100 <EVP_SealUpdate@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    0xca3(%rip),%rdi
lea    0xdf0(%rip),%rdx
mov    $0x188,%esi
call   1030 <test_true@plt>
test   %eax,%eax
je     14d5 <test_EVP_Enveloped+0x2c5>
movslq -0x30(%rbp),%rax
lea    (%rax,%rbp,1),%rsi
add    $0xffffffffffffff80,%rsi
lea    -0x34(%rbp),%rdx
mov    %r15,%rdi
call   1040 <EVP_SealFinal@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    0xc63(%rip),%rdi
lea    0xdf3(%rip),%rdx
mov    $0x18a,%esi
call   1030 <test_true@plt>
test   %eax,%eax
je     14d5 <test_EVP_Enveloped+0x2c5>
mov    -0x34(%rbp),%eax
add    %eax,-0x30(%rbp)
mov    -0x40(%rbp),%rdx
mov    -0x4c(%rbp),%ecx
mov    -0x48(%rbp),%r9
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r13,%r8
call   10c0 <EVP_OpenInit@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    0xc1c(%rip),%rdi
lea    0xde2(%rip),%rdx
mov    $0x190,%esi
call   1030 <test_true@plt>
test   %eax,%eax
je     14d5 <test_EVP_Enveloped+0x2c5>
mov    -0x30(%rbp),%r8d
lea    -0x60(%rbp),%rbx
lea    -0x2c(%rbp),%rdx
lea    -0x80(%rbp),%rcx
mov    %r15,%rdi
mov    %rbx,%rsi
call   10b0 <EVP_OpenUpdate@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    0xbd9(%rip),%rdi
lea    0xdd2(%rip),%rdx
mov    $0x191,%esi
call   1030 <test_true@plt>
test   %eax,%eax
je     14d5 <test_EVP_Enveloped+0x2c5>
movslq -0x2c(%rbp),%rax
lea    (%rax,%rbp,1),%rsi
add    $0xffffffffffffffa0,%rsi
lea    -0x34(%rbp),%rdx
mov    %r15,%rdi
call   1130 <EVP_OpenFinal@plt>
xor    %ecx,%ecx
test   %rax,%rax
setne  %cl
lea    0xb99(%rip),%rdi
lea    0xddd(%rip),%rdx
mov    $0x193,%esi
call   1030 <test_true@plt>
test   %eax,%eax
je     14d5 <test_EVP_Enveloped+0x2c5>
mov    -0x2c(%rbp),%eax
add    -0x34(%rbp),%eax
mov    %eax,-0x2c(%rbp)
lea    0xb74(%rip),%rdi
lea    0xdec(%rip),%rdx
lea    0xde9(%rip),%rcx
lea    0xb57(%rip),%r8
mov    $0x197,%esi
mov    $0x8,%r9d
push   %rax
push   %rbx
call   10f0 <test_mem_eq@plt>
add    $0x10,%rsp
xor    %r14d,%r14d
test   %eax,%eax
setne  %r14b
jmp    14d5 <test_EVP_Enveloped+0x2c5>
xor    %r15d,%r15d
jmp    14d5 <test_EVP_Enveloped+0x2c5>
xor    %r15d,%r15d
xor    %r14d,%r14d
mov    -0x40(%rbp),%rdi
call   1110 <OPENSSL_free@plt>
mov    -0x48(%rbp),%rdi
call   1060 <EVP_PKEY_free@plt>
mov    %r15,%rdi
call   10a0 <EVP_CIPHER_CTX_free@plt>
mov    %r12,%rsp
mov    %r14d,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EVP_MAX_IV_LENGTH = global i32 0
@test_EVP_Enveloped.msg = internal constant [8 x i8] c"\01\02\03\04\05\06\07\08"
@.str = [178 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/master/Src/OSF/OpenSSL-111/test/evp_extra_test.c\00"
@.str.1 = [33 x i8] c"keypair = load_example_rsa_key()\00"
@.str.2 = [45 x i8] c"kek = OPENSSL_zalloc(EVP_PKEY_size(keypair))\00"
@.str.3 = [27 x i8] c"ctx = EVP_CIPHER_CTX_new()\00"
@.str.4 = [57 x i8] c"EVP_SealInit(ctx, type, &kek, &kek_len, iv, &keypair, 1)\00"
@.str.5 = [67 x i8] c"EVP_SealUpdate(ctx, ciphertext, &ciphertext_len, msg, sizeof(msg))\00"
@.str.6 = [54 x i8] c"EVP_SealFinal(ctx, ciphertext + ciphertext_len, &len)\00"
@.str.7 = [51 x i8] c"EVP_OpenInit(ctx, type, kek, kek_len, iv, keypair)\00"
@.str.8 = [75 x i8] c"EVP_OpenUpdate(ctx, plaintext, &plaintext_len, ciphertext, ciphertext_len)\00"
@.str.9 = [52 x i8] c"EVP_OpenFinal(ctx, plaintext + plaintext_len, &len)\00"
@.str.10 = [4 x i8] c"msg\00"
@.str.11 = [10 x i8] c"plaintext\00"
define i32 @test_EVP_Enveloped() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca [32 x i8]
%12 = alloca [16 x i8]
%13 = alloca i32*
store i32 0, i32* %1
store i8* null, i8** %2
store i8* null, i8** %3
store i8* null, i8** %4
%14 = load i32, i32* @EVP_MAX_IV_LENGTH
%15 = zext i32 %14 to i64
%16 = call i8* @llvm.stacksave()
store i8* %16, i8** %5
%17 = alloca i8, i64 %15
store i64 %15, i64* %6
%18 = call i32* (...) @EVP_aes_256_cbc()
store i32* %18, i32** %13
%19 = call i8* (...) @load_example_rsa_key()
store i8* %19, i8** %3
%20 = call i32 @test_ptr(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 387, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %59
22: ; preds = %0
%23 = load i8*, i8** %3
%24 = call i32 @EVP_PKEY_size(i8* %23)
%25 = call i8* @OPENSSL_zalloc(i32 %24)
store i8* %25, i8** %4
%26 = call i32 @test_ptr(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 388, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %59
28: ; preds = %22
%29 = call i8* (...) @EVP_CIPHER_CTX_new()
store i8* %29, i8** %2
%30 = call i32 @test_ptr(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 389, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %29)
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %59
32: ; preds = %28
%33 = load i8*, i8** %2
%34 = load i32*, i32** %13
%35 = call i64 @EVP_SealInit(i8* %33, i32* %34, i8** %4, i32* %8, i8* %17, i8** %3, i32 1)
%36 = icmp ne i64 %35, 0
%37 = zext i1 %36 to i32
%38 = call i32 @test_true(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 390, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0), i32 %37)
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %59
40: ; preds = %32
%41 = load i8*, i8** %2
%42 = getelementptr inbounds [32 x i8], [32 x i8]* %11, i64 0, i64 0
%43 = call i64 @EVP_SealUpdate(i8* %41, i8* %42, i32* %9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @test_EVP_Enveloped.msg, i64 0, i64 0), i32 8)
%44 = icmp ne i64 %43, 0
%45 = zext i1 %44 to i32
%46 = call i32 @test_true(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 392, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.5, i64 0, i64 0), i32 %45)
%47 = icmp ne i32 %46, 0
br i1 %47, label %48, label %59
48: ; preds = %40
%49 = load i8*, i8** %2
%50 = getelementptr inbounds [32 x i8], [32 x i8]* %11, i64 0, i64 0
%51 = load i32, i32* %9
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
%54 = call i64 @EVP_SealFinal(i8* %49, i8* %53, i32* %7)
%55 = icmp ne i64 %54, 0
%56 = zext i1 %55 to i32
%57 = call i32 @test_true(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 394, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.6, i64 0, i64 0), i32 %56)
%58 = icmp ne i32 %57, 0
br i1 %58, label %60, label %59
59: ; preds = %48, %40, %32, %28, %22, %0
br label %106
60: ; preds = %48
%61 = load i32, i32* %7
%62 = load i32, i32* %9
%63 = add nsw i32 %62, %61
store i32 %63, i32* %9
%64 = load i8*, i8** %2
%65 = load i32*, i32** %13
%66 = load i8*, i8** %4
%67 = load i32, i32* %8
%68 = load i8*, i8** %3
%69 = call i64 @EVP_OpenInit(i8* %64, i32* %65, i8* %66, i32 %67, i8* %17, i8* %68)
%70 = icmp ne i64 %69, 0
%71 = zext i1 %70 to i32
%72 = call i32 @test_true(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 400, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.7, i64 0, i64 0), i32 %71)
%73 = icmp ne i32 %72, 0
br i1 %73, label %74, label %95
74: ; preds = %60
%75 = load i8*, i8** %2
%76 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%77 = getelementptr inbounds [32 x i8], [32 x i8]* %11, i64 0, i64 0
%78 = load i32, i32* %9
%79 = call i64 @EVP_OpenUpdate(i8* %75, i8* %76, i32* %10, i8* %77, i32 %78)
%80 = icmp ne i64 %79, 0
%81 = zext i1 %80 to i32
%82 = call i32 @test_true(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 401, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.8, i64 0, i64 0), i32 %81)
%83 = icmp ne i32 %82, 0
br i1 %83, label %84, label %95
84: ; preds = %74
%85 = load i8*, i8** %2
%86 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%87 = load i32, i32* %10
%88 = sext i32 %87 to i64
%89 = getelementptr inbounds i8, i8* %86, i64 %88
%90 = call i64 @EVP_OpenFinal(i8* %85, i8* %89, i32* %7)
%91 = icmp ne i64 %90, 0
%92 = zext i1 %91 to i32
%93 = call i32 @test_true(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 403, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.9, i64 0, i64 0), i32 %92)
%94 = icmp ne i32 %93, 0
br i1 %94, label %96, label %95
95: ; preds = %84, %74, %60
br label %106
96: ; preds = %84
%97 = load i32, i32* %7
%98 = load i32, i32* %10
%99 = add nsw i32 %98, %97
store i32 %99, i32* %10
%100 = getelementptr inbounds [16 x i8], [16 x i8]* %12, i64 0, i64 0
%101 = load i32, i32* %10
%102 = call i32 @test_mem_eq(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 407, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @test_EVP_Enveloped.msg, i64 0, i64 0), i32 8, i8* %100, i32 %101)
%103 = icmp ne i32 %102, 0
br i1 %103, label %105, label %104
104: ; preds = %96
br label %106
105: ; preds = %96
store i32 1, i32* %1
br label %106
106: ; preds = %105, %104, %95, %59
%107 = load i8*, i8** %4
%108 = call i32 @OPENSSL_free(i8* %107)
%109 = load i8*, i8** %3
%110 = call i32 @EVP_PKEY_free(i8* %109)
%111 = load i8*, i8** %2
%112 = call i32 @EVP_CIPHER_CTX_free(i8* %111)
%113 = load i32, i32* %1
%114 = load i8*, i8** %5
ret i32 %113
}

LLVM IR (-O2):
@EVP_MAX_IV_LENGTH = global i32 0
@test_EVP_Enveloped.msg = internal constant [8 x i8] c"\01\02\03\04\05\06\07\08"
@.str = [178 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/papyrussolution/OpenPapyrus/refs/heads/master/Src/OSF/OpenSSL-111/test/evp_extra_test.c\00"
@.str.1 = [33 x i8] c"keypair = load_example_rsa_key()\00"
@.str.2 = [45 x i8] c"kek = OPENSSL_zalloc(EVP_PKEY_size(keypair))\00"
@.str.3 = [27 x i8] c"ctx = EVP_CIPHER_CTX_new()\00"
@.str.4 = [57 x i8] c"EVP_SealInit(ctx, type, &kek, &kek_len, iv, &keypair, 1)\00"
@.str.5 = [67 x i8] c"EVP_SealUpdate(ctx, ciphertext, &ciphertext_len, msg, sizeof(msg))\00"
@.str.6 = [54 x i8] c"EVP_SealFinal(ctx, ciphertext + ciphertext_len, &len)\00"
@.str.7 = [51 x i8] c"EVP_OpenInit(ctx, type, kek, kek_len, iv, keypair)\00"
@.str.8 = [75 x i8] c"EVP_OpenUpdate(ctx, plaintext, &plaintext_len, ciphertext, ciphertext_len)\00"
@.str.9 = [52 x i8] c"EVP_OpenFinal(ctx, plaintext + plaintext_len, &len)\00"
@.str.10 = [4 x i8] c"msg\00"
@.str.11 = [10 x i8] c"plaintext\00"
define i32 @test_EVP_Enveloped() {
%1 = alloca i8*
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca [32 x i8]
%8 = alloca [16 x i8]
%9 = bitcast i8** %1 to i8*
%10 = bitcast i8** %2 to i8*
store i8* null, i8** %2
%11 = load i32, i32* @EVP_MAX_IV_LENGTH
%12 = zext i32 %11 to i64
%13 = tail call i8* @llvm.stacksave()
%14 = alloca i8, i64 %12
%15 = bitcast i32* %3 to i8*
%16 = bitcast i32* %4 to i8*
%17 = bitcast i32* %5 to i8*
%18 = bitcast i32* %6 to i8*
%19 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%20 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 0
%21 = tail call i32* (...) @EVP_aes_256_cbc()
%22 = tail call i8* (...) @load_example_rsa_key()
store i8* %22, i8** %1
%23 = tail call i32 @test_ptr(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 387, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = icmp eq i32 %23, 0
br i1 %24, label %90, label %25
25: ; preds = %0
%26 = tail call i32 @EVP_PKEY_size(i8* %22)
%27 = tail call i8* @OPENSSL_zalloc(i32 %26)
store i8* %27, i8** %2
%28 = tail call i32 @test_ptr(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 388, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.2, i64 0, i64 0), i8* %27)
%29 = icmp eq i32 %28, 0
br i1 %29, label %90, label %30
30: ; preds = %25
%31 = tail call i8* (...) @EVP_CIPHER_CTX_new()
%32 = tail call i32 @test_ptr(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 389, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0), i8* %31)
%33 = icmp eq i32 %32, 0
br i1 %33, label %90, label %34
34: ; preds = %30
%35 = call i64 @EVP_SealInit(i8* %31, i32* %21, i8** %2, i32* %4, i8* %14, i8** %1, i32 1)
%36 = icmp ne i64 %35, 0
%37 = zext i1 %36 to i32
%38 = call i32 @test_true(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 390, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.4, i64 0, i64 0), i32 %37)
%39 = icmp eq i32 %38, 0
br i1 %39, label %90, label %40
40: ; preds = %34
%41 = call i64 @EVP_SealUpdate(i8* %31, i8* %19, i32* %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @test_EVP_Enveloped.msg, i64 0, i64 0), i32 8)
%42 = icmp ne i64 %41, 0
%43 = zext i1 %42 to i32
%44 = call i32 @test_true(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 392, i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.5, i64 0, i64 0), i32 %43)
%45 = icmp eq i32 %44, 0
br i1 %45, label %90, label %46
46: ; preds = %40
%47 = load i32, i32* %5
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 %48
%50 = call i64 @EVP_SealFinal(i8* %31, i8* %49, i32* %3)
%51 = icmp ne i64 %50, 0
%52 = zext i1 %51 to i32
%53 = call i32 @test_true(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 394, i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.6, i64 0, i64 0), i32 %52)
%54 = icmp eq i32 %53, 0
br i1 %54, label %90, label %55
55: ; preds = %46
%56 = load i32, i32* %3
%57 = load i32, i32* %5
%58 = add nsw i32 %57, %56
store i32 %58, i32* %5
%59 = load i8*, i8** %2
%60 = load i32, i32* %4
%61 = load i8*, i8** %1
%62 = call i64 @EVP_OpenInit(i8* %31, i32* %21, i8* %59, i32 %60, i8* %14, i8* %61)
%63 = icmp ne i64 %62, 0
%64 = zext i1 %63 to i32
%65 = call i32 @test_true(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 400, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.7, i64 0, i64 0), i32 %64)
%66 = icmp eq i32 %65, 0
br i1 %66, label %90, label %67
67: ; preds = %55
%68 = load i32, i32* %5
%69 = call i64 @EVP_OpenUpdate(i8* %31, i8* %20, i32* %6, i8* %19, i32 %68)
%70 = icmp ne i64 %69, 0
%71 = zext i1 %70 to i32
%72 = call i32 @test_true(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 401, i8* getelementptr inbounds ([75 x i8], [75 x i8]* @.str.8, i64 0, i64 0), i32 %71)
%73 = icmp eq i32 %72, 0
br i1 %73, label %90, label %74
74: ; preds = %67
%75 = load i32, i32* %6
%76 = sext i32 %75 to i64
%77 = getelementptr inbounds [16 x i8], [16 x i8]* %8, i64 0, i64 %76
%78 = call i64 @EVP_OpenFinal(i8* %31, i8* %77, i32* %3)
%79 = icmp ne i64 %78, 0
%80 = zext i1 %79 to i32
%81 = call i32 @test_true(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 403, i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.9, i64 0, i64 0), i32 %80)
%82 = icmp eq i32 %81, 0
br i1 %82, label %90, label %83
83: ; preds = %74
%84 = load i32, i32* %3
%85 = load i32, i32* %6
%86 = add nsw i32 %85, %84
store i32 %86, i32* %6
%87 = call i32 @test_mem_eq(i8* getelementptr inbounds ([178 x i8], [178 x i8]* @.str, i64 0, i64 0), i32 407, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @test_EVP_Enveloped.msg, i64 0, i64 0), i32 8, i8* %20, i32 %86)
%88 = icmp ne i32 %87, 0
%89 = zext i1 %88 to i32
br label %90
90: ; preds = %83, %55, %67, %74, %0, %25, %30, %34, %40, %46
%91 = phi i8* [ %31, %74 ], [ %31, %67 ], [ %31, %55 ], [ %31, %46 ], [ %31, %40 ], [ %31, %34 ], [ %31, %30 ], [ null, %25 ], [ null, %0 ], [ %31, %83 ]
%92 = phi i32 [ 0, %74 ], [ 0, %67 ], [ 0, %55 ], [ 0, %46 ], [ 0, %40 ], [ 0, %34 ], [ 0, %30 ], [ 0, %25 ], [ 0, %0 ], [ %89, %83 ]
%93 = load i8*, i8** %2
%94 = call i32 @OPENSSL_free(i8* %93)
%95 = load i8*, i8** %1
%96 = call i32 @EVP_PKEY_free(i8* %95)
%97 = call i32 @EVP_CIPHER_CTX_free(i8* %91)
ret i32 %92
}