#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*/ ASN1_F_PKCS5_PBE_SET;
int /*<<< orphan*/ ASN1err(int /*<<< orphan*/, 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) {
    ASN1err(ASN1_F_PKCS5_PBE_SET, 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   1040 <X509_ALGOR_new@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    118f <PKCS5_pbe_set+0x4f>
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
mov    0x2e65(%rip),%rax
mov    (%rax),%esi
call   1030 <ASN1err@plt>
movq   $0x0,-0x8(%rbp)
jmp    11ce <PKCS5_pbe_set+0x8e>
mov    -0x28(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
call   1050 <PKCS5_pbe_set0_algor@plt>
cmp    $0x0,%rax
je     11bd <PKCS5_pbe_set+0x7d>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11ce <PKCS5_pbe_set+0x8e>
mov    -0x28(%rbp),%rdi
call   1060 <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   1040 <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   1050 <PKCS5_pbe_set0_algor@plt>
test   %rax,%rax
jne    119d <PKCS5_pbe_set+0x5d>
mov    %rbx,%rdi
call   1060 <X509_ALGOR_free@plt>
jmp    119b <PKCS5_pbe_set+0x5b>
mov    0x2e65(%rip),%rax
mov    (%rax),%edi
mov    0x2e4c(%rip),%rax
mov    (%rax),%esi
call   1030 <ASN1err@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@ASN1_F_PKCS5_PBE_SET = global i32 0
@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 %18, label %14
14: ; preds = %4
%15 = load i32, i32* @ASN1_F_PKCS5_PBE_SET
%16 = load i32, i32* @ERR_R_MALLOC_FAILURE
%17 = call i32 @ASN1err(i32 %15, i32 %16)
store i32* null, i32** %5
br label %31
18: ; preds = %4
%19 = load i32*, i32** %10
%20 = load i32, i32* %6
%21 = load i32, i32* %7
%22 = load i8*, i8** %8
%23 = load i32, i32* %9
%24 = call i64 @PKCS5_pbe_set0_algor(i32* %19, i32 %20, i32 %21, i8* %22, i32 %23)
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %18
%27 = load i32*, i32** %10
store i32* %27, i32** %5
br label %31
28: ; preds = %18
%29 = load i32*, i32** %10
%30 = call i32 @X509_ALGOR_free(i32* %29)
store i32* null, i32** %5
br label %31
31: ; preds = %28, %26, %14
%32 = load i32*, i32** %5
ret i32* %32
}

LLVM IR (-O2):
@ASN1_F_PKCS5_PBE_SET = global i32 0
@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 %11
7: ; preds = %4
%8 = load i32, i32* @ASN1_F_PKCS5_PBE_SET
%9 = load i32, i32* @ERR_R_MALLOC_FAILURE
%10 = tail call i32 @ASN1err(i32 %8, i32 %9)
br label %16
11: ; preds = %4
%12 = tail call i64 @PKCS5_pbe_set0_algor(i32* %5, i32 %0, i32 %1, i8* %2, i32 %3)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call i32 @X509_ALGOR_free(i32* %5)
br label %16
16: ; preds = %11, %14, %7
%17 = phi i32* [ null, %14 ], [ null, %7 ], [ %5, %11 ]
ret i32* %17
}