#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*/ X509_CRL;
typedef int /*<<< orphan*/ ASN1_OCTET_STRING;

/* Variables and functions */
scalar_t__ ASN1_OCTET_STRING_cmp(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ X509_CRL_get_ext(int /*<<< orphan*/ *, int);
int X509_CRL_get_ext_by_NID(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ *X509_EXTENSION_get_data(int /*<<< orphan*/);
int crl_extension_match(X509_CRL *a, X509_CRL *b, int nid) {
  ASN1_OCTET_STRING *exta, *extb;
  int i;
  i = X509_CRL_get_ext_by_NID(a, nid, -1);
  if (i >= 0) {
    if (X509_CRL_get_ext_by_NID(a, nid, i) != -1)
      return 0;
    exta = X509_EXTENSION_get_data(X509_CRL_get_ext(a, i));
  } else
    exta = NULL;
  i = X509_CRL_get_ext_by_NID(b, nid, -1);
  if (i >= 0) {
    if (X509_CRL_get_ext_by_NID(b, nid, i) != -1)
      return 0;
    extb = X509_EXTENSION_get_data(X509_CRL_get_ext(b, i));
  } else
    extb = NULL;
  if (!exta && !extb)
    return 1;
  if (!exta || !extb)
    return 0;
  if (ASN1_OCTET_STRING_cmp(exta, extb))
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<crl_extension_match>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    $0xffffffff,%edx
call   1040 <X509_CRL_get_ext_by_NID@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jl     11b1 <crl_extension_match+0x71>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x34(%rbp),%edx
call   1040 <X509_CRL_get_ext_by_NID@plt>
cmp    $0xffffffff,%eax
je     1195 <crl_extension_match+0x55>
movl   $0x0,-0x4(%rbp)
jmp    128d <crl_extension_match+0x14d>
mov    -0x10(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1060 <X509_CRL_get_ext@plt>
mov    %eax,%edi
call   1050 <X509_EXTENSION_get_data@plt>
mov    %rax,-0x28(%rbp)
jmp    11b9 <crl_extension_match+0x79>
movq   $0x0,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    $0xffffffff,%edx
call   1040 <X509_CRL_get_ext_by_NID@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x0,-0x34(%rbp)
jl     1217 <crl_extension_match+0xd7>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
mov    -0x34(%rbp),%edx
call   1040 <X509_CRL_get_ext_by_NID@plt>
cmp    $0xffffffff,%eax
je     11fb <crl_extension_match+0xbb>
movl   $0x0,-0x4(%rbp)
jmp    128d <crl_extension_match+0x14d>
mov    -0x18(%rbp),%rdi
mov    -0x34(%rbp),%esi
call   1060 <X509_CRL_get_ext@plt>
mov    %eax,%edi
call   1050 <X509_EXTENSION_get_data@plt>
mov    %rax,-0x30(%rbp)
jmp    121f <crl_extension_match+0xdf>
movq   $0x0,-0x30(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1241 <crl_extension_match+0x101>
cmpq   $0x0,-0x30(%rbp)
jne    1241 <crl_extension_match+0x101>
movl   $0x1,-0x4(%rbp)
jmp    128d <crl_extension_match+0x14d>
cmpq   $0x0,-0x28(%rbp)
je     1257 <crl_extension_match+0x117>
cmpq   $0x0,-0x30(%rbp)
jne    1263 <crl_extension_match+0x123>
movl   $0x0,-0x4(%rbp)
jmp    128d <crl_extension_match+0x14d>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <ASN1_OCTET_STRING_cmp@plt>
cmp    $0x0,%rax
je     1286 <crl_extension_match+0x146>
movl   $0x0,-0x4(%rbp)
jmp    128d <crl_extension_match+0x14d>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crl_extension_match>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%r12d
mov    %rsi,%r15
mov    %rdi,%rbp
mov    %edx,%esi
mov    $0xffffffff,%edx
call   1040 <X509_CRL_get_ext_by_NID@plt>
xor    %r13d,%r13d
test   %eax,%eax
js     1195 <crl_extension_match+0x55>
mov    %eax,%ebx
mov    %rbp,%rdi
mov    %r12d,%esi
mov    %eax,%edx
call   1040 <X509_CRL_get_ext_by_NID@plt>
cmp    $0xffffffff,%eax
jne    1208 <crl_extension_match+0xc8>
mov    %rbp,%rdi
mov    %ebx,%esi
call   1060 <X509_CRL_get_ext@plt>
mov    %eax,%edi
call   1050 <X509_EXTENSION_get_data@plt>
mov    %rax,%r14
jmp    1198 <crl_extension_match+0x58>
xor    %r14d,%r14d
mov    %r15,%rdi
mov    %r12d,%esi
mov    $0xffffffff,%edx
call   1040 <X509_CRL_get_ext_by_NID@plt>
xor    %r13d,%r13d
test   %eax,%eax
js     11d6 <crl_extension_match+0x96>
mov    %eax,%ebx
mov    %r15,%rdi
mov    %r12d,%esi
mov    %eax,%edx
call   1040 <X509_CRL_get_ext_by_NID@plt>
cmp    $0xffffffff,%eax
jne    1208 <crl_extension_match+0xc8>
mov    %r15,%rdi
mov    %ebx,%esi
call   1060 <X509_CRL_get_ext@plt>
mov    %eax,%edi
call   1050 <X509_EXTENSION_get_data@plt>
jmp    11d8 <crl_extension_match+0x98>
xor    %eax,%eax
mov    $0x1,%r13d
mov    %r14,%rcx
or     %rax,%rcx
je     1208 <crl_extension_match+0xc8>
xor    %r13d,%r13d
test   %r14,%r14
je     1208 <crl_extension_match+0xc8>
test   %rax,%rax
je     1208 <crl_extension_match+0xc8>
mov    %r14,%rdi
mov    %rax,%rsi
call   1030 <ASN1_OCTET_STRING_cmp@plt>
xor    %r13d,%r13d
test   %rax,%rax
sete   %r13b
mov    %r13d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @crl_extension_match(i32* %0, i32* %1, i32 %2) {
%4 = tail call i32 @X509_CRL_get_ext_by_NID(i32* %0, i32 %2, i32 -1)
%5 = icmp sgt i32 %4, -1
br i1 %5, label %6, label %12
6: ; preds = %3
%7 = tail call i32 @X509_CRL_get_ext_by_NID(i32* %0, i32 %2, i32 %4)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %33
9: ; preds = %6
%10 = tail call i32 @X509_CRL_get_ext(i32* %0, i32 %4)
%11 = tail call i32* @X509_EXTENSION_get_data(i32 %10)
br label %12
12: ; preds = %3, %9
%13 = phi i32* [ %11, %9 ], [ null, %3 ]
%14 = tail call i32 @X509_CRL_get_ext_by_NID(i32* %1, i32 %2, i32 -1)
%15 = icmp sgt i32 %14, -1
br i1 %15, label %16, label %22
16: ; preds = %12
%17 = tail call i32 @X509_CRL_get_ext_by_NID(i32* %1, i32 %2, i32 %14)
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %33
19: ; preds = %16
%20 = tail call i32 @X509_CRL_get_ext(i32* %1, i32 %14)
%21 = tail call i32* @X509_EXTENSION_get_data(i32 %20)
br label %22
22: ; preds = %12, %19
%23 = phi i32* [ %21, %19 ], [ null, %12 ]
%24 = icmp ne i32* %13, null
%25 = icmp ne i32* %23, null
%26 = select i1 %24, i1 true, i1 %25
br i1 %26, label %27, label %33
27: ; preds = %22
%28 = select i1 %24, i1 %25, i1 false
br i1 %28, label %29, label %33
29: ; preds = %27
%30 = tail call i64 @ASN1_OCTET_STRING_cmp(i32* %13, i32* %23)
%31 = icmp eq i64 %30, 0
%32 = zext i1 %31 to i32
br label %33
33: ; preds = %29, %27, %22, %16, %6
%34 = phi i32 [ 0, %6 ], [ 0, %16 ], [ 1, %22 ], [ 0, %27 ], [ %32, %29 ]
ret i32 %34
}