#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__ {
  unsigned char *data;
  int /*<<< orphan*/ length;
};
typedef TYPE_1__ ASN1_STRING;
typedef int /*<<< orphan*/ ASN1_ITEM;

/* Variables and functions */
int /*<<< orphan*/ ASN1_R_DECODE_ERROR;
void *ASN1_item_d2i(int /*<<< orphan*/ *, unsigned char const **,
                    int /*<<< orphan*/, int /*<<< orphan*/ const *);
int /*<<< orphan*/ ASN1error(int /*<<< orphan*/);
void *ASN1_item_unpack(const ASN1_STRING *oct, const ASN1_ITEM *it) {
  const unsigned char *p;
  void *ret;
  p = oct->data;
  if (!(ret = ASN1_item_d2i(NULL, &p, oct->length, it)))
    ASN1error(ASN1_R_DECODE_ERROR);
  return ret;
}


x86 assembly (clang, -O0):
<ASN1_item_unpack>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%edx
mov    -0x10(%rbp),%rcx
xor    %eax,%eax
mov    %eax,%edi
lea    -0x18(%rbp),%rsi
call   1030 <ASN1_item_d2i@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
jne    116f <ASN1_item_unpack+0x4f>
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
call   1040 <ASN1error@plt>
mov    -0x20(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ASN1_item_unpack>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rcx
mov    (%rdi),%rax
mov    %rax,0x8(%rsp)
mov    0x8(%rdi),%edx
lea    0x8(%rsp),%rsi
xor    %edi,%edi
call   1030 <ASN1_item_d2i@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1155 <ASN1_item_unpack+0x35>
mov    0x2e92(%rip),%rax
mov    (%rax),%edi
call   1040 <ASN1error@plt>
mov    %rbx,%rax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i8*, i32 }
@ASN1_R_DECODE_ERROR = global i32 0
define i8* @ASN1_item_unpack(%struct.TYPE_3__* %0, i32* %1) {
%3 = alloca %struct.TYPE_3__*
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
store %struct.TYPE_3__* %0, %struct.TYPE_3__** %3
store i32* %1, i32** %4
%7 = load %struct.TYPE_3__*, %struct.TYPE_3__** %3
%8 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %7, i32 0, i32 0
%9 = load i8*, i8** %8
store i8* %9, i8** %5
%10 = load %struct.TYPE_3__*, %struct.TYPE_3__** %3
%11 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i32 0, i32 1
%12 = load i32, i32* %11
%13 = load i32*, i32** %4
%14 = call i8* @ASN1_item_d2i(i32* null, i8** %5, i32 %12, i32* %13)
store i8* %14, i8** %6
%15 = icmp ne i8* %14, null
br i1 %15, label %19, label %16
16: ; preds = %2
%17 = load i32, i32* @ASN1_R_DECODE_ERROR
%18 = call i32 @ASN1error(i32 %17)
br label %19
19: ; preds = %16, %2
%20 = load i8*, i8** %6
ret i8* %20
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i8*, i32 }
@ASN1_R_DECODE_ERROR = global i32 0
define i8* @ASN1_item_unpack(%struct.TYPE_3__* nocapture %0, i32* %1) {
%3 = alloca i8*
%4 = bitcast i8** %3 to i8*
%5 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
%6 = load i8*, i8** %5
store i8* %6, i8** %3
%7 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 1
%8 = load i32, i32* %7
%9 = call i8* @ASN1_item_d2i(i32* null, i8** %3, i32 %8, i32* %1)
%10 = icmp eq i8* %9, null
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32, i32* @ASN1_R_DECODE_ERROR
%13 = call i32 @ASN1error(i32 %12)
br label %14
14: ; preds = %11, %2
ret i8* %9
}