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

/* Variables and functions */
int /*<<< orphan*/ ASN1_INTEGER_free(int /*<<< orphan*/ *);
int /*<<< orphan*/ *ASN1_INTEGER_new();
int /*<<< orphan*/ ASN1_INTEGER_set(int /*<<< orphan*/ *, unsigned long);
int /*<<< orphan*/ ERR_R_MALLOC_FAILURE;
int SXNET_add_id_INTEGER(int /*<<< orphan*/ **, int /*<<< orphan*/ *,
                         char const *, int);
int /*<<< orphan*/ X509V3error(int /*<<< orphan*/);
int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, const char *user,
                       int userlen) {
  ASN1_INTEGER *izone = NULL;
  if (!(izone = ASN1_INTEGER_new()) || !ASN1_INTEGER_set(izone, lzone)) {
    X509V3error(ERR_R_MALLOC_FAILURE);
    ASN1_INTEGER_free(izone);
    return 0;
  }
  return SXNET_add_id_INTEGER(psx, izone, user, userlen);
}


x86 assembly (clang, -O0):
<SXNET_add_id_ulong>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
movq   $0x0,-0x30(%rbp)
mov    $0x0,%al
call   1030 <ASN1_INTEGER_new@plt>
mov    %rax,-0x30(%rbp)
cmp    $0x0,%rax
je     119a <SXNET_add_id_ulong+0x4a>
mov    -0x30(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <ASN1_INTEGER_set@plt>
cmp    $0x0,%eax
jne    11bd <SXNET_add_id_ulong+0x6d>
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
call   1050 <X509V3error@plt>
mov    -0x30(%rbp),%rdi
call   1070 <ASN1_INTEGER_free@plt>
movl   $0x0,-0x4(%rbp)
jmp    11d4 <SXNET_add_id_ulong+0x84>
mov    -0x10(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x24(%rbp),%ecx
call   1040 <SXNET_add_id_INTEGER@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SXNET_add_id_ulong>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r12
xor    %eax,%eax
call   1030 <ASN1_INTEGER_new@plt>
mov    %rax,%rbp
test   %rax,%rax
je     119b <SXNET_add_id_ulong+0x4b>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1060 <ASN1_INTEGER_set@plt>
test   %eax,%eax
je     119b <SXNET_add_id_ulong+0x4b>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r15,%rdx
mov    %r14d,%ecx
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <SXNET_add_id_INTEGER@plt>
mov    0x2e46(%rip),%rax
mov    (%rax),%edi
call   1050 <X509V3error@plt>
mov    %rbp,%rdi
call   1070 <ASN1_INTEGER_free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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