#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*/ X509V3_F_SXNET_GET_ID_ULONG;
int /*<<< orphan*/ X509V3err(int /*<<< orphan*/, 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)) {
    X509V3err(X509V3_F_SXNET_GET_ID_ULONG, 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   1040 <ASN1_INTEGER_set@plt>
cmp    $0x0,%eax
jne    11c0 <SXNET_get_id_ulong+0x70>
mov    0x2e4e(%rip),%rax
mov    (%rax),%edi
mov    0x2e3d(%rip),%rax
mov    (%rax),%esi
call   1070 <X509V3err@plt>
mov    -0x20(%rbp),%rdi
call   1060 <ASN1_INTEGER_free@plt>
movq   $0x0,-0x8(%rbp)
jmp    11e2 <SXNET_get_id_ulong+0x92>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1050 <SXNET_get_id_INTEGER@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <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   1040 <ASN1_INTEGER_set@plt>
test   %eax,%eax
je     1194 <SXNET_get_id_ulong+0x44>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <SXNET_get_id_INTEGER@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1060 <ASN1_INTEGER_free@plt>
mov    %r14,%rax
jmp    11b5 <SXNET_get_id_ulong+0x65>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
mov    0x2e3c(%rip),%rax
mov    (%rax),%esi
call   1070 <X509V3err@plt>
mov    %rbx,%rdi
call   1060 <ASN1_INTEGER_free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@X509V3_F_SXNET_GET_ID_ULONG = global i32 0
@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 %21, label %15
15: ; preds = %10, %2
%16 = load i32, i32* @X509V3_F_SXNET_GET_ID_ULONG
%17 = load i32, i32* @ERR_R_MALLOC_FAILURE
%18 = call i32 @X509V3err(i32 %16, i32 %17)
%19 = load i32*, i32** %6
%20 = call i32 @ASN1_INTEGER_free(i32* %19)
store i32* null, i32** %3
br label %28
21: ; preds = %10
%22 = load i32*, i32** %4
%23 = load i32*, i32** %6
%24 = call i32* @SXNET_get_id_INTEGER(i32* %22, i32* %23)
store i32* %24, i32** %7
%25 = load i32*, i32** %6
%26 = call i32 @ASN1_INTEGER_free(i32* %25)
%27 = load i32*, i32** %7
store i32* %27, i32** %3
br label %28
28: ; preds = %21, %15
%29 = load i32*, i32** %3
ret i32* %29
}

LLVM IR (-O2):
@X509V3_F_SXNET_GET_ID_ULONG = global i32 0
@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 %13
8: ; preds = %5, %2
%9 = load i32, i32* @X509V3_F_SXNET_GET_ID_ULONG
%10 = load i32, i32* @ERR_R_MALLOC_FAILURE
%11 = tail call i32 @X509V3err(i32 %9, i32 %10)
%12 = tail call i32 @ASN1_INTEGER_free(i32* %3)
br label %16
13: ; preds = %5
%14 = tail call i32* @SXNET_get_id_INTEGER(i32* %0, i32* %3)
%15 = tail call i32 @ASN1_INTEGER_free(i32* %3)
br label %16
16: ; preds = %13, %8
%17 = phi i32* [ %14, %13 ], [ null, %8 ]
ret i32* %17
}