#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 */
typedef struct TYPE_15__ TYPE_6__;
typedef struct TYPE_14__ TYPE_5__;
typedef struct TYPE_13__ TYPE_4__;
typedef struct TYPE_12__ TYPE_3__;
typedef struct TYPE_11__ TYPE_2__;
typedef struct TYPE_10__ TYPE_1__;

/* Type definitions */
struct TYPE_11__ {
  TYPE_1__ *sequence;
};
struct TYPE_15__ {
  scalar_t__ type;
  TYPE_2__ value;
};
struct TYPE_14__ {
  TYPE_4__ *keyfunc;
  TYPE_3__ *encryption;
};
struct TYPE_13__ {
  int /*<<< orphan*/ parameter;
  int /*<<< orphan*/ algorithm;
};
struct TYPE_12__ {
  int /*<<< orphan*/ parameter;
  int /*<<< orphan*/ algorithm;
};
struct TYPE_10__ {
  unsigned char *data;
  int length;
};
typedef TYPE_5__ PBE2PARAM;
typedef int /*<<< orphan*/ EVP_MD;
typedef int /*<<< orphan*/ EVP_CIPHER_CTX;
typedef int /*<<< orphan*/ EVP_CIPHER;
typedef TYPE_6__ ASN1_TYPE;

/* Variables and functions */
scalar_t__ EVP_CIPHER_asn1_to_param(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ EVP_CipherInit_ex(int /*<<< orphan*/ *,
                                     int /*<<< orphan*/ const *,
                                     int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                     int /*<<< orphan*/ *, int);
int /*<<< orphan*/ EVP_F_PKCS5_V2_PBE_KEYIVGEN;
int /*<<< orphan*/ EVP_R_CIPHER_PARAMETER_ERROR;
int /*<<< orphan*/ EVP_R_DECODE_ERROR;
int /*<<< orphan*/ EVP_R_UNSUPPORTED_CIPHER;
int /*<<< orphan*/ EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION;
int /*<<< orphan*/ *EVP_get_cipherbyobj(int /*<<< orphan*/);
int /*<<< orphan*/ EVPerr(int /*<<< orphan*/, int /*<<< orphan*/);
scalar_t__ NID_id_pbkdf2;
scalar_t__ OBJ_obj2nid(int /*<<< orphan*/);
int /*<<< orphan*/ PBE2PARAM_free(TYPE_5__ *);
int PKCS5_v2_PBKDF2_keyivgen(int /*<<< orphan*/ *, char const *, int,
                             int /*<<< orphan*/, int /*<<< orphan*/ const *,
                             int /*<<< orphan*/ const *, int);
scalar_t__ V_ASN1_SEQUENCE;
TYPE_5__ *d2i_PBE2PARAM(int /*<<< orphan*/ *, unsigned char const **, int);
int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen,
                          ASN1_TYPE *param, const EVP_CIPHER *c,
                          const EVP_MD *md, int en_de) {
  const unsigned char *pbuf;
  int plen;
  PBE2PARAM *pbe2 = NULL;
  const EVP_CIPHER *cipher;
  int rv = 0;
  if (param == NULL || param->type != V_ASN1_SEQUENCE ||
      param->value.sequence == NULL) {
    EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, EVP_R_DECODE_ERROR);
    goto err;
  }
  pbuf = param->value.sequence->data;
  plen = param->value.sequence->length;
  if (!(pbe2 = d2i_PBE2PARAM(NULL, &pbuf, plen))) {
    EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, EVP_R_DECODE_ERROR);
    goto err;
  }
  if (OBJ_obj2nid(pbe2->keyfunc->algorithm) != NID_id_pbkdf2) {
    EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN,
           EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION);
    goto err;
  }
  cipher = EVP_get_cipherbyobj(pbe2->encryption->algorithm);
  if (!cipher) {
    EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, EVP_R_UNSUPPORTED_CIPHER);
    goto err;
  }
  if (!EVP_CipherInit_ex(ctx, cipher, NULL, NULL, NULL, en_de))
    goto err;
  if (EVP_CIPHER_asn1_to_param(ctx, pbe2->encryption->parameter) < 0) {
    EVPerr(EVP_F_PKCS5_V2_PBE_KEYIVGEN, EVP_R_CIPHER_PARAMETER_ERROR);
    goto err;
  }
  rv = PKCS5_v2_PBKDF2_keyivgen(ctx, pass, passlen, pbe2->keyfunc->parameter, c,
                                md, en_de);
err:
  PBE2PARAM_free(pbe2);
  return rv;
}


x86 assembly (clang, -O0):
<PKCS5_v2_PBE_keyivgen>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
movq   $0x0,-0x48(%rbp)
movl   $0x0,-0x54(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11e2 <PKCS5_v2_PBE_keyivgen+0x62>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    0x2de6(%rip),%rcx
cmp    (%rcx),%rax
jne    11e2 <PKCS5_v2_PBE_keyivgen+0x62>
mov    -0x20(%rbp),%rax
cmpq   $0x0,0x8(%rax)
jne    11fe <PKCS5_v2_PBE_keyivgen+0x7e>
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
mov    0x2dce(%rip),%rax
mov    (%rax),%esi
call   1070 <EVPerr@plt>
jmp    1358 <PKCS5_v2_PBE_keyivgen+0x1d8>
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%edx
xor    %eax,%eax
mov    %eax,%edi
lea    -0x38(%rbp),%rsi
call   1090 <d2i_PBE2PARAM@plt>
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
jne    1255 <PKCS5_v2_PBE_keyivgen+0xd5>
mov    0x2d68(%rip),%rax
mov    (%rax),%edi
mov    0x2d77(%rip),%rax
mov    (%rax),%esi
call   1070 <EVPerr@plt>
jmp    1358 <PKCS5_v2_PBE_keyivgen+0x1d8>
mov    -0x48(%rbp),%rax
mov    (%rax),%rax
mov    0x4(%rax),%edi
call   1030 <OBJ_obj2nid@plt>
mov    0x2d75(%rip),%rcx
cmp    (%rcx),%rax
je     1290 <PKCS5_v2_PBE_keyivgen+0x110>
mov    0x2d2d(%rip),%rax
mov    (%rax),%edi
mov    0x2d64(%rip),%rax
mov    (%rax),%esi
call   1070 <EVPerr@plt>
jmp    1358 <PKCS5_v2_PBE_keyivgen+0x1d8>
mov    -0x48(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x4(%rax),%edi
call   1080 <EVP_get_cipherbyobj@plt>
mov    %rax,-0x50(%rbp)
cmpq   $0x0,-0x50(%rbp)
jne    12cb <PKCS5_v2_PBE_keyivgen+0x14b>
mov    0x2cf2(%rip),%rax
mov    (%rax),%edi
mov    0x2d09(%rip),%rax
mov    (%rax),%esi
call   1070 <EVPerr@plt>
jmp    1358 <PKCS5_v2_PBE_keyivgen+0x1d8>
mov    -0x8(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    0x10(%rbp),%r9d
xor    %eax,%eax
mov    %eax,%r8d
mov    %r8,%rdx
mov    %r8,%rcx
call   10a0 <EVP_CipherInit_ex@plt>
cmp    $0x0,%eax
jne    12f5 <PKCS5_v2_PBE_keyivgen+0x175>
jmp    1358 <PKCS5_v2_PBE_keyivgen+0x1d8>
mov    -0x8(%rbp),%rdi
mov    -0x48(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%esi
call   1060 <EVP_CIPHER_asn1_to_param@plt>
cmp    $0x0,%rax
jge    132e <PKCS5_v2_PBE_keyivgen+0x1ae>
mov    0x2c8f(%rip),%rax
mov    (%rax),%edi
mov    0x2cae(%rip),%rax
mov    (%rax),%esi
call   1070 <EVPerr@plt>
jmp    1358 <PKCS5_v2_PBE_keyivgen+0x1d8>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x48(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%ecx
mov    -0x28(%rbp),%r8
mov    -0x30(%rbp),%r9
mov    0x10(%rbp),%eax
mov    %eax,(%rsp)
call   1050 <PKCS5_v2_PBKDF2_keyivgen@plt>
mov    %eax,-0x54(%rbp)
mov    -0x48(%rbp),%rdi
call   1040 <PBE2PARAM_free@plt>
mov    -0x54(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PKCS5_v2_PBE_keyivgen>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %rcx,%rcx
je     127a <PKCS5_v2_PBE_keyivgen+0xfa>
mov    %edx,%r12d
mov    (%rcx),%rax
mov    0x2e0c(%rip),%rdx
cmp    (%rdx),%rax
jne    127a <PKCS5_v2_PBE_keyivgen+0xfa>
mov    0x8(%rcx),%rax
test   %rax,%rax
je     127a <PKCS5_v2_PBE_keyivgen+0xfa>
mov    %r8,%r15
mov    %rsi,%r13
mov    %rdi,%rbp
mov    %r9,0x8(%rsp)
mov    (%rax),%rcx
mov    %rcx,0x10(%rsp)
mov    0x8(%rax),%edx
xor    %r14d,%r14d
lea    0x10(%rsp),%rsi
xor    %edi,%edi
call   1090 <d2i_PBE2PARAM@plt>
test   %rax,%rax
je     12b0 <PKCS5_v2_PBE_keyivgen+0x130>
mov    %rax,%rbx
mov    (%rax),%rax
mov    0x4(%rax),%edi
call   1030 <OBJ_obj2nid@plt>
mov    0x2de0(%rip),%rcx
cmp    (%rcx),%rax
jne    12cb <PKCS5_v2_PBE_keyivgen+0x14b>
mov    0x8(%rbx),%rax
mov    0x4(%rax),%edi
call   1080 <EVP_get_cipherbyobj@plt>
test   %rax,%rax
je     12dd <PKCS5_v2_PBE_keyivgen+0x15d>
mov    0x50(%rsp),%r9d
xor    %r14d,%r14d
mov    %rbp,%rdi
mov    %rax,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   10a0 <EVP_CipherInit_ex@plt>
test   %eax,%eax
je     1296 <PKCS5_v2_PBE_keyivgen+0x116>
mov    0x8(%rbx),%rax
mov    (%rax),%esi
mov    %rbp,%rdi
call   1060 <EVP_CIPHER_asn1_to_param@plt>
test   %rax,%rax
js     12f6 <PKCS5_v2_PBE_keyivgen+0x176>
mov    (%rbx),%rax
mov    (%rax),%ecx
mov    0x50(%rsp),%eax
mov    %eax,(%rsp)
mov    %rbp,%rdi
mov    %r13,%rsi
mov    %r12d,%edx
mov    %r15,%r8
mov    0x8(%rsp),%r9
call   1050 <PKCS5_v2_PBKDF2_keyivgen@plt>
mov    %eax,%r14d
jmp    1296 <PKCS5_v2_PBE_keyivgen+0x116>
mov    0x2d27(%rip),%rax
mov    (%rax),%edi
mov    0x2d36(%rip),%rax
mov    (%rax),%esi
call   1070 <EVPerr@plt>
xor    %ebx,%ebx
xor    %r14d,%r14d
mov    %rbx,%rdi
call   1040 <PBE2PARAM_free@plt>
mov    %r14d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2cf1(%rip),%rax
mov    (%rax),%edi
mov    0x2d00(%rip),%rax
mov    (%rax),%esi
call   1070 <EVPerr@plt>
xor    %ebx,%ebx
jmp    1296 <PKCS5_v2_PBE_keyivgen+0x116>
mov    0x2cd6(%rip),%rax
mov    (%rax),%edi
mov    0x2d0d(%rip),%rax
jmp    12ed <PKCS5_v2_PBE_keyivgen+0x16d>
mov    0x2cc4(%rip),%rax
mov    (%rax),%edi
mov    0x2cdb(%rip),%rax
mov    (%rax),%esi
call   1070 <EVPerr@plt>
jmp    1293 <PKCS5_v2_PBE_keyivgen+0x113>
mov    0x2cab(%rip),%rax
mov    (%rax),%edi
mov    0x2cca(%rip),%rax
mov    (%rax),%esi
call   1070 <EVPerr@plt>
jmp    1296 <PKCS5_v2_PBE_keyivgen+0x116>

LLVM IR (-O0):
%struct.TYPE_15__ = type { i64, %struct.TYPE_11__ }
%struct.TYPE_11__ = type { %struct.TYPE_10__* }
%struct.TYPE_10__ = type { i8*, i32 }
%struct.TYPE_14__ = type { %struct.TYPE_13__*, %struct.TYPE_12__* }
%struct.TYPE_13__ = type { i32, i32 }
%struct.TYPE_12__ = type { i32, i32 }
@V_ASN1_SEQUENCE = global i64 0
@EVP_F_PKCS5_V2_PBE_KEYIVGEN = global i32 0
@EVP_R_DECODE_ERROR = global i32 0
@NID_id_pbkdf2 = global i64 0
@EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION = global i32 0
@EVP_R_UNSUPPORTED_CIPHER = global i32 0
@EVP_R_CIPHER_PARAMETER_ERROR = global i32 0
define i32 @PKCS5_v2_PBE_keyivgen(i32* %0, i8* %1, i32 %2, %struct.TYPE_15__* %3, i32* %4, i32* %5, i32 %6) {
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca %struct.TYPE_15__*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i32
%17 = alloca %struct.TYPE_14__*
%18 = alloca i32*
%19 = alloca i32
store i32* %0, i32** %8
store i8* %1, i8** %9
store i32 %2, i32* %10
store %struct.TYPE_15__* %3, %struct.TYPE_15__** %11
store i32* %4, i32** %12
store i32* %5, i32** %13
store i32 %6, i32* %14
store %struct.TYPE_14__* null, %struct.TYPE_14__** %17
store i32 0, i32* %19
%20 = load %struct.TYPE_15__*, %struct.TYPE_15__** %11
%21 = icmp eq %struct.TYPE_15__* %20, null
br i1 %21, label %34, label %22
22: ; preds = %7
%23 = load %struct.TYPE_15__*, %struct.TYPE_15__** %11
%24 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %23, i32 0, i32 0
%25 = load i64, i64* %24
%26 = load i64, i64* @V_ASN1_SEQUENCE
%27 = icmp ne i64 %25, %26
br i1 %27, label %34, label %28
28: ; preds = %22
%29 = load %struct.TYPE_15__*, %struct.TYPE_15__** %11
%30 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %29, i32 0, i32 1
%31 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %30, i32 0, i32 0
%32 = load %struct.TYPE_10__*, %struct.TYPE_10__** %31
%33 = icmp eq %struct.TYPE_10__* %32, null
br i1 %33, label %34, label %38
34: ; preds = %28, %22, %7
%35 = load i32, i32* @EVP_F_PKCS5_V2_PBE_KEYIVGEN
%36 = load i32, i32* @EVP_R_DECODE_ERROR
%37 = call i32 @EVPerr(i32 %35, i32 %36)
br label %117
38: ; preds = %28
%39 = load %struct.TYPE_15__*, %struct.TYPE_15__** %11
%40 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %39, i32 0, i32 1
%41 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %40, i32 0, i32 0
%42 = load %struct.TYPE_10__*, %struct.TYPE_10__** %41
%43 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %42, i32 0, i32 0
%44 = load i8*, i8** %43
store i8* %44, i8** %15
%45 = load %struct.TYPE_15__*, %struct.TYPE_15__** %11
%46 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %45, i32 0, i32 1
%47 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %46, i32 0, i32 0
%48 = load %struct.TYPE_10__*, %struct.TYPE_10__** %47
%49 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %48, i32 0, i32 1
%50 = load i32, i32* %49
store i32 %50, i32* %16
%51 = load i32, i32* %16
%52 = call %struct.TYPE_14__* @d2i_PBE2PARAM(i32* null, i8** %15, i32 %51)
store %struct.TYPE_14__* %52, %struct.TYPE_14__** %17
%53 = icmp ne %struct.TYPE_14__* %52, null
br i1 %53, label %58, label %54
54: ; preds = %38
%55 = load i32, i32* @EVP_F_PKCS5_V2_PBE_KEYIVGEN
%56 = load i32, i32* @EVP_R_DECODE_ERROR
%57 = call i32 @EVPerr(i32 %55, i32 %56)
br label %117
58: ; preds = %38
%59 = load %struct.TYPE_14__*, %struct.TYPE_14__** %17
%60 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %59, i32 0, i32 0
%61 = load %struct.TYPE_13__*, %struct.TYPE_13__** %60
%62 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %61, i32 0, i32 1
%63 = load i32, i32* %62
%64 = call i64 @OBJ_obj2nid(i32 %63)
%65 = load i64, i64* @NID_id_pbkdf2
%66 = icmp ne i64 %64, %65
br i1 %66, label %67, label %71
67: ; preds = %58
%68 = load i32, i32* @EVP_F_PKCS5_V2_PBE_KEYIVGEN
%69 = load i32, i32* @EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION
%70 = call i32 @EVPerr(i32 %68, i32 %69)
br label %117
71: ; preds = %58
%72 = load %struct.TYPE_14__*, %struct.TYPE_14__** %17
%73 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %72, i32 0, i32 1
%74 = load %struct.TYPE_12__*, %struct.TYPE_12__** %73
%75 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %74, i32 0, i32 1
%76 = load i32, i32* %75
%77 = call i32* @EVP_get_cipherbyobj(i32 %76)
store i32* %77, i32** %18
%78 = load i32*, i32** %18
%79 = icmp ne i32* %78, null
br i1 %79, label %84, label %80
80: ; preds = %71
%81 = load i32, i32* @EVP_F_PKCS5_V2_PBE_KEYIVGEN
%82 = load i32, i32* @EVP_R_UNSUPPORTED_CIPHER
%83 = call i32 @EVPerr(i32 %81, i32 %82)
br label %117
84: ; preds = %71
%85 = load i32*, i32** %8
%86 = load i32*, i32** %18
%87 = load i32, i32* %14
%88 = call i32 @EVP_CipherInit_ex(i32* %85, i32* %86, i32* null, i32* null, i32* null, i32 %87)
%89 = icmp ne i32 %88, 0
br i1 %89, label %91, label %90
90: ; preds = %84
br label %117
91: ; preds = %84
%92 = load i32*, i32** %8
%93 = load %struct.TYPE_14__*, %struct.TYPE_14__** %17
%94 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %93, i32 0, i32 1
%95 = load %struct.TYPE_12__*, %struct.TYPE_12__** %94
%96 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %95, i32 0, i32 0
%97 = load i32, i32* %96
%98 = call i64 @EVP_CIPHER_asn1_to_param(i32* %92, i32 %97)
%99 = icmp slt i64 %98, 0
br i1 %99, label %100, label %104
100: ; preds = %91
%101 = load i32, i32* @EVP_F_PKCS5_V2_PBE_KEYIVGEN
%102 = load i32, i32* @EVP_R_CIPHER_PARAMETER_ERROR
%103 = call i32 @EVPerr(i32 %101, i32 %102)
br label %117
104: ; preds = %91
%105 = load i32*, i32** %8
%106 = load i8*, i8** %9
%107 = load i32, i32* %10
%108 = load %struct.TYPE_14__*, %struct.TYPE_14__** %17
%109 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %108, i32 0, i32 0
%110 = load %struct.TYPE_13__*, %struct.TYPE_13__** %109
%111 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %110, i32 0, i32 0
%112 = load i32, i32* %111
%113 = load i32*, i32** %12
%114 = load i32*, i32** %13
%115 = load i32, i32* %14
%116 = call i32 @PKCS5_v2_PBKDF2_keyivgen(i32* %105, i8* %106, i32 %107, i32 %112, i32* %113, i32* %114, i32 %115)
store i32 %116, i32* %19
br label %117
117: ; preds = %104, %100, %90, %80, %67, %54, %34
%118 = load %struct.TYPE_14__*, %struct.TYPE_14__** %17
%119 = call i32 @PBE2PARAM_free(%struct.TYPE_14__* %118)
%120 = load i32, i32* %19
ret i32 %120
}

LLVM IR (-O2):
%struct.TYPE_15__ = type { i64, %struct.TYPE_11__ }
%struct.TYPE_11__ = type { %struct.TYPE_10__* }
%struct.TYPE_10__ = type { i8*, i32 }
%struct.TYPE_14__ = type { %struct.TYPE_13__*, %struct.TYPE_12__* }
%struct.TYPE_13__ = type { i32, i32 }
%struct.TYPE_12__ = type { i32, i32 }
@V_ASN1_SEQUENCE = global i64 0
@EVP_F_PKCS5_V2_PBE_KEYIVGEN = global i32 0
@EVP_R_DECODE_ERROR = global i32 0
@NID_id_pbkdf2 = global i64 0
@EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION = global i32 0
@EVP_R_UNSUPPORTED_CIPHER = global i32 0
@EVP_R_CIPHER_PARAMETER_ERROR = global i32 0
define i32 @PKCS5_v2_PBE_keyivgen(i32* %0, i8* %1, i32 %2, %struct.TYPE_15__* %3, i32* %4, i32* %5, i32 %6) {
%8 = alloca i8*
%9 = bitcast i8** %8 to i8*
%10 = icmp eq %struct.TYPE_15__* %3, null
br i1 %10, label %20, label %11
11: ; preds = %7
%12 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %3, i64 0, i32 0
%13 = load i64, i64* %12
%14 = load i64, i64* @V_ASN1_SEQUENCE
%15 = icmp eq i64 %13, %14
br i1 %15, label %16, label %20
16: ; preds = %11
%17 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %3, i64 0, i32 1, i32 0
%18 = load %struct.TYPE_10__*, %struct.TYPE_10__** %17
%19 = icmp eq %struct.TYPE_10__* %18, null
br i1 %19, label %20, label %24
20: ; preds = %16, %11, %7
%21 = load i32, i32* @EVP_F_PKCS5_V2_PBE_KEYIVGEN
%22 = load i32, i32* @EVP_R_DECODE_ERROR
%23 = tail call i32 @EVPerr(i32 %21, i32 %22)
br label %76
24: ; preds = %16
%25 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %18, i64 0, i32 0
%26 = load i8*, i8** %25
store i8* %26, i8** %8
%27 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %18, i64 0, i32 1
%28 = load i32, i32* %27
%29 = call %struct.TYPE_14__* @d2i_PBE2PARAM(i32* null, i8** %8, i32 %28)
%30 = icmp eq %struct.TYPE_14__* %29, null
br i1 %30, label %31, label %35
31: ; preds = %24
%32 = load i32, i32* @EVP_F_PKCS5_V2_PBE_KEYIVGEN
%33 = load i32, i32* @EVP_R_DECODE_ERROR
%34 = call i32 @EVPerr(i32 %32, i32 %33)
br label %76
35: ; preds = %24
%36 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %29, i64 0, i32 0
%37 = load %struct.TYPE_13__*, %struct.TYPE_13__** %36
%38 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %37, i64 0, i32 1
%39 = load i32, i32* %38
%40 = call i64 @OBJ_obj2nid(i32 %39)
%41 = load i64, i64* @NID_id_pbkdf2
%42 = icmp eq i64 %40, %41
br i1 %42, label %47, label %43
43: ; preds = %35
%44 = load i32, i32* @EVP_F_PKCS5_V2_PBE_KEYIVGEN
%45 = load i32, i32* @EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION
%46 = call i32 @EVPerr(i32 %44, i32 %45)
br label %76
47: ; preds = %35
%48 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %29, i64 0, i32 1
%49 = load %struct.TYPE_12__*, %struct.TYPE_12__** %48
%50 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %49, i64 0, i32 1
%51 = load i32, i32* %50
%52 = call i32* @EVP_get_cipherbyobj(i32 %51)
%53 = icmp eq i32* %52, null
br i1 %53, label %54, label %58
54: ; preds = %47
%55 = load i32, i32* @EVP_F_PKCS5_V2_PBE_KEYIVGEN
%56 = load i32, i32* @EVP_R_UNSUPPORTED_CIPHER
%57 = call i32 @EVPerr(i32 %55, i32 %56)
br label %76
58: ; preds = %47
%59 = call i32 @EVP_CipherInit_ex(i32* %0, i32* %52, i32* null, i32* null, i32* null, i32 %6)
%60 = icmp eq i32 %59, 0
br i1 %60, label %76, label %61
61: ; preds = %58
%62 = load %struct.TYPE_12__*, %struct.TYPE_12__** %48
%63 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %62, i64 0, i32 0
%64 = load i32, i32* %63
%65 = call i64 @EVP_CIPHER_asn1_to_param(i32* %0, i32 %64)
%66 = icmp slt i64 %65, 0
br i1 %66, label %67, label %71
67: ; preds = %61
%68 = load i32, i32* @EVP_F_PKCS5_V2_PBE_KEYIVGEN
%69 = load i32, i32* @EVP_R_CIPHER_PARAMETER_ERROR
%70 = call i32 @EVPerr(i32 %68, i32 %69)
br label %76
71: ; preds = %61
%72 = load %struct.TYPE_13__*, %struct.TYPE_13__** %36
%73 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %72, i64 0, i32 0
%74 = load i32, i32* %73
%75 = call i32 @PKCS5_v2_PBKDF2_keyivgen(i32* %0, i8* %1, i32 %2, i32 %74, i32* %4, i32* %5, i32 %6)
br label %76
76: ; preds = %58, %71, %67, %54, %43, %31, %20
%77 = phi %struct.TYPE_14__* [ null, %20 ], [ %29, %43 ], [ %29, %67 ], [ %29, %71 ], [ %29, %58 ], [ %29, %54 ], [ null, %31 ]
%78 = phi i32 [ 0, %20 ], [ 0, %43 ], [ 0, %67 ], [ %75, %71 ], [ 0, %58 ], [ 0, %54 ], [ 0, %31 ]
%79 = call i32 @PBE2PARAM_free(%struct.TYPE_14__* %77)
ret i32 %78
}