#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_10__ TYPE_4__;
typedef struct TYPE_9__ TYPE_3__;
typedef struct TYPE_8__ TYPE_2__;
typedef struct TYPE_7__ TYPE_1__;

/* Type definitions */
struct TYPE_10__ {
  scalar_t__ itype;
  int utype;
  int size;
  TYPE_3__ *funcs;
};
struct TYPE_9__ {
  int /*<<< orphan*/ (*prim_free)(int /*<<< orphan*/ **, TYPE_4__ const *);
};
struct TYPE_7__ {
  int /*<<< orphan*/ *asn1_value;
};
struct TYPE_8__ {
  int type;
  TYPE_1__ value;
};
typedef int /*<<< orphan*/ ASN1_VALUE;
typedef TYPE_2__ ASN1_TYPE;
typedef int /*<<< orphan*/ ASN1_STRING;
typedef TYPE_3__ ASN1_PRIMITIVE_FUNCS;
typedef int /*<<< orphan*/ ASN1_OBJECT;
typedef TYPE_4__ ASN1_ITEM;
typedef int ASN1_BOOLEAN;

/* Variables and functions */
scalar_t__ ASN1_ITYPE_MSTRING;
int /*<<< orphan*/ ASN1_OBJECT_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ OPENSSL_free(int /*<<< orphan*/ *);
#define V_ASN1_ANY 131
#define V_ASN1_BOOLEAN 130
#define V_ASN1_NULL 129
#define V_ASN1_OBJECT 128
int /*<<< orphan*/ asn1_string_embed_free(int /*<<< orphan*/ *, int);
int /*<<< orphan*/ stub1(int /*<<< orphan*/ **, TYPE_4__ const *);
void asn1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed) {
  int utype;
  if (it) {
    const ASN1_PRIMITIVE_FUNCS *pf = it->funcs;
    if (pf && pf->prim_free) {
      pf->prim_free(pval, it);
      return;
    }
  }
  if (!it) {
    ASN1_TYPE *typ = (ASN1_TYPE *)*pval;
    utype = typ->type;
    pval = &typ->value.asn1_value;
    if (!*pval)
      return;
  } else if (it->itype == ASN1_ITYPE_MSTRING) {
    utype = -1;
    if (!*pval)
      return;
  } else {
    utype = it->utype;
    if ((utype != V_ASN1_BOOLEAN) && !*pval)
      return;
  }
  switch (utype) {
  case V_ASN1_OBJECT:
    ASN1_OBJECT_free((ASN1_OBJECT *)*pval);
    break;
  case V_ASN1_BOOLEAN:
    if (it)
      *(ASN1_BOOLEAN *)pval = it->size;
    else
      *(ASN1_BOOLEAN *)pval = -1;
    return;
  case V_ASN1_NULL:
    break;
  case V_ASN1_ANY:
    asn1_primitive_free(pval, NULL, 0);
    OPENSSL_free(*pval);
    break;
  default:
    asn1_string_embed_free((ASN1_STRING *)*pval, embed);
    break;
  }
  *pval = NULL;
}


x86 assembly (clang, -O0):
<asn1_primitive_free>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     119e <asn1_primitive_free+0x5e>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1199 <asn1_primitive_free+0x59>
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     1199 <asn1_primitive_free+0x59>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   *%rax
jmp    12f0 <asn1_primitive_free+0x1b0>
jmp    119e <asn1_primitive_free+0x5e>
cmpq   $0x0,-0x10(%rbp)
jne    11e1 <asn1_primitive_free+0xa1>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11dc <asn1_primitive_free+0x9c>
jmp    12f0 <asn1_primitive_free+0x1b0>
jmp    124b <asn1_primitive_free+0x10b>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2df1(%rip),%rcx
cmp    (%rcx),%rax
jne    1217 <asn1_primitive_free+0xd7>
movl   $0xffffffff,-0x18(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1212 <asn1_primitive_free+0xd2>
jmp    12f0 <asn1_primitive_free+0x1b0>
jmp    1246 <asn1_primitive_free+0x106>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x82,-0x18(%rbp)
je     1241 <asn1_primitive_free+0x101>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1241 <asn1_primitive_free+0x101>
jmp    12f0 <asn1_primitive_free+0x1b0>
jmp    1246 <asn1_primitive_free+0x106>
jmp    124b <asn1_primitive_free+0x10b>
mov    -0x18(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x3,%eax
ja     12d6 <asn1_primitive_free+0x196>
mov    -0x30(%rbp),%rax
lea    0xd95(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1040 <ASN1_OBJECT_free@plt>
jmp    12e5 <asn1_primitive_free+0x1a5>
cmpq   $0x0,-0x10(%rbp)
je     12a2 <asn1_primitive_free+0x162>
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
jmp    12ac <asn1_primitive_free+0x16c>
mov    -0x8(%rbp),%rax
movl   $0xffffffff,(%rax)
jmp    12f0 <asn1_primitive_free+0x1b0>
jmp    12e5 <asn1_primitive_free+0x1a5>
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1060 <asn1_primitive_free@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1050 <OPENSSL_free@plt>
jmp    12e5 <asn1_primitive_free+0x1a5>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x14(%rbp),%esi
call   1030 <asn1_string_embed_free@plt>
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<asn1_primitive_free>:
push   %rbx
mov    %rdi,%rbx
test   %rsi,%rsi
je     1179 <asn1_primitive_free+0x39>
mov    0x10(%rsi),%rax
test   %rax,%rax
je     1160 <asn1_primitive_free+0x20>
mov    (%rax),%rax
test   %rax,%rax
je     1160 <asn1_primitive_free+0x20>
mov    %rbx,%rdi
pop    %rbx
jmp    *%rax
mov    (%rsi),%rax
mov    0x2e76(%rip),%rcx
cmp    (%rcx),%rax
jne    11aa <asn1_primitive_free+0x6a>
mov    (%rbx),%rdi
test   %rdi,%rdi
jne    11be <asn1_primitive_free+0x7e>
pop    %rbx
ret
mov    (%rbx),%rbx
mov    0x8(%rbx),%rdi
test   %rdi,%rdi
je     1177 <asn1_primitive_free+0x37>
mov    (%rbx),%eax
add    $0x8,%rbx
add    $0xffffff80,%eax
cmp    $0x3,%eax
ja     11be <asn1_primitive_free+0x7e>
lea    0xe66(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
call   1040 <ASN1_OBJECT_free@plt>
jmp    11e7 <asn1_primitive_free+0xa7>
mov    0x8(%rsi),%eax
cmp    $0x82,%eax
je     11cc <asn1_primitive_free+0x8c>
mov    (%rbx),%rdi
test   %rdi,%rdi
jne    118b <asn1_primitive_free+0x4b>
jmp    1177 <asn1_primitive_free+0x37>
mov    %edx,%esi
call   1030 <asn1_string_embed_free@plt>
jmp    11e7 <asn1_primitive_free+0xa7>
test   %rsi,%rsi
je     11f0 <asn1_primitive_free+0xb0>
mov    0xc(%rsi),%eax
mov    %eax,(%rbx)
pop    %rbx
ret
mov    %rbx,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   1060 <asn1_primitive_free@plt>
mov    (%rbx),%rdi
call   1050 <OPENSSL_free@plt>
movq   $0x0,(%rbx)
pop    %rbx
ret
movl   $0xffffffff,(%rbx)
pop    %rbx
ret

LLVM IR (-O0):
%struct.TYPE_10__ = type { i64, i32, i32, %struct.TYPE_9__* }
%struct.TYPE_9__ = type { i32 (i32**, %struct.TYPE_10__*)* }
%struct.TYPE_8__ = type { i32, %struct.TYPE_7__ }
%struct.TYPE_7__ = type { i32* }
@ASN1_ITYPE_MSTRING = global i64 0
define void @asn1_primitive_free(i32** %0, %struct.TYPE_10__* %1, i32 %2) {
%4 = alloca i32**
%5 = alloca %struct.TYPE_10__*
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.TYPE_9__*
%9 = alloca %struct.TYPE_8__*
store i32** %0, i32*** %4
store %struct.TYPE_10__* %1, %struct.TYPE_10__** %5
store i32 %2, i32* %6
%10 = load %struct.TYPE_10__*, %struct.TYPE_10__** %5
%11 = icmp ne %struct.TYPE_10__* %10, null
br i1 %11, label %12, label %31
12: ; preds = %3
%13 = load %struct.TYPE_10__*, %struct.TYPE_10__** %5
%14 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %13, i32 0, i32 3
%15 = load %struct.TYPE_9__*, %struct.TYPE_9__** %14
store %struct.TYPE_9__* %15, %struct.TYPE_9__** %8
%16 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%17 = icmp ne %struct.TYPE_9__* %16, null
br i1 %17, label %18, label %30
18: ; preds = %12
%19 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%20 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %19, i32 0, i32 0
%21 = load i32 (i32**, %struct.TYPE_10__*)*, i32 (i32**, %struct.TYPE_10__*)** %20
%22 = icmp ne i32 (i32**, %struct.TYPE_10__*)* %21, null
br i1 %22, label %23, label %30
23: ; preds = %18
%24 = load %struct.TYPE_9__*, %struct.TYPE_9__** %8
%25 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %24, i32 0, i32 0
%26 = load i32 (i32**, %struct.TYPE_10__*)*, i32 (i32**, %struct.TYPE_10__*)** %25
%27 = load i32**, i32*** %4
%28 = load %struct.TYPE_10__*, %struct.TYPE_10__** %5
%29 = call i32 %26(i32** %27, %struct.TYPE_10__* %28)
br label %106
30: ; preds = %18, %12
br label %31
31: ; preds = %30, %3
%32 = load %struct.TYPE_10__*, %struct.TYPE_10__** %5
%33 = icmp ne %struct.TYPE_10__* %32, null
br i1 %33, label %49, label %34
34: ; preds = %31
%35 = load i32**, i32*** %4
%36 = load i32*, i32** %35
%37 = bitcast i32* %36 to %struct.TYPE_8__*
store %struct.TYPE_8__* %37, %struct.TYPE_8__** %9
%38 = load %struct.TYPE_8__*, %struct.TYPE_8__** %9
%39 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %38, i32 0, i32 0
%40 = load i32, i32* %39
store i32 %40, i32* %7
%41 = load %struct.TYPE_8__*, %struct.TYPE_8__** %9
%42 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %41, i32 0, i32 1
%43 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %42, i32 0, i32 0
store i32** %43, i32*** %4
%44 = load i32**, i32*** %4
%45 = load i32*, i32** %44
%46 = icmp ne i32* %45, null
br i1 %46, label %48, label %47
47: ; preds = %34
br label %106
48: ; preds = %34
br label %74
49: ; preds = %31
%50 = load %struct.TYPE_10__*, %struct.TYPE_10__** %5
%51 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %50, i32 0, i32 0
%52 = load i64, i64* %51
%53 = load i64, i64* @ASN1_ITYPE_MSTRING
%54 = icmp eq i64 %52, %53
br i1 %54, label %55, label %61
55: ; preds = %49
store i32 -1, i32* %7
%56 = load i32**, i32*** %4
%57 = load i32*, i32** %56
%58 = icmp ne i32* %57, null
br i1 %58, label %60, label %59
59: ; preds = %55
br label %106
60: ; preds = %55
br label %73
61: ; preds = %49
%62 = load %struct.TYPE_10__*, %struct.TYPE_10__** %5
%63 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %62, i32 0, i32 1
%64 = load i32, i32* %63
store i32 %64, i32* %7
%65 = load i32, i32* %7
%66 = icmp ne i32 %65, 130
br i1 %66, label %67, label %72
67: ; preds = %61
%68 = load i32**, i32*** %4
%69 = load i32*, i32** %68
%70 = icmp ne i32* %69, null
br i1 %70, label %72, label %71
71: ; preds = %67
br label %106
72: ; preds = %67, %61
br label %73
73: ; preds = %72, %60
br label %74
74: ; preds = %73, %48
%75 = load i32, i32* %7
switch i32 %75, label %99 [
i32 128, label %76
i32 130, label %80
i32 129, label %93
i32 131, label %94
]
76: ; preds = %74
%77 = load i32**, i32*** %4
%78 = load i32*, i32** %77
%79 = call i32 @ASN1_OBJECT_free(i32* %78)
br label %104
80: ; preds = %74
%81 = load %struct.TYPE_10__*, %struct.TYPE_10__** %5
%82 = icmp ne %struct.TYPE_10__* %81, null
br i1 %82, label %83, label %89
83: ; preds = %80
%84 = load %struct.TYPE_10__*, %struct.TYPE_10__** %5
%85 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %84, i32 0, i32 2
%86 = load i32, i32* %85
%87 = load i32**, i32*** %4
%88 = bitcast i32** %87 to i32*
store i32 %86, i32* %88
br label %92
89: ; preds = %80
%90 = load i32**, i32*** %4
%91 = bitcast i32** %90 to i32*
store i32 -1, i32* %91
br label %92
92: ; preds = %89, %83
br label %106
93: ; preds = %74
br label %104
94: ; preds = %74
%95 = load i32**, i32*** %4
%96 = load i32**, i32*** %4
%97 = load i32*, i32** %96
%98 = call i32 @OPENSSL_free(i32* %97)
br label %104
99: ; preds = %74
%100 = load i32**, i32*** %4
%101 = load i32*, i32** %100
%102 = load i32, i32* %6
%103 = call i32 @asn1_string_embed_free(i32* %101, i32 %102)
br label %104
104: ; preds = %99, %94, %93, %76
%105 = load i32**, i32*** %4
store i32* null, i32** %105
br label %106
106: ; preds = %104, %92, %71, %59, %47, %23
ret void
}

LLVM IR (-O2):
%struct.TYPE_10__ = type { i64, i32, i32, %struct.TYPE_9__* }
%struct.TYPE_9__ = type { i32 (i32**, %struct.TYPE_10__*)* }
%struct.TYPE_8__ = type { i32, %struct.TYPE_7__ }
%struct.TYPE_7__ = type { i32* }
@ASN1_ITYPE_MSTRING = global i64 0
define void @asn1_primitive_free(i32** %0, %struct.TYPE_10__* %1, i32 %2) {
%4 = icmp eq %struct.TYPE_10__* %1, null
br i1 %4, label %15, label %5
5: ; preds = %3
%6 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %1, i64 0, i32 3
%7 = load %struct.TYPE_9__*, %struct.TYPE_9__** %6
%8 = icmp eq %struct.TYPE_9__* %7, null
br i1 %8, label %23, label %9
9: ; preds = %5
%10 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %7, i64 0, i32 0
%11 = load i32 (i32**, %struct.TYPE_10__*)*, i32 (i32**, %struct.TYPE_10__*)** %10
%12 = icmp eq i32 (i32**, %struct.TYPE_10__*)* %11, null
br i1 %12, label %23, label %13
13: ; preds = %9
%14 = tail call i32 %11(i32** %0, %struct.TYPE_10__* %1)
br label %61
15: ; preds = %3
%16 = bitcast i32** %0 to %struct.TYPE_8__**
%17 = load %struct.TYPE_8__*, %struct.TYPE_8__** %16
%18 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %17, i64 0, i32 0
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %17, i64 0, i32 1, i32 0
%21 = load i32*, i32** %20
%22 = icmp eq i32* %21, null
br i1 %22, label %61, label %38
23: ; preds = %5, %9
%24 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %1, i64 0, i32 0
%25 = load i64, i64* %24
%26 = load i64, i64* @ASN1_ITYPE_MSTRING
%27 = icmp eq i64 %25, %26
br i1 %27, label %28, label %31
28: ; preds = %23
%29 = load i32*, i32** %0
%30 = icmp eq i32* %29, null
br i1 %30, label %61, label %55
31: ; preds = %23
%32 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %1, i64 0, i32 1
%33 = load i32, i32* %32
%34 = icmp eq i32 %33, 130
br i1 %34, label %45, label %35
35: ; preds = %31
%36 = load i32*, i32** %0
%37 = icmp eq i32* %36, null
br i1 %37, label %61, label %38
38: ; preds = %35, %15
%39 = phi i32* [ %36, %35 ], [ %21, %15 ]
%40 = phi i32 [ %33, %35 ], [ %19, %15 ]
%41 = phi i32** [ %0, %35 ], [ %20, %15 ]
switch i32 %40, label %55 [
i32 128, label %42
i32 130, label %44
i32 129, label %59
i32 131, label %52
]
42: ; preds = %38
%43 = tail call i32 @ASN1_OBJECT_free(i32* %39)
br label %59
44: ; preds = %38
br i1 %4, label %50, label %45
45: ; preds = %31, %44
%46 = phi i32** [ %41, %44 ], [ %0, %31 ]
%47 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %1, i64 0, i32 2
%48 = load i32, i32* %47
%49 = bitcast i32** %46 to i32*
store i32 %48, i32* %49
br label %61
50: ; preds = %44
%51 = bitcast i32** %41 to i32*
store i32 -1, i32* %51
br label %61
52: ; preds = %38
tail call void @asn1_primitive_free(i32** %41, %struct.TYPE_10__* null, i32 0)
%53 = load i32*, i32** %41
%54 = tail call i32 @OPENSSL_free(i32* %53)
br label %59
55: ; preds = %28, %38
%56 = phi i32* [ %39, %38 ], [ %29, %28 ]
%57 = phi i32** [ %41, %38 ], [ %0, %28 ]
%58 = tail call i32 @asn1_string_embed_free(i32* %56, i32 %2)
br label %59
59: ; preds = %55, %52, %38, %42
%60 = phi i32** [ %57, %55 ], [ %41, %52 ], [ %41, %38 ], [ %41, %42 ]
store i32* null, i32** %60
br label %61
61: ; preds = %45, %50, %35, %28, %13, %15, %59
ret void
}