#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*/ SSL_CTX;
typedef int /*<<< orphan*/ RSA;

/* Variables and functions */
int /*<<< orphan*/ ERR_LIB_SSL;
int /*<<< orphan*/ ERR_R_ASN1_LIB;
int /*<<< orphan*/ ERR_raise(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ RSA_free(int /*<<< orphan*/ *);
int SSL_CTX_use_RSAPrivateKey(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *d2i_RSAPrivateKey(int /*<<< orphan*/ *,
                                      unsigned char const **, long);
int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const unsigned char *d,
                                   long len) {
  int ret;
  const unsigned char *p;
  RSA *rsa;
  p = d;
  if ((rsa = d2i_RSAPrivateKey(NULL, &p, (long)len)) == NULL) {
    ERR_raise(ERR_LIB_SSL, ERR_R_ASN1_LIB);
    return 0;
  }
  ret = SSL_CTX_use_RSAPrivateKey(ctx, rsa);
  RSA_free(rsa);
  return ret;
}


x86 assembly (clang, -O0):
<SSL_CTX_use_RSAPrivateKey_ASN1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%edi
lea    -0x30(%rbp),%rsi
call   1040 <d2i_RSAPrivateKey@plt>
mov    %rax,-0x38(%rbp)
cmp    $0x0,%rax
jne    119e <SSL_CTX_use_RSAPrivateKey_ASN1+0x5e>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
mov    0x2e55(%rip),%rax
mov    (%rax),%esi
call   1060 <ERR_raise@plt>
movl   $0x0,-0x4(%rbp)
jmp    11bd <SSL_CTX_use_RSAPrivateKey_ASN1+0x7d>
mov    -0x10(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1050 <SSL_CTX_use_RSAPrivateKey@plt>
mov    %eax,-0x24(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <RSA_free@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SSL_CTX_use_RSAPrivateKey_ASN1>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%r14
mov    %rsi,0x8(%rsp)
xor    %r15d,%r15d
lea    0x8(%rsp),%rsi
xor    %edi,%edi
call   1040 <d2i_RSAPrivateKey@plt>
test   %rax,%rax
je     1180 <SSL_CTX_use_RSAPrivateKey_ASN1+0x40>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <SSL_CTX_use_RSAPrivateKey@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1030 <RSA_free@plt>
jmp    1197 <SSL_CTX_use_RSAPrivateKey_ASN1+0x57>
mov    0x2e61(%rip),%rax
mov    (%rax),%edi
mov    0x2e50(%rip),%rax
mov    (%rax),%esi
call   1060 <ERR_raise@plt>
mov    %r15d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@ERR_LIB_SSL = global i32 0
@ERR_R_ASN1_LIB = global i32 0
define i32 @SSL_CTX_use_RSAPrivateKey_ASN1(i32* %0, i8* %1, i64 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32*
store i32* %0, i32** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
%11 = load i8*, i8** %6
store i8* %11, i8** %9
%12 = load i64, i64* %7
%13 = call i32* @d2i_RSAPrivateKey(i32* null, i8** %9, i64 %12)
store i32* %13, i32** %10
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %19
15: ; preds = %3
%16 = load i32, i32* @ERR_LIB_SSL
%17 = load i32, i32* @ERR_R_ASN1_LIB
%18 = call i32 @ERR_raise(i32 %16, i32 %17)
store i32 0, i32* %4
br label %26
19: ; preds = %3
%20 = load i32*, i32** %5
%21 = load i32*, i32** %10
%22 = call i32 @SSL_CTX_use_RSAPrivateKey(i32* %20, i32* %21)
store i32 %22, i32* %8
%23 = load i32*, i32** %10
%24 = call i32 @RSA_free(i32* %23)
%25 = load i32, i32* %8
store i32 %25, i32* %4
br label %26
26: ; preds = %19, %15
%27 = load i32, i32* %4
ret i32 %27
}

LLVM IR (-O2):
@ERR_LIB_SSL = global i32 0
@ERR_R_ASN1_LIB = global i32 0
define i32 @SSL_CTX_use_RSAPrivateKey_ASN1(i32* %0, i8* %1, i64 %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
store i8* %1, i8** %4
%6 = call i32* @d2i_RSAPrivateKey(i32* null, i8** %4, i64 %2)
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %12
8: ; preds = %3
%9 = load i32, i32* @ERR_LIB_SSL
%10 = load i32, i32* @ERR_R_ASN1_LIB
%11 = call i32 @ERR_raise(i32 %9, i32 %10)
br label %15
12: ; preds = %3
%13 = call i32 @SSL_CTX_use_RSAPrivateKey(i32* %0, i32* %6)
%14 = call i32 @RSA_free(i32* %6)
br label %15
15: ; preds = %12, %8
%16 = phi i32 [ 0, %8 ], [ %13, %12 ]
ret i32 %16
}