#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*/ buf;
typedef int /*<<< orphan*/ X509_NAME;
typedef int /*<<< orphan*/ X509;
typedef int /*<<< orphan*/ SSL_METHOD;
typedef int /*<<< orphan*/ SSL_CTX;
typedef int /*<<< orphan*/ SSL;
typedef int /*<<< orphan*/ BIO;

/* Variables and functions */
int /*<<< orphan*/ BIO_NOCLOSE;
int /*<<< orphan*/ *BIO_new(int /*<<< orphan*/);
int /*<<< orphan*/ *BIO_new_fp(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ BIO_printf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ BIO_s_file();
int /*<<< orphan*/ ERR_load_BIO_strings();
int /*<<< orphan*/ ERR_load_crypto_strings();
int /*<<< orphan*/ OpenSSL_add_all_algorithms();
int /*<<< orphan*/ SSL_CTX_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *SSL_CTX_new(int /*<<< orphan*/ const *);
int /*<<< orphan*/ SSL_CTX_set_options(int /*<<< orphan*/ *,
                                       int /*<<< orphan*/);
int /*<<< orphan*/ SSL_OP_NO_SSLv2;
int SSL_connect(int /*<<< orphan*/ *);
int /*<<< orphan*/ SSL_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *SSL_get_peer_certificate(int /*<<< orphan*/ *);
scalar_t__ SSL_library_init();
int /*<<< orphan*/ SSL_load_error_strings();
int /*<<< orphan*/ *SSL_new(int /*<<< orphan*/ *);
int SSL_read(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ SSL_set_fd(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ SSL_write(int /*<<< orphan*/ *, char *, int /*<<< orphan*/);
int /*<<< orphan*/ *SSLv23_client_method();
int /*<<< orphan*/ *X509_NAME_new();
int /*<<< orphan*/ X509_NAME_print_ex(int /*<<< orphan*/ *,
                                      int /*<<< orphan*/ *, int /*<<< orphan*/,
                                      int /*<<< orphan*/);
int /*<<< orphan*/ X509_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *X509_get_subject_name(int /*<<< orphan*/ *);
int /*<<< orphan*/ close(int);
int create_socket(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strlen(char *);
int main() {
  char dest_url[] = "http://r01.cs.ucla.edu";
  BIO *certbio = NULL;
  BIO *outbio = NULL;
  X509 *cert = NULL;
  X509_NAME *certname = NULL;
  const SSL_METHOD *method;
  SSL_CTX *ctx;
  SSL *ssl;
  int server = 0;
  int ret, i;
  OpenSSL_add_all_algorithms();
  ERR_load_BIO_strings();
  ERR_load_crypto_strings();
  SSL_load_error_strings();
  certbio = BIO_new(BIO_s_file());
  outbio = BIO_new_fp(stdout, BIO_NOCLOSE);
  if (SSL_library_init() < 0)
    BIO_printf(outbio, "Could not initialize the OpenSSL library !\n");
  method = SSLv23_client_method();
  if ((ctx = SSL_CTX_new(method)) == NULL)
    BIO_printf(outbio, "Unable to create a new SSL context structure.\n");
  SSL_CTX_set_options(ctx, SSL_OP_NO_SSLv2);
  ssl = SSL_new(ctx);
  server = create_socket(dest_url, outbio);
  if (server != 0)
    BIO_printf(outbio, "Successfully made the TCP connection to: %s.\n",
               dest_url);
  SSL_set_fd(ssl, server);
  if (SSL_connect(ssl) != 1)
    BIO_printf(outbio, "Error: Could not build a SSL session to: %s.\n",
               dest_url);
  else
    BIO_printf(outbio, "Successfully enabled SSL/TLS session to: %s.\n",
               dest_url);
  cert = SSL_get_peer_certificate(ssl);
  if (cert == NULL)
    BIO_printf(outbio, "Error: Could not get a certificate from: %s.\n",
               dest_url);
  else
    BIO_printf(outbio, "Retrieved the server's certificate from: %s.\n",
               dest_url);
  certname = X509_NAME_new();
  certname = X509_get_subject_name(cert);
  BIO_printf(outbio, "Displaying the certificate subject data:\n");
  X509_NAME_print_ex(outbio, certname, 0, 0);
  BIO_printf(outbio, "\n");
  char *msg = "ID = Group6 Password = 26498294";
  char buf[1024];
  int bytes;
  SSL_write(ssl, msg, strlen(msg));
  bytes = SSL_read(ssl, buf, sizeof(buf));
  buf[bytes] = 0;
  printf("Received: %s\n", buf);
  SSL_free(ssl);
  close(server);
  X509_free(cert);
  SSL_CTX_free(ctx);
  BIO_printf(outbio, "Finished SSL/TLS connection with server: %s.\n",
             dest_url);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x490,%rsp
movl   $0x0,-0x4(%rbp)
mov    0xd27(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xd24(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xd22(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xd1c(%rip),%ax
mov    %ax,-0xc(%rbp)
mov    0xd14(%rip),%al
mov    %al,-0xa(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    $0x0,%al
call   1110 <OpenSSL_add_all_algorithms@plt>
mov    $0x0,%al
call   11e0 <ERR_load_BIO_strings@plt>
mov    $0x0,%al
call   11c0 <ERR_load_crypto_strings@plt>
mov    $0x0,%al
call   11b0 <SSL_load_error_strings@plt>
mov    $0x0,%al
call   11d0 <BIO_s_file@plt>
mov    %eax,%edi
call   1150 <BIO_new@plt>
mov    %rax,-0x28(%rbp)
mov    0x2c77(%rip),%rax
mov    (%rax),%edi
mov    0x2c7e(%rip),%rax
mov    (%rax),%esi
call   1030 <BIO_new_fp@plt>
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   10e0 <SSL_library_init@plt>
cmp    $0x0,%rax
jge    1398 <main+0xd8>
mov    -0x30(%rbp),%rdi
lea    0xc86(%rip),%rsi
mov    $0x0,%al
call   10c0 <BIO_printf@plt>
mov    $0x0,%al
call   1060 <SSLv23_client_method@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
call   1120 <SSL_CTX_new@plt>
mov    %rax,-0x50(%rbp)
cmp    $0x0,%rax
jne    13cc <main+0x10c>
mov    -0x30(%rbp),%rdi
lea    0xc7e(%rip),%rsi
mov    $0x0,%al
call   10c0 <BIO_printf@plt>
mov    -0x50(%rbp),%rdi
mov    0x2bf1(%rip),%rax
mov    (%rax),%esi
call   1040 <SSL_CTX_set_options@plt>
mov    -0x50(%rbp),%rdi
call   1100 <SSL_new@plt>
mov    %rax,-0x58(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1160 <create_socket@plt>
mov    %eax,-0x5c(%rbp)
cmpl   $0x0,-0x5c(%rbp)
je     141b <main+0x15b>
mov    -0x30(%rbp),%rdi
lea    -0x20(%rbp),%rdx
lea    0xc5e(%rip),%rsi
mov    $0x0,%al
call   10c0 <BIO_printf@plt>
mov    -0x58(%rbp),%rdi
mov    -0x5c(%rbp),%esi
call   1080 <SSL_set_fd@plt>
mov    -0x58(%rbp),%rdi
call   1190 <SSL_connect@plt>
cmp    $0x1,%eax
je     1454 <main+0x194>
mov    -0x30(%rbp),%rdi
lea    -0x20(%rbp),%rdx
lea    0xc58(%rip),%rsi
mov    $0x0,%al
call   10c0 <BIO_printf@plt>
jmp    146a <main+0x1aa>
mov    -0x30(%rbp),%rdi
lea    -0x20(%rbp),%rdx
lea    0xc6b(%rip),%rsi
mov    $0x0,%al
call   10c0 <BIO_printf@plt>
mov    -0x58(%rbp),%rdi
call   1140 <SSL_get_peer_certificate@plt>
mov    %rax,-0x38(%rbp)
cmpq   $0x0,-0x38(%rbp)
jne    149d <main+0x1dd>
mov    -0x30(%rbp),%rdi
lea    -0x20(%rbp),%rdx
lea    0xc6b(%rip),%rsi
mov    $0x0,%al
call   10c0 <BIO_printf@plt>
jmp    14b3 <main+0x1f3>
mov    -0x30(%rbp),%rdi
lea    -0x20(%rbp),%rdx
lea    0xc7e(%rip),%rsi
mov    $0x0,%al
call   10c0 <BIO_printf@plt>
mov    $0x0,%al
call   1130 <X509_NAME_new@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
call   10b0 <X509_get_subject_name@plt>
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xc82(%rip),%rsi
mov    $0x0,%al
call   10c0 <BIO_printf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x40(%rbp),%rsi
xor    %ecx,%ecx
mov    %ecx,%edx
call   1180 <X509_NAME_print_ex@plt>
mov    -0x30(%rbp),%rdi
lea    0xb48(%rip),%rsi
mov    $0x0,%al
call   10c0 <BIO_printf@plt>
lea    0xc7b(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    -0x58(%rbp),%rax
mov    %rax,-0x488(%rbp)
mov    -0x70(%rbp),%rax
mov    %rax,-0x480(%rbp)
mov    -0x70(%rbp),%rdi
call   1090 <strlen@plt>
mov    -0x488(%rbp),%rdi
mov    -0x480(%rbp),%rsi
mov    %eax,%edx
call   1050 <SSL_write@plt>
mov    -0x58(%rbp),%rdi
lea    -0x470(%rbp),%rsi
mov    $0x400,%edx
call   10f0 <SSL_read@plt>
mov    %eax,-0x474(%rbp)
movslq -0x474(%rbp),%rax
movb   $0x0,-0x470(%rbp,%rax,1)
lea    -0x470(%rbp),%rsi
lea    0xc2b(%rip),%rdi
call   10a0 <printf@plt>
mov    -0x58(%rbp),%rdi
call   1070 <SSL_free@plt>
mov    -0x5c(%rbp),%edi
call   10d0 <close@plt>
mov    -0x38(%rbp),%rdi
call   1170 <X509_free@plt>
mov    -0x50(%rbp),%rdi
call   11a0 <SSL_CTX_free@plt>
mov    -0x30(%rbp),%rdi
lea    -0x20(%rbp),%rdx
lea    0xc02(%rip),%rsi
mov    $0x0,%al
call   10c0 <BIO_printf@plt>
xor    %eax,%eax
add    $0x490,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
movaps 0xd28(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0x7564652e616c63,%rax
mov    %rax,0xf(%rsp)
xor    %eax,%eax
call   1110 <OpenSSL_add_all_algorithms@plt>
xor    %eax,%eax
call   11e0 <ERR_load_BIO_strings@plt>
xor    %eax,%eax
call   11c0 <ERR_load_crypto_strings@plt>
xor    %eax,%eax
call   11b0 <SSL_load_error_strings@plt>
xor    %eax,%eax
call   11d0 <BIO_s_file@plt>
mov    %eax,%edi
call   1150 <BIO_new@plt>
mov    0x2cbc(%rip),%rax
mov    (%rax),%edi
mov    0x2cc3(%rip),%rax
mov    (%rax),%esi
call   1030 <BIO_new_fp@plt>
mov    %rax,%r15
xor    %eax,%eax
call   10e0 <SSL_library_init@plt>
test   %rax,%rax
jns    134c <main+0x8c>
lea    0xcd5(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   10c0 <BIO_printf@plt>
xor    %eax,%eax
call   1060 <SSLv23_client_method@plt>
mov    %rax,%rdi
call   1120 <SSL_CTX_new@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1374 <main+0xb4>
lea    0xcd9(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   10c0 <BIO_printf@plt>
mov    0x2c4d(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1040 <SSL_CTX_set_options@plt>
mov    %rbx,0x18(%rsp)
mov    %rbx,%rdi
call   1100 <SSL_new@plt>
mov    %rax,%rbx
mov    %rsp,%rdi
mov    %r15,%rsi
call   1160 <create_socket@plt>
mov    %eax,%r13d
test   %eax,%eax
je     13bb <main+0xfb>
lea    0xcc4(%rip),%rsi
mov    %rsp,%rdx
mov    %r15,%rdi
xor    %eax,%eax
call   10c0 <BIO_printf@plt>
mov    %rbx,%rdi
mov    %r13d,%esi
call   1080 <SSL_set_fd@plt>
mov    %rbx,%rdi
call   1190 <SSL_connect@plt>
cmp    $0x1,%eax
lea    0xcf6(%rip),%rax
lea    0xcc1(%rip),%rsi
cmove  %rax,%rsi
mov    %rsp,%rbp
mov    %r15,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   10c0 <BIO_printf@plt>
mov    %rbx,%rdi
call   1140 <SSL_get_peer_certificate@plt>
mov    %rax,%r14
test   %rax,%rax
lea    0xcf4(%rip),%rax
lea    0xd1b(%rip),%rsi
cmove  %rax,%rsi
mov    %r15,%rdi
mov    %rbp,%rdx
xor    %eax,%eax
call   10c0 <BIO_printf@plt>
xor    %eax,%eax
call   1130 <X509_NAME_new@plt>
mov    %r14,%rdi
call   10b0 <X509_get_subject_name@plt>
mov    %rax,%r12
lea    0xd1f(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   10c0 <BIO_printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1180 <X509_NAME_print_ex@plt>
lea    0xbe8(%rip),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   10c0 <BIO_printf@plt>
lea    0xd18(%rip),%rbp
mov    %rbp,%rdi
call   1090 <strlen@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    %eax,%edx
call   1050 <SSL_write@plt>
lea    0x20(%rsp),%rbp
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x400,%edx
call   10f0 <SSL_read@plt>
cltq
movb   $0x0,0x20(%rsp,%rax,1)
lea    0xd00(%rip),%rdi
mov    %rbp,%rsi
call   10a0 <printf@plt>
mov    %rbx,%rdi
call   1070 <SSL_free@plt>
mov    %r13d,%edi
call   10d0 <close@plt>
mov    %r14,%rdi
call   1170 <X509_free@plt>
mov    0x18(%rsp),%rdi
call   11a0 <SSL_CTX_free@plt>
lea    0xcdd(%rip),%rsi
mov    %r15,%rdi
mov    %rsp,%rdx
xor    %eax,%eax
call   10c0 <BIO_printf@plt>
xor    %eax,%eax
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.dest_url = [23 x i8] c"http://r01.cs.ucla.edu\00"
@stdout = global i32 0
@BIO_NOCLOSE = global i32 0
@.str = [44 x i8] c"Could not initialize the OpenSSL library !\0A\00"
@.str.1 = [47 x i8] c"Unable to create a new SSL context structure.\0A\00"
@SSL_OP_NO_SSLv2 = global i32 0
@.str.2 = [46 x i8] c"Successfully made the TCP connection to: %s.\0A\00"
@.str.3 = [46 x i8] c"Error: Could not build a SSL session to: %s.\0A\00"
@.str.4 = [46 x i8] c"Successfully enabled SSL/TLS session to: %s.\0A\00"
@.str.5 = [46 x i8] c"Error: Could not get a certificate from: %s.\0A\00"
@.str.6 = [46 x i8] c"Retrieved the server's certificate from: %s.\0A\00"
@.str.7 = [42 x i8] c"Displaying the certificate subject data:\0A\00"
@.str.8 = [2 x i8] c"\0A\00"
@.str.9 = [32 x i8] c"ID = Group6 Password = 26498294\00"
@.str.10 = [14 x i8] c"Received: %s\0A\00"
@.str.11 = [46 x i8] c"Finished SSL/TLS connection with server: %s.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [23 x i8]
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8*
%14 = alloca [1024 x i8]
%15 = alloca i32
store i32 0, i32* %1
%16 = bitcast [23 x i8]* %2 to i8*
store i32* null, i32** %3
store i32* null, i32** %4
store i32* null, i32** %5
store i32* null, i32** %6
store i32 0, i32* %10
%17 = call i32 (...) @OpenSSL_add_all_algorithms()
%18 = call i32 (...) @ERR_load_BIO_strings()
%19 = call i32 (...) @ERR_load_crypto_strings()
%20 = call i32 (...) @SSL_load_error_strings()
%21 = call i32 (...) @BIO_s_file()
%22 = call i32* @BIO_new(i32 %21)
store i32* %22, i32** %3
%23 = load i32, i32* @stdout
%24 = load i32, i32* @BIO_NOCLOSE
%25 = call i32* @BIO_new_fp(i32 %23, i32 %24)
store i32* %25, i32** %4
%26 = call i64 (...) @SSL_library_init()
%27 = icmp slt i64 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %0
%29 = load i32*, i32** %4
%30 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %29, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
br label %31
31: ; preds = %28, %0
%32 = call i32* (...) @SSLv23_client_method()
store i32* %32, i32** %7
%33 = load i32*, i32** %7
%34 = call i32* @SSL_CTX_new(i32* %33)
store i32* %34, i32** %8
%35 = icmp eq i32* %34, null
br i1 %35, label %36, label %39
36: ; preds = %31
%37 = load i32*, i32** %4
%38 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %37, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
br label %39
39: ; preds = %36, %31
%40 = load i32*, i32** %8
%41 = load i32, i32* @SSL_OP_NO_SSLv2
%42 = call i32 @SSL_CTX_set_options(i32* %40, i32 %41)
%43 = load i32*, i32** %8
%44 = call i32* @SSL_new(i32* %43)
store i32* %44, i32** %9
%45 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 0
%46 = load i32*, i32** %4
%47 = call i32 @create_socket(i8* %45, i32* %46)
store i32 %47, i32* %10
%48 = load i32, i32* %10
%49 = icmp ne i32 %48, 0
br i1 %49, label %50, label %54
50: ; preds = %39
%51 = load i32*, i32** %4
%52 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 0
%53 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %51, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i8* %52)
br label %54
54: ; preds = %50, %39
%55 = load i32*, i32** %9
%56 = load i32, i32* %10
%57 = call i32 @SSL_set_fd(i32* %55, i32 %56)
%58 = load i32*, i32** %9
%59 = call i32 @SSL_connect(i32* %58)
%60 = icmp ne i32 %59, 1
br i1 %60, label %61, label %65
61: ; preds = %54
%62 = load i32*, i32** %4
%63 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 0
%64 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %62, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i8* %63)
br label %69
65: ; preds = %54
%66 = load i32*, i32** %4
%67 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 0
%68 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %66, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i8* %67)
br label %69
69: ; preds = %65, %61
%70 = load i32*, i32** %9
%71 = call i32* @SSL_get_peer_certificate(i32* %70)
store i32* %71, i32** %5
%72 = load i32*, i32** %5
%73 = icmp eq i32* %72, null
br i1 %73, label %74, label %78
74: ; preds = %69
%75 = load i32*, i32** %4
%76 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 0
%77 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %75, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0), i8* %76)
br label %82
78: ; preds = %69
%79 = load i32*, i32** %4
%80 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 0
%81 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %79, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.6, i64 0, i64 0), i8* %80)
br label %82
82: ; preds = %78, %74
%83 = call i32* (...) @X509_NAME_new()
store i32* %83, i32** %6
%84 = load i32*, i32** %5
%85 = call i32* @X509_get_subject_name(i32* %84)
store i32* %85, i32** %6
%86 = load i32*, i32** %4
%87 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %86, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0))
%88 = load i32*, i32** %4
%89 = load i32*, i32** %6
%90 = call i32 @X509_NAME_print_ex(i32* %88, i32* %89, i32 0, i32 0)
%91 = load i32*, i32** %4
%92 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %91, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
store i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0), i8** %13
%93 = load i32*, i32** %9
%94 = load i8*, i8** %13
%95 = load i8*, i8** %13
%96 = call i32 @strlen(i8* %95)
%97 = call i32 @SSL_write(i32* %93, i8* %94, i32 %96)
%98 = load i32*, i32** %9
%99 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%100 = call i32 @SSL_read(i32* %98, i8* %99, i32 1024)
store i32 %100, i32* %15
%101 = load i32, i32* %15
%102 = sext i32 %101 to i64
%103 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 %102
store i8 0, i8* %103
%104 = getelementptr inbounds [1024 x i8], [1024 x i8]* %14, i64 0, i64 0
%105 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i8* %104)
%106 = load i32*, i32** %9
%107 = call i32 @SSL_free(i32* %106)
%108 = load i32, i32* %10
%109 = call i32 @close(i32 %108)
%110 = load i32*, i32** %5
%111 = call i32 @X509_free(i32* %110)
%112 = load i32*, i32** %8
%113 = call i32 @SSL_CTX_free(i32* %112)
%114 = load i32*, i32** %4
%115 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 0
%116 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %114, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.11, i64 0, i64 0), i8* %115)
ret i32 0
}

LLVM IR (-O2):
@__const.main.dest_url = [23 x i8] c"http://r01.cs.ucla.edu\00"
@stdout = global i32 0
@BIO_NOCLOSE = global i32 0
@.str = [44 x i8] c"Could not initialize the OpenSSL library !\0A\00"
@.str.1 = [47 x i8] c"Unable to create a new SSL context structure.\0A\00"
@SSL_OP_NO_SSLv2 = global i32 0
@.str.2 = [46 x i8] c"Successfully made the TCP connection to: %s.\0A\00"
@.str.3 = [46 x i8] c"Error: Could not build a SSL session to: %s.\0A\00"
@.str.4 = [46 x i8] c"Successfully enabled SSL/TLS session to: %s.\0A\00"
@.str.5 = [46 x i8] c"Error: Could not get a certificate from: %s.\0A\00"
@.str.6 = [46 x i8] c"Retrieved the server's certificate from: %s.\0A\00"
@.str.7 = [42 x i8] c"Displaying the certificate subject data:\0A\00"
@.str.8 = [2 x i8] c"\0A\00"
@.str.9 = [32 x i8] c"ID = Group6 Password = 26498294\00"
@.str.10 = [14 x i8] c"Received: %s\0A\00"
@.str.11 = [46 x i8] c"Finished SSL/TLS connection with server: %s.\0A\00"
define i32 @main() {
%1 = alloca [23 x i8]
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [23 x i8], [23 x i8]* %1, i64 0, i64 0
%4 = tail call i32 (...) @OpenSSL_add_all_algorithms()
%5 = tail call i32 (...) @ERR_load_BIO_strings()
%6 = tail call i32 (...) @ERR_load_crypto_strings()
%7 = tail call i32 (...) @SSL_load_error_strings()
%8 = tail call i32 (...) @BIO_s_file()
%9 = tail call i32* @BIO_new(i32 %8)
%10 = load i32, i32* @stdout
%11 = load i32, i32* @BIO_NOCLOSE
%12 = tail call i32* @BIO_new_fp(i32 %10, i32 %11)
%13 = tail call i64 (...) @SSL_library_init()
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %0
%16 = tail call i32 (i32*, i8*, ...) @BIO_printf(i32* %12, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %0
%18 = tail call i32* (...) @SSLv23_client_method()
%19 = tail call i32* @SSL_CTX_new(i32* %18)
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %23
21: ; preds = %17
%22 = tail call i32 (i32*, i8*, ...) @BIO_printf(i32* %12, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
br label %23
23: ; preds = %21, %17
%24 = load i32, i32* @SSL_OP_NO_SSLv2
%25 = tail call i32 @SSL_CTX_set_options(i32* %19, i32 %24)
%26 = tail call i32* @SSL_new(i32* %19)
%27 = call i32 @create_socket(i8* %3, i32* %12)
%28 = icmp eq i32 %27, 0
br i1 %28, label %31, label %29
29: ; preds = %23
%30 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %12, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.2, i64 0, i64 0), i8* %3)
br label %31
31: ; preds = %29, %23
%32 = call i32 @SSL_set_fd(i32* %26, i32 %27)
%33 = call i32 @SSL_connect(i32* %26)
%34 = icmp eq i32 %33, 1
%35 = select i1 %34, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0)
%36 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %12, i8* %35, i8* %3)
%37 = call i32* @SSL_get_peer_certificate(i32* %26)
%38 = icmp eq i32* %37, null
%39 = select i1 %38, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.6, i64 0, i64 0)
%40 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %12, i8* %39, i8* %3)
%41 = call i32* (...) @X509_NAME_new()
%42 = call i32* @X509_get_subject_name(i32* %37)
%43 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %12, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.7, i64 0, i64 0))
%44 = call i32 @X509_NAME_print_ex(i32* %12, i32* %42, i32 0, i32 0)
%45 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%47 = call i32 @strlen(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0))
%48 = call i32 @SSL_write(i32* %26, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0), i32 %47)
%49 = call i32 @SSL_read(i32* %26, i8* %46, i32 1024)
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 %50
store i8 0, i8* %51
%52 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.10, i64 0, i64 0), i8* %46)
%53 = call i32 @SSL_free(i32* %26)
%54 = call i32 @close(i32 %27)
%55 = call i32 @X509_free(i32* %37)
%56 = call i32 @SSL_CTX_free(i32* %19)
%57 = call i32 (i32*, i8*, ...) @BIO_printf(i32* %12, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.11, i64 0, i64 0), i8* %3)
ret i32 0
}