#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)
    goto err;
  if ((ssl = BIO_new_ssl(ctx, 1)) == NULL)
    goto err;
  if ((ret = BIO_push(ssl, con)) == NULL)
    goto err;
  return (ret);
err:
  BIO_free(con);
  BIO_free(ssl);
  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    1195 <BIO_new_ssl_connect+0x45>
jmp    11e3 <BIO_new_ssl_connect+0x93>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1040 <BIO_new_ssl@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11b6 <BIO_new_ssl_connect+0x66>
jmp    11e3 <BIO_new_ssl_connect+0x93>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1030 <BIO_push@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11d6 <BIO_new_ssl_connect+0x86>
jmp    11e3 <BIO_new_ssl_connect+0x93>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11fd <BIO_new_ssl_connect+0xad>
mov    -0x20(%rbp),%rdi
call   1070 <BIO_free@plt>
mov    -0x28(%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>
mov    %rax,%r14
test   %rax,%rax
je     1199 <BIO_new_ssl_connect+0x49>
mov    %r15,%rdi
mov    $0x1,%esi
call   1040 <BIO_new_ssl@plt>
test   %rax,%rax
je     1197 <BIO_new_ssl_connect+0x47>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1030 <BIO_push@plt>
test   %rax,%rax
jne    11ab <BIO_new_ssl_connect+0x5b>
jmp    1199 <BIO_new_ssl_connect+0x49>
xor    %ebx,%ebx
mov    %r14,%rdi
call   1070 <BIO_free@plt>
mov    %rbx,%rdi
call   1070 <BIO_free@plt>
xor    %eax,%eax
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
br label %24
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 %29
24: ; preds = %21, %15, %10
%25 = load i32*, i32** %5
%26 = call i32 @BIO_free(i32* %25)
%27 = load i32*, i32** %6
%28 = call i32 @BIO_free(i32* %27)
store i32* null, i32** %2
br label %29
29: ; preds = %24, %22
%30 = load i32*, i32** %2
ret i32* %30
}

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 %11, 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 %15
11: ; preds = %8, %5, %1
%12 = phi i32* [ null, %1 ], [ null, %5 ], [ %6, %8 ]
%13 = tail call i32 @BIO_free(i32* %3)
%14 = tail call i32 @BIO_free(i32* %12)
br label %15
15: ; preds = %8, %11
%16 = phi i32* [ null, %11 ], [ %9, %8 ]
ret i32* %16
}