#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_14__ {
  int /*<<< orphan*/ algorithm;
  TYPE_4__ *parameter;
};
typedef TYPE_5__ X509_ALGOR;
struct TYPE_15__ {
  TYPE_1__ *salt;
  int /*<<< orphan*/ iter;
};
struct TYPE_12__ {
  TYPE_2__ *sequence;
};
struct TYPE_13__ {
  TYPE_3__ value;
};
struct TYPE_11__ {
  unsigned char *data;
  int /*<<< orphan*/ length;
};
struct TYPE_10__ {
  int length;
};
typedef TYPE_6__ PBEPARAM;

/* Variables and functions */
int ASN1_INTEGER_get(int /*<<< orphan*/);
int OBJ_obj2nid(int /*<<< orphan*/);
int /*<<< orphan*/ PBEPARAM_free(TYPE_6__ *);
TYPE_6__ *d2i_PBEPARAM(int /*<<< orphan*/ *, unsigned char const **,
                       int /*<<< orphan*/);
int alg_get(X509_ALGOR *alg, int *pnid, int *piter, int *psaltlen) {
  PBEPARAM *pbe;
  const unsigned char *p;
  p = alg->parameter->value.sequence->data;
  pbe = d2i_PBEPARAM(NULL, &p, alg->parameter->value.sequence->length);
  *pnid = OBJ_obj2nid(alg->algorithm);
  *piter = ASN1_INTEGER_get(pbe->iter);
  *psaltlen = pbe->salt->length;
  PBEPARAM_free(pbe);
  return 0;
}


x86 assembly (clang, -O0):
<alg_get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rax
mov    0x8(%rax),%edx
xor    %eax,%eax
mov    %eax,%edi
lea    -0x30(%rbp),%rsi
call   1060 <d2i_PBEPARAM@plt>
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1030 <OBJ_obj2nid@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%edi
call   1050 <ASN1_INTEGER_get@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rdi
call   1040 <PBEPARAM_free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alg_get>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
mov    0x8(%rdi),%rax
mov    (%rax),%rcx
mov    (%rcx),%rcx
mov    %rcx,0x8(%rsp)
mov    (%rax),%rax
mov    0x8(%rax),%edx
lea    0x8(%rsp),%rsi
xor    %edi,%edi
call   1060 <d2i_PBEPARAM@plt>
mov    %rax,%rbx
mov    0x0(%r13),%edi
call   1030 <OBJ_obj2nid@plt>
mov    %eax,(%r12)
mov    0x8(%rbx),%edi
call   1050 <ASN1_INTEGER_get@plt>
mov    %eax,(%r15)
mov    (%rbx),%rax
mov    (%rax),%eax
mov    %eax,(%r14)
mov    %rbx,%rdi
call   1040 <PBEPARAM_free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.TYPE_14__ = type { i32, %struct.TYPE_13__* }
%struct.TYPE_13__ = type { %struct.TYPE_12__ }
%struct.TYPE_12__ = type { %struct.TYPE_11__* }
%struct.TYPE_11__ = type { i8*, i32 }
%struct.TYPE_15__ = type { %struct.TYPE_10__*, i32 }
%struct.TYPE_10__ = type { i32 }
define i32 @alg_get(%struct.TYPE_14__* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca %struct.TYPE_14__*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca %struct.TYPE_15__*
%10 = alloca i8*
store %struct.TYPE_14__* %0, %struct.TYPE_14__** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%11 = load %struct.TYPE_14__*, %struct.TYPE_14__** %5
%12 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %11, i32 0, i32 1
%13 = load %struct.TYPE_13__*, %struct.TYPE_13__** %12
%14 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %13, i32 0, i32 0
%15 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %14, i32 0, i32 0
%16 = load %struct.TYPE_11__*, %struct.TYPE_11__** %15
%17 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %16, i32 0, i32 0
%18 = load i8*, i8** %17
store i8* %18, i8** %10
%19 = load %struct.TYPE_14__*, %struct.TYPE_14__** %5
%20 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %19, i32 0, i32 1
%21 = load %struct.TYPE_13__*, %struct.TYPE_13__** %20
%22 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %21, i32 0, i32 0
%23 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %22, i32 0, i32 0
%24 = load %struct.TYPE_11__*, %struct.TYPE_11__** %23
%25 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %24, i32 0, i32 1
%26 = load i32, i32* %25
%27 = call %struct.TYPE_15__* @d2i_PBEPARAM(i32* null, i8** %10, i32 %26)
store %struct.TYPE_15__* %27, %struct.TYPE_15__** %9
%28 = load %struct.TYPE_14__*, %struct.TYPE_14__** %5
%29 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %28, i32 0, i32 0
%30 = load i32, i32* %29
%31 = call i32 @OBJ_obj2nid(i32 %30)
%32 = load i32*, i32** %6
store i32 %31, i32* %32
%33 = load %struct.TYPE_15__*, %struct.TYPE_15__** %9
%34 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %33, i32 0, i32 1
%35 = load i32, i32* %34
%36 = call i32 @ASN1_INTEGER_get(i32 %35)
%37 = load i32*, i32** %7
store i32 %36, i32* %37
%38 = load %struct.TYPE_15__*, %struct.TYPE_15__** %9
%39 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %38, i32 0, i32 0
%40 = load %struct.TYPE_10__*, %struct.TYPE_10__** %39
%41 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %40, i32 0, i32 0
%42 = load i32, i32* %41
%43 = load i32*, i32** %8
store i32 %42, i32* %43
%44 = load %struct.TYPE_15__*, %struct.TYPE_15__** %9
%45 = call i32 @PBEPARAM_free(%struct.TYPE_15__* %44)
ret i32 0
}

LLVM IR (-O2):
%struct.TYPE_14__ = type { i32, %struct.TYPE_13__* }
%struct.TYPE_13__ = type { %struct.TYPE_12__ }
%struct.TYPE_12__ = type { %struct.TYPE_11__* }
%struct.TYPE_11__ = type { i8*, i32 }
%struct.TYPE_15__ = type { %struct.TYPE_10__*, i32 }
%struct.TYPE_10__ = type { i32 }
define i32 @alg_get(%struct.TYPE_14__* nocapture %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3) {
%5 = alloca i8*
%6 = bitcast i8** %5 to i8*
%7 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %0, i64 0, i32 1
%8 = load %struct.TYPE_13__*, %struct.TYPE_13__** %7
%9 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %8, i64 0, i32 0, i32 0
%10 = load %struct.TYPE_11__*, %struct.TYPE_11__** %9
%11 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %10, i64 0, i32 0
%12 = load i8*, i8** %11
store i8* %12, i8** %5
%13 = load %struct.TYPE_11__*, %struct.TYPE_11__** %9
%14 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %13, i64 0, i32 1
%15 = load i32, i32* %14
%16 = call %struct.TYPE_15__* @d2i_PBEPARAM(i32* null, i8** %5, i32 %15)
%17 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %0, i64 0, i32 0
%18 = load i32, i32* %17
%19 = call i32 @OBJ_obj2nid(i32 %18)
store i32 %19, i32* %1
%20 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %16, i64 0, i32 1
%21 = load i32, i32* %20
%22 = call i32 @ASN1_INTEGER_get(i32 %21)
store i32 %22, i32* %2
%23 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %16, i64 0, i32 0
%24 = load %struct.TYPE_10__*, %struct.TYPE_10__** %23
%25 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %24, i64 0, i32 0
%26 = load i32, i32* %25
store i32 %26, i32* %3
%27 = call i32 @PBEPARAM_free(%struct.TYPE_15__* %16)
ret i32 0
}