#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*/ *);
int SSL_CTX_use_PrivateKey_file(int /*<<< orphan*/ *, char const *,
                                int /*<<< orphan*/);
int SSL_CTX_use_certificate_file(int /*<<< orphan*/ *, char const *,
                                 int /*<<< orphan*/);
int /*<<< orphan*/ SSL_FILETYPE_PEM;
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
void loadCerts(SSL_CTX *ctx, const char *cert_file, const char *key_file) {
  if (SSL_CTX_use_certificate_file(ctx, cert_file, SSL_FILETYPE_PEM) != 1) {
    perror("SSL_CTX_use_certificate_file() error\n");
    ERR_print_errors_fp(stderr);
  }
  if (SSL_CTX_use_PrivateKey_file(ctx, key_file, SSL_FILETYPE_PEM) != 1) {
    perror("SSL_CTX_use_PrivateKey_file() error\n");
    ERR_print_errors_fp(stderr);
  }
  if (!SSL_CTX_check_private_key(ctx)) {
    printf("Private key does not match the public certificate\n");
    ERR_print_errors_fp(stderr);
  }
}


x86 assembly (clang, -O0):
<loadCerts>:
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    $0x1,%eax
je     11ad <loadCerts+0x4d>
lea    0xe66(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
call   1080 <ERR_print_errors_fp@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2e2c(%rip),%rax
mov    (%rax),%edx
call   1050 <SSL_CTX_use_PrivateKey_file@plt>
cmp    $0x1,%eax
je     11e6 <loadCerts+0x86>
lea    0xe53(%rip),%rdi
call   1060 <perror@plt>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
call   1080 <ERR_print_errors_fp@plt>
mov    -0x8(%rbp),%rdi
call   1070 <SSL_CTX_check_private_key@plt>
cmp    $0x0,%eax
jne    1212 <loadCerts+0xb2>
lea    0xe4c(%rip),%rdi
call   1030 <printf@plt>
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
call   1080 <ERR_print_errors_fp@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<loadCerts>:
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>
cmp    $0x1,%eax
jne    11c3 <loadCerts+0x63>
mov    (%r15),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <SSL_CTX_use_PrivateKey_file@plt>
cmp    $0x1,%eax
jne    11df <loadCerts+0x7f>
mov    %rbx,%rdi
call   1070 <SSL_CTX_check_private_key@plt>
test   %eax,%eax
je     11a4 <loadCerts+0x44>
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xea0(%rip),%rdi
call   1030 <puts@plt>
mov    0x2e21(%rip),%rax
mov    (%rax),%edi
pop    %rbx
pop    %r14
pop    %r15
jmp    1080 <ERR_print_errors_fp@plt>
lea    0xe36(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e02(%rip),%rax
mov    (%rax),%edi
call   1080 <ERR_print_errors_fp@plt>
jmp    117f <loadCerts+0x1f>
lea    0xe40(%rip),%rdi
call   1060 <perror@plt>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
call   1080 <ERR_print_errors_fp@plt>
jmp    1192 <loadCerts+0x32>

LLVM IR (-O0):
@SSL_FILETYPE_PEM = global i32 0
@.str = [38 x i8] c"SSL_CTX_use_certificate_file() error\0A\00"
@stderr = global i32 0
@.str.1 = [37 x i8] c"SSL_CTX_use_PrivateKey_file() error\0A\00"
@.str.2 = [51 x i8] c"Private key does not match the public certificate\0A\00"
define void @loadCerts(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 i32 @SSL_CTX_use_certificate_file(i32* %7, i8* %8, i32 %9)
%11 = icmp ne i32 %10, 1
br i1 %11, label %12, label %16
12: ; preds = %3
%13 = call i32 @perror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%14 = load i32, i32* @stderr
%15 = call i32 @ERR_print_errors_fp(i32 %14)
br label %16
16: ; preds = %12, %3
%17 = load i32*, i32** %4
%18 = load i8*, i8** %6
%19 = load i32, i32* @SSL_FILETYPE_PEM
%20 = call i32 @SSL_CTX_use_PrivateKey_file(i32* %17, i8* %18, i32 %19)
%21 = icmp ne i32 %20, 1
br i1 %21, label %22, label %26
22: ; preds = %16
%23 = call i32 @perror(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%24 = load i32, i32* @stderr
%25 = call i32 @ERR_print_errors_fp(i32 %24)
br label %26
26: ; preds = %22, %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 = call i32 @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.2, i64 0, i64 0))
%32 = load i32, i32* @stderr
%33 = call i32 @ERR_print_errors_fp(i32 %32)
br label %34
34: ; preds = %30, %26
ret void
}

LLVM IR (-O2):
@SSL_FILETYPE_PEM = global i32 0
@.str = [38 x i8] c"SSL_CTX_use_certificate_file() error\0A\00"
@stderr = global i32 0
@.str.1 = [37 x i8] c"SSL_CTX_use_PrivateKey_file() error\0A\00"
@str = [50 x i8] c"Private key does not match the public certificate\00"
define void @loadCerts(i32* %0, i8* %1, i8* %2) {
%4 = load i32, i32* @SSL_FILETYPE_PEM
%5 = tail call i32 @SSL_CTX_use_certificate_file(i32* %0, i8* %1, i32 %4)
%6 = icmp eq i32 %5, 1
br i1 %6, label %11, label %7
7: ; preds = %3
%8 = tail call i32 @perror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%9 = load i32, i32* @stderr
%10 = tail call i32 @ERR_print_errors_fp(i32 %9)
br label %11
11: ; preds = %7, %3
%12 = load i32, i32* @SSL_FILETYPE_PEM
%13 = tail call i32 @SSL_CTX_use_PrivateKey_file(i32* %0, i8* %2, i32 %12)
%14 = icmp eq i32 %13, 1
br i1 %14, label %19, label %15
15: ; preds = %11
%16 = tail call i32 @perror(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%17 = load i32, i32* @stderr
%18 = tail call i32 @ERR_print_errors_fp(i32 %17)
br label %19
19: ; preds = %15, %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 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str, i64 0, i64 0))
%24 = load i32, i32* @stderr
%25 = tail call i32 @ERR_print_errors_fp(i32 %24)
br label %26
26: ; preds = %22, %19
ret void
}