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

/* Variables and functions */
int /*<<< orphan*/ SSL_CTX_set_verify(int /*<<< orphan*/ *, int,
                                      int /*<<< orphan*/ *);
int /*<<< orphan*/ SSL_CTX_set_verify_depth(int /*<<< orphan*/ *, int);
int SSL_VERIFY_FAIL_IF_NO_PEER_CERT;
int SSL_VERIFY_PEER;
int SSL_accept(int /*<<< orphan*/ *);
int /*<<< orphan*/ *SSL_new(int /*<<< orphan*/ *);
int /*<<< orphan*/ SSL_set_fd(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ initSSL();
int /*<<< orphan*/ *initServerCTX();
int /*<<< orphan*/ loadCerts(int /*<<< orphan*/ *, char const *, char const *);
int /*<<< orphan*/ printSSLErr(char *);
int /*<<< orphan*/ showCerts(int /*<<< orphan*/ *);
int /*<<< orphan*/ shutdownSSL(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
SSL *configServerSSL(int worker_sock) {
  int status, ssl_err;
  const char *cert = "/pwdmanlib/certs/server.pem";
  const char *key = "/pwdmanlib/certs/server.key";
  const char *cafile = "/pwdmanlib/certs2/rootCA.pem";
  const char *capath = NULL;
  SSL_CTX *ctx;
  initSSL();
  ctx = initServerCTX();
  if (!ctx) {
    printSSLErr("initServerCTX() error: ctx is NULL");
  }
  SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER | SSL_VERIFY_FAIL_IF_NO_PEER_CERT,
                     NULL);
  SSL_CTX_set_verify_depth(ctx, 4);
  loadCerts(ctx, cert, key);
  SSL *cSSL = SSL_new(ctx);
  showCerts(cSSL);
  SSL_set_fd(cSSL, worker_sock);
  ssl_err = SSL_accept(cSSL);
  if (ssl_err <= 0) {
    fprintf(stderr, ("SSL_accept() error\n"));
    shutdownSSL(cSSL, ctx);
    exit(1);
  }
  return cSSL;
}


x86 assembly (clang, -O0):
<configServerSSL>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
lea    0xe1e(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xe2f(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xe40(%rip),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    $0x0,%al
call   1080 <initSSL@plt>
mov    $0x0,%al
call   1040 <initServerCTX@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    122d <configServerSSL+0x5d>
lea    0xe2d(%rip),%rdi
call   10f0 <printSSLErr@plt>
mov    -0x38(%rbp),%rdi
mov    0x2da0(%rip),%rax
mov    (%rax),%esi
mov    0x2d8f(%rip),%rax
or     (%rax),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1060 <SSL_CTX_set_verify@plt>
mov    -0x38(%rbp),%rdi
mov    $0x4,%esi
call   10d0 <SSL_CTX_set_verify_depth@plt>
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <loadCerts@plt>
mov    -0x38(%rbp),%rdi
call   1090 <SSL_new@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
call   10c0 <showCerts@plt>
mov    -0x40(%rbp),%rdi
mov    -0x4(%rbp),%esi
call   1050 <SSL_set_fd@plt>
mov    -0x40(%rbp),%rdi
call   10b0 <SSL_accept@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jg     12cf <configServerSSL+0xff>
mov    0x2d36(%rip),%rax
mov    (%rax),%edi
lea    0xdc5(%rip),%rsi
call   10a0 <fprintf@plt>
mov    -0x40(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1070 <shutdownSSL@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>
mov    -0x40(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<configServerSSL>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%r14d
xor    %eax,%eax
call   1080 <initSSL@plt>
xor    %eax,%eax
call   1040 <initServerCTX@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11f9 <configServerSSL+0x29>
lea    0xe44(%rip),%rdi
call   10f0 <printSSLErr@plt>
mov    0x2dd8(%rip),%rax
mov    0x2dc9(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    %rbx,%rdi
xor    %edx,%edx
call   1060 <SSL_CTX_set_verify@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   10d0 <SSL_CTX_set_verify_depth@plt>
lea    0xdd7(%rip),%rsi
lea    0xdec(%rip),%rdx
mov    %rbx,%rdi
call   1030 <loadCerts@plt>
mov    %rbx,%rdi
call   1090 <SSL_new@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   10c0 <showCerts@plt>
mov    %rbp,%rdi
mov    %r14d,%esi
call   1050 <SSL_set_fd@plt>
mov    %rbp,%rdi
call   10b0 <SSL_accept@plt>
test   %eax,%eax
jle    126a <configServerSSL+0x9a>
mov    %rbp,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2d6f(%rip),%rax
mov    (%rax),%edi
lea    0xde1(%rip),%rsi
call   10a0 <fprintf@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1070 <shutdownSSL@plt>
mov    $0x1,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@.str = [28 x i8] c"/pwdmanlib/certs/server.pem\00"
@.str.1 = [28 x i8] c"/pwdmanlib/certs/server.key\00"
@.str.2 = [29 x i8] c"/pwdmanlib/certs2/rootCA.pem\00"
@.str.3 = [35 x i8] c"initServerCTX() error: ctx is NULL\00"
@SSL_VERIFY_PEER = global i32 0
@SSL_VERIFY_FAIL_IF_NO_PEER_CERT = global i32 0
@stderr = global i32 0
@.str.4 = [20 x i8] c"SSL_accept() error\0A\00"
define i32* @configServerSSL(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32*
store i32 %0, i32* %2
store i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8** %5
store i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8** %6
store i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8** %7
store i8* null, i8** %8
%11 = call i32 (...) @initSSL()
%12 = call i32* (...) @initServerCTX()
store i32* %12, i32** %9
%13 = load i32*, i32** %9
%14 = icmp ne i32* %13, null
br i1 %14, label %17, label %15
15: ; preds = %1
%16 = call i32 @printSSLErr(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
br label %17
17: ; preds = %15, %1
%18 = load i32*, i32** %9
%19 = load i32, i32* @SSL_VERIFY_PEER
%20 = load i32, i32* @SSL_VERIFY_FAIL_IF_NO_PEER_CERT
%21 = or i32 %19, %20
%22 = call i32 @SSL_CTX_set_verify(i32* %18, i32 %21, i32* null)
%23 = load i32*, i32** %9
%24 = call i32 @SSL_CTX_set_verify_depth(i32* %23, i32 4)
%25 = load i32*, i32** %9
%26 = load i8*, i8** %5
%27 = load i8*, i8** %6
%28 = call i32 @loadCerts(i32* %25, i8* %26, i8* %27)
%29 = load i32*, i32** %9
%30 = call i32* @SSL_new(i32* %29)
store i32* %30, i32** %10
%31 = load i32*, i32** %10
%32 = call i32 @showCerts(i32* %31)
%33 = load i32*, i32** %10
%34 = load i32, i32* %2
%35 = call i32 @SSL_set_fd(i32* %33, i32 %34)
%36 = load i32*, i32** %10
%37 = call i32 @SSL_accept(i32* %36)
store i32 %37, i32* %4
%38 = load i32, i32* %4
%39 = icmp sle i32 %38, 0
br i1 %39, label %40, label %47
40: ; preds = %17
%41 = load i32, i32* @stderr
%42 = call i32 @fprintf(i32 %41, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%43 = load i32*, i32** %10
%44 = load i32*, i32** %9
%45 = call i32 @shutdownSSL(i32* %43, i32* %44)
%46 = call i32 @exit(i32 1)
unreachable
47: ; preds = %17
%48 = load i32*, i32** %10
ret i32* %48
}

LLVM IR (-O2):
@.str = [28 x i8] c"/pwdmanlib/certs/server.pem\00"
@.str.1 = [28 x i8] c"/pwdmanlib/certs/server.key\00"
@.str.3 = [35 x i8] c"initServerCTX() error: ctx is NULL\00"
@SSL_VERIFY_PEER = global i32 0
@SSL_VERIFY_FAIL_IF_NO_PEER_CERT = global i32 0
@stderr = global i32 0
@.str.4 = [20 x i8] c"SSL_accept() error\0A\00"
define i32* @configServerSSL(i32 %0) {
%2 = tail call i32 (...) @initSSL()
%3 = tail call i32* (...) @initServerCTX()
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %1
%6 = tail call i32 @printSSLErr(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
br label %7
7: ; preds = %5, %1
%8 = load i32, i32* @SSL_VERIFY_PEER
%9 = load i32, i32* @SSL_VERIFY_FAIL_IF_NO_PEER_CERT
%10 = or i32 %9, %8
%11 = tail call i32 @SSL_CTX_set_verify(i32* %3, i32 %10, i32* null)
%12 = tail call i32 @SSL_CTX_set_verify_depth(i32* %3, i32 4)
%13 = tail call i32 @loadCerts(i32* %3, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%14 = tail call i32* @SSL_new(i32* %3)
%15 = tail call i32 @showCerts(i32* %14)
%16 = tail call i32 @SSL_set_fd(i32* %14, i32 %0)
%17 = tail call i32 @SSL_accept(i32* %14)
%18 = icmp slt i32 %17, 1
br i1 %18, label %19, label %24
19: ; preds = %7
%20 = load i32, i32* @stderr
%21 = tail call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%22 = tail call i32 @shutdownSSL(i32* %14, i32* %3)
%23 = tail call i32 @exit(i32 1)
unreachable
24: ; preds = %7
ret i32* %14
}