#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_5__ TYPE_1__;

/* Type definitions */
struct TYPE_5__ {
  int flags;
  int /*<<< orphan*/ tag;
};
typedef int /*<<< orphan*/ ASN1_VALUE;
typedef int /*<<< orphan*/ ASN1_TLC;
typedef TYPE_1__ ASN1_TEMPLATE;

/* Variables and functions */
int /*<<< orphan*/ ASN1_F_ASN1_TEMPLATE_EX_D2I;
int /*<<< orphan*/ ASN1_R_EXPLICIT_LENGTH_MISMATCH;
int /*<<< orphan*/ ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED;
int /*<<< orphan*/ ASN1_R_MISSING_EOC;
int ASN1_TFLG_EXPTAG;
int ASN1_TFLG_TAG_CLASS;
int /*<<< orphan*/ ASN1_template_free(int /*<<< orphan*/ **, TYPE_1__ const *);
int /*<<< orphan*/ ASN1err(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ ERR_R_NESTED_ASN1_ERROR;
int /*<<< orphan*/ asn1_check_eoc(unsigned char const **, long);
int asn1_check_tlen(long *, int /*<<< orphan*/ *, int /*<<< orphan*/ *, char *,
                    char *, unsigned char const **, long, int /*<<< orphan*/,
                    int, char, int /*<<< orphan*/ *);
int asn1_template_noexp_d2i(int /*<<< orphan*/ **, unsigned char const **, long,
                            TYPE_1__ const *, char, int /*<<< orphan*/ *);
int asn1_template_ex_d2i(ASN1_VALUE **val, const unsigned char **in, long inlen,
                         const ASN1_TEMPLATE *tt, char opt, ASN1_TLC *ctx) {
  int flags, aclass;
  int ret;
  long len;
  const unsigned char *p, *q;
  char exp_eoc;
  if (!val)
    return 0;
  flags = tt->flags;
  aclass = flags & ASN1_TFLG_TAG_CLASS;
  p = *in;
  if (flags & ASN1_TFLG_EXPTAG) {
    char cst;
    ret = asn1_check_tlen(&len, NULL, NULL, &exp_eoc, &cst, &p, inlen, tt->tag,
                          aclass, opt, ctx);
    q = p;
    if (!ret) {
      ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, ERR_R_NESTED_ASN1_ERROR);
      return 0;
    } else if (ret == -1)
      return -1;
    if (!cst) {
      ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED);
      return 0;
    }
    ret = asn1_template_noexp_d2i(val, &p, len, tt, 0, ctx);
    if (!ret) {
      ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, ERR_R_NESTED_ASN1_ERROR);
      return 0;
    }
    len -= p - q;
    if (exp_eoc) {
      if (!asn1_check_eoc(&p, len)) {
        ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, ASN1_R_MISSING_EOC);
        goto err;
      }
    } else {
      if (len) {
        ASN1err(ASN1_F_ASN1_TEMPLATE_EX_D2I, ASN1_R_EXPLICIT_LENGTH_MISMATCH);
        goto err;
      }
    }
  } else
    return asn1_template_noexp_d2i(val, in, inlen, tt, opt, ctx);
  *in = p;
  return 1;
err:
  ASN1_template_free(val, tt);
  *val = NULL;
  return 0;
}


x86 assembly (clang, -O0):
<asn1_template_ex_d2i>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x90,%rsp
mov    %r8b,%al
mov    %rdi,-0x20(%rbp)
mov    %rsi,-0x28(%rbp)
mov    %rdx,-0x30(%rbp)
mov    %rcx,-0x38(%rbp)
mov    %al,-0x39(%rbp)
mov    %r9,-0x48(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    118f <asn1_template_ex_d2i+0x3f>
movl   $0x0,-0x14(%rbp)
jmp    13c7 <asn1_template_ex_d2i+0x277>
mov    -0x38(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    0x2e36(%rip),%rcx
and    (%rcx),%eax
mov    %eax,-0x50(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x68(%rbp)
mov    -0x4c(%rbp),%eax
mov    0x2df4(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     1369 <asn1_template_ex_d2i+0x219>
mov    -0x30(%rbp),%r14
mov    -0x38(%rbp),%rax
mov    0x4(%rax),%ebx
mov    -0x50(%rbp),%r11d
mov    -0x39(%rbp),%r10b
mov    -0x48(%rbp),%rax
lea    -0x60(%rbp),%rdi
xor    %ecx,%ecx
mov    %ecx,%edx
lea    -0x71(%rbp),%rcx
lea    -0x72(%rbp),%r8
lea    -0x68(%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,-0x54(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0x70(%rbp)
cmpl   $0x0,-0x54(%rbp)
jne    124d <asn1_template_ex_d2i+0xfd>
mov    0x2d97(%rip),%rax
mov    (%rax),%edi
mov    0x2d96(%rip),%rax
mov    (%rax),%esi
call   1040 <ASN1err@plt>
movl   $0x0,-0x14(%rbp)
jmp    13c7 <asn1_template_ex_d2i+0x277>
cmpl   $0xffffffff,-0x54(%rbp)
jne    1263 <asn1_template_ex_d2i+0x113>
movl   $0xffffffff,-0x14(%rbp)
jmp    13c7 <asn1_template_ex_d2i+0x277>
jmp    1268 <asn1_template_ex_d2i+0x118>
cmpb   $0x0,-0x72(%rbp)
jne    1295 <asn1_template_ex_d2i+0x145>
mov    0x2d4f(%rip),%rax
mov    (%rax),%edi
mov    0x2d36(%rip),%rax
mov    (%rax),%esi
call   1040 <ASN1err@plt>
movl   $0x0,-0x14(%rbp)
jmp    13c7 <asn1_template_ex_d2i+0x277>
mov    -0x20(%rbp),%rdi
mov    -0x60(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x48(%rbp),%r9
lea    -0x68(%rbp),%rsi
xor    %r8d,%r8d
call   1070 <asn1_template_noexp_d2i@plt>
mov    %eax,-0x54(%rbp)
cmpl   $0x0,-0x54(%rbp)
jne    12e1 <asn1_template_ex_d2i+0x191>
mov    0x2d03(%rip),%rax
mov    (%rax),%edi
mov    0x2d02(%rip),%rax
mov    (%rax),%esi
call   1040 <ASN1err@plt>
movl   $0x0,-0x14(%rbp)
jmp    13c7 <asn1_template_ex_d2i+0x277>
mov    -0x68(%rbp),%rcx
mov    -0x70(%rbp),%rax
sub    %rax,%rcx
mov    -0x60(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x60(%rbp)
cmpb   $0x0,-0x71(%rbp)
je     1338 <asn1_template_ex_d2i+0x1e8>
mov    -0x60(%rbp),%rsi
lea    -0x68(%rbp),%rdi
call   1060 <asn1_check_eoc@plt>
cmp    $0x0,%eax
jne    1333 <asn1_template_ex_d2i+0x1e3>
mov    0x2caa(%rip),%rax
mov    (%rax),%edi
mov    0x2cb9(%rip),%rax
mov    (%rax),%esi
call   1040 <ASN1err@plt>
jmp    13a8 <asn1_template_ex_d2i+0x258>
jmp    1364 <asn1_template_ex_d2i+0x214>
cmpq   $0x0,-0x60(%rbp)
je     135f <asn1_template_ex_d2i+0x20f>
mov    0x2c7e(%rip),%rax
mov    (%rax),%edi
mov    0x2c95(%rip),%rax
mov    (%rax),%esi
call   1040 <ASN1err@plt>
jmp    13a8 <asn1_template_ex_d2i+0x258>
jmp    1364 <asn1_template_ex_d2i+0x214>
jmp    1391 <asn1_template_ex_d2i+0x241>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x39(%rbp),%al
mov    -0x48(%rbp),%r9
movsbl %al,%r8d
call   1070 <asn1_template_noexp_d2i@plt>
mov    %eax,-0x14(%rbp)
jmp    13c7 <asn1_template_ex_d2i+0x277>
mov    -0x68(%rbp),%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x1,-0x14(%rbp)
jmp    13c7 <asn1_template_ex_d2i+0x277>
mov    -0x20(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1050 <ASN1_template_free@plt>
mov    -0x20(%rbp),%rax
movq   $0x0,(%rax)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x90,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

x86 assembly (clang, -O2):
<asn1_template_ex_d2i>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
test   %rdi,%rdi
je     1280 <asn1_template_ex_d2i+0x130>
mov    %r9,%r13
mov    %rcx,%r14
mov    %rdx,%rax
mov    %rsi,%r15
mov    %rdi,%r12
mov    (%rcx),%ecx
mov    0x2e59(%rip),%rdx
mov    (%rdx),%ebp
mov    (%rsi),%rdx
mov    %rdx,0x8(%rsp)
mov    0x2e20(%rip),%rdx
test   %ecx,(%rdx)
je     1242 <asn1_template_ex_d2i+0xf2>
and    %ecx,%ebp
mov    0x4(%r14),%r10d
sub    $0x8,%rsp
movsbl %r8b,%ebx
lea    0x18(%rsp),%rdi
lea    0xf(%rsp),%rcx
lea    0xe(%rsp),%r8
lea    0x10(%rsp),%r9
xor    %esi,%esi
xor    %edx,%edx
push   %r13
push   %rbx
push   %rbp
push   %r10
push   %rax
call   1030 <asn1_check_tlen@plt>
add    $0x30,%rsp
cmp    $0xffffffff,%eax
je     1282 <asn1_template_ex_d2i+0x132>
mov    0x2df2(%rip),%rbp
test   %eax,%eax
je     126f <asn1_template_ex_d2i+0x11f>
cmpb   $0x0,0x6(%rsp)
je     1268 <asn1_template_ex_d2i+0x118>
mov    0x8(%rsp),%rbx
mov    0x10(%rsp),%rdx
lea    0x8(%rsp),%rsi
mov    %r12,%rdi
mov    %r14,%rcx
xor    %r8d,%r8d
mov    %r13,%r9
call   1070 <asn1_template_noexp_d2i@plt>
test   %eax,%eax
je     126f <asn1_template_ex_d2i+0x11f>
mov    0x8(%rsp),%rax
sub    %rax,%rbx
add    0x10(%rsp),%rbx
mov    %rbx,0x10(%rsp)
cmpb   $0x0,0x7(%rsp)
je     1291 <asn1_template_ex_d2i+0x141>
lea    0x8(%rsp),%rdi
mov    %rbx,%rsi
call   1060 <asn1_check_eoc@plt>
test   %eax,%eax
je     12a9 <asn1_template_ex_d2i+0x159>
mov    0x8(%rsp),%rax
jmp    129f <asn1_template_ex_d2i+0x14f>
movsbl %r8b,%r8d
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rax,%rdx
mov    %r14,%rcx
mov    %r13,%r9
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <asn1_template_noexp_d2i@plt>
mov    0x2d49(%rip),%rbp
mov    0x2d52(%rip),%rax
mov    (%rax),%edi
mov    0x0(%rbp),%esi
call   1040 <ASN1err@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
test   %rbx,%rbx
je     129f <asn1_template_ex_d2i+0x14f>
mov    0x2d4b(%rip),%rax
jmp    12b0 <asn1_template_ex_d2i+0x160>
mov    %rax,(%r15)
mov    $0x1,%eax
jmp    1282 <asn1_template_ex_d2i+0x132>
mov    0x2d30(%rip),%rax
mov    0x2d11(%rip),%rcx
mov    (%rcx),%edi
mov    (%rax),%esi
call   1040 <ASN1err@plt>
mov    %r12,%rdi
mov    %r14,%rsi
call   1050 <ASN1_template_free@plt>
movq   $0x0,(%r12)
jmp    1280 <asn1_template_ex_d2i+0x130>

LLVM IR (-O0):
%struct.TYPE_5__ = type { i32, i32 }
@ASN1_TFLG_TAG_CLASS = global i32 0
@ASN1_TFLG_EXPTAG = global i32 0
@ASN1_F_ASN1_TEMPLATE_EX_D2I = global i32 0
@ERR_R_NESTED_ASN1_ERROR = global i32 0
@ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED = global i32 0
@ASN1_R_MISSING_EOC = global i32 0
@ASN1_R_EXPLICIT_LENGTH_MISMATCH = global i32 0
define i32 @asn1_template_ex_d2i(i32** %0, i8** %1, i64 %2, %struct.TYPE_5__* %3, i8 signext %4, i32* %5) {
%7 = alloca i32
%8 = alloca i32**
%9 = alloca i8**
%10 = alloca i64
%11 = alloca %struct.TYPE_5__*
%12 = alloca i8
%13 = alloca i32*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i64
%18 = alloca i8*
%19 = alloca i8*
%20 = alloca i8
%21 = alloca i8
store i32** %0, i32*** %8
store i8** %1, i8*** %9
store i64 %2, i64* %10
store %struct.TYPE_5__* %3, %struct.TYPE_5__** %11
store i8 %4, i8* %12
store i32* %5, i32** %13
%22 = load i32**, i32*** %8
%23 = icmp ne i32** %22, null
br i1 %23, label %25, label %24
24: ; preds = %6
store i32 0, i32* %7
br label %122
25: ; preds = %6
%26 = load %struct.TYPE_5__*, %struct.TYPE_5__** %11
%27 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %26, i32 0, i32 0
%28 = load i32, i32* %27
store i32 %28, i32* %14
%29 = load i32, i32* %14
%30 = load i32, i32* @ASN1_TFLG_TAG_CLASS
%31 = and i32 %29, %30
store i32 %31, i32* %15
%32 = load i8**, i8*** %9
%33 = load i8*, i8** %32
store i8* %33, i8** %18
%34 = load i32, i32* %14
%35 = load i32, i32* @ASN1_TFLG_EXPTAG
%36 = and i32 %34, %35
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %106
38: ; preds = %25
%39 = load i64, i64* %10
%40 = load %struct.TYPE_5__*, %struct.TYPE_5__** %11
%41 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %40, i32 0, i32 1
%42 = load i32, i32* %41
%43 = load i32, i32* %15
%44 = load i8, i8* %12
%45 = load i32*, i32** %13
%46 = call i32 @asn1_check_tlen(i64* %17, i32* null, i32* null, i8* %20, i8* %21, i8** %18, i64 %39, i32 %42, i32 %43, i8 signext %44, i32* %45)
store i32 %46, i32* %16
%47 = load i8*, i8** %18
store i8* %47, i8** %19
%48 = load i32, i32* %16
%49 = icmp ne i32 %48, 0
br i1 %49, label %54, label %50
50: ; preds = %38
%51 = load i32, i32* @ASN1_F_ASN1_TEMPLATE_EX_D2I
%52 = load i32, i32* @ERR_R_NESTED_ASN1_ERROR
%53 = call i32 @ASN1err(i32 %51, i32 %52)
store i32 0, i32* %7
br label %122
54: ; preds = %38
%55 = load i32, i32* %16
%56 = icmp eq i32 %55, -1
br i1 %56, label %57, label %58
57: ; preds = %54
store i32 -1, i32* %7
br label %122
58: ; preds = %54
br label %59
59: ; preds = %58
%60 = load i8, i8* %21
%61 = icmp ne i8 %60, 0
br i1 %61, label %66, label %62
62: ; preds = %59
%63 = load i32, i32* @ASN1_F_ASN1_TEMPLATE_EX_D2I
%64 = load i32, i32* @ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED
%65 = call i32 @ASN1err(i32 %63, i32 %64)
store i32 0, i32* %7
br label %122
66: ; preds = %59
%67 = load i32**, i32*** %8
%68 = load i64, i64* %17
%69 = load %struct.TYPE_5__*, %struct.TYPE_5__** %11
%70 = load i32*, i32** %13
%71 = call i32 @asn1_template_noexp_d2i(i32** %67, i8** %18, i64 %68, %struct.TYPE_5__* %69, i8 signext 0, i32* %70)
store i32 %71, i32* %16
%72 = load i32, i32* %16
%73 = icmp ne i32 %72, 0
br i1 %73, label %78, label %74
74: ; preds = %66
%75 = load i32, i32* @ASN1_F_ASN1_TEMPLATE_EX_D2I
%76 = load i32, i32* @ERR_R_NESTED_ASN1_ERROR
%77 = call i32 @ASN1err(i32 %75, i32 %76)
store i32 0, i32* %7
br label %122
78: ; preds = %66
%79 = load i8*, i8** %18
%80 = load i8*, i8** %19
%81 = ptrtoint i8* %79 to i64
%82 = ptrtoint i8* %80 to i64
%83 = sub i64 %81, %82
%84 = load i64, i64* %17
%85 = sub nsw i64 %84, %83
store i64 %85, i64* %17
%86 = load i8, i8* %20
%87 = icmp ne i8 %86, 0
br i1 %87, label %88, label %97
88: ; preds = %78
%89 = load i64, i64* %17
%90 = call i32 @asn1_check_eoc(i8** %18, i64 %89)
%91 = icmp ne i32 %90, 0
br i1 %91, label %96, label %92
92: ; preds = %88
%93 = load i32, i32* @ASN1_F_ASN1_TEMPLATE_EX_D2I
%94 = load i32, i32* @ASN1_R_MISSING_EOC
%95 = call i32 @ASN1err(i32 %93, i32 %94)
br label %117
96: ; preds = %88
br label %105
97: ; preds = %78
%98 = load i64, i64* %17
%99 = icmp ne i64 %98, 0
br i1 %99, label %100, label %104
100: ; preds = %97
%101 = load i32, i32* @ASN1_F_ASN1_TEMPLATE_EX_D2I
%102 = load i32, i32* @ASN1_R_EXPLICIT_LENGTH_MISMATCH
%103 = call i32 @ASN1err(i32 %101, i32 %102)
br label %117
104: ; preds = %97
br label %105
105: ; preds = %104, %96
br label %114
106: ; preds = %25
%107 = load i32**, i32*** %8
%108 = load i8**, i8*** %9
%109 = load i64, i64* %10
%110 = load %struct.TYPE_5__*, %struct.TYPE_5__** %11
%111 = load i8, i8* %12
%112 = load i32*, i32** %13
%113 = call i32 @asn1_template_noexp_d2i(i32** %107, i8** %108, i64 %109, %struct.TYPE_5__* %110, i8 signext %111, i32* %112)
store i32 %113, i32* %7
br label %122
114: ; preds = %105
%115 = load i8*, i8** %18
%116 = load i8**, i8*** %9
store i8* %115, i8** %116
store i32 1, i32* %7
br label %122
117: ; preds = %100, %92
%118 = load i32**, i32*** %8
%119 = load %struct.TYPE_5__*, %struct.TYPE_5__** %11
%120 = call i32 @ASN1_template_free(i32** %118, %struct.TYPE_5__* %119)
%121 = load i32**, i32*** %8
store i32* null, i32** %121
store i32 0, i32* %7
br label %122
122: ; preds = %117, %114, %106, %74, %62, %57, %50, %24
%123 = load i32, i32* %7
ret i32 %123
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i32, i32 }
@ASN1_TFLG_TAG_CLASS = global i32 0
@ASN1_TFLG_EXPTAG = global i32 0
@ASN1_F_ASN1_TEMPLATE_EX_D2I = global i32 0
@ERR_R_NESTED_ASN1_ERROR = global i32 0
@ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED = global i32 0
@ASN1_R_MISSING_EOC = global i32 0
@ASN1_R_EXPLICIT_LENGTH_MISMATCH = global i32 0
define i32 @asn1_template_ex_d2i(i32** %0, i8** %1, i64 %2, %struct.TYPE_5__* %3, i8 signext %4, i32* %5) {
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i8
%10 = alloca i8
%11 = bitcast i64* %7 to i8*
%12 = bitcast i8** %8 to i8*
%13 = icmp eq i32** %0, null
br i1 %13, label %68, label %14
14: ; preds = %6
%15 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 0
%16 = load i32, i32* %15
%17 = load i32, i32* @ASN1_TFLG_TAG_CLASS
%18 = load i8*, i8** %1
store i8* %18, i8** %8
%19 = load i32, i32* @ASN1_TFLG_EXPTAG
%20 = and i32 %19, %16
%21 = icmp eq i32 %20, 0
br i1 %21, label %58, label %22
22: ; preds = %14
%23 = and i32 %17, %16
%24 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %3, i64 0, i32 1
%25 = load i32, i32* %24
%26 = call i32 @asn1_check_tlen(i64* %7, i32* null, i32* null, i8* %9, i8* %10, i8** %8, i64 %2, i32 %25, i32 %23, i8 signext %4, i32* %5)
%27 = load i8*, i8** %8
switch i32 %26, label %28 [
i32 0, label %51
i32 -1, label %56
]
28: ; preds = %22
%29 = load i8, i8* %10
%30 = icmp eq i8 %29, 0
br i1 %30, label %51, label %31
31: ; preds = %28
%32 = load i64, i64* %7
%33 = call i32 @asn1_template_noexp_d2i(i32** %0, i8** %8, i64 %32, %struct.TYPE_5__* %3, i8 signext 0, i32* %5)
%34 = icmp eq i32 %33, 0
br i1 %34, label %51, label %35
35: ; preds = %31
%36 = load i8*, i8** %8
%37 = ptrtoint i8* %36 to i64
%38 = ptrtoint i8* %27 to i64
%39 = sub i64 %38, %37
%40 = load i64, i64* %7
%41 = add i64 %39, %40
store i64 %41, i64* %7
%42 = load i8, i8* %9
%43 = icmp eq i8 %42, 0
br i1 %43, label %49, label %44
44: ; preds = %35
%45 = call i32 @asn1_check_eoc(i8** %8, i64 %41)
%46 = icmp eq i32 %45, 0
br i1 %46, label %62, label %47
47: ; preds = %44
%48 = load i8*, i8** %8
br label %60
49: ; preds = %35
%50 = icmp eq i64 %41, 0
br i1 %50, label %60, label %62
51: ; preds = %31, %28, %22
%52 = phi i32* [ @ERR_R_NESTED_ASN1_ERROR, %22 ], [ @ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED, %28 ], [ @ERR_R_NESTED_ASN1_ERROR, %31 ]
%53 = load i32, i32* @ASN1_F_ASN1_TEMPLATE_EX_D2I
%54 = load i32, i32* %52
%55 = call i32 @ASN1err(i32 %53, i32 %54)
br label %56
56: ; preds = %51, %22
%57 = phi i32 [ %26, %22 ], [ 0, %51 ]
br label %68
58: ; preds = %14
%59 = tail call i32 @asn1_template_noexp_d2i(i32** %0, i8** %1, i64 %2, %struct.TYPE_5__* %3, i8 signext %4, i32* %5)
br label %68
60: ; preds = %47, %49
%61 = phi i8* [ %48, %47 ], [ %36, %49 ]
store i8* %61, i8** %1
br label %68
62: ; preds = %49, %44
%63 = phi i32* [ @ASN1_R_MISSING_EOC, %44 ], [ @ASN1_R_EXPLICIT_LENGTH_MISMATCH, %49 ]
%64 = load i32, i32* @ASN1_F_ASN1_TEMPLATE_EX_D2I
%65 = load i32, i32* %63
%66 = call i32 @ASN1err(i32 %64, i32 %65)
%67 = call i32 @ASN1_template_free(i32** %0, %struct.TYPE_5__* %3)
store i32* null, i32** %0
br label %68
68: ; preds = %56, %6, %62, %60, %58
%69 = phi i32 [ 0, %62 ], [ 1, %60 ], [ %59, %58 ], [ 0, %6 ], [ %57, %56 ]
ret i32 %69
}