#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 */
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
struct TYPE_5__ {
  struct TYPE_5__ *data;
  scalar_t__ max;
};
typedef TYPE_1__ BUF_MEM;

/* Variables and functions */
int /*<<< orphan*/ OPENSSL_free(TYPE_1__ *);
int /*<<< orphan*/ memset(TYPE_1__ *, int /*<<< orphan*/, unsigned int);
void BUF_MEM_free(BUF_MEM *a) {
  if (a == NULL)
    return;
  if (a->data != NULL) {
    memset(a->data, 0, (unsigned int)a->max);
    OPENSSL_free(a->data);
  }
  OPENSSL_free(a);
}


x86 assembly (clang, -O0):
<BUF_MEM_free>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    113c <BUF_MEM_free+0x1c>
jmp    1177 <BUF_MEM_free+0x57>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     116e <BUF_MEM_free+0x4e>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    %eax,%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1040 <OPENSSL_free@plt>
mov    -0x8(%rbp),%rdi
call   1040 <OPENSSL_free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BUF_MEM_free>:
test   %rdi,%rdi
je     114c <BUF_MEM_free+0x2c>
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%rdi
test   %rdi,%rdi
je     1143 <BUF_MEM_free+0x23>
mov    0x8(%rbx),%edx
xor    %esi,%esi
call   1030 <memset@plt>
mov    (%rbx),%rdi
call   1040 <OPENSSL_free@plt>
mov    %rbx,%rdi
pop    %rbx
jmp    1040 <OPENSSL_free@plt>
ret

LLVM IR (-O0):
%struct.TYPE_5__ = type { %struct.TYPE_5__*, i64 }
define void @BUF_MEM_free(%struct.TYPE_5__* %0) {
%2 = alloca %struct.TYPE_5__*
store %struct.TYPE_5__* %0, %struct.TYPE_5__** %2
%3 = load %struct.TYPE_5__*, %struct.TYPE_5__** %2
%4 = icmp eq %struct.TYPE_5__* %3, null
br i1 %4, label %5, label %6
5: ; preds = %1
br label %27
6: ; preds = %1
%7 = load %struct.TYPE_5__*, %struct.TYPE_5__** %2
%8 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %7, i32 0, i32 0
%9 = load %struct.TYPE_5__*, %struct.TYPE_5__** %8
%10 = icmp ne %struct.TYPE_5__* %9, null
br i1 %10, label %11, label %24
11: ; preds = %6
%12 = load %struct.TYPE_5__*, %struct.TYPE_5__** %2
%13 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %12, i32 0, i32 0
%14 = load %struct.TYPE_5__*, %struct.TYPE_5__** %13
%15 = load %struct.TYPE_5__*, %struct.TYPE_5__** %2
%16 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %15, i32 0, i32 1
%17 = load i64, i64* %16
%18 = trunc i64 %17 to i32
%19 = call i32 @memset(%struct.TYPE_5__* %14, i32 0, i32 %18)
%20 = load %struct.TYPE_5__*, %struct.TYPE_5__** %2
%21 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %20, i32 0, i32 0
%22 = load %struct.TYPE_5__*, %struct.TYPE_5__** %21
%23 = call i32 @OPENSSL_free(%struct.TYPE_5__* %22)
br label %24
24: ; preds = %11, %6
%25 = load %struct.TYPE_5__*, %struct.TYPE_5__** %2
%26 = call i32 @OPENSSL_free(%struct.TYPE_5__* %25)
br label %27
27: ; preds = %24, %5
ret void
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { %struct.TYPE_5__*, i64 }
define void @BUF_MEM_free(%struct.TYPE_5__* %0) {
%2 = icmp eq %struct.TYPE_5__* %0, null
br i1 %2, label %16, label %3
3: ; preds = %1
%4 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %0, i64 0, i32 0
%5 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%6 = icmp eq %struct.TYPE_5__* %5, null
br i1 %6, label %14, label %7
7: ; preds = %3
%8 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %0, i64 0, i32 1
%9 = load i64, i64* %8
%10 = trunc i64 %9 to i32
%11 = tail call i32 @memset(%struct.TYPE_5__* %5, i32 0, i32 %10)
%12 = load %struct.TYPE_5__*, %struct.TYPE_5__** %4
%13 = tail call i32 @OPENSSL_free(%struct.TYPE_5__* %12)
br label %14
14: ; preds = %7, %3
%15 = tail call i32 @OPENSSL_free(%struct.TYPE_5__* %0)
br label %16
16: ; preds = %1, %14
ret void
}