#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_OCTET_STRING;
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 /*<<< orphan*/ *SXNET_get_id_INTEGER(int /*<<< orphan*/ *,
                                         int /*<<< orphan*/ *);
int /*<<< orphan*/ X509V3error(int /*<<< orphan*/);
ASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone) {
  ASN1_INTEGER *izone = NULL;
  ASN1_OCTET_STRING *oct;
  if (!(izone = ASN1_INTEGER_new()) || !ASN1_INTEGER_set(izone, lzone)) {
    X509V3error(ERR_R_MALLOC_FAILURE);
    ASN1_INTEGER_free(izone);
    return NULL;
  }
  oct = SXNET_get_id_INTEGER(sx, izone);
  ASN1_INTEGER_free(izone);
  return oct;
}


x86 assembly (clang, -O0):
<SXNET_get_id_ulong>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    $0x0,%al
call   1030 <ASN1_INTEGER_new@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     1193 <SXNET_get_id_ulong+0x43>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <ASN1_INTEGER_set@plt>
cmp    $0x0,%eax
jne    11b7 <SXNET_get_id_ulong+0x67>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
call   1040 <X509V3error@plt>
mov    -0x20(%rbp),%rdi
call   1070 <ASN1_INTEGER_free@plt>
movq   $0x0,-0x8(%rbp)
jmp    11d9 <SXNET_get_id_ulong+0x89>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <SXNET_get_id_INTEGER@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <ASN1_INTEGER_free@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SXNET_get_id_ulong>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r14
xor    %eax,%eax
call   1030 <ASN1_INTEGER_new@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1194 <SXNET_get_id_ulong+0x44>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <ASN1_INTEGER_set@plt>
test   %eax,%eax
je     1194 <SXNET_get_id_ulong+0x44>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <SXNET_get_id_INTEGER@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1070 <ASN1_INTEGER_free@plt>
mov    %r14,%rax
jmp    11ac <SXNET_get_id_ulong+0x5c>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
call   1040 <X509V3error@plt>
mov    %rbx,%rdi
call   1070 <ASN1_INTEGER_free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

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

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