#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 */
typedef struct TYPE_6__ TYPE_2__;
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
struct TYPE_6__ {
  int /*<<< orphan*/ ids;
};
struct TYPE_5__ {
  int /*<<< orphan*/ *user;
  int /*<<< orphan*/ zone;
};
typedef TYPE_1__ SXNETID;
typedef TYPE_2__ SXNET;
typedef int /*<<< orphan*/ ASN1_OCTET_STRING;
typedef int /*<<< orphan*/ ASN1_INTEGER;

/* Variables and functions */
int /*<<< orphan*/ ASN1_INTEGER_cmp(int /*<<< orphan*/, int /*<<< orphan*/ *);
int sk_SXNETID_num(int /*<<< orphan*/);
TYPE_1__ *sk_SXNETID_value(int /*<<< orphan*/, int);
ASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone) {
  SXNETID *id;
  int i;
  for (i = 0; i < sk_SXNETID_num(sx->ids); i++) {
    id = sk_SXNETID_value(sx->ids, i);
    if (!ASN1_INTEGER_cmp(id->zone, zone))
      return id->user;
  }
  return NULL;
}


x86 assembly (clang, -O0):
<SXNET_get_id_INTEGER>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1030 <sk_SXNETID_num@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cmp    %ecx,%eax
jge    11b3 <SXNET_get_id_INTEGER+0x83>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    -0x24(%rbp),%esi
call   1040 <sk_SXNETID_value@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0x18(%rbp),%rsi
call   1050 <ASN1_INTEGER_cmp@plt>
cmp    $0x0,%eax
jne    11a0 <SXNET_get_id_INTEGER+0x70>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    11bb <SXNET_get_id_INTEGER+0x8b>
jmp    11a5 <SXNET_get_id_INTEGER+0x75>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1147 <SXNET_get_id_INTEGER+0x17>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SXNET_get_id_INTEGER>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%r15
mov    %rdi,%r12
mov    (%rdi),%edi
call   1030 <sk_SXNETID_num@plt>
xor    %r14d,%r14d
test   %eax,%eax
jle    1182 <SXNET_get_id_INTEGER+0x52>
xor    %ebp,%ebp
xchg   %ax,%ax
mov    (%r12),%edi
mov    %ebp,%esi
call   1040 <sk_SXNETID_value@plt>
mov    %rax,%rbx
mov    0x8(%rax),%edi
mov    %r15,%rsi
call   1050 <ASN1_INTEGER_cmp@plt>
test   %eax,%eax
je     117f <SXNET_get_id_INTEGER+0x4f>
add    $0x1,%ebp
mov    (%r12),%edi
call   1030 <sk_SXNETID_num@plt>
cmp    %eax,%ebp
jl     1150 <SXNET_get_id_INTEGER+0x20>
jmp    1182 <SXNET_get_id_INTEGER+0x52>
mov    (%rbx),%r14
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_6__ = type { i32 }
%struct.TYPE_5__ = type { i32*, i32 }
define i32* @SXNET_get_id_INTEGER(%struct.TYPE_6__* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca %struct.TYPE_6__*
%5 = alloca i32*
%6 = alloca %struct.TYPE_5__*
%7 = alloca i32
store %struct.TYPE_6__* %0, %struct.TYPE_6__** %4
store i32* %1, i32** %5
store i32 0, i32* %7
br label %8
8: ; preds = %32, %2
%9 = load i32, i32* %7
%10 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%11 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %10, i32 0, i32 0
%12 = load i32, i32* %11
%13 = call i32 @sk_SXNETID_num(i32 %12)
%14 = icmp slt i32 %9, %13
br i1 %14, label %15, label %35
15: ; preds = %8
%16 = load %struct.TYPE_6__*, %struct.TYPE_6__** %4
%17 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %16, i32 0, i32 0
%18 = load i32, i32* %17
%19 = load i32, i32* %7
%20 = call %struct.TYPE_5__* @sk_SXNETID_value(i32 %18, i32 %19)
store %struct.TYPE_5__* %20, %struct.TYPE_5__** %6
%21 = load %struct.TYPE_5__*, %struct.TYPE_5__** %6
%22 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %21, i32 0, i32 1
%23 = load i32, i32* %22
%24 = load i32*, i32** %5
%25 = call i32 @ASN1_INTEGER_cmp(i32 %23, i32* %24)
%26 = icmp ne i32 %25, 0
br i1 %26, label %31, label %27
27: ; preds = %15
%28 = load %struct.TYPE_5__*, %struct.TYPE_5__** %6
%29 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %28, i32 0, i32 0
%30 = load i32*, i32** %29
store i32* %30, i32** %3
br label %36
31: ; preds = %15
br label %32
32: ; preds = %31
%33 = load i32, i32* %7
%34 = add nsw i32 %33, 1
store i32 %34, i32* %7
br label %8
35: ; preds = %8
store i32* null, i32** %3
br label %36
36: ; preds = %35, %27
%37 = load i32*, i32** %3
ret i32* %37
}

LLVM IR (-O2):
%struct.TYPE_6__ = type { i32 }
%struct.TYPE_5__ = type { i32*, i32 }
define i32* @SXNET_get_id_INTEGER(%struct.TYPE_6__* nocapture %0, i32* %1) {
%3 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %0, i64 0, i32 0
%4 = load i32, i32* %3
%5 = tail call i32 @sk_SXNETID_num(i32 %4)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %11, label %23
7: ; preds = %11
%8 = load i32, i32* %3
%9 = tail call i32 @sk_SXNETID_num(i32 %8)
%10 = icmp slt i32 %19, %9
br i1 %10, label %11, label %23
11: ; preds = %2, %7
%12 = phi i32 [ %19, %7 ], [ 0, %2 ]
%13 = load i32, i32* %3
%14 = tail call %struct.TYPE_5__* @sk_SXNETID_value(i32 %13, i32 %12)
%15 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i64 0, i32 1
%16 = load i32, i32* %15
%17 = tail call i32 @ASN1_INTEGER_cmp(i32 %16, i32* %1)
%18 = icmp eq i32 %17, 0
%19 = add nuw nsw i32 %12, 1
br i1 %18, label %20, label %7
20: ; preds = %11
%21 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %14, i64 0, i32 0
%22 = load i32*, i32** %21
br label %23
23: ; preds = %7, %2, %20
%24 = phi i32* [ %22, %20 ], [ null, %2 ], [ null, %7 ]
ret i32* %24
}