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

/* Type definitions */
typedef int /*<<< orphan*/ X509_NAME_ENTRY;
typedef int /*<<< orphan*/ X509_NAME;
typedef int /*<<< orphan*/ X509;
struct TYPE_7__ {
  int length;
  int /*<<< orphan*/ data;
};
struct TYPE_5__ {
  TYPE_3__ *iPAddress;
};
struct TYPE_6__ {
  int type;
  TYPE_1__ d;
};
typedef int /*<<< orphan*/ GENERAL_NAMES;
typedef TYPE_2__ GENERAL_NAME;
typedef int /*<<< orphan*/ ASN1_STRING;
typedef TYPE_3__ ASN1_OCTET_STRING;

/* Variables and functions */
scalar_t__ CheckX509HostnameMatch(int /*<<< orphan*/ *, char const *, int,
                                  int /*<<< orphan*/);
int /*<<< orphan*/ GENERAL_NAMES_free(int /*<<< orphan*/ *);
int GEN_IPADD;
int NID_commonName;
int /*<<< orphan*/ NID_subject_alt_name;
int /*<<< orphan*/ *X509_NAME_ENTRY_get_data(int /*<<< orphan*/ *);
int /*<<< orphan*/ *X509_NAME_get_entry(int /*<<< orphan*/ *, int);
int X509_NAME_get_index_by_NID(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ *X509_get_ext_d2i(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                     int /*<<< orphan*/ *,
                                     int /*<<< orphan*/ *);
int /*<<< orphan*/ *X509_get_subject_name(int /*<<< orphan*/ *);
int /*<<< orphan*/ memcmp(unsigned char const *, int /*<<< orphan*/, size_t);
int sk_GENERAL_NAME_num(int /*<<< orphan*/ *);
TYPE_2__ *sk_GENERAL_NAME_value(int /*<<< orphan*/ *, int);
int CheckX509IpAddress(X509 *x509, const unsigned char *addressBytes,
                       int addressBytesLen, const char *hostname,
                       int cchHostname) {
  if (!x509)
    return -2;
  if (cchHostname > 0 && !hostname)
    return -3;
  if (cchHostname < 0)
    return -4;
  if (addressBytesLen < 0)
    return -5;
  if (!addressBytes)
    return -6;
  int subjectNid = NID_commonName;
  int sanGenType = GEN_IPADD;
  GENERAL_NAMES *san = X509_get_ext_d2i(x509, NID_subject_alt_name, NULL, NULL);
  int success = 0;
  if (san) {
    int i;
    int count = sk_GENERAL_NAME_num(san);
    for (i = 0; i < count; ++i) {
      GENERAL_NAME *sanEntry = sk_GENERAL_NAME_value(san, i);
      ASN1_OCTET_STRING *ipAddr;
      if (sanEntry->type != sanGenType) {
        continue;
      }
      ipAddr = sanEntry->d.iPAddress;
      if (!ipAddr || !ipAddr->data || ipAddr->length != addressBytesLen) {
        continue;
      }
      if (!memcmp(addressBytes, ipAddr->data, (size_t)addressBytesLen)) {
        success = 1;
        break;
      }
    }
    GENERAL_NAMES_free(san);
  }
  if (!success) {
    X509_NAME *subject = X509_get_subject_name(x509);
    if (subject) {
      int i = -1;
      while ((i = X509_NAME_get_index_by_NID(subject, subjectNid, i)) >= 0) {
        X509_NAME_ENTRY *nameEnt = X509_NAME_get_entry(subject, i);
        ASN1_STRING *cn = X509_NAME_ENTRY_get_data(nameEnt);
        if (CheckX509HostnameMatch(cn, hostname, cchHostname, 0)) {
          success = 1;
          break;
        }
      }
    }
  }
  return success;
}


x86 assembly (clang, -O0):
<CheckX509IpAddress>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    11d5 <CheckX509IpAddress+0x35>
movl   $0xfffffffe,-0x4(%rbp)
jmp    13df <CheckX509IpAddress+0x23f>
cmpl   $0x0,-0x2c(%rbp)
jle    11f6 <CheckX509IpAddress+0x56>
cmpq   $0x0,-0x28(%rbp)
jne    11f6 <CheckX509IpAddress+0x56>
movl   $0xfffffffd,-0x4(%rbp)
jmp    13df <CheckX509IpAddress+0x23f>
cmpl   $0x0,-0x2c(%rbp)
jge    120c <CheckX509IpAddress+0x6c>
movl   $0xfffffffc,-0x4(%rbp)
jmp    13df <CheckX509IpAddress+0x23f>
cmpl   $0x0,-0x1c(%rbp)
jge    1222 <CheckX509IpAddress+0x82>
movl   $0xfffffffb,-0x4(%rbp)
jmp    13df <CheckX509IpAddress+0x23f>
cmpq   $0x0,-0x18(%rbp)
jne    1239 <CheckX509IpAddress+0x99>
movl   $0xfffffffa,-0x4(%rbp)
jmp    13df <CheckX509IpAddress+0x23f>
mov    0x2d90(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    0x2d94(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2d9c(%rip),%rax
mov    (%rax),%esi
xor    %eax,%eax
mov    %eax,%ecx
mov    %rcx,%rdx
call   10b0 <X509_get_ext_d2i@plt>
mov    %rax,-0x40(%rbp)
movl   $0x0,-0x44(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     1341 <CheckX509IpAddress+0x1a1>
mov    -0x40(%rbp),%rdi
call   1030 <sk_GENERAL_NAME_num@plt>
mov    %eax,-0x4c(%rbp)
movl   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%eax
cmp    -0x4c(%rbp),%eax
jge    1338 <CheckX509IpAddress+0x198>
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%esi
call   1070 <sk_GENERAL_NAME_value@plt>
mov    %rax,-0x58(%rbp)
mov    -0x58(%rbp),%rax
mov    (%rax),%eax
cmp    -0x34(%rbp),%eax
je     12c3 <CheckX509IpAddress+0x123>
jmp    132a <CheckX509IpAddress+0x18a>
mov    -0x58(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x60(%rbp)
cmpq   $0x0,-0x60(%rbp)
je     12f7 <CheckX509IpAddress+0x157>
mov    -0x60(%rbp),%rax
cmpl   $0x0,0x4(%rax)
je     12f7 <CheckX509IpAddress+0x157>
mov    -0x60(%rbp),%rax
mov    (%rax),%eax
cmp    -0x1c(%rbp),%eax
je     12fc <CheckX509IpAddress+0x15c>
jmp    132a <CheckX509IpAddress+0x18a>
mov    -0x18(%rbp),%rdi
mov    -0x60(%rbp),%rax
mov    0x4(%rax),%esi
movslq -0x1c(%rbp),%rdx
call   1080 <memcmp@plt>
cmp    $0x0,%eax
jne    1325 <CheckX509IpAddress+0x185>
movl   $0x1,-0x44(%rbp)
jmp    1338 <CheckX509IpAddress+0x198>
jmp    132a <CheckX509IpAddress+0x18a>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1293 <CheckX509IpAddress+0xf3>
mov    -0x40(%rbp),%rdi
call   1090 <GENERAL_NAMES_free@plt>
cmpl   $0x0,-0x44(%rbp)
jne    13d9 <CheckX509IpAddress+0x239>
mov    -0x10(%rbp),%rdi
call   1060 <X509_get_subject_name@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
je     13d4 <CheckX509IpAddress+0x234>
movl   $0xffffffff,-0x6c(%rbp)
mov    -0x68(%rbp),%rdi
mov    -0x30(%rbp),%esi
mov    -0x6c(%rbp),%edx
call   10c0 <X509_NAME_get_index_by_NID@plt>
mov    %eax,-0x6c(%rbp)
cmp    $0x0,%eax
jl     13cf <CheckX509IpAddress+0x22f>
mov    -0x68(%rbp),%rdi
mov    -0x6c(%rbp),%esi
call   10a0 <X509_NAME_get_entry@plt>
mov    %rax,-0x78(%rbp)
mov    -0x78(%rbp),%rdi
call   1050 <X509_NAME_ENTRY_get_data@plt>
mov    %rax,-0x80(%rbp)
mov    -0x80(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x2c(%rbp),%edx
xor    %ecx,%ecx
call   1040 <CheckX509HostnameMatch@plt>
cmp    $0x0,%rax
je     13ca <CheckX509IpAddress+0x22a>
movl   $0x1,-0x44(%rbp)
jmp    13cf <CheckX509IpAddress+0x22f>
jmp    136a <CheckX509IpAddress+0x1ca>
jmp    13d4 <CheckX509IpAddress+0x234>
jmp    13d9 <CheckX509IpAddress+0x239>
mov    -0x44(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CheckX509IpAddress>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
test   %rdi,%rdi
je     12cd <CheckX509IpAddress+0x12d>
mov    %r8d,%r12d
mov    %rcx,%r14
mov    %edx,%ebx
mov    %rsi,%r15
mov    %rdi,%r13
test   %rcx,%rcx
jne    11d8 <CheckX509IpAddress+0x38>
mov    $0xfffffffd,%ebp
test   %r12d,%r12d
jg     1353 <CheckX509IpAddress+0x1b3>
test   %r12d,%r12d
js     12d7 <CheckX509IpAddress+0x137>
test   %ebx,%ebx
js     12de <CheckX509IpAddress+0x13e>
test   %r15,%r15
je     12e5 <CheckX509IpAddress+0x145>
mov    0x2dd7(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x10(%rsp)
mov    0x2dda(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x14(%rsp)
mov    0x2de5(%rip),%rax
mov    (%rax),%esi
xor    %ebp,%ebp
mov    %r13,%rdi
xor    %edx,%edx
xor    %ecx,%ecx
call   10b0 <X509_get_ext_d2i@plt>
test   %rax,%rax
je     12f1 <CheckX509IpAddress+0x151>
mov    %r15,0x20(%rsp)
mov    %ebx,0x4(%rsp)
mov    %rax,0x8(%rsp)
mov    0x8(%rsp),%rdi
call   1030 <sk_GENERAL_NAME_num@plt>
mov    0x8(%rsp),%rdi
test   %eax,%eax
jle    12ec <CheckX509IpAddress+0x14c>
mov    %eax,%ebx
mov    0x4(%rsp),%eax
mov    %rax,0x18(%rsp)
xor    %r15d,%r15d
jmp    127e <CheckX509IpAddress+0xde>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15d
cmp    %r15d,%ebx
mov    0x8(%rsp),%rdi
je     12ec <CheckX509IpAddress+0x14c>
mov    %r15d,%esi
call   1070 <sk_GENERAL_NAME_value@plt>
mov    0x14(%rsp),%ecx
cmp    %ecx,(%rax)
jne    1270 <CheckX509IpAddress+0xd0>
mov    0x8(%rax),%rax
test   %rax,%rax
je     1270 <CheckX509IpAddress+0xd0>
mov    0x4(%rax),%esi
test   %esi,%esi
je     1270 <CheckX509IpAddress+0xd0>
mov    0x4(%rsp),%ecx
cmp    %ecx,(%rax)
jne    1270 <CheckX509IpAddress+0xd0>
mov    0x20(%rsp),%rdi
mov    0x18(%rsp),%rdx
call   1080 <memcmp@plt>
test   %eax,%eax
jne    1270 <CheckX509IpAddress+0xd0>
mov    0x8(%rsp),%rdi
call   1090 <GENERAL_NAMES_free@plt>
mov    $0x1,%ebp
jmp    1353 <CheckX509IpAddress+0x1b3>
mov    $0xfffffffe,%ebp
jmp    1353 <CheckX509IpAddress+0x1b3>
mov    $0xfffffffc,%ebp
jmp    1353 <CheckX509IpAddress+0x1b3>
mov    $0xfffffffb,%ebp
jmp    1353 <CheckX509IpAddress+0x1b3>
mov    $0xfffffffa,%ebp
jmp    1353 <CheckX509IpAddress+0x1b3>
call   1090 <GENERAL_NAMES_free@plt>
mov    %r13,%rdi
call   1060 <X509_get_subject_name@plt>
test   %rax,%rax
mov    0x10(%rsp),%r13d
je     1353 <CheckX509IpAddress+0x1b3>
mov    %rax,%r15
mov    $0xffffffff,%ebx
nopl   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r13d,%esi
mov    %ebx,%edx
call   10c0 <X509_NAME_get_index_by_NID@plt>
test   %eax,%eax
js     1351 <CheckX509IpAddress+0x1b1>
mov    %eax,%ebx
mov    %r15,%rdi
mov    %eax,%esi
call   10a0 <X509_NAME_get_entry@plt>
mov    %rax,%rdi
call   1050 <X509_NAME_ENTRY_get_data@plt>
mov    %rax,%rdi
mov    %r14,%rsi
mov    %r12d,%edx
xor    %ecx,%ecx
call   1040 <CheckX509HostnameMatch@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     1310 <CheckX509IpAddress+0x170>
jmp    1353 <CheckX509IpAddress+0x1b3>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_6__ = type { i32, %struct.TYPE_5__ }
%struct.TYPE_5__ = type { %struct.TYPE_7__* }
%struct.TYPE_7__ = type { i32, i32 }
@NID_commonName = global i32 0
@GEN_IPADD = global i32 0
@NID_subject_alt_name = global i32 0
define i32 @CheckX509IpAddress(i32* %0, i8* %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca %struct.TYPE_6__*
%19 = alloca %struct.TYPE_7__*
%20 = alloca i32*
%21 = alloca i32
%22 = alloca i32*
%23 = alloca i32*
store i32* %0, i32** %7
store i8* %1, i8** %8
store i32 %2, i32* %9
store i8* %3, i8** %10
store i32 %4, i32* %11
%24 = load i32*, i32** %7
%25 = icmp ne i32* %24, null
br i1 %25, label %27, label %26
26: ; preds = %5
store i32 -2, i32* %6
br label %139
27: ; preds = %5
%28 = load i32, i32* %11
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %27
%31 = load i8*, i8** %10
%32 = icmp ne i8* %31, null
br i1 %32, label %34, label %33
33: ; preds = %30
store i32 -3, i32* %6
br label %139
34: ; preds = %30, %27
%35 = load i32, i32* %11
%36 = icmp slt i32 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %34
store i32 -4, i32* %6
br label %139
38: ; preds = %34
%39 = load i32, i32* %9
%40 = icmp slt i32 %39, 0
br i1 %40, label %41, label %42
41: ; preds = %38
store i32 -5, i32* %6
br label %139
42: ; preds = %38
%43 = load i8*, i8** %8
%44 = icmp ne i8* %43, null
br i1 %44, label %46, label %45
45: ; preds = %42
store i32 -6, i32* %6
br label %139
46: ; preds = %42
%47 = load i32, i32* @NID_commonName
store i32 %47, i32* %12
%48 = load i32, i32* @GEN_IPADD
store i32 %48, i32* %13
%49 = load i32*, i32** %7
%50 = load i32, i32* @NID_subject_alt_name
%51 = call i32* @X509_get_ext_d2i(i32* %49, i32 %50, i32* null, i32* null)
store i32* %51, i32** %14
store i32 0, i32* %15
%52 = load i32*, i32** %14
%53 = icmp ne i32* %52, null
br i1 %53, label %54, label %107
54: ; preds = %46
%55 = load i32*, i32** %14
%56 = call i32 @sk_GENERAL_NAME_num(i32* %55)
store i32 %56, i32* %17
store i32 0, i32* %16
br label %57
57: ; preds = %101, %54
%58 = load i32, i32* %16
%59 = load i32, i32* %17
%60 = icmp slt i32 %58, %59
br i1 %60, label %61, label %104
61: ; preds = %57
%62 = load i32*, i32** %14
%63 = load i32, i32* %16
%64 = call %struct.TYPE_6__* @sk_GENERAL_NAME_value(i32* %62, i32 %63)
store %struct.TYPE_6__* %64, %struct.TYPE_6__** %18
%65 = load %struct.TYPE_6__*, %struct.TYPE_6__** %18
%66 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %65, i32 0, i32 0
%67 = load i32, i32* %66
%68 = load i32, i32* %13
%69 = icmp ne i32 %67, %68
br i1 %69, label %70, label %71
70: ; preds = %61
br label %101
71: ; preds = %61
%72 = load %struct.TYPE_6__*, %struct.TYPE_6__** %18
%73 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %72, i32 0, i32 1
%74 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %73, i32 0, i32 0
%75 = load %struct.TYPE_7__*, %struct.TYPE_7__** %74
store %struct.TYPE_7__* %75, %struct.TYPE_7__** %19
%76 = load %struct.TYPE_7__*, %struct.TYPE_7__** %19
%77 = icmp ne %struct.TYPE_7__* %76, null
br i1 %77, label %78, label %89
78: ; preds = %71
%79 = load %struct.TYPE_7__*, %struct.TYPE_7__** %19
%80 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %79, i32 0, i32 1
%81 = load i32, i32* %80
%82 = icmp ne i32 %81, 0
br i1 %82, label %83, label %89
83: ; preds = %78
%84 = load %struct.TYPE_7__*, %struct.TYPE_7__** %19
%85 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %84, i32 0, i32 0
%86 = load i32, i32* %85
%87 = load i32, i32* %9
%88 = icmp ne i32 %86, %87
br i1 %88, label %89, label %90
89: ; preds = %83, %78, %71
br label %101
90: ; preds = %83
%91 = load i8*, i8** %8
%92 = load %struct.TYPE_7__*, %struct.TYPE_7__** %19
%93 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %92, i32 0, i32 1
%94 = load i32, i32* %93
%95 = load i32, i32* %9
%96 = sext i32 %95 to i64
%97 = call i32 @memcmp(i8* %91, i32 %94, i64 %96)
%98 = icmp ne i32 %97, 0
br i1 %98, label %100, label %99
99: ; preds = %90
store i32 1, i32* %15
br label %104
100: ; preds = %90
br label %101
101: ; preds = %100, %89, %70
%102 = load i32, i32* %16
%103 = add nsw i32 %102, 1
store i32 %103, i32* %16
br label %57
104: ; preds = %99, %57
%105 = load i32*, i32** %14
%106 = call i32 @GENERAL_NAMES_free(i32* %105)
br label %107
107: ; preds = %104, %46
%108 = load i32, i32* %15
%109 = icmp ne i32 %108, 0
br i1 %109, label %137, label %110
110: ; preds = %107
%111 = load i32*, i32** %7
%112 = call i32* @X509_get_subject_name(i32* %111)
store i32* %112, i32** %20
%113 = load i32*, i32** %20
%114 = icmp ne i32* %113, null
br i1 %114, label %115, label %136
115: ; preds = %110
store i32 -1, i32* %21
br label %116
116: ; preds = %134, %115
%117 = load i32*, i32** %20
%118 = load i32, i32* %12
%119 = load i32, i32* %21
%120 = call i32 @X509_NAME_get_index_by_NID(i32* %117, i32 %118, i32 %119)
store i32 %120, i32* %21
%121 = icmp sge i32 %120, 0
br i1 %121, label %122, label %135
122: ; preds = %116
%123 = load i32*, i32** %20
%124 = load i32, i32* %21
%125 = call i32* @X509_NAME_get_entry(i32* %123, i32 %124)
store i32* %125, i32** %22
%126 = load i32*, i32** %22
%127 = call i32* @X509_NAME_ENTRY_get_data(i32* %126)
store i32* %127, i32** %23
%128 = load i32*, i32** %23
%129 = load i8*, i8** %10
%130 = load i32, i32* %11
%131 = call i64 @CheckX509HostnameMatch(i32* %128, i8* %129, i32 %130, i32 0)
%132 = icmp ne i64 %131, 0
br i1 %132, label %133, label %134
133: ; preds = %122
store i32 1, i32* %15
br label %135
134: ; preds = %122
br label %116
135: ; preds = %133, %116
br label %136
136: ; preds = %135, %110
br label %137
137: ; preds = %136, %107
%138 = load i32, i32* %15
store i32 %138, i32* %6
br label %139
139: ; preds = %137, %45, %41, %37, %33, %26
%140 = load i32, i32* %6
ret i32 %140
}

LLVM IR (-O2):
%struct.TYPE_6__ = type { i32, %struct.TYPE_5__ }
%struct.TYPE_5__ = type { %struct.TYPE_7__* }
%struct.TYPE_7__ = type { i32, i32 }
@NID_commonName = global i32 0
@GEN_IPADD = global i32 0
@NID_subject_alt_name = global i32 0
define i32 @CheckX509IpAddress(i32* %0, i8* %1, i32 %2, i8* %3, i32 %4) {
%6 = icmp eq i32* %0, null
br i1 %6, label %67, label %7
7: ; preds = %5
%8 = icmp slt i32 %4, 1
%9 = icmp ne i8* %3, null
%10 = or i1 %9, %8
br i1 %10, label %11, label %67
11: ; preds = %7
%12 = icmp slt i32 %4, 0
br i1 %12, label %67, label %13
13: ; preds = %11
%14 = icmp slt i32 %2, 0
br i1 %14, label %67, label %15
15: ; preds = %13
%16 = icmp eq i8* %1, null
br i1 %16, label %67, label %17
17: ; preds = %15
%18 = load i32, i32* @NID_commonName
%19 = load i32, i32* @GEN_IPADD
%20 = load i32, i32* @NID_subject_alt_name
%21 = tail call i32* @X509_get_ext_d2i(i32* %0, i32 %20, i32* null, i32* null)
%22 = icmp eq i32* %21, null
br i1 %22, label %53, label %23
23: ; preds = %17
%24 = tail call i32 @sk_GENERAL_NAME_num(i32* %21)
%25 = zext i32 %2 to i64
%26 = icmp sgt i32 %24, 0
br i1 %26, label %27, label %51
27: ; preds = %23, %48
%28 = phi i32 [ %49, %48 ], [ 0, %23 ]
%29 = tail call %struct.TYPE_6__* @sk_GENERAL_NAME_value(i32* %21, i32 %28)
%30 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %29, i64 0, i32 0
%31 = load i32, i32* %30
%32 = icmp eq i32 %31, %19
br i1 %32, label %33, label %48
33: ; preds = %27
%34 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %29, i64 0, i32 1, i32 0
%35 = load %struct.TYPE_7__*, %struct.TYPE_7__** %34
%36 = icmp eq %struct.TYPE_7__* %35, null
br i1 %36, label %48, label %37
37: ; preds = %33
%38 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %35, i64 0, i32 1
%39 = load i32, i32* %38
%40 = icmp eq i32 %39, 0
br i1 %40, label %48, label %41
41: ; preds = %37
%42 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %35, i64 0, i32 0
%43 = load i32, i32* %42
%44 = icmp eq i32 %43, %2
br i1 %44, label %45, label %48
45: ; preds = %41
%46 = tail call i32 @memcmp(i8* %1, i32 %39, i64 %25)
%47 = icmp eq i32 %46, 0
br i1 %47, label %65, label %48
48: ; preds = %33, %37, %41, %27, %45
%49 = add nuw nsw i32 %28, 1
%50 = icmp eq i32 %49, %24
br i1 %50, label %51, label %27
51: ; preds = %48, %23
%52 = tail call i32 @GENERAL_NAMES_free(i32* %21)
br label %53
53: ; preds = %51, %17
%54 = tail call i32* @X509_get_subject_name(i32* %0)
%55 = icmp eq i32* %54, null
br i1 %55, label %67, label %56
56: ; preds = %53, %60
%57 = phi i32 [ %58, %60 ], [ -1, %53 ]
%58 = tail call i32 @X509_NAME_get_index_by_NID(i32* %54, i32 %18, i32 %57)
%59 = icmp sgt i32 %58, -1
br i1 %59, label %60, label %67
60: ; preds = %56
%61 = tail call i32* @X509_NAME_get_entry(i32* %54, i32 %58)
%62 = tail call i32* @X509_NAME_ENTRY_get_data(i32* %61)
%63 = tail call i64 @CheckX509HostnameMatch(i32* %62, i8* %3, i32 %4, i32 0)
%64 = icmp eq i64 %63, 0
br i1 %64, label %56, label %67
65: ; preds = %45
%66 = tail call i32 @GENERAL_NAMES_free(i32* %21)
br label %67
67: ; preds = %60, %56, %65, %53, %15, %13, %11, %7, %5
%68 = phi i32 [ -2, %5 ], [ -3, %7 ], [ -4, %11 ], [ -5, %13 ], [ -6, %15 ], [ 0, %53 ], [ 1, %65 ], [ 0, %56 ], [ 1, %60 ]
ret i32 %68
}