#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*/ X509V3_EXT_METHOD;
typedef int /*<<< orphan*/ BIGNUM;
typedef int /*<<< orphan*/ ASN1_INTEGER;

/* Variables and functions */
int /*<<< orphan*/ *ASN1_INTEGER_to_BN(int /*<<< orphan*/ const *,
                                       int /*<<< orphan*/ *);
char *BN_bn2dec(int /*<<< orphan*/ *);
int /*<<< orphan*/ BN_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ ERR_R_MALLOC_FAILURE;
int /*<<< orphan*/ X509V3error(int /*<<< orphan*/);
char *i2s_ASN1_INTEGER(X509V3_EXT_METHOD *method, const ASN1_INTEGER *a) {
  BIGNUM *bntmp = NULL;
  char *strtmp = NULL;
  if (!a)
    return NULL;
  if (!(bntmp = ASN1_INTEGER_to_BN(a, NULL)) || !(strtmp = BN_bn2dec(bntmp)))
    X509V3error(ERR_R_MALLOC_FAILURE);
  BN_free(bntmp);
  return strtmp;
}


x86 assembly (clang, -O0):
<i2s_ASN1_INTEGER>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1178 <i2s_ASN1_INTEGER+0x38>
movq   $0x0,-0x8(%rbp)
jmp    11c9 <i2s_ASN1_INTEGER+0x89>
mov    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <ASN1_INTEGER_to_BN@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     11aa <i2s_ASN1_INTEGER+0x6a>
mov    -0x20(%rbp),%rdi
call   1030 <BN_bn2dec@plt>
mov    %rax,-0x28(%rbp)
cmp    $0x0,%rax
jne    11b8 <i2s_ASN1_INTEGER+0x78>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
call   1040 <X509V3error@plt>
mov    -0x20(%rbp),%rdi
call   1060 <BN_free@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<i2s_ASN1_INTEGER>:
push   %r14
push   %rbx
push   %rax
test   %rsi,%rsi
je     1185 <i2s_ASN1_INTEGER+0x45>
mov    %rsi,%rdi
xor    %esi,%esi
call   1050 <ASN1_INTEGER_to_BN@plt>
mov    %rax,%r14
test   %rax,%rax
je     116b <i2s_ASN1_INTEGER+0x2b>
mov    %r14,%rdi
call   1030 <BN_bn2dec@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    117b <i2s_ASN1_INTEGER+0x3b>
mov    0x2e76(%rip),%rax
mov    (%rax),%edi
call   1040 <X509V3error@plt>
xor    %ebx,%ebx
mov    %r14,%rdi
call   1060 <BN_free@plt>
jmp    1187 <i2s_ASN1_INTEGER+0x47>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@ERR_R_MALLOC_FAILURE = global i32 0
define i8* @i2s_ASN1_INTEGER(i32* %0, i32* %1) {
%3 = alloca i8*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i8*
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32* null, i32** %6
store i8* null, i8** %7
%8 = load i32*, i32** %5
%9 = icmp ne i32* %8, null
br i1 %9, label %11, label %10
10: ; preds = %2
store i8* null, i8** %3
br label %26
11: ; preds = %2
%12 = load i32*, i32** %5
%13 = call i32* @ASN1_INTEGER_to_BN(i32* %12, i32* null)
store i32* %13, i32** %6
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %19
15: ; preds = %11
%16 = load i32*, i32** %6
%17 = call i8* @BN_bn2dec(i32* %16)
store i8* %17, i8** %7
%18 = icmp ne i8* %17, null
br i1 %18, label %22, label %19
19: ; preds = %15, %11
%20 = load i32, i32* @ERR_R_MALLOC_FAILURE
%21 = call i32 @X509V3error(i32 %20)
br label %22
22: ; preds = %19, %15
%23 = load i32*, i32** %6
%24 = call i32 @BN_free(i32* %23)
%25 = load i8*, i8** %7
store i8* %25, i8** %3
br label %26
26: ; preds = %22, %10
%27 = load i8*, i8** %3
ret i8* %27
}

LLVM IR (-O2):
@ERR_R_MALLOC_FAILURE = global i32 0
define i8* @i2s_ASN1_INTEGER(i32* nocapture readnone %0, i32* %1) {
%3 = icmp eq i32* %1, null
br i1 %3, label %16, label %4
4: ; preds = %2
%5 = tail call i32* @ASN1_INTEGER_to_BN(i32* %1, i32* null)
%6 = icmp eq i32* %5, null
br i1 %6, label %10, label %7
7: ; preds = %4
%8 = tail call i8* @BN_bn2dec(i32* %5)
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %13
10: ; preds = %7, %4
%11 = load i32, i32* @ERR_R_MALLOC_FAILURE
%12 = tail call i32 @X509V3error(i32 %11)
br label %13
13: ; preds = %10, %7
%14 = phi i8* [ %8, %7 ], [ null, %10 ]
%15 = tail call i32 @BN_free(i32* %5)
br label %16
16: ; preds = %2, %13
%17 = phi i8* [ %14, %13 ], [ null, %2 ]
ret i8* %17
}