#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_6__ TYPE_2__;
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
struct TYPE_6__ {
  scalar_t__ itype;
  int utype;
  int /*<<< orphan*/ size;
  TYPE_1__ *funcs;
};
struct TYPE_5__ {
  int /*<<< orphan*/ (*prim_clear)(int /*<<< orphan*/ **, TYPE_2__ const *);
};
typedef int /*<<< orphan*/ ASN1_VALUE;
typedef TYPE_1__ ASN1_PRIMITIVE_FUNCS;
typedef TYPE_2__ ASN1_ITEM;
typedef int /*<<< orphan*/ ASN1_BOOLEAN;

/* Variables and functions */
scalar_t__ ASN1_ITYPE_MSTRING;
int V_ASN1_BOOLEAN;
int V_ASN1_UNDEF;
int /*<<< orphan*/ stub1(int /*<<< orphan*/ **, TYPE_2__ const *);
void asn1_primitive_clear(ASN1_VALUE **pval, const ASN1_ITEM *it) {
  int utype;
  if (it != NULL && it->funcs != NULL) {
    const ASN1_PRIMITIVE_FUNCS *pf = it->funcs;
    if (pf->prim_clear)
      pf->prim_clear(pval, it);
    else
      *pval = NULL;
    return;
  }
  if (!it || (it->itype == ASN1_ITYPE_MSTRING))
    utype = V_ASN1_UNDEF;
  else
    utype = it->utype;
  if (utype == V_ASN1_BOOLEAN)
    *(ASN1_BOOLEAN *)pval = it->size;
  else
    *pval = NULL;
}


x86 assembly (clang, -O0):
<asn1_primitive_clear>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     116a <asn1_primitive_clear+0x6a>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     116a <asn1_primitive_clear+0x6a>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     115a <asn1_primitive_clear+0x5a>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   *%rax
jmp    1165 <asn1_primitive_clear+0x65>
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
jmp    11d6 <asn1_primitive_clear+0xd6>
cmpq   $0x0,-0x10(%rbp)
je     118c <asn1_primitive_clear+0x8c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2e55(%rip),%rcx
cmp    (%rcx),%rax
jne    119d <asn1_primitive_clear+0x9d>
mov    0x2e55(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
jmp    11a7 <asn1_primitive_clear+0xa7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e1f(%rip),%rcx
cmp    (%rcx),%eax
jne    11cb <asn1_primitive_clear+0xcb>
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
jmp    11d6 <asn1_primitive_clear+0xd6>
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<asn1_primitive_clear>:
test   %rsi,%rsi
je     1127 <asn1_primitive_clear+0x27>
mov    0x10(%rsi),%rax
test   %rax,%rax
je     1118 <asn1_primitive_clear+0x18>
mov    (%rax),%rax
test   %rax,%rax
je     1147 <asn1_primitive_clear+0x47>
jmp    *%rax
mov    (%rsi),%rax
mov    0x2eb6(%rip),%rcx
cmp    (%rcx),%rax
jne    1130 <asn1_primitive_clear+0x30>
mov    0x2eba(%rip),%rax
jmp    1134 <asn1_primitive_clear+0x34>
lea    0x8(%rsi),%rax
mov    (%rax),%eax
mov    0x2e93(%rip),%rcx
cmp    (%rcx),%eax
jne    1147 <asn1_primitive_clear+0x47>
mov    0xc(%rsi),%eax
mov    %eax,(%rdi)
ret
movq   $0x0,(%rdi)
ret

LLVM IR (-O0):
%struct.TYPE_6__ = type { i64, i32, i32, %struct.TYPE_5__* }
%struct.TYPE_5__ = type { i32 (i32**, %struct.TYPE_6__*)* }
@ASN1_ITYPE_MSTRING = global i64 0
@V_ASN1_UNDEF = global i32 0
@V_ASN1_BOOLEAN = global i32 0
define void @asn1_primitive_clear(i32** %0, %struct.TYPE_6__* %1) {
%3 = alloca i32**
%4 = alloca %struct.TYPE_6__*
%5 = alloca i32
%6 = alloca %struct.TYPE_5__*
store i32** %0, i32*** %3
store %struct.TYPE_6__* %1, %struct.TYPE_6__** %4
%7 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%8 = icmp ne %struct.TYPE_6__* %7, null
br i1 %8, label %9, label %32
9: ; preds = %2
%10 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%11 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %10, i32 0, i32 3
%12 = load %struct.TYPE_5__*, %struct.TYPE_5__** %11
%13 = icmp ne %struct.TYPE_5__* %12, null
br i1 %13, label %14, label %32
14: ; preds = %9
%15 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%16 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %15, i32 0, i32 3
%17 = load %struct.TYPE_5__*, %struct.TYPE_5__** %16
store %struct.TYPE_5__* %17, %struct.TYPE_5__** %6
%18 = load %struct.TYPE_5__*, %struct.TYPE_5__** %6
%19 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %18, i32 0, i32 0
%20 = load i32 (i32**, %struct.TYPE_6__*)*, i32 (i32**, %struct.TYPE_6__*)** %19
%21 = icmp ne i32 (i32**, %struct.TYPE_6__*)* %20, null
br i1 %21, label %22, label %29
22: ; preds = %14
%23 = load %struct.TYPE_5__*, %struct.TYPE_5__** %6
%24 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %23, i32 0, i32 0
%25 = load i32 (i32**, %struct.TYPE_6__*)*, i32 (i32**, %struct.TYPE_6__*)** %24
%26 = load i32**, i32*** %3
%27 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%28 = call i32 %25(i32** %26, %struct.TYPE_6__* %27)
br label %31
29: ; preds = %14
%30 = load i32**, i32*** %3
store i32* null, i32** %30
br label %31
31: ; preds = %29, %22
br label %59
32: ; preds = %9, %2
%33 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%34 = icmp ne %struct.TYPE_6__* %33, null
br i1 %34, label %35, label %41
35: ; preds = %32
%36 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%37 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %36, i32 0, i32 0
%38 = load i64, i64* %37
%39 = load i64, i64* @ASN1_ITYPE_MSTRING
%40 = icmp eq i64 %38, %39
br i1 %40, label %41, label %43
41: ; preds = %35, %32
%42 = load i32, i32* @V_ASN1_UNDEF
store i32 %42, i32* %5
br label %47
43: ; preds = %35
%44 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%45 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %44, i32 0, i32 1
%46 = load i32, i32* %45
store i32 %46, i32* %5
br label %47
47: ; preds = %43, %41
%48 = load i32, i32* %5
%49 = load i32, i32* @V_ASN1_BOOLEAN
%50 = icmp eq i32 %48, %49
br i1 %50, label %51, label %57
51: ; preds = %47
%52 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%53 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %52, i32 0, i32 2
%54 = load i32, i32* %53
%55 = load i32**, i32*** %3
%56 = bitcast i32** %55 to i32*
store i32 %54, i32* %56
br label %59
57: ; preds = %47
%58 = load i32**, i32*** %3
store i32* null, i32** %58
br label %59
59: ; preds = %31, %57, %51
ret void
}

LLVM IR (-O2):
%struct.TYPE_6__ = type { i64, i32, i32, %struct.TYPE_5__* }
%struct.TYPE_5__ = type { i32 (i32**, %struct.TYPE_6__*)* }
@ASN1_ITYPE_MSTRING = global i64 0
@V_ASN1_UNDEF = global i32 0
@V_ASN1_BOOLEAN = global i32 0
define void @asn1_primitive_clear(i32** %0, %struct.TYPE_6__* %1) {
%3 = icmp eq %struct.TYPE_6__* %1, null
br i1 %3, label %22, label %4
4: ; preds = %2
%5 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %1, i64 0, i32 3
%6 = load %struct.TYPE_5__*, %struct.TYPE_5__** %5
%7 = icmp eq %struct.TYPE_5__* %6, null
br i1 %7, label %15, label %8
8: ; preds = %4
%9 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %6, i64 0, i32 0
%10 = load i32 (i32**, %struct.TYPE_6__*)*, i32 (i32**, %struct.TYPE_6__*)** %9
%11 = icmp eq i32 (i32**, %struct.TYPE_6__*)* %10, null
br i1 %11, label %14, label %12
12: ; preds = %8
%13 = tail call i32 %10(i32** %0, %struct.TYPE_6__* %1)
br label %32
14: ; preds = %8
store i32* null, i32** %0
br label %32
15: ; preds = %4
%16 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %1, i64 0, i32 0
%17 = load i64, i64* %16
%18 = load i64, i64* @ASN1_ITYPE_MSTRING
%19 = icmp eq i64 %17, %18
%20 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %1, i64 0, i32 1
%21 = select i1 %19, i32* @V_ASN1_UNDEF, i32* %20
br label %22
22: ; preds = %15, %2
%23 = phi i32* [ @V_ASN1_UNDEF, %2 ], [ %21, %15 ]
%24 = load i32, i32* %23
%25 = load i32, i32* @V_ASN1_BOOLEAN
%26 = icmp eq i32 %24, %25
br i1 %26, label %27, label %31
27: ; preds = %22
%28 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %1, i64 0, i32 2
%29 = load i32, i32* %28
%30 = bitcast i32** %0 to i32*
store i32 %29, i32* %30
br label %32
31: ; preds = %22
store i32* null, i32** %0
br label %32
32: ; preds = %27, %31, %12, %14
ret void
}