#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 in_addr {
  int dummy;
};
struct sockaddr_in {
  struct in_addr sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct hostent {
  scalar_t__ h_addr;
};
typedef int /*<<< orphan*/ srv_addr;
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ SSL_CTX;
typedef int /*<<< orphan*/ SSL;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ ERR_free_strings();
int /*<<< orphan*/ ERR_print_errors_fp(int /*<<< orphan*/);
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ *SSL_CTX_new(int /*<<< orphan*/);
int SSL_connect(int /*<<< orphan*/ *);
int SSL_get_error(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ SSL_library_init();
int /*<<< orphan*/ SSL_load_error_strings();
int /*<<< orphan*/ *SSL_new(int /*<<< orphan*/ *);
int SSL_read(int /*<<< orphan*/ *, char *, int);
int SSL_set_fd(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ SSL_shutdown(int /*<<< orphan*/ *);
int /*<<< orphan*/ SSLv23_client_method();
int /*<<< orphan*/ close(int);
int connect(int, struct sockaddr *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
struct hostent *gethostbyname(char *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  char buf[256];
  int sockfd;
  int err;
  SSL *ssl;
  SSL_CTX *ctx;
  struct hostent *srv_info;
  struct sockaddr_in srv_addr;
  if (argc != 2) {
    fprintf(stderr, "Usage: ./ssl_client <address>\n");
    return 1;
  }
  sockfd = socket(AF_INET, SOCK_STREAM, 0);
  srv_info = gethostbyname(argv[1]);
  if (srv_info == NULL) {
    fprintf(stderr, "No such host!\n");
    return 1;
  }
  srv_addr.sin_family = AF_INET;
  srv_addr.sin_port = htons(995);
  srv_addr.sin_addr = *(struct in_addr *)srv_info->h_addr;
  err = connect(sockfd, (struct sockaddr *)&srv_addr, sizeof(srv_addr));
  if (err == -1) {
    perror("connect");
    return 1;
  }
  SSL_load_error_strings();
  SSL_library_init();
  ctx = SSL_CTX_new(SSLv23_client_method());
  if (ctx == NULL) {
    fprintf(stderr, "Error while making ctx!\n");
    return 1;
  }
  ssl = SSL_new(ctx);
  if (ssl == NULL) {
    ERR_print_errors_fp(stderr);
    return 1;
  }
  err = SSL_set_fd(ssl, sockfd);
  if (!err) {
    ERR_print_errors_fp(stderr);
    return 1;
  }
  err = SSL_connect(ssl);
  if (err <= 0) {
    fprintf(stderr, "SSL_connect ends with code: %d\n",
            SSL_get_error(ssl, err));
    return 1;
  }
  err = SSL_read(ssl, buf, sizeof(buf) - 1);
  if (err <= 0) {
    fprintf(stderr, "SSL_read ends with code: %d\n", SSL_get_error(ssl, err));
    return 1;
  }
  printf("%s\n", buf);
  SSL_shutdown(ssl);
  close(sockfd);
  ERR_free_strings();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     1286 <main+0x46>
mov    0x2d6e(%rip),%rax
mov    (%rax),%edi
lea    0xd8d(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1533 <main+0x2f3>
mov    0x2d5b(%rip),%rax
mov    (%rax),%edi
mov    0x2d3a(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1160 <socket@plt>
mov    %eax,-0x114(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10d0 <gethostbyname@plt>
mov    %rax,-0x130(%rbp)
cmpq   $0x0,-0x130(%rbp)
jne    12ea <main+0xaa>
mov    0x2d0a(%rip),%rax
mov    (%rax),%edi
lea    0xd48(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1533 <main+0x2f3>
mov    0x2cf7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x138(%rbp)
mov    $0x3e3,%edi
call   1060 <htons@plt>
mov    %eax,-0x13c(%rbp)
mov    -0x130(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%eax
mov    %eax,-0x140(%rbp)
mov    -0x114(%rbp),%edi
lea    -0x140(%rbp),%rsi
mov    $0xc,%edx
call   1140 <connect@plt>
mov    %eax,-0x118(%rbp)
cmpl   $0xffffffff,-0x118(%rbp)
jne    135d <main+0x11d>
lea    0xce2(%rip),%rdi
call   1130 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    1533 <main+0x2f3>
mov    $0x0,%al
call   1120 <SSL_load_error_strings@plt>
mov    $0x0,%al
call   1090 <SSL_library_init@plt>
mov    $0x0,%al
call   1040 <SSLv23_client_method@plt>
mov    %eax,%edi
call   1100 <SSL_CTX_new@plt>
mov    %rax,-0x128(%rbp)
cmpq   $0x0,-0x128(%rbp)
jne    13b1 <main+0x171>
mov    0x2c43(%rip),%rax
mov    (%rax),%edi
lea    0xc98(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1533 <main+0x2f3>
mov    -0x128(%rbp),%rdi
call   10b0 <SSL_new@plt>
mov    %rax,-0x120(%rbp)
cmpq   $0x0,-0x120(%rbp)
jne    13ec <main+0x1ac>
mov    0x2bff(%rip),%rax
mov    (%rax),%edi
call   1150 <ERR_print_errors_fp@plt>
movl   $0x1,-0x4(%rbp)
jmp    1533 <main+0x2f3>
mov    -0x120(%rbp),%rdi
mov    -0x114(%rbp),%esi
call   1050 <SSL_set_fd@plt>
mov    %eax,-0x118(%rbp)
cmpl   $0x0,-0x118(%rbp)
jne    142b <main+0x1eb>
mov    0x2bc0(%rip),%rax
mov    (%rax),%edi
call   1150 <ERR_print_errors_fp@plt>
movl   $0x1,-0x4(%rbp)
jmp    1533 <main+0x2f3>
mov    -0x120(%rbp),%rdi
call   1110 <SSL_connect@plt>
mov    %eax,-0x118(%rbp)
cmpl   $0x0,-0x118(%rbp)
jg     148d <main+0x24d>
mov    0x2b87(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x144(%rbp)
mov    -0x120(%rbp),%rdi
mov    -0x118(%rbp),%esi
call   1030 <SSL_get_error@plt>
mov    -0x144(%rbp),%edi
mov    %eax,%edx
lea    0xbd5(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1533 <main+0x2f3>
mov    -0x120(%rbp),%rdi
lea    -0x110(%rbp),%rsi
mov    $0xff,%edx
call   10a0 <SSL_read@plt>
mov    %eax,-0x118(%rbp)
cmpl   $0x0,-0x118(%rbp)
jg     14fb <main+0x2bb>
mov    0x2b19(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x148(%rbp)
mov    -0x120(%rbp),%rdi
mov    -0x118(%rbp),%esi
call   1030 <SSL_get_error@plt>
mov    -0x148(%rbp),%edi
mov    %eax,%edx
lea    0xb87(%rip),%rsi
mov    $0x0,%al
call   10e0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1533 <main+0x2f3>
lea    -0x110(%rbp),%rsi
lea    0xb83(%rip),%rdi
call   1070 <printf@plt>
mov    -0x120(%rbp),%rdi
call   10c0 <SSL_shutdown@plt>
mov    -0x114(%rbp),%edi
call   1080 <close@plt>
mov    $0x0,%al
call   10f0 <ERR_free_strings@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x110,%rsp
cmp    $0x2,%edi
jne    135d <main+0x11d>
mov    %rsi,%rbx
mov    0x2d8a(%rip),%rbp
mov    0x0(%rbp),%edi
mov    0x2d68(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1160 <socket@plt>
mov    %eax,%r14d
mov    0x8(%rbx),%rdi
call   10d0 <gethostbyname@plt>
test   %rax,%rax
je     136f <main+0x12f>
mov    %rax,%rbx
mov    0x0(%rbp),%eax
mov    %eax,0x8(%rsp)
mov    $0x3e3,%edi
call   1060 <htons@plt>
mov    %eax,0x4(%rsp)
mov    (%rbx),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
mov    %rsp,%rsi
mov    %r14d,%edi
mov    $0xc,%edx
call   1140 <connect@plt>
cmp    $0xffffffff,%eax
je     13d7 <main+0x197>
xor    %eax,%eax
call   1120 <SSL_load_error_strings@plt>
xor    %eax,%eax
call   1090 <SSL_library_init@plt>
xor    %eax,%eax
call   1040 <SSLv23_client_method@plt>
mov    %eax,%edi
call   1100 <SSL_CTX_new@plt>
test   %rax,%rax
je     1391 <main+0x151>
mov    %rax,%rdi
call   10b0 <SSL_new@plt>
test   %rax,%rax
je     1381 <main+0x141>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14d,%esi
call   1050 <SSL_set_fd@plt>
test   %eax,%eax
je     1381 <main+0x141>
mov    %rbx,%rdi
call   1110 <SSL_connect@plt>
test   %eax,%eax
jle    13bb <main+0x17b>
lea    0x10(%rsp),%rsi
mov    %rbx,%rdi
mov    $0xff,%edx
call   10a0 <SSL_read@plt>
test   %eax,%eax
jle    13e5 <main+0x1a5>
lea    0xd54(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1070 <printf@plt>
mov    %rbx,%rdi
call   10c0 <SSL_shutdown@plt>
mov    %r14d,%edi
call   1080 <close@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   10f0 <ERR_free_strings@plt>
jmp    13ad <main+0x16d>
mov    0x2c74(%rip),%rax
mov    (%rax),%edi
lea    0xc93(%rip),%rsi
jmp    13a1 <main+0x161>
mov    0x2c62(%rip),%rax
mov    (%rax),%edi
lea    0xca0(%rip),%rsi
jmp    13a1 <main+0x161>
mov    0x2c50(%rip),%rax
mov    (%rax),%edi
call   1150 <ERR_print_errors_fp@plt>
jmp    13a8 <main+0x168>
mov    0x2c40(%rip),%rax
mov    (%rax),%edi
lea    0xc95(%rip),%rsi
xor    %eax,%eax
call   10e0 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x110,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    0x2c16(%rip),%rcx
mov    (%rcx),%ebp
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <SSL_get_error@plt>
lea    0xc7a(%rip),%rsi
jmp    13ff <main+0x1bf>
lea    0xc50(%rip),%rdi
call   1130 <perror@plt>
jmp    13a8 <main+0x168>
mov    0x2bec(%rip),%rcx
mov    (%rcx),%ebp
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <SSL_get_error@plt>
lea    0xc70(%rip),%rsi
mov    %ebp,%edi
mov    %eax,%edx
xor    %eax,%eax
call   10e0 <fprintf@plt>
jmp    13a8 <main+0x168>

LLVM IR (-O0):
%struct.hostent = type { i64 }
%struct.sockaddr_in = type { %struct.in_addr, i32, i32 }
%struct.in_addr = type { i32 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [31 x i8] c"Usage: ./ssl_client <address>\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [15 x i8] c"No such host!\0A\00"
@.str.2 = [8 x i8] c"connect\00"
@.str.3 = [25 x i8] c"Error while making ctx!\0A\00"
@.str.4 = [32 x i8] c"SSL_connect ends with code: %d\0A\00"
@.str.5 = [29 x i8] c"SSL_read ends with code: %d\0A\00"
@.str.6 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [256 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca %struct.hostent*
%12 = alloca %struct.sockaddr_in
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 2
br i1 %14, label %15, label %18
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = call i32 (i32, i8*, ...) @fprintf(i32 %16, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %108
18: ; preds = %2
%19 = load i32, i32* @AF_INET
%20 = load i32, i32* @SOCK_STREAM
%21 = call i32 @socket(i32 %19, i32 %20, i32 0)
store i32 %21, i32* %7
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call %struct.hostent* @gethostbyname(i8* %24)
store %struct.hostent* %25, %struct.hostent** %11
%26 = load %struct.hostent*, %struct.hostent** %11
%27 = icmp eq %struct.hostent* %26, null
br i1 %27, label %28, label %31
28: ; preds = %18
%29 = load i32, i32* @stderr
%30 = call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %3
br label %108
31: ; preds = %18
%32 = load i32, i32* @AF_INET
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 2
store i32 %32, i32* %33
%34 = call i32 @htons(i32 995)
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 1
store i32 %34, i32* %35
%36 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 0
%37 = load %struct.hostent*, %struct.hostent** %11
%38 = getelementptr inbounds %struct.hostent, %struct.hostent* %37, i32 0, i32 0
%39 = load i64, i64* %38
%40 = inttoptr i64 %39 to %struct.in_addr*
%41 = bitcast %struct.in_addr* %36 to i8*
%42 = bitcast %struct.in_addr* %40 to i8*
%43 = load i32, i32* %7
%44 = bitcast %struct.sockaddr_in* %12 to %struct.sockaddr*
%45 = call i32 @connect(i32 %43, %struct.sockaddr* %44, i32 12)
store i32 %45, i32* %8
%46 = load i32, i32* %8
%47 = icmp eq i32 %46, -1
br i1 %47, label %48, label %50
48: ; preds = %31
%49 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %108
50: ; preds = %31
%51 = call i32 (...) @SSL_load_error_strings()
%52 = call i32 (...) @SSL_library_init()
%53 = call i32 (...) @SSLv23_client_method()
%54 = call i32* @SSL_CTX_new(i32 %53)
store i32* %54, i32** %10
%55 = load i32*, i32** %10
%56 = icmp eq i32* %55, null
br i1 %56, label %57, label %60
57: ; preds = %50
%58 = load i32, i32* @stderr
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %58, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
store i32 1, i32* %3
br label %108
60: ; preds = %50
%61 = load i32*, i32** %10
%62 = call i32* @SSL_new(i32* %61)
store i32* %62, i32** %9
%63 = load i32*, i32** %9
%64 = icmp eq i32* %63, null
br i1 %64, label %65, label %68
65: ; preds = %60
%66 = load i32, i32* @stderr
%67 = call i32 @ERR_print_errors_fp(i32 %66)
store i32 1, i32* %3
br label %108
68: ; preds = %60
%69 = load i32*, i32** %9
%70 = load i32, i32* %7
%71 = call i32 @SSL_set_fd(i32* %69, i32 %70)
store i32 %71, i32* %8
%72 = load i32, i32* %8
%73 = icmp ne i32 %72, 0
br i1 %73, label %77, label %74
74: ; preds = %68
%75 = load i32, i32* @stderr
%76 = call i32 @ERR_print_errors_fp(i32 %75)
store i32 1, i32* %3
br label %108
77: ; preds = %68
%78 = load i32*, i32** %9
%79 = call i32 @SSL_connect(i32* %78)
store i32 %79, i32* %8
%80 = load i32, i32* %8
%81 = icmp sle i32 %80, 0
br i1 %81, label %82, label %88
82: ; preds = %77
%83 = load i32, i32* @stderr
%84 = load i32*, i32** %9
%85 = load i32, i32* %8
%86 = call i32 @SSL_get_error(i32* %84, i32 %85)
%87 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i32 %86)
store i32 1, i32* %3
br label %108
88: ; preds = %77
%89 = load i32*, i32** %9
%90 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%91 = call i32 @SSL_read(i32* %89, i8* %90, i32 255)
store i32 %91, i32* %8
%92 = load i32, i32* %8
%93 = icmp sle i32 %92, 0
br i1 %93, label %94, label %100
94: ; preds = %88
%95 = load i32, i32* @stderr
%96 = load i32*, i32** %9
%97 = load i32, i32* %8
%98 = call i32 @SSL_get_error(i32* %96, i32 %97)
%99 = call i32 (i32, i8*, ...) @fprintf(i32 %95, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i32 %98)
store i32 1, i32* %3
br label %108
100: ; preds = %88
%101 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%102 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %101)
%103 = load i32*, i32** %9
%104 = call i32 @SSL_shutdown(i32* %103)
%105 = load i32, i32* %7
%106 = call i32 @close(i32 %105)
%107 = call i32 (...) @ERR_free_strings()
store i32 0, i32* %3
br label %108
108: ; preds = %100, %94, %82, %74, %65, %57, %48, %28, %15
%109 = load i32, i32* %3
ret i32 %109
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.in_addr, i32, i32 }
%struct.in_addr = type { i32 }
%struct.hostent = type { i64 }
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [31 x i8] c"Usage: ./ssl_client <address>\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.1 = [15 x i8] c"No such host!\0A\00"
@.str.2 = [8 x i8] c"connect\00"
@.str.3 = [25 x i8] c"Error while making ctx!\0A\00"
@.str.4 = [32 x i8] c"SSL_connect ends with code: %d\0A\00"
@.str.5 = [29 x i8] c"SSL_read ends with code: %d\0A\00"
@.str.6 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = alloca %struct.sockaddr_in
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = bitcast %struct.sockaddr_in* %4 to i8*
%7 = icmp eq i32 %0, 2
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %77
11: ; preds = %2
%12 = load i32, i32* @AF_INET
%13 = load i32, i32* @SOCK_STREAM
%14 = tail call i32 @socket(i32 %12, i32 %13, i32 0)
%15 = getelementptr inbounds i8*, i8** %1, i64 1
%16 = load i8*, i8** %15
%17 = tail call %struct.hostent* @gethostbyname(i8* %16)
%18 = icmp eq %struct.hostent* %17, null
br i1 %18, label %19, label %22
19: ; preds = %11
%20 = load i32, i32* @stderr
%21 = tail call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
br label %77
22: ; preds = %11
%23 = load i32, i32* @AF_INET
%24 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %23, i32* %24
%25 = tail call i32 @htons(i32 995)
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
store i32 %25, i32* %26
%27 = getelementptr inbounds %struct.hostent, %struct.hostent* %17, i64 0, i32 0
%28 = load i64, i64* %27
%29 = inttoptr i64 %28 to i32*
%30 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0, i32 0
%31 = load i32, i32* %29
store i32 %31, i32* %30
%32 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%33 = call i32 @connect(i32 %14, %struct.sockaddr* %32, i32 12)
%34 = icmp eq i32 %33, -1
br i1 %34, label %35, label %37
35: ; preds = %22
%36 = call i32 @perror(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0))
br label %77
37: ; preds = %22
%38 = call i32 (...) @SSL_load_error_strings()
%39 = call i32 (...) @SSL_library_init()
%40 = call i32 (...) @SSLv23_client_method()
%41 = call i32* @SSL_CTX_new(i32 %40)
%42 = icmp eq i32* %41, null
br i1 %42, label %43, label %46
43: ; preds = %37
%44 = load i32, i32* @stderr
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
br label %77
46: ; preds = %37
%47 = call i32* @SSL_new(i32* %41)
%48 = icmp eq i32* %47, null
br i1 %48, label %49, label %52
49: ; preds = %46
%50 = load i32, i32* @stderr
%51 = call i32 @ERR_print_errors_fp(i32 %50)
br label %77
52: ; preds = %46
%53 = call i32 @SSL_set_fd(i32* %47, i32 %14)
%54 = icmp eq i32 %53, 0
br i1 %54, label %55, label %58
55: ; preds = %52
%56 = load i32, i32* @stderr
%57 = call i32 @ERR_print_errors_fp(i32 %56)
br label %77
58: ; preds = %52
%59 = call i32 @SSL_connect(i32* %47)
%60 = icmp slt i32 %59, 1
br i1 %60, label %61, label %65
61: ; preds = %58
%62 = load i32, i32* @stderr
%63 = call i32 @SSL_get_error(i32* %47, i32 %59)
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %62, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0), i32 %63)
br label %77
65: ; preds = %58
%66 = call i32 @SSL_read(i32* %47, i8* %5, i32 255)
%67 = icmp slt i32 %66, 1
br i1 %67, label %68, label %72
68: ; preds = %65
%69 = load i32, i32* @stderr
%70 = call i32 @SSL_get_error(i32* %47, i32 %66)
%71 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.5, i64 0, i64 0), i32 %70)
br label %77
72: ; preds = %65
%73 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %5)
%74 = call i32 @SSL_shutdown(i32* %47)
%75 = call i32 @close(i32 %14)
%76 = call i32 (...) @ERR_free_strings()
br label %77
77: ; preds = %72, %68, %61, %55, %49, %43, %35, %19, %8
%78 = phi i32 [ 1, %8 ], [ 1, %19 ], [ 1, %35 ], [ 1, %43 ], [ 1, %49 ], [ 1, %61 ], [ 1, %68 ], [ 0, %72 ], [ 1, %55 ]
ret i32 %78
}