#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*/ BIO;

/* Variables and functions */
int /*<<< orphan*/ BIO_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BIO_new(int /*<<< orphan*/);
int /*<<< orphan*/ *BIO_new_ssl(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ *BIO_push(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ BIO_s_connect();
BIO *BIO_new_ssl_connect(SSL_CTX *ctx) {
  BIO *ret = NULL, *con = NULL, *ssl = NULL;
  if ((con = BIO_new(BIO_s_connect())) == NULL)
    return (NULL);
  if ((ssl = BIO_new_ssl(ctx, 1)) == NULL)
    goto err;
  if ((ret = BIO_push(ssl, con)) == NULL)
    goto err;
  return (ret);
err:
  if (con != NULL)
    BIO_free(con);
  if (ret != NULL)
    BIO_free(ret);
  return (NULL);
}


x86 assembly (clang, -O0):
<BIO_new_ssl_connect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    $0x0,%al
call   1050 <BIO_s_connect@plt>
mov    %eax,%edi
call   1060 <BIO_new@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    119d <BIO_new_ssl_connect+0x4d>
movq   $0x0,-0x8(%rbp)
jmp    121b <BIO_new_ssl_connect+0xcb>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1040 <BIO_new_ssl@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11be <BIO_new_ssl_connect+0x6e>
jmp    11eb <BIO_new_ssl_connect+0x9b>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <BIO_push@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11de <BIO_new_ssl_connect+0x8e>
jmp    11eb <BIO_new_ssl_connect+0x9b>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    121b <BIO_new_ssl_connect+0xcb>
cmpq   $0x0,-0x20(%rbp)
je     11ff <BIO_new_ssl_connect+0xaf>
mov    -0x20(%rbp),%rdi
call   1070 <BIO_free@plt>
cmpq   $0x0,-0x18(%rbp)
je     1213 <BIO_new_ssl_connect+0xc3>
mov    -0x18(%rbp),%rdi
call   1070 <BIO_free@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BIO_new_ssl_connect>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <BIO_s_connect@plt>
mov    %eax,%edi
call   1060 <BIO_new@plt>
test   %rax,%rax
je     119f <BIO_new_ssl_connect+0x4f>
mov    %rax,%r14
mov    %r15,%rdi
mov    $0x1,%esi
call   1040 <BIO_new_ssl@plt>
test   %rax,%rax
je     1195 <BIO_new_ssl_connect+0x45>
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <BIO_push@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    119f <BIO_new_ssl_connect+0x4f>
mov    %r14,%rdi
call   1070 <BIO_free@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32* @BIO_new_ssl_connect(i32* %0) {
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
store i32* %0, i32** %3
store i32* null, i32** %4
store i32* null, i32** %5
store i32* null, i32** %6
%7 = call i32 (...) @BIO_s_connect()
%8 = call i32* @BIO_new(i32 %7)
store i32* %8, i32** %5
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %11
10: ; preds = %1
store i32* null, i32** %2
br label %37
11: ; preds = %1
%12 = load i32*, i32** %3
%13 = call i32* @BIO_new_ssl(i32* %12, i32 1)
store i32* %13, i32** %6
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %16
15: ; preds = %11
br label %24
16: ; preds = %11
%17 = load i32*, i32** %6
%18 = load i32*, i32** %5
%19 = call i32* @BIO_push(i32* %17, i32* %18)
store i32* %19, i32** %4
%20 = icmp eq i32* %19, null
br i1 %20, label %21, label %22
21: ; preds = %16
br label %24
22: ; preds = %16
%23 = load i32*, i32** %4
store i32* %23, i32** %2
br label %37
24: ; preds = %21, %15
%25 = load i32*, i32** %5
%26 = icmp ne i32* %25, null
br i1 %26, label %27, label %30
27: ; preds = %24
%28 = load i32*, i32** %5
%29 = call i32 @BIO_free(i32* %28)
br label %30
30: ; preds = %27, %24
%31 = load i32*, i32** %4
%32 = icmp ne i32* %31, null
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = load i32*, i32** %4
%35 = call i32 @BIO_free(i32* %34)
br label %36
36: ; preds = %33, %30
store i32* null, i32** %2
br label %37
37: ; preds = %36, %22, %10
%38 = load i32*, i32** %2
ret i32* %38
}

LLVM IR (-O2):
define i32* @BIO_new_ssl_connect(i32* %0) {
%2 = tail call i32 (...) @BIO_s_connect()
%3 = tail call i32* @BIO_new(i32 %2)
%4 = icmp eq i32* %3, null
br i1 %4, label %13, label %5
5: ; preds = %1
%6 = tail call i32* @BIO_new_ssl(i32* %0, i32 1)
%7 = icmp eq i32* %6, null
br i1 %7, label %11, label %8
8: ; preds = %5
%9 = tail call i32* @BIO_push(i32* %6, i32* %3)
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %13
11: ; preds = %5, %8
%12 = tail call i32 @BIO_free(i32* %3)
br label %13
13: ; preds = %8, %1, %11
%14 = phi i32* [ null, %11 ], [ null, %1 ], [ %9, %8 ]
ret i32* %14
}