#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*/ *);
char *BIO_get_conn_hostname(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;
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 const *);
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;
int strlen(char *);
int main(int argc, char *argv[]) {
  const char *hostport = "localhost:4433";
  const char *CAfile = "root.pem";
  const 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];
  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);
  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);
  hostname = BIO_get_conn_hostname(out);
  if (!hostname || SSL_set1_host(ssl, hostname) <= 0)
    goto err;
  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    0xd30(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xd34(%rip),%rax
mov    %rax,-0x20(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x2850(%rbp)
mov    0x2cd7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2870(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1317 <main+0x67>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    132d <main+0x7d>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    $0x0,%al
call   1030 <TLS_client_method@plt>
mov    %eax,%edi
call   1120 <SSL_CTX_new@plt>
mov    %rax,-0x2850(%rbp)
mov    -0x2850(%rbp),%rdi
mov    0x2c78(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%edx
call   1080 <SSL_CTX_set_verify@plt>
mov    -0x2850(%rbp),%rdi
mov    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
call   1140 <SSL_CTX_load_verify_locations@plt>
mov    -0x2850(%rbp),%rdi
call   10d0 <SSL_new@plt>
mov    %rax,-0x2858(%rbp)
mov    -0x2858(%rbp),%rdi
call   10e0 <SSL_set_connect_state@plt>
mov    $0x0,%al
call   10b0 <BIO_f_ssl@plt>
mov    %eax,%edi
call   1130 <BIO_new@plt>
mov    %rax,-0x2860(%rbp)
mov    -0x2860(%rbp),%rdi
mov    -0x2858(%rbp),%rsi
mov    0x2bf8(%rip),%rax
mov    (%rax),%edx
call   1150 <BIO_set_ssl@plt>
mov    $0x0,%al
call   10c0 <BIO_s_connect@plt>
mov    %eax,%edi
call   1130 <BIO_new@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1100 <BIO_set_conn_hostname@plt>
mov    -0x38(%rbp),%rdi
call   1060 <BIO_get_conn_hostname@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1410 <main+0x160>
mov    -0x2858(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1110 <SSL_set1_host@plt>
cmp    $0x0,%rax
jg     1415 <main+0x165>
jmp    15c5 <main+0x315>
mov    -0x38(%rbp),%rdi
mov    $0x1,%esi
call   1040 <BIO_set_nbio@plt>
mov    -0x2860(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1070 <BIO_push@plt>
mov    %rax,-0x38(%rbp)
lea    0xbda(%rip),%rax
mov    %rax,-0x2848(%rbp)
mov    -0x2848(%rbp),%rdi
call   10a0 <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   11b0 <BIO_write@plt>
mov    %eax,-0x2864(%rbp)
cmpl   $0x0,-0x2864(%rbp)
jg     14d2 <main+0x222>
mov    -0x38(%rbp),%rdi
call   11a0 <BIO_should_retry@plt>
cmp    $0x0,%rax
je     14cd <main+0x21d>
mov    0x2b32(%rip),%rax
mov    (%rax),%edi
lea    0xb74(%rip),%rsi
mov    $0x0,%al
call   10f0 <fprintf@plt>
mov    $0x1,%edi
call   11d0 <sleep@plt>
jmp    1461 <main+0x1b1>
jmp    15c5 <main+0x315>
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     150a <main+0x25a>
jmp    150f <main+0x25f>
jmp    1461 <main+0x1b1>
jmp    1514 <main+0x264>
mov    -0x38(%rbp),%rdi
lea    -0x2840(%rbp),%rsi
mov    $0x2800,%edx
call   1090 <BIO_read@plt>
mov    %eax,-0x2864(%rbp)
cmpl   $0x0,-0x2864(%rbp)
jne    1541 <main+0x291>
jmp    15b1 <main+0x301>
cmpl   $0x0,-0x2864(%rbp)
jge    158c <main+0x2dc>
mov    -0x38(%rbp),%rdi
call   11a0 <BIO_should_retry@plt>
cmp    $0x0,%rax
je     1587 <main+0x2d7>
mov    0x2a78(%rip),%rax
mov    (%rax),%edi
lea    0xac7(%rip),%rsi
mov    $0x0,%al
call   10f0 <fprintf@plt>
mov    $0x1,%edi
call   11d0 <sleep@plt>
jmp    1514 <main+0x264>
jmp    15c5 <main+0x315>
lea    -0x2840(%rbp),%rdi
mov    -0x2864(%rbp),%edx
mov    0x2a20(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%esi
call   1190 <fwrite@plt>
jmp    1514 <main+0x264>
mov    0x2a00(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2870(%rbp)
jmp    161a <main+0x36a>
mov    $0x0,%al
call   1050 <ERR_peek_error@plt>
cmp    $0x0,%rax
jne    1607 <main+0x357>
mov    0x2a03(%rip),%rax
mov    (%rax),%edi
mov    0x29f2(%rip),%rax
mov    (%rax),%edx
lea    0xa55(%rip),%rsi
mov    $0x0,%al
call   10f0 <fprintf@plt>
lea    0xa51(%rip),%rdi
call   1170 <perror@plt>
jmp    1615 <main+0x365>
mov    0x29d2(%rip),%rax
mov    (%rax),%edi
call   11c0 <ERR_print_errors_fp@plt>
jmp    161a <main+0x36a>
mov    -0x38(%rbp),%rdi
call   1180 <BIO_free_all@plt>
mov    -0x2850(%rbp),%rdi
call   1160 <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    0x2d08(%rip),%rax
lea    0xd40(%rip),%rbx
cmp    $0x2,%edi
jl     12e0 <main+0x30>
mov    0x8(%rsi),%r12
je     12e7 <main+0x37>
mov    0x10(%rsi),%rbx
jmp    12e7 <main+0x37>
lea    0xd19(%rip),%r12
mov    (%rax),%r14d
xor    %eax,%eax
call   1030 <TLS_client_method@plt>
mov    %eax,%edi
call   1120 <SSL_CTX_new@plt>
mov    %rax,%r15
mov    0x2cc6(%rip),%rax
mov    (%rax),%esi
mov    %r15,%rdi
xor    %edx,%edx
call   1080 <SSL_CTX_set_verify@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %edx,%edx
call   1140 <SSL_CTX_load_verify_locations@plt>
mov    %r15,%rdi
call   10d0 <SSL_new@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   10e0 <SSL_set_connect_state@plt>
xor    %eax,%eax
call   10b0 <BIO_f_ssl@plt>
mov    %eax,%edi
call   1130 <BIO_new@plt>
mov    %rax,%r13
mov    0x2c6a(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
mov    %rbx,%rsi
call   1150 <BIO_set_ssl@plt>
xor    %eax,%eax
call   10c0 <BIO_s_connect@plt>
mov    %eax,%edi
call   1130 <BIO_new@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %r12,%rsi
call   1100 <BIO_set_conn_hostname@plt>
mov    %rbp,%rdi
call   1060 <BIO_get_conn_hostname@plt>
test   %rax,%rax
je     14cf <main+0x21f>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1110 <SSL_set1_host@plt>
test   %rax,%rax
jle    14cf <main+0x21f>
mov    %r15,0x8(%rsp)
mov    %r14d,0x4(%rsp)
mov    %rbp,%rdi
mov    $0x1,%esi
call   1040 <BIO_set_nbio@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
call   1070 <BIO_push@plt>
mov    %rax,%rbp
lea    0xc58(%rip),%rdi
call   10a0 <strlen@plt>
mov    %eax,%ebx
mov    0x2c12(%rip),%r12
lea    0xc56(%rip),%r13
xor    %r15d,%r15d
jmp    13e7 <main+0x137>
nopw   0x0(%rax,%rax,1)
add    %eax,%r15d
sub    %eax,%ebx
jle    143c <main+0x18c>
movslq %r15d,%r14
lea    0xc27(%rip),%rax
add    %rax,%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   11b0 <BIO_write@plt>
test   %eax,%eax
jg     13e0 <main+0x130>
mov    %rbp,%rdi
call   11a0 <BIO_should_retry@plt>
test   %rax,%rax
je     14c5 <main+0x215>
mov    (%r12),%edi
mov    %r13,%rsi
xor    %eax,%eax
call   10f0 <fprintf@plt>
mov    $0x1,%edi
call   11d0 <sleep@plt>
jmp    1400 <main+0x150>
lea    0x10(%rsp),%rsi
mov    %rbp,%rdi
mov    $0x2800,%edx
call   1090 <BIO_read@plt>
test   %eax,%eax
je     1533 <main+0x283>
lea    0xbdb(%rip),%r14
lea    0x10(%rsp),%rbx
mov    0x2b57(%rip),%r15
jmp    149a <main+0x1ea>
nopl   0x0(%rax,%rax,1)
mov    (%r15),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %eax,%edx
call   1190 <fwrite@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    $0x2800,%edx
call   1090 <BIO_read@plt>
test   %eax,%eax
je     1533 <main+0x283>
test   %eax,%eax
jns    1470 <main+0x1c0>
mov    %rbp,%rdi
call   11a0 <BIO_should_retry@plt>
test   %rax,%rax
je     14c5 <main+0x215>
mov    (%r12),%edi
mov    %r14,%rsi
xor    %eax,%eax
call   10f0 <fprintf@plt>
mov    $0x1,%edi
call   11d0 <sleep@plt>
jmp    1482 <main+0x1d2>
mov    0x4(%rsp),%r14d
mov    0x8(%rsp),%r15
xor    %eax,%eax
call   1050 <ERR_peek_error@plt>
mov    0x2b03(%rip),%rcx
mov    (%rcx),%edi
test   %rax,%rax
je     150e <main+0x25e>
call   11c0 <ERR_print_errors_fp@plt>
mov    %rbp,%rdi
call   1180 <BIO_free_all@plt>
mov    %r15,%rdi
call   1160 <SSL_CTX_free@plt>
mov    %r14d,%eax
add    $0x2818,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2ac3(%rip),%rax
mov    (%rax),%edx
lea    0xb26(%rip),%rsi
xor    %eax,%eax
call   10f0 <fprintf@plt>
lea    0xb22(%rip),%rdi
call   1170 <perror@plt>
jmp    14e9 <main+0x239>
mov    0x2a7e(%rip),%rax
mov    (%rax),%r14d
mov    0x8(%rsp),%r15
jmp    14e9 <main+0x239>

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 = call i32 (...) @TLS_client_method()
%36 = call i32* @SSL_CTX_new(i32 %35)
store i32* %36, i32** %13
%37 = load i32*, i32** %13
%38 = load i32, i32* @SSL_VERIFY_PEER
%39 = call i32 @SSL_CTX_set_verify(i32* %37, i32 %38, i32* null)
%40 = load i32*, i32** %13
%41 = load i8*, i8** %7
%42 = call i32 @SSL_CTX_load_verify_locations(i32* %40, i8* %41, i32* null)
%43 = load i32*, i32** %13
%44 = call i32* @SSL_new(i32* %43)
store i32* %44, i32** %14
%45 = load i32*, i32** %14
%46 = call i32 @SSL_set_connect_state(i32* %45)
%47 = call i32 (...) @BIO_f_ssl()
%48 = call i32* @BIO_new(i32 %47)
store i32* %48, i32** %15
%49 = load i32*, i32** %15
%50 = load i32*, i32** %14
%51 = load i32, i32* @BIO_CLOSE
%52 = call i32 @BIO_set_ssl(i32* %49, i32* %50, i32 %51)
%53 = call i32 (...) @BIO_s_connect()
%54 = call i32* @BIO_new(i32 %53)
store i32* %54, i32** %10
%55 = load i32*, i32** %10
%56 = load i8*, i8** %6
%57 = call i32 @BIO_set_conn_hostname(i32* %55, i8* %56)
%58 = load i32*, i32** %10
%59 = call i8* @BIO_get_conn_hostname(i32* %58)
store i8* %59, i8** %8
%60 = load i8*, i8** %8
%61 = icmp ne i8* %60, null
br i1 %61, label %62, label %67
62: ; preds = %34
%63 = load i32*, i32** %14
%64 = load i8*, i8** %8
%65 = call i64 @SSL_set1_host(i32* %63, i8* %64)
%66 = icmp sle i64 %65, 0
br i1 %66, label %67, label %68
67: ; preds = %62, %34
br label %133
68: ; preds = %62
%69 = load i32*, i32** %10
%70 = call i32 @BIO_set_nbio(i32* %69, i32 1)
%71 = load i32*, i32** %15
%72 = load i32*, i32** %10
%73 = call i32* @BIO_push(i32* %71, i32* %72)
store i32* %73, i32** %10
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8** %12
%74 = load i8*, i8** %12
%75 = call i32 @strlen(i8* %74)
store i32 %75, i32* %17
store i32 0, i32* %18
br label %76
76: ; preds = %105, %90, %68
%77 = load i32*, i32** %10
%78 = load i8*, i8** %12
%79 = load i32, i32* %18
%80 = sext i32 %79 to i64
%81 = getelementptr inbounds i8, i8* %78, i64 %80
%82 = load i32, i32* %17
%83 = call i32 @BIO_write(i32* %77, i8* %81, i32 %82)
store i32 %83, i32* %16
%84 = load i32, i32* %16
%85 = icmp sle i32 %84, 0
br i1 %85, label %86, label %95
86: ; preds = %76
%87 = load i32*, i32** %10
%88 = call i64 @BIO_should_retry(i32* %87)
%89 = icmp ne i64 %88, 0
br i1 %89, label %90, label %94
90: ; preds = %86
%91 = load i32, i32* @stderr
%92 = call i32 (i32, i8*, ...) @fprintf(i32 %91, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%93 = call i32 @sleep(i32 1)
br label %76
94: ; preds = %86
br label %133
95: ; preds = %76
%96 = load i32, i32* %16
%97 = load i32, i32* %18
%98 = add nsw i32 %97, %96
store i32 %98, i32* %18
%99 = load i32, i32* %16
%100 = load i32, i32* %17
%101 = sub nsw i32 %100, %99
store i32 %101, i32* %17
%102 = load i32, i32* %17
%103 = icmp sle i32 %102, 0
br i1 %103, label %104, label %105
104: ; preds = %95
br label %106
105: ; preds = %95
br label %76
106: ; preds = %104
br label %107
107: ; preds = %126, %121, %106
%108 = load i32*, i32** %10
%109 = getelementptr inbounds [10240 x i8], [10240 x i8]* %11, i64 0, i64 0
%110 = call i32 @BIO_read(i32* %108, i8* %109, i32 10240)
store i32 %110, i32* %16
%111 = load i32, i32* %16
%112 = icmp eq i32 %111, 0
br i1 %112, label %113, label %114
113: ; preds = %107
br label %131
114: ; preds = %107
%115 = load i32, i32* %16
%116 = icmp slt i32 %115, 0
br i1 %116, label %117, label %126
117: ; preds = %114
%118 = load i32*, i32** %10
%119 = call i64 @BIO_should_retry(i32* %118)
%120 = icmp ne i64 %119, 0
br i1 %120, label %121, label %125
121: ; preds = %117
%122 = load i32, i32* @stderr
%123 = call i32 (i32, i8*, ...) @fprintf(i32 %122, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%124 = call i32 @sleep(i32 1)
br label %107
125: ; preds = %117
br label %133
126: ; preds = %114
%127 = getelementptr inbounds [10240 x i8], [10240 x i8]* %11, i64 0, i64 0
%128 = load i32, i32* %16
%129 = load i32, i32* @stdout
%130 = call i32 @fwrite(i8* %127, i32 1, i32 %128, i32 %129)
br label %107
131: ; preds = %113
%132 = load i32, i32* @EXIT_SUCCESS
store i32 %132, i32* %19
br label %145
133: ; preds = %125, %94, %67
%134 = call i64 (...) @ERR_peek_error()
%135 = icmp eq i64 %134, 0
br i1 %135, label %136, label %141
136: ; preds = %133
%137 = load i32, i32* @stderr
%138 = load i32, i32* @errno
%139 = call i32 (i32, i8*, ...) @fprintf(i32 %137, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %138)
%140 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %144
141: ; preds = %133
%142 = load i32, i32* @stderr
%143 = call i32 @ERR_print_errors_fp(i32 %142)
br label %144
144: ; preds = %141, %136
br label %145
145: ; preds = %144, %131
%146 = load i32*, i32** %10
%147 = call i32 @BIO_free_all(i32* %146)
%148 = load i32*, i32** %13
%149 = call i32 @SSL_CTX_free(i32* %148)
%150 = load i32, i32* %19
ret i32 %150
}

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 i32 (...) @TLS_client_method()
%18 = tail call i32* @SSL_CTX_new(i32 %17)
%19 = load i32, i32* @SSL_VERIFY_PEER
%20 = tail call i32 @SSL_CTX_set_verify(i32* %18, i32 %19, i32* null)
%21 = tail call i32 @SSL_CTX_load_verify_locations(i32* %18, i8* %16, i32* null)
%22 = tail call i32* @SSL_new(i32* %18)
%23 = tail call i32 @SSL_set_connect_state(i32* %22)
%24 = tail call i32 (...) @BIO_f_ssl()
%25 = tail call i32* @BIO_new(i32 %24)
%26 = load i32, i32* @BIO_CLOSE
%27 = tail call i32 @BIO_set_ssl(i32* %25, i32* %22, i32 %26)
%28 = tail call i32 (...) @BIO_s_connect()
%29 = tail call i32* @BIO_new(i32 %28)
%30 = tail call i32 @BIO_set_conn_hostname(i32* %29, i8* %15)
%31 = tail call i8* @BIO_get_conn_hostname(i32* %29)
%32 = icmp eq i8* %31, null
br i1 %32, label %82, label %33
33: ; preds = %14
%34 = tail call i64 @SSL_set1_host(i32* %22, i8* %31)
%35 = icmp slt i64 %34, 1
br i1 %35, label %82, label %36
36: ; preds = %33
%37 = tail call i32 @BIO_set_nbio(i32* %29, i32 1)
%38 = tail call i32* @BIO_push(i32* %25, i32* %29)
%39 = tail call i32 @strlen(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %40
40: ; preds = %56, %36
%41 = phi i32 [ %59, %56 ], [ %39, %36 ]
%42 = phi i32 [ %58, %56 ], [ 0, %36 ]
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds [19 x i8], [19 x i8]* @.str.2, i64 0, i64 %43
%45 = tail call i32 @BIO_write(i32* %38, i8* %44, i32 %41)
%46 = icmp slt i32 %45, 1
br i1 %46, label %47, label %56
47: ; preds = %40, %50
%48 = tail call i64 @BIO_should_retry(i32* %38)
%49 = icmp eq i64 %48, 0
br i1 %49, label %82, label %50
50: ; preds = %47
%51 = load i32, i32* @stderr
%52 = tail call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%53 = tail call i32 @sleep(i32 1)
%54 = tail call i32 @BIO_write(i32* %38, i8* %44, i32 %41)
%55 = icmp slt i32 %54, 1
br i1 %55, label %47, label %56
56: ; preds = %50, %40
%57 = phi i32 [ %45, %40 ], [ %54, %50 ]
%58 = add nsw i32 %57, %42
%59 = sub nsw i32 %41, %57
%60 = icmp slt i32 %59, 1
br i1 %60, label %61, label %40
61: ; preds = %56
%62 = call i32 @BIO_read(i32* %38, i8* %4, i32 10240)
%63 = icmp eq i32 %62, 0
br i1 %63, label %80, label %64
64: ; preds = %61, %74
%65 = phi i32 [ %75, %74 ], [ %62, %61 ]
%66 = icmp slt i32 %65, 0
br i1 %66, label %67, label %77
67: ; preds = %64
%68 = call i64 @BIO_should_retry(i32* %38)
%69 = icmp eq i64 %68, 0
br i1 %69, label %82, label %70
70: ; preds = %67
%71 = load i32, i32* @stderr
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%73 = call i32 @sleep(i32 1)
br label %74
74: ; preds = %70, %77
%75 = call i32 @BIO_read(i32* %38, i8* %4, i32 10240)
%76 = icmp eq i32 %75, 0
br i1 %76, label %80, label %64
77: ; preds = %64
%78 = load i32, i32* @stdout
%79 = call i32 @fwrite(i8* %4, i32 1, i32 %65, i32 %78)
br label %74
80: ; preds = %74, %61
%81 = load i32, i32* @EXIT_SUCCESS
br label %93
82: ; preds = %47, %67, %14, %33
%83 = phi i32* [ %29, %33 ], [ %29, %14 ], [ %38, %67 ], [ %38, %47 ]
%84 = call i64 (...) @ERR_peek_error()
%85 = icmp eq i64 %84, 0
%86 = load i32, i32* @stderr
br i1 %85, label %87, label %91
87: ; preds = %82
%88 = load i32, i32* @errno
%89 = call i32 (i32, i8*, ...) @fprintf(i32 %86, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0), i32 %88)
%90 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %93
91: ; preds = %82
%92 = call i32 @ERR_print_errors_fp(i32 %86)
br label %93
93: ; preds = %87, %91, %80
%94 = phi i32* [ %83, %87 ], [ %83, %91 ], [ %38, %80 ]
%95 = phi i32 [ %5, %87 ], [ %5, %91 ], [ %81, %80 ]
%96 = call i32 @BIO_free_all(i32* %94)
%97 = call i32 @SSL_CTX_free(i32* %18)
ret i32 %95
}