#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);
  if (!pbe)
    return 0;
  *pnid = OBJ_obj2nid(alg->algorithm);
  *piter = ASN1_INTEGER_get(pbe->iter);
  *psaltlen = pbe->salt->length;
  PBEPARAM_free(pbe);
  return 1;
}


x86 assembly (clang, -O0):
<alg_get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rax
mov    0x8(%rax),%edx
xor    %eax,%eax
mov    %eax,%edi
lea    -0x38(%rbp),%rsi
call   1060 <d2i_PBEPARAM@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11a0 <alg_get+0x60>
movl   $0x0,-0x4(%rbp)
jmp    11e6 <alg_get+0xa6>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1030 <OBJ_obj2nid@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%edi
call   1050 <ASN1_INTEGER_get@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%rdi
call   1040 <PBEPARAM_free@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<alg_get>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%r12
mov    %rdi,%r13
mov    0x8(%rdi),%rax
mov    (%rax),%rcx
mov    (%rcx),%rcx
mov    %rcx,(%rsp)
mov    (%rax),%rax
mov    0x8(%rax),%edx
xor    %ebp,%ebp
mov    %rsp,%rsi
xor    %edi,%edi
call   1060 <d2i_PBEPARAM@plt>
test   %rax,%rax
je     11ac <alg_get+0x6c>
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>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
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 i32
%6 = alloca %struct.TYPE_14__*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca %struct.TYPE_15__*
%11 = alloca i8*
store %struct.TYPE_14__* %0, %struct.TYPE_14__** %6
store i32* %1, i32** %7
store i32* %2, i32** %8
store i32* %3, i32** %9
%12 = load %struct.TYPE_14__*, %struct.TYPE_14__** %6
%13 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %12, i32 0, i32 1
%14 = load %struct.TYPE_13__*, %struct.TYPE_13__** %13
%15 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %14, i32 0, i32 0
%16 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %15, i32 0, i32 0
%17 = load %struct.TYPE_11__*, %struct.TYPE_11__** %16
%18 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %17, i32 0, i32 0
%19 = load i8*, i8** %18
store i8* %19, i8** %11
%20 = load %struct.TYPE_14__*, %struct.TYPE_14__** %6
%21 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %20, i32 0, i32 1
%22 = load %struct.TYPE_13__*, %struct.TYPE_13__** %21
%23 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %22, i32 0, i32 0
%24 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %23, i32 0, i32 0
%25 = load %struct.TYPE_11__*, %struct.TYPE_11__** %24
%26 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %25, i32 0, i32 1
%27 = load i32, i32* %26
%28 = call %struct.TYPE_15__* @d2i_PBEPARAM(i32* null, i8** %11, i32 %27)
store %struct.TYPE_15__* %28, %struct.TYPE_15__** %10
%29 = load %struct.TYPE_15__*, %struct.TYPE_15__** %10
%30 = icmp ne %struct.TYPE_15__* %29, null
br i1 %30, label %32, label %31
31: ; preds = %4
store i32 0, i32* %5
br label %51
32: ; preds = %4
%33 = load %struct.TYPE_14__*, %struct.TYPE_14__** %6
%34 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %33, i32 0, i32 0
%35 = load i32, i32* %34
%36 = call i32 @OBJ_obj2nid(i32 %35)
%37 = load i32*, i32** %7
store i32 %36, i32* %37
%38 = load %struct.TYPE_15__*, %struct.TYPE_15__** %10
%39 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %38, i32 0, i32 1
%40 = load i32, i32* %39
%41 = call i32 @ASN1_INTEGER_get(i32 %40)
%42 = load i32*, i32** %8
store i32 %41, i32* %42
%43 = load %struct.TYPE_15__*, %struct.TYPE_15__** %10
%44 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %43, i32 0, i32 0
%45 = load %struct.TYPE_10__*, %struct.TYPE_10__** %44
%46 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %45, i32 0, i32 0
%47 = load i32, i32* %46
%48 = load i32*, i32** %9
store i32 %47, i32* %48
%49 = load %struct.TYPE_15__*, %struct.TYPE_15__** %10
%50 = call i32 @PBEPARAM_free(%struct.TYPE_15__* %49)
store i32 1, i32* %5
br label %51
51: ; preds = %32, %31
%52 = load i32, i32* %5
ret i32 %52
}

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 = icmp eq %struct.TYPE_15__* %16, null
br i1 %17, label %30, label %18
18: ; preds = %4
%19 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %0, i64 0, i32 0
%20 = load i32, i32* %19
%21 = call i32 @OBJ_obj2nid(i32 %20)
store i32 %21, i32* %1
%22 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %16, i64 0, i32 1
%23 = load i32, i32* %22
%24 = call i32 @ASN1_INTEGER_get(i32 %23)
store i32 %24, i32* %2
%25 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %16, i64 0, i32 0
%26 = load %struct.TYPE_10__*, %struct.TYPE_10__** %25
%27 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %26, i64 0, i32 0
%28 = load i32, i32* %27
store i32 %28, i32* %3
%29 = call i32 @PBEPARAM_free(%struct.TYPE_15__* %16)
br label %30
30: ; preds = %4, %18
%31 = phi i32 [ 1, %18 ], [ 0, %4 ]
ret i32 %31
}