#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_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int length;
  int /*<<< orphan*/ *data;
};
typedef TYPE_1__ ASN1_STRING;

/* Variables and functions */
int /*<<< orphan*/ explicit_bzero(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ free(int /*<<< orphan*/ *);
void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len) {
  if (str->data != NULL)
    explicit_bzero(str->data, str->length);
  free(str->data);
  str->data = data;
  str->length = len;
}


x86 assembly (clang, -O0):
<ASN1_STRING_set0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     1155 <ASN1_STRING_set0+0x35>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
call   1040 <explicit_bzero@plt>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x14(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ASN1_STRING_set0>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    0x8(%rdi),%rdi
test   %rdi,%rdi
je     1143 <ASN1_STRING_set0+0x23>
mov    (%rbx),%esi
call   1040 <explicit_bzero@plt>
mov    0x8(%rbx),%rdi
jmp    1145 <ASN1_STRING_set0+0x25>
xor    %edi,%edi
call   1030 <free@plt>
mov    %rbp,0x8(%rbx)
mov    %r14d,(%rbx)
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32* }
define void @ASN1_STRING_set0(%struct.TYPE_3__* nocapture %0, i8* %1, i32 %2) {
%4 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 1
%5 = load i32*, i32** %4
%6 = icmp eq i32* %5, null
br i1 %6, label %12, label %7
7: ; preds = %3
%8 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
%9 = load i32, i32* %8
%10 = tail call i32 @explicit_bzero(i32* %5, i32 %9)
%11 = load i32*, i32** %4
br label %12
12: ; preds = %7, %3
%13 = phi i32* [ %11, %7 ], [ null, %3 ]
%14 = tail call i32 @free(i32* %13)
%15 = bitcast i32** %4 to i8**
store i8* %1, i8** %15
%16 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
store i32 %2, i32* %16
ret void
}