#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_f_buffer();
int /*<<< orphan*/ BIO_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BIO_new(int /*<<< orphan*/);
int /*<<< orphan*/ *BIO_new_ssl_connect(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BIO_push(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx) {
  BIO *ret = NULL, *buf = NULL, *ssl = NULL;
  if ((buf = BIO_new(BIO_f_buffer())) == NULL)
    return (NULL);
  if ((ssl = BIO_new_ssl_connect(ctx)) == NULL)
    goto err;
  if ((ret = BIO_push(buf, ssl)) == NULL)
    goto err;
  return (ret);
err:
  if (buf != NULL)
    BIO_free(buf);
  if (ssl != NULL)
    BIO_free(ssl);
  return (NULL);
}


x86 assembly (clang, -O0):
<BIO_new_buffer_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   1040 <BIO_f_buffer@plt>
mov    %eax,%edi
call   1050 <BIO_new@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    119d <BIO_new_buffer_ssl_connect+0x4d>
movq   $0x0,-0x8(%rbp)
jmp    1216 <BIO_new_buffer_ssl_connect+0xc6>
mov    -0x10(%rbp),%rdi
call   1070 <BIO_new_ssl_connect@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11b9 <BIO_new_buffer_ssl_connect+0x69>
jmp    11e6 <BIO_new_buffer_ssl_connect+0x96>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1030 <BIO_push@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11d9 <BIO_new_buffer_ssl_connect+0x89>
jmp    11e6 <BIO_new_buffer_ssl_connect+0x96>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1216 <BIO_new_buffer_ssl_connect+0xc6>
cmpq   $0x0,-0x20(%rbp)
je     11fa <BIO_new_buffer_ssl_connect+0xaa>
mov    -0x20(%rbp),%rdi
call   1060 <BIO_free@plt>
cmpq   $0x0,-0x28(%rbp)
je     120e <BIO_new_buffer_ssl_connect+0xbe>
mov    -0x28(%rbp),%rdi
call   1060 <BIO_free@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BIO_new_buffer_ssl_connect>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <BIO_f_buffer@plt>
mov    %eax,%edi
call   1050 <BIO_new@plt>
test   %rax,%rax
je     11aa <BIO_new_buffer_ssl_connect+0x5a>
mov    %rax,%r14
mov    %r15,%rdi
call   1070 <BIO_new_ssl_connect@plt>
test   %rax,%rax
je     119d <BIO_new_buffer_ssl_connect+0x4d>
mov    %rax,%r15
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <BIO_push@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    11aa <BIO_new_buffer_ssl_connect+0x5a>
mov    %r14,%rdi
call   1060 <BIO_free@plt>
jmp    11a0 <BIO_new_buffer_ssl_connect+0x50>
mov    %r14,%r15
mov    %r15,%rdi
call   1060 <BIO_free@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32* @BIO_new_buffer_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_f_buffer()
%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_connect(i32* %12)
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** %5
%18 = load i32*, i32** %6
%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** %6
%32 = icmp ne i32* %31, null
br i1 %32, label %33, label %36
33: ; preds = %30
%34 = load i32*, i32** %6
%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_buffer_ssl_connect(i32* %0) {
%2 = tail call i32 (...) @BIO_f_buffer()
%3 = tail call i32* @BIO_new(i32 %2)
%4 = icmp eq i32* %3, null
br i1 %4, label %16, label %5
5: ; preds = %1
%6 = tail call i32* @BIO_new_ssl_connect(i32* %0)
%7 = icmp eq i32* %6, null
br i1 %7, label %13, label %8
8: ; preds = %5
%9 = tail call i32* @BIO_push(i32* %3, i32* %6)
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %16
11: ; preds = %8
%12 = tail call i32 @BIO_free(i32* %3)
br label %13
13: ; preds = %5, %11
%14 = phi i32* [ %6, %11 ], [ %3, %5 ]
%15 = tail call i32 @BIO_free(i32* %14)
br label %16
16: ; preds = %13, %8, %1
%17 = phi i32* [ null, %1 ], [ %9, %8 ], [ null, %13 ]
ret i32* %17
}