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

/* Variables and functions */
int /*<<< orphan*/ BIO_CLOSE;
int /*<<< orphan*/ BIO_f_ssl();
int /*<<< orphan*/ BIO_free_all(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BIO_new(int /*<<< orphan*/);
int /*<<< orphan*/ *BIO_push(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int BIO_read(int /*<<< orphan*/ *, char *, int);
int /*<<< orphan*/ BIO_s_connect();
int /*<<< orphan*/ BIO_set_conn_hostname(int /*<<< orphan*/ *, char const *);
int /*<<< orphan*/ BIO_set_nbio(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ BIO_set_ssl(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                               int /*<<< orphan*/);
scalar_t__ BIO_should_retry(int /*<<< orphan*/ *);
int BIO_write(int /*<<< orphan*/ *, char *, int);
scalar_t__ ERR_peek_error();
int /*<<< orphan*/ ERR_print_errors_fp(int /*<<< orphan*/);
int EXIT_FAILURE;
int EXIT_SUCCESS;
char *OPENSSL_strdup(char const *);
int /*<<< orphan*/ SSL_CTX_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ SSL_CTX_load_verify_locations(int /*<<< orphan*/ *,
                                                 char const *,
                                                 int /*<<< orphan*/ *);
int /*<<< orphan*/ *SSL_CTX_new(int /*<<< orphan*/);
int /*<<< orphan*/ SSL_CTX_set_verify(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                      int /*<<< orphan*/ *);
int /*<<< orphan*/ SSL_VERIFY_PEER;
int /*<<< orphan*/ *SSL_new(int /*<<< orphan*/ *);
scalar_t__ SSL_set1_host(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ SSL_set_connect_state(int /*<<< orphan*/ *);
int /*<<< orphan*/ TLS_client_method();
int errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
char *strchr(char *, char);
int strlen(char *);
int main(int argc, char *argv[]) {
  const char *hostport = "localhost:4433";
  const char *CAfile = "root.pem";
  char *hostname;
  char *cp;
  BIO *out = NULL;
  char buf[1024 * 10], *p;
  SSL_CTX *ssl_ctx = NULL;
  SSL *ssl;
  BIO *ssl_bio;
  int i, len, off, ret = EXIT_FAILURE;
  if (argc > 1)
    hostport = argv[1];
  if (argc > 2)
    CAfile = argv[2];
  hostname = OPENSSL_strdup(hostport);
  if ((cp = strchr(hostname, ':')) != NULL)
    *cp = 0;
  ssl_ctx = SSL_CTX_new(TLS_client_method());
  SSL_CTX_set_verify(ssl_ctx, SSL_VERIFY_PEER, NULL);
  SSL_CTX_load_verify_locations(ssl_ctx, CAfile, NULL);
  ssl = SSL_new(ssl_ctx);
  SSL_set_connect_state(ssl);
  if (SSL_set1_host(ssl, hostname) <= 0)
    goto err;
  ssl_bio = BIO_new(BIO_f_ssl());
  BIO_set_ssl(ssl_bio, ssl, BIO_CLOSE);
  out = BIO_new(BIO_s_connect());
  BIO_set_conn_hostname(out, hostport);
  BIO_set_nbio(out, 1);
  out = BIO_push(ssl_bio, out);
  p = "GET / HTTP/1.0\r\n\r\n";
  len = strlen(p);
  off = 0;
  for (;;) {
    i = BIO_write(out, &(p[off]), len);
    if (i <= 0) {
      if (BIO_should_retry(out)) {
        fprintf(stderr, "write DELAY\n");
        sleep(1);
        continue;
      } else {
        goto err;
      }
    }
    off += i;
    len -= i;
    if (len <= 0)
      break;
  }
  for (;;) {
    i = BIO_read(out, buf, sizeof(buf));
    if (i == 0)
      break;
    if (i < 0) {
      if (BIO_should_retry(out)) {
        fprintf(stderr, "read DELAY\n");
        sleep(1);
        continue;
      }
      goto err;
    }
    fwrite(buf, 1, i, stdout);
  }
  ret = EXIT_SUCCESS;
  goto done;
err:
  if (ERR_peek_error() == 0) {
    fprintf(stderr, "errno=%d ", errno);
    perror("error");
  } else {
    ERR_print_errors_fp(stderr);
  }
done:
  BIO_free_all(out);
  SSL_CTX_free(ssl_ctx);
  return ret;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2870,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xd20(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xd24(%rip),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x2850(%rbp)
mov    0x2cc7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2870(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1327 <main+0x67>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    133d <main+0x7d>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   10d0 <OPENSSL_strdup@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    $0x3a,%esi
call   10a0 <strchr@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     136d <main+0xad>
mov    -0x30(%rbp),%rax
movb   $0x0,(%rax)
mov    $0x0,%al
call   1030 <TLS_client_method@plt>
mov    %eax,%edi
call   1130 <SSL_CTX_new@plt>
mov    %rax,-0x2850(%rbp)
mov    -0x2850(%rbp),%rdi
mov    0x2c38(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1070 <SSL_CTX_set_verify@plt>
mov    -0x2850(%rbp),%rdi
mov    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1150 <SSL_CTX_load_verify_locations@plt>
mov    -0x2850(%rbp),%rdi
call   10e0 <SSL_new@plt>
mov    %rax,-0x2858(%rbp)
mov    -0x2858(%rbp),%rdi
call   10f0 <SSL_set_connect_state@plt>
mov    -0x2858(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1120 <SSL_set1_host@plt>
cmp    $0x0,%rax
jg     13ed <main+0x12d>
jmp    15ed <main+0x32d>
mov    $0x0,%al
call   10b0 <BIO_f_ssl@plt>
mov    %eax,%edi
call   1140 <BIO_new@plt>
mov    %rax,-0x2860(%rbp)
mov    -0x2860(%rbp),%rdi
mov    -0x2858(%rbp),%rsi
mov    0x2b99(%rip),%rax
mov    (%rax),%edx
call   1160 <BIO_set_ssl@plt>
mov    $0x0,%al
call   10c0 <BIO_s_connect@plt>
mov    %eax,%edi
call   1140 <BIO_new@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1110 <BIO_set_conn_hostname@plt>
mov    -0x38(%rbp),%rdi
mov    $0x1,%esi
call   1040 <BIO_set_nbio@plt>
mov    -0x2860(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1060 <BIO_push@plt>
mov    %rax,-0x38(%rbp)
lea    0xbb2(%rip),%rax
mov    %rax,-0x2848(%rbp)
mov    -0x2848(%rbp),%rdi
call   1090 <strlen@plt>
mov    %eax,-0x2868(%rbp)
movl   $0x0,-0x286c(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x2848(%rbp),%rsi
movslq -0x286c(%rbp),%rax
add    %rax,%rsi
mov    -0x2868(%rbp),%edx
call   11c0 <BIO_write@plt>
mov    %eax,-0x2864(%rbp)
cmpl   $0x0,-0x2864(%rbp)
jg     14fa <main+0x23a>
mov    -0x38(%rbp),%rdi
call   11b0 <BIO_should_retry@plt>
cmp    $0x0,%rax
je     14f5 <main+0x235>
mov    0x2b0a(%rip),%rax
mov    (%rax),%edi
lea    0xb4c(%rip),%rsi
mov    $0x0,%al
call   1100 <fprintf@plt>
mov    $0x1,%edi
call   11e0 <sleep@plt>
jmp    1489 <main+0x1c9>
jmp    15ed <main+0x32d>
mov    -0x2864(%rbp),%eax
add    -0x286c(%rbp),%eax
mov    %eax,-0x286c(%rbp)
mov    -0x2864(%rbp),%ecx
mov    -0x2868(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x2868(%rbp)
cmpl   $0x0,-0x2868(%rbp)
jg     1532 <main+0x272>
jmp    1537 <main+0x277>
jmp    1489 <main+0x1c9>
jmp    153c <main+0x27c>
mov    -0x38(%rbp),%rdi
lea    -0x2840(%rbp),%rsi
mov    $0x2800,%edx
call   1080 <BIO_read@plt>
mov    %eax,-0x2864(%rbp)
cmpl   $0x0,-0x2864(%rbp)
jne    1569 <main+0x2a9>
jmp    15d9 <main+0x319>
cmpl   $0x0,-0x2864(%rbp)
jge    15b4 <main+0x2f4>
mov    -0x38(%rbp),%rdi
call   11b0 <BIO_should_retry@plt>
cmp    $0x0,%rax
je     15af <main+0x2ef>
mov    0x2a50(%rip),%rax
mov    (%rax),%edi
lea    0xa9f(%rip),%rsi
mov    $0x0,%al
call   1100 <fprintf@plt>
mov    $0x1,%edi
call   11e0 <sleep@plt>
jmp    153c <main+0x27c>
jmp    15ed <main+0x32d>
lea    -0x2840(%rbp),%rdi
mov    -0x2864(%rbp),%edx
mov    0x29f8(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   11a0 <fwrite@plt>
jmp    153c <main+0x27c>
mov    0x29d8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2870(%rbp)
jmp    1642 <main+0x382>
mov    $0x0,%al
call   1050 <ERR_peek_error@plt>
cmp    $0x0,%rax
jne    162f <main+0x36f>
mov    0x29db(%rip),%rax
mov    (%rax),%edi
mov    0x29ca(%rip),%rax
mov    (%rax),%edx
lea    0xa2d(%rip),%rsi
mov    $0x0,%al
call   1100 <fprintf@plt>
lea    0xa29(%rip),%rdi
call   1180 <perror@plt>
jmp    163d <main+0x37d>
mov    0x29aa(%rip),%rax
mov    (%rax),%edi
call   11d0 <ERR_print_errors_fp@plt>
jmp    1642 <main+0x382>
mov    -0x38(%rbp),%rdi
call   1190 <BIO_free_all@plt>
mov    -0x2850(%rbp),%rdi
call   1170 <SSL_CTX_free@plt>
mov    -0x2870(%rbp),%eax
add    $0x2870,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x2818,%rsp
mov    0x2cf8(%rip),%rax
lea    0xd30(%rip),%rbx
cmp    $0x2,%edi
jl     12f0 <main+0x30>
mov    0x8(%rsi),%r12
je     12f7 <main+0x37>
mov    0x10(%rsi),%rbx
jmp    12f7 <main+0x37>
lea    0xd09(%rip),%r12
mov    (%rax),%r14d
mov    %r12,%rdi
call   10d0 <OPENSSL_strdup@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    $0x3a,%esi
call   10a0 <strchr@plt>
test   %rax,%rax
je     131a <main+0x5a>
movb   $0x0,(%rax)
xor    %eax,%eax
call   1030 <TLS_client_method@plt>
mov    %eax,%edi
call   1130 <SSL_CTX_new@plt>
mov    %rax,%r15
mov    0x2c96(%rip),%rax
mov    (%rax),%esi
mov    %r15,%rdi
xor    %edx,%edx
call   1070 <SSL_CTX_set_verify@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   1150 <SSL_CTX_load_verify_locations@plt>
mov    %r15,%rdi
call   10e0 <SSL_new@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   10f0 <SSL_set_connect_state@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1120 <SSL_set1_host@plt>
mov    $0x0,%ebp
test   %rax,%rax
jle    14ea <main+0x22a>
mov    %r15,0x8(%rsp)
mov    %r14d,0x4(%rsp)
xor    %eax,%eax
call   10b0 <BIO_f_ssl@plt>
mov    %eax,%edi
call   1140 <BIO_new@plt>
mov    %rax,%rbp
mov    0x2c17(%rip),%rax
mov    (%rax),%edx
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1160 <BIO_set_ssl@plt>
xor    %eax,%eax
call   10c0 <BIO_s_connect@plt>
mov    %eax,%edi
call   1140 <BIO_new@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r12,%rsi
call   1110 <BIO_set_conn_hostname@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1040 <BIO_set_nbio@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1060 <BIO_push@plt>
mov    %rax,%rbp
lea    0xc34(%rip),%rdi
call   1090 <strlen@plt>
mov    %eax,%ebx
mov    0x2bee(%rip),%r15
lea    0xc32(%rip),%r13
xor    %r12d,%r12d
jmp    1407 <main+0x147>
xchg   %ax,%ax
add    %eax,%r12d
sub    %eax,%ebx
jle    145b <main+0x19b>
movslq %r12d,%r14
lea    0xc07(%rip),%rax
add    %rax,%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   11c0 <BIO_write@plt>
test   %eax,%eax
jg     1400 <main+0x140>
mov    %rbp,%rdi
call   11b0 <BIO_should_retry@plt>
test   %rax,%rax
je     14e0 <main+0x220>
mov    (%r15),%edi
mov    %r13,%rsi
xor    %eax,%eax
call   1100 <fprintf@plt>
mov    $0x1,%edi
call   11e0 <sleep@plt>
jmp    1420 <main+0x160>
lea    0x10(%rsp),%rsi
mov    %rbp,%rdi
mov    $0x2800,%edx
call   1080 <BIO_read@plt>
test   %eax,%eax
je     1529 <main+0x269>
lea    0xbbc(%rip),%r12
lea    0x10(%rsp),%rbx
mov    0x2b38(%rip),%r14
jmp    14b6 <main+0x1f6>
nopw   0x0(%rax,%rax,1)
mov    (%r14),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %eax,%edx
call   11a0 <fwrite@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x2800,%edx
call   1080 <BIO_read@plt>
test   %eax,%eax
je     1529 <main+0x269>
test   %eax,%eax
jns    1490 <main+0x1d0>
mov    %rbp,%rdi
call   11b0 <BIO_should_retry@plt>
test   %rax,%rax
je     14e0 <main+0x220>
mov    (%r15),%edi
mov    %r12,%rsi
xor    %eax,%eax
call   1100 <fprintf@plt>
mov    $0x1,%edi
call   11e0 <sleep@plt>
jmp    14a2 <main+0x1e2>
mov    0x4(%rsp),%r14d
mov    0x8(%rsp),%r15
xor    %eax,%eax
call   1050 <ERR_peek_error@plt>
mov    0x2ae8(%rip),%rcx
mov    (%rcx),%edi
test   %rax,%rax
je     153a <main+0x27a>
call   11d0 <ERR_print_errors_fp@plt>
mov    %rbp,%rdi
call   1190 <BIO_free_all@plt>
mov    %r15,%rdi
call   1170 <SSL_CTX_free@plt>
mov    %r14d,%eax
add    $0x2818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2a88(%rip),%rax
mov    (%rax),%r14d
mov    0x8(%rsp),%r15
jmp    1504 <main+0x244>
mov    0x2a97(%rip),%rax
mov    (%rax),%edx
lea    0xafa(%rip),%rsi
xor    %eax,%eax
call   1100 <fprintf@plt>
lea    0xaf6(%rip),%rdi
call   1180 <perror@plt>
jmp    1504 <main+0x244>

LLVM IR (-O0):
@.str = [15 x i8] c"localhost:4433\00"
@.str.1 = [9 x i8] c"root.pem\00"
@EXIT_FAILURE = global i32 0
@SSL_VERIFY_PEER = global i32 0
@BIO_CLOSE = global i32 0
@.str.2 = [19 x i8] c"GET / HTTP/1.0\0D\0A\0D\0A\00"
@stderr = global i32 0
@.str.3 = [13 x i8] c"write DELAY\0A\00"
@.str.4 = [12 x i8] c"read DELAY\0A\00"
@stdout = global i32 0
@EXIT_SUCCESS = global i32 0
@.str.5 = [10 x i8] c"errno=%d \00"
@errno = global i32 0
@.str.6 = [6 x i8] c"error\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca [10240 x i8]
%12 = alloca i8*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i8** %6
store i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8** %7
store i32* null, i32** %10
store i32* null, i32** %13
%20 = load i32, i32* @EXIT_FAILURE
store i32 %20, i32* %19
%21 = load i32, i32* %4
%22 = icmp sgt i32 %21, 1
br i1 %22, label %23, label %27
23: ; preds = %2
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
store i8* %26, i8** %6
br label %27
27: ; preds = %23, %2
%28 = load i32, i32* %4
%29 = icmp sgt i32 %28, 2
br i1 %29, label %30, label %34
30: ; preds = %27
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = load i8*, i8** %32
store i8* %33, i8** %7
br label %34
34: ; preds = %30, %27
%35 = load i8*, i8** %6
%36 = call i8* @OPENSSL_strdup(i8* %35)
store i8* %36, i8** %8
%37 = load i8*, i8** %8
%38 = call i8* @strchr(i8* %37, i8 signext 58)
store i8* %38, i8** %9
%39 = icmp ne i8* %38, null
br i1 %39, label %40, label %42
40: ; preds = %34
%41 = load i8*, i8** %9
store i8 0, i8* %41
br label %42
42: ; preds = %40, %34
%43 = call i32 (...) @TLS_client_method()
%44 = call i32* @SSL_CTX_new(i32 %43)
store i32* %44, i32** %13
%45 = load i32*, i32** %13
%46 = load i32, i32* @SSL_VERIFY_PEER
%47 = call i32 @SSL_CTX_set_verify(i32* %45, i32 %46, i32* null)
%48 = load i32*, i32** %13
%49 = load i8*, i8** %7
%50 = call i32 @SSL_CTX_load_verify_locations(i32* %48, i8* %49, i32* null)
%51 = load i32*, i32** %13
%52 = call i32* @SSL_new(i32* %51)
store i32* %52, i32** %14
%53 = load i32*, i32** %14
%54 = call i32 @SSL_set_connect_state(i32* %53)
%55 = load i32*, i32** %14
%56 = load i8*, i8** %8
%57 = call i64 @SSL_set1_host(i32* %55, i8* %56)
%58 = icmp sle i64 %57, 0
br i1 %58, label %59, label %60
59: ; preds = %42
br label %136
60: ; preds = %42
%61 = call i32 (...) @BIO_f_ssl()
%62 = call i32* @BIO_new(i32 %61)
store i32* %62, i32** %15
%63 = load i32*, i32** %15
%64 = load i32*, i32** %14
%65 = load i32, i32* @BIO_CLOSE
%66 = call i32 @BIO_set_ssl(i32* %63, i32* %64, i32 %65)
%67 = call i32 (...) @BIO_s_connect()
%68 = call i32* @BIO_new(i32 %67)
store i32* %68, i32** %10
%69 = load i32*, i32** %10
%70 = load i8*, i8** %6
%71 = call i32 @BIO_set_conn_hostname(i32* %69, i8* %70)
%72 = load i32*, i32** %10
%73 = call i32 @BIO_set_nbio(i32* %72, i32 1)
%74 = load i32*, i32** %15
%75 = load i32*, i32** %10
%76 = call i32* @BIO_push(i32* %74, i32* %75)
store i32* %76, i32** %10
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8** %12
%77 = load i8*, i8** %12
%78 = call i32 @strlen(i8* %77)
store i32 %78, i32* %17
store i32 0, i32* %18
br label %79
79: ; preds = %108, %93, %60
%80 = load i32*, i32** %10
%81 = load i8*, i8** %12
%82 = load i32, i32* %18
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8, i8* %81, i64 %83
%85 = load i32, i32* %17
%86 = call i32 @BIO_write(i32* %80, i8* %84, i32 %85)
store i32 %86, i32* %16
%87 = load i32, i32* %16
%88 = icmp sle i32 %87, 0
br i1 %88, label %89, label %98
89: ; preds = %79
%90 = load i32*, i32** %10
%91 = call i64 @BIO_should_retry(i32* %90)
%92 = icmp ne i64 %91, 0
br i1 %92, label %93, label %97
93: ; preds = %89
%94 = load i32, i32* @stderr
%95 = call i32 (i32, i8*, ...) @fprintf(i32 %94, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%96 = call i32 @sleep(i32 1)
br label %79
97: ; preds = %89
br label %136
98: ; preds = %79
%99 = load i32, i32* %16
%100 = load i32, i32* %18
%101 = add nsw i32 %100, %99
store i32 %101, i32* %18
%102 = load i32, i32* %16
%103 = load i32, i32* %17
%104 = sub nsw i32 %103, %102
store i32 %104, i32* %17
%105 = load i32, i32* %17
%106 = icmp sle i32 %105, 0
br i1 %106, label %107, label %108
107: ; preds = %98
br label %109
108: ; preds = %98
br label %79
109: ; preds = %107
br label %110
110: ; preds = %129, %124, %109
%111 = load i32*, i32** %10
%112 = getelementptr inbounds [10240 x i8], [10240 x i8]* %11, i64 0, i64 0
%113 = call i32 @BIO_read(i32* %111, i8* %112, i32 10240)
store i32 %113, i32* %16
%114 = load i32, i32* %16
%115 = icmp eq i32 %114, 0
br i1 %115, label %116, label %117
116: ; preds = %110
br label %134
117: ; preds = %110
%118 = load i32, i32* %16
%119 = icmp slt i32 %118, 0
br i1 %119, label %120, label %129
120: ; preds = %117
%121 = load i32*, i32** %10
%122 = call i64 @BIO_should_retry(i32* %121)
%123 = icmp ne i64 %122, 0
br i1 %123, label %124, label %128
124: ; preds = %120
%125 = load i32, i32* @stderr
%126 = call i32 (i32, i8*, ...) @fprintf(i32 %125, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%127 = call i32 @sleep(i32 1)
br label %110
128: ; preds = %120
br label %136
129: ; preds = %117
%130 = getelementptr inbounds [10240 x i8], [10240 x i8]* %11, i64 0, i64 0
%131 = load i32, i32* %16
%132 = load i32, i32* @stdout
%133 = call i32 @fwrite(i8* %130, i32 1, i32 %131, i32 %132)
br label %110
134: ; preds = %116
%135 = load i32, i32* @EXIT_SUCCESS
store i32 %135, i32* %19
br label %148
136: ; preds = %128, %97, %59
%137 = call i64 (...) @ERR_peek_error()
%138 = icmp eq i64 %137, 0
br i1 %138, label %139, label %144
139: ; preds = %136
%140 = load i32, i32* @stderr
%141 = load i32, i32* @errno
%142 = call i32 (i32, i8*, ...) @fprintf(i32 %140, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %141)
%143 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %147
144: ; preds = %136
%145 = load i32, i32* @stderr
%146 = call i32 @ERR_print_errors_fp(i32 %145)
br label %147
147: ; preds = %144, %139
br label %148
148: ; preds = %147, %134
%149 = load i32*, i32** %10
%150 = call i32 @BIO_free_all(i32* %149)
%151 = load i32*, i32** %13
%152 = call i32 @SSL_CTX_free(i32* %151)
%153 = load i32, i32* %19
ret i32 %153
}

LLVM IR (-O2):
@.str = [15 x i8] c"localhost:4433\00"
@.str.1 = [9 x i8] c"root.pem\00"
@EXIT_FAILURE = global i32 0
@SSL_VERIFY_PEER = global i32 0
@BIO_CLOSE = global i32 0
@.str.2 = [19 x i8] c"GET / HTTP/1.0\0D\0A\0D\0A\00"
@stderr = global i32 0
@.str.3 = [13 x i8] c"write DELAY\0A\00"
@.str.4 = [12 x i8] c"read DELAY\0A\00"
@stdout = global i32 0
@EXIT_SUCCESS = global i32 0
@.str.5 = [10 x i8] c"errno=%d \00"
@errno = global i32 0
@.str.6 = [6 x i8] c"error\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [10240 x i8]
%4 = getelementptr inbounds [10240 x i8], [10240 x i8]* %3, i64 0, i64 0
%5 = load i32, i32* @EXIT_FAILURE
%6 = icmp sgt i32 %0, 1
br i1 %6, label %7, label %14
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = icmp eq i32 %0, 2
br i1 %10, label %14, label %11
11: ; preds = %7
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
br label %14
14: ; preds = %2, %11, %7
%15 = phi i8* [ %9, %11 ], [ %9, %7 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), %2 ]
%16 = phi i8* [ %13, %11 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), %7 ], [ getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), %2 ]
%17 = tail call i8* @OPENSSL_strdup(i8* %15)
%18 = tail call i8* @strchr(i8* dereferenceable(1) %17, i8 signext 58)
%19 = icmp eq i8* %18, null
br i1 %19, label %21, label %20
20: ; preds = %14
store i8 0, i8* %18
br label %21
21: ; preds = %20, %14
%22 = tail call i32 (...) @TLS_client_method()
%23 = tail call i32* @SSL_CTX_new(i32 %22)
%24 = load i32, i32* @SSL_VERIFY_PEER
%25 = tail call i32 @SSL_CTX_set_verify(i32* %23, i32 %24, i32* null)
%26 = tail call i32 @SSL_CTX_load_verify_locations(i32* %23, i8* %16, i32* null)
%27 = tail call i32* @SSL_new(i32* %23)
%28 = tail call i32 @SSL_set_connect_state(i32* %27)
%29 = tail call i64 @SSL_set1_host(i32* %27, i8* %17)
%30 = icmp slt i64 %29, 1
br i1 %30, label %84, label %31
31: ; preds = %21
%32 = tail call i32 (...) @BIO_f_ssl()
%33 = tail call i32* @BIO_new(i32 %32)
%34 = load i32, i32* @BIO_CLOSE
%35 = tail call i32 @BIO_set_ssl(i32* %33, i32* %27, i32 %34)
%36 = tail call i32 (...) @BIO_s_connect()
%37 = tail call i32* @BIO_new(i32 %36)
%38 = tail call i32 @BIO_set_conn_hostname(i32* %37, i8* %15)
%39 = tail call i32 @BIO_set_nbio(i32* %37, i32 1)
%40 = tail call i32* @BIO_push(i32* %33, i32* %37)
%41 = tail call i32 @strlen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %42
42: ; preds = %58, %31
%43 = phi i32 [ %61, %58 ], [ %41, %31 ]
%44 = phi i32 [ %60, %58 ], [ 0, %31 ]
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [19 x i8], [19 x i8]* @.str.2, i64 0, i64 %45
%47 = tail call i32 @BIO_write(i32* %40, i8* %46, i32 %43)
%48 = icmp slt i32 %47, 1
br i1 %48, label %49, label %58
49: ; preds = %42, %52
%50 = tail call i64 @BIO_should_retry(i32* %40)
%51 = icmp eq i64 %50, 0
br i1 %51, label %84, label %52
52: ; preds = %49
%53 = load i32, i32* @stderr
%54 = tail call i32 (i32, i8*, ...) @fprintf(i32 %53, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%55 = tail call i32 @sleep(i32 1)
%56 = tail call i32 @BIO_write(i32* %40, i8* %46, i32 %43)
%57 = icmp slt i32 %56, 1
br i1 %57, label %49, label %58
58: ; preds = %52, %42
%59 = phi i32 [ %47, %42 ], [ %56, %52 ]
%60 = add nsw i32 %59, %44
%61 = sub nsw i32 %43, %59
%62 = icmp slt i32 %61, 1
br i1 %62, label %63, label %42
63: ; preds = %58
%64 = call i32 @BIO_read(i32* %40, i8* %4, i32 10240)
%65 = icmp eq i32 %64, 0
br i1 %65, label %82, label %66
66: ; preds = %63, %76
%67 = phi i32 [ %77, %76 ], [ %64, %63 ]
%68 = icmp slt i32 %67, 0
br i1 %68, label %69, label %79
69: ; preds = %66
%70 = call i64 @BIO_should_retry(i32* %40)
%71 = icmp eq i64 %70, 0
br i1 %71, label %84, label %72
72: ; preds = %69
%73 = load i32, i32* @stderr
%74 = call i32 (i32, i8*, ...) @fprintf(i32 %73, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%75 = call i32 @sleep(i32 1)
br label %76
76: ; preds = %72, %79
%77 = call i32 @BIO_read(i32* %40, i8* %4, i32 10240)
%78 = icmp eq i32 %77, 0
br i1 %78, label %82, label %66
79: ; preds = %66
%80 = load i32, i32* @stdout
%81 = call i32 @fwrite(i8* %4, i32 1, i32 %67, i32 %80)
br label %76
82: ; preds = %76, %63
%83 = load i32, i32* @EXIT_SUCCESS
br label %95
84: ; preds = %49, %69, %21
%85 = phi i32* [ null, %21 ], [ %40, %69 ], [ %40, %49 ]
%86 = call i64 (...) @ERR_peek_error()
%87 = icmp eq i64 %86, 0
%88 = load i32, i32* @stderr
br i1 %87, label %89, label %93
89: ; preds = %84
%90 = load i32, i32* @errno
%91 = call i32 (i32, i8*, ...) @fprintf(i32 %88, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %90)
%92 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %95
93: ; preds = %84
%94 = call i32 @ERR_print_errors_fp(i32 %88)
br label %95
95: ; preds = %89, %93, %82
%96 = phi i32* [ %85, %89 ], [ %85, %93 ], [ %40, %82 ]
%97 = phi i32 [ %5, %89 ], [ %5, %93 ], [ %83, %82 ]
%98 = call i32 @BIO_free_all(i32* %96)
%99 = call i32 @SSL_CTX_free(i32* %23)
ret i32 %97
}