#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) {
    const ASN1_PRIMITIVE_FUNCS *pf;
    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);
    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     119b <ASN1_primitive_free+0x5b>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1196 <ASN1_primitive_free+0x56>
mov    -0x20(%rbp),%rax
cmpq   $0x0,(%rax)
je     1196 <ASN1_primitive_free+0x56>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   *%rax
jmp    12e8 <ASN1_primitive_free+0x1a8>
jmp    119b <ASN1_primitive_free+0x5b>
cmpq   $0x0,-0x10(%rbp)
jne    11de <ASN1_primitive_free+0x9e>
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    11d9 <ASN1_primitive_free+0x99>
jmp    12e8 <ASN1_primitive_free+0x1a8>
jmp    1248 <ASN1_primitive_free+0x108>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    0x2df4(%rip),%rcx
cmp    (%rcx),%rax
jne    1214 <ASN1_primitive_free+0xd4>
movl   $0xffffffff,-0x14(%rbp)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jne    120f <ASN1_primitive_free+0xcf>
jmp    12e8 <ASN1_primitive_free+0x1a8>
jmp    1243 <ASN1_primitive_free+0x103>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x82,-0x14(%rbp)
je     123e <ASN1_primitive_free+0xfe>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
jne    123e <ASN1_primitive_free+0xfe>
jmp    12e8 <ASN1_primitive_free+0x1a8>
jmp    1243 <ASN1_primitive_free+0x103>
jmp    1248 <ASN1_primitive_free+0x108>
mov    -0x14(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x3,%eax
ja     12d1 <ASN1_primitive_free+0x191>
mov    -0x30(%rbp),%rax
lea    0xd98(%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    12dd <ASN1_primitive_free+0x19d>
cmpq   $0x0,-0x10(%rbp)
je     129f <ASN1_primitive_free+0x15f>
mov    -0x10(%rbp),%rax
mov    0xc(%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
jmp    12a9 <ASN1_primitive_free+0x169>
mov    -0x8(%rbp),%rax
movl   $0xffffffff,(%rax)
jmp    12e8 <ASN1_primitive_free+0x1a8>
jmp    12dd <ASN1_primitive_free+0x19d>
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    12dd <ASN1_primitive_free+0x19d>
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     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   1060 <ASN1_OBJECT_free@plt>
jmp    11e3 <ASN1_primitive_free+0xa3>
mov    0x8(%rsi),%eax
cmp    $0x82,%eax
je     11ca <ASN1_primitive_free+0x8a>
mov    (%rbx),%rdi
test   %rdi,%rdi
jne    118b <ASN1_primitive_free+0x4b>
jmp    1177 <ASN1_primitive_free+0x37>
call   1050 <ASN1_STRING_free@plt>
jmp    11e3 <ASN1_primitive_free+0xa3>
test   %rsi,%rsi
je     11ec <ASN1_primitive_free+0xac>
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 %29
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
store %struct.TYPE_9__* %13, %struct.TYPE_9__** %6
%14 = load %struct.TYPE_9__*, %struct.TYPE_9__** %6
%15 = icmp ne %struct.TYPE_9__* %14, null
br i1 %15, label %16, label %28
16: ; preds = %10
%17 = load %struct.TYPE_9__*, %struct.TYPE_9__** %6
%18 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %17, i32 0, i32 0
%19 = load i32 (i32**, %struct.TYPE_10__*)*, i32 (i32**, %struct.TYPE_10__*)** %18
%20 = icmp ne i32 (i32**, %struct.TYPE_10__*)* %19, null
br i1 %20, label %21, label %28
21: ; preds = %16
%22 = load %struct.TYPE_9__*, %struct.TYPE_9__** %6
%23 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %22, i32 0, i32 0
%24 = load i32 (i32**, %struct.TYPE_10__*)*, i32 (i32**, %struct.TYPE_10__*)** %23
%25 = load i32**, i32*** %3
%26 = load %struct.TYPE_10__*, %struct.TYPE_10__** %4
%27 = call i32 %24(i32** %25, %struct.TYPE_10__* %26)
br label %103
28: ; preds = %16, %10
br label %29
29: ; preds = %28, %2
%30 = load %struct.TYPE_10__*, %struct.TYPE_10__** %4
%31 = icmp ne %struct.TYPE_10__* %30, null
br i1 %31, label %47, label %32
32: ; preds = %29
%33 = load i32**, i32*** %3
%34 = load i32*, i32** %33
%35 = bitcast i32* %34 to %struct.TYPE_8__*
store %struct.TYPE_8__* %35, %struct.TYPE_8__** %7
%36 = load %struct.TYPE_8__*, %struct.TYPE_8__** %7
%37 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %36, i32 0, i32 0
%38 = load i32, i32* %37
store i32 %38, i32* %5
%39 = load %struct.TYPE_8__*, %struct.TYPE_8__** %7
%40 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %39, i32 0, i32 1
%41 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %40, i32 0, i32 0
store i32** %41, i32*** %3
%42 = load i32**, i32*** %3
%43 = load i32*, i32** %42
%44 = icmp ne i32* %43, null
br i1 %44, label %46, label %45
45: ; preds = %32
br label %103
46: ; preds = %32
br label %72
47: ; preds = %29
%48 = load %struct.TYPE_10__*, %struct.TYPE_10__** %4
%49 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %48, i32 0, i32 0
%50 = load i64, i64* %49
%51 = load i64, i64* @ASN1_ITYPE_MSTRING
%52 = icmp eq i64 %50, %51
br i1 %52, label %53, label %59
53: ; preds = %47
store i32 -1, i32* %5
%54 = load i32**, i32*** %3
%55 = load i32*, i32** %54
%56 = icmp ne i32* %55, null
br i1 %56, label %58, label %57
57: ; preds = %53
br label %103
58: ; preds = %53
br label %71
59: ; preds = %47
%60 = load %struct.TYPE_10__*, %struct.TYPE_10__** %4
%61 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %60, i32 0, i32 1
%62 = load i32, i32* %61
store i32 %62, i32* %5
%63 = load i32, i32* %5
%64 = icmp ne i32 %63, 130
br i1 %64, label %65, label %70
65: ; preds = %59
%66 = load i32**, i32*** %3
%67 = load i32*, i32** %66
%68 = icmp ne i32* %67, null
br i1 %68, label %70, label %69
69: ; preds = %65
br label %103
70: ; preds = %65, %59
br label %71
71: ; preds = %70, %58
br label %72
72: ; preds = %71, %46
%73 = load i32, i32* %5
switch i32 %73, label %97 [
i32 128, label %74
i32 130, label %78
i32 129, label %91
i32 131, label %92
]
74: ; preds = %72
%75 = load i32**, i32*** %3
%76 = load i32*, i32** %75
%77 = call i32 @ASN1_OBJECT_free(i32* %76)
br label %101
78: ; preds = %72
%79 = load %struct.TYPE_10__*, %struct.TYPE_10__** %4
%80 = icmp ne %struct.TYPE_10__* %79, null
br i1 %80, label %81, label %87
81: ; preds = %78
%82 = load %struct.TYPE_10__*, %struct.TYPE_10__** %4
%83 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %82, i32 0, i32 2
%84 = load i32, i32* %83
%85 = load i32**, i32*** %3
%86 = bitcast i32** %85 to i32*
store i32 %84, i32* %86
br label %90
87: ; preds = %78
%88 = load i32**, i32*** %3
%89 = bitcast i32** %88 to i32*
store i32 -1, i32* %89
br label %90
90: ; preds = %87, %81
br label %103
91: ; preds = %72
br label %101
92: ; preds = %72
%93 = load i32**, i32*** %3
%94 = load i32**, i32*** %3
%95 = load i32*, i32** %94
%96 = call i32 @free(i32* %95)
br label %101
97: ; preds = %72
%98 = load i32**, i32*** %3
%99 = load i32*, i32** %98
%100 = call i32 @ASN1_STRING_free(i32* %99)
br label %101
101: ; preds = %97, %92, %91, %74
%102 = load i32**, i32*** %3
store i32* null, i32** %102
br label %103
103: ; preds = %101, %90, %69, %57, %45, %21
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 %14, 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 %22, 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 = icmp eq i32 (i32**, %struct.TYPE_10__*)* %10, null
br i1 %11, label %22, label %12
12: ; preds = %8
%13 = tail call i32 %10(i32** %0, %struct.TYPE_10__* %1)
br label %60
14: ; preds = %2
%15 = bitcast i32** %0 to %struct.TYPE_8__**
%16 = load %struct.TYPE_8__*, %struct.TYPE_8__** %15
%17 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %16, i64 0, i32 0
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %16, i64 0, i32 1, i32 0
%20 = load i32*, i32** %19
%21 = icmp eq i32* %20, null
br i1 %21, label %60, label %37
22: ; preds = %4, %8
%23 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %1, i64 0, i32 0
%24 = load i64, i64* %23
%25 = load i64, i64* @ASN1_ITYPE_MSTRING
%26 = icmp eq i64 %24, %25
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = load i32*, i32** %0
%29 = icmp eq i32* %28, null
br i1 %29, label %60, label %54
30: ; preds = %22
%31 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %1, i64 0, i32 1
%32 = load i32, i32* %31
%33 = icmp eq i32 %32, 130
br i1 %33, label %44, label %34
34: ; preds = %30
%35 = load i32*, i32** %0
%36 = icmp eq i32* %35, null
br i1 %36, label %60, label %37
37: ; preds = %34, %14
%38 = phi i32* [ %35, %34 ], [ %20, %14 ]
%39 = phi i32 [ %32, %34 ], [ %18, %14 ]
%40 = phi i32** [ %0, %34 ], [ %19, %14 ]
switch i32 %39, label %54 [
i32 128, label %41
i32 130, label %43
i32 129, label %58
i32 131, label %51
]
41: ; preds = %37
%42 = tail call i32 @ASN1_OBJECT_free(i32* %38)
br label %58
43: ; preds = %37
br i1 %3, label %49, label %44
44: ; preds = %30, %43
%45 = phi i32** [ %40, %43 ], [ %0, %30 ]
%46 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %1, i64 0, i32 2
%47 = load i32, i32* %46
%48 = bitcast i32** %45 to i32*
store i32 %47, i32* %48
br label %60
49: ; preds = %43
%50 = bitcast i32** %40 to i32*
store i32 -1, i32* %50
br label %60
51: ; preds = %37
tail call void @ASN1_primitive_free(i32** %40, %struct.TYPE_10__* null)
%52 = load i32*, i32** %40
%53 = tail call i32 @free(i32* %52)
br label %58
54: ; preds = %27, %37
%55 = phi i32* [ %38, %37 ], [ %28, %27 ]
%56 = phi i32** [ %40, %37 ], [ %0, %27 ]
%57 = tail call i32 @ASN1_STRING_free(i32* %55)
br label %58
58: ; preds = %54, %51, %37, %41
%59 = phi i32** [ %56, %54 ], [ %40, %51 ], [ %40, %37 ], [ %40, %41 ]
store i32* null, i32** %59
br label %60
60: ; preds = %44, %49, %34, %27, %12, %14, %58
ret void
}