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

/* Variables and functions */
int /*<<< orphan*/ BIO_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BIO_new(int /*<<< orphan*/);
scalar_t__ BIO_read_filename(int /*<<< orphan*/ *, char const *);
int /*<<< orphan*/ BIO_s_file();
int /*<<< orphan*/ ERR_LIB_SSL;
int ERR_R_ASN1_LIB;
int ERR_R_BUF_LIB;
int ERR_R_PEM_LIB;
int ERR_R_SYS_LIB;
int /*<<< orphan*/ ERR_raise(int /*<<< orphan*/, int);
int /*<<< orphan*/ *PEM_read_bio_RSAPrivateKey(int /*<<< orphan*/ *,
                                               int /*<<< orphan*/ *,
                                               int /*<<< orphan*/,
                                               int /*<<< orphan*/);
int /*<<< orphan*/ RSA_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ SSL_CTX_get_default_passwd_cb(int /*<<< orphan*/ *);
int /*<<< orphan*/ SSL_CTX_get_default_passwd_cb_userdata(int /*<<< orphan*/ *);
int SSL_CTX_use_RSAPrivateKey(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int SSL_FILETYPE_ASN1;
int SSL_FILETYPE_PEM;
int SSL_R_BAD_SSL_FILETYPE;
int /*<<< orphan*/ *d2i_RSAPrivateKey_bio(int /*<<< orphan*/ *,
                                          int /*<<< orphan*/ *);
int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type) {
  int j, ret = 0;
  BIO *in;
  RSA *rsa = NULL;
  in = BIO_new(BIO_s_file());
  if (in == NULL) {
    ERR_raise(ERR_LIB_SSL, ERR_R_BUF_LIB);
    goto end;
  }
  if (BIO_read_filename(in, file) <= 0) {
    ERR_raise(ERR_LIB_SSL, ERR_R_SYS_LIB);
    goto end;
  }
  if (type == SSL_FILETYPE_ASN1) {
    j = ERR_R_ASN1_LIB;
    rsa = d2i_RSAPrivateKey_bio(in, NULL);
  } else if (type == SSL_FILETYPE_PEM) {
    j = ERR_R_PEM_LIB;
    rsa =
        PEM_read_bio_RSAPrivateKey(in, NULL, SSL_CTX_get_default_passwd_cb(ctx),
                                   SSL_CTX_get_default_passwd_cb_userdata(ctx));
  } else {
    ERR_raise(ERR_LIB_SSL, SSL_R_BAD_SSL_FILETYPE);
    goto end;
  }
  if (rsa == NULL) {
    ERR_raise(ERR_LIB_SSL, j);
    goto end;
  }
  ret = SSL_CTX_use_RSAPrivateKey(ctx, rsa);
  RSA_free(rsa);
end:
  BIO_free(in);
  return ret;
}


x86 assembly (clang, -O0):
<SSL_CTX_use_RSAPrivateKey_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x1c(%rbp)
movq   $0x0,-0x30(%rbp)
mov    $0x0,%al
call   10d0 <BIO_s_file@plt>
mov    %eax,%edi
call   1070 <BIO_new@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    120b <SSL_CTX_use_RSAPrivateKey_file+0x5b>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
mov    0x2df9(%rip),%rax
mov    (%rax),%esi
call   10b0 <ERR_raise@plt>
jmp    1323 <SSL_CTX_use_RSAPrivateKey_file+0x173>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   10a0 <BIO_read_filename@plt>
cmp    $0x0,%rax
jg     123e <SSL_CTX_use_RSAPrivateKey_file+0x8e>
mov    0x2da7(%rip),%rax
mov    (%rax),%edi
mov    0x2d76(%rip),%rax
mov    (%rax),%esi
call   10b0 <ERR_raise@plt>
jmp    1323 <SSL_CTX_use_RSAPrivateKey_file+0x173>
mov    -0x14(%rbp),%eax
mov    0x2d68(%rip),%rcx
cmp    (%rcx),%eax
jne    1272 <SSL_CTX_use_RSAPrivateKey_file+0xc2>
mov    0x2d69(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   10c0 <d2i_RSAPrivateKey_bio@plt>
mov    %rax,-0x30(%rbp)
jmp    12e9 <SSL_CTX_use_RSAPrivateKey_file+0x139>
mov    -0x14(%rbp),%eax
mov    0x2d4c(%rip),%rcx
cmp    (%rcx),%eax
jne    12c8 <SSL_CTX_use_RSAPrivateKey_file+0x118>
mov    0x2d5d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <SSL_CTX_get_default_passwd_cb@plt>
mov    %eax,-0x34(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <SSL_CTX_get_default_passwd_cb_userdata@plt>
mov    -0x40(%rbp),%rdi
mov    -0x34(%rbp),%edx
mov    %eax,%ecx
xor    %eax,%eax
mov    %eax,%esi
call   1060 <PEM_read_bio_RSAPrivateKey@plt>
mov    %rax,-0x30(%rbp)
jmp    12e4 <SSL_CTX_use_RSAPrivateKey_file+0x134>
mov    0x2d01(%rip),%rax
mov    (%rax),%edi
mov    0x2d00(%rip),%rax
mov    (%rax),%esi
call   10b0 <ERR_raise@plt>
jmp    1323 <SSL_CTX_use_RSAPrivateKey_file+0x173>
jmp    12e9 <SSL_CTX_use_RSAPrivateKey_file+0x139>
cmpq   $0x0,-0x30(%rbp)
jne    130a <SSL_CTX_use_RSAPrivateKey_file+0x15a>
mov    0x2cd5(%rip),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%esi
call   10b0 <ERR_raise@plt>
jmp    1323 <SSL_CTX_use_RSAPrivateKey_file+0x173>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1090 <SSL_CTX_use_RSAPrivateKey@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <RSA_free@plt>
mov    -0x28(%rbp),%rdi
call   1080 <BIO_free@plt>
mov    -0x1c(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SSL_CTX_use_RSAPrivateKey_file>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r12d
mov    %rsi,%rbx
mov    %rdi,%r14
xor    %ebp,%ebp
xor    %eax,%eax
call   10d0 <BIO_s_file@plt>
mov    %eax,%edi
call   1070 <BIO_new@plt>
mov    %rax,%r15
test   %rax,%rax
je     120a <SSL_CTX_use_RSAPrivateKey_file+0x5a>
mov    %r15,%rdi
mov    %rbx,%rsi
call   10a0 <BIO_read_filename@plt>
test   %rax,%rax
jle    1226 <SSL_CTX_use_RSAPrivateKey_file+0x76>
mov    0x2dc0(%rip),%rax
cmp    %r12d,(%rax)
jne    1238 <SSL_CTX_use_RSAPrivateKey_file+0x88>
mov    0x2dc4(%rip),%rax
mov    (%rax),%ebp
mov    %r15,%rdi
xor    %esi,%esi
call   10c0 <d2i_RSAPrivateKey_bio@plt>
jmp    126d <SSL_CTX_use_RSAPrivateKey_file+0xbd>
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
mov    0x2dde(%rip),%rax
mov    (%rax),%esi
call   10b0 <ERR_raise@plt>
jmp    12b2 <SSL_CTX_use_RSAPrivateKey_file+0x102>
mov    0x2da3(%rip),%rax
mov    (%rax),%edi
mov    0x2d72(%rip),%rax
jmp    12a9 <SSL_CTX_use_RSAPrivateKey_file+0xf9>
mov    0x2d89(%rip),%rax
cmp    %r12d,(%rax)
jne    1299 <SSL_CTX_use_RSAPrivateKey_file+0xe9>
mov    0x2d9d(%rip),%rax
mov    (%rax),%ebp
mov    %r14,%rdi
call   1030 <SSL_CTX_get_default_passwd_cb@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1050 <SSL_CTX_get_default_passwd_cb_userdata@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    %ebx,%edx
mov    %eax,%ecx
call   1060 <PEM_read_bio_RSAPrivateKey@plt>
mov    %rax,%rbx
test   %rax,%rax
je     128c <SSL_CTX_use_RSAPrivateKey_file+0xdc>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1090 <SSL_CTX_use_RSAPrivateKey@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1040 <RSA_free@plt>
jmp    12b2 <SSL_CTX_use_RSAPrivateKey_file+0x102>
mov    0x2d3d(%rip),%rax
mov    (%rax),%edi
mov    %ebp,%esi
jmp    12ab <SSL_CTX_use_RSAPrivateKey_file+0xfb>
mov    0x2d30(%rip),%rax
mov    (%rax),%edi
mov    0x2d2f(%rip),%rax
mov    (%rax),%esi
call   10b0 <ERR_raise@plt>
xor    %ebp,%ebp
mov    %r15,%rdi
call   1080 <BIO_free@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@ERR_LIB_SSL = global i32 0
@ERR_R_BUF_LIB = global i32 0
@ERR_R_SYS_LIB = global i32 0
@SSL_FILETYPE_ASN1 = global i32 0
@ERR_R_ASN1_LIB = global i32 0
@SSL_FILETYPE_PEM = global i32 0
@ERR_R_PEM_LIB = global i32 0
@SSL_R_BAD_SSL_FILETYPE = global i32 0
define i32 @SSL_CTX_use_RSAPrivateKey_file(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32*
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 0, i32* %8
store i32* null, i32** %10
%11 = call i32 (...) @BIO_s_file()
%12 = call i32* @BIO_new(i32 %11)
store i32* %12, i32** %9
%13 = load i32*, i32** %9
%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_BUF_LIB
%18 = call i32 @ERR_raise(i32 %16, i32 %17)
br label %66
19: ; preds = %3
%20 = load i32*, i32** %9
%21 = load i8*, i8** %5
%22 = call i64 @BIO_read_filename(i32* %20, i8* %21)
%23 = icmp sle i64 %22, 0
br i1 %23, label %24, label %28
24: ; preds = %19
%25 = load i32, i32* @ERR_LIB_SSL
%26 = load i32, i32* @ERR_R_SYS_LIB
%27 = call i32 @ERR_raise(i32 %25, i32 %26)
br label %66
28: ; preds = %19
%29 = load i32, i32* %6
%30 = load i32, i32* @SSL_FILETYPE_ASN1
%31 = icmp eq i32 %29, %30
br i1 %31, label %32, label %36
32: ; preds = %28
%33 = load i32, i32* @ERR_R_ASN1_LIB
store i32 %33, i32* %7
%34 = load i32*, i32** %9
%35 = call i32* @d2i_RSAPrivateKey_bio(i32* %34, i32* null)
store i32* %35, i32** %10
br label %53
36: ; preds = %28
%37 = load i32, i32* %6
%38 = load i32, i32* @SSL_FILETYPE_PEM
%39 = icmp eq i32 %37, %38
br i1 %39, label %40, label %48
40: ; preds = %36
%41 = load i32, i32* @ERR_R_PEM_LIB
store i32 %41, i32* %7
%42 = load i32*, i32** %9
%43 = load i32*, i32** %4
%44 = call i32 @SSL_CTX_get_default_passwd_cb(i32* %43)
%45 = load i32*, i32** %4
%46 = call i32 @SSL_CTX_get_default_passwd_cb_userdata(i32* %45)
%47 = call i32* @PEM_read_bio_RSAPrivateKey(i32* %42, i32* null, i32 %44, i32 %46)
store i32* %47, i32** %10
br label %52
48: ; preds = %36
%49 = load i32, i32* @ERR_LIB_SSL
%50 = load i32, i32* @SSL_R_BAD_SSL_FILETYPE
%51 = call i32 @ERR_raise(i32 %49, i32 %50)
br label %66
52: ; preds = %40
br label %53
53: ; preds = %52, %32
%54 = load i32*, i32** %10
%55 = icmp eq i32* %54, null
br i1 %55, label %56, label %60
56: ; preds = %53
%57 = load i32, i32* @ERR_LIB_SSL
%58 = load i32, i32* %7
%59 = call i32 @ERR_raise(i32 %57, i32 %58)
br label %66
60: ; preds = %53
%61 = load i32*, i32** %4
%62 = load i32*, i32** %10
%63 = call i32 @SSL_CTX_use_RSAPrivateKey(i32* %61, i32* %62)
store i32 %63, i32* %8
%64 = load i32*, i32** %10
%65 = call i32 @RSA_free(i32* %64)
br label %66
66: ; preds = %60, %56, %48, %24, %15
%67 = load i32*, i32** %9
%68 = call i32 @BIO_free(i32* %67)
%69 = load i32, i32* %8
ret i32 %69
}

LLVM IR (-O2):
@ERR_LIB_SSL = global i32 0
@ERR_R_BUF_LIB = global i32 0
@ERR_R_SYS_LIB = global i32 0
@SSL_FILETYPE_ASN1 = global i32 0
@ERR_R_ASN1_LIB = global i32 0
@SSL_FILETYPE_PEM = global i32 0
@ERR_R_PEM_LIB = global i32 0
@SSL_R_BAD_SSL_FILETYPE = global i32 0
define i32 @SSL_CTX_use_RSAPrivateKey_file(i32* %0, i8* %1, i32 %2) {
%4 = tail call i32 (...) @BIO_s_file()
%5 = tail call i32* @BIO_new(i32 %4)
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %11
7: ; preds = %3
%8 = load i32, i32* @ERR_LIB_SSL
%9 = load i32, i32* @ERR_R_BUF_LIB
%10 = tail call i32 @ERR_raise(i32 %8, i32 %9)
br label %46
11: ; preds = %3
%12 = tail call i64 @BIO_read_filename(i32* %5, i8* %1)
%13 = icmp slt i64 %12, 1
br i1 %13, label %14, label %18
14: ; preds = %11
%15 = load i32, i32* @ERR_LIB_SSL
%16 = load i32, i32* @ERR_R_SYS_LIB
%17 = tail call i32 @ERR_raise(i32 %15, i32 %16)
br label %46
18: ; preds = %11
%19 = load i32, i32* @SSL_FILETYPE_ASN1
%20 = icmp eq i32 %19, %2
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i32, i32* @ERR_R_ASN1_LIB
%23 = tail call i32* @d2i_RSAPrivateKey_bio(i32* %5, i32* null)
br label %36
24: ; preds = %18
%25 = load i32, i32* @SSL_FILETYPE_PEM
%26 = icmp eq i32 %25, %2
br i1 %26, label %27, label %32
27: ; preds = %24
%28 = load i32, i32* @ERR_R_PEM_LIB
%29 = tail call i32 @SSL_CTX_get_default_passwd_cb(i32* %0)
%30 = tail call i32 @SSL_CTX_get_default_passwd_cb_userdata(i32* %0)
%31 = tail call i32* @PEM_read_bio_RSAPrivateKey(i32* %5, i32* null, i32 %29, i32 %30)
br label %36
32: ; preds = %24
%33 = load i32, i32* @ERR_LIB_SSL
%34 = load i32, i32* @SSL_R_BAD_SSL_FILETYPE
%35 = tail call i32 @ERR_raise(i32 %33, i32 %34)
br label %46
36: ; preds = %27, %21
%37 = phi i32 [ %22, %21 ], [ %28, %27 ]
%38 = phi i32* [ %23, %21 ], [ %31, %27 ]
%39 = icmp eq i32* %38, null
br i1 %39, label %40, label %43
40: ; preds = %36
%41 = load i32, i32* @ERR_LIB_SSL
%42 = tail call i32 @ERR_raise(i32 %41, i32 %37)
br label %46
43: ; preds = %36
%44 = tail call i32 @SSL_CTX_use_RSAPrivateKey(i32* %0, i32* %38)
%45 = tail call i32 @RSA_free(i32* %38)
br label %46
46: ; preds = %43, %40, %32, %14, %7
%47 = phi i32 [ 0, %7 ], [ 0, %14 ], [ 0, %40 ], [ %44, %43 ], [ 0, %32 ]
%48 = tail call i32 @BIO_free(i32* %5)
ret i32 %47
}