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

/* Type definitions */
struct TYPE_3__ {
  scalar_t__ valid;
};
typedef int /*<<< orphan*/ ASN1_VALUE;
typedef TYPE_1__ ASN1_TLC;
typedef int /*<<< orphan*/ ASN1_ITEM;

/* Variables and functions */
scalar_t__ ASN1_item_ex_d2i(int /*<<< orphan*/ **, unsigned char const **, long,
                            int /*<<< orphan*/ const *, int, int /*<<< orphan*/,
                            int /*<<< orphan*/, TYPE_1__ *);
ASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
                          const ASN1_ITEM *it) {
  ASN1_TLC c;
  ASN1_VALUE *ptmpval = NULL;
  if (!pval)
    pval = &ptmpval;
  if (&c)
    (&c)->valid = 0;
  if (ASN1_item_ex_d2i(pval, in, len, it, -1, 0, 0, &c) > 0)
    return *pval;
  return NULL;
}


x86 assembly (clang, -O0):
<ASN1_item_d2i>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
movq   $0x0,-0x38(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1143 <ASN1_item_d2i+0x33>
lea    -0x38(%rbp),%rax
mov    %rax,-0x10(%rbp)
lea    -0x30(%rbp),%rax
cmp    $0x0,%rax
je     1159 <ASN1_item_d2i+0x49>
movq   $0x0,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
lea    -0x30(%rbp),%rax
movl   $0x0,(%rsp)
mov    %rax,0x8(%rsp)
call   1030 <ASN1_item_ex_d2i@plt>
cmp    $0x0,%rax
jle    11a1 <ASN1_item_d2i+0x91>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    11a9 <ASN1_item_d2i+0x99>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ASN1_item_d2i>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movq   $0x0,0x8(%rsp)
test   %rdi,%rdi
lea    0x8(%rsp),%rbx
cmovne %rdi,%rbx
movq   $0x0,0x10(%rsp)
lea    0x10(%rsp),%rax
xor    %r14d,%r14d
mov    %rbx,%rdi
mov    $0xffffffff,%r8d
xor    %r9d,%r9d
push   %rax
push   $0x0
call   1030 <ASN1_item_ex_d2i@plt>
add    $0x10,%rsp
test   %rax,%rax
jle    115d <ASN1_item_d2i+0x4d>
mov    (%rbx),%r14
mov    %r14,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i64 }
define i32* @ASN1_item_d2i(i32** %0, i8** %1, i64 %2, i32* %3) {
%5 = alloca i32*
%6 = alloca i32**
%7 = alloca i8**
%8 = alloca i64
%9 = alloca i32*
%10 = alloca %struct.TYPE_3__
%11 = alloca i32*
store i32** %0, i32*** %6
store i8** %1, i8*** %7
store i64 %2, i64* %8
store i32* %3, i32** %9
store i32* null, i32** %11
%12 = load i32**, i32*** %6
%13 = icmp ne i32** %12, null
br i1 %13, label %15, label %14
14: ; preds = %4
store i32** %11, i32*** %6
br label %15
15: ; preds = %14, %4
%16 = icmp ne %struct.TYPE_3__* %10, null
br i1 %16, label %17, label %19
17: ; preds = %15
%18 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i32 0, i32 0
store i64 0, i64* %18
br label %19
19: ; preds = %17, %15
%20 = load i32**, i32*** %6
%21 = load i8**, i8*** %7
%22 = load i64, i64* %8
%23 = load i32*, i32** %9
%24 = call i64 @ASN1_item_ex_d2i(i32** %20, i8** %21, i64 %22, i32* %23, i32 -1, i32 0, i32 0, %struct.TYPE_3__* %10)
%25 = icmp sgt i64 %24, 0
br i1 %25, label %26, label %29
26: ; preds = %19
%27 = load i32**, i32*** %6
%28 = load i32*, i32** %27
store i32* %28, i32** %5
br label %30
29: ; preds = %19
store i32* null, i32** %5
br label %30
30: ; preds = %29, %26
%31 = load i32*, i32** %5
ret i32* %31
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i64 }
define i32* @ASN1_item_d2i(i32** %0, i8** %1, i64 %2, i32* %3) {
%5 = alloca %struct.TYPE_3__
%6 = alloca i32*
%7 = bitcast %struct.TYPE_3__* %5 to i8*
%8 = bitcast i32** %6 to i8*
store i32* null, i32** %6
%9 = icmp eq i32** %0, null
%10 = select i1 %9, i32** %6, i32** %0
%11 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %5, i64 0, i32 0
store i64 0, i64* %11
%12 = call i64 @ASN1_item_ex_d2i(i32** %10, i8** %1, i64 %2, i32* %3, i32 -1, i32 0, i32 0, %struct.TYPE_3__* %5)
%13 = icmp sgt i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %4
%15 = load i32*, i32** %10
br label %16
16: ; preds = %4, %14
%17 = phi i32* [ %15, %14 ], [ null, %4 ]
ret i32* %17
}