#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;
  (&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)
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    1193 <ASN1_item_d2i+0x83>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    119b <ASN1_item_d2i+0x8b>
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 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i32 0, i32 0
store i64 0, i64* %16
%17 = load i32**, i32*** %6
%18 = load i8**, i8*** %7
%19 = load i64, i64* %8
%20 = load i32*, i32** %9
%21 = call i64 @ASN1_item_ex_d2i(i32** %17, i8** %18, i64 %19, i32* %20, i32 -1, i32 0, i32 0, %struct.TYPE_3__* %10)
%22 = icmp sgt i64 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %15
%24 = load i32**, i32*** %6
%25 = load i32*, i32** %24
store i32* %25, i32** %5
br label %27
26: ; preds = %15
store i32* null, i32** %5
br label %27
27: ; preds = %26, %23
%28 = load i32*, i32** %5
ret i32* %28
}

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
}