#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 */

/* Type definitions */
typedef int /*<<< orphan*/ BIGNUM;
typedef int /*<<< orphan*/ ASN1_VALUE;
typedef int /*<<< orphan*/ ASN1_ITEM;

/* Variables and functions */
int /*<<< orphan*/ BN_bin2bn(unsigned char const *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ bn_free(int /*<<< orphan*/ **, int /*<<< orphan*/ const *);
scalar_t__ bn_new(int /*<<< orphan*/ **, int /*<<< orphan*/ const *);
int bn_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len, int utype,
           char *free_cont, const ASN1_ITEM *it) {
  BIGNUM *bn;
  if (*pval == NULL) {
    if (bn_new(pval, it) == 0)
      return 0;
  }
  bn = (BIGNUM *)*pval;
  if (!BN_bin2bn(cont, len, bn)) {
    bn_free(pval, it);
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<bn_c2i>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1184 <bn_c2i+0x54>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1050 <bn_new@plt>
cmp    $0x0,%rax
jne    117f <bn_c2i+0x4f>
movl   $0x0,-0x4(%rbp)
jmp    11c8 <bn_c2i+0x98>
jmp    1184 <bn_c2i+0x54>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x38(%rbp),%rdx
call   1040 <BN_bin2bn@plt>
cmp    $0x0,%eax
jne    11c1 <bn_c2i+0x91>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <bn_free@plt>
movl   $0x0,-0x4(%rbp)
jmp    11c8 <bn_c2i+0x98>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bn_c2i>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %r9,%r14
mov    %edx,%r15d
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    (%rdi),%rdx
test   %rdx,%rdx
jne    115e <bn_c2i+0x2e>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <bn_new@plt>
test   %rax,%rax
je     117f <bn_c2i+0x4f>
mov    (%rbx),%rdx
mov    %rbp,%rdi
mov    %r15d,%esi
call   1040 <BN_bin2bn@plt>
mov    %eax,%ecx
mov    $0x1,%eax
test   %ecx,%ecx
jne    1181 <bn_c2i+0x51>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <bn_free@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @bn_c2i(i32** %0, i8* %1, i32 %2, i32 %3, i8* %4, i32* %5) {
%7 = alloca i32
%8 = alloca i32**
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32*
%14 = alloca i32*
store i32** %0, i32*** %8
store i8* %1, i8** %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i8* %4, i8** %12
store i32* %5, i32** %13
%15 = load i32**, i32*** %8
%16 = load i32*, i32** %15
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %25
18: ; preds = %6
%19 = load i32**, i32*** %8
%20 = load i32*, i32** %13
%21 = call i64 @bn_new(i32** %19, i32* %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %18
store i32 0, i32* %7
br label %38
24: ; preds = %18
br label %25
25: ; preds = %24, %6
%26 = load i32**, i32*** %8
%27 = load i32*, i32** %26
store i32* %27, i32** %14
%28 = load i8*, i8** %9
%29 = load i32, i32* %10
%30 = load i32*, i32** %14
%31 = call i32 @BN_bin2bn(i8* %28, i32 %29, i32* %30)
%32 = icmp ne i32 %31, 0
br i1 %32, label %37, label %33
33: ; preds = %25
%34 = load i32**, i32*** %8
%35 = load i32*, i32** %13
%36 = call i32 @bn_free(i32** %34, i32* %35)
store i32 0, i32* %7
br label %38
37: ; preds = %25
store i32 1, i32* %7
br label %38
38: ; preds = %37, %33, %23
%39 = load i32, i32* %7
ret i32 %39
}

LLVM IR (-O2):
define i32 @bn_c2i(i32** %0, i8* %1, i32 %2, i32 %3, i8* nocapture readnone %4, i32* %5) {
%7 = load i32*, i32** %0
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %14
9: ; preds = %6
%10 = tail call i64 @bn_new(i32** %0, i32* %5)
%11 = icmp eq i64 %10, 0
br i1 %11, label %20, label %12
12: ; preds = %9
%13 = load i32*, i32** %0
br label %14
14: ; preds = %12, %6
%15 = phi i32* [ %13, %12 ], [ %7, %6 ]
%16 = tail call i32 @BN_bin2bn(i8* %1, i32 %2, i32* %15)
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %14
%19 = tail call i32 @bn_free(i32** %0, i32* %5)
br label %20
20: ; preds = %14, %9, %18
%21 = phi i32 [ 0, %18 ], [ 0, %9 ], [ 1, %14 ]
ret i32 %21
}