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

/* Variables and functions */
int /*<<< orphan*/ BIO_free_all(int /*<<< orphan*/ *);
scalar_t__ BIO_get_ssl(int /*<<< orphan*/ *, int /*<<< orphan*/ **);
int /*<<< orphan*/ BIO_ssl_shutdown(int /*<<< orphan*/ *);
int /*<<< orphan*/ SSL_CTX_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *SSL_get_SSL_CTX(int /*<<< orphan*/ *);
void _myproxy_close_ssl(BIO **sbio) {
  SSL *ssl;
  SSL_CTX *ctx;
  if (*sbio) {
    if (BIO_get_ssl(*sbio, &ssl) > 0) {
      ctx = SSL_get_SSL_CTX(ssl);
      SSL_CTX_free(ctx);
    }
    BIO_ssl_shutdown(*sbio);
    BIO_free_all(*sbio);
    *sbio = NULL;
  }
}


x86 assembly (clang, -O0):
<_myproxy_close_ssl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     11bd <_myproxy_close_ssl+0x6d>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <BIO_get_ssl@plt>
cmp    $0x0,%rax
jle    119a <_myproxy_close_ssl+0x4a>
mov    -0x10(%rbp),%rdi
call   1030 <SSL_get_SSL_CTX@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <SSL_CTX_free@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1050 <BIO_ssl_shutdown@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1070 <BIO_free_all@plt>
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_myproxy_close_ssl>:
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
je     1198 <_myproxy_close_ssl+0x48>
lea    0x8(%rsp),%rsi
call   1040 <BIO_get_ssl@plt>
test   %rax,%rax
jle    1181 <_myproxy_close_ssl+0x31>
mov    0x8(%rsp),%rdi
call   1030 <SSL_get_SSL_CTX@plt>
mov    %rax,%rdi
call   1060 <SSL_CTX_free@plt>
mov    (%rbx),%rdi
call   1050 <BIO_ssl_shutdown@plt>
mov    (%rbx),%rdi
call   1070 <BIO_free_all@plt>
movq   $0x0,(%rbx)
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @_myproxy_close_ssl(i32** %0) {
%2 = alloca i32**
%3 = alloca i32*
%4 = alloca i32*
store i32** %0, i32*** %2
%5 = load i32**, i32*** %2
%6 = load i32*, i32** %5
%7 = icmp ne i32* %6, null
br i1 %7, label %8, label %26
8: ; preds = %1
%9 = load i32**, i32*** %2
%10 = load i32*, i32** %9
%11 = call i64 @BIO_get_ssl(i32* %10, i32** %3)
%12 = icmp sgt i64 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %8
%14 = load i32*, i32** %3
%15 = call i32* @SSL_get_SSL_CTX(i32* %14)
store i32* %15, i32** %4
%16 = load i32*, i32** %4
%17 = call i32 @SSL_CTX_free(i32* %16)
br label %18
18: ; preds = %13, %8
%19 = load i32**, i32*** %2
%20 = load i32*, i32** %19
%21 = call i32 @BIO_ssl_shutdown(i32* %20)
%22 = load i32**, i32*** %2
%23 = load i32*, i32** %22
%24 = call i32 @BIO_free_all(i32* %23)
%25 = load i32**, i32*** %2
store i32* null, i32** %25
br label %26
26: ; preds = %18, %1
ret void
}

LLVM IR (-O2):
define void @_myproxy_close_ssl(i32** nocapture %0) {
%2 = alloca i32*
%3 = bitcast i32** %2 to i8*
%4 = load i32*, i32** %0
%5 = icmp eq i32* %4, null
br i1 %5, label %18, label %6
6: ; preds = %1
%7 = call i64 @BIO_get_ssl(i32* %4, i32** %2)
%8 = icmp sgt i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %6
%10 = load i32*, i32** %2
%11 = call i32* @SSL_get_SSL_CTX(i32* %10)
%12 = call i32 @SSL_CTX_free(i32* %11)
br label %13
13: ; preds = %9, %6
%14 = load i32*, i32** %0
%15 = call i32 @BIO_ssl_shutdown(i32* %14)
%16 = load i32*, i32** %0
%17 = call i32 @BIO_free_all(i32* %16)
store i32* null, i32** %0
br label %18
18: ; preds = %13, %1
ret void
}