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

/* Variables and functions */
int /*<<< orphan*/ *BIO_new(int /*<<< orphan*/);
int BIO_read(int /*<<< orphan*/ *, unsigned char *, int);
int /*<<< orphan*/ BIO_s_mem();
int /*<<< orphan*/ BIO_write(int /*<<< orphan*/ *, unsigned char *, int);
int /*<<< orphan*/ ERR_load_BIO_strings();
int /*<<< orphan*/ OpenSSL_add_all_algorithms();
int /*<<< orphan*/ *SSL_CTX_new(int /*<<< orphan*/);
int /*<<< orphan*/ SSL_CTX_use_PrivateKey_file(int /*<<< orphan*/ *, char *,
                                               int /*<<< orphan*/);
int /*<<< orphan*/ SSL_CTX_use_certificate_file(int /*<<< orphan*/ *, char *,
                                                int /*<<< orphan*/);
scalar_t__ SSL_ERROR_WANT_READ;
scalar_t__ SSL_ERROR_WANT_WRITE;
int /*<<< orphan*/ SSL_FILETYPE_PEM;
int SSL_do_handshake(int /*<<< orphan*/ *);
scalar_t__ SSL_get_error(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ SSL_is_init_finished(int /*<<< orphan*/ *);
int /*<<< orphan*/ SSL_library_init();
int /*<<< orphan*/ SSL_load_error_strings();
int /*<<< orphan*/ *SSL_new(int /*<<< orphan*/ *);
int /*<<< orphan*/ SSL_set_accept_state(int /*<<< orphan*/ *);
int /*<<< orphan*/ SSL_set_bio(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *);
int /*<<< orphan*/ SSL_set_connect_state(int /*<<< orphan*/ *);
char *SSL_state_string(int /*<<< orphan*/ *);
char *SSL_state_string_long(int /*<<< orphan*/ *);
int /*<<< orphan*/ TLSv1_method();
int /*<<< orphan*/ err();
int /*<<< orphan*/ *fopen(char *, char *);
int fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int main(int argc, char **argv) {
  int r, c, step;
  unsigned char buf[4096];
  char *ifi;
  FILE *f;
  char fn[15];
  SSL_CTX *sctx, *cctx;
  SSL *server, *client;
  BIO *sinbio, *soutbio, *cinbio, *coutbio;
  if (argc != 3) {
    step = -1;
  } else {
    step = argv[1][0] - '0';
    ifi = argv[2];
  }
  SSL_library_init();
  SSL_load_error_strings();
  ERR_load_BIO_strings();
  OpenSSL_add_all_algorithms();
  if (!(sctx = SSL_CTX_new(TLSv1_method())))
    err();
  if (!SSL_CTX_use_certificate_file(sctx, "server.pem", SSL_FILETYPE_PEM))
    err();
  if (!SSL_CTX_use_PrivateKey_file(sctx, "server.key", SSL_FILETYPE_PEM))
    err();
  if (!(server = SSL_new(sctx)))
    err();
  sinbio = BIO_new(BIO_s_mem());
  soutbio = BIO_new(BIO_s_mem());
  SSL_set_bio(server, sinbio, soutbio);
  SSL_set_accept_state(server);
  if (!(cctx = SSL_CTX_new(TLSv1_method())))
    err();
  if (!(client = SSL_new(cctx)))
    err();
  cinbio = BIO_new(BIO_s_mem());
  coutbio = BIO_new(BIO_s_mem());
  SSL_set_bio(client, cinbio, coutbio);
  SSL_set_connect_state(client);
  c = 0;
  do {
    r = SSL_do_handshake(client);
    if (r == -1) {
      if ((SSL_get_error(client, r) != SSL_ERROR_WANT_WRITE) &&
          (SSL_get_error(client, r) != SSL_ERROR_WANT_READ))
        err();
    }
    r = BIO_read(coutbio, buf, 4096);
    if (r == -1)
      err();
    c++;
    if (c == step) {
      f = fopen(ifi, "rb");
      r = fread(buf, 1, 4096, f);
    } else if (step == -1) {
      sprintf(fn, "packet-%i", c);
      f = fopen(fn, "wb");
      fwrite(buf, 1, r, f);
    }
    BIO_write(sinbio, buf, r);
    r = SSL_do_handshake(server);
    if (r == -1) {
      if ((SSL_get_error(server, r) != SSL_ERROR_WANT_WRITE) &&
          (SSL_get_error(server, r) != SSL_ERROR_WANT_READ))
        err();
    }
    r = BIO_read(soutbio, buf, 4096);
    if (r == -1)
      err();
    c++;
    if (c == step) {
      f = fopen(ifi, "rb");
      r = fread(buf, 1, 4096, f);
    } else if (step == -1) {
      sprintf(fn, "packet-%i", c);
      f = fopen(fn, "wb");
      fwrite(buf, 1, r, f);
    }
    BIO_write(cinbio, buf, r);
    printf("server state: %s / %s\n", SSL_state_string(server),
           SSL_state_string_long(server));
    printf("client state: %s / %s\n", SSL_state_string(client),
           SSL_state_string_long(client));
  } while ((!SSL_is_init_finished(server) || !SSL_is_init_finished(client)) &&
           c < 10);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10a0,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     12df <main+0x2f>
movl   $0xffffffff,-0x1c(%rbp)
jmp    12ff <main+0x4f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movsbl (%rax),%eax
sub    $0x30,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x1028(%rbp)
mov    $0x0,%al
call   1070 <SSL_library_init@plt>
mov    $0x0,%al
call   1150 <SSL_load_error_strings@plt>
mov    $0x0,%al
call   11b0 <ERR_load_BIO_strings@plt>
mov    $0x0,%al
call   10d0 <OpenSSL_add_all_algorithms@plt>
mov    $0x0,%al
call   10e0 <TLSv1_method@plt>
mov    %eax,%edi
call   10f0 <SSL_CTX_new@plt>
mov    %rax,-0x1048(%rbp)
cmp    $0x0,%rax
jne    1341 <main+0x91>
mov    $0x0,%al
call   1110 <err@plt>
mov    -0x1048(%rbp),%rdi
mov    0x2c91(%rip),%rax
mov    (%rax),%edx
lea    0xca8(%rip),%rsi
call   10b0 <SSL_CTX_use_certificate_file@plt>
cmp    $0x0,%eax
jne    136d <main+0xbd>
mov    $0x0,%al
call   1110 <err@plt>
mov    -0x1048(%rbp),%rdi
mov    0x2c65(%rip),%rax
mov    (%rax),%edx
lea    0xc87(%rip),%rsi
call   1130 <SSL_CTX_use_PrivateKey_file@plt>
cmp    $0x0,%eax
jne    1399 <main+0xe9>
mov    $0x0,%al
call   1110 <err@plt>
mov    -0x1048(%rbp),%rdi
call   1090 <SSL_new@plt>
mov    %rax,-0x1058(%rbp)
cmp    $0x0,%rax
jne    13bd <main+0x10d>
mov    $0x0,%al
call   1110 <err@plt>
mov    $0x0,%al
call   11c0 <BIO_s_mem@plt>
mov    %eax,%edi
call   1120 <BIO_new@plt>
mov    %rax,-0x1068(%rbp)
mov    $0x0,%al
call   11c0 <BIO_s_mem@plt>
mov    %eax,%edi
call   1120 <BIO_new@plt>
mov    %rax,-0x1070(%rbp)
mov    -0x1058(%rbp),%rdi
mov    -0x1068(%rbp),%rsi
mov    -0x1070(%rbp),%rdx
call   11d0 <SSL_set_bio@plt>
mov    -0x1058(%rbp),%rdi
call   1100 <SSL_set_accept_state@plt>
mov    $0x0,%al
call   10e0 <TLSv1_method@plt>
mov    %eax,%edi
call   10f0 <SSL_CTX_new@plt>
mov    %rax,-0x1050(%rbp)
cmp    $0x0,%rax
jne    1433 <main+0x183>
mov    $0x0,%al
call   1110 <err@plt>
mov    -0x1050(%rbp),%rdi
call   1090 <SSL_new@plt>
mov    %rax,-0x1060(%rbp)
cmp    $0x0,%rax
jne    1457 <main+0x1a7>
mov    $0x0,%al
call   1110 <err@plt>
mov    $0x0,%al
call   11c0 <BIO_s_mem@plt>
mov    %eax,%edi
call   1120 <BIO_new@plt>
mov    %rax,-0x1078(%rbp)
mov    $0x0,%al
call   11c0 <BIO_s_mem@plt>
mov    %eax,%edi
call   1120 <BIO_new@plt>
mov    %rax,-0x1080(%rbp)
mov    -0x1060(%rbp),%rdi
mov    -0x1078(%rbp),%rsi
mov    -0x1080(%rbp),%rdx
call   11d0 <SSL_set_bio@plt>
mov    -0x1060(%rbp),%rdi
call   10a0 <SSL_set_connect_state@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x1060(%rbp),%rdi
call   11a0 <SSL_do_handshake@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1511 <main+0x261>
mov    -0x1060(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <SSL_get_error@plt>
mov    0x2b13(%rip),%rcx
cmp    (%rcx),%rax
je     150c <main+0x25c>
mov    -0x1060(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <SSL_get_error@plt>
mov    0x2ad4(%rip),%rcx
cmp    (%rcx),%rax
je     150c <main+0x25c>
mov    $0x0,%al
call   1110 <err@plt>
jmp    1511 <main+0x261>
mov    -0x1080(%rbp),%rdi
lea    -0x1020(%rbp),%rsi
mov    $0x1000,%edx
call   1050 <BIO_read@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    153d <main+0x28d>
mov    $0x0,%al
call   1110 <err@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    1591 <main+0x2e1>
mov    -0x1028(%rbp),%rdi
lea    0xab6(%rip),%rsi
call   1140 <fopen@plt>
mov    %rax,-0x1030(%rbp)
lea    -0x1020(%rbp),%rdi
mov    -0x1030(%rbp),%rcx
mov    $0x1,%esi
mov    $0x1000,%edx
call   1040 <fread@plt>
mov    %eax,-0x14(%rbp)
jmp    15eb <main+0x33b>
cmpl   $0xffffffff,-0x1c(%rbp)
jne    15e6 <main+0x336>
lea    -0x103f(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    0xa6d(%rip),%rsi
call   1160 <sprintf@plt>
lea    -0x103f(%rbp),%rdi
lea    0xa64(%rip),%rsi
call   1140 <fopen@plt>
mov    %rax,-0x1030(%rbp)
lea    -0x1020(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x1030(%rbp),%rcx
mov    $0x1,%esi
call   1170 <fwrite@plt>
jmp    15eb <main+0x33b>
mov    -0x1068(%rbp),%rdi
lea    -0x1020(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1180 <BIO_write@plt>
mov    -0x1058(%rbp),%rdi
call   11a0 <SSL_do_handshake@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1664 <main+0x3b4>
mov    -0x1058(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <SSL_get_error@plt>
mov    0x29c0(%rip),%rcx
cmp    (%rcx),%rax
je     165f <main+0x3af>
mov    -0x1058(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <SSL_get_error@plt>
mov    0x2981(%rip),%rcx
cmp    (%rcx),%rax
je     165f <main+0x3af>
mov    $0x0,%al
call   1110 <err@plt>
jmp    1664 <main+0x3b4>
mov    -0x1070(%rbp),%rdi
lea    -0x1020(%rbp),%rsi
mov    $0x1000,%edx
call   1050 <BIO_read@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1690 <main+0x3e0>
mov    $0x0,%al
call   1110 <err@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jne    16e4 <main+0x434>
mov    -0x1028(%rbp),%rdi
lea    0x963(%rip),%rsi
call   1140 <fopen@plt>
mov    %rax,-0x1030(%rbp)
lea    -0x1020(%rbp),%rdi
mov    -0x1030(%rbp),%rcx
mov    $0x1,%esi
mov    $0x1000,%edx
call   1040 <fread@plt>
mov    %eax,-0x14(%rbp)
jmp    173e <main+0x48e>
cmpl   $0xffffffff,-0x1c(%rbp)
jne    1739 <main+0x489>
lea    -0x103f(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    0x91a(%rip),%rsi
call   1160 <sprintf@plt>
lea    -0x103f(%rbp),%rdi
lea    0x911(%rip),%rsi
call   1140 <fopen@plt>
mov    %rax,-0x1030(%rbp)
lea    -0x1020(%rbp),%rdi
mov    -0x14(%rbp),%edx
mov    -0x1030(%rbp),%rcx
mov    $0x1,%esi
call   1170 <fwrite@plt>
jmp    173e <main+0x48e>
mov    -0x1078(%rbp),%rdi
lea    -0x1020(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1180 <BIO_write@plt>
mov    -0x1058(%rbp),%rdi
call   1190 <SSL_state_string@plt>
mov    %rax,-0x1090(%rbp)
mov    -0x1058(%rbp),%rdi
call   10c0 <SSL_state_string_long@plt>
mov    -0x1090(%rbp),%rsi
mov    %rax,%rdx
lea    0x8a2(%rip),%rdi
call   1060 <printf@plt>
mov    -0x1060(%rbp),%rdi
call   1190 <SSL_state_string@plt>
mov    %rax,-0x1088(%rbp)
mov    -0x1060(%rbp),%rdi
call   10c0 <SSL_state_string_long@plt>
mov    -0x1088(%rbp),%rsi
mov    %rax,%rdx
lea    0x884(%rip),%rdi
call   1060 <printf@plt>
mov    -0x1058(%rbp),%rdi
call   1080 <SSL_is_init_finished@plt>
cmp    $0x0,%eax
je     17f2 <main+0x542>
mov    -0x1060(%rbp),%rdi
call   1080 <SSL_is_init_finished@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x1091(%rbp)
jne    17ff <main+0x54f>
cmpl   $0xa,-0x18(%rbp)
setl   %al
mov    %al,-0x1091(%rbp)
mov    -0x1091(%rbp),%al
test   $0x1,%al
jne    14ae <main+0x1fe>
xor    %eax,%eax
add    $0x10a0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1058,%rsp
cmp    $0x3,%edi
jne    12df <main+0x2f>
mov    0x8(%rsi),%rax
mov    0x10(%rsi),%rcx
mov    %rcx,0x10(%rsp)
movsbl (%rax),%eax
add    $0xffffffd0,%eax
mov    %eax,0xc(%rsp)
jmp    12e7 <main+0x37>
movl   $0xffffffff,0xc(%rsp)
ff
xor    %eax,%eax
call   1070 <SSL_library_init@plt>
xor    %eax,%eax
call   1150 <SSL_load_error_strings@plt>
xor    %eax,%eax
call   11b0 <ERR_load_BIO_strings@plt>
xor    %eax,%eax
call   10d0 <OpenSSL_add_all_algorithms@plt>
xor    %eax,%eax
call   10e0 <TLSv1_method@plt>
mov    %eax,%edi
call   10f0 <SSL_CTX_new@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1320 <main+0x70>
xor    %eax,%eax
call   1110 <err@plt>
mov    0x2cb9(%rip),%rbp
mov    0x0(%rbp),%edx
lea    0xccf(%rip),%rsi
mov    %rbx,%rdi
call   10b0 <SSL_CTX_use_certificate_file@plt>
test   %eax,%eax
jne    1344 <main+0x94>
xor    %eax,%eax
call   1110 <err@plt>
mov    0x0(%rbp),%edx
lea    0xcbd(%rip),%rsi
mov    %rbx,%rdi
call   1130 <SSL_CTX_use_PrivateKey_file@plt>
test   %eax,%eax
jne    1361 <main+0xb1>
xor    %eax,%eax
call   1110 <err@plt>
mov    %rbx,%rdi
call   1090 <SSL_new@plt>
mov    %rax,%r13
test   %rax,%rax
jne    1378 <main+0xc8>
xor    %eax,%eax
call   1110 <err@plt>
xor    %eax,%eax
call   11c0 <BIO_s_mem@plt>
mov    %eax,%edi
call   1120 <BIO_new@plt>
mov    %rax,%rbx
xor    %eax,%eax
call   11c0 <BIO_s_mem@plt>
mov    %eax,%edi
call   1120 <BIO_new@plt>
mov    %r13,%rdi
mov    %rbx,0x38(%rsp)
mov    %rbx,%rsi
mov    %rax,0x30(%rsp)
mov    %rax,%rdx
call   11d0 <SSL_set_bio@plt>
mov    %r13,%rdi
call   1100 <SSL_set_accept_state@plt>
xor    %eax,%eax
call   10e0 <TLSv1_method@plt>
mov    %eax,%edi
call   10f0 <SSL_CTX_new@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    13d4 <main+0x124>
xor    %eax,%eax
call   1110 <err@plt>
mov    %rbx,%rdi
call   1090 <SSL_new@plt>
mov    %rax,%r12
test   %rax,%rax
jne    13eb <main+0x13b>
xor    %eax,%eax
call   1110 <err@plt>
xor    %eax,%eax
call   11c0 <BIO_s_mem@plt>
mov    %eax,%edi
call   1120 <BIO_new@plt>
mov    %rax,%rbp
xor    %eax,%eax
call   11c0 <BIO_s_mem@plt>
mov    %eax,%edi
call   1120 <BIO_new@plt>
mov    %r12,%rdi
mov    %rbp,0x28(%rsp)
mov    %rbp,%rsi
mov    %rax,0x20(%rsp)
mov    %rax,%rdx
call   11d0 <SSL_set_bio@plt>
mov    %r12,%rdi
call   10a0 <SSL_set_connect_state@plt>
mov    0xc(%rsp),%eax
mov    %eax,%r14d
neg    %r14d
mov    $0x2,%r15d
lea    0x50(%rsp),%rbx
mov    %r14,0x18(%rsp)
jmp    1463 <main+0x1b3>
cs nopw 0x0(%rax,%rax,1)
cmp    $0x7,%r14d
ja     16cb <main+0x41b>
add    $0x2,%r15d
mov    0x18(%rsp),%r14
mov    %r12,%rdi
call   11a0 <SSL_do_handshake@plt>
cmp    $0xffffffff,%eax
jne    14b0 <main+0x200>
mov    %r12,%rdi
mov    $0xffffffff,%esi
call   1030 <SSL_get_error@plt>
mov    0x2b6c(%rip),%rcx
cmp    (%rcx),%rax
je     14b0 <main+0x200>
mov    %r12,%rdi
mov    $0xffffffff,%esi
call   1030 <SSL_get_error@plt>
mov    0x2b33(%rip),%rcx
cmp    (%rcx),%rax
je     14b0 <main+0x200>
xor    %eax,%eax
call   1110 <err@plt>
nopl   0x0(%rax)
mov    0x20(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x1000,%edx
call   1050 <BIO_read@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    14d0 <main+0x220>
xor    %eax,%eax
call   1110 <err@plt>
lea    (%r14,%r15,1),%eax
cmp    $0x1,%eax
jne    1510 <main+0x260>
mov    0x10(%rsp),%rdi
lea    0xb31(%rip),%rsi
call   1140 <fopen@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1000,%edx
mov    %rax,%rcx
call   1040 <fread@plt>
mov    %eax,%ebp
jmp    1550 <main+0x2a0>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmpl   $0xffffffff,0xc(%rsp)
jne    1550 <main+0x2a0>
lea    -0x1(%r15),%edx
lea    0x41(%rsp),%rdi
lea    0xaf2(%rip),%rsi
call   1160 <sprintf@plt>
lea    0x41(%rsp),%rdi
lea    0xaeb(%rip),%rsi
call   1140 <fopen@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
mov    %rax,%rcx
call   1170 <fwrite@plt>
nop
mov    0x38(%rsp),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
call   1180 <BIO_write@plt>
mov    %r13,%rdi
call   11a0 <SSL_do_handshake@plt>
cmp    $0xffffffff,%eax
jne    15b0 <main+0x300>
mov    %r13,%rdi
mov    $0xffffffff,%esi
call   1030 <SSL_get_error@plt>
mov    0x2a70(%rip),%rcx
cmp    (%rcx),%rax
je     15b0 <main+0x300>
mov    %r13,%rdi
mov    $0xffffffff,%esi
call   1030 <SSL_get_error@plt>
mov    0x2a37(%rip),%rcx
cmp    (%rcx),%rax
je     15b0 <main+0x300>
xor    %eax,%eax
call   1110 <err@plt>
cs nopw 0x0(%rax,%rax,1)
nop
mov    0x30(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x1000,%edx
call   1050 <BIO_read@plt>
mov    %eax,%ebp
cmp    $0xffffffff,%eax
jne    15d0 <main+0x320>
xor    %eax,%eax
call   1110 <err@plt>
mov    %r14d,%eax
add    %r15d,%eax
je     1620 <main+0x370>
cmpl   $0xffffffff,0xc(%rsp)
jne    1648 <main+0x398>
lea    0x41(%rsp),%r14
mov    %r14,%rdi
lea    0xa2b(%rip),%rsi
mov    %r15d,%edx
call   1160 <sprintf@plt>
mov    %r14,%rdi
lea    0xa23(%rip),%rsi
call   1140 <fopen@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %ebp,%edx
mov    %rax,%rcx
call   1170 <fwrite@plt>
jmp    1648 <main+0x398>
nopl   0x0(%rax)
mov    0x10(%rsp),%rdi
lea    0x9ea(%rip),%rsi
call   1140 <fopen@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x1000,%edx
mov    %rax,%rcx
call   1040 <fread@plt>
mov    %eax,%ebp
mov    %rbx,%rsi
lea    -0x2(%r15),%r14d
mov    0x28(%rsp),%rdi
mov    %ebp,%edx
call   1180 <BIO_write@plt>
mov    %r13,%rdi
call   1190 <SSL_state_string@plt>
mov    %rax,%rbp
mov    %r13,%rdi
call   10c0 <SSL_state_string_long@plt>
lea    0x9b1(%rip),%rdi
mov    %rbp,%rsi
mov    %rax,%rdx
call   1060 <printf@plt>
mov    %r12,%rdi
call   1190 <SSL_state_string@plt>
mov    %rax,%rbp
mov    %r12,%rdi
call   10c0 <SSL_state_string_long@plt>
lea    0x9a3(%rip),%rdi
mov    %rbp,%rsi
mov    %rax,%rdx
call   1060 <printf@plt>
mov    %r13,%rdi
call   1080 <SSL_is_init_finished@plt>
test   %eax,%eax
je     1450 <main+0x1a0>
mov    %r12,%rdi
call   1080 <SSL_is_init_finished@plt>
test   %eax,%eax
jne    16cb <main+0x41b>
cmp    $0x8,%r14d
jb     145a <main+0x1aa>
xor    %eax,%eax
add    $0x1058,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"server.pem\00"
@SSL_FILETYPE_PEM = global i32 0
@.str.1 = [11 x i8] c"server.key\00"
@SSL_ERROR_WANT_WRITE = global i64 0
@SSL_ERROR_WANT_READ = global i64 0
@.str.2 = [3 x i8] c"rb\00"
@.str.3 = [10 x i8] c"packet-%i\00"
@.str.4 = [3 x i8] c"wb\00"
@.str.5 = [23 x i8] c"server state: %s / %s\0A\00"
@.str.6 = [23 x i8] c"client state: %s / %s\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 i32
%9 = alloca [4096 x i8]
%10 = alloca i8*
%11 = alloca i32*
%12 = alloca [15 x i8]
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32*
%16 = alloca i32*
%17 = alloca i32*
%18 = alloca i32*
%19 = alloca i32*
%20 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%21 = load i32, i32* %4
%22 = icmp ne i32 %21, 3
br i1 %22, label %23, label %24
23: ; preds = %2
store i32 -1, i32* %8
br label %35
24: ; preds = %2
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 1
%27 = load i8*, i8** %26
%28 = getelementptr inbounds i8, i8* %27, i64 0
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = sub nsw i32 %30, 48
store i32 %31, i32* %8
%32 = load i8**, i8*** %5
%33 = getelementptr inbounds i8*, i8** %32, i64 2
%34 = load i8*, i8** %33
store i8* %34, i8** %10
br label %35
35: ; preds = %24, %23
%36 = call i32 (...) @SSL_library_init()
%37 = call i32 (...) @SSL_load_error_strings()
%38 = call i32 (...) @ERR_load_BIO_strings()
%39 = call i32 (...) @OpenSSL_add_all_algorithms()
%40 = call i32 (...) @TLSv1_method()
%41 = call i32* @SSL_CTX_new(i32 %40)
store i32* %41, i32** %13
%42 = icmp ne i32* %41, null
br i1 %42, label %45, label %43
43: ; preds = %35
%44 = call i32 (...) @err()
br label %45
45: ; preds = %43, %35
%46 = load i32*, i32** %13
%47 = load i32, i32* @SSL_FILETYPE_PEM
%48 = call i32 @SSL_CTX_use_certificate_file(i32* %46, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %47)
%49 = icmp ne i32 %48, 0
br i1 %49, label %52, label %50
50: ; preds = %45
%51 = call i32 (...) @err()
br label %52
52: ; preds = %50, %45
%53 = load i32*, i32** %13
%54 = load i32, i32* @SSL_FILETYPE_PEM
%55 = call i32 @SSL_CTX_use_PrivateKey_file(i32* %53, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %54)
%56 = icmp ne i32 %55, 0
br i1 %56, label %59, label %57
57: ; preds = %52
%58 = call i32 (...) @err()
br label %59
59: ; preds = %57, %52
%60 = load i32*, i32** %13
%61 = call i32* @SSL_new(i32* %60)
store i32* %61, i32** %15
%62 = icmp ne i32* %61, null
br i1 %62, label %65, label %63
63: ; preds = %59
%64 = call i32 (...) @err()
br label %65
65: ; preds = %63, %59
%66 = call i32 (...) @BIO_s_mem()
%67 = call i32* @BIO_new(i32 %66)
store i32* %67, i32** %17
%68 = call i32 (...) @BIO_s_mem()
%69 = call i32* @BIO_new(i32 %68)
store i32* %69, i32** %18
%70 = load i32*, i32** %15
%71 = load i32*, i32** %17
%72 = load i32*, i32** %18
%73 = call i32 @SSL_set_bio(i32* %70, i32* %71, i32* %72)
%74 = load i32*, i32** %15
%75 = call i32 @SSL_set_accept_state(i32* %74)
%76 = call i32 (...) @TLSv1_method()
%77 = call i32* @SSL_CTX_new(i32 %76)
store i32* %77, i32** %14
%78 = icmp ne i32* %77, null
br i1 %78, label %81, label %79
79: ; preds = %65
%80 = call i32 (...) @err()
br label %81
81: ; preds = %79, %65
%82 = load i32*, i32** %14
%83 = call i32* @SSL_new(i32* %82)
store i32* %83, i32** %16
%84 = icmp ne i32* %83, null
br i1 %84, label %87, label %85
85: ; preds = %81
%86 = call i32 (...) @err()
br label %87
87: ; preds = %85, %81
%88 = call i32 (...) @BIO_s_mem()
%89 = call i32* @BIO_new(i32 %88)
store i32* %89, i32** %19
%90 = call i32 (...) @BIO_s_mem()
%91 = call i32* @BIO_new(i32 %90)
store i32* %91, i32** %20
%92 = load i32*, i32** %16
%93 = load i32*, i32** %19
%94 = load i32*, i32** %20
%95 = call i32 @SSL_set_bio(i32* %92, i32* %93, i32* %94)
%96 = load i32*, i32** %16
%97 = call i32 @SSL_set_connect_state(i32* %96)
store i32 0, i32* %7
br label %98
98: ; preds = %236, %87
%99 = load i32*, i32** %16
%100 = call i32 @SSL_do_handshake(i32* %99)
store i32 %100, i32* %6
%101 = load i32, i32* %6
%102 = icmp eq i32 %101, -1
br i1 %102, label %103, label %118
103: ; preds = %98
%104 = load i32*, i32** %16
%105 = load i32, i32* %6
%106 = call i64 @SSL_get_error(i32* %104, i32 %105)
%107 = load i64, i64* @SSL_ERROR_WANT_WRITE
%108 = icmp ne i64 %106, %107
br i1 %108, label %109, label %117
109: ; preds = %103
%110 = load i32*, i32** %16
%111 = load i32, i32* %6
%112 = call i64 @SSL_get_error(i32* %110, i32 %111)
%113 = load i64, i64* @SSL_ERROR_WANT_READ
%114 = icmp ne i64 %112, %113
br i1 %114, label %115, label %117
115: ; preds = %109
%116 = call i32 (...) @err()
br label %117
117: ; preds = %115, %109, %103
br label %118
118: ; preds = %117, %98
%119 = load i32*, i32** %20
%120 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%121 = call i32 @BIO_read(i32* %119, i8* %120, i32 4096)
store i32 %121, i32* %6
%122 = load i32, i32* %6
%123 = icmp eq i32 %122, -1
br i1 %123, label %124, label %126
124: ; preds = %118
%125 = call i32 (...) @err()
br label %126
126: ; preds = %124, %118
%127 = load i32, i32* %7
%128 = add nsw i32 %127, 1
store i32 %128, i32* %7
%129 = load i32, i32* %7
%130 = load i32, i32* %8
%131 = icmp eq i32 %129, %130
br i1 %131, label %132, label %138
132: ; preds = %126
%133 = load i8*, i8** %10
%134 = call i32* @fopen(i8* %133, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %134, i32** %11
%135 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%136 = load i32*, i32** %11
%137 = call i32 @fread(i8* %135, i32 1, i32 4096, i32* %136)
store i32 %137, i32* %6
br label %152
138: ; preds = %126
%139 = load i32, i32* %8
%140 = icmp eq i32 %139, -1
br i1 %140, label %141, label %151
141: ; preds = %138
%142 = getelementptr inbounds [15 x i8], [15 x i8]* %12, i64 0, i64 0
%143 = load i32, i32* %7
%144 = call i32 @sprintf(i8* %142, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %143)
%145 = getelementptr inbounds [15 x i8], [15 x i8]* %12, i64 0, i64 0
%146 = call i32* @fopen(i8* %145, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %146, i32** %11
%147 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%148 = load i32, i32* %6
%149 = load i32*, i32** %11
%150 = call i32 @fwrite(i8* %147, i32 1, i32 %148, i32* %149)
br label %151
151: ; preds = %141, %138
br label %152
152: ; preds = %151, %132
%153 = load i32*, i32** %17
%154 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%155 = load i32, i32* %6
%156 = call i32 @BIO_write(i32* %153, i8* %154, i32 %155)
%157 = load i32*, i32** %15
%158 = call i32 @SSL_do_handshake(i32* %157)
store i32 %158, i32* %6
%159 = load i32, i32* %6
%160 = icmp eq i32 %159, -1
br i1 %160, label %161, label %176
161: ; preds = %152
%162 = load i32*, i32** %15
%163 = load i32, i32* %6
%164 = call i64 @SSL_get_error(i32* %162, i32 %163)
%165 = load i64, i64* @SSL_ERROR_WANT_WRITE
%166 = icmp ne i64 %164, %165
br i1 %166, label %167, label %175
167: ; preds = %161
%168 = load i32*, i32** %15
%169 = load i32, i32* %6
%170 = call i64 @SSL_get_error(i32* %168, i32 %169)
%171 = load i64, i64* @SSL_ERROR_WANT_READ
%172 = icmp ne i64 %170, %171
br i1 %172, label %173, label %175
173: ; preds = %167
%174 = call i32 (...) @err()
br label %175
175: ; preds = %173, %167, %161
br label %176
176: ; preds = %175, %152
%177 = load i32*, i32** %18
%178 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%179 = call i32 @BIO_read(i32* %177, i8* %178, i32 4096)
store i32 %179, i32* %6
%180 = load i32, i32* %6
%181 = icmp eq i32 %180, -1
br i1 %181, label %182, label %184
182: ; preds = %176
%183 = call i32 (...) @err()
br label %184
184: ; preds = %182, %176
%185 = load i32, i32* %7
%186 = add nsw i32 %185, 1
store i32 %186, i32* %7
%187 = load i32, i32* %7
%188 = load i32, i32* %8
%189 = icmp eq i32 %187, %188
br i1 %189, label %190, label %196
190: ; preds = %184
%191 = load i8*, i8** %10
%192 = call i32* @fopen(i8* %191, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %192, i32** %11
%193 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%194 = load i32*, i32** %11
%195 = call i32 @fread(i8* %193, i32 1, i32 4096, i32* %194)
store i32 %195, i32* %6
br label %210
196: ; preds = %184
%197 = load i32, i32* %8
%198 = icmp eq i32 %197, -1
br i1 %198, label %199, label %209
199: ; preds = %196
%200 = getelementptr inbounds [15 x i8], [15 x i8]* %12, i64 0, i64 0
%201 = load i32, i32* %7
%202 = call i32 @sprintf(i8* %200, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %201)
%203 = getelementptr inbounds [15 x i8], [15 x i8]* %12, i64 0, i64 0
%204 = call i32* @fopen(i8* %203, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
store i32* %204, i32** %11
%205 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%206 = load i32, i32* %6
%207 = load i32*, i32** %11
%208 = call i32 @fwrite(i8* %205, i32 1, i32 %206, i32* %207)
br label %209
209: ; preds = %199, %196
br label %210
210: ; preds = %209, %190
%211 = load i32*, i32** %19
%212 = getelementptr inbounds [4096 x i8], [4096 x i8]* %9, i64 0, i64 0
%213 = load i32, i32* %6
%214 = call i32 @BIO_write(i32* %211, i8* %212, i32 %213)
%215 = load i32*, i32** %15
%216 = call i8* @SSL_state_string(i32* %215)
%217 = load i32*, i32** %15
%218 = call i8* @SSL_state_string_long(i32* %217)
%219 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %216, i8* %218)
%220 = load i32*, i32** %16
%221 = call i8* @SSL_state_string(i32* %220)
%222 = load i32*, i32** %16
%223 = call i8* @SSL_state_string_long(i32* %222)
%224 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %221, i8* %223)
br label %225
225: ; preds = %210
%226 = load i32*, i32** %15
%227 = call i32 @SSL_is_init_finished(i32* %226)
%228 = icmp ne i32 %227, 0
br i1 %228, label %229, label %233
229: ; preds = %225
%230 = load i32*, i32** %16
%231 = call i32 @SSL_is_init_finished(i32* %230)
%232 = icmp ne i32 %231, 0
br i1 %232, label %236, label %233
233: ; preds = %229, %225
%234 = load i32, i32* %7
%235 = icmp slt i32 %234, 10
br label %236
236: ; preds = %233, %229
%237 = phi i1 [ false, %229 ], [ %235, %233 ]
br i1 %237, label %98, label %238
238: ; preds = %236
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"server.pem\00"
@SSL_FILETYPE_PEM = global i32 0
@.str.1 = [11 x i8] c"server.key\00"
@SSL_ERROR_WANT_WRITE = global i64 0
@SSL_ERROR_WANT_READ = global i64 0
@.str.2 = [3 x i8] c"rb\00"
@.str.3 = [10 x i8] c"packet-%i\00"
@.str.4 = [3 x i8] c"wb\00"
@.str.5 = [23 x i8] c"server state: %s / %s\0A\00"
@.str.6 = [23 x i8] c"client state: %s / %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4096 x i8]
%4 = alloca [15 x i8]
%5 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [15 x i8], [15 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %0, 3
br i1 %7, label %8, label %16
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = add nsw i32 %12, -48
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
br label %16
16: ; preds = %2, %8
%17 = phi i8* [ %15, %8 ], [ undef, %2 ]
%18 = phi i32 [ %13, %8 ], [ -1, %2 ]
%19 = tail call i32 (...) @SSL_library_init()
%20 = tail call i32 (...) @SSL_load_error_strings()
%21 = tail call i32 (...) @ERR_load_BIO_strings()
%22 = tail call i32 (...) @OpenSSL_add_all_algorithms()
%23 = tail call i32 (...) @TLSv1_method()
%24 = tail call i32* @SSL_CTX_new(i32 %23)
%25 = icmp eq i32* %24, null
br i1 %25, label %26, label %28
26: ; preds = %16
%27 = tail call i32 (...) @err()
br label %28
28: ; preds = %26, %16
%29 = load i32, i32* @SSL_FILETYPE_PEM
%30 = tail call i32 @SSL_CTX_use_certificate_file(i32* %24, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %29)
%31 = icmp eq i32 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = tail call i32 (...) @err()
br label %34
34: ; preds = %32, %28
%35 = load i32, i32* @SSL_FILETYPE_PEM
%36 = tail call i32 @SSL_CTX_use_PrivateKey_file(i32* %24, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %35)
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = tail call i32 (...) @err()
br label %40
40: ; preds = %38, %34
%41 = tail call i32* @SSL_new(i32* %24)
%42 = icmp eq i32* %41, null
br i1 %42, label %43, label %45
43: ; preds = %40
%44 = tail call i32 (...) @err()
br label %45
45: ; preds = %43, %40
%46 = tail call i32 (...) @BIO_s_mem()
%47 = tail call i32* @BIO_new(i32 %46)
%48 = tail call i32 (...) @BIO_s_mem()
%49 = tail call i32* @BIO_new(i32 %48)
%50 = tail call i32 @SSL_set_bio(i32* %41, i32* %47, i32* %49)
%51 = tail call i32 @SSL_set_accept_state(i32* %41)
%52 = tail call i32 (...) @TLSv1_method()
%53 = tail call i32* @SSL_CTX_new(i32 %52)
%54 = icmp eq i32* %53, null
br i1 %54, label %55, label %57
55: ; preds = %45
%56 = tail call i32 (...) @err()
br label %57
57: ; preds = %55, %45
%58 = tail call i32* @SSL_new(i32* %53)
%59 = icmp eq i32* %58, null
br i1 %59, label %60, label %62
60: ; preds = %57
%61 = tail call i32 (...) @err()
br label %62
62: ; preds = %60, %57
%63 = tail call i32 (...) @BIO_s_mem()
%64 = tail call i32* @BIO_new(i32 %63)
%65 = tail call i32 (...) @BIO_s_mem()
%66 = tail call i32* @BIO_new(i32 %65)
%67 = tail call i32 @SSL_set_bio(i32* %58, i32* %64, i32* %66)
%68 = tail call i32 @SSL_set_connect_state(i32* %58)
%69 = icmp eq i32 %18, -1
br label %70
70: ; preds = %149, %62
%71 = phi i32 [ 0, %62 ], [ %121, %149 ]
%72 = call i32 @SSL_do_handshake(i32* %58)
%73 = icmp eq i32 %72, -1
br i1 %73, label %74, label %84
74: ; preds = %70
%75 = call i64 @SSL_get_error(i32* %58, i32 -1)
%76 = load i64, i64* @SSL_ERROR_WANT_WRITE
%77 = icmp eq i64 %75, %76
br i1 %77, label %84, label %78
78: ; preds = %74
%79 = call i64 @SSL_get_error(i32* %58, i32 -1)
%80 = load i64, i64* @SSL_ERROR_WANT_READ
%81 = icmp eq i64 %79, %80
br i1 %81, label %84, label %82
82: ; preds = %78
%83 = call i32 (...) @err()
br label %84
84: ; preds = %74, %78, %82, %70
%85 = call i32 @BIO_read(i32* %66, i8* %5, i32 4096)
%86 = icmp eq i32 %85, -1
br i1 %86, label %87, label %89
87: ; preds = %84
%88 = call i32 (...) @err()
br label %89
89: ; preds = %87, %84
%90 = or i32 %71, 1
%91 = icmp eq i32 %90, %18
br i1 %91, label %92, label %95
92: ; preds = %89
%93 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%94 = call i32 @fread(i8* %5, i32 1, i32 4096, i32* %93)
br label %100
95: ; preds = %89
br i1 %69, label %96, label %100
96: ; preds = %95
%97 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %90)
%98 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%99 = call i32 @fwrite(i8* %5, i32 1, i32 %85, i32* %98)
br label %100
100: ; preds = %95, %96, %92
%101 = phi i32 [ %94, %92 ], [ %85, %96 ], [ %85, %95 ]
%102 = call i32 @BIO_write(i32* %47, i8* %5, i32 %101)
%103 = call i32 @SSL_do_handshake(i32* %41)
%104 = icmp eq i32 %103, -1
br i1 %104, label %105, label %115
105: ; preds = %100
%106 = call i64 @SSL_get_error(i32* %41, i32 -1)
%107 = load i64, i64* @SSL_ERROR_WANT_WRITE
%108 = icmp eq i64 %106, %107
br i1 %108, label %115, label %109
109: ; preds = %105
%110 = call i64 @SSL_get_error(i32* %41, i32 -1)
%111 = load i64, i64* @SSL_ERROR_WANT_READ
%112 = icmp eq i64 %110, %111
br i1 %112, label %115, label %113
113: ; preds = %109
%114 = call i32 (...) @err()
br label %115
115: ; preds = %105, %109, %113, %100
%116 = call i32 @BIO_read(i32* %49, i8* %5, i32 4096)
%117 = icmp eq i32 %116, -1
br i1 %117, label %118, label %120
118: ; preds = %115
%119 = call i32 (...) @err()
br label %120
120: ; preds = %118, %115
%121 = add nuw nsw i32 %71, 2
%122 = icmp eq i32 %121, %18
br i1 %122, label %123, label %126
123: ; preds = %120
%124 = call i32* @fopen(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%125 = call i32 @fread(i8* %5, i32 1, i32 4096, i32* %124)
br label %131
126: ; preds = %120
br i1 %69, label %127, label %131
127: ; preds = %126
%128 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %121)
%129 = call i32* @fopen(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0))
%130 = call i32 @fwrite(i8* %5, i32 1, i32 %116, i32* %129)
br label %131
131: ; preds = %126, %127, %123
%132 = phi i32 [ %125, %123 ], [ %116, %127 ], [ %116, %126 ]
%133 = call i32 @BIO_write(i32* %64, i8* %5, i32 %132)
%134 = call i8* @SSL_state_string(i32* %41)
%135 = call i8* @SSL_state_string_long(i32* %41)
%136 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i8* %134, i8* %135)
%137 = call i8* @SSL_state_string(i32* %58)
%138 = call i8* @SSL_state_string_long(i32* %58)
%139 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.6, i64 0, i64 0), i8* %137, i8* %138)
%140 = call i32 @SSL_is_init_finished(i32* %41)
%141 = icmp eq i32 %140, 0
br i1 %141, label %147, label %142
142: ; preds = %131
%143 = call i32 @SSL_is_init_finished(i32* %58)
%144 = icmp eq i32 %143, 0
%145 = icmp ult i32 %71, 8
%146 = select i1 %144, i1 %145, i1 false
br i1 %146, label %149, label %150
147: ; preds = %131
%148 = icmp ult i32 %71, 8
br i1 %148, label %149, label %150
149: ; preds = %147, %142
br label %70
150: ; preds = %142, %147
ret i32 0
}