#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*/ ASN1_STRING_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*/ free(int /*<<< orphan*/ *);
int /*<<< orphan*/ stub1(int /*<<< orphan*/ **, TYPE_4__ const *);
void ASN1_primitive_free(ASN1_VALUE **pval, const ASN1_ITEM *it) {
  int utype;
  if (it != NULL && it->funcs != NULL) {
    const ASN1_PRIMITIVE_FUNCS *pf = it->funcs;
    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);
    free(*pval);
    break;
  default:
    ASN1_STRING_free((ASN1_STRING *)*pval);
    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)
cmpq   $0x0,-0x10(%rbp)
je     118c <ASN1_primitive_free+0x4c>
mov    -0x10(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     118c <ASN1_primitive_free+0x4c>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   *%rax
jmp    12d9 <ASN1_primitive_free+0x199>
cmpq   $0x0,-0x10(%rbp)
jne    11cf <ASN1_primitive_free+0x8f>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jne    11ca <ASN1_primitive_free+0x8a>
jmp    12d9 <ASN1_primitive_free+0x199>
jmp    1239 <ASN1_primitive_free+0xf9>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2e03(%rip),%rcx
cmp    (%rcx),%rax
jne    1205 <ASN1_primitive_free+0xc5>
movl   $0xffffffff,-0x14(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1200 <ASN1_primitive_free+0xc0>
jmp    12d9 <ASN1_primitive_free+0x199>
jmp    1234 <ASN1_primitive_free+0xf4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x82,-0x14(%rbp)
je     122f <ASN1_primitive_free+0xef>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jne    122f <ASN1_primitive_free+0xef>
jmp    12d9 <ASN1_primitive_free+0x199>
jmp    1234 <ASN1_primitive_free+0xf4>
jmp    1239 <ASN1_primitive_free+0xf9>
mov    -0x14(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x3,%eax
ja     12c2 <ASN1_primitive_free+0x182>
mov    -0x30(%rbp),%rax
lea    0xda7(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1060 <ASN1_OBJECT_free@plt>
jmp    12ce <ASN1_primitive_free+0x18e>
cmpq   $0x0,-0x10(%rbp)
je     1290 <ASN1_primitive_free+0x150>
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
jmp    129a <ASN1_primitive_free+0x15a>
mov    -0x8(%rbp),%rax
movl   $0xffffffff,(%rax)
jmp    12d9 <ASN1_primitive_free+0x199>
jmp    12ce <ASN1_primitive_free+0x18e>
mov    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <ASN1_primitive_free@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
jmp    12ce <ASN1_primitive_free+0x18e>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1050 <ASN1_STRING_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     115b <ASN1_primitive_free+0x1b>
mov    0x10(%rsi),%rax
test   %rax,%rax
je     118c <ASN1_primitive_free+0x4c>
mov    (%rax),%rax
mov    %rbx,%rdi
pop    %rbx
jmp    *%rax
mov    (%rbx),%rbx
mov    0x8(%rbx),%rdi
test   %rdi,%rdi
je     11bc <ASN1_primitive_free+0x7c>
mov    (%rbx),%eax
add    $0x8,%rbx
add    $0xffffff80,%eax
cmp    $0x3,%eax
ja     11a3 <ASN1_primitive_free+0x63>
lea    0xe84(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
call   1060 <ASN1_OBJECT_free@plt>
jmp    11dc <ASN1_primitive_free+0x9c>
mov    (%rsi),%rax
mov    0x2e4a(%rip),%rcx
cmp    (%rcx),%rax
jne    11aa <ASN1_primitive_free+0x6a>
mov    (%rbx),%rdi
test   %rdi,%rdi
je     11bc <ASN1_primitive_free+0x7c>
call   1050 <ASN1_STRING_free@plt>
jmp    11dc <ASN1_primitive_free+0x9c>
mov    0x8(%rsi),%eax
cmp    $0x82,%eax
je     11c3 <ASN1_primitive_free+0x83>
mov    (%rbx),%rdi
test   %rdi,%rdi
jne    116d <ASN1_primitive_free+0x2d>
pop    %rbx
ret
test   %rsi,%rsi
je     11e5 <ASN1_primitive_free+0xa5>
mov    0xc(%rsi),%eax
mov    %eax,(%rbx)
pop    %rbx
ret
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <ASN1_primitive_free@plt>
mov    (%rbx),%rdi
call   1030 <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) {
%3 = alloca i32**
%4 = alloca %struct.TYPE_10__*
%5 = alloca i32
%6 = alloca %struct.TYPE_9__*
%7 = alloca %struct.TYPE_8__*
store i32** %0, i32*** %3
store %struct.TYPE_10__* %1, %struct.TYPE_10__** %4
%8 = load %struct.TYPE_10__*, %struct.TYPE_10__** %4
%9 = icmp ne %struct.TYPE_10__* %8, null
br i1 %9, label %10, label %25
10: ; preds = %2
%11 = load %struct.TYPE_10__*, %struct.TYPE_10__** %4
%12 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %11, i32 0, i32 3
%13 = load %struct.TYPE_9__*, %struct.TYPE_9__** %12
%14 = icmp ne %struct.TYPE_9__* %13, null
br i1 %14, label %15, label %25
15: ; preds = %10
%16 = load %struct.TYPE_10__*, %struct.TYPE_10__** %4
%17 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %16, i32 0, i32 3
%18 = load %struct.TYPE_9__*, %struct.TYPE_9__** %17
store %struct.TYPE_9__* %18, %struct.TYPE_9__** %6
%19 = load %struct.TYPE_9__*, %struct.TYPE_9__** %6
%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 = load i32**, i32*** %3
%23 = load %struct.TYPE_10__*, %struct.TYPE_10__** %4
%24 = call i32 %21(i32** %22, %struct.TYPE_10__* %23)
br label %99
25: ; preds = %10, %2
%26 = load %struct.TYPE_10__*, %struct.TYPE_10__** %4
%27 = icmp ne %struct.TYPE_10__* %26, null
br i1 %27, label %43, label %28
28: ; preds = %25
%29 = load i32**, i32*** %3
%30 = load i32*, i32** %29
%31 = bitcast i32* %30 to %struct.TYPE_8__*
store %struct.TYPE_8__* %31, %struct.TYPE_8__** %7
%32 = load %struct.TYPE_8__*, %struct.TYPE_8__** %7
%33 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %32, i32 0, i32 0
%34 = load i32, i32* %33
store i32 %34, i32* %5
%35 = load %struct.TYPE_8__*, %struct.TYPE_8__** %7
%36 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %35, i32 0, i32 1
%37 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %36, i32 0, i32 0
store i32** %37, i32*** %3
%38 = load i32**, i32*** %3
%39 = load i32*, i32** %38
%40 = icmp ne i32* %39, null
br i1 %40, label %42, label %41
41: ; preds = %28
br label %99
42: ; preds = %28
br label %68
43: ; preds = %25
%44 = load %struct.TYPE_10__*, %struct.TYPE_10__** %4
%45 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %44, i32 0, i32 0
%46 = load i64, i64* %45
%47 = load i64, i64* @ASN1_ITYPE_MSTRING
%48 = icmp eq i64 %46, %47
br i1 %48, label %49, label %55
49: ; preds = %43
store i32 -1, i32* %5
%50 = load i32**, i32*** %3
%51 = load i32*, i32** %50
%52 = icmp ne i32* %51, null
br i1 %52, label %54, label %53
53: ; preds = %49
br label %99
54: ; preds = %49
br label %67
55: ; preds = %43
%56 = load %struct.TYPE_10__*, %struct.TYPE_10__** %4
%57 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %56, i32 0, i32 1
%58 = load i32, i32* %57
store i32 %58, i32* %5
%59 = load i32, i32* %5
%60 = icmp ne i32 %59, 130
br i1 %60, label %61, label %66
61: ; preds = %55
%62 = load i32**, i32*** %3
%63 = load i32*, i32** %62
%64 = icmp ne i32* %63, null
br i1 %64, label %66, label %65
65: ; preds = %61
br label %99
66: ; preds = %61, %55
br label %67
67: ; preds = %66, %54
br label %68
68: ; preds = %67, %42
%69 = load i32, i32* %5
switch i32 %69, label %93 [
i32 128, label %70
i32 130, label %74
i32 129, label %87
i32 131, label %88
]
70: ; preds = %68
%71 = load i32**, i32*** %3
%72 = load i32*, i32** %71
%73 = call i32 @ASN1_OBJECT_free(i32* %72)
br label %97
74: ; preds = %68
%75 = load %struct.TYPE_10__*, %struct.TYPE_10__** %4
%76 = icmp ne %struct.TYPE_10__* %75, null
br i1 %76, label %77, label %83
77: ; preds = %74
%78 = load %struct.TYPE_10__*, %struct.TYPE_10__** %4
%79 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %78, i32 0, i32 2
%80 = load i32, i32* %79
%81 = load i32**, i32*** %3
%82 = bitcast i32** %81 to i32*
store i32 %80, i32* %82
br label %86
83: ; preds = %74
%84 = load i32**, i32*** %3
%85 = bitcast i32** %84 to i32*
store i32 -1, i32* %85
br label %86
86: ; preds = %83, %77
br label %99
87: ; preds = %68
br label %97
88: ; preds = %68
%89 = load i32**, i32*** %3
%90 = load i32**, i32*** %3
%91 = load i32*, i32** %90
%92 = call i32 @free(i32* %91)
br label %97
93: ; preds = %68
%94 = load i32**, i32*** %3
%95 = load i32*, i32** %94
%96 = call i32 @ASN1_STRING_free(i32* %95)
br label %97
97: ; preds = %93, %88, %87, %70
%98 = load i32**, i32*** %3
store i32* null, i32** %98
br label %99
99: ; preds = %97, %86, %65, %53, %41, %15
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) {
%3 = icmp eq %struct.TYPE_10__* %1, null
br i1 %3, label %12, label %4
4: ; preds = %2
%5 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %1, i64 0, i32 3
%6 = load %struct.TYPE_9__*, %struct.TYPE_9__** %5
%7 = icmp eq %struct.TYPE_9__* %6, null
br i1 %7, label %20, label %8
8: ; preds = %4
%9 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %6, i64 0, i32 0
%10 = load i32 (i32**, %struct.TYPE_10__*)*, i32 (i32**, %struct.TYPE_10__*)** %9
%11 = tail call i32 %10(i32** %0, %struct.TYPE_10__* %1)
br label %58
12: ; preds = %2
%13 = bitcast i32** %0 to %struct.TYPE_8__**
%14 = load %struct.TYPE_8__*, %struct.TYPE_8__** %13
%15 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %14, i64 0, i32 0
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %14, i64 0, i32 1, i32 0
%18 = load i32*, i32** %17
%19 = icmp eq i32* %18, null
br i1 %19, label %58, label %35
20: ; preds = %4
%21 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %1, i64 0, i32 0
%22 = load i64, i64* %21
%23 = load i64, i64* @ASN1_ITYPE_MSTRING
%24 = icmp eq i64 %22, %23
br i1 %24, label %25, label %28
25: ; preds = %20
%26 = load i32*, i32** %0
%27 = icmp eq i32* %26, null
br i1 %27, label %58, label %52
28: ; preds = %20
%29 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %1, i64 0, i32 1
%30 = load i32, i32* %29
%31 = icmp eq i32 %30, 130
br i1 %31, label %42, label %32
32: ; preds = %28
%33 = load i32*, i32** %0
%34 = icmp eq i32* %33, null
br i1 %34, label %58, label %35
35: ; preds = %32, %12
%36 = phi i32* [ %33, %32 ], [ %18, %12 ]
%37 = phi i32 [ %30, %32 ], [ %16, %12 ]
%38 = phi i32** [ %0, %32 ], [ %17, %12 ]
switch i32 %37, label %52 [
i32 128, label %39
i32 130, label %41
i32 129, label %56
i32 131, label %49
]
39: ; preds = %35
%40 = tail call i32 @ASN1_OBJECT_free(i32* %36)
br label %56
41: ; preds = %35
br i1 %3, label %47, label %42
42: ; preds = %28, %41
%43 = phi i32** [ %38, %41 ], [ %0, %28 ]
%44 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %1, i64 0, i32 2
%45 = load i32, i32* %44
%46 = bitcast i32** %43 to i32*
store i32 %45, i32* %46
br label %58
47: ; preds = %41
%48 = bitcast i32** %38 to i32*
store i32 -1, i32* %48
br label %58
49: ; preds = %35
tail call void @ASN1_primitive_free(i32** %38, %struct.TYPE_10__* null)
%50 = load i32*, i32** %38
%51 = tail call i32 @free(i32* %50)
br label %56
52: ; preds = %25, %35
%53 = phi i32* [ %36, %35 ], [ %26, %25 ]
%54 = phi i32** [ %38, %35 ], [ %0, %25 ]
%55 = tail call i32 @ASN1_STRING_free(i32* %53)
br label %56
56: ; preds = %52, %49, %35, %39
%57 = phi i32** [ %54, %52 ], [ %38, %49 ], [ %38, %35 ], [ %38, %39 ]
store i32* null, i32** %57
br label %58
58: ; preds = %42, %47, %32, %25, %12, %56, %8
ret void
}