#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 /*<<< orphan*/ stub1(int /*<<< orphan*/ **, TYPE_2__ const *);
void asn1_primitive_clear(ASN1_VALUE **pval, const ASN1_ITEM *it) {
  int utype;
  if (it && it->funcs) {
    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 = -1;
  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    11d1 <asn1_primitive_clear+0xd1>
cmpq   $0x0,-0x10(%rbp)
je     118c <asn1_primitive_clear+0x8c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2e5d(%rip),%rcx
cmp    (%rcx),%rax
jne    1198 <asn1_primitive_clear+0x98>
movl   $0xffffffff,-0x14(%rbp)
jmp    11a2 <asn1_primitive_clear+0xa2>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e2c(%rip),%rcx
cmp    (%rcx),%eax
jne    11c6 <asn1_primitive_clear+0xc6>
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
jmp    11d1 <asn1_primitive_clear+0xd1>
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<asn1_primitive_clear>:
mov    $0xffffffff,%eax
test   %rsi,%rsi
je     112f <asn1_primitive_clear+0x2f>
mov    0x10(%rsi),%rcx
test   %rcx,%rcx
je     111d <asn1_primitive_clear+0x1d>
mov    (%rcx),%rax
test   %rax,%rax
je     1140 <asn1_primitive_clear+0x40>
jmp    *%rax
mov    (%rsi),%rcx
mov    0x2eb9(%rip),%rdx
cmp    (%rdx),%rcx
je     112f <asn1_primitive_clear+0x2f>
mov    0x8(%rsi),%eax
mov    0x2ea2(%rip),%rcx
cmp    (%rcx),%eax
jne    1140 <asn1_primitive_clear+0x40>
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_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 %58
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 %42
41: ; preds = %35, %32
store i32 -1, i32* %5
br label %46
42: ; preds = %35
%43 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%44 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %43, i32 0, i32 1
%45 = load i32, i32* %44
store i32 %45, i32* %5
br label %46
46: ; preds = %42, %41
%47 = load i32, i32* %5
%48 = load i32, i32* @V_ASN1_BOOLEAN
%49 = icmp eq i32 %47, %48
br i1 %49, label %50, label %56
50: ; preds = %46
%51 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%52 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %51, i32 0, i32 2
%53 = load i32, i32* %52
%54 = load i32**, i32*** %3
%55 = bitcast i32** %54 to i32*
store i32 %53, i32* %55
br label %58
56: ; preds = %46
%57 = load i32**, i32*** %3
store i32* null, i32** %57
br label %58
58: ; preds = %31, %56, %50
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_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 %23, 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
br i1 %19, label %23, label %20
20: ; preds = %15
%21 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %1, i64 0, i32 1
%22 = load i32, i32* %21
br label %23
23: ; preds = %15, %2, %20
%24 = phi i32 [ %22, %20 ], [ -1, %2 ], [ -1, %15 ]
%25 = load i32, i32* @V_ASN1_BOOLEAN
%26 = icmp eq i32 %24, %25
br i1 %26, label %27, label %31
27: ; preds = %23
%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 = %23
store i32* null, i32** %0
br label %32
32: ; preds = %27, %31, %12, %14
ret void
}