#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;

/* Variables and functions */
int /*<<< orphan*/ ERR_print_errors_fp(int /*<<< orphan*/);
int /*<<< orphan*/ SSL_CTX_check_private_key(int /*<<< orphan*/ *);
scalar_t__ SSL_CTX_use_PrivateKey_file(int /*<<< orphan*/ *, char *,
                                       int /*<<< orphan*/);
scalar_t__ SSL_CTX_use_certificate_file(int /*<<< orphan*/ *, char *,
                                        int /*<<< orphan*/);
int /*<<< orphan*/ SSL_FILETYPE_PEM;
int /*<<< orphan*/ abort();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
void LoadCertificates(SSL_CTX *ctx, char *CertFile, char *KeyFile) {
  if (SSL_CTX_use_certificate_file(ctx, CertFile, SSL_FILETYPE_PEM) <= 0) {
    ERR_print_errors_fp(stderr);
    abort();
  }
  if (SSL_CTX_use_PrivateKey_file(ctx, KeyFile, SSL_FILETYPE_PEM) <= 0) {
    ERR_print_errors_fp(stderr);
    abort();
  }
  if (!SSL_CTX_check_private_key(ctx)) {
    fprintf(stderr, "Private key does not match the public certificate\n");
    abort();
  }
}


x86 assembly (clang, -O0):
<LoadCertificates>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    0x2e65(%rip),%rax
mov    (%rax),%edx
call   1040 <SSL_CTX_use_certificate_file@plt>
cmp    $0x0,%rax
jg     11a9 <LoadCertificates+0x49>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
call   1080 <ERR_print_errors_fp@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2e30(%rip),%rax
mov    (%rax),%edx
call   1060 <SSL_CTX_use_PrivateKey_file@plt>
cmp    $0x0,%rax
jg     11de <LoadCertificates+0x7e>
mov    0x2e08(%rip),%rax
mov    (%rax),%edi
call   1080 <ERR_print_errors_fp@plt>
mov    $0x0,%al
call   1030 <abort@plt>
mov    -0x8(%rbp),%rdi
call   1070 <SSL_CTX_check_private_key@plt>
cmp    $0x0,%eax
jne    120c <LoadCertificates+0xac>
mov    0x2de1(%rip),%rax
mov    (%rax),%edi
lea    0xe00(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LoadCertificates>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rdi,%rbx
mov    0x2e76(%rip),%r15
mov    (%r15),%edx
call   1040 <SSL_CTX_use_certificate_file@plt>
test   %rax,%rax
jle    11a4 <LoadCertificates+0x44>
mov    (%r15),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <SSL_CTX_use_PrivateKey_file@plt>
test   %rax,%rax
jle    11a4 <LoadCertificates+0x44>
mov    %rbx,%rdi
call   1070 <SSL_CTX_check_private_key@plt>
test   %eax,%eax
je     11b9 <LoadCertificates+0x59>
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2e2d(%rip),%rax
mov    (%rax),%edi
call   1080 <ERR_print_errors_fp@plt>
xor    %eax,%eax
call   1030 <abort@plt>
mov    0x2e18(%rip),%rax
mov    (%rax),%edi
lea    0xe37(%rip),%rsi
call   1050 <fprintf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@SSL_FILETYPE_PEM = global i32 0
@stderr = global i32 0
@.str = [51 x i8] c"Private key does not match the public certificate\0A\00"
define void @LoadCertificates(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
store i32* %0, i32** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%7 = load i32*, i32** %4
%8 = load i8*, i8** %5
%9 = load i32, i32* @SSL_FILETYPE_PEM
%10 = call i64 @SSL_CTX_use_certificate_file(i32* %7, i8* %8, i32 %9)
%11 = icmp sle i64 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %3
%13 = load i32, i32* @stderr
%14 = call i32 @ERR_print_errors_fp(i32 %13)
%15 = call i32 (...) @abort()
unreachable
16: ; preds = %3
%17 = load i32*, i32** %4
%18 = load i8*, i8** %6
%19 = load i32, i32* @SSL_FILETYPE_PEM
%20 = call i64 @SSL_CTX_use_PrivateKey_file(i32* %17, i8* %18, i32 %19)
%21 = icmp sle i64 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %16
%23 = load i32, i32* @stderr
%24 = call i32 @ERR_print_errors_fp(i32 %23)
%25 = call i32 (...) @abort()
unreachable
26: ; preds = %16
%27 = load i32*, i32** %4
%28 = call i32 @SSL_CTX_check_private_key(i32* %27)
%29 = icmp ne i32 %28, 0
br i1 %29, label %34, label %30
30: ; preds = %26
%31 = load i32, i32* @stderr
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%33 = call i32 (...) @abort()
unreachable
34: ; preds = %26
ret void
}

LLVM IR (-O2):
@SSL_FILETYPE_PEM = global i32 0
@stderr = global i32 0
@.str = [51 x i8] c"Private key does not match the public certificate\0A\00"
define void @LoadCertificates(i32* %0, i8* %1, i8* %2) {
%4 = load i32, i32* @SSL_FILETYPE_PEM
%5 = tail call i64 @SSL_CTX_use_certificate_file(i32* %0, i8* %1, i32 %4)
%6 = icmp slt i64 %5, 1
br i1 %6, label %7, label %11
7: ; preds = %3
%8 = load i32, i32* @stderr
%9 = tail call i32 @ERR_print_errors_fp(i32 %8)
%10 = tail call i32 (...) @abort()
unreachable
11: ; preds = %3
%12 = load i32, i32* @SSL_FILETYPE_PEM
%13 = tail call i64 @SSL_CTX_use_PrivateKey_file(i32* %0, i8* %2, i32 %12)
%14 = icmp slt i64 %13, 1
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = load i32, i32* @stderr
%17 = tail call i32 @ERR_print_errors_fp(i32 %16)
%18 = tail call i32 (...) @abort()
unreachable
19: ; preds = %11
%20 = tail call i32 @SSL_CTX_check_private_key(i32* %0)
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %26
22: ; preds = %19
%23 = load i32, i32* @stderr
%24 = tail call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%25 = tail call i32 (...) @abort()
unreachable
26: ; preds = %19
ret void
}