#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_8__ TYPE_3__;
typedef struct TYPE_7__ TYPE_2__;
typedef struct TYPE_6__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ X509_NAME;
typedef int /*<<< orphan*/ X509_CRL;
struct TYPE_8__ {
  int /*<<< orphan*/ CRLissuer;
};
struct TYPE_6__ {
  int /*<<< orphan*/ directoryName;
};
struct TYPE_7__ {
  scalar_t__ type;
  TYPE_1__ d;
};
typedef TYPE_2__ GENERAL_NAME;
typedef TYPE_3__ DIST_POINT;

/* Variables and functions */
scalar_t__ GEN_DIRNAME;
int /*<<< orphan*/ *X509_CRL_get_issuer(int /*<<< orphan*/ *);
int /*<<< orphan*/ X509_NAME_cmp(int /*<<< orphan*/, int /*<<< orphan*/ *);
int sk_GENERAL_NAME_num(int /*<<< orphan*/);
TYPE_2__ *sk_GENERAL_NAME_value(int /*<<< orphan*/, int);
int crldp_check_crlissuer(DIST_POINT *dp, X509_CRL *crl, int crl_score) {
  int i;
  X509_NAME *nm = X509_CRL_get_issuer(crl);
  if (!dp->CRLissuer)
    return !!(crl_score & 0x020);
  for (i = 0; i < sk_GENERAL_NAME_num(dp->CRLissuer); i++) {
    GENERAL_NAME *gen = sk_GENERAL_NAME_value(dp->CRLissuer, i);
    if (gen->type != GEN_DIRNAME)
      continue;
    if (!X509_NAME_cmp(gen->d.directoryName, nm))
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<crldp_check_crlissuer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <X509_CRL_get_issuer@plt>
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jne    118a <crldp_check_crlissuer+0x4a>
mov    -0x1c(%rbp),%eax
and    $0x20,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    121c <crldp_check_crlissuer+0xdc>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1030 <sk_GENERAL_NAME_num@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
cmp    %ecx,%eax
jge    1215 <crldp_check_crlissuer+0xd5>
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%esi
call   1050 <sk_GENERAL_NAME_value@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
mov    (%rax),%rax
mov    0x2e19(%rip),%rcx
cmp    (%rcx),%rax
je     11dd <crldp_check_crlissuer+0x9d>
jmp    1207 <crldp_check_crlissuer+0xc7>
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%edi
mov    -0x28(%rbp),%rsi
call   1060 <X509_NAME_cmp@plt>
cmp    $0x0,%eax
jne    1202 <crldp_check_crlissuer+0xc2>
movl   $0x1,-0x4(%rbp)
jmp    121c <crldp_check_crlissuer+0xdc>
jmp    1207 <crldp_check_crlissuer+0xc7>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1191 <crldp_check_crlissuer+0x51>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crldp_check_crlissuer>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1040 <X509_CRL_get_issuer@plt>
mov    (%rbx),%edi
test   %edi,%edi
je     11b9 <crldp_check_crlissuer+0x79>
mov    %rax,%r14
call   1030 <sk_GENERAL_NAME_num@plt>
test   %eax,%eax
jle    11b5 <crldp_check_crlissuer+0x75>
xor    %ebp,%ebp
mov    0x2e79(%rip),%r15
jmp    118e <crldp_check_crlissuer+0x4e>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    (%rbx),%edi
call   1030 <sk_GENERAL_NAME_num@plt>
cmp    %eax,%ebp
jge    11b5 <crldp_check_crlissuer+0x75>
mov    (%rbx),%edi
mov    %ebp,%esi
call   1050 <sk_GENERAL_NAME_value@plt>
mov    (%rax),%rcx
cmp    (%r15),%rcx
jne    1180 <crldp_check_crlissuer+0x40>
mov    0x8(%rax),%edi
mov    %r14,%rsi
call   1060 <X509_NAME_cmp@plt>
test   %eax,%eax
jne    1180 <crldp_check_crlissuer+0x40>
mov    $0x1,%ebp
jmp    11bf <crldp_check_crlissuer+0x7f>
xor    %ebp,%ebp
jmp    11bf <crldp_check_crlissuer+0x7f>
shr    $0x5,%ebp
and    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_8__ = type { i32 }
%struct.TYPE_7__ = type { i64, %struct.TYPE_6__ }
%struct.TYPE_6__ = type { i32 }
@GEN_DIRNAME = global i64 0
define i32 @crldp_check_crlissuer(%struct.TYPE_8__* %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca %struct.TYPE_8__*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca %struct.TYPE_7__*
store %struct.TYPE_8__* %0, %struct.TYPE_8__** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
%11 = load i32*, i32** %6
%12 = call i32* @X509_CRL_get_issuer(i32* %11)
store i32* %12, i32** %9
%13 = load %struct.TYPE_8__*, %struct.TYPE_8__** %5
%14 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %13, i32 0, i32 0
%15 = load i32, i32* %14
%16 = icmp ne i32 %15, 0
br i1 %16, label %24, label %17
17: ; preds = %3
%18 = load i32, i32* %7
%19 = and i32 %18, 32
%20 = icmp ne i32 %19, 0
%21 = xor i1 %20, true
%22 = xor i1 %21, true
%23 = zext i1 %22 to i32
store i32 %23, i32* %4
br label %58
24: ; preds = %3
store i32 0, i32* %8
br label %25
25: ; preds = %54, %24
%26 = load i32, i32* %8
%27 = load %struct.TYPE_8__*, %struct.TYPE_8__** %5
%28 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %27, i32 0, i32 0
%29 = load i32, i32* %28
%30 = call i32 @sk_GENERAL_NAME_num(i32 %29)
%31 = icmp slt i32 %26, %30
br i1 %31, label %32, label %57
32: ; preds = %25
%33 = load %struct.TYPE_8__*, %struct.TYPE_8__** %5
%34 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %33, i32 0, i32 0
%35 = load i32, i32* %34
%36 = load i32, i32* %8
%37 = call %struct.TYPE_7__* @sk_GENERAL_NAME_value(i32 %35, i32 %36)
store %struct.TYPE_7__* %37, %struct.TYPE_7__** %10
%38 = load %struct.TYPE_7__*, %struct.TYPE_7__** %10
%39 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %38, i32 0, i32 0
%40 = load i64, i64* %39
%41 = load i64, i64* @GEN_DIRNAME
%42 = icmp ne i64 %40, %41
br i1 %42, label %43, label %44
43: ; preds = %32
br label %54
44: ; preds = %32
%45 = load %struct.TYPE_7__*, %struct.TYPE_7__** %10
%46 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %45, i32 0, i32 1
%47 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %46, i32 0, i32 0
%48 = load i32, i32* %47
%49 = load i32*, i32** %9
%50 = call i32 @X509_NAME_cmp(i32 %48, i32* %49)
%51 = icmp ne i32 %50, 0
br i1 %51, label %53, label %52
52: ; preds = %44
store i32 1, i32* %4
br label %58
53: ; preds = %44
br label %54
54: ; preds = %53, %43
%55 = load i32, i32* %8
%56 = add nsw i32 %55, 1
store i32 %56, i32* %8
br label %25
57: ; preds = %25
store i32 0, i32* %4
br label %58
58: ; preds = %57, %52, %17
%59 = load i32, i32* %4
ret i32 %59
}

LLVM IR (-O2):
%struct.TYPE_8__ = type { i32 }
%struct.TYPE_7__ = type { i64, %struct.TYPE_6__ }
%struct.TYPE_6__ = type { i32 }
@GEN_DIRNAME = global i64 0
define i32 @crldp_check_crlissuer(%struct.TYPE_8__* nocapture %0, i32* %1, i32 %2) {
%4 = tail call i32* @X509_CRL_get_issuer(i32* %1)
%5 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %0, i64 0, i32 0
%6 = load i32, i32* %5
%7 = icmp eq i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %3
%9 = tail call i32 @sk_GENERAL_NAME_num(i32 %6)
%10 = icmp sgt i32 %9, 0
br i1 %10, label %14, label %32
11: ; preds = %3
%12 = lshr i32 %2, 5
%13 = and i32 %12, 1
br label %32
14: ; preds = %8, %27
%15 = phi i32 [ %28, %27 ], [ 0, %8 ]
%16 = load i32, i32* %5
%17 = tail call %struct.TYPE_7__* @sk_GENERAL_NAME_value(i32 %16, i32 %15)
%18 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %17, i64 0, i32 0
%19 = load i64, i64* %18
%20 = load i64, i64* @GEN_DIRNAME
%21 = icmp eq i64 %19, %20
br i1 %21, label %22, label %27
22: ; preds = %14
%23 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %17, i64 0, i32 1, i32 0
%24 = load i32, i32* %23
%25 = tail call i32 @X509_NAME_cmp(i32 %24, i32* %4)
%26 = icmp eq i32 %25, 0
br i1 %26, label %32, label %27
27: ; preds = %14, %22
%28 = add nuw nsw i32 %15, 1
%29 = load i32, i32* %5
%30 = tail call i32 @sk_GENERAL_NAME_num(i32 %29)
%31 = icmp slt i32 %28, %30
br i1 %31, label %14, label %32
32: ; preds = %27, %22, %8, %11
%33 = phi i32 [ %13, %11 ], [ 0, %8 ], [ 0, %27 ], [ 1, %22 ]
ret i32 %33
}