#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__ type;
  int /*<<< orphan*/ length;
  int /*<<< orphan*/ data;
};
typedef int /*<<< orphan*/ BIGNUM;
typedef TYPE_1__ ASN1_ENUMERATED;

/* Variables and functions */
int /*<<< orphan*/ ASN1_R_BN_LIB;
int /*<<< orphan*/ ASN1error(int /*<<< orphan*/);
int /*<<< orphan*/ *BN_bin2bn(int /*<<< orphan*/, int /*<<< orphan*/,
                              int /*<<< orphan*/ *);
int /*<<< orphan*/ BN_set_negative(int /*<<< orphan*/ *, int);
scalar_t__ V_ASN1_NEG_ENUMERATED;
BIGNUM *ASN1_ENUMERATED_to_BN(const ASN1_ENUMERATED *ai, BIGNUM *bn) {
  BIGNUM *ret;
  if ((ret = BN_bin2bn(ai->data, ai->length, bn)) == NULL)
    ASN1error(ASN1_R_BN_LIB);
  else if (ai->type == V_ASN1_NEG_ENUMERATED)
    BN_set_negative(ret, 1);
  return (ret);
}


x86 assembly (clang, -O0):
<ASN1_ENUMERATED_to_BN>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%edi
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%esi
mov    -0x10(%rbp),%rdx
call   1030 <BN_bin2bn@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1178 <ASN1_ENUMERATED_to_BN+0x48>
mov    0x2e8c(%rip),%rax
mov    (%rax),%edi
call   1050 <ASN1error@plt>
jmp    11a2 <ASN1_ENUMERATED_to_BN+0x72>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    0x2e5a(%rip),%rcx
cmp    (%rcx),%rax
jne    119d <ASN1_ENUMERATED_to_BN+0x6d>
mov    -0x18(%rbp),%rdi
mov    $0x1,%esi
call   1040 <BN_set_negative@plt>
jmp    11a2 <ASN1_ENUMERATED_to_BN+0x72>
mov    -0x18(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ASN1_ENUMERATED_to_BN>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rdx
mov    %rdi,%rbx
mov    0x8(%rdi),%esi
mov    0xc(%rdi),%edi
call   1030 <BN_bin2bn@plt>
mov    %rax,%r14
test   %rax,%rax
je     116b <ASN1_ENUMERATED_to_BN+0x3b>
mov    (%rbx),%rax
mov    0x2e89(%rip),%rcx
cmp    (%rcx),%rax
jne    1179 <ASN1_ENUMERATED_to_BN+0x49>
mov    %r14,%rdi
mov    $0x1,%esi
call   1040 <BN_set_negative@plt>
jmp    1179 <ASN1_ENUMERATED_to_BN+0x49>
mov    0x2e86(%rip),%rax
mov    (%rax),%edi
call   1050 <ASN1error@plt>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
%struct.TYPE_3__ = type { i64, i32, i32 }
@ASN1_R_BN_LIB = global i32 0
@V_ASN1_NEG_ENUMERATED = global i64 0
define i32* @ASN1_ENUMERATED_to_BN(%struct.TYPE_3__* nocapture %0, i32* %1) {
%3 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 2
%4 = load i32, i32* %3
%5 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 1
%6 = load i32, i32* %5
%7 = tail call i32* @BN_bin2bn(i32 %4, i32 %6, i32* %1)
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = load i32, i32* @ASN1_R_BN_LIB
%11 = tail call i32 @ASN1error(i32 %10)
br label %19
12: ; preds = %2
%13 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %0, i64 0, i32 0
%14 = load i64, i64* %13
%15 = load i64, i64* @V_ASN1_NEG_ENUMERATED
%16 = icmp eq i64 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = tail call i32 @BN_set_negative(i32* %7, i32 1)
br label %19
19: ; preds = %12, %17, %9
ret i32* %7
}