#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_load_verify_locations(int /*<<< orphan*/ *, char *,
                                         int /*<<< orphan*/);
int /*<<< orphan*/ SSL_CTX_set_cipher_list(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ SSL_CTX_set_options(int /*<<< orphan*/ *,
                                       int /*<<< orphan*/);
int /*<<< orphan*/ SSL_CTX_set_verify(int /*<<< orphan*/ *, int,
                                      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*/ SSL_OP_NO_COMPRESSION;
int SSL_VERIFY_CLIENT_ONCE;
int SSL_VERIFY_FAIL_IF_NO_PEER_CERT;
int SSL_VERIFY_PEER;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
void init_ssl_opts(SSL_CTX *ctx) {
  if (!SSL_CTX_set_cipher_list(ctx, "AES128-GCM-SHA256")) {
    printf("Could not set cipher list");
    exit(1);
  }
  if (!SSL_CTX_set_options(ctx, SSL_OP_NO_COMPRESSION)) {
    printf("Could not disable compression");
    exit(2);
  }
  if (SSL_CTX_load_verify_locations(ctx, "src/server.crt", 0) <= 0) {
    ERR_print_errors_fp(stderr);
    exit(5);
  }
  if (SSL_CTX_use_certificate_file(ctx, "src/server.crt", SSL_FILETYPE_PEM) <=
      0) {
    printf("Could not load cert file: ");
    ERR_print_errors_fp(stderr);
    exit(5);
  }
  if (SSL_CTX_use_PrivateKey_file(ctx, "src/server.key", SSL_FILETYPE_PEM) <=
      0) {
    printf("Could not load key file");
    ERR_print_errors_fp(stderr);
    exit(6);
  }
  if (!SSL_CTX_check_private_key(ctx)) {
    fprintf(stderr, "Private key does not match public key in certificate.\n");
    exit(7);
  }
  SSL_CTX_set_verify(ctx,
                     SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT |
                         SSL_VERIFY_CLIENT_ONCE,
                     0);
}


x86 assembly (clang, -O0):
<init_ssl_opts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe39(%rip),%rsi
call   10a0 <SSL_CTX_set_cipher_list@plt>
cmp    $0x0,%eax
jne    11eb <init_ssl_opts+0x3b>
lea    0xe36(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
mov    -0x8(%rbp),%rdi
mov    0x2de2(%rip),%rax
mov    (%rax),%esi
call   1030 <SSL_CTX_set_options@plt>
cmp    $0x0,%eax
jne    121c <init_ssl_opts+0x6c>
lea    0xe1f(%rip),%rdi
call   1050 <printf@plt>
mov    $0x2,%edi
call   10b0 <exit@plt>
mov    -0x8(%rbp),%rdi
lea    0xe23(%rip),%rsi
xor    %edx,%edx
call   1080 <SSL_CTX_load_verify_locations@plt>
cmp    $0x0,%rax
jg     1250 <init_ssl_opts+0xa0>
mov    0x2d89(%rip),%rax
mov    (%rax),%edi
call   10d0 <ERR_print_errors_fp@plt>
mov    $0x5,%edi
call   10b0 <exit@plt>
mov    -0x8(%rbp),%rdi
mov    0x2d85(%rip),%rax
mov    (%rax),%edx
lea    0xde6(%rip),%rsi
call   1060 <SSL_CTX_use_certificate_file@plt>
cmp    $0x0,%rax
jg     1297 <init_ssl_opts+0xe7>
lea    0xddf(%rip),%rdi
call   1050 <printf@plt>
mov    0x2d42(%rip),%rax
mov    (%rax),%edi
call   10d0 <ERR_print_errors_fp@plt>
mov    $0x5,%edi
call   10b0 <exit@plt>
mov    -0x8(%rbp),%rdi
mov    0x2d3e(%rip),%rax
mov    (%rax),%edx
lea    0xdc9(%rip),%rsi
call   1090 <SSL_CTX_use_PrivateKey_file@plt>
cmp    $0x0,%rax
jg     12de <init_ssl_opts+0x12e>
lea    0xdc2(%rip),%rdi
call   1050 <printf@plt>
mov    0x2cfb(%rip),%rax
mov    (%rax),%edi
call   10d0 <ERR_print_errors_fp@plt>
mov    $0x6,%edi
call   10b0 <exit@plt>
mov    -0x8(%rbp),%rdi
call   10c0 <SSL_CTX_check_private_key@plt>
cmp    $0x0,%eax
jne    130f <init_ssl_opts+0x15f>
mov    0x2cd1(%rip),%rax
mov    (%rax),%edi
lea    0xd9b(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x7,%edi
call   10b0 <exit@plt>
mov    -0x8(%rbp),%rdi
mov    0x2ca6(%rip),%rax
mov    (%rax),%esi
mov    0x2c95(%rip),%rax
or     (%rax),%esi
mov    0x2cbc(%rip),%rax
or     (%rax),%esi
xor    %edx,%edx
call   1040 <SSL_CTX_set_verify@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_ssl_opts>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xe42(%rip),%rsi
call   10a0 <SSL_CTX_set_cipher_list@plt>
test   %eax,%eax
je     1277 <init_ssl_opts+0xc7>
mov    0x2e06(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1030 <SSL_CTX_set_options@plt>
test   %eax,%eax
je     128d <init_ssl_opts+0xdd>
lea    0xe5f(%rip),%rsi
mov    %rbx,%rdi
xor    %edx,%edx
call   1080 <SSL_CTX_load_verify_locations@plt>
test   %rax,%rax
jle    12af <init_ssl_opts+0xff>
mov    0x2ddb(%rip),%r14
mov    (%r14),%edx
lea    0xe3b(%rip),%rsi
mov    %rbx,%rdi
call   1060 <SSL_CTX_use_certificate_file@plt>
test   %rax,%rax
jle    12a3 <init_ssl_opts+0xf3>
mov    (%r14),%edx
lea    0xe4a(%rip),%rsi
mov    %rbx,%rdi
call   1090 <SSL_CTX_use_PrivateKey_file@plt>
test   %rax,%rax
jle    12c7 <init_ssl_opts+0x117>
mov    %rbx,%rdi
call   10c0 <SSL_CTX_check_private_key@plt>
test   %eax,%eax
je     12eb <init_ssl_opts+0x13b>
mov    0x2d6e(%rip),%rax
mov    0x2d5f(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2d84(%rip),%rax
or     (%rax),%esi
mov    %rbx,%rdi
xor    %edx,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <SSL_CTX_set_verify@plt>
lea    0xd94(%rip),%rdi
call   1050 <printf@plt>
mov    $0x1,%edi
call   10b0 <exit@plt>
lea    0xd98(%rip),%rdi
call   1050 <printf@plt>
mov    $0x2,%edi
call   10b0 <exit@plt>
lea    0xdaf(%rip),%rdi
call   1050 <printf@plt>
mov    0x2d12(%rip),%rax
mov    (%rax),%edi
call   10d0 <ERR_print_errors_fp@plt>
mov    $0x5,%edi
call   10b0 <exit@plt>
lea    0xdb5(%rip),%rdi
call   1050 <printf@plt>
mov    0x2cee(%rip),%rax
mov    (%rax),%edi
call   10d0 <ERR_print_errors_fp@plt>
mov    $0x6,%edi
call   10b0 <exit@plt>
mov    0x2cd6(%rip),%rax
mov    (%rax),%edi
lea    0xda0(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x7,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"AES128-GCM-SHA256\00"
@.str.1 = [26 x i8] c"Could not set cipher list\00"
@SSL_OP_NO_COMPRESSION = global i32 0
@.str.2 = [30 x i8] c"Could not disable compression\00"
@.str.3 = [15 x i8] c"src/server.crt\00"
@stderr = global i32 0
@SSL_FILETYPE_PEM = global i32 0
@.str.4 = [27 x i8] c"Could not load cert file: \00"
@.str.5 = [15 x i8] c"src/server.key\00"
@.str.6 = [24 x i8] c"Could not load key file\00"
@.str.7 = [55 x i8] c"Private key does not match public key in certificate.\0A\00"
@SSL_VERIFY_PEER = global i32 0
@SSL_VERIFY_FAIL_IF_NO_PEER_CERT = global i32 0
@SSL_VERIFY_CLIENT_ONCE = global i32 0
define void @init_ssl_opts(i32* %0) {
%2 = alloca i32*
store i32* %0, i32** %2
%3 = load i32*, i32** %2
%4 = call i32 @SSL_CTX_set_cipher_list(i32* %3, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%5 = icmp ne i32 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %1
%7 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @exit(i32 1)
unreachable
9: ; preds = %1
%10 = load i32*, i32** %2
%11 = load i32, i32* @SSL_OP_NO_COMPRESSION
%12 = call i32 @SSL_CTX_set_options(i32* %10, i32 %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %9
%15 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @exit(i32 2)
unreachable
17: ; preds = %9
%18 = load i32*, i32** %2
%19 = call i64 @SSL_CTX_load_verify_locations(i32* %18, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 0)
%20 = icmp sle i64 %19, 0
br i1 %20, label %21, label %25
21: ; preds = %17
%22 = load i32, i32* @stderr
%23 = call i32 @ERR_print_errors_fp(i32 %22)
%24 = call i32 @exit(i32 5)
unreachable
25: ; preds = %17
%26 = load i32*, i32** %2
%27 = load i32, i32* @SSL_FILETYPE_PEM
%28 = call i64 @SSL_CTX_use_certificate_file(i32* %26, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %27)
%29 = icmp sle i64 %28, 0
br i1 %29, label %30, label %35
30: ; preds = %25
%31 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%32 = load i32, i32* @stderr
%33 = call i32 @ERR_print_errors_fp(i32 %32)
%34 = call i32 @exit(i32 5)
unreachable
35: ; preds = %25
%36 = load i32*, i32** %2
%37 = load i32, i32* @SSL_FILETYPE_PEM
%38 = call i64 @SSL_CTX_use_PrivateKey_file(i32* %36, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %37)
%39 = icmp sle i64 %38, 0
br i1 %39, label %40, label %45
40: ; preds = %35
%41 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
%42 = load i32, i32* @stderr
%43 = call i32 @ERR_print_errors_fp(i32 %42)
%44 = call i32 @exit(i32 6)
unreachable
45: ; preds = %35
%46 = load i32*, i32** %2
%47 = call i32 @SSL_CTX_check_private_key(i32* %46)
%48 = icmp ne i32 %47, 0
br i1 %48, label %53, label %49
49: ; preds = %45
%50 = load i32, i32* @stderr
%51 = call i32 @fprintf(i32 %50, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.7, i64 0, i64 0))
%52 = call i32 @exit(i32 7)
unreachable
53: ; preds = %45
%54 = load i32*, i32** %2
%55 = load i32, i32* @SSL_VERIFY_PEER
%56 = load i32, i32* @SSL_VERIFY_FAIL_IF_NO_PEER_CERT
%57 = or i32 %55, %56
%58 = load i32, i32* @SSL_VERIFY_CLIENT_ONCE
%59 = or i32 %57, %58
%60 = call i32 @SSL_CTX_set_verify(i32* %54, i32 %59, i32 0)
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"AES128-GCM-SHA256\00"
@.str.1 = [26 x i8] c"Could not set cipher list\00"
@SSL_OP_NO_COMPRESSION = global i32 0
@.str.2 = [30 x i8] c"Could not disable compression\00"
@.str.3 = [15 x i8] c"src/server.crt\00"
@stderr = global i32 0
@SSL_FILETYPE_PEM = global i32 0
@.str.4 = [27 x i8] c"Could not load cert file: \00"
@.str.5 = [15 x i8] c"src/server.key\00"
@.str.6 = [24 x i8] c"Could not load key file\00"
@.str.7 = [55 x i8] c"Private key does not match public key in certificate.\0A\00"
@SSL_VERIFY_PEER = global i32 0
@SSL_VERIFY_FAIL_IF_NO_PEER_CERT = global i32 0
@SSL_VERIFY_CLIENT_ONCE = global i32 0
define void @init_ssl_opts(i32* %0) {
%2 = tail call i32 @SSL_CTX_set_cipher_list(i32* %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %1
%8 = load i32, i32* @SSL_OP_NO_COMPRESSION
%9 = tail call i32 @SSL_CTX_set_options(i32* %0, i32 %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%13 = tail call i32 @exit(i32 2)
unreachable
14: ; preds = %7
%15 = tail call i64 @SSL_CTX_load_verify_locations(i32* %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 0)
%16 = icmp slt i64 %15, 1
br i1 %16, label %17, label %21
17: ; preds = %14
%18 = load i32, i32* @stderr
%19 = tail call i32 @ERR_print_errors_fp(i32 %18)
%20 = tail call i32 @exit(i32 5)
unreachable
21: ; preds = %14
%22 = load i32, i32* @SSL_FILETYPE_PEM
%23 = tail call i64 @SSL_CTX_use_certificate_file(i32* %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = icmp slt i64 %23, 1
br i1 %24, label %25, label %30
25: ; preds = %21
%26 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%27 = load i32, i32* @stderr
%28 = tail call i32 @ERR_print_errors_fp(i32 %27)
%29 = tail call i32 @exit(i32 5)
unreachable
30: ; preds = %21
%31 = load i32, i32* @SSL_FILETYPE_PEM
%32 = tail call i64 @SSL_CTX_use_PrivateKey_file(i32* %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %31)
%33 = icmp slt i64 %32, 1
br i1 %33, label %34, label %39
34: ; preds = %30
%35 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
%36 = load i32, i32* @stderr
%37 = tail call i32 @ERR_print_errors_fp(i32 %36)
%38 = tail call i32 @exit(i32 6)
unreachable
39: ; preds = %30
%40 = tail call i32 @SSL_CTX_check_private_key(i32* %0)
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %39
%43 = load i32, i32* @stderr
%44 = tail call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.7, i64 0, i64 0))
%45 = tail call i32 @exit(i32 7)
unreachable
46: ; preds = %39
%47 = load i32, i32* @SSL_VERIFY_PEER
%48 = load i32, i32* @SSL_VERIFY_FAIL_IF_NO_PEER_CERT
%49 = or i32 %48, %47
%50 = load i32, i32* @SSL_VERIFY_CLIENT_ONCE
%51 = or i32 %49, %50
%52 = tail call i32 @SSL_CTX_set_verify(i32* %0, i32 %51, i32 0)
ret void
}