#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_16__ TYPE_5__;
typedef struct TYPE_15__ TYPE_4__;
typedef struct TYPE_14__ TYPE_3__;
typedef struct TYPE_13__ TYPE_2__;
typedef struct TYPE_12__ TYPE_1__;

/* Type definitions */
struct TYPE_16__ {
  scalar_t__ itype;
  int utype;
  int /*<<< orphan*/ size;
  TYPE_4__ *funcs;
};
struct TYPE_15__ {
  int (*prim_new)(int /*<<< orphan*/ **, TYPE_5__ const *);
  int /*<<< orphan*/ (*prim_clear)(int /*<<< orphan*/ **, TYPE_5__ const *);
};
struct TYPE_14__ {
  int type;
  int /*<<< orphan*/ flags;
};
struct TYPE_12__ {
  int /*<<< orphan*/ *ptr;
};
struct TYPE_13__ {
  int type;
  TYPE_1__ value;
};
typedef int /*<<< orphan*/ ASN1_VALUE;
typedef TYPE_2__ ASN1_TYPE;
typedef TYPE_3__ ASN1_STRING;
typedef TYPE_4__ ASN1_PRIMITIVE_FUNCS;
typedef TYPE_5__ ASN1_ITEM;
typedef int /*<<< orphan*/ ASN1_BOOLEAN;

/* Variables and functions */
scalar_t__ ASN1_ITYPE_MSTRING;
int /*<<< orphan*/ ASN1_STRING_FLAG_EMBED;
int /*<<< orphan*/ ASN1_STRING_FLAG_MSTRING;
TYPE_3__ *ASN1_STRING_type_new(int);
int /*<<< orphan*/ ERR_LIB_ASN1;
int /*<<< orphan*/ ERR_R_MALLOC_FAILURE;
int /*<<< orphan*/ ERR_raise(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ NID_undef;
scalar_t__ OBJ_nid2obj(int /*<<< orphan*/);
TYPE_2__ *OPENSSL_malloc(int);
#define V_ASN1_ANY 131
#define V_ASN1_BOOLEAN 130
#define V_ASN1_NULL 129
#define V_ASN1_OBJECT 128
int /*<<< orphan*/ memset(TYPE_3__ *, int /*<<< orphan*/, int);
int /*<<< orphan*/ stub1(int /*<<< orphan*/ **, TYPE_5__ const *);
int stub2(int /*<<< orphan*/ **, TYPE_5__ const *);
int asn1_primitive_new(ASN1_VALUE **pval, const ASN1_ITEM *it, int embed) {
  ASN1_TYPE *typ;
  ASN1_STRING *str;
  int utype;
  if (!it)
    return 0;
  if (it->funcs) {
    const ASN1_PRIMITIVE_FUNCS *pf = it->funcs;
    if (embed) {
      if (pf->prim_clear) {
        pf->prim_clear(pval, it);
        return 1;
      }
    } else if (pf->prim_new) {
      return pf->prim_new(pval, it);
    }
  }
  if (it->itype == ASN1_ITYPE_MSTRING)
    utype = -1;
  else
    utype = it->utype;
  switch (utype) {
  case V_ASN1_OBJECT:
    *pval = (ASN1_VALUE *)OBJ_nid2obj(NID_undef);
    return 1;
  case V_ASN1_BOOLEAN:
    *(ASN1_BOOLEAN *)pval = it->size;
    return 1;
  case V_ASN1_NULL:
    *pval = (ASN1_VALUE *)1;
    return 1;
  case V_ASN1_ANY:
    if ((typ = OPENSSL_malloc(sizeof(*typ))) == NULL) {
      ERR_raise(ERR_LIB_ASN1, ERR_R_MALLOC_FAILURE);
      return 0;
    }
    typ->value.ptr = NULL;
    typ->type = -1;
    *pval = (ASN1_VALUE *)typ;
    break;
  default:
    if (embed) {
      str = *(ASN1_STRING **)pval;
      memset(str, 0, sizeof(*str));
      str->type = utype;
      str->flags = ASN1_STRING_FLAG_EMBED;
    } else {
      str = ASN1_STRING_type_new(utype);
      *pval = (ASN1_VALUE *)str;
    }
    if (it->itype == ASN1_ITYPE_MSTRING && str)
      str->flags |= ASN1_STRING_FLAG_MSTRING;
    break;
  }
  if (*pval)
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<asn1_primitive_new>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    117a <asn1_primitive_new+0x2a>
movl   $0x0,-0x4(%rbp)
jmp    13c3 <asn1_primitive_new+0x273>
mov    -0x18(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     1202 <asn1_primitive_new+0xb2>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x40(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11d1 <asn1_primitive_new+0x81>
mov    -0x40(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     11cc <asn1_primitive_new+0x7c>
mov    -0x40(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   *%rax
movl   $0x1,-0x4(%rbp)
jmp    13c3 <asn1_primitive_new+0x273>
jmp    11fd <asn1_primitive_new+0xad>
mov    -0x40(%rbp),%rax
cmpq   $0x0,(%rax)
je     11f8 <asn1_primitive_new+0xa8>
mov    -0x40(%rbp),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   *%rax
mov    %eax,-0x4(%rbp)
jmp    13c3 <asn1_primitive_new+0x273>
jmp    11fd <asn1_primitive_new+0xad>
jmp    1202 <asn1_primitive_new+0xb2>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    0x2db0(%rip),%rcx
cmp    (%rcx),%rax
jne    1225 <asn1_primitive_new+0xd5>
movl   $0xffffffff,-0x34(%rbp)
jmp    122f <asn1_primitive_new+0xdf>
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x48(%rbp)
sub    $0x3,%eax
ja     130e <asn1_primitive_new+0x1be>
mov    -0x48(%rbp),%rax
lea    0xdb1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2d59(%rip),%rax
mov    (%rax),%edi
call   1030 <OBJ_nid2obj@plt>
mov    %rax,%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    13c3 <asn1_primitive_new+0x273>
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    13c3 <asn1_primitive_new+0x273>
mov    -0x10(%rbp),%rax
mov    $0x1,%ecx
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    13c3 <asn1_primitive_new+0x273>
mov    $0x10,%edi
call   1050 <OPENSSL_malloc@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    12e8 <asn1_primitive_new+0x198>
mov    0x2d04(%rip),%rax
mov    (%rax),%edi
mov    0x2d0b(%rip),%rax
mov    (%rax),%esi
call   1060 <ERR_raise@plt>
movl   $0x0,-0x4(%rbp)
jmp    13c3 <asn1_primitive_new+0x273>
mov    -0x28(%rbp),%rax
movq   $0x0,0x8(%rax)
mov    -0x28(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x28(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
jmp    13a2 <asn1_primitive_new+0x252>
cmpl   $0x0,-0x1c(%rbp)
je     1351 <asn1_primitive_new+0x201>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    -0x34(%rbp),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,(%rax)
mov    0x2ca5(%rip),%rax
mov    (%rax),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0x4(%rax)
jmp    1368 <asn1_primitive_new+0x218>
mov    -0x34(%rbp),%edi
call   1070 <ASN1_STRING_type_new@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    0x2c4a(%rip),%rcx
cmp    (%rcx),%rax
jne    139d <asn1_primitive_new+0x24d>
cmpq   $0x0,-0x30(%rbp)
je     139d <asn1_primitive_new+0x24d>
mov    0x2c47(%rip),%rax
mov    (%rax),%ecx
mov    -0x30(%rbp),%rax
or     0x4(%rax),%ecx
mov    %ecx,0x4(%rax)
jmp    13a2 <asn1_primitive_new+0x252>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     13bc <asn1_primitive_new+0x26c>
movl   $0x1,-0x4(%rbp)
jmp    13c3 <asn1_primitive_new+0x273>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<asn1_primitive_new>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %ebp,%ebp
test   %rsi,%rsi
je     124e <asn1_primitive_new+0xfe>
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x10(%rsi),%rax
test   %rax,%rax
je     11a9 <asn1_primitive_new+0x59>
test   %edx,%edx
je     1191 <asn1_primitive_new+0x41>
mov    0x8(%rax),%rax
test   %rax,%rax
je     11a9 <asn1_primitive_new+0x59>
mov    %r14,%rdi
mov    %rbx,%rsi
call   *%rax
mov    $0x1,%ebp
jmp    124e <asn1_primitive_new+0xfe>
mov    (%rax),%rax
test   %rax,%rax
je     11a9 <asn1_primitive_new+0x59>
mov    %r14,%rdi
mov    %rbx,%rsi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    *%rax
mov    (%rbx),%rax
mov    0x2e0d(%rip),%r12
mov    $0xffffffff,%r15d
cmp    (%r12),%rax
jne    11e7 <asn1_primitive_new+0x97>
test   %edx,%edx
je     121c <asn1_primitive_new+0xcc>
mov    (%r14),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    %r15d,0x0(%rbp)
mov    0x2e08(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rbp)
jmp    122a <asn1_primitive_new+0xda>
mov    0x8(%rbx),%r15d
lea    -0x80(%r15),%eax
cmp    $0x3,%eax
ja     11bf <asn1_primitive_new+0x6f>
lea    0xe05(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2dad(%rip),%rax
mov    (%rax),%edi
call   1030 <OBJ_nid2obj@plt>
mov    %rax,(%r14)
mov    $0x1,%ebp
jmp    124e <asn1_primitive_new+0xfe>
mov    %r15d,%edi
call   1070 <ASN1_STRING_type_new@plt>
mov    %rax,%rbp
mov    %rax,(%r14)
mov    (%rbx),%rax
cmp    (%r12),%rax
jne    1244 <asn1_primitive_new+0xf4>
test   %rbp,%rbp
je     1244 <asn1_primitive_new+0xf4>
mov    0x2d99(%rip),%rax
mov    (%rax),%eax
or     %eax,0x4(%rbp)
xor    %ebp,%ebp
cmpq   $0x0,(%r14)
setne  %bpl
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
movq   $0x1,(%r14)
mov    $0x1,%ebp
jmp    124e <asn1_primitive_new+0xfe>
mov    0xc(%rbx),%eax
mov    %eax,(%r14)
mov    $0x1,%ebp
jmp    124e <asn1_primitive_new+0xfe>
mov    $0x10,%edi
call   1050 <OPENSSL_malloc@plt>
test   %rax,%rax
je     1296 <asn1_primitive_new+0x146>
movq   $0x0,0x8(%rax)
movl   $0xffffffff,(%rax)
mov    %rax,(%r14)
jmp    1244 <asn1_primitive_new+0xf4>
mov    0x2d33(%rip),%rax
mov    (%rax),%edi
mov    0x2d3a(%rip),%rax
mov    (%rax),%esi
call   1060 <ERR_raise@plt>
jmp    124e <asn1_primitive_new+0xfe>

LLVM IR (-O0):
%struct.TYPE_16__ = type { i64, i32, i32, %struct.TYPE_15__* }
%struct.TYPE_15__ = type { i32 (i32**, %struct.TYPE_16__*)*, i32 (i32**, %struct.TYPE_16__*)* }
%struct.TYPE_13__ = type { i32, %struct.TYPE_12__ }
%struct.TYPE_12__ = type { i32* }
%struct.TYPE_14__ = type { i32, i32 }
@ASN1_ITYPE_MSTRING = global i64 0
@NID_undef = global i32 0
@ERR_LIB_ASN1 = global i32 0
@ERR_R_MALLOC_FAILURE = global i32 0
@ASN1_STRING_FLAG_EMBED = global i32 0
@ASN1_STRING_FLAG_MSTRING = global i32 0
define i32 @asn1_primitive_new(i32** %0, %struct.TYPE_16__* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32**
%6 = alloca %struct.TYPE_16__*
%7 = alloca i32
%8 = alloca %struct.TYPE_13__*
%9 = alloca %struct.TYPE_14__*
%10 = alloca i32
%11 = alloca %struct.TYPE_15__*
store i32** %0, i32*** %5
store %struct.TYPE_16__* %1, %struct.TYPE_16__** %6
store i32 %2, i32* %7
%12 = load %struct.TYPE_16__*, %struct.TYPE_16__** %6
%13 = icmp ne %struct.TYPE_16__* %12, null
br i1 %13, label %15, label %14
14: ; preds = %3
store i32 0, i32* %4
br label %138
15: ; preds = %3
%16 = load %struct.TYPE_16__*, %struct.TYPE_16__** %6
%17 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %16, i32 0, i32 3
%18 = load %struct.TYPE_15__*, %struct.TYPE_15__** %17
%19 = icmp ne %struct.TYPE_15__* %18, null
br i1 %19, label %20, label %53
20: ; preds = %15
%21 = load %struct.TYPE_16__*, %struct.TYPE_16__** %6
%22 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %21, i32 0, i32 3
%23 = load %struct.TYPE_15__*, %struct.TYPE_15__** %22
store %struct.TYPE_15__* %23, %struct.TYPE_15__** %11
%24 = load i32, i32* %7
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %39
26: ; preds = %20
%27 = load %struct.TYPE_15__*, %struct.TYPE_15__** %11
%28 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %27, i32 0, i32 1
%29 = load i32 (i32**, %struct.TYPE_16__*)*, i32 (i32**, %struct.TYPE_16__*)** %28
%30 = icmp ne i32 (i32**, %struct.TYPE_16__*)* %29, null
br i1 %30, label %31, label %38
31: ; preds = %26
%32 = load %struct.TYPE_15__*, %struct.TYPE_15__** %11
%33 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %32, i32 0, i32 1
%34 = load i32 (i32**, %struct.TYPE_16__*)*, i32 (i32**, %struct.TYPE_16__*)** %33
%35 = load i32**, i32*** %5
%36 = load %struct.TYPE_16__*, %struct.TYPE_16__** %6
%37 = call i32 %34(i32** %35, %struct.TYPE_16__* %36)
store i32 1, i32* %4
br label %138
38: ; preds = %26
br label %52
39: ; preds = %20
%40 = load %struct.TYPE_15__*, %struct.TYPE_15__** %11
%41 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %40, i32 0, i32 0
%42 = load i32 (i32**, %struct.TYPE_16__*)*, i32 (i32**, %struct.TYPE_16__*)** %41
%43 = icmp ne i32 (i32**, %struct.TYPE_16__*)* %42, null
br i1 %43, label %44, label %51
44: ; preds = %39
%45 = load %struct.TYPE_15__*, %struct.TYPE_15__** %11
%46 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %45, i32 0, i32 0
%47 = load i32 (i32**, %struct.TYPE_16__*)*, i32 (i32**, %struct.TYPE_16__*)** %46
%48 = load i32**, i32*** %5
%49 = load %struct.TYPE_16__*, %struct.TYPE_16__** %6
%50 = call i32 %47(i32** %48, %struct.TYPE_16__* %49)
store i32 %50, i32* %4
br label %138
51: ; preds = %39
br label %52
52: ; preds = %51, %38
br label %53
53: ; preds = %52, %15
%54 = load %struct.TYPE_16__*, %struct.TYPE_16__** %6
%55 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %54, i32 0, i32 0
%56 = load i64, i64* %55
%57 = load i64, i64* @ASN1_ITYPE_MSTRING
%58 = icmp eq i64 %56, %57
br i1 %58, label %59, label %60
59: ; preds = %53
store i32 -1, i32* %10
br label %64
60: ; preds = %53
%61 = load %struct.TYPE_16__*, %struct.TYPE_16__** %6
%62 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %61, i32 0, i32 1
%63 = load i32, i32* %62
store i32 %63, i32* %10
br label %64
64: ; preds = %60, %59
%65 = load i32, i32* %10
switch i32 %65, label %95 [
i32 128, label %66
i32 130, label %71
i32 129, label %77
i32 131, label %79
]
66: ; preds = %64
%67 = load i32, i32* @NID_undef
%68 = call i64 @OBJ_nid2obj(i32 %67)
%69 = inttoptr i64 %68 to i32*
%70 = load i32**, i32*** %5
store i32* %69, i32** %70
store i32 1, i32* %4
br label %138
71: ; preds = %64
%72 = load %struct.TYPE_16__*, %struct.TYPE_16__** %6
%73 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %72, i32 0, i32 2
%74 = load i32, i32* %73
%75 = load i32**, i32*** %5
%76 = bitcast i32** %75 to i32*
store i32 %74, i32* %76
store i32 1, i32* %4
br label %138
77: ; preds = %64
%78 = load i32**, i32*** %5
store i32* inttoptr (i64 1 to i32*), i32** %78
store i32 1, i32* %4
br label %138
79: ; preds = %64
%80 = call %struct.TYPE_13__* @OPENSSL_malloc(i32 16)
store %struct.TYPE_13__* %80, %struct.TYPE_13__** %8
%81 = icmp eq %struct.TYPE_13__* %80, null
br i1 %81, label %82, label %86
82: ; preds = %79
%83 = load i32, i32* @ERR_LIB_ASN1
%84 = load i32, i32* @ERR_R_MALLOC_FAILURE
%85 = call i32 @ERR_raise(i32 %83, i32 %84)
store i32 0, i32* %4
br label %138
86: ; preds = %79
%87 = load %struct.TYPE_13__*, %struct.TYPE_13__** %8
%88 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %87, i32 0, i32 1
%89 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %88, i32 0, i32 0
store i32* null, i32** %89
%90 = load %struct.TYPE_13__*, %struct.TYPE_13__** %8
%91 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %90, i32 0, i32 0
store i32 -1, i32* %91
%92 = load %struct.TYPE_13__*, %struct.TYPE_13__** %8
%93 = bitcast %struct.TYPE_13__* %92 to i32*
%94 = load i32**, i32*** %5
store i32* %93, i32** %94
br label %132
95: ; preds = %64
%96 = load i32, i32* %7
%97 = icmp ne i32 %96, 0
br i1 %97, label %98, label %110
98: ; preds = %95
%99 = load i32**, i32*** %5
%100 = bitcast i32** %99 to %struct.TYPE_14__**
%101 = load %struct.TYPE_14__*, %struct.TYPE_14__** %100
store %struct.TYPE_14__* %101, %struct.TYPE_14__** %9
%102 = load %struct.TYPE_14__*, %struct.TYPE_14__** %9
%103 = call i32 @memset(%struct.TYPE_14__* %102, i32 0, i32 8)
%104 = load i32, i32* %10
%105 = load %struct.TYPE_14__*, %struct.TYPE_14__** %9
%106 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %105, i32 0, i32 0
store i32 %104, i32* %106
%107 = load i32, i32* @ASN1_STRING_FLAG_EMBED
%108 = load %struct.TYPE_14__*, %struct.TYPE_14__** %9
%109 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %108, i32 0, i32 1
store i32 %107, i32* %109
br label %116
110: ; preds = %95
%111 = load i32, i32* %10
%112 = call %struct.TYPE_14__* @ASN1_STRING_type_new(i32 %111)
store %struct.TYPE_14__* %112, %struct.TYPE_14__** %9
%113 = load %struct.TYPE_14__*, %struct.TYPE_14__** %9
%114 = bitcast %struct.TYPE_14__* %113 to i32*
%115 = load i32**, i32*** %5
store i32* %114, i32** %115
br label %116
116: ; preds = %110, %98
%117 = load %struct.TYPE_16__*, %struct.TYPE_16__** %6
%118 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %117, i32 0, i32 0
%119 = load i64, i64* %118
%120 = load i64, i64* @ASN1_ITYPE_MSTRING
%121 = icmp eq i64 %119, %120
br i1 %121, label %122, label %131
122: ; preds = %116
%123 = load %struct.TYPE_14__*, %struct.TYPE_14__** %9
%124 = icmp ne %struct.TYPE_14__* %123, null
br i1 %124, label %125, label %131
125: ; preds = %122
%126 = load i32, i32* @ASN1_STRING_FLAG_MSTRING
%127 = load %struct.TYPE_14__*, %struct.TYPE_14__** %9
%128 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %127, i32 0, i32 1
%129 = load i32, i32* %128
%130 = or i32 %129, %126
store i32 %130, i32* %128
br label %131
131: ; preds = %125, %122, %116
br label %132
132: ; preds = %131, %86
%133 = load i32**, i32*** %5
%134 = load i32*, i32** %133
%135 = icmp ne i32* %134, null
br i1 %135, label %136, label %137
136: ; preds = %132
store i32 1, i32* %4
br label %138
137: ; preds = %132
store i32 0, i32* %4
br label %138
138: ; preds = %137, %136, %82, %77, %71, %66, %44, %31, %14
%139 = load i32, i32* %4
ret i32 %139
}

LLVM IR (-O2):
%struct.TYPE_16__ = type { i64, i32, i32, %struct.TYPE_15__* }
%struct.TYPE_15__ = type { i32 (i32**, %struct.TYPE_16__*)*, i32 (i32**, %struct.TYPE_16__*)* }
%struct.TYPE_13__ = type { i32, %struct.TYPE_12__ }
%struct.TYPE_12__ = type { i32* }
%struct.TYPE_14__ = type { i32, i32 }
@ASN1_ITYPE_MSTRING = global i64 0
@NID_undef = global i32 0
@ERR_LIB_ASN1 = global i32 0
@ERR_R_MALLOC_FAILURE = global i32 0
@ASN1_STRING_FLAG_EMBED = global i32 0
@ASN1_STRING_FLAG_MSTRING = global i32 0
define i32 @asn1_primitive_new(i32** %0, %struct.TYPE_16__* %1, i32 %2) {
%4 = icmp eq %struct.TYPE_16__* %1, null
br i1 %4, label %79, label %5
5: ; preds = %3
%6 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %1, i64 0, i32 3
%7 = load %struct.TYPE_15__*, %struct.TYPE_15__** %6
%8 = icmp eq %struct.TYPE_15__* %7, null
br i1 %8, label %23, label %9
9: ; preds = %5
%10 = icmp eq i32 %2, 0
br i1 %10, label %17, label %11
11: ; preds = %9
%12 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %7, i64 0, i32 1
%13 = load i32 (i32**, %struct.TYPE_16__*)*, i32 (i32**, %struct.TYPE_16__*)** %12
%14 = icmp eq i32 (i32**, %struct.TYPE_16__*)* %13, null
br i1 %14, label %23, label %15
15: ; preds = %11
%16 = tail call i32 %13(i32** %0, %struct.TYPE_16__* %1)
br label %79
17: ; preds = %9
%18 = getelementptr inbounds %struct.TYPE_15__, %struct.TYPE_15__* %7, i64 0, i32 0
%19 = load i32 (i32**, %struct.TYPE_16__*)*, i32 (i32**, %struct.TYPE_16__*)** %18
%20 = icmp eq i32 (i32**, %struct.TYPE_16__*)* %19, null
br i1 %20, label %23, label %21
21: ; preds = %17
%22 = tail call i32 %19(i32** %0, %struct.TYPE_16__* %1)
br label %79
23: ; preds = %11, %17, %5
%24 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %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 %50, label %28
28: ; preds = %23
%29 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %1, i64 0, i32 1
%30 = load i32, i32* %29
switch i32 %30, label %50 [
i32 128, label %31
i32 130, label %35
i32 129, label %39
i32 131, label %40
]
31: ; preds = %28
%32 = load i32, i32* @NID_undef
%33 = tail call i64 @OBJ_nid2obj(i32 %32)
%34 = inttoptr i64 %33 to i32*
store i32* %34, i32** %0
br label %79
35: ; preds = %28
%36 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %1, i64 0, i32 2
%37 = load i32, i32* %36
%38 = bitcast i32** %0 to i32*
store i32 %37, i32* %38
br label %79
39: ; preds = %28
store i32* inttoptr (i64 1 to i32*), i32** %0
br label %79
40: ; preds = %28
%41 = tail call %struct.TYPE_13__* @OPENSSL_malloc(i32 16)
%42 = icmp eq %struct.TYPE_13__* %41, null
br i1 %42, label %43, label %47
43: ; preds = %40
%44 = load i32, i32* @ERR_LIB_ASN1
%45 = load i32, i32* @ERR_R_MALLOC_FAILURE
%46 = tail call i32 @ERR_raise(i32 %44, i32 %45)
br label %79
47: ; preds = %40
%48 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %41, i64 0, i32 1, i32 0
store i32* null, i32** %48
%49 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %41, i64 0, i32 0
store i32 -1, i32* %49
store i32* %49, i32** %0
br label %75
50: ; preds = %23, %28
%51 = phi i32 [ %30, %28 ], [ -1, %23 ]
%52 = icmp eq i32 %2, 0
br i1 %52, label %60, label %53
53: ; preds = %50
%54 = bitcast i32** %0 to %struct.TYPE_14__**
%55 = load %struct.TYPE_14__*, %struct.TYPE_14__** %54
%56 = tail call i32 @memset(%struct.TYPE_14__* %55, i32 0, i32 8)
%57 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %55, i64 0, i32 0
store i32 %51, i32* %57
%58 = load i32, i32* @ASN1_STRING_FLAG_EMBED
%59 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %55, i64 0, i32 1
store i32 %58, i32* %59
br label %63
60: ; preds = %50
%61 = tail call %struct.TYPE_14__* @ASN1_STRING_type_new(i32 %51)
%62 = getelementptr %struct.TYPE_14__, %struct.TYPE_14__* %61, i64 0, i32 0
store i32* %62, i32** %0
br label %63
63: ; preds = %60, %53
%64 = phi %struct.TYPE_14__* [ %55, %53 ], [ %61, %60 ]
%65 = load i64, i64* %24
%66 = load i64, i64* @ASN1_ITYPE_MSTRING
%67 = icmp eq i64 %65, %66
%68 = icmp ne %struct.TYPE_14__* %64, null
%69 = select i1 %67, i1 %68, i1 false
br i1 %69, label %70, label %75
70: ; preds = %63
%71 = load i32, i32* @ASN1_STRING_FLAG_MSTRING
%72 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %64, i64 0, i32 1
%73 = load i32, i32* %72
%74 = or i32 %73, %71
store i32 %74, i32* %72
br label %75
75: ; preds = %63, %70, %47
%76 = load i32*, i32** %0
%77 = icmp ne i32* %76, null
%78 = zext i1 %77 to i32
br label %79
79: ; preds = %15, %21, %75, %3, %43, %39, %35, %31
%80 = phi i32 [ 0, %43 ], [ 1, %39 ], [ 1, %35 ], [ 1, %31 ], [ 0, %3 ], [ %78, %75 ], [ %22, %21 ], [ 1, %15 ]
ret i32 %80
}