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

/* Variables and functions */
int /*<<< orphan*/ ERR_print_errors_fp(int /*<<< orphan*/);
int /*<<< orphan*/ SSL_CTX_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *SSL_CTX_new(int /*<<< orphan*/ const *);
scalar_t__ SSL_CTX_use_PrivateKey_file(int /*<<< orphan*/ *, char const *,
                                       int /*<<< orphan*/);
scalar_t__ SSL_CTX_use_certificate_file(int /*<<< orphan*/ *, char const *,
                                        int /*<<< orphan*/);
int /*<<< orphan*/ SSL_FILETYPE_PEM;
int /*<<< orphan*/ *SSLv23_server_method();
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
SSL_CTX *ssl_servctx_init(const char *certpem, const char *keypem) {
  const SSL_METHOD *method;
  SSL_CTX *ctx;
  method = SSLv23_server_method();
  ctx = SSL_CTX_new(method);
  if (!ctx) {
    perror("Unable to create SSL context");
    ERR_print_errors_fp(stderr);
    return NULL;
  }
  if (SSL_CTX_use_certificate_file(ctx, certpem, SSL_FILETYPE_PEM) < 0) {
    ERR_print_errors_fp(stderr);
    SSL_CTX_free(ctx);
    return NULL;
  }
  if (SSL_CTX_use_PrivateKey_file(ctx, keypem, SSL_FILETYPE_PEM) < 0) {
    ERR_print_errors_fp(stderr);
    SSL_CTX_free(ctx);
    return NULL;
  }
  return ctx;
}


x86 assembly (clang, -O0):
<ssl_servctx_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    $0x0,%al
call   1030 <SSLv23_server_method@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <SSL_CTX_new@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    11ca <ssl_servctx_init+0x5a>
lea    0xe56(%rip),%rdi
call   1080 <perror@plt>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
call   1090 <ERR_print_errors_fp@plt>
movq   $0x0,-0x8(%rbp)
jmp    125a <ssl_servctx_init+0xea>
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x2e0f(%rip),%rax
mov    (%rax),%edx
call   1040 <SSL_CTX_use_certificate_file@plt>
cmp    $0x0,%rax
jge    120e <ssl_servctx_init+0x9e>
mov    0x2de7(%rip),%rax
mov    (%rax),%edi
call   1090 <ERR_print_errors_fp@plt>
mov    -0x28(%rbp),%rdi
call   1070 <SSL_CTX_free@plt>
movq   $0x0,-0x8(%rbp)
jmp    125a <ssl_servctx_init+0xea>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2dcb(%rip),%rax
mov    (%rax),%edx
call   1060 <SSL_CTX_use_PrivateKey_file@plt>
cmp    $0x0,%rax
jge    1252 <ssl_servctx_init+0xe2>
mov    0x2da3(%rip),%rax
mov    (%rax),%edi
call   1090 <ERR_print_errors_fp@plt>
mov    -0x28(%rbp),%rdi
call   1070 <SSL_CTX_free@plt>
movq   $0x0,-0x8(%rbp)
jmp    125a <ssl_servctx_init+0xea>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ssl_servctx_init>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
xor    %eax,%eax
call   1030 <SSLv23_server_method@plt>
mov    %rax,%rdi
call   1050 <SSL_CTX_new@plt>
test   %rax,%rax
je     11eb <ssl_servctx_init+0x7b>
mov    %rax,%rbx
mov    0x2e4c(%rip),%r12
mov    (%r12),%edx
mov    %rax,%rdi
mov    %r15,%rsi
call   1040 <SSL_CTX_use_certificate_file@plt>
test   %rax,%rax
js     11c4 <ssl_servctx_init+0x54>
mov    (%r12),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <SSL_CTX_use_PrivateKey_file@plt>
test   %rax,%rax
jns    11dc <ssl_servctx_init+0x6c>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
call   1090 <ERR_print_errors_fp@plt>
mov    %rbx,%rdi
call   1070 <SSL_CTX_free@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xe0e(%rip),%rdi
call   1080 <perror@plt>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
call   1090 <ERR_print_errors_fp@plt>
jmp    11da <ssl_servctx_init+0x6a>

LLVM IR (-O0):
@.str = [29 x i8] c"Unable to create SSL context\00"
@stderr = global i32 0
@SSL_FILETYPE_PEM = global i32 0
define i32* @ssl_servctx_init(i8* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
%8 = call i32* (...) @SSLv23_server_method()
store i32* %8, i32** %6
%9 = load i32*, i32** %6
%10 = call i32* @SSL_CTX_new(i32* %9)
store i32* %10, i32** %7
%11 = load i32*, i32** %7
%12 = icmp ne i32* %11, null
br i1 %12, label %17, label %13
13: ; preds = %2
%14 = call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%15 = load i32, i32* @stderr
%16 = call i32 @ERR_print_errors_fp(i32 %15)
store i32* null, i32** %3
br label %41
17: ; preds = %2
%18 = load i32*, i32** %7
%19 = load i8*, i8** %4
%20 = load i32, i32* @SSL_FILETYPE_PEM
%21 = call i64 @SSL_CTX_use_certificate_file(i32* %18, i8* %19, i32 %20)
%22 = icmp slt i64 %21, 0
br i1 %22, label %23, label %28
23: ; preds = %17
%24 = load i32, i32* @stderr
%25 = call i32 @ERR_print_errors_fp(i32 %24)
%26 = load i32*, i32** %7
%27 = call i32 @SSL_CTX_free(i32* %26)
store i32* null, i32** %3
br label %41
28: ; preds = %17
%29 = load i32*, i32** %7
%30 = load i8*, i8** %5
%31 = load i32, i32* @SSL_FILETYPE_PEM
%32 = call i64 @SSL_CTX_use_PrivateKey_file(i32* %29, i8* %30, i32 %31)
%33 = icmp slt i64 %32, 0
br i1 %33, label %34, label %39
34: ; preds = %28
%35 = load i32, i32* @stderr
%36 = call i32 @ERR_print_errors_fp(i32 %35)
%37 = load i32*, i32** %7
%38 = call i32 @SSL_CTX_free(i32* %37)
store i32* null, i32** %3
br label %41
39: ; preds = %28
%40 = load i32*, i32** %7
store i32* %40, i32** %3
br label %41
41: ; preds = %39, %34, %23, %13
%42 = load i32*, i32** %3
ret i32* %42
}

LLVM IR (-O2):
@.str = [29 x i8] c"Unable to create SSL context\00"
@stderr = global i32 0
@SSL_FILETYPE_PEM = global i32 0
define i32* @ssl_servctx_init(i8* %0, i8* %1) {
%3 = tail call i32* (...) @SSLv23_server_method()
%4 = tail call i32* @SSL_CTX_new(i32* %3)
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = tail call i32 @perror(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @stderr
%9 = tail call i32 @ERR_print_errors_fp(i32 %8)
br label %26
10: ; preds = %2
%11 = load i32, i32* @SSL_FILETYPE_PEM
%12 = tail call i64 @SSL_CTX_use_certificate_file(i32* %4, i8* %0, i32 %11)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %18
14: ; preds = %10
%15 = load i32, i32* @stderr
%16 = tail call i32 @ERR_print_errors_fp(i32 %15)
%17 = tail call i32 @SSL_CTX_free(i32* %4)
br label %26
18: ; preds = %10
%19 = load i32, i32* @SSL_FILETYPE_PEM
%20 = tail call i64 @SSL_CTX_use_PrivateKey_file(i32* %4, i8* %1, i32 %19)
%21 = icmp slt i64 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %18
%23 = load i32, i32* @stderr
%24 = tail call i32 @ERR_print_errors_fp(i32 %23)
%25 = tail call i32 @SSL_CTX_free(i32* %4)
br label %26
26: ; preds = %18, %22, %14, %6
%27 = phi i32* [ null, %14 ], [ null, %22 ], [ null, %6 ], [ %4, %18 ]
ret i32* %27
}