#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*/ EVP_PBE_KEYGEN;
typedef int /*<<< orphan*/ EVP_MD;
typedef int /*<<< orphan*/ EVP_CIPHER;

/* Variables and functions */
int EVP_CIPHER_type(int /*<<< orphan*/ const *);
int EVP_MD_type(int /*<<< orphan*/ const *);
int /*<<< orphan*/ EVP_PBE_TYPE_OUTER;
int EVP_PBE_alg_add_type(int /*<<< orphan*/, int, int, int,
                         int /*<<< orphan*/ *);
int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md,
                    EVP_PBE_KEYGEN *keygen) {
  int cipher_nid, md_nid;
  if (cipher)
    cipher_nid = EVP_CIPHER_type(cipher);
  else
    cipher_nid = -1;
  if (md)
    md_nid = EVP_MD_type(md);
  else
    md_nid = -1;
  return EVP_PBE_alg_add_type(EVP_PBE_TYPE_OUTER, nid, cipher_nid, md_nid,
                              keygen);
}


x86 assembly (clang, -O0):
<EVP_PBE_alg_add>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1163 <EVP_PBE_alg_add+0x33>
mov    -0x10(%rbp),%rdi
call   1030 <EVP_CIPHER_type@plt>
mov    %eax,-0x24(%rbp)
jmp    116a <EVP_PBE_alg_add+0x3a>
movl   $0xffffffff,-0x24(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1186 <EVP_PBE_alg_add+0x56>
mov    -0x18(%rbp),%rdi
call   1050 <EVP_MD_type@plt>
mov    %eax,-0x28(%rbp)
jmp    118d <EVP_PBE_alg_add+0x5d>
movl   $0xffffffff,-0x28(%rbp)
mov    0x2e64(%rip),%rax
mov    (%rax),%edi
mov    -0x4(%rbp),%esi
mov    -0x24(%rbp),%edx
mov    -0x28(%rbp),%ecx
mov    -0x20(%rbp),%r8
call   1040 <EVP_PBE_alg_add_type@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<EVP_PBE_alg_add>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %rdx,%rbx
mov    %edi,%r15d
mov    $0xffffffff,%r12d
mov    $0xffffffff,%ebp
test   %rsi,%rsi
je     115b <EVP_PBE_alg_add+0x2b>
mov    %rsi,%rdi
call   1030 <EVP_CIPHER_type@plt>
mov    %eax,%ebp
test   %rbx,%rbx
je     116b <EVP_PBE_alg_add+0x3b>
mov    %rbx,%rdi
call   1050 <EVP_MD_type@plt>
mov    %eax,%r12d
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
mov    %r15d,%esi
mov    %ebp,%edx
mov    %r12d,%ecx
mov    %r14,%r8
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <EVP_PBE_alg_add_type@plt>

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

LLVM IR (-O2):
@EVP_PBE_TYPE_OUTER = global i32 0
define i32 @EVP_PBE_alg_add(i32 %0, i32* %1, i32* %2, i32* %3) {
%5 = icmp eq i32* %1, null
br i1 %5, label %8, label %6
6: ; preds = %4
%7 = tail call i32 @EVP_CIPHER_type(i32* %1)
br label %8
8: ; preds = %4, %6
%9 = phi i32 [ %7, %6 ], [ -1, %4 ]
%10 = icmp eq i32* %2, null
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = tail call i32 @EVP_MD_type(i32* %2)
br label %13
13: ; preds = %8, %11
%14 = phi i32 [ %12, %11 ], [ -1, %8 ]
%15 = load i32, i32* @EVP_PBE_TYPE_OUTER
%16 = tail call i32 @EVP_PBE_alg_add_type(i32 %15, i32 %0, i32 %9, i32 %14, i32* %3)
ret i32 %16
}