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

/* Variables and functions */
scalar_t__ ASN1_INTEGER_cmp(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ extract_min_max(int /*<<< orphan*/, int /*<<< orphan*/ **,
                                   int /*<<< orphan*/ **);
int sk_ASIdOrRange_num(int /*<<< orphan*/ *);
int /*<<< orphan*/ sk_ASIdOrRange_value(int /*<<< orphan*/ *, int);
int asid_contains(ASIdOrRanges *parent, ASIdOrRanges *child) {
  ASN1_INTEGER *p_min, *p_max, *c_min, *c_max;
  int p, c;
  if (child == NULL || parent == child)
    return 1;
  if (parent == NULL)
    return 0;
  p = 0;
  for (c = 0; c < sk_ASIdOrRange_num(child); c++) {
    extract_min_max(sk_ASIdOrRange_value(child, c), &c_min, &c_max);
    for (;; p++) {
      if (p >= sk_ASIdOrRange_num(parent))
        return 0;
      extract_min_max(sk_ASIdOrRange_value(parent, p), &p_min, &p_max);
      if (ASN1_INTEGER_cmp(p_max, c_max) < 0)
        continue;
      if (ASN1_INTEGER_cmp(p_min, c_min) > 0)
        return 0;
      break;
    }
  }
  return 1;
}


x86 assembly (clang, -O0):
<asid_contains>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1169 <asid_contains+0x29>
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    1175 <asid_contains+0x35>
movl   $0x1,-0x4(%rbp)
jmp    1280 <asid_contains+0x140>
cmpq   $0x0,-0x10(%rbp)
jne    118c <asid_contains+0x4c>
movl   $0x0,-0x4(%rbp)
jmp    1280 <asid_contains+0x140>
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x40(%rbp)
mov    -0x40(%rbp),%eax
mov    %eax,-0x44(%rbp)
mov    -0x18(%rbp),%rdi
call   1060 <sk_ASIdOrRange_num@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
cmp    %ecx,%eax
jge    1279 <asid_contains+0x139>
mov    -0x18(%rbp),%rdi
mov    -0x40(%rbp),%esi
call   1030 <sk_ASIdOrRange_value@plt>
mov    %eax,%edi
lea    -0x30(%rbp),%rsi
lea    -0x38(%rbp),%rdx
call   1040 <extract_min_max@plt>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <sk_ASIdOrRange_num@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%eax
cmp    %ecx,%eax
jl     11f9 <asid_contains+0xb9>
movl   $0x0,-0x4(%rbp)
jmp    1280 <asid_contains+0x140>
mov    -0x10(%rbp),%rdi
mov    -0x3c(%rbp),%esi
call   1030 <sk_ASIdOrRange_value@plt>
mov    %eax,%edi
lea    -0x20(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1040 <extract_min_max@plt>
mov    -0x28(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1050 <ASN1_INTEGER_cmp@plt>
cmp    $0x0,%rax
jge    1230 <asid_contains+0xf0>
jmp    1258 <asid_contains+0x118>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1050 <ASN1_INTEGER_cmp@plt>
cmp    $0x0,%rax
jle    1253 <asid_contains+0x113>
movl   $0x0,-0x4(%rbp)
jmp    1280 <asid_contains+0x140>
jmp    1266 <asid_contains+0x126>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    11d1 <asid_contains+0x91>
jmp    126b <asid_contains+0x12b>
mov    -0x40(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x40(%rbp)
jmp    119a <asid_contains+0x5a>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<asid_contains>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    $0x1,%ebx
test   %rsi,%rsi
je     124a <asid_contains+0x10a>
mov    %rsi,%r12
mov    %rdi,%rbp
cmp    %rsi,%rdi
je     124a <asid_contains+0x10a>
test   %rbp,%rbp
je     1248 <asid_contains+0x108>
mov    %r12,%rdi
call   1060 <sk_ASIdOrRange_num@plt>
test   %eax,%eax
jle    124a <asid_contains+0x10a>
lea    0x8(%rsp),%rbx
lea    0x10(%rsp),%r13
lea    0x18(%rsp),%r15
xor    %esi,%esi
xor    %r14d,%r14d
mov    %r12,%rdi
mov    %esi,0x4(%rsp)
call   1030 <sk_ASIdOrRange_value@plt>
mov    %eax,%edi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1040 <extract_min_max@plt>
mov    %rbp,%rdi
call   1060 <sk_ASIdOrRange_num@plt>
cmp    %eax,%r14d
jge    1248 <asid_contains+0x108>
lea    0x20(%rsp),%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
mov    %r14d,%esi
call   1030 <sk_ASIdOrRange_value@plt>
mov    %eax,%edi
mov    %rbx,%rsi
mov    %r15,%rdx
call   1040 <extract_min_max@plt>
mov    0x18(%rsp),%rdi
mov    0x10(%rsp),%rsi
call   1050 <ASN1_INTEGER_cmp@plt>
test   %rax,%rax
jns    120f <asid_contains+0xcf>
add    $0x1,%r14d
mov    %rbp,%rdi
call   1060 <sk_ASIdOrRange_num@plt>
cmp    %eax,%r14d
jl     11d0 <asid_contains+0x90>
jmp    1248 <asid_contains+0x108>
mov    0x20(%rsp),%rdi
mov    0x8(%rsp),%rsi
call   1050 <ASN1_INTEGER_cmp@plt>
test   %rax,%rax
jg     1248 <asid_contains+0x108>
mov    0x4(%rsp),%ebx
add    $0x1,%ebx
mov    %r12,%rdi
call   1060 <sk_ASIdOrRange_num@plt>
mov    %ebx,%esi
cmp    %eax,%ebx
lea    0x8(%rsp),%rbx
jl     1198 <asid_contains+0x58>
mov    $0x1,%ebx
jmp    124a <asid_contains+0x10a>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @asid_contains(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
%12 = load i32*, i32** %5
%13 = icmp eq i32* %12, null
br i1 %13, label %18, label %14
14: ; preds = %2
%15 = load i32*, i32** %4
%16 = load i32*, i32** %5
%17 = icmp eq i32* %15, %16
br i1 %17, label %18, label %19
18: ; preds = %14, %2
store i32 1, i32* %3
br label %65
19: ; preds = %14
%20 = load i32*, i32** %4
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %23
22: ; preds = %19
store i32 0, i32* %3
br label %65
23: ; preds = %19
store i32 0, i32* %10
store i32 0, i32* %11
br label %24
24: ; preds = %61, %23
%25 = load i32, i32* %11
%26 = load i32*, i32** %5
%27 = call i32 @sk_ASIdOrRange_num(i32* %26)
%28 = icmp slt i32 %25, %27
br i1 %28, label %29, label %64
29: ; preds = %24
%30 = load i32*, i32** %5
%31 = load i32, i32* %11
%32 = call i32 @sk_ASIdOrRange_value(i32* %30, i32 %31)
%33 = call i32 @extract_min_max(i32 %32, i32** %8, i32** %9)
br label %34
34: ; preds = %57, %29
%35 = load i32, i32* %10
%36 = load i32*, i32** %4
%37 = call i32 @sk_ASIdOrRange_num(i32* %36)
%38 = icmp sge i32 %35, %37
br i1 %38, label %39, label %40
39: ; preds = %34
store i32 0, i32* %3
br label %65
40: ; preds = %34
%41 = load i32*, i32** %4
%42 = load i32, i32* %10
%43 = call i32 @sk_ASIdOrRange_value(i32* %41, i32 %42)
%44 = call i32 @extract_min_max(i32 %43, i32** %6, i32** %7)
%45 = load i32*, i32** %7
%46 = load i32*, i32** %9
%47 = call i64 @ASN1_INTEGER_cmp(i32* %45, i32* %46)
%48 = icmp slt i64 %47, 0
br i1 %48, label %49, label %50
49: ; preds = %40
br label %57
50: ; preds = %40
%51 = load i32*, i32** %6
%52 = load i32*, i32** %8
%53 = call i64 @ASN1_INTEGER_cmp(i32* %51, i32* %52)
%54 = icmp sgt i64 %53, 0
br i1 %54, label %55, label %56
55: ; preds = %50
store i32 0, i32* %3
br label %65
56: ; preds = %50
br label %60
57: ; preds = %49
%58 = load i32, i32* %10
%59 = add nsw i32 %58, 1
store i32 %59, i32* %10
br label %34
60: ; preds = %56
br label %61
61: ; preds = %60
%62 = load i32, i32* %11
%63 = add nsw i32 %62, 1
store i32 %63, i32* %11
br label %24
64: ; preds = %24
store i32 1, i32* %3
br label %65
65: ; preds = %64, %55, %39, %22, %18
%66 = load i32, i32* %3
ret i32 %66
}

LLVM IR (-O2):
define i32 @asid_contains(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = bitcast i32** %3 to i8*
%8 = bitcast i32** %4 to i8*
%9 = bitcast i32** %5 to i8*
%10 = bitcast i32** %6 to i8*
%11 = icmp eq i32* %1, null
%12 = icmp eq i32* %0, %1
%13 = or i1 %11, %12
br i1 %13, label %47, label %14
14: ; preds = %2
%15 = icmp eq i32* %0, null
br i1 %15, label %47, label %16
16: ; preds = %14
%17 = call i32 @sk_ASIdOrRange_num(i32* %1)
%18 = icmp sgt i32 %17, 0
br i1 %18, label %22, label %47
19: ; preds = %37
%20 = call i32 @sk_ASIdOrRange_num(i32* %1)
%21 = icmp slt i32 %42, %20
br i1 %21, label %22, label %47
22: ; preds = %16, %19
%23 = phi i32 [ %42, %19 ], [ 0, %16 ]
%24 = phi i32 [ %30, %19 ], [ 0, %16 ]
%25 = call i32 @sk_ASIdOrRange_value(i32* %1, i32 %23)
%26 = call i32 @extract_min_max(i32 %25, i32** %5, i32** %6)
%27 = call i32 @sk_ASIdOrRange_num(i32* %0)
%28 = icmp slt i32 %24, %27
br i1 %28, label %29, label %47
29: ; preds = %22, %43
%30 = phi i32 [ %44, %43 ], [ %24, %22 ]
%31 = call i32 @sk_ASIdOrRange_value(i32* %0, i32 %30)
%32 = call i32 @extract_min_max(i32 %31, i32** %3, i32** %4)
%33 = load i32*, i32** %4
%34 = load i32*, i32** %6
%35 = call i64 @ASN1_INTEGER_cmp(i32* %33, i32* %34)
%36 = icmp slt i64 %35, 0
br i1 %36, label %43, label %37
37: ; preds = %29
%38 = load i32*, i32** %3
%39 = load i32*, i32** %5
%40 = call i64 @ASN1_INTEGER_cmp(i32* %38, i32* %39)
%41 = icmp sgt i64 %40, 0
%42 = add nuw nsw i32 %23, 1
br i1 %41, label %47, label %19
43: ; preds = %29
%44 = add nsw i32 %30, 1
%45 = call i32 @sk_ASIdOrRange_num(i32* %0)
%46 = icmp slt i32 %44, %45
br i1 %46, label %29, label %47
47: ; preds = %37, %19, %22, %43, %16, %14, %2
%48 = phi i32 [ 1, %2 ], [ 0, %14 ], [ 1, %16 ], [ 0, %43 ], [ 0, %22 ], [ 0, %37 ], [ 1, %19 ]
ret i32 %48
}