#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;
  const ASN1_PRIMITIVE_FUNCS *pf;
  pf = it->funcs;
  if (pf) {
    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)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     115b <asn1_primitive_clear+0x5b>
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     114b <asn1_primitive_clear+0x4b>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   *%rax
jmp    1156 <asn1_primitive_clear+0x56>
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
jmp    11c2 <asn1_primitive_clear+0xc2>
cmpq   $0x0,-0x10(%rbp)
je     117d <asn1_primitive_clear+0x7d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2e6c(%rip),%rcx
cmp    (%rcx),%rax
jne    1189 <asn1_primitive_clear+0x89>
movl   $0xffffffff,-0x14(%rbp)
jmp    1193 <asn1_primitive_clear+0x93>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e3b(%rip),%rcx
cmp    (%rcx),%eax
jne    11b7 <asn1_primitive_clear+0xb7>
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
jmp    11c2 <asn1_primitive_clear+0xc2>
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<asn1_primitive_clear>:
mov    0x10(%rsi),%rax
test   %rax,%rax
je     1113 <asn1_primitive_clear+0x13>
mov    (%rax),%rax
test   %rax,%rax
je     113b <asn1_primitive_clear+0x3b>
jmp    *%rax
mov    (%rsi),%rcx
mov    0x2ec3(%rip),%rdx
mov    $0xffffffff,%eax
cmp    (%rdx),%rcx
je     112a <asn1_primitive_clear+0x2a>
mov    0x8(%rsi),%eax
mov    0x2ea7(%rip),%rcx
cmp    (%rcx),%eax
jne    113b <asn1_primitive_clear+0x3b>
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 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %7, i32 0, i32 3
%9 = load %struct.TYPE_5__*, %struct.TYPE_5__** %8
store %struct.TYPE_5__* %9, %struct.TYPE_5__** %6
%10 = load %struct.TYPE_5__*, %struct.TYPE_5__** %6
%11 = icmp ne %struct.TYPE_5__* %10, null
br i1 %11, label %12, label %27
12: ; preds = %2
%13 = load %struct.TYPE_5__*, %struct.TYPE_5__** %6
%14 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %13, i32 0, i32 0
%15 = load i32 (i32**, %struct.TYPE_6__*)*, i32 (i32**, %struct.TYPE_6__*)** %14
%16 = icmp ne i32 (i32**, %struct.TYPE_6__*)* %15, null
br i1 %16, label %17, label %24
17: ; preds = %12
%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 = load i32**, i32*** %3
%22 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%23 = call i32 %20(i32** %21, %struct.TYPE_6__* %22)
br label %26
24: ; preds = %12
%25 = load i32**, i32*** %3
store i32* null, i32** %25
br label %26
26: ; preds = %24, %17
br label %53
27: ; preds = %2
%28 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%29 = icmp ne %struct.TYPE_6__* %28, null
br i1 %29, label %30, label %36
30: ; preds = %27
%31 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%32 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %31, i32 0, i32 0
%33 = load i64, i64* %32
%34 = load i64, i64* @ASN1_ITYPE_MSTRING
%35 = icmp eq i64 %33, %34
br i1 %35, label %36, label %37
36: ; preds = %30, %27
store i32 -1, i32* %5
br label %41
37: ; preds = %30
%38 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%39 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %38, i32 0, i32 1
%40 = load i32, i32* %39
store i32 %40, i32* %5
br label %41
41: ; preds = %37, %36
%42 = load i32, i32* %5
%43 = load i32, i32* @V_ASN1_BOOLEAN
%44 = icmp eq i32 %42, %43
br i1 %44, label %45, label %51
45: ; preds = %41
%46 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%47 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %46, i32 0, i32 2
%48 = load i32, i32* %47
%49 = load i32**, i32*** %3
%50 = bitcast i32** %49 to i32*
store i32 %48, i32* %50
br label %53
51: ; preds = %41
%52 = load i32**, i32*** %3
store i32* null, i32** %52
br label %53
53: ; preds = %26, %51, %45
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 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %1, i64 0, i32 3
%4 = load %struct.TYPE_5__*, %struct.TYPE_5__** %3
%5 = icmp eq %struct.TYPE_5__* %4, null
br i1 %5, label %13, label %6
6: ; preds = %2
%7 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %4, i64 0, i32 0
%8 = load i32 (i32**, %struct.TYPE_6__*)*, i32 (i32**, %struct.TYPE_6__*)** %7
%9 = icmp eq i32 (i32**, %struct.TYPE_6__*)* %8, null
br i1 %9, label %12, label %10
10: ; preds = %6
%11 = tail call i32 %8(i32** %0, %struct.TYPE_6__* %1)
br label %30
12: ; preds = %6
store i32* null, i32** %0
br label %30
13: ; preds = %2
%14 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %1, i64 0, i32 0
%15 = load i64, i64* %14
%16 = load i64, i64* @ASN1_ITYPE_MSTRING
%17 = icmp eq i64 %15, %16
br i1 %17, label %21, label %18
18: ; preds = %13
%19 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %1, i64 0, i32 1
%20 = load i32, i32* %19
br label %21
21: ; preds = %13, %18
%22 = phi i32 [ %20, %18 ], [ -1, %13 ]
%23 = load i32, i32* @V_ASN1_BOOLEAN
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %1, i64 0, i32 2
%27 = load i32, i32* %26
%28 = bitcast i32** %0 to i32*
store i32 %27, i32* %28
br label %30
29: ; preds = %21
store i32* null, i32** %0
br label %30
30: ; preds = %25, %29, %10, %12
ret void
}