#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;
};
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;
  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 && buf.data)
    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)
movq   $0x0,-0x80(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11de <asn1_d2i_ex_primitive+0x6e>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
mov    0x2d7d(%rip),%rax
mov    (%rax),%esi
call   1040 <ASN1err@plt>
movl   $0x0,-0x14(%rbp)
jmp    16da <asn1_d2i_ex_primitive+0x56a>
mov    -0x38(%rbp),%rax
mov    (%rax),%rax
mov    0x2da4(%rip),%rcx
cmp    (%rcx),%rax
jne    1207 <asn1_d2i_ex_primitive+0x97>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x48(%rbp)
movl   $0xffffffff,-0x3c(%rbp)
jmp    1211 <asn1_d2i_ex_primitive+0xa1>
mov    -0x38(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
mov    0x2d45(%rip),%rcx
cmp    (%rcx),%eax
jne    132c <asn1_d2i_ex_primitive+0x1bc>
cmpl   $0x0,-0x3c(%rbp)
jl     1250 <asn1_d2i_ex_primitive+0xe0>
mov    0x2db4(%rip),%rax
mov    (%rax),%edi
mov    0x2d7b(%rip),%rax
mov    (%rax),%esi
call   1040 <ASN1err@plt>
movl   $0x0,-0x14(%rbp)
jmp    16da <asn1_d2i_ex_primitive+0x56a>
cmpb   $0x0,0x10(%rbp)
je     127d <asn1_d2i_ex_primitive+0x10d>
mov    0x2d87(%rip),%rax
mov    (%rax),%edi
mov    0x2cfe(%rip),%rax
mov    (%rax),%esi
call   1040 <ASN1err@plt>
movl   $0x0,-0x14(%rbp)
jmp    16da <asn1_d2i_ex_primitive+0x56a>
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    -0x89(%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    1302 <asn1_d2i_ex_primitive+0x192>
mov    0x2d02(%rip),%rax
mov    (%rax),%edi
mov    0x2cb9(%rip),%rax
mov    (%rax),%esi
call   1040 <ASN1err@plt>
movl   $0x0,-0x14(%rbp)
jmp    16da <asn1_d2i_ex_primitive+0x56a>
movzbl -0x89(%rbp),%eax
mov    0x2c78(%rip),%rcx
movzbl (%rcx),%ecx
cmp    %ecx,%eax
je     1327 <asn1_d2i_ex_primitive+0x1b7>
mov    0x2cb6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
jmp    132c <asn1_d2i_ex_primitive+0x1bc>
cmpl   $0xffffffff,-0x3c(%rbp)
jne    1349 <asn1_d2i_ex_primitive+0x1d9>
mov    -0x48(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    0x2c45(%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    13ce <asn1_d2i_ex_primitive+0x25e>
mov    0x2c36(%rip),%rax
mov    (%rax),%edi
mov    0x2bed(%rip),%rax
mov    (%rax),%esi
call   1040 <ASN1err@plt>
movl   $0x0,-0x14(%rbp)
jmp    16da <asn1_d2i_ex_primitive+0x56a>
cmpl   $0xffffffff,-0x44(%rbp)
jne    13e4 <asn1_d2i_ex_primitive+0x274>
movl   $0xffffffff,-0x14(%rbp)
jmp    16da <asn1_d2i_ex_primitive+0x56a>
jmp    13e9 <asn1_d2i_ex_primitive+0x279>
movl   $0x0,-0x44(%rbp)
mov    -0x48(%rbp),%eax
mov    0x2b56(%rip),%rcx
cmp    (%rcx),%eax
je     1426 <asn1_d2i_ex_primitive+0x2b6>
mov    -0x48(%rbp),%eax
mov    0x2b64(%rip),%rcx
cmp    (%rcx),%eax
je     1426 <asn1_d2i_ex_primitive+0x2b6>
mov    -0x48(%rbp),%eax
mov    0x2bba(%rip),%rcx
cmp    (%rcx),%eax
jne    14ff <asn1_d2i_ex_primitive+0x38f>
mov    -0x48(%rbp),%eax
mov    0x2ba8(%rip),%rcx
cmp    (%rcx),%eax
jne    1453 <asn1_d2i_ex_primitive+0x2e3>
cmpq   $0x0,0x18(%rbp)
je     144e <asn1_d2i_ex_primitive+0x2de>
mov    0x18(%rbp),%rax
movq   $0x0,(%rax)
jmp    1485 <asn1_d2i_ex_primitive+0x315>
cmpb   $0x0,-0x51(%rbp)
jne    1480 <asn1_d2i_ex_primitive+0x310>
mov    0x2b84(%rip),%rax
mov    (%rax),%edi
mov    0x2b73(%rip),%rax
mov    (%rax),%esi
call   1040 <ASN1err@plt>
movl   $0x0,-0x14(%rbp)
jmp    16da <asn1_d2i_ex_primitive+0x56a>
jmp    1485 <asn1_d2i_ex_primitive+0x315>
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x80(%rbp)
cmpb   $0x0,-0x52(%rbp)
je     14d0 <asn1_d2i_ex_primitive+0x360>
mov    -0x50(%rbp),%rsi
lea    -0x60(%rbp),%rdi
movsbl -0x52(%rbp),%edx
call   1090 <asn1_find_end@plt>
cmp    $0x0,%eax
jne    14b9 <asn1_d2i_ex_primitive+0x349>
jmp    16b3 <asn1_d2i_ex_primitive+0x543>
mov    -0x60(%rbp),%rax
mov    -0x80(%rbp),%rcx
sub    %rcx,%rax
mov    %rax,-0x88(%rbp)
jmp    14fa <asn1_d2i_ex_primitive+0x38a>
mov    -0x60(%rbp),%rax
mov    -0x80(%rbp),%rcx
sub    %rcx,%rax
add    -0x50(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x50(%rbp),%rax
add    -0x60(%rbp),%rax
mov    %rax,-0x60(%rbp)
movq   $0x0,-0x70(%rbp)
jmp    1674 <asn1_d2i_ex_primitive+0x504>
cmpb   $0x0,-0x51(%rbp)
je     1650 <asn1_d2i_ex_primitive+0x4e0>
mov    -0x48(%rbp),%eax
mov    0x2a65(%rip),%rcx
cmp    (%rcx),%eax
je     1563 <asn1_d2i_ex_primitive+0x3f3>
mov    -0x48(%rbp),%eax
mov    0x2a5b(%rip),%rcx
cmp    (%rcx),%eax
je     1563 <asn1_d2i_ex_primitive+0x3f3>
mov    -0x48(%rbp),%eax
mov    0x2a91(%rip),%rcx
cmp    (%rcx),%eax
je     1563 <asn1_d2i_ex_primitive+0x3f3>
mov    -0x48(%rbp),%eax
mov    0x2a67(%rip),%rcx
cmp    (%rcx),%eax
je     1563 <asn1_d2i_ex_primitive+0x3f3>
mov    -0x48(%rbp),%eax
mov    0x2a3d(%rip),%rcx
cmp    (%rcx),%eax
jne    1586 <asn1_d2i_ex_primitive+0x416>
mov    0x2a7e(%rip),%rax
mov    (%rax),%edi
mov    0x2a5d(%rip),%rax
mov    (%rax),%esi
call   1040 <ASN1err@plt>
movl   $0x0,-0x14(%rbp)
jmp    16da <asn1_d2i_ex_primitive+0x56a>
movq   $0x0,-0x78(%rbp)
movq   $0x0,-0x68(%rbp)
movq   $0x0,-0x70(%rbp)
mov    -0x50(%rbp),%rdx
mov    -0x52(%rbp),%cl
lea    -0x78(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    $0xffffffff,%r8d
xor    %eax,%eax
mov    0x29cc(%rip),%rax
movsbl %cl,%ecx
movzbl (%rax),%r9d
movl   $0x0,(%rsp)
call   1050 <asn1_collect@plt>
cmp    $0x0,%eax
jne    15e1 <asn1_d2i_ex_primitive+0x471>
movb   $0x1,-0x53(%rbp)
jmp    16b3 <asn1_d2i_ex_primitive+0x543>
mov    -0x78(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x88(%rbp),%rsi
add    $0x1,%rsi
lea    -0x78(%rbp),%rdi
call   1070 <BUF_MEM_grow_clean@plt>
cmp    $0x0,%eax
jne    162c <asn1_d2i_ex_primitive+0x4bc>
mov    0x29d8(%rip),%rax
mov    (%rax),%edi
mov    0x29a7(%rip),%rax
mov    (%rax),%esi
call   1040 <ASN1err@plt>
movl   $0x0,-0x14(%rbp)
jmp    16da <asn1_d2i_ex_primitive+0x56a>
mov    -0x70(%rbp),%rax
mov    -0x88(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x70(%rbp),%rax
mov    %rax,-0x80(%rbp)
movb   $0x1,-0x53(%rbp)
jmp    166f <asn1_d2i_ex_primitive+0x4ff>
mov    -0x60(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x50(%rbp),%rax
add    -0x60(%rbp),%rax
mov    %rax,-0x60(%rbp)
jmp    1674 <asn1_d2i_ex_primitive+0x504>
mov    -0x20(%rbp),%rdi
mov    -0x80(%rbp),%rsi
mov    -0x88(%rbp),%rdx
mov    -0x48(%rbp),%ecx
mov    -0x38(%rbp),%r9
lea    -0x53(%rbp),%r8
call   1060 <asn1_ex_c2i@plt>
cmp    $0x0,%eax
jne    16a1 <asn1_d2i_ex_primitive+0x531>
jmp    16b3 <asn1_d2i_ex_primitive+0x543>
mov    -0x60(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x44(%rbp)
movsbl -0x53(%rbp),%eax
cmp    $0x0,%eax
je     16d4 <asn1_d2i_ex_primitive+0x564>
cmpq   $0x0,-0x70(%rbp)
je     16d4 <asn1_d2i_ex_primitive+0x564>
mov    -0x70(%rbp),%rdi
call   1080 <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    $0x48,%rsp
movb   $0x0,0x9(%rsp)
test   %rdi,%rdi
je     11d3 <asn1_d2i_ex_primitive+0x63>
mov    %r9d,%r15d
mov    %r8d,%ebp
mov    %rdx,%r13
mov    %rdi,%r12
mov    0x88(%rsp),%r10
mov    0x80(%rsp),%bl
mov    (%rcx),%rax
mov    0x2de3(%rip),%rdx
cmp    (%rdx),%rax
jne    11e8 <asn1_d2i_ex_primitive+0x78>
mov    %ebp,0xc(%rsp)
mov    0x2da3(%rip),%rdx
mov    %ebp,%eax
cmp    %ebp,(%rdx)
mov    $0xffffffff,%ebp
jne    12cd <asn1_d2i_ex_primitive+0x15d>
mov    $0xffffffff,%ebp
jmp    1217 <asn1_d2i_ex_primitive+0xa7>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
mov    0x2d65(%rip),%rax
jmp    1340 <asn1_d2i_ex_primitive+0x1d0>
mov    0x8(%rcx),%eax
mov    %eax,0xc(%rsp)
mov    0x2d6a(%rip),%rdx
cmp    (%rdx),%eax
jne    12cd <asn1_d2i_ex_primitive+0x15d>
test   %ebp,%ebp
js     1217 <asn1_d2i_ex_primitive+0xa7>
mov    0x2ddf(%rip),%rax
mov    (%rax),%edi
mov    0x2da6(%rip),%rax
jmp    1340 <asn1_d2i_ex_primitive+0x1d0>
test   %bl,%bl
je     1230 <asn1_d2i_ex_primitive+0xc0>
mov    0x2dc6(%rip),%rax
mov    (%rax),%edi
mov    0x2d3d(%rip),%rax
jmp    1340 <asn1_d2i_ex_primitive+0x1d0>
mov    %rcx,0x20(%rsp)
mov    %rsi,0x18(%rsp)
mov    (%rsi),%rax
mov    %rax,0x10(%rsp)
sub    $0x8,%rsp
xor    %r14d,%r14d
lea    0x14(%rsp),%rsi
lea    0x38(%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     128b <asn1_d2i_ex_primitive+0x11b>
mov    0x30(%rsp),%al
mov    0x2d07(%rip),%rcx
cmp    (%rcx),%al
jne    12a7 <asn1_d2i_ex_primitive+0x137>
mov    0xc(%rsp),%eax
jmp    12b4 <asn1_d2i_ex_primitive+0x144>
mov    0x2d56(%rip),%rax
mov    (%rax),%edi
mov    0x2d0d(%rip),%rax
mov    (%rax),%esi
call   1040 <ASN1err@plt>
jmp    134a <asn1_d2i_ex_primitive+0x1da>
mov    0x2d2a(%rip),%rax
mov    (%rax),%eax
mov    %eax,0xc(%rsp)
mov    0x18(%rsp),%rsi
mov    0x88(%rsp),%r10
mov    0x20(%rsp),%rcx
mov    0x80(%rsp),%bl
mov    %rcx,0x20(%rsp)
cmp    $0xffffffff,%ebp
mov    0x2cac(%rip),%rcx
movzbl (%rcx),%ecx
cmove  %ecx,%r15d
cmovne %ebp,%eax
mov    %rsi,0x18(%rsp)
mov    (%rsi),%rcx
mov    %rcx,0x10(%rsp)
sub    $0x8,%rsp
movsbl %bl,%ebp
lea    0x30(%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     134a <asn1_d2i_ex_primitive+0x1da>
test   %r14d,%r14d
jne    135c <asn1_d2i_ex_primitive+0x1ec>
mov    0x2cb1(%rip),%rax
mov    (%rax),%edi
mov    0x2c68(%rip),%rax
mov    (%rax),%esi
call   1040 <ASN1err@plt>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0xc(%rsp),%eax
mov    0x2be9(%rip),%rdx
mov    0x2c6a(%rip),%rcx
mov    (%rcx),%ecx
cmp    (%rdx),%eax
je     1469 <asn1_d2i_ex_primitive+0x2f9>
mov    0x2bf1(%rip),%rdx
cmp    (%rdx),%eax
je     1469 <asn1_d2i_ex_primitive+0x2f9>
cmp    %ecx,%eax
je     1469 <asn1_d2i_ex_primitive+0x2f9>
cmpb   $0x0,0xb(%rsp)
mov    0x18(%rsp),%r14
je     14c2 <asn1_d2i_ex_primitive+0x352>
mov    0x2bd2(%rip),%rcx
cmp    (%rcx),%eax
je     14d7 <asn1_d2i_ex_primitive+0x367>
mov    0x2bcb(%rip),%rcx
cmp    (%rcx),%eax
je     14d7 <asn1_d2i_ex_primitive+0x367>
mov    0x2c04(%rip),%rcx
cmp    (%rcx),%eax
je     14d7 <asn1_d2i_ex_primitive+0x367>
mov    0x2bdd(%rip),%rcx
cmp    (%rcx),%eax
je     14d7 <asn1_d2i_ex_primitive+0x367>
mov    0x2bb6(%rip),%rcx
cmp    (%rcx),%eax
je     14d7 <asn1_d2i_ex_primitive+0x367>
xorps  %xmm0,%xmm0
movaps %xmm0,0x30(%rsp)
movq   $0x0,0x40(%rsp)
mov    0x28(%rsp),%rdx
movsbl 0xa(%rsp),%ecx
mov    0x2b7c(%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     1555 <asn1_d2i_ex_primitive+0x3e5>
mov    0x30(%rsp),%rbp
lea    0x1(%rbp),%rsi
lea    0x30(%rsp),%rdi
call   1070 <BUF_MEM_grow_clean@plt>
test   %eax,%eax
je     1580 <asn1_d2i_ex_primitive+0x410>
mov    0x38(%rsp),%rbx
movq   $0x0,(%rbx,%rbp,8)
movb   $0x1,0x9(%rsp)
jmp    1510 <asn1_d2i_ex_primitive+0x3a0>
cmp    %ecx,%eax
mov    0x18(%rsp),%r14
jne    1488 <asn1_d2i_ex_primitive+0x318>
mov    0x88(%rsp),%rax
test   %rax,%rax
je     1493 <asn1_d2i_ex_primitive+0x323>
movq   $0x0,(%rax)
jmp    1493 <asn1_d2i_ex_primitive+0x323>
cmpb   $0x0,0xb(%rsp)
je     1540 <asn1_d2i_ex_primitive+0x3d0>
mov    (%r14),%rbx
mov    0xa(%rsp),%al
test   %al,%al
je     14ec <asn1_d2i_ex_primitive+0x37c>
mov    0x28(%rsp),%rsi
movsbl %al,%edx
lea    0x10(%rsp),%rdi
call   1090 <asn1_find_end@plt>
test   %eax,%eax
je     155a <asn1_d2i_ex_primitive+0x3ea>
mov    0x10(%rsp),%rbp
sub    %rbx,%rbp
jmp    1510 <asn1_d2i_ex_primitive+0x3a0>
mov    0x10(%rsp),%rbx
mov    0x28(%rsp),%rbp
lea    (%rbx,%rbp,1),%rax
mov    %rax,0x10(%rsp)
jmp    1510 <asn1_d2i_ex_primitive+0x3a0>
mov    0x2b0a(%rip),%rax
mov    (%rax),%edi
mov    0x2ae9(%rip),%rax
jmp    1340 <asn1_d2i_ex_primitive+0x1d0>
mov    0x10(%rsp),%rax
mov    %rax,%rbp
sub    %rbx,%rbp
mov    0x28(%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    0x20(%rsp),%r9
call   1060 <asn1_ex_c2i@plt>
test   %eax,%eax
je     155a <asn1_d2i_ex_primitive+0x3ea>
mov    0x10(%rsp),%rax
mov    %rax,(%r14)
mov    $0x1,%r14d
jmp    155d <asn1_d2i_ex_primitive+0x3ed>
mov    0x2aa1(%rip),%rax
mov    (%rax),%edi
mov    0x2a90(%rip),%rax
jmp    1340 <asn1_d2i_ex_primitive+0x1d0>
movb   $0x1,0x9(%rsp)
xor    %r14d,%r14d
cmpb   $0x0,0x9(%rsp)
je     134a <asn1_d2i_ex_primitive+0x1da>
mov    0x38(%rsp),%rdi
test   %rdi,%rdi
je     134a <asn1_d2i_ex_primitive+0x1da>
call   1080 <OPENSSL_free@plt>
jmp    134a <asn1_d2i_ex_primitive+0x1da>
mov    0x2a61(%rip),%rax
mov    (%rax),%edi
mov    0x2a30(%rip),%rax
jmp    1340 <asn1_d2i_ex_primitive+0x1d0>

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

LLVM IR (-O2):
%struct.TYPE_12__ = type { i64, i32 }
%struct.TYPE_11__ = type { i64 }
%struct.TYPE_10__ = type { i64, i64*, i64 }
@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 %196
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 %196
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 %196
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 %196
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 %196
]
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 %196
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 %196
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 %196
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 %186
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 %196
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, %159
%187 = phi i32 [ 1, %184 ], [ 0, %178 ], [ 0, %111 ], [ 0, %159 ]
%188 = load i8, i8* %13
%189 = icmp ne i8 %188, 0
%190 = getelementptr inbounds %struct.TYPE_10__, %struct.TYPE_10__* %15, i64 0, i32 1
%191 = load i64*, i64** %190
%192 = icmp ne i64* %191, null
%193 = select i1 %189, i1 %192, i1 false
br i1 %193, label %194, label %196
194: ; preds = %186
%195 = call i32 @OPENSSL_free(i64* %191)
br label %196
196: ; preds = %186, %194, %71, %42, %49, %57, %166, %147, %103, %81, %22
%197 = phi i32 [ 0, %103 ], [ 0, %147 ], [ 0, %166 ], [ 0, %81 ], [ 0, %22 ], [ 0, %57 ], [ 0, %49 ], [ 0, %42 ], [ %80, %71 ], [ %187, %194 ], [ %187, %186 ]
ret i32 %197
}