#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_20__ TYPE_6__;
typedef struct TYPE_19__ TYPE_5__;
typedef struct TYPE_18__ TYPE_4__;
typedef struct TYPE_17__ TYPE_3__;
typedef struct TYPE_16__ TYPE_2__;
typedef struct TYPE_15__ TYPE_1__;
typedef struct TYPE_14__ TYPE_12__;

/* Type definitions */
struct TYPE_18__ {
  TYPE_12__ *parameter;
  int /*<<< orphan*/ algorithm;
};
typedef TYPE_4__ X509_ALGOR;
struct TYPE_20__ {
  int length;
  int /*<<< orphan*/ data;
};
struct TYPE_19__ {
  void *prf;
  int /*<<< orphan*/ keylength;
  int /*<<< orphan*/ iter;
  TYPE_2__ *salt;
};
struct TYPE_17__ {
  int /*<<< orphan*/ sequence;
};
struct TYPE_15__ {
  TYPE_6__ *octet_string;
};
struct TYPE_16__ {
  int /*<<< orphan*/ type;
  TYPE_1__ value;
};
struct TYPE_14__ {
  int /*<<< orphan*/ type;
  TYPE_3__ value;
};
typedef TYPE_5__ PBKDF2PARAM;
typedef TYPE_6__ ASN1_OCTET_STRING;

/* Variables and functions */
int /*<<< orphan*/ ASN1_INTEGER_new();
int /*<<< orphan*/ ASN1_INTEGER_set(int /*<<< orphan*/, int);
TYPE_6__ *ASN1_OCTET_STRING_new();
TYPE_12__ *ASN1_TYPE_new();
int /*<<< orphan*/ ASN1_item_pack(TYPE_5__ *, int /*<<< orphan*/ *,
                                  int /*<<< orphan*/ *);
int /*<<< orphan*/ ASN1error(int /*<<< orphan*/);
int /*<<< orphan*/ ERR_R_MALLOC_FAILURE;
int NID_hmacWithSHA1;
int NID_id_pbkdf2;
int /*<<< orphan*/ OBJ_nid2obj(int);
int /*<<< orphan*/ PBKDF2PARAM_free(TYPE_5__ *);
int /*<<< orphan*/ PBKDF2PARAM_it;
TYPE_5__ *PBKDF2PARAM_new();
int PKCS5_DEFAULT_ITER;
int PKCS5_SALT_LEN;
int /*<<< orphan*/ V_ASN1_NULL;
int /*<<< orphan*/ V_ASN1_OCTET_STRING;
int /*<<< orphan*/ V_ASN1_SEQUENCE;
int /*<<< orphan*/ X509_ALGOR_free(TYPE_4__ *);
void *X509_ALGOR_new();
int /*<<< orphan*/ X509_ALGOR_set0(void *, int /*<<< orphan*/,
                                   int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ arc4random_buf(int /*<<< orphan*/, int);
int /*<<< orphan*/ malloc(int);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/, unsigned char *, int);
X509_ALGOR *PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen,
                             int prf_nid, int keylen) {
  X509_ALGOR *keyfunc = NULL;
  PBKDF2PARAM *kdf = NULL;
  ASN1_OCTET_STRING *osalt = NULL;
  if (!(kdf = PBKDF2PARAM_new()))
    goto merr;
  if (!(osalt = ASN1_OCTET_STRING_new()))
    goto merr;
  kdf->salt->value.octet_string = osalt;
  kdf->salt->type = V_ASN1_OCTET_STRING;
  if (!saltlen)
    saltlen = PKCS5_SALT_LEN;
  if (!(osalt->data = malloc(saltlen)))
    goto merr;
  osalt->length = saltlen;
  if (salt)
    memcpy(osalt->data, salt, saltlen);
  else
    arc4random_buf(osalt->data, saltlen);
  if (iter <= 0)
    iter = PKCS5_DEFAULT_ITER;
  if (!ASN1_INTEGER_set(kdf->iter, iter))
    goto merr;
  if (keylen > 0) {
    if (!(kdf->keylength = ASN1_INTEGER_new()))
      goto merr;
    if (!ASN1_INTEGER_set(kdf->keylength, keylen))
      goto merr;
  }
  if (prf_nid > 0 && prf_nid != NID_hmacWithSHA1) {
    kdf->prf = X509_ALGOR_new();
    if (!kdf->prf)
      goto merr;
    X509_ALGOR_set0(kdf->prf, OBJ_nid2obj(prf_nid), V_ASN1_NULL, NULL);
  }
  keyfunc = X509_ALGOR_new();
  if (!keyfunc)
    goto merr;
  keyfunc->algorithm = OBJ_nid2obj(NID_id_pbkdf2);
  if (!(keyfunc->parameter = ASN1_TYPE_new()))
    goto merr;
  if (!ASN1_item_pack(kdf, &PBKDF2PARAM_it,
                      &keyfunc->parameter->value.sequence))
    goto merr;
  keyfunc->parameter->type = V_ASN1_SEQUENCE;
  PBKDF2PARAM_free(kdf);
  return keyfunc;
merr:
  ASN1error(ERR_R_MALLOC_FAILURE);
  PBKDF2PARAM_free(kdf);
  X509_ALGOR_free(keyfunc);
  return NULL;
}


x86 assembly (clang, -O0):
<PKCS5_pbkdf2_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
mov    $0x0,%al
call   1100 <PBKDF2PARAM_new@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    123b <PKCS5_pbkdf2_set+0x4b>
jmp    146c <PKCS5_pbkdf2_set+0x27c>
mov    $0x0,%al
call   1050 <ASN1_OCTET_STRING_new@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
jne    1255 <PKCS5_pbkdf2_set+0x65>
jmp    146c <PKCS5_pbkdf2_set+0x27c>
mov    -0x40(%rbp),%rcx
mov    -0x38(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rcx,0x8(%rax)
mov    0x2d3c(%rip),%rax
mov    (%rax),%ecx
mov    -0x38(%rbp),%rax
mov    0x10(%rax),%rax
mov    %ecx,(%rax)
cmpl   $0x0,-0x1c(%rbp)
jne    128e <PKCS5_pbkdf2_set+0x9e>
mov    0x2d47(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
call   10e0 <malloc@plt>
mov    -0x40(%rbp),%rcx
mov    %eax,0x4(%rcx)
cmp    $0x0,%eax
jne    12ab <PKCS5_pbkdf2_set+0xbb>
jmp    146c <PKCS5_pbkdf2_set+0x27c>
mov    -0x1c(%rbp),%ecx
mov    -0x40(%rbp),%rax
mov    %ecx,(%rax)
cmpq   $0x0,-0x18(%rbp)
je     12d7 <PKCS5_pbkdf2_set+0xe7>
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   10c0 <memcpy@plt>
jmp    12e6 <PKCS5_pbkdf2_set+0xf6>
mov    -0x40(%rbp),%rax
mov    0x4(%rax),%edi
mov    -0x1c(%rbp),%esi
call   1080 <arc4random_buf@plt>
cmpl   $0x0,-0xc(%rbp)
jg     12fc <PKCS5_pbkdf2_set+0x10c>
mov    0x2cb9(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0xc(%rbp)
mov    -0x38(%rbp),%rax
mov    0xc(%rax),%edi
mov    -0xc(%rbp),%esi
call   10b0 <ASN1_INTEGER_set@plt>
cmp    $0x0,%eax
jne    1319 <PKCS5_pbkdf2_set+0x129>
jmp    146c <PKCS5_pbkdf2_set+0x27c>
cmpl   $0x0,-0x24(%rbp)
jle    1361 <PKCS5_pbkdf2_set+0x171>
mov    $0x0,%al
call   1090 <ASN1_INTEGER_new@plt>
mov    -0x38(%rbp),%rcx
mov    %eax,0x8(%rcx)
cmp    $0x0,%eax
jne    133f <PKCS5_pbkdf2_set+0x14f>
jmp    146c <PKCS5_pbkdf2_set+0x27c>
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0x24(%rbp),%esi
call   10b0 <ASN1_INTEGER_set@plt>
cmp    $0x0,%eax
jne    135c <PKCS5_pbkdf2_set+0x16c>
jmp    146c <PKCS5_pbkdf2_set+0x27c>
jmp    1361 <PKCS5_pbkdf2_set+0x171>
cmpl   $0x0,-0x20(%rbp)
jle    13cc <PKCS5_pbkdf2_set+0x1dc>
mov    -0x20(%rbp),%eax
mov    0x2c4b(%rip),%rcx
cmp    (%rcx),%eax
je     13cc <PKCS5_pbkdf2_set+0x1dc>
mov    $0x0,%al
call   1070 <X509_ALGOR_new@plt>
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x38(%rbp),%rax
cmpq   $0x0,(%rax)
jne    13a1 <PKCS5_pbkdf2_set+0x1b1>
jmp    146c <PKCS5_pbkdf2_set+0x27c>
mov    -0x38(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%edi
call   1060 <OBJ_nid2obj@plt>
mov    -0x48(%rbp),%rdi
mov    %eax,%esi
mov    0x2bf7(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%ecx
call   10a0 <X509_ALGOR_set0@plt>
mov    $0x0,%al
call   1070 <X509_ALGOR_new@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    13e7 <PKCS5_pbkdf2_set+0x1f7>
jmp    146c <PKCS5_pbkdf2_set+0x27c>
mov    0x2bfa(%rip),%rax
mov    (%rax),%edi
call   1060 <OBJ_nid2obj@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    $0x0,%al
call   1030 <ASN1_TYPE_new@plt>
mov    -0x30(%rbp),%rcx
mov    %rax,(%rcx)
cmp    $0x0,%rax
jne    141b <PKCS5_pbkdf2_set+0x22b>
jmp    146c <PKCS5_pbkdf2_set+0x27c>
mov    -0x38(%rbp),%rdi
mov    -0x30(%rbp),%rax
mov    (%rax),%rdx
add    $0x4,%rdx
mov    0x2ba7(%rip),%rsi
call   1040 <ASN1_item_pack@plt>
cmp    $0x0,%eax
jne    1444 <PKCS5_pbkdf2_set+0x254>
jmp    146c <PKCS5_pbkdf2_set+0x27c>
mov    0x2b4d(%rip),%rax
mov    (%rax),%ecx
mov    -0x30(%rbp),%rax
mov    (%rax),%rax
mov    %ecx,(%rax)
mov    -0x38(%rbp),%rdi
call   10f0 <PBKDF2PARAM_free@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1494 <PKCS5_pbkdf2_set+0x2a4>
mov    0x2b6d(%rip),%rax
mov    (%rax),%edi
call   1110 <ASN1error@plt>
mov    -0x38(%rbp),%rdi
call   10f0 <PBKDF2PARAM_free@plt>
mov    -0x30(%rbp),%rdi
call   10d0 <X509_ALGOR_free@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PKCS5_pbkdf2_set>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8d,%r13d
mov    %ecx,%ebp
mov    %edx,%r14d
mov    %rsi,0x10(%rsp)
mov    %edi,%ebx
xor    %r12d,%r12d
xor    %eax,%eax
call   1100 <PBKDF2PARAM_new@plt>
mov    %rax,%r15
test   %rax,%rax
je     13ab <PKCS5_pbkdf2_set+0x1bb>
mov    %r13d,0xc(%rsp)
mov    %r15,%r13
xor    %r12d,%r12d
xor    %eax,%eax
call   1050 <ASN1_OCTET_STRING_new@plt>
test   %rax,%rax
je     1288 <PKCS5_pbkdf2_set+0x98>
mov    %rax,%r15
mov    0x10(%r13),%rax
mov    %r15,0x8(%rax)
mov    0x2d5c(%rip),%rcx
mov    (%rcx),%ecx
mov    %ecx,(%rax)
test   %r14d,%r14d
jne    125f <PKCS5_pbkdf2_set+0x6f>
mov    0x2d74(%rip),%rax
mov    (%rax),%r14d
mov    %r14d,%edi
call   10e0 <malloc@plt>
mov    %eax,0x4(%r15)
test   %eax,%eax
je     1290 <PKCS5_pbkdf2_set+0xa0>
mov    %r14d,(%r15)
mov    0x10(%rsp),%rsi
mov    %eax,%edi
test   %rsi,%rsi
je     129b <PKCS5_pbkdf2_set+0xab>
mov    %r14d,%edx
call   10c0 <memcpy@plt>
jmp    12a3 <PKCS5_pbkdf2_set+0xb3>
mov    %r13,%r15
jmp    13ab <PKCS5_pbkdf2_set+0x1bb>
xor    %r12d,%r12d
mov    %r13,%r15
jmp    13ab <PKCS5_pbkdf2_set+0x1bb>
mov    %r14d,%esi
call   1080 <arc4random_buf@plt>
mov    %ebp,%r14d
mov    %r13,%r15
test   %ebx,%ebx
mov    0xc(%rsp),%ebp
jg     12ba <PKCS5_pbkdf2_set+0xca>
mov    0x2cf8(%rip),%rax
mov    (%rax),%ebx
mov    0xc(%r15),%edi
mov    %ebx,%esi
call   10b0 <ASN1_INTEGER_set@plt>
test   %eax,%eax
je     13a3 <PKCS5_pbkdf2_set+0x1b3>
test   %ebp,%ebp
jle    12f8 <PKCS5_pbkdf2_set+0x108>
xor    %r12d,%r12d
xor    %eax,%eax
call   1090 <ASN1_INTEGER_new@plt>
mov    %eax,0x8(%r15)
test   %eax,%eax
je     13ab <PKCS5_pbkdf2_set+0x1bb>
mov    %eax,%edi
mov    %ebp,%esi
call   10b0 <ASN1_INTEGER_set@plt>
test   %eax,%eax
je     13a3 <PKCS5_pbkdf2_set+0x1b3>
test   %r14d,%r14d
jle    133f <PKCS5_pbkdf2_set+0x14f>
mov    0x2cbc(%rip),%rax
cmp    %r14d,(%rax)
je     133f <PKCS5_pbkdf2_set+0x14f>
xor    %r12d,%r12d
xor    %eax,%eax
call   1070 <X509_ALGOR_new@plt>
mov    %rax,(%r15)
test   %rax,%rax
je     13ab <PKCS5_pbkdf2_set+0x1bb>
mov    %rax,%rbx
mov    %r14d,%edi
call   1060 <OBJ_nid2obj@plt>
mov    0x2c87(%rip),%rcx
mov    (%rcx),%edx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %ecx,%ecx
call   10a0 <X509_ALGOR_set0@plt>
xor    %r12d,%r12d
xor    %eax,%eax
call   1070 <X509_ALGOR_new@plt>
test   %rax,%rax
je     13ab <PKCS5_pbkdf2_set+0x1bb>
mov    %rax,%rbx
mov    0x2c90(%rip),%rax
mov    (%rax),%edi
call   1060 <OBJ_nid2obj@plt>
mov    %eax,0x8(%rbx)
xor    %eax,%eax
call   1030 <ASN1_TYPE_new@plt>
mov    %rax,(%rbx)
test   %rax,%rax
je     13a8 <PKCS5_pbkdf2_set+0x1b8>
add    $0x4,%rax
mov    0x2c5c(%rip),%rsi
mov    %r15,%rdi
mov    %rax,%rdx
call   1040 <ASN1_item_pack@plt>
test   %eax,%eax
je     13a8 <PKCS5_pbkdf2_set+0x1b8>
mov    0x2c06(%rip),%rax
mov    (%rax),%eax
mov    (%rbx),%rcx
mov    %eax,(%rcx)
mov    %r15,%rdi
call   10f0 <PBKDF2PARAM_free@plt>
jmp    13cb <PKCS5_pbkdf2_set+0x1db>
xor    %r12d,%r12d
jmp    13ab <PKCS5_pbkdf2_set+0x1bb>
mov    %rbx,%r12
mov    0x2c2e(%rip),%rax
mov    (%rax),%edi
call   1110 <ASN1error@plt>
mov    %r15,%rdi
call   10f0 <PBKDF2PARAM_free@plt>
mov    %r12,%rdi
call   10d0 <X509_ALGOR_free@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_18__ = type { %struct.TYPE_14__*, i32 }
%struct.TYPE_14__ = type { i32, %struct.TYPE_17__ }
%struct.TYPE_17__ = type { i32 }
%struct.TYPE_19__ = type { i8*, i32, i32, %struct.TYPE_16__* }
%struct.TYPE_16__ = type { i32, %struct.TYPE_15__ }
%struct.TYPE_15__ = type { %struct.TYPE_20__* }
%struct.TYPE_20__ = type { i32, i32 }
@V_ASN1_OCTET_STRING = global i32 0
@PKCS5_SALT_LEN = global i32 0
@PKCS5_DEFAULT_ITER = global i32 0
@NID_hmacWithSHA1 = global i32 0
@V_ASN1_NULL = global i32 0
@NID_id_pbkdf2 = global i32 0
@PBKDF2PARAM_it = global i32 0
@V_ASN1_SEQUENCE = global i32 0
@ERR_R_MALLOC_FAILURE = global i32 0
define %struct.TYPE_18__* @PKCS5_pbkdf2_set(i32 %0, i8* %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca %struct.TYPE_18__*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca %struct.TYPE_18__*
%13 = alloca %struct.TYPE_19__*
%14 = alloca %struct.TYPE_20__*
store i32 %0, i32* %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store %struct.TYPE_18__* null, %struct.TYPE_18__** %12
store %struct.TYPE_19__* null, %struct.TYPE_19__** %13
store %struct.TYPE_20__* null, %struct.TYPE_20__** %14
%15 = call %struct.TYPE_19__* (...) @PBKDF2PARAM_new()
store %struct.TYPE_19__* %15, %struct.TYPE_19__** %13
%16 = icmp ne %struct.TYPE_19__* %15, null
br i1 %16, label %18, label %17
17: ; preds = %5
br label %154
18: ; preds = %5
%19 = call %struct.TYPE_20__* (...) @ASN1_OCTET_STRING_new()
store %struct.TYPE_20__* %19, %struct.TYPE_20__** %14
%20 = icmp ne %struct.TYPE_20__* %19, null
br i1 %20, label %22, label %21
21: ; preds = %18
br label %154
22: ; preds = %18
%23 = load %struct.TYPE_20__*, %struct.TYPE_20__** %14
%24 = load %struct.TYPE_19__*, %struct.TYPE_19__** %13
%25 = getelementptr inbounds %struct.TYPE_19__, %struct.TYPE_19__* %24, i32 0, i32 3
%26 = load %struct.TYPE_16__*, %struct.TYPE_16__** %25
%27 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %26, i32 0, i32 1
%28 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %27, i32 0, i32 0
store %struct.TYPE_20__* %23, %struct.TYPE_20__** %28
%29 = load i32, i32* @V_ASN1_OCTET_STRING
%30 = load %struct.TYPE_19__*, %struct.TYPE_19__** %13
%31 = getelementptr inbounds %struct.TYPE_19__, %struct.TYPE_19__* %30, i32 0, i32 3
%32 = load %struct.TYPE_16__*, %struct.TYPE_16__** %31
%33 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %32, i32 0, i32 0
store i32 %29, i32* %33
%34 = load i32, i32* %9
%35 = icmp ne i32 %34, 0
br i1 %35, label %38, label %36
36: ; preds = %22
%37 = load i32, i32* @PKCS5_SALT_LEN
store i32 %37, i32* %9
br label %38
38: ; preds = %36, %22
%39 = load i32, i32* %9
%40 = call i32 @malloc(i32 %39)
%41 = load %struct.TYPE_20__*, %struct.TYPE_20__** %14
%42 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %41, i32 0, i32 1
store i32 %40, i32* %42
%43 = icmp ne i32 %40, 0
br i1 %43, label %45, label %44
44: ; preds = %38
br label %154
45: ; preds = %38
%46 = load i32, i32* %9
%47 = load %struct.TYPE_20__*, %struct.TYPE_20__** %14
%48 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %47, i32 0, i32 0
store i32 %46, i32* %48
%49 = load i8*, i8** %8
%50 = icmp ne i8* %49, null
br i1 %50, label %51, label %58
51: ; preds = %45
%52 = load %struct.TYPE_20__*, %struct.TYPE_20__** %14
%53 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %52, i32 0, i32 1
%54 = load i32, i32* %53
%55 = load i8*, i8** %8
%56 = load i32, i32* %9
%57 = call i32 @memcpy(i32 %54, i8* %55, i32 %56)
br label %64
58: ; preds = %45
%59 = load %struct.TYPE_20__*, %struct.TYPE_20__** %14
%60 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %59, i32 0, i32 1
%61 = load i32, i32* %60
%62 = load i32, i32* %9
%63 = call i32 @arc4random_buf(i32 %61, i32 %62)
br label %64
64: ; preds = %58, %51
%65 = load i32, i32* %7
%66 = icmp sle i32 %65, 0
br i1 %66, label %67, label %69
67: ; preds = %64
%68 = load i32, i32* @PKCS5_DEFAULT_ITER
store i32 %68, i32* %7
br label %69
69: ; preds = %67, %64
%70 = load %struct.TYPE_19__*, %struct.TYPE_19__** %13
%71 = getelementptr inbounds %struct.TYPE_19__, %struct.TYPE_19__* %70, i32 0, i32 2
%72 = load i32, i32* %71
%73 = load i32, i32* %7
%74 = call i32 @ASN1_INTEGER_set(i32 %72, i32 %73)
%75 = icmp ne i32 %74, 0
br i1 %75, label %77, label %76
76: ; preds = %69
br label %154
77: ; preds = %69
%78 = load i32, i32* %11
%79 = icmp sgt i32 %78, 0
br i1 %79, label %80, label %95
80: ; preds = %77
%81 = call i32 (...) @ASN1_INTEGER_new()
%82 = load %struct.TYPE_19__*, %struct.TYPE_19__** %13
%83 = getelementptr inbounds %struct.TYPE_19__, %struct.TYPE_19__* %82, i32 0, i32 1
store i32 %81, i32* %83
%84 = icmp ne i32 %81, 0
br i1 %84, label %86, label %85
85: ; preds = %80
br label %154
86: ; preds = %80
%87 = load %struct.TYPE_19__*, %struct.TYPE_19__** %13
%88 = getelementptr inbounds %struct.TYPE_19__, %struct.TYPE_19__* %87, i32 0, i32 1
%89 = load i32, i32* %88
%90 = load i32, i32* %11
%91 = call i32 @ASN1_INTEGER_set(i32 %89, i32 %90)
%92 = icmp ne i32 %91, 0
br i1 %92, label %94, label %93
93: ; preds = %86
br label %154
94: ; preds = %86
br label %95
95: ; preds = %94, %77
%96 = load i32, i32* %10
%97 = icmp sgt i32 %96, 0
br i1 %97, label %98, label %119
98: ; preds = %95
%99 = load i32, i32* %10
%100 = load i32, i32* @NID_hmacWithSHA1
%101 = icmp ne i32 %99, %100
br i1 %101, label %102, label %119
102: ; preds = %98
%103 = call i8* (...) @X509_ALGOR_new()
%104 = load %struct.TYPE_19__*, %struct.TYPE_19__** %13
%105 = getelementptr inbounds %struct.TYPE_19__, %struct.TYPE_19__* %104, i32 0, i32 0
store i8* %103, i8** %105
%106 = load %struct.TYPE_19__*, %struct.TYPE_19__** %13
%107 = getelementptr inbounds %struct.TYPE_19__, %struct.TYPE_19__* %106, i32 0, i32 0
%108 = load i8*, i8** %107
%109 = icmp ne i8* %108, null
br i1 %109, label %111, label %110
110: ; preds = %102
br label %154
111: ; preds = %102
%112 = load %struct.TYPE_19__*, %struct.TYPE_19__** %13
%113 = getelementptr inbounds %struct.TYPE_19__, %struct.TYPE_19__* %112, i32 0, i32 0
%114 = load i8*, i8** %113
%115 = load i32, i32* %10
%116 = call i32 @OBJ_nid2obj(i32 %115)
%117 = load i32, i32* @V_ASN1_NULL
%118 = call i32 @X509_ALGOR_set0(i8* %114, i32 %116, i32 %117, i32* null)
br label %119
119: ; preds = %111, %98, %95
%120 = call i8* (...) @X509_ALGOR_new()
%121 = bitcast i8* %120 to %struct.TYPE_18__*
store %struct.TYPE_18__* %121, %struct.TYPE_18__** %12
%122 = load %struct.TYPE_18__*, %struct.TYPE_18__** %12
%123 = icmp ne %struct.TYPE_18__* %122, null
br i1 %123, label %125, label %124
124: ; preds = %119
br label %154
125: ; preds = %119
%126 = load i32, i32* @NID_id_pbkdf2
%127 = call i32 @OBJ_nid2obj(i32 %126)
%128 = load %struct.TYPE_18__*, %struct.TYPE_18__** %12
%129 = getelementptr inbounds %struct.TYPE_18__, %struct.TYPE_18__* %128, i32 0, i32 1
store i32 %127, i32* %129
%130 = call %struct.TYPE_14__* (...) @ASN1_TYPE_new()
%131 = load %struct.TYPE_18__*, %struct.TYPE_18__** %12
%132 = getelementptr inbounds %struct.TYPE_18__, %struct.TYPE_18__* %131, i32 0, i32 0
store %struct.TYPE_14__* %130, %struct.TYPE_14__** %132
%133 = icmp ne %struct.TYPE_14__* %130, null
br i1 %133, label %135, label %134
134: ; preds = %125
br label %154
135: ; preds = %125
%136 = load %struct.TYPE_19__*, %struct.TYPE_19__** %13
%137 = load %struct.TYPE_18__*, %struct.TYPE_18__** %12
%138 = getelementptr inbounds %struct.TYPE_18__, %struct.TYPE_18__* %137, i32 0, i32 0
%139 = load %struct.TYPE_14__*, %struct.TYPE_14__** %138
%140 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %139, i32 0, i32 1
%141 = getelementptr inbounds %struct.TYPE_17__, %struct.TYPE_17__* %140, i32 0, i32 0
%142 = call i32 @ASN1_item_pack(%struct.TYPE_19__* %136, i32* @PBKDF2PARAM_it, i32* %141)
%143 = icmp ne i32 %142, 0
br i1 %143, label %145, label %144
144: ; preds = %135
br label %154
145: ; preds = %135
%146 = load i32, i32* @V_ASN1_SEQUENCE
%147 = load %struct.TYPE_18__*, %struct.TYPE_18__** %12
%148 = getelementptr inbounds %struct.TYPE_18__, %struct.TYPE_18__* %147, i32 0, i32 0
%149 = load %struct.TYPE_14__*, %struct.TYPE_14__** %148
%150 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %149, i32 0, i32 0
store i32 %146, i32* %150
%151 = load %struct.TYPE_19__*, %struct.TYPE_19__** %13
%152 = call i32 @PBKDF2PARAM_free(%struct.TYPE_19__* %151)
%153 = load %struct.TYPE_18__*, %struct.TYPE_18__** %12
store %struct.TYPE_18__* %153, %struct.TYPE_18__** %6
br label %161
154: ; preds = %144, %134, %124, %110, %93, %85, %76, %44, %21, %17
%155 = load i32, i32* @ERR_R_MALLOC_FAILURE
%156 = call i32 @ASN1error(i32 %155)
%157 = load %struct.TYPE_19__*, %struct.TYPE_19__** %13
%158 = call i32 @PBKDF2PARAM_free(%struct.TYPE_19__* %157)
%159 = load %struct.TYPE_18__*, %struct.TYPE_18__** %12
%160 = call i32 @X509_ALGOR_free(%struct.TYPE_18__* %159)
store %struct.TYPE_18__* null, %struct.TYPE_18__** %6
br label %161
161: ; preds = %154, %145
%162 = load %struct.TYPE_18__*, %struct.TYPE_18__** %6
ret %struct.TYPE_18__* %162
}

LLVM IR (-O2):
%struct.TYPE_18__ = type { %struct.TYPE_14__*, i32 }
%struct.TYPE_14__ = type { i32, %struct.TYPE_17__ }
%struct.TYPE_17__ = type { i32 }
%struct.TYPE_19__ = type { i8*, i32, i32, %struct.TYPE_16__* }
%struct.TYPE_16__ = type { i32, %struct.TYPE_15__ }
%struct.TYPE_15__ = type { %struct.TYPE_20__* }
%struct.TYPE_20__ = type { i32, i32 }
@V_ASN1_OCTET_STRING = global i32 0
@PKCS5_SALT_LEN = global i32 0
@PKCS5_DEFAULT_ITER = global i32 0
@NID_hmacWithSHA1 = global i32 0
@V_ASN1_NULL = global i32 0
@NID_id_pbkdf2 = global i32 0
@PBKDF2PARAM_it = global i32 0
@V_ASN1_SEQUENCE = global i32 0
@ERR_R_MALLOC_FAILURE = global i32 0
define %struct.TYPE_18__* @PKCS5_pbkdf2_set(i32 %0, i8* %1, i32 %2, i32 %3, i32 %4) {
%6 = tail call %struct.TYPE_19__* (...) @PBKDF2PARAM_new()
%7 = icmp eq %struct.TYPE_19__* %6, null
br i1 %7, label %81, label %8
8: ; preds = %5
%9 = tail call %struct.TYPE_20__* (...) @ASN1_OCTET_STRING_new()
%10 = icmp eq %struct.TYPE_20__* %9, null
br i1 %10, label %81, label %11
11: ; preds = %8
%12 = getelementptr inbounds %struct.TYPE_19__, %struct.TYPE_19__* %6, i64 0, i32 3
%13 = load %struct.TYPE_16__*, %struct.TYPE_16__** %12
%14 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %13, i64 0, i32 1, i32 0
store %struct.TYPE_20__* %9, %struct.TYPE_20__** %14
%15 = load i32, i32* @V_ASN1_OCTET_STRING
%16 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %13, i64 0, i32 0
store i32 %15, i32* %16
%17 = icmp eq i32 %2, 0
%18 = load i32, i32* @PKCS5_SALT_LEN
%19 = select i1 %17, i32 %18, i32 %2
%20 = tail call i32 @malloc(i32 %19)
%21 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %9, i64 0, i32 1
store i32 %20, i32* %21
%22 = icmp eq i32 %20, 0
br i1 %22, label %81, label %23
23: ; preds = %11
%24 = getelementptr inbounds %struct.TYPE_20__, %struct.TYPE_20__* %9, i64 0, i32 0
store i32 %19, i32* %24
%25 = icmp eq i8* %1, null
br i1 %25, label %28, label %26
26: ; preds = %23
%27 = tail call i32 @memcpy(i32 %20, i8* %1, i32 %19)
br label %30
28: ; preds = %23
%29 = tail call i32 @arc4random_buf(i32 %20, i32 %19)
br label %30
30: ; preds = %28, %26
%31 = icmp slt i32 %0, 1
%32 = load i32, i32* @PKCS5_DEFAULT_ITER
%33 = select i1 %31, i32 %32, i32 %0
%34 = getelementptr inbounds %struct.TYPE_19__, %struct.TYPE_19__* %6, i64 0, i32 2
%35 = load i32, i32* %34
%36 = tail call i32 @ASN1_INTEGER_set(i32 %35, i32 %33)
%37 = icmp eq i32 %36, 0
br i1 %37, label %81, label %38
38: ; preds = %30
%39 = icmp sgt i32 %4, 0
br i1 %39, label %40, label %47
40: ; preds = %38
%41 = tail call i32 (...) @ASN1_INTEGER_new()
%42 = getelementptr inbounds %struct.TYPE_19__, %struct.TYPE_19__* %6, i64 0, i32 1
store i32 %41, i32* %42
%43 = icmp eq i32 %41, 0
br i1 %43, label %81, label %44
44: ; preds = %40
%45 = tail call i32 @ASN1_INTEGER_set(i32 %41, i32 %4)
%46 = icmp eq i32 %45, 0
br i1 %46, label %81, label %47
47: ; preds = %44, %38
%48 = icmp slt i32 %3, 1
%49 = load i32, i32* @NID_hmacWithSHA1
%50 = icmp eq i32 %49, %3
%51 = select i1 %48, i1 true, i1 %50
br i1 %51, label %60, label %52
52: ; preds = %47
%53 = tail call i8* (...) @X509_ALGOR_new()
%54 = getelementptr inbounds %struct.TYPE_19__, %struct.TYPE_19__* %6, i64 0, i32 0
store i8* %53, i8** %54
%55 = icmp eq i8* %53, null
br i1 %55, label %81, label %56
56: ; preds = %52
%57 = tail call i32 @OBJ_nid2obj(i32 %3)
%58 = load i32, i32* @V_ASN1_NULL
%59 = tail call i32 @X509_ALGOR_set0(i8* %53, i32 %57, i32 %58, i32* null)
br label %60
60: ; preds = %56, %47
%61 = tail call i8* (...) @X509_ALGOR_new()
%62 = bitcast i8* %61 to %struct.TYPE_18__*
%63 = icmp eq i8* %61, null
br i1 %63, label %81, label %64
64: ; preds = %60
%65 = load i32, i32* @NID_id_pbkdf2
%66 = tail call i32 @OBJ_nid2obj(i32 %65)
%67 = getelementptr inbounds i8, i8* %61, i64 8
%68 = bitcast i8* %67 to i32*
store i32 %66, i32* %68
%69 = tail call %struct.TYPE_14__* (...) @ASN1_TYPE_new()
%70 = bitcast i8* %61 to %struct.TYPE_14__**
store %struct.TYPE_14__* %69, %struct.TYPE_14__** %70
%71 = icmp eq %struct.TYPE_14__* %69, null
br i1 %71, label %81, label %72
72: ; preds = %64
%73 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %69, i64 0, i32 1, i32 0
%74 = tail call i32 @ASN1_item_pack(%struct.TYPE_19__* %6, i32* @PBKDF2PARAM_it, i32* %73)
%75 = icmp eq i32 %74, 0
br i1 %75, label %81, label %76
76: ; preds = %72
%77 = load i32, i32* @V_ASN1_SEQUENCE
%78 = load %struct.TYPE_14__*, %struct.TYPE_14__** %70
%79 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %78, i64 0, i32 0
store i32 %77, i32* %79
%80 = tail call i32 @PBKDF2PARAM_free(%struct.TYPE_19__* %6)
br label %87
81: ; preds = %72, %64, %60, %52, %44, %40, %30, %11, %8, %5
%82 = phi %struct.TYPE_18__* [ %62, %72 ], [ %62, %64 ], [ null, %60 ], [ null, %52 ], [ null, %44 ], [ null, %40 ], [ null, %30 ], [ null, %11 ], [ null, %8 ], [ null, %5 ]
%83 = load i32, i32* @ERR_R_MALLOC_FAILURE
%84 = tail call i32 @ASN1error(i32 %83)
%85 = tail call i32 @PBKDF2PARAM_free(%struct.TYPE_19__* %6)
%86 = tail call i32 @X509_ALGOR_free(%struct.TYPE_18__* %82)
br label %87
87: ; preds = %81, %76
%88 = phi %struct.TYPE_18__* [ %62, %76 ], [ null, %81 ]
ret %struct.TYPE_18__* %88
}