#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*/ 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:
    typ = OPENSSL_malloc(sizeof(*typ));
    if (typ == NULL)
      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    116a <asn1_primitive_new+0x2a>
movl   $0x0,-0x4(%rbp)
jmp    139d <asn1_primitive_new+0x25d>
mov    -0x18(%rbp),%rax
cmpq   $0x0,0x10(%rax)
je     11f2 <asn1_primitive_new+0xb2>
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x40(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11c1 <asn1_primitive_new+0x81>
mov    -0x40(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     11bc <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    139d <asn1_primitive_new+0x25d>
jmp    11ed <asn1_primitive_new+0xad>
mov    -0x40(%rbp),%rax
cmpq   $0x0,(%rax)
je     11e8 <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    139d <asn1_primitive_new+0x25d>
jmp    11ed <asn1_primitive_new+0xad>
jmp    11f2 <asn1_primitive_new+0xb2>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    0x2dd0(%rip),%rcx
cmp    (%rcx),%rax
jne    1215 <asn1_primitive_new+0xd5>
movl   $0xffffffff,-0x34(%rbp)
jmp    121f <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     12e8 <asn1_primitive_new+0x1a8>
mov    -0x48(%rbp),%rax
lea    0xdc1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2d79(%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    139d <asn1_primitive_new+0x25d>
mov    -0x18(%rbp),%rax
mov    0xc(%rax),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    139d <asn1_primitive_new+0x25d>
mov    -0x10(%rbp),%rax
mov    $0x1,%ecx
mov    %rcx,(%rax)
movl   $0x1,-0x4(%rbp)
jmp    139d <asn1_primitive_new+0x25d>
mov    $0x10,%edi
call   1050 <OPENSSL_malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12c2 <asn1_primitive_new+0x182>
movl   $0x0,-0x4(%rbp)
jmp    139d <asn1_primitive_new+0x25d>
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    137c <asn1_primitive_new+0x23c>
cmpl   $0x0,-0x1c(%rbp)
je     132b <asn1_primitive_new+0x1eb>
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    0x2ccb(%rip),%rax
mov    (%rax),%ecx
mov    -0x30(%rbp),%rax
mov    %ecx,0x4(%rax)
jmp    1342 <asn1_primitive_new+0x202>
mov    -0x34(%rbp),%edi
call   1060 <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    0x2c80(%rip),%rcx
cmp    (%rcx),%rax
jne    1377 <asn1_primitive_new+0x237>
cmpq   $0x0,-0x30(%rbp)
je     1377 <asn1_primitive_new+0x237>
mov    0x2c75(%rip),%rax
mov    (%rax),%ecx
mov    -0x30(%rbp),%rax
or     0x4(%rax),%ecx
mov    %ecx,0x4(%rax)
jmp    137c <asn1_primitive_new+0x23c>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     1396 <asn1_primitive_new+0x256>
movl   $0x1,-0x4(%rbp)
jmp    139d <asn1_primitive_new+0x25d>
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     123e <asn1_primitive_new+0xfe>
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x10(%rsi),%rax
test   %rax,%rax
je     1199 <asn1_primitive_new+0x59>
test   %edx,%edx
je     1181 <asn1_primitive_new+0x41>
mov    0x8(%rax),%rax
test   %rax,%rax
je     1199 <asn1_primitive_new+0x59>
mov    %r14,%rdi
mov    %rbx,%rsi
call   *%rax
mov    $0x1,%ebp
jmp    123e <asn1_primitive_new+0xfe>
mov    (%rax),%rax
test   %rax,%rax
je     1199 <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    0x2e2d(%rip),%r12
mov    $0xffffffff,%r15d
cmp    (%r12),%rax
jne    11d7 <asn1_primitive_new+0x97>
test   %edx,%edx
je     120c <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    0x2e18(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rbp)
jmp    121a <asn1_primitive_new+0xda>
mov    0x8(%rbx),%r15d
lea    -0x80(%r15),%eax
cmp    $0x3,%eax
ja     11af <asn1_primitive_new+0x6f>
lea    0xe15(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    0x2dcd(%rip),%rax
mov    (%rax),%edi
call   1030 <OBJ_nid2obj@plt>
mov    %rax,(%r14)
mov    $0x1,%ebp
jmp    123e <asn1_primitive_new+0xfe>
mov    %r15d,%edi
call   1060 <ASN1_STRING_type_new@plt>
mov    %rax,%rbp
mov    %rax,(%r14)
mov    (%rbx),%rax
cmp    (%r12),%rax
jne    1234 <asn1_primitive_new+0xf4>
test   %rbp,%rbp
je     1234 <asn1_primitive_new+0xf4>
mov    0x2db1(%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    123e <asn1_primitive_new+0xfe>
mov    0xc(%rbx),%eax
mov    %eax,(%r14)
mov    $0x1,%ebp
jmp    123e <asn1_primitive_new+0xfe>
mov    $0x10,%edi
call   1050 <OPENSSL_malloc@plt>
test   %rax,%rax
je     123e <asn1_primitive_new+0xfe>
movq   $0x0,0x8(%rax)
movl   $0xffffffff,(%rax)
mov    %rax,(%r14)
jmp    1234 <asn1_primitive_new+0xf4>

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
@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 %136
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 %136
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 %136
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 %93 [
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 %136
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 %136
77: ; preds = %64
%78 = load i32**, i32*** %5
store i32* inttoptr (i64 1 to i32*), i32** %78
store i32 1, i32* %4
br label %136
79: ; preds = %64
%80 = call %struct.TYPE_13__* @OPENSSL_malloc(i32 16)
store %struct.TYPE_13__* %80, %struct.TYPE_13__** %8
%81 = load %struct.TYPE_13__*, %struct.TYPE_13__** %8
%82 = icmp eq %struct.TYPE_13__* %81, null
br i1 %82, label %83, label %84
83: ; preds = %79
store i32 0, i32* %4
br label %136
84: ; preds = %79
%85 = load %struct.TYPE_13__*, %struct.TYPE_13__** %8
%86 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %85, i32 0, i32 1
%87 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %86, i32 0, i32 0
store i32* null, i32** %87
%88 = load %struct.TYPE_13__*, %struct.TYPE_13__** %8
%89 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %88, i32 0, i32 0
store i32 -1, i32* %89
%90 = load %struct.TYPE_13__*, %struct.TYPE_13__** %8
%91 = bitcast %struct.TYPE_13__* %90 to i32*
%92 = load i32**, i32*** %5
store i32* %91, i32** %92
br label %130
93: ; preds = %64
%94 = load i32, i32* %7
%95 = icmp ne i32 %94, 0
br i1 %95, label %96, label %108
96: ; preds = %93
%97 = load i32**, i32*** %5
%98 = bitcast i32** %97 to %struct.TYPE_14__**
%99 = load %struct.TYPE_14__*, %struct.TYPE_14__** %98
store %struct.TYPE_14__* %99, %struct.TYPE_14__** %9
%100 = load %struct.TYPE_14__*, %struct.TYPE_14__** %9
%101 = call i32 @memset(%struct.TYPE_14__* %100, i32 0, i32 8)
%102 = load i32, i32* %10
%103 = load %struct.TYPE_14__*, %struct.TYPE_14__** %9
%104 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %103, i32 0, i32 0
store i32 %102, i32* %104
%105 = load i32, i32* @ASN1_STRING_FLAG_EMBED
%106 = load %struct.TYPE_14__*, %struct.TYPE_14__** %9
%107 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %106, i32 0, i32 1
store i32 %105, i32* %107
br label %114
108: ; preds = %93
%109 = load i32, i32* %10
%110 = call %struct.TYPE_14__* @ASN1_STRING_type_new(i32 %109)
store %struct.TYPE_14__* %110, %struct.TYPE_14__** %9
%111 = load %struct.TYPE_14__*, %struct.TYPE_14__** %9
%112 = bitcast %struct.TYPE_14__* %111 to i32*
%113 = load i32**, i32*** %5
store i32* %112, i32** %113
br label %114
114: ; preds = %108, %96
%115 = load %struct.TYPE_16__*, %struct.TYPE_16__** %6
%116 = getelementptr inbounds %struct.TYPE_16__, %struct.TYPE_16__* %115, i32 0, i32 0
%117 = load i64, i64* %116
%118 = load i64, i64* @ASN1_ITYPE_MSTRING
%119 = icmp eq i64 %117, %118
br i1 %119, label %120, label %129
120: ; preds = %114
%121 = load %struct.TYPE_14__*, %struct.TYPE_14__** %9
%122 = icmp ne %struct.TYPE_14__* %121, null
br i1 %122, label %123, label %129
123: ; preds = %120
%124 = load i32, i32* @ASN1_STRING_FLAG_MSTRING
%125 = load %struct.TYPE_14__*, %struct.TYPE_14__** %9
%126 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %125, i32 0, i32 1
%127 = load i32, i32* %126
%128 = or i32 %127, %124
store i32 %128, i32* %126
br label %129
129: ; preds = %123, %120, %114
br label %130
130: ; preds = %129, %84
%131 = load i32**, i32*** %5
%132 = load i32*, i32** %131
%133 = icmp ne i32* %132, null
br i1 %133, label %134, label %135
134: ; preds = %130
store i32 1, i32* %4
br label %136
135: ; preds = %130
store i32 0, i32* %4
br label %136
136: ; preds = %135, %134, %83, %77, %71, %66, %44, %31, %14
%137 = load i32, i32* %4
ret i32 %137
}

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
@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 %75, 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 %75
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 %75
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 %46, 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 %46 [
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 %75
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 %75
39: ; preds = %28
store i32* inttoptr (i64 1 to i32*), i32** %0
br label %75
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 %75, label %43
43: ; preds = %40
%44 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %41, i64 0, i32 1, i32 0
store i32* null, i32** %44
%45 = getelementptr inbounds %struct.TYPE_13__, %struct.TYPE_13__* %41, i64 0, i32 0
store i32 -1, i32* %45
store i32* %45, i32** %0
br label %71
46: ; preds = %23, %28
%47 = phi i32 [ %30, %28 ], [ -1, %23 ]
%48 = icmp eq i32 %2, 0
br i1 %48, label %56, label %49
49: ; preds = %46
%50 = bitcast i32** %0 to %struct.TYPE_14__**
%51 = load %struct.TYPE_14__*, %struct.TYPE_14__** %50
%52 = tail call i32 @memset(%struct.TYPE_14__* %51, i32 0, i32 8)
%53 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %51, i64 0, i32 0
store i32 %47, i32* %53
%54 = load i32, i32* @ASN1_STRING_FLAG_EMBED
%55 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %51, i64 0, i32 1
store i32 %54, i32* %55
br label %59
56: ; preds = %46
%57 = tail call %struct.TYPE_14__* @ASN1_STRING_type_new(i32 %47)
%58 = getelementptr %struct.TYPE_14__, %struct.TYPE_14__* %57, i64 0, i32 0
store i32* %58, i32** %0
br label %59
59: ; preds = %56, %49
%60 = phi %struct.TYPE_14__* [ %51, %49 ], [ %57, %56 ]
%61 = load i64, i64* %24
%62 = load i64, i64* @ASN1_ITYPE_MSTRING
%63 = icmp eq i64 %61, %62
%64 = icmp ne %struct.TYPE_14__* %60, null
%65 = select i1 %63, i1 %64, i1 false
br i1 %65, label %66, label %71
66: ; preds = %59
%67 = load i32, i32* @ASN1_STRING_FLAG_MSTRING
%68 = getelementptr inbounds %struct.TYPE_14__, %struct.TYPE_14__* %60, i64 0, i32 1
%69 = load i32, i32* %68
%70 = or i32 %69, %67
store i32 %70, i32* %68
br label %71
71: ; preds = %59, %66, %43
%72 = load i32*, i32** %0
%73 = icmp ne i32* %72, null
%74 = zext i1 %73 to i32
br label %75
75: ; preds = %15, %21, %71, %40, %3, %39, %35, %31
%76 = phi i32 [ 1, %39 ], [ 1, %35 ], [ 1, %31 ], [ 0, %3 ], [ 0, %40 ], [ %74, %71 ], [ %22, %21 ], [ 1, %15 ]
ret i32 %76
}