#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_12__ TYPE_3__;
typedef struct TYPE_11__ TYPE_2__;
typedef struct TYPE_10__ TYPE_1__;

/* Type definitions */
struct TYPE_12__ {
  scalar_t__ itype;
  int utype;
};
struct TYPE_11__ {
  scalar_t__ valid;
};
struct TYPE_10__ {
  long length;
  scalar_t__ *data;
  scalar_t__ max;
  int /*<<< orphan*/ member_0;
};
typedef TYPE_1__ BUF_MEM;
typedef int /*<<< orphan*/ ASN1_VALUE;
typedef TYPE_2__ ASN1_TLC;
typedef TYPE_3__ ASN1_ITEM;

/* Variables and functions */
int /*<<< orphan*/ ASN1_F_ASN1_D2I_EX_PRIMITIVE;
scalar_t__ ASN1_ITYPE_MSTRING;
int /*<<< orphan*/ ASN1_R_ILLEGAL_NULL;
int /*<<< orphan*/ ASN1_R_ILLEGAL_OPTIONAL_ANY;
int /*<<< orphan*/ ASN1_R_ILLEGAL_TAGGED_ANY;
int /*<<< orphan*/ ASN1_R_TYPE_NOT_CONSTRUCTED;
int /*<<< orphan*/ ASN1_R_TYPE_NOT_PRIMITIVE;
int /*<<< orphan*/ ASN1err(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ BUF_MEM_grow_clean(TYPE_1__ *, long);
int /*<<< orphan*/ ERR_R_MALLOC_FAILURE;
int /*<<< orphan*/ ERR_R_NESTED_ASN1_ERROR;
int /*<<< orphan*/ OPENSSL_free(scalar_t__ *);
int V_ASN1_ANY;
int V_ASN1_BOOLEAN;
int V_ASN1_ENUMERATED;
int V_ASN1_INTEGER;
int V_ASN1_NULL;
int V_ASN1_OBJECT;
int V_ASN1_OTHER;
int V_ASN1_SEQUENCE;
int V_ASN1_SET;
unsigned char V_ASN1_UNIVERSAL;
int asn1_check_tlen(long *, int *, unsigned char *, char *, char *,
                    unsigned char const **, long, int, int, char, TYPE_2__ *);
int /*<<< orphan*/ asn1_collect(TYPE_1__ *, unsigned char const **, long, char,
                                int, unsigned char, int /*<<< orphan*/);
int /*<<< orphan*/ asn1_ex_c2i(int /*<<< orphan*/ **, unsigned char const *,
                               long, int, char *, TYPE_3__ const *);
int /*<<< orphan*/ asn1_find_end(unsigned char const **, long, char);
int asn1_d2i_ex_primitive(ASN1_VALUE **pval, const unsigned char **in,
                          long inlen, const ASN1_ITEM *it, int tag, int aclass,
                          char opt, ASN1_TLC *ctx) {
  int ret = 0, utype;
  long plen;
  char cst, inf, free_cont = 0;
  const unsigned char *p;
  BUF_MEM buf = {0};
  const unsigned char *cont = NULL;
  long len;
  if (!pval) {
    ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ASN1_R_ILLEGAL_NULL);
    return 0;
  }
  if (it->itype == ASN1_ITYPE_MSTRING) {
    utype = tag;
    tag = -1;
  } else
    utype = it->utype;
  if (utype == V_ASN1_ANY) {
    unsigned char oclass;
    if (tag >= 0) {
      ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ASN1_R_ILLEGAL_TAGGED_ANY);
      return 0;
    }
    if (opt) {
      ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ASN1_R_ILLEGAL_OPTIONAL_ANY);
      return 0;
    }
    p = *in;
    ret = asn1_check_tlen(NULL, &utype, &oclass, NULL, NULL, &p, inlen, -1, 0,
                          0, ctx);
    if (!ret) {
      ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ERR_R_NESTED_ASN1_ERROR);
      return 0;
    }
    if (oclass != V_ASN1_UNIVERSAL)
      utype = V_ASN1_OTHER;
  }
  if (tag == -1) {
    tag = utype;
    aclass = V_ASN1_UNIVERSAL;
  }
  p = *in;
  ret = asn1_check_tlen(&plen, NULL, NULL, &inf, &cst, &p, inlen, tag, aclass,
                        opt, ctx);
  if (!ret) {
    ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ERR_R_NESTED_ASN1_ERROR);
    return 0;
  } else if (ret == -1)
    return -1;
  ret = 0;
  if ((utype == V_ASN1_SEQUENCE) || (utype == V_ASN1_SET) ||
      (utype == V_ASN1_OTHER)) {
    if (utype == V_ASN1_OTHER) {
      if (ctx)
        (ctx)->valid = 0;
    } else if (!cst) {
      ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ASN1_R_TYPE_NOT_CONSTRUCTED);
      return 0;
    }
    cont = *in;
    if (inf) {
      if (!asn1_find_end(&p, plen, inf))
        goto err;
      len = p - cont;
    } else {
      len = p - cont + plen;
      p += plen;
      buf.data = NULL;
    }
  } else if (cst) {
    if (utype == V_ASN1_NULL || utype == V_ASN1_BOOLEAN ||
        utype == V_ASN1_OBJECT || utype == V_ASN1_INTEGER ||
        utype == V_ASN1_ENUMERATED) {
      ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ASN1_R_TYPE_NOT_PRIMITIVE);
      return 0;
    }
    buf.length = 0;
    buf.max = 0;
    buf.data = NULL;
    if (!asn1_collect(&buf, &p, plen, inf, -1, V_ASN1_UNIVERSAL, 0)) {
      free_cont = 1;
      goto err;
    }
    len = buf.length;
    if (!BUF_MEM_grow_clean(&buf, len + 1)) {
      ASN1err(ASN1_F_ASN1_D2I_EX_PRIMITIVE, ERR_R_MALLOC_FAILURE);
      return 0;
    }
    buf.data[len] = 0;
    cont = (const unsigned char *)buf.data;
    free_cont = 1;
  } else {
    cont = p;
    len = plen;
    p += plen;
  }
  if (!asn1_ex_c2i(pval, cont, len, utype, &free_cont, it))
    goto err;
  *in = p;
  ret = 1;
err:
  if (free_cont)
    OPENSSL_free(buf.data);
  return ret;
}


x86 assembly (clang, -O0):
<asn1_d2i_ex_primitive>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0xb0,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%al
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
mov    %rcx,-0x38(%rbp)
mov    %r8d,-0x3c(%rbp)
mov    %r9d,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
movb   $0x0,-0x53(%rbp)
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x20,%edx
call   1050 <memset@plt>
movq   $0x0,-0x88(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1201 <asn1_d2i_ex_primitive+0x81>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
mov    0x2d5a(%rip),%rax
mov    (%rax),%esi
call   1040 <ASN1err@plt>
movl   $0x0,-0x14(%rbp)
jmp    1701 <asn1_d2i_ex_primitive+0x581>
mov    -0x38(%rbp),%rax
mov    (%rax),%rax
mov    0x2d81(%rip),%rcx
cmp    (%rcx),%rax
jne    122a <asn1_d2i_ex_primitive+0xaa>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x48(%rbp)
movl   $0xffffffff,-0x3c(%rbp)
jmp    1234 <asn1_d2i_ex_primitive+0xb4>
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
mov    0x2d22(%rip),%rcx
cmp    (%rcx),%eax
jne    134f <asn1_d2i_ex_primitive+0x1cf>
cmpl   $0x0,-0x3c(%rbp)
jl     1273 <asn1_d2i_ex_primitive+0xf3>
mov    0x2d91(%rip),%rax
mov    (%rax),%edi
mov    0x2d58(%rip),%rax
mov    (%rax),%esi
call   1040 <ASN1err@plt>
movl   $0x0,-0x14(%rbp)
jmp    1701 <asn1_d2i_ex_primitive+0x581>
cmpb   $0x0,0x10(%rbp)
je     12a0 <asn1_d2i_ex_primitive+0x120>
mov    0x2d64(%rip),%rax
mov    (%rax),%edi
mov    0x2cdb(%rip),%rax
mov    (%rax),%esi
call   1040 <ASN1err@plt>
movl   $0x0,-0x14(%rbp)
jmp    1701 <asn1_d2i_ex_primitive+0x581>
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x60(%rbp)
mov    -0x30(%rbp),%r10
mov    0x18(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%r8d
lea    -0x48(%rbp),%rsi
lea    -0x91(%rbp),%rdx
lea    -0x60(%rbp),%r9
xor    %ecx,%ecx
mov    %r8,%rdi
mov    %r8,%rcx
mov    %r10,(%rsp)
movl   $0xffffffff,0x8(%rsp)
ff
movl   $0x0,0x10(%rsp)
movl   $0x0,0x18(%rsp)
mov    %rax,0x20(%rsp)
call   1030 <asn1_check_tlen@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jne    1325 <asn1_d2i_ex_primitive+0x1a5>
mov    0x2cdf(%rip),%rax
mov    (%rax),%edi
mov    0x2c96(%rip),%rax
mov    (%rax),%esi
call   1040 <ASN1err@plt>
movl   $0x0,-0x14(%rbp)
jmp    1701 <asn1_d2i_ex_primitive+0x581>
movzbl -0x91(%rbp),%eax
mov    0x2c55(%rip),%rcx
movzbl (%rcx),%ecx
cmp    %ecx,%eax
je     134a <asn1_d2i_ex_primitive+0x1ca>
mov    0x2c93(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
jmp    134f <asn1_d2i_ex_primitive+0x1cf>
cmpl   $0xffffffff,-0x3c(%rbp)
jne    136c <asn1_d2i_ex_primitive+0x1ec>
mov    -0x48(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    0x2c22(%rip),%rax
movzbl (%rax),%eax
mov    %eax,-0x40(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x60(%rbp)
mov    -0x30(%rbp),%r14
mov    -0x3c(%rbp),%ebx
mov    -0x40(%rbp),%r11d
mov    0x10(%rbp),%r10b
mov    0x18(%rbp),%rax
lea    -0x50(%rbp),%rdi
xor    %ecx,%ecx
mov    %ecx,%edx
lea    -0x52(%rbp),%rcx
lea    -0x51(%rbp),%r8
lea    -0x60(%rbp),%r9
mov    %rdx,%rsi
mov    %r14,(%rsp)
mov    %ebx,0x8(%rsp)
mov    %r11d,0x10(%rsp)
movsbl %r10b,%r10d
mov    %r10d,0x18(%rsp)
mov    %rax,0x20(%rsp)
call   1030 <asn1_check_tlen@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jne    13f1 <asn1_d2i_ex_primitive+0x271>
mov    0x2c13(%rip),%rax
mov    (%rax),%edi
mov    0x2bca(%rip),%rax
mov    (%rax),%esi
call   1040 <ASN1err@plt>
movl   $0x0,-0x14(%rbp)
jmp    1701 <asn1_d2i_ex_primitive+0x581>
cmpl   $0xffffffff,-0x44(%rbp)
jne    1407 <asn1_d2i_ex_primitive+0x287>
movl   $0xffffffff,-0x14(%rbp)
jmp    1701 <asn1_d2i_ex_primitive+0x581>
jmp    140c <asn1_d2i_ex_primitive+0x28c>
movl   $0x0,-0x44(%rbp)
mov    -0x48(%rbp),%eax
mov    0x2b33(%rip),%rcx
cmp    (%rcx),%eax
je     1449 <asn1_d2i_ex_primitive+0x2c9>
mov    -0x48(%rbp),%eax
mov    0x2b41(%rip),%rcx
cmp    (%rcx),%eax
je     1449 <asn1_d2i_ex_primitive+0x2c9>
mov    -0x48(%rbp),%eax
mov    0x2b97(%rip),%rcx
cmp    (%rcx),%eax
jne    152b <asn1_d2i_ex_primitive+0x3ab>
mov    -0x48(%rbp),%eax
mov    0x2b85(%rip),%rcx
cmp    (%rcx),%eax
jne    1476 <asn1_d2i_ex_primitive+0x2f6>
cmpq   $0x0,0x18(%rbp)
je     1471 <asn1_d2i_ex_primitive+0x2f1>
mov    0x18(%rbp),%rax
movq   $0x0,(%rax)
jmp    14a8 <asn1_d2i_ex_primitive+0x328>
cmpb   $0x0,-0x51(%rbp)
jne    14a3 <asn1_d2i_ex_primitive+0x323>
mov    0x2b61(%rip),%rax
mov    (%rax),%edi
mov    0x2b50(%rip),%rax
mov    (%rax),%esi
call   1040 <ASN1err@plt>
movl   $0x0,-0x14(%rbp)
jmp    1701 <asn1_d2i_ex_primitive+0x581>
jmp    14a8 <asn1_d2i_ex_primitive+0x328>
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x88(%rbp)
cmpb   $0x0,-0x52(%rbp)
je     14f9 <asn1_d2i_ex_primitive+0x379>
mov    -0x50(%rbp),%rsi
lea    -0x60(%rbp),%rdi
movsbl -0x52(%rbp),%edx
call   10a0 <asn1_find_end@plt>
cmp    $0x0,%eax
jne    14df <asn1_d2i_ex_primitive+0x35f>
jmp    16e8 <asn1_d2i_ex_primitive+0x568>
mov    -0x60(%rbp),%rax
mov    -0x88(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x90(%rbp)
jmp    1526 <asn1_d2i_ex_primitive+0x3a6>
mov    -0x60(%rbp),%rax
mov    -0x88(%rbp),%rcx
sub    %rcx,%rax
add    -0x50(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x50(%rbp),%rax
add    -0x60(%rbp),%rax
mov    %rax,-0x60(%rbp)
movq   $0x0,-0x78(%rbp)
jmp    16a6 <asn1_d2i_ex_primitive+0x526>
cmpb   $0x0,-0x51(%rbp)
je     167f <asn1_d2i_ex_primitive+0x4ff>
mov    -0x48(%rbp),%eax
mov    0x2a39(%rip),%rcx
cmp    (%rcx),%eax
je     158f <asn1_d2i_ex_primitive+0x40f>
mov    -0x48(%rbp),%eax
mov    0x2a2f(%rip),%rcx
cmp    (%rcx),%eax
je     158f <asn1_d2i_ex_primitive+0x40f>
mov    -0x48(%rbp),%eax
mov    0x2a65(%rip),%rcx
cmp    (%rcx),%eax
je     158f <asn1_d2i_ex_primitive+0x40f>
mov    -0x48(%rbp),%eax
mov    0x2a3b(%rip),%rcx
cmp    (%rcx),%eax
je     158f <asn1_d2i_ex_primitive+0x40f>
mov    -0x48(%rbp),%eax
mov    0x2a11(%rip),%rcx
cmp    (%rcx),%eax
jne    15b2 <asn1_d2i_ex_primitive+0x432>
mov    0x2a52(%rip),%rax
mov    (%rax),%edi
mov    0x2a31(%rip),%rax
mov    (%rax),%esi
call   1040 <ASN1err@plt>
movl   $0x0,-0x14(%rbp)
jmp    1701 <asn1_d2i_ex_primitive+0x581>
movq   $0x0,-0x80(%rbp)
movq   $0x0,-0x70(%rbp)
movq   $0x0,-0x78(%rbp)
mov    -0x50(%rbp),%rdx
mov    -0x52(%rbp),%cl
lea    -0x80(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    $0xffffffff,%r8d
xor    %eax,%eax
mov    0x29a0(%rip),%rax
movsbl %cl,%ecx
movzbl (%rax),%r9d
movl   $0x0,(%rsp)
call   1060 <asn1_collect@plt>
cmp    $0x0,%eax
jne    160d <asn1_d2i_ex_primitive+0x48d>
movb   $0x1,-0x53(%rbp)
jmp    16e8 <asn1_d2i_ex_primitive+0x568>
mov    -0x80(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x90(%rbp),%rsi
add    $0x1,%rsi
lea    -0x80(%rbp),%rdi
call   1080 <BUF_MEM_grow_clean@plt>
cmp    $0x0,%eax
jne    1658 <asn1_d2i_ex_primitive+0x4d8>
mov    0x29ac(%rip),%rax
mov    (%rax),%edi
mov    0x297b(%rip),%rax
mov    (%rax),%esi
call   1040 <ASN1err@plt>
movl   $0x0,-0x14(%rbp)
jmp    1701 <asn1_d2i_ex_primitive+0x581>
mov    -0x78(%rbp),%rax
mov    -0x90(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x78(%rbp),%rax
mov    %rax,-0x88(%rbp)
movb   $0x1,-0x53(%rbp)
jmp    16a1 <asn1_d2i_ex_primitive+0x521>
mov    -0x60(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x50(%rbp),%rax
add    -0x60(%rbp),%rax
mov    %rax,-0x60(%rbp)
jmp    16a6 <asn1_d2i_ex_primitive+0x526>
mov    -0x20(%rbp),%rdi
mov    -0x88(%rbp),%rsi
mov    -0x90(%rbp),%rdx
mov    -0x48(%rbp),%ecx
mov    -0x38(%rbp),%r9
lea    -0x53(%rbp),%r8
call   1070 <asn1_ex_c2i@plt>
cmp    $0x0,%eax
jne    16d6 <asn1_d2i_ex_primitive+0x556>
jmp    16e8 <asn1_d2i_ex_primitive+0x568>
mov    -0x60(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x44(%rbp)
cmpb   $0x0,-0x53(%rbp)
je     16fb <asn1_d2i_ex_primitive+0x57b>
mov    -0x78(%rbp),%rdi
call   1090 <OPENSSL_free@plt>
mov    -0x44(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0xb0,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<asn1_d2i_ex_primitive>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
movb   $0x0,0x9(%rsp)
xorps  %xmm0,%xmm0
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
test   %rdi,%rdi
je     11e0 <asn1_d2i_ex_primitive+0x70>
mov    %r9d,%r15d
mov    %r8d,%ebp
mov    %rdx,%r13
mov    %rdi,%r12
mov    0x98(%rsp),%r10
mov    0x90(%rsp),%bl
mov    (%rcx),%rax
mov    0x2dd6(%rip),%rdx
cmp    (%rdx),%rax
jne    11f5 <asn1_d2i_ex_primitive+0x85>
mov    %ebp,0xc(%rsp)
mov    0x2d96(%rip),%rdx
mov    %ebp,%eax
cmp    %ebp,(%rdx)
mov    $0xffffffff,%ebp
jne    12da <asn1_d2i_ex_primitive+0x16a>
mov    $0xffffffff,%ebp
jmp    1224 <asn1_d2i_ex_primitive+0xb4>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
mov    0x2d58(%rip),%rax
jmp    134d <asn1_d2i_ex_primitive+0x1dd>
mov    0x8(%rcx),%eax
mov    %eax,0xc(%rsp)
mov    0x2d5d(%rip),%rdx
cmp    (%rdx),%eax
jne    12da <asn1_d2i_ex_primitive+0x16a>
test   %ebp,%ebp
js     1224 <asn1_d2i_ex_primitive+0xb4>
mov    0x2dd2(%rip),%rax
mov    (%rax),%edi
mov    0x2d99(%rip),%rax
jmp    134d <asn1_d2i_ex_primitive+0x1dd>
test   %bl,%bl
je     123d <asn1_d2i_ex_primitive+0xcd>
mov    0x2db9(%rip),%rax
mov    (%rax),%edi
mov    0x2d30(%rip),%rax
jmp    134d <asn1_d2i_ex_primitive+0x1dd>
mov    %rcx,0x28(%rsp)
mov    %rsi,0x20(%rsp)
mov    (%rsi),%rax
mov    %rax,0x10(%rsp)
sub    $0x8,%rsp
xor    %r14d,%r14d
lea    0x14(%rsp),%rsi
lea    0x20(%rsp),%rdx
lea    0x18(%rsp),%r9
xor    %edi,%edi
xor    %ecx,%ecx
xor    %r8d,%r8d
push   %r10
push   $0x0
push   $0x0
push   $0xffffffffffffffff
push   %r13
call   1030 <asn1_check_tlen@plt>
add    $0x30,%rsp
test   %eax,%eax
je     1298 <asn1_d2i_ex_primitive+0x128>
mov    0x18(%rsp),%al
mov    0x2cfa(%rip),%rcx
cmp    (%rcx),%al
jne    12b4 <asn1_d2i_ex_primitive+0x144>
mov    0xc(%rsp),%eax
jmp    12c1 <asn1_d2i_ex_primitive+0x151>
mov    0x2d49(%rip),%rax
mov    (%rax),%edi
mov    0x2d00(%rip),%rax
mov    (%rax),%esi
call   1040 <ASN1err@plt>
jmp    1357 <asn1_d2i_ex_primitive+0x1e7>
mov    0x2d1d(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
mov    0x20(%rsp),%rsi
mov    0x98(%rsp),%r10
mov    0x28(%rsp),%rcx
mov    0x90(%rsp),%bl
mov    %rcx,0x28(%rsp)
cmp    $0xffffffff,%ebp
mov    0x2c9f(%rip),%rcx
movzbl (%rcx),%ecx
cmove  %ecx,%r15d
cmovne %ebp,%eax
mov    %rsi,0x20(%rsp)
mov    (%rsi),%rcx
mov    %rcx,0x10(%rsp)
sub    $0x8,%rsp
movsbl %bl,%ebp
lea    0x20(%rsp),%rdi
lea    0x12(%rsp),%rcx
lea    0x13(%rsp),%r8
lea    0x18(%rsp),%r9
xor    %esi,%esi
xor    %edx,%edx
push   %r10
push   %rbp
push   %r15
push   %rax
push   %r13
call   1030 <asn1_check_tlen@plt>
add    $0x30,%rsp
mov    %eax,%r14d
cmp    $0xffffffff,%eax
je     1357 <asn1_d2i_ex_primitive+0x1e7>
test   %r14d,%r14d
jne    1369 <asn1_d2i_ex_primitive+0x1f9>
mov    0x2ca4(%rip),%rax
mov    (%rax),%edi
mov    0x2c5b(%rip),%rax
mov    (%rax),%esi
call   1040 <ASN1err@plt>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0xc(%rsp),%eax
mov    0x2bdc(%rip),%rdx
mov    0x2c5d(%rip),%rcx
mov    (%rcx),%ecx
cmp    (%rdx),%eax
je     1476 <asn1_d2i_ex_primitive+0x306>
mov    0x2be4(%rip),%rdx
cmp    (%rdx),%eax
je     1476 <asn1_d2i_ex_primitive+0x306>
cmp    %ecx,%eax
je     1476 <asn1_d2i_ex_primitive+0x306>
cmpb   $0x0,0xb(%rsp)
mov    0x20(%rsp),%r14
je     14cf <asn1_d2i_ex_primitive+0x35f>
mov    0x2bc5(%rip),%rcx
cmp    (%rcx),%eax
je     14e4 <asn1_d2i_ex_primitive+0x374>
mov    0x2bbe(%rip),%rcx
cmp    (%rcx),%eax
je     14e4 <asn1_d2i_ex_primitive+0x374>
mov    0x2bf7(%rip),%rcx
cmp    (%rcx),%eax
je     14e4 <asn1_d2i_ex_primitive+0x374>
mov    0x2bd0(%rip),%rcx
cmp    (%rcx),%eax
je     14e4 <asn1_d2i_ex_primitive+0x374>
mov    0x2ba9(%rip),%rcx
cmp    (%rcx),%eax
je     14e4 <asn1_d2i_ex_primitive+0x374>
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movq   $0x0,0x40(%rsp)
mov    0x18(%rsp),%rdx
movsbl 0xa(%rsp),%ecx
mov    0x2b6f(%rip),%rax
movzbl (%rax),%r9d
sub    $0x8,%rsp
lea    0x38(%rsp),%rdi
lea    0x18(%rsp),%rsi
mov    $0xffffffff,%r8d
push   $0x0
call   1050 <asn1_collect@plt>
add    $0x10,%rsp
test   %eax,%eax
je     157f <asn1_d2i_ex_primitive+0x40f>
mov    0x30(%rsp),%rbp
lea    0x1(%rbp),%rsi
lea    0x30(%rsp),%rdi
call   1070 <BUF_MEM_grow_clean@plt>
test   %eax,%eax
je     1589 <asn1_d2i_ex_primitive+0x419>
mov    0x38(%rsp),%rbx
movq   $0x0,(%rbx,%rbp,8)
movb   $0x1,0x9(%rsp)
jmp    151d <asn1_d2i_ex_primitive+0x3ad>
cmp    %ecx,%eax
mov    0x20(%rsp),%r14
jne    1495 <asn1_d2i_ex_primitive+0x325>
mov    0x98(%rsp),%rax
test   %rax,%rax
je     14a0 <asn1_d2i_ex_primitive+0x330>
movq   $0x0,(%rax)
jmp    14a0 <asn1_d2i_ex_primitive+0x330>
cmpb   $0x0,0xb(%rsp)
je     156a <asn1_d2i_ex_primitive+0x3fa>
mov    (%r14),%rbx
mov    0xa(%rsp),%al
test   %al,%al
je     14f9 <asn1_d2i_ex_primitive+0x389>
mov    0x18(%rsp),%rsi
movsbl %al,%edx
lea    0x10(%rsp),%rdi
call   1090 <asn1_find_end@plt>
test   %eax,%eax
je     154d <asn1_d2i_ex_primitive+0x3dd>
mov    0x10(%rsp),%rbp
sub    %rbx,%rbp
jmp    151d <asn1_d2i_ex_primitive+0x3ad>
mov    0x10(%rsp),%rbx
mov    0x18(%rsp),%rbp
lea    (%rbx,%rbp,1),%rax
mov    %rax,0x10(%rsp)
jmp    151d <asn1_d2i_ex_primitive+0x3ad>
mov    0x2afd(%rip),%rax
mov    (%rax),%edi
mov    0x2adc(%rip),%rax
jmp    134d <asn1_d2i_ex_primitive+0x1dd>
mov    0x10(%rsp),%rax
mov    %rax,%rbp
sub    %rbx,%rbp
mov    0x18(%rsp),%rcx
add    %rcx,%rbp
add    %rcx,%rax
mov    %rax,0x10(%rsp)
movq   $0x0,0x38(%rsp)
mov    0xc(%rsp),%ecx
lea    0x9(%rsp),%r8
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
mov    0x28(%rsp),%r9
call   1060 <asn1_ex_c2i@plt>
test   %eax,%eax
je     154d <asn1_d2i_ex_primitive+0x3dd>
mov    0x10(%rsp),%rax
mov    %rax,(%r14)
mov    $0x1,%r14d
jmp    1550 <asn1_d2i_ex_primitive+0x3e0>
xor    %r14d,%r14d
cmpb   $0x0,0x9(%rsp)
je     1357 <asn1_d2i_ex_primitive+0x1e7>
mov    0x38(%rsp),%rdi
call   1080 <OPENSSL_free@plt>
jmp    1357 <asn1_d2i_ex_primitive+0x1e7>
mov    0x2a77(%rip),%rax
mov    (%rax),%edi
mov    0x2a66(%rip),%rax
jmp    134d <asn1_d2i_ex_primitive+0x1dd>
movb   $0x1,0x9(%rsp)
xor    %r14d,%r14d
jmp    155b <asn1_d2i_ex_primitive+0x3eb>
mov    0x2a58(%rip),%rax
mov    (%rax),%edi
mov    0x2a27(%rip),%rax
jmp    134d <asn1_d2i_ex_primitive+0x1dd>

LLVM IR (-O0):
%struct.TYPE_12__ = type { i64, i32 }
%struct.TYPE_11__ = type { i64 }
%struct.TYPE_10__ = type { i64, i64*, i64, i32 }
@ASN1_F_ASN1_D2I_EX_PRIMITIVE = global i32 0
@ASN1_R_ILLEGAL_NULL = global i32 0
@ASN1_ITYPE_MSTRING = global i64 0
@V_ASN1_ANY = global i32 0
@ASN1_R_ILLEGAL_TAGGED_ANY = global i32 0
@ASN1_R_ILLEGAL_OPTIONAL_ANY = global i32 0
@ERR_R_NESTED_ASN1_ERROR = global i32 0
@V_ASN1_UNIVERSAL = global i8 0
@V_ASN1_OTHER = global i32 0
@V_ASN1_SEQUENCE = global i32 0
@V_ASN1_SET = global i32 0
@ASN1_R_TYPE_NOT_CONSTRUCTED = global i32 0
@V_ASN1_NULL = global i32 0
@V_ASN1_BOOLEAN = global i32 0
@V_ASN1_OBJECT = global i32 0
@V_ASN1_INTEGER = global i32 0
@V_ASN1_ENUMERATED = global i32 0
@ASN1_R_TYPE_NOT_PRIMITIVE = global i32 0
@ERR_R_MALLOC_FAILURE = global i32 0
define i32 @asn1_d2i_ex_primitive(i32** %0, i8** %1, i64 %2, %struct.TYPE_12__* %3, i32 %4, i32 %5, i8 signext %6, %struct.TYPE_11__* %7) {
%9 = alloca i32
%10 = alloca i32**
%11 = alloca i8**
%12 = alloca i64
%13 = alloca %struct.TYPE_12__*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i8
%17 = alloca %struct.TYPE_11__*
%18 = alloca i32
%19 = alloca i32
%20 = alloca i64
%21 = alloca i8
%22 = alloca i8
%23 = alloca i8
%24 = alloca i8*
%25 = alloca %struct.TYPE_10__
%26 = alloca i8*
%27 = alloca i64
%28 = alloca i8
store i32** %0, i32*** %10
store i8** %1, i8*** %11
store i64 %2, i64* %12
store %struct.TYPE_12__* %3, %struct.TYPE_12__** %13
store i32 %4, i32* %14
store i32 %5, i32* %15
store i8 %6, i8* %16
store %struct.TYPE_11__* %7, %struct.TYPE_11__** %17
store i32 0, i32* %18
store i8 0, i8* %23
%29 = bitcast %struct.TYPE_10__* %25 to i8*
store i8* null, i8** %26
%30 = load i32**, i32*** %10
%31 = icmp ne i32** %30, null
br i1 %31, label %36, label %32
32: ; preds = %8
%33 = load i32, i32* @ASN1_F_ASN1_D2I_EX_PRIMITIVE
%34 = load i32, i32* @ASN1_R_ILLEGAL_NULL
%35 = call i32 @ASN1err(i32 %33, i32 %34)
store i32 0, i32* %9
br label %259
36: ; preds = %8
%37 = load %struct.TYPE_12__*, %struct.TYPE_12__** %13
%38 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %37, i32 0, i32 0
%39 = load i64, i64* %38
%40 = load i64, i64* @ASN1_ITYPE_MSTRING
%41 = icmp eq i64 %39, %40
br i1 %41, label %42, label %44
42: ; preds = %36
%43 = load i32, i32* %14
store i32 %43, i32* %19
store i32 -1, i32* %14
br label %48
44: ; preds = %36
%45 = load %struct.TYPE_12__*, %struct.TYPE_12__** %13
%46 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %45, i32 0, i32 1
%47 = load i32, i32* %46
store i32 %47, i32* %19
br label %48
48: ; preds = %44, %42
%49 = load i32, i32* %19
%50 = load i32, i32* @V_ASN1_ANY
%51 = icmp eq i32 %49, %50
br i1 %51, label %52, label %87
52: ; preds = %48
%53 = load i32, i32* %14
%54 = icmp sge i32 %53, 0
br i1 %54, label %55, label %59
55: ; preds = %52
%56 = load i32, i32* @ASN1_F_ASN1_D2I_EX_PRIMITIVE
%57 = load i32, i32* @ASN1_R_ILLEGAL_TAGGED_ANY
%58 = call i32 @ASN1err(i32 %56, i32 %57)
store i32 0, i32* %9
br label %259
59: ; preds = %52
%60 = load i8, i8* %16
%61 = icmp ne i8 %60, 0
br i1 %61, label %62, label %66
62: ; preds = %59
%63 = load i32, i32* @ASN1_F_ASN1_D2I_EX_PRIMITIVE
%64 = load i32, i32* @ASN1_R_ILLEGAL_OPTIONAL_ANY
%65 = call i32 @ASN1err(i32 %63, i32 %64)
store i32 0, i32* %9
br label %259
66: ; preds = %59
%67 = load i8**, i8*** %11
%68 = load i8*, i8** %67
store i8* %68, i8** %24
%69 = load i64, i64* %12
%70 = load %struct.TYPE_11__*, %struct.TYPE_11__** %17
%71 = call i32 @asn1_check_tlen(i64* null, i32* %19, i8* %28, i8* null, i8* null, i8** %24, i64 %69, i32 -1, i32 0, i8 signext 0, %struct.TYPE_11__* %70)
store i32 %71, i32* %18
%72 = load i32, i32* %18
%73 = icmp ne i32 %72, 0
br i1 %73, label %78, label %74
74: ; preds = %66
%75 = load i32, i32* @ASN1_F_ASN1_D2I_EX_PRIMITIVE
%76 = load i32, i32* @ERR_R_NESTED_ASN1_ERROR
%77 = call i32 @ASN1err(i32 %75, i32 %76)
store i32 0, i32* %9
br label %259
78: ; preds = %66
%79 = load i8, i8* %28
%80 = zext i8 %79 to i32
%81 = load i8, i8* @V_ASN1_UNIVERSAL
%82 = zext i8 %81 to i32
%83 = icmp ne i32 %80, %82
br i1 %83, label %84, label %86
84: ; preds = %78
%85 = load i32, i32* @V_ASN1_OTHER
store i32 %85, i32* %19
br label %86
86: ; preds = %84, %78
br label %87
87: ; preds = %86, %48
%88 = load i32, i32* %14
%89 = icmp eq i32 %88, -1
br i1 %89, label %90, label %94
90: ; preds = %87
%91 = load i32, i32* %19
store i32 %91, i32* %14
%92 = load i8, i8* @V_ASN1_UNIVERSAL
%93 = zext i8 %92 to i32
store i32 %93, i32* %15
br label %94
94: ; preds = %90, %87
%95 = load i8**, i8*** %11
%96 = load i8*, i8** %95
store i8* %96, i8** %24
%97 = load i64, i64* %12
%98 = load i32, i32* %14
%99 = load i32, i32* %15
%100 = load i8, i8* %16
%101 = load %struct.TYPE_11__*, %struct.TYPE_11__** %17
%102 = call i32 @asn1_check_tlen(i64* %20, i32* null, i8* null, i8* %22, i8* %21, i8** %24, i64 %97, i32 %98, i32 %99, i8 signext %100, %struct.TYPE_11__* %101)
store i32 %102, i32* %18
%103 = load i32, i32* %18
%104 = icmp ne i32 %103, 0
br i1 %104, label %109, label %105
105: ; preds = %94
%106 = load i32, i32* @ASN1_F_ASN1_D2I_EX_PRIMITIVE
%107 = load i32, i32* @ERR_R_NESTED_ASN1_ERROR
%108 = call i32 @ASN1err(i32 %106, i32 %107)
store i32 0, i32* %9
br label %259
109: ; preds = %94
%110 = load i32, i32* %18
%111 = icmp eq i32 %110, -1
br i1 %111, label %112, label %113
112: ; preds = %109
store i32 -1, i32* %9
br label %259
113: ; preds = %109
br label %114
114: ; preds = %113
store i32 0, i32* %18
%115 = load i32, i32* %19
%116 = load i32, i32* @V_ASN1_SEQUENCE
%117 = icmp eq i32 %115, %116
br i1 %117, label %126, label %118
118: ; preds = %114
%119 = load i32, i32* %19
%120 = load i32, i32* @V_ASN1_SET
%121 = icmp eq i32 %119, %120
br i1 %121, label %126, label %122
122: ; preds = %118
%123 = load i32, i32* %19
%124 = load i32, i32* @V_ASN1_OTHER
%125 = icmp eq i32 %123, %124
br i1 %125, label %126, label %175
126: ; preds = %122, %118, %114
%127 = load i32, i32* %19
%128 = load i32, i32* @V_ASN1_OTHER
%129 = icmp eq i32 %127, %128
br i1 %129, label %130, label %137
130: ; preds = %126
%131 = load %struct.TYPE_11__*, %struct.TYPE_11__** %17
%132 = icmp ne %struct.TYPE_11__* %131, null
br i1 %132, label %133, label %136
133: ; preds = %130
%134 = load %struct.TYPE_11__*, %struct.TYPE_11__** %17
%135 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %134, i32 0, i32 0
store i64 0, i64* %135
br label %136
136: ; preds = %133, %130
br label %145
137: ; preds = %126
%138 = load i8, i8* %21
%139 = icmp ne i8 %138, 0
br i1 %139, label %144, label %140
140: ; preds = %137
%141 = load i32, i32* @ASN1_F_ASN1_D2I_EX_PRIMITIVE
%142 = load i32, i32* @ASN1_R_TYPE_NOT_CONSTRUCTED
%143 = call i32 @ASN1err(i32 %141, i32 %142)
store i32 0, i32* %9
br label %259
144: ; preds = %137
br label %145
145: ; preds = %144, %136
%146 = load i8**, i8*** %11
%147 = load i8*, i8** %146
store i8* %147, i8** %26
%148 = load i8, i8* %22
%149 = icmp ne i8 %148, 0
br i1 %149, label %150, label %162
150: ; preds = %145
%151 = load i64, i64* %20
%152 = load i8, i8* %22
%153 = call i32 @asn1_find_end(i8** %24, i64 %151, i8 signext %152)
%154 = icmp ne i32 %153, 0
br i1 %154, label %156, label %155
155: ; preds = %150
br label %250
156: ; preds = %150
%157 = load i8*, i8** %24
%158 = load i8*, i8** %26
%159 = ptrtoint i8* %157 to i64
%160 = ptrtoint i8* %158 to i64
%161 = sub i64 %159, %160
store i64 %161, i64* %27
br label %174
162: ; preds = %145
%163 = load i8*, i8** %24
%164 = load i8*, i8** %26
%165 = ptrtoint i8* %163 to i64
%166 = ptrtoint i8* %164 to i64
%167 = sub i64 %165, %166
%168 = load i64, i64* %20
%169 = add nsw i64 %167, %168
store i64 %169, i64* %27
%170 = load i64, i64* %20
%171 = load i8*, i8** %24
%172 = getelementptr inbounds i8, i8* %171, i64 %170
store i8* %172, i8** %24
%173 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %25, i32 0, i32 1
store i64* null, i64** %173
br label %174
174: ; preds = %162, %156
br label %238
175: ; preds = %122
%176 = load i8, i8* %21
%177 = icmp ne i8 %176, 0
br i1 %177, label %178, label %231
178: ; preds = %175
%179 = load i32, i32* %19
%180 = load i32, i32* @V_ASN1_NULL
%181 = icmp eq i32 %179, %180
br i1 %181, label %198, label %182
182: ; preds = %178
%183 = load i32, i32* %19
%184 = load i32, i32* @V_ASN1_BOOLEAN
%185 = icmp eq i32 %183, %184
br i1 %185, label %198, label %186
186: ; preds = %182
%187 = load i32, i32* %19
%188 = load i32, i32* @V_ASN1_OBJECT
%189 = icmp eq i32 %187, %188
br i1 %189, label %198, label %190
190: ; preds = %186
%191 = load i32, i32* %19
%192 = load i32, i32* @V_ASN1_INTEGER
%193 = icmp eq i32 %191, %192
br i1 %193, label %198, label %194
194: ; preds = %190
%195 = load i32, i32* %19
%196 = load i32, i32* @V_ASN1_ENUMERATED
%197 = icmp eq i32 %195, %196
br i1 %197, label %198, label %202
198: ; preds = %194, %190, %186, %182, %178
%199 = load i32, i32* @ASN1_F_ASN1_D2I_EX_PRIMITIVE
%200 = load i32, i32* @ASN1_R_TYPE_NOT_PRIMITIVE
%201 = call i32 @ASN1err(i32 %199, i32 %200)
store i32 0, i32* %9
br label %259
202: ; preds = %194
%203 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %25, i32 0, i32 0
store i64 0, i64* %203
%204 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %25, i32 0, i32 2
store i64 0, i64* %204
%205 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %25, i32 0, i32 1
store i64* null, i64** %205
%206 = load i64, i64* %20
%207 = load i8, i8* %22
%208 = load i8, i8* @V_ASN1_UNIVERSAL
%209 = call i32 @asn1_collect(%struct.TYPE_10__* %25, i8** %24, i64 %206, i8 signext %207, i32 -1, i8 zeroext %208, i32 0)
%210 = icmp ne i32 %209, 0
br i1 %210, label %212, label %211
211: ; preds = %202
store i8 1, i8* %23
br label %250
212: ; preds = %202
%213 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %25, i32 0, i32 0
%214 = load i64, i64* %213
store i64 %214, i64* %27
%215 = load i64, i64* %27
%216 = add nsw i64 %215, 1
%217 = call i32 @BUF_MEM_grow_clean(%struct.TYPE_10__* %25, i64 %216)
%218 = icmp ne i32 %217, 0
br i1 %218, label %223, label %219
219: ; preds = %212
%220 = load i32, i32* @ASN1_F_ASN1_D2I_EX_PRIMITIVE
%221 = load i32, i32* @ERR_R_MALLOC_FAILURE
%222 = call i32 @ASN1err(i32 %220, i32 %221)
store i32 0, i32* %9
br label %259
223: ; preds = %212
%224 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %25, i32 0, i32 1
%225 = load i64*, i64** %224
%226 = load i64, i64* %27
%227 = getelementptr inbounds i64, i64* %225, i64 %226
store i64 0, i64* %227
%228 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %25, i32 0, i32 1
%229 = load i64*, i64** %228
%230 = bitcast i64* %229 to i8*
store i8* %230, i8** %26
store i8 1, i8* %23
br label %237
231: ; preds = %175
%232 = load i8*, i8** %24
store i8* %232, i8** %26
%233 = load i64, i64* %20
store i64 %233, i64* %27
%234 = load i64, i64* %20
%235 = load i8*, i8** %24
%236 = getelementptr inbounds i8, i8* %235, i64 %234
store i8* %236, i8** %24
br label %237
237: ; preds = %231, %223
br label %238
238: ; preds = %237, %174
%239 = load i32**, i32*** %10
%240 = load i8*, i8** %26
%241 = load i64, i64* %27
%242 = load i32, i32* %19
%243 = load %struct.TYPE_12__*, %struct.TYPE_12__** %13
%244 = call i32 @asn1_ex_c2i(i32** %239, i8* %240, i64 %241, i32 %242, i8* %23, %struct.TYPE_12__* %243)
%245 = icmp ne i32 %244, 0
br i1 %245, label %247, label %246
246: ; preds = %238
br label %250
247: ; preds = %238
%248 = load i8*, i8** %24
%249 = load i8**, i8*** %11
store i8* %248, i8** %249
store i32 1, i32* %18
br label %250
250: ; preds = %247, %246, %211, %155
%251 = load i8, i8* %23
%252 = icmp ne i8 %251, 0
br i1 %252, label %253, label %257
253: ; preds = %250
%254 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %25, i32 0, i32 1
%255 = load i64*, i64** %254
%256 = call i32 @OPENSSL_free(i64* %255)
br label %257
257: ; preds = %253, %250
%258 = load i32, i32* %18
store i32 %258, i32* %9
br label %259
259: ; preds = %257, %219, %198, %140, %112, %105, %74, %62, %55, %32
%260 = load i32, i32* %9
ret i32 %260
}

LLVM IR (-O2):
%struct.TYPE_12__ = type { i64, i32 }
%struct.TYPE_11__ = type { i64 }
%struct.TYPE_10__ = type { i64, i64*, i64, i32 }
@ASN1_F_ASN1_D2I_EX_PRIMITIVE = global i32 0
@ASN1_R_ILLEGAL_NULL = global i32 0
@ASN1_ITYPE_MSTRING = global i64 0
@V_ASN1_ANY = global i32 0
@ASN1_R_ILLEGAL_TAGGED_ANY = global i32 0
@ASN1_R_ILLEGAL_OPTIONAL_ANY = global i32 0
@ERR_R_NESTED_ASN1_ERROR = global i32 0
@V_ASN1_UNIVERSAL = global i8 0
@V_ASN1_OTHER = global i32 0
@V_ASN1_SEQUENCE = global i32 0
@V_ASN1_SET = global i32 0
@ASN1_R_TYPE_NOT_CONSTRUCTED = global i32 0
@V_ASN1_NULL = global i32 0
@V_ASN1_BOOLEAN = global i32 0
@V_ASN1_OBJECT = global i32 0
@V_ASN1_INTEGER = global i32 0
@V_ASN1_ENUMERATED = global i32 0
@ASN1_R_TYPE_NOT_PRIMITIVE = global i32 0
@ERR_R_MALLOC_FAILURE = global i32 0
define i32 @asn1_d2i_ex_primitive(i32** %0, i8** nocapture %1, i64 %2, %struct.TYPE_12__* %3, i32 %4, i32 %5, i8 signext %6, %struct.TYPE_11__* %7) {
%9 = alloca i32
%10 = alloca i64
%11 = alloca i8
%12 = alloca i8
%13 = alloca i8
%14 = alloca i8*
%15 = alloca %struct.TYPE_10__
%16 = alloca i8
%17 = bitcast i32* %9 to i8*
%18 = bitcast i64* %10 to i8*
store i8 0, i8* %13
%19 = bitcast i8** %14 to i8*
%20 = bitcast %struct.TYPE_10__* %15 to i8*
%21 = icmp eq i32** %0, null
br i1 %21, label %22, label %26
22: ; preds = %8
%23 = load i32, i32* @ASN1_F_ASN1_D2I_EX_PRIMITIVE
%24 = load i32, i32* @ASN1_R_ILLEGAL_NULL
%25 = tail call i32 @ASN1err(i32 %23, i32 %24)
br label %195
26: ; preds = %8
%27 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %3, i64 0, i32 0
%28 = load i64, i64* %27
%29 = load i64, i64* @ASN1_ITYPE_MSTRING
%30 = icmp eq i64 %28, %29
br i1 %30, label %36, label %31
31: ; preds = %26
%32 = getelementptr inbounds %struct.TYPE_12__, %struct.TYPE_12__* %3, i64 0, i32 1
%33 = load i32, i32* %32
store i32 %33, i32* %9
%34 = load i32, i32* @V_ASN1_ANY
%35 = icmp eq i32 %33, %34
br i1 %35, label %40, label %71
36: ; preds = %26
store i32 %4, i32* %9
%37 = load i32, i32* @V_ASN1_ANY
%38 = icmp eq i32 %37, %4
br i1 %38, label %39, label %71
39: ; preds = %36
br label %46
40: ; preds = %31
%41 = icmp sgt i32 %4, -1
br i1 %41, label %42, label %46
42: ; preds = %40
%43 = load i32, i32* @ASN1_F_ASN1_D2I_EX_PRIMITIVE
%44 = load i32, i32* @ASN1_R_ILLEGAL_TAGGED_ANY
%45 = tail call i32 @ASN1err(i32 %43, i32 %44)
br label %195
46: ; preds = %39, %40
%47 = phi i32 [ -1, %39 ], [ %4, %40 ]
%48 = icmp eq i8 %6, 0
br i1 %48, label %53, label %49
49: ; preds = %46
%50 = load i32, i32* @ASN1_F_ASN1_D2I_EX_PRIMITIVE
%51 = load i32, i32* @ASN1_R_ILLEGAL_OPTIONAL_ANY
%52 = tail call i32 @ASN1err(i32 %50, i32 %51)
br label %195
53: ; preds = %46
%54 = load i8*, i8** %1
store i8* %54, i8** %14
%55 = call i32 @asn1_check_tlen(i64* null, i32* %9, i8* %16, i8* null, i8* null, i8** %14, i64 %2, i32 -1, i32 0, i8 signext 0, %struct.TYPE_11__* %7)
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %61
57: ; preds = %53
%58 = load i32, i32* @ASN1_F_ASN1_D2I_EX_PRIMITIVE
%59 = load i32, i32* @ERR_R_NESTED_ASN1_ERROR
%60 = call i32 @ASN1err(i32 %58, i32 %59)
br label %195
61: ; preds = %53
%62 = load i8, i8* %16
%63 = load i8, i8* @V_ASN1_UNIVERSAL
%64 = icmp eq i8 %62, %63
br i1 %64, label %65, label %67
65: ; preds = %61
%66 = load i32, i32* %9
br label %69
67: ; preds = %61
%68 = load i32, i32* @V_ASN1_OTHER
store i32 %68, i32* %9
br label %69
69: ; preds = %65, %67
%70 = phi i32 [ %66, %65 ], [ %68, %67 ]
br label %71
71: ; preds = %36, %69, %31
%72 = phi i32 [ %4, %36 ], [ %70, %69 ], [ %33, %31 ]
%73 = phi i32 [ -1, %36 ], [ %47, %69 ], [ %4, %31 ]
%74 = icmp eq i32 %73, -1
%75 = load i8, i8* @V_ASN1_UNIVERSAL
%76 = zext i8 %75 to i32
%77 = select i1 %74, i32 %76, i32 %5
%78 = select i1 %74, i32 %72, i32 %73
%79 = load i8*, i8** %1
store i8* %79, i8** %14
%80 = call i32 @asn1_check_tlen(i64* %10, i32* null, i8* null, i8* %12, i8* %11, i8** %14, i64 %2, i32 %78, i32 %77, i8 signext %6, %struct.TYPE_11__* %7)
switch i32 %80, label %85 [
i32 0, label %81
i32 -1, label %195
]
81: ; preds = %71
%82 = load i32, i32* @ASN1_F_ASN1_D2I_EX_PRIMITIVE
%83 = load i32, i32* @ERR_R_NESTED_ASN1_ERROR
%84 = call i32 @ASN1err(i32 %82, i32 %83)
br label %195
85: ; preds = %71
%86 = load i32, i32* %9
%87 = load i32, i32* @V_ASN1_SEQUENCE
%88 = icmp eq i32 %86, %87
%89 = load i32, i32* @V_ASN1_SET
%90 = icmp eq i32 %86, %89
%91 = select i1 %88, i1 true, i1 %90
%92 = load i32, i32* @V_ASN1_OTHER
%93 = icmp eq i32 %86, %92
%94 = select i1 %91, i1 true, i1 %93
br i1 %94, label %95, label %129
95: ; preds = %85
br i1 %93, label %96, label %100
96: ; preds = %95
%97 = icmp eq %struct.TYPE_11__* %7, null
br i1 %97, label %107, label %98
98: ; preds = %96
%99 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %7, i64 0, i32 0
store i64 0, i64* %99
br label %107
100: ; preds = %95
%101 = load i8, i8* %11
%102 = icmp eq i8 %101, 0
br i1 %102, label %103, label %107
103: ; preds = %100
%104 = load i32, i32* @ASN1_F_ASN1_D2I_EX_PRIMITIVE
%105 = load i32, i32* @ASN1_R_TYPE_NOT_CONSTRUCTED
%106 = call i32 @ASN1err(i32 %104, i32 %105)
br label %195
107: ; preds = %100, %96, %98
%108 = load i8*, i8** %1
%109 = load i8, i8* %12
%110 = icmp eq i8 %109, 0
br i1 %110, label %120, label %111
111: ; preds = %107
%112 = load i64, i64* %10
%113 = call i32 @asn1_find_end(i8** %14, i64 %112, i8 signext %109)
%114 = icmp eq i32 %113, 0
br i1 %114, label %186, label %115
115: ; preds = %111
%116 = load i8*, i8** %14
%117 = ptrtoint i8* %116 to i64
%118 = ptrtoint i8* %108 to i64
%119 = sub i64 %117, %118
br label %178
120: ; preds = %107
%121 = load i8*, i8** %14
%122 = ptrtoint i8* %121 to i64
%123 = ptrtoint i8* %108 to i64
%124 = sub i64 %122, %123
%125 = load i64, i64* %10
%126 = add nsw i64 %124, %125
%127 = getelementptr inbounds i8, i8* %121, i64 %125
store i8* %127, i8** %14
%128 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %15, i64 0, i32 1
store i64* null, i64** %128
br label %178
129: ; preds = %85
%130 = load i8, i8* %11
%131 = icmp eq i8 %130, 0
br i1 %131, label %174, label %132
132: ; preds = %129
%133 = load i32, i32* @V_ASN1_NULL
%134 = icmp eq i32 %86, %133
%135 = load i32, i32* @V_ASN1_BOOLEAN
%136 = icmp eq i32 %86, %135
%137 = select i1 %134, i1 true, i1 %136
%138 = load i32, i32* @V_ASN1_OBJECT
%139 = icmp eq i32 %86, %138
%140 = select i1 %137, i1 true, i1 %139
%141 = load i32, i32* @V_ASN1_INTEGER
%142 = icmp eq i32 %86, %141
%143 = select i1 %140, i1 true, i1 %142
%144 = load i32, i32* @V_ASN1_ENUMERATED
%145 = icmp eq i32 %86, %144
%146 = select i1 %143, i1 true, i1 %145
br i1 %146, label %147, label %151
147: ; preds = %132
%148 = load i32, i32* @ASN1_F_ASN1_D2I_EX_PRIMITIVE
%149 = load i32, i32* @ASN1_R_TYPE_NOT_PRIMITIVE
%150 = call i32 @ASN1err(i32 %148, i32 %149)
br label %195
151: ; preds = %132
%152 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %15, i64 0, i32 1
%153 = bitcast %struct.TYPE_10__* %15 to i8*
%154 = load i64, i64* %10
%155 = load i8, i8* %12
%156 = load i8, i8* @V_ASN1_UNIVERSAL
%157 = call i32 @asn1_collect(%struct.TYPE_10__* %15, i8** %14, i64 %154, i8 signext %155, i32 -1, i8 zeroext %156, i32 0)
%158 = icmp eq i32 %157, 0
br i1 %158, label %159, label %160
159: ; preds = %151
store i8 1, i8* %13
br label %190
160: ; preds = %151
%161 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %15, i64 0, i32 0
%162 = load i64, i64* %161
%163 = add nsw i64 %162, 1
%164 = call i32 @BUF_MEM_grow_clean(%struct.TYPE_10__* %15, i64 %163)
%165 = icmp eq i32 %164, 0
br i1 %165, label %166, label %170
166: ; preds = %160
%167 = load i32, i32* @ASN1_F_ASN1_D2I_EX_PRIMITIVE
%168 = load i32, i32* @ERR_R_MALLOC_FAILURE
%169 = call i32 @ASN1err(i32 %167, i32 %168)
br label %195
170: ; preds = %160
%171 = load i64*, i64** %152
%172 = getelementptr inbounds i64, i64* %171, i64 %162
store i64 0, i64* %172
%173 = bitcast i64* %171 to i8*
store i8 1, i8* %13
br label %178
174: ; preds = %129
%175 = load i8*, i8** %14
%176 = load i64, i64* %10
%177 = getelementptr inbounds i8, i8* %175, i64 %176
store i8* %177, i8** %14
br label %178
178: ; preds = %170, %174, %115, %120
%179 = phi i8* [ %108, %115 ], [ %108, %120 ], [ %173, %170 ], [ %175, %174 ]
%180 = phi i64 [ %119, %115 ], [ %126, %120 ], [ %162, %170 ], [ %176, %174 ]
%181 = load i32, i32* %9
%182 = call i32 @asn1_ex_c2i(i32** %0, i8* %179, i64 %180, i32 %181, i8* %13, %struct.TYPE_12__* %3)
%183 = icmp eq i32 %182, 0
br i1 %183, label %186, label %184
184: ; preds = %178
%185 = load i8*, i8** %14
store i8* %185, i8** %1
br label %186
186: ; preds = %178, %111, %184
%187 = phi i32 [ 0, %111 ], [ 0, %178 ], [ 1, %184 ]
%188 = load i8, i8* %13
%189 = icmp eq i8 %188, 0
br i1 %189, label %195, label %190
190: ; preds = %159, %186
%191 = phi i32 [ 0, %159 ], [ %187, %186 ]
%192 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %15, i64 0, i32 1
%193 = load i64*, i64** %192
%194 = call i32 @OPENSSL_free(i64* %193)
br label %195
195: ; preds = %186, %190, %71, %42, %49, %57, %166, %147, %103, %81, %22
%196 = phi i32 [ 0, %103 ], [ 0, %147 ], [ 0, %166 ], [ 0, %81 ], [ 0, %22 ], [ 0, %57 ], [ 0, %49 ], [ 0, %42 ], [ %80, %71 ], [ %191, %190 ], [ %187, %186 ]
ret i32 %196
}