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

/* Variables and functions */
int /*<<< orphan*/ SSL_FILETYPE_PEM;
int /*<<< orphan*/ SSL_check_private_key(int /*<<< orphan*/ *);
scalar_t__ SSL_use_PrivateKey_file(int /*<<< orphan*/ *, char *,
                                   int /*<<< orphan*/);
scalar_t__ SSL_use_certificate_file(int /*<<< orphan*/ *, char *,
                                    int /*<<< orphan*/);
int /*<<< orphan*/ print_str(char *);
int ssl_load_client_certs(SSL *ssl, char *cert_file, char *key_file) {
  if (SSL_use_certificate_file(ssl, cert_file, SSL_FILETYPE_PEM) <= 0) {
    return 1;
  }
  if (SSL_use_PrivateKey_file(ssl, key_file, SSL_FILETYPE_PEM) <= 0) {
    return 2;
  }
  if (!SSL_check_private_key(ssl)) {
    print_str("ERROR: private key does not match the public certificate\n");
    return 3;
  }
  return 0;
}


x86 assembly (clang, -O0):
<ssl_load_client_certs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2e85(%rip),%rax
mov    (%rax),%edx
call   1030 <SSL_use_certificate_file@plt>
cmp    $0x0,%rax
jg     1180 <ssl_load_client_certs+0x40>
movl   $0x1,-0x4(%rbp)
jmp    11dd <ssl_load_client_certs+0x9d>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    0x2e59(%rip),%rax
mov    (%rax),%edx
call   1050 <SSL_use_PrivateKey_file@plt>
cmp    $0x0,%rax
jg     11ac <ssl_load_client_certs+0x6c>
movl   $0x2,-0x4(%rbp)
jmp    11dd <ssl_load_client_certs+0x9d>
mov    -0x10(%rbp),%rdi
call   1060 <SSL_check_private_key@plt>
cmp    $0x0,%eax
jne    11d6 <ssl_load_client_certs+0x96>
lea    0xe3b(%rip),%rdi
call   1040 <print_str@plt>
movl   $0x3,-0x4(%rbp)
jmp    11dd <ssl_load_client_certs+0x9d>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ssl_load_client_certs>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rdi,%rbx
mov    0x2e96(%rip),%r15
mov    (%r15),%edx
call   1030 <SSL_use_certificate_file@plt>
test   %rax,%rax
jle    1195 <ssl_load_client_certs+0x55>
mov    (%r15),%edx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <SSL_use_PrivateKey_file@plt>
test   %rax,%rax
jle    119c <ssl_load_client_certs+0x5c>
mov    %rbx,%rdi
call   1060 <SSL_check_private_key@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
jne    11a1 <ssl_load_client_certs+0x61>
lea    0xe77(%rip),%rdi
call   1040 <print_str@plt>
mov    $0x3,%eax
jmp    11a1 <ssl_load_client_certs+0x61>
mov    $0x1,%eax
jmp    11a1 <ssl_load_client_certs+0x61>
mov    $0x2,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@SSL_FILETYPE_PEM = global i32 0
@.str = [58 x i8] c"ERROR: private key does not match the public certificate\0A\00"
define i32 @ssl_load_client_certs(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
%8 = load i32*, i32** %5
%9 = load i8*, i8** %6
%10 = load i32, i32* @SSL_FILETYPE_PEM
%11 = call i64 @SSL_use_certificate_file(i32* %8, i8* %9, i32 %10)
%12 = icmp sle i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %3
store i32 1, i32* %4
br label %28
14: ; preds = %3
%15 = load i32*, i32** %5
%16 = load i8*, i8** %7
%17 = load i32, i32* @SSL_FILETYPE_PEM
%18 = call i64 @SSL_use_PrivateKey_file(i32* %15, i8* %16, i32 %17)
%19 = icmp sle i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %14
store i32 2, i32* %4
br label %28
21: ; preds = %14
%22 = load i32*, i32** %5
%23 = call i32 @SSL_check_private_key(i32* %22)
%24 = icmp ne i32 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %21
%26 = call i32 @print_str(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
store i32 3, i32* %4
br label %28
27: ; preds = %21
store i32 0, i32* %4
br label %28
28: ; preds = %27, %25, %20, %13
%29 = load i32, i32* %4
ret i32 %29
}

LLVM IR (-O2):
@SSL_FILETYPE_PEM = global i32 0
@.str = [58 x i8] c"ERROR: private key does not match the public certificate\0A\00"
define i32 @ssl_load_client_certs(i32* %0, i8* %1, i8* %2) {
%4 = load i32, i32* @SSL_FILETYPE_PEM
%5 = tail call i64 @SSL_use_certificate_file(i32* %0, i8* %1, i32 %4)
%6 = icmp slt i64 %5, 1
br i1 %6, label %16, label %7
7: ; preds = %3
%8 = load i32, i32* @SSL_FILETYPE_PEM
%9 = tail call i64 @SSL_use_PrivateKey_file(i32* %0, i8* %2, i32 %8)
%10 = icmp slt i64 %9, 1
br i1 %10, label %16, label %11
11: ; preds = %7
%12 = tail call i32 @SSL_check_private_key(i32* %0)
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = tail call i32 @print_str(i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str, i64 0, i64 0))
br label %16
16: ; preds = %11, %7, %3, %14
%17 = phi i32 [ 3, %14 ], [ 1, %3 ], [ 2, %7 ], [ 0, %11 ]
ret i32 %17
}