#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*/ X509_ALGOR;

/* Variables and functions */
int /*<<< orphan*/ ASN1error(int /*<<< orphan*/);
int /*<<< orphan*/ ERR_R_MALLOC_FAILURE;
scalar_t__ PKCS5_pbe_set0_algor(int /*<<< orphan*/ *, int, int,
                                unsigned char const *, int);
int /*<<< orphan*/ X509_ALGOR_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *X509_ALGOR_new();
X509_ALGOR *PKCS5_pbe_set(int alg, int iter, const unsigned char *salt,
                          int saltlen) {
  X509_ALGOR *ret;
  ret = X509_ALGOR_new();
  if (!ret) {
    ASN1error(ERR_R_MALLOC_FAILURE);
    return NULL;
  }
  if (PKCS5_pbe_set0_algor(ret, alg, iter, salt, saltlen))
    return ret;
  X509_ALGOR_free(ret);
  return NULL;
}


x86 assembly (clang, -O0):
<PKCS5_pbe_set>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    $0x0,%al
call   1030 <X509_ALGOR_new@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1186 <PKCS5_pbe_set+0x46>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
call   1060 <ASN1error@plt>
movq   $0x0,-0x8(%rbp)
jmp    11c5 <PKCS5_pbe_set+0x85>
mov    -0x28(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
call   1040 <PKCS5_pbe_set0_algor@plt>
cmp    $0x0,%rax
je     11b4 <PKCS5_pbe_set+0x74>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11c5 <PKCS5_pbe_set+0x85>
mov    -0x28(%rbp),%rdi
call   1050 <X509_ALGOR_free@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<PKCS5_pbe_set>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %esi,%r12d
mov    %edi,%ebp
xor    %eax,%eax
call   1030 <X509_ALGOR_new@plt>
test   %rax,%rax
je     1184 <PKCS5_pbe_set+0x44>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %ebp,%esi
mov    %r12d,%edx
mov    %r15,%rcx
mov    %r14d,%r8d
call   1040 <PKCS5_pbe_set0_algor@plt>
test   %rax,%rax
jne    1194 <PKCS5_pbe_set+0x54>
mov    %rbx,%rdi
call   1050 <X509_ALGOR_free@plt>
jmp    1192 <PKCS5_pbe_set+0x52>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
call   1060 <ASN1error@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@ERR_R_MALLOC_FAILURE = global i32 0
define i32* @PKCS5_pbe_set(i32 %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32*
store i32 %0, i32* %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%11 = call i32* (...) @X509_ALGOR_new()
store i32* %11, i32** %10
%12 = load i32*, i32** %10
%13 = icmp ne i32* %12, null
br i1 %13, label %17, label %14
14: ; preds = %4
%15 = load i32, i32* @ERR_R_MALLOC_FAILURE
%16 = call i32 @ASN1error(i32 %15)
store i32* null, i32** %5
br label %30
17: ; preds = %4
%18 = load i32*, i32** %10
%19 = load i32, i32* %6
%20 = load i32, i32* %7
%21 = load i8*, i8** %8
%22 = load i32, i32* %9
%23 = call i64 @PKCS5_pbe_set0_algor(i32* %18, i32 %19, i32 %20, i8* %21, i32 %22)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %17
%26 = load i32*, i32** %10
store i32* %26, i32** %5
br label %30
27: ; preds = %17
%28 = load i32*, i32** %10
%29 = call i32 @X509_ALGOR_free(i32* %28)
store i32* null, i32** %5
br label %30
30: ; preds = %27, %25, %14
%31 = load i32*, i32** %5
ret i32* %31
}

LLVM IR (-O2):
@ERR_R_MALLOC_FAILURE = global i32 0
define i32* @PKCS5_pbe_set(i32 %0, i32 %1, i8* %2, i32 %3) {
%5 = tail call i32* (...) @X509_ALGOR_new()
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = load i32, i32* @ERR_R_MALLOC_FAILURE
%9 = tail call i32 @ASN1error(i32 %8)
br label %15
10: ; preds = %4
%11 = tail call i64 @PKCS5_pbe_set0_algor(i32* %5, i32 %0, i32 %1, i8* %2, i32 %3)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = tail call i32 @X509_ALGOR_free(i32* %5)
br label %15
15: ; preds = %10, %13, %7
%16 = phi i32* [ null, %13 ], [ null, %7 ], [ %5, %10 ]
ret i32* %16
}