#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_PKEY;
typedef int /*<<< orphan*/ DSA;

/* Variables and functions */
int /*<<< orphan*/ DSA_F_OLD_DSA_PRIV_DECODE;
int /*<<< orphan*/ DSAerr(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ ERR_R_DSA_LIB;
int /*<<< orphan*/ EVP_PKEY_assign_DSA(int /*<<< orphan*/ *,
                                       int /*<<< orphan*/ *);
int /*<<< orphan*/ *d2i_DSAPrivateKey(int /*<<< orphan*/ *,
                                      unsigned char const **, int);
int old_dsa_priv_decode(EVP_PKEY *pkey, const unsigned char **pder,
                        int derlen) {
  DSA *dsa;
  if (!(dsa = d2i_DSAPrivateKey(NULL, pder, derlen))) {
    DSAerr(DSA_F_OLD_DSA_PRIV_DECODE, ERR_R_DSA_LIB);
    return 0;
  }
  EVP_PKEY_assign_DSA(pkey, dsa);
  return 1;
}


x86 assembly (clang, -O0):
<old_dsa_priv_decode>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%rsi
mov    -0x1c(%rbp),%edx
xor    %eax,%eax
mov    %eax,%edi
call   1030 <d2i_DSAPrivateKey@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    1184 <old_dsa_priv_decode+0x54>
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
mov    0x2e67(%rip),%rax
mov    (%rax),%esi
call   1050 <DSAerr@plt>
movl   $0x0,-0x4(%rbp)
jmp    1198 <old_dsa_priv_decode+0x68>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1040 <EVP_PKEY_assign_DSA@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<old_dsa_priv_decode>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %ebx,%ebx
xor    %edi,%edi
call   1030 <d2i_DSAPrivateKey@plt>
test   %rax,%rax
je     1157 <old_dsa_priv_decode+0x27>
mov    %r14,%rdi
mov    %rax,%rsi
call   1040 <EVP_PKEY_assign_DSA@plt>
mov    $0x1,%ebx
jmp    116e <old_dsa_priv_decode+0x3e>
mov    0x2e8a(%rip),%rax
mov    (%rax),%edi
mov    0x2e71(%rip),%rax
mov    (%rax),%esi
call   1050 <DSAerr@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@DSA_F_OLD_DSA_PRIV_DECODE = global i32 0
@ERR_R_DSA_LIB = global i32 0
define i32 @old_dsa_priv_decode(i32* %0, i8** %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8**
%7 = alloca i32
%8 = alloca i32*
store i32* %0, i32** %5
store i8** %1, i8*** %6
store i32 %2, i32* %7
%9 = load i8**, i8*** %6
%10 = load i32, i32* %7
%11 = call i32* @d2i_DSAPrivateKey(i32* null, i8** %9, i32 %10)
store i32* %11, i32** %8
%12 = icmp ne i32* %11, null
br i1 %12, label %17, label %13
13: ; preds = %3
%14 = load i32, i32* @DSA_F_OLD_DSA_PRIV_DECODE
%15 = load i32, i32* @ERR_R_DSA_LIB
%16 = call i32 @DSAerr(i32 %14, i32 %15)
store i32 0, i32* %4
br label %21
17: ; preds = %3
%18 = load i32*, i32** %5
%19 = load i32*, i32** %8
%20 = call i32 @EVP_PKEY_assign_DSA(i32* %18, i32* %19)
store i32 1, i32* %4
br label %21
21: ; preds = %17, %13
%22 = load i32, i32* %4
ret i32 %22
}

LLVM IR (-O2):
@DSA_F_OLD_DSA_PRIV_DECODE = global i32 0
@ERR_R_DSA_LIB = global i32 0
define i32 @old_dsa_priv_decode(i32* %0, i8** %1, i32 %2) {
%4 = tail call i32* @d2i_DSAPrivateKey(i32* null, i8** %1, i32 %2)
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = load i32, i32* @DSA_F_OLD_DSA_PRIV_DECODE
%8 = load i32, i32* @ERR_R_DSA_LIB
%9 = tail call i32 @DSAerr(i32 %7, i32 %8)
br label %12
10: ; preds = %3
%11 = tail call i32 @EVP_PKEY_assign_DSA(i32* %0, i32* %4)
br label %12
12: ; preds = %10, %6
%13 = phi i32 [ 1, %10 ], [ 0, %6 ]
ret i32 %13
}