#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 */
struct sockaddr_in {
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_addr;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ socklen_t;
typedef int /*<<< orphan*/ SSL_CTX;
typedef int /*<<< orphan*/ SSL;

/* Variables and functions */
int /*<<< orphan*/ *InitServerCTX();
int /*<<< orphan*/ LoadCertificates(int /*<<< orphan*/ *, char *, char *);
int OpenListener(int);
int /*<<< orphan*/ SSL_CTX_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *SSL_new(int /*<<< orphan*/ *);
int /*<<< orphan*/ SSL_set_fd(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ Servlet(int /*<<< orphan*/ *);
int accept(int, struct sockaddr *, int /*<<< orphan*/ *);
int /*<<< orphan*/ close(int);
char *inet_ntoa(int /*<<< orphan*/);
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, int);
int main(int count, char *strings[]) {
  SSL_CTX *ctx;
  int server;
  ctx = InitServerCTX();
  LoadCertificates(ctx, "server.crt", "server.key");
  server = OpenListener(5006);
  while (1) {
    struct sockaddr_in addr;
    socklen_t len;
    SSL *ssl;
    int client = accept(server, (struct sockaddr *)&addr, &len);
    printf("Connection: %s:%d\n", inet_ntoa(addr.sin_addr),
           ntohs(addr.sin_port));
    ssl = SSL_new(ctx);
    SSL_set_fd(ssl, client);
    Servlet(ssl);
  }
  close(server);
  SSL_CTX_free(ctx);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1080 <InitServerCTX@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe34(%rip),%rsi
lea    0xe38(%rip),%rdx
call   10c0 <LoadCertificates@plt>
mov    $0x138e,%edi
call   1090 <OpenListener@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x28(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
call   10b0 <accept@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x24(%rbp),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,-0x48(%rbp)
mov    -0x28(%rbp),%edi
call   10a0 <ntohs@plt>
mov    -0x48(%rbp),%rsi
mov    %eax,%edx
lea    0xdfd(%rip),%rdi
call   1060 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1070 <SSL_new@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x3c(%rbp),%esi
call   1050 <SSL_set_fd@plt>
mov    -0x38(%rbp),%rdi
call   1030 <Servlet@plt>
jmp    11e5 <main+0x45>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xor    %eax,%eax
call   1080 <InitServerCTX@plt>
mov    %rax,%r13
lea    0xe41(%rip),%rsi
lea    0xe45(%rip),%rdx
mov    %rax,%rdi
call   10c0 <LoadCertificates@plt>
mov    $0x138e,%edi
call   1090 <OpenListener@plt>
mov    %eax,%r15d
lea    0xe34(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15d,%edi
lea    0x8(%rsp),%rsi
lea    0x14(%rsp),%rdx
call   10b0 <accept@plt>
mov    %eax,%ebx
mov    0xc(%rsp),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,%r14
mov    0x8(%rsp),%edi
call   10a0 <ntohs@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1060 <printf@plt>
mov    %r13,%rdi
call   1070 <SSL_new@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %ebx,%esi
call   1050 <SSL_set_fd@plt>
mov    %rbp,%rdi
call   1030 <Servlet@plt>
jmp    11f0 <main+0x50>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [11 x i8] c"server.crt\00"
@.str.1 = [11 x i8] c"server.key\00"
@.str.2 = [19 x i8] c"Connection: %s:%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
%8 = alloca %struct.sockaddr_in
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = call i32* (...) @InitServerCTX()
store i32* %12, i32** %6
%13 = load i32*, i32** %6
%14 = call i32 @LoadCertificates(i32* %13, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%15 = call i32 @OpenListener(i32 5006)
store i32 %15, i32* %7
br label %16
16: ; preds = %2, %16
%17 = load i32, i32* %7
%18 = bitcast %struct.sockaddr_in* %8 to %struct.sockaddr*
%19 = call i32 @accept(i32 %17, %struct.sockaddr* %18, i32* %9)
store i32 %19, i32* %11
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
%21 = load i32, i32* %20
%22 = call i8* @inet_ntoa(i32 %21)
%23 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 0
%24 = load i32, i32* %23
%25 = call i32 @ntohs(i32 %24)
%26 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %22, i32 %25)
%27 = load i32*, i32** %6
%28 = call i32* @SSL_new(i32* %27)
store i32* %28, i32** %10
%29 = load i32*, i32** %10
%30 = load i32, i32* %11
%31 = call i32 @SSL_set_fd(i32* %29, i32 %30)
%32 = load i32*, i32** %10
%33 = call i32 @Servlet(i32* %32)
br label %16
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32 }
%struct.sockaddr = type { i32 }
@.str = [11 x i8] c"server.crt\00"
@.str.1 = [11 x i8] c"server.key\00"
@.str.2 = [19 x i8] c"Connection: %s:%d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
%5 = tail call i32* (...) @InitServerCTX()
%6 = tail call i32 @LoadCertificates(i32* %5, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32 @OpenListener(i32 5006)
%8 = bitcast %struct.sockaddr_in* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 1
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i64 0, i32 0
br label %13
13: ; preds = %13, %2
%14 = call i32 @accept(i32 %7, %struct.sockaddr* %10, i32* %4)
%15 = load i32, i32* %11
%16 = call i8* @inet_ntoa(i32 %15)
%17 = load i32, i32* %12
%18 = call i32 @ntohs(i32 %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %16, i32 %18)
%20 = call i32* @SSL_new(i32* %5)
%21 = call i32 @SSL_set_fd(i32* %20, i32 %14)
%22 = call i32 @Servlet(i32* %20)
br label %13
}