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

/* Variables and functions */
int /*<<< orphan*/ BIO_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *BIO_new(int /*<<< orphan*/);
int /*<<< orphan*/ BIO_s_connect();
scalar_t__ BIO_set_conn_hostname(int /*<<< orphan*/ *, char const *);
BIO *BIO_new_connect(const char *str) {
  BIO *ret;
  ret = BIO_new(BIO_s_connect());
  if (ret == NULL)
    return (NULL);
  if (BIO_set_conn_hostname(ret, str))
    return (ret);
  else {
    BIO_free(ret);
    return (NULL);
  }
}


x86 assembly (clang, -O0):
<BIO_new_connect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <BIO_s_connect@plt>
mov    %eax,%edi
call   1050 <BIO_new@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1176 <BIO_new_connect+0x36>
movq   $0x0,-0x8(%rbp)
jmp    11ab <BIO_new_connect+0x6b>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <BIO_set_conn_hostname@plt>
cmp    $0x0,%rax
je     119a <BIO_new_connect+0x5a>
mov    -0x18(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11ab <BIO_new_connect+0x6b>
mov    -0x18(%rbp),%rdi
call   1060 <BIO_free@plt>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BIO_new_connect>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <BIO_s_connect@plt>
mov    %eax,%edi
call   1050 <BIO_new@plt>
test   %rax,%rax
je     1175 <BIO_new_connect+0x35>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <BIO_set_conn_hostname@plt>
test   %rax,%rax
jne    1177 <BIO_new_connect+0x37>
mov    %rbx,%rdi
call   1060 <BIO_free@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32* @BIO_new_connect(i8* %0) {
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i32*
store i8* %0, i8** %3
%5 = call i32 (...) @BIO_s_connect()
%6 = call i32* @BIO_new(i32 %5)
store i32* %6, i32** %4
%7 = load i32*, i32** %4
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %10
9: ; preds = %1
store i32* null, i32** %2
br label %20
10: ; preds = %1
%11 = load i32*, i32** %4
%12 = load i8*, i8** %3
%13 = call i64 @BIO_set_conn_hostname(i32* %11, i8* %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = load i32*, i32** %4
store i32* %16, i32** %2
br label %20
17: ; preds = %10
%18 = load i32*, i32** %4
%19 = call i32 @BIO_free(i32* %18)
store i32* null, i32** %2
br label %20
20: ; preds = %17, %15, %9
%21 = load i32*, i32** %2
ret i32* %21
}

LLVM IR (-O2):
define i32* @BIO_new_connect(i8* %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 %10, label %5
5: ; preds = %1
%6 = tail call i64 @BIO_set_conn_hostname(i32* %3, i8* %0)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 @BIO_free(i32* %3)
br label %10
10: ; preds = %5, %1, %8
%11 = phi i32* [ null, %8 ], [ null, %1 ], [ %3, %5 ]
ret i32* %11
}