// File: /workspace/github_c_makefile_star2_O0/aerospike[P]aerospike-common/src/main/aerospike/ssl_util.c
// Function: modssl_X509_match_name
static BOOL modssl_X509_match_name(apr_pool_t *p, X509 *x509, const char *name,
                            BOOL allow_wildcard, server_rec *s)
{
    BOOL matched = FALSE;
    apr_array_header_t *ids = NULL;

    /*
     * At some day in the future, this might be replaced with X509_check_host()
     * (available in OpenSSL 1.0.2 and later), but two points should be noted:
     * 1) wildcard matching in X509_check_host() might yield different
     *    results (by default, it supports a broader set of patterns, e.g.
     *    wildcards in non-initial positions);
     * 2) we lose the option of logging each DNS- and CN-ID (until a match
     *    is found).
     */

    if (getIDs(p, x509, &ids)) {
        const char *cp;
        int i;
        char **id = (char **)ids->elts;
        BOOL is_wildcard;

        for (i = 0; i < ids->nelts; i++) {
            if (!id[i])
                continue;

            /*
             * Determine if it is a wildcard ID - we're restrictive
             * in the sense that we require the wildcard character to be
             * THE left-most label (i.e., the ID must start with "*.")
             */
            is_wildcard = (*id[i] == '*' && *(id[i]+1) == '.') ? TRUE : FALSE;

            /*
             * If the ID includes a wildcard character (and the caller is
             * allowing wildcards), check if it matches for the left-most
             * DNS label - i.e., the wildcard character is not allowed
             * to match a dot. Otherwise, try a simple string compare.
             */
            if ((allow_wildcard == TRUE && is_wildcard == TRUE &&
                 (cp = strchr(name, '.')) && !strcasecmp(id[i]+1, cp)) ||
                !strcasecmp(id[i], name)) {
                matched = TRUE;
            }

#if !defined ENHANCED_ALLOC
			if (!matched) {
				as_log_info("as_tls_match_name: expecting name '%s', "
							"%smatched by ID '%s'",
							name,
							matched == TRUE ? "" : "NOT ",
							id[i]);
			}
#endif

            if (matched == TRUE) {
                break;
            }
        }

    }

#if !defined ENHANCED_ALLOC
	if (!matched) {
		as_log_warn("Cert %s for name '%s'",
					matched == TRUE ? "matches" : "does not match",
					name);
	}
#endif

    as_array_destroy(ids);
    
    return matched;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x70, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq %r8, -0x28(%rbp)
movl $0x0, -0x2c(%rbp)
movq $0x0, -0x38(%rbp)
movq -0x8(%rbp), %rdi
movq -0x10(%rbp), %rsi
leaq -0x38(%rbp), %rdx
callq 0x1f420
cmpl $0x0, %eax
je 0x1f127
movq -0x38(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x50(%rbp)
movl $0x0, -0x44(%rbp)
movl -0x44(%rbp), %eax
movq -0x38(%rbp), %rcx
cmpl 0xc(%rcx), %eax
jge 0x1f125
movq -0x50(%rbp), %rax
movslq -0x44(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
jne 0x1efdb
jmp 0x1f117
movq -0x50(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl (%rax), %ecx
xorl %eax, %eax
cmpl $0x2a, %ecx
movb %al, -0x55(%rbp)
jne 0x1f00d
movq -0x50(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movsbl 0x1(%rax), %eax
cmpl $0x2e, %eax
sete %al
movb %al, -0x55(%rbp)
movb -0x55(%rbp), %dl
xorl %eax, %eax
movl $0x1, %ecx
testb $0x1, %dl
cmovnel %ecx, %eax
movl %eax, -0x54(%rbp)
cmpl $0x1, -0x1c(%rbp)
jne 0x1f062
cmpl $0x1, -0x54(%rbp)
jne 0x1f062
movq -0x18(%rbp), %rdi
movl $0x2e, %esi
callq 0x8300
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
je 0x1f062
movq -0x50(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
addq $0x1, %rdi
movq -0x40(%rbp), %rsi
callq 0x8150
cmpl $0x0, %eax
je 0x1f07c
movq -0x50(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x18(%rbp), %rsi
callq 0x8150
cmpl $0x0, %eax
jne 0x1f083
movl $0x1, -0x2c(%rbp)
cmpl $0x0, -0x2c(%rbp)
jne 0x1f10d
movq 0x10f34(%rip), %rax     # 0x2ffc8
cmpq $0x0, 0x8(%rax)
je 0x1f10b
movl $0x2, %eax
movq 0x10f21(%rip), %rcx     # 0x2ffc8
cmpl (%rcx), %eax
ja 0x1f10b
movq 0x10f16(%rip), %rax     # 0x2ffc8
movq 0x8(%rax), %r10
movq -0x18(%rbp), %r9
movl -0x2c(%rbp), %ecx
leaq 0x8448(%rip), %r11      # 0x2750c
leaq 0x82cb(%rip), %rax      # 0x27396
cmpl $0x1, %ecx
cmoveq %rax, %r11
movq -0x50(%rbp), %rax
movslq -0x44(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movl $0x2, %edi
leaq 0x83b0(%rip), %rsi      # 0x2749a
leaq 0x83c0(%rip), %rdx      # 0x274b1
movl $0x15f, %ecx            # imm = 0x15F
leaq 0x83d2(%rip), %r8       # 0x274cf
movq %r11, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq *%r10
jmp 0x1f10d
cmpl $0x1, -0x2c(%rbp)
jne 0x1f115
jmp 0x1f125
jmp 0x1f117
movl -0x44(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x44(%rbp)
jmp 0x1efb7
jmp 0x1f127
cmpl $0x0, -0x2c(%rbp)
jne 0x1f19c
movq 0x10e94(%rip), %rax     # 0x2ffc8
cmpq $0x0, 0x8(%rax)
je 0x1f19a
movl $0x1, %eax
movq 0x10e81(%rip), %rcx     # 0x2ffc8
cmpl (%rcx), %eax
ja 0x1f19a
movq 0x10e76(%rip), %rax     # 0x2ffc8
movq 0x8(%rax), %r10
movl -0x2c(%rbp), %ecx
leaq 0x83cf(%rip), %r9       # 0x2752f
leaq 0x83c0(%rip), %rax      # 0x27527
cmpl $0x1, %ecx
cmoveq %rax, %r9
movq -0x18(%rbp), %rax
movl $0x1, %edi
leaq 0x831c(%rip), %rsi      # 0x2749a
leaq 0x832c(%rip), %rdx      # 0x274b1
movl $0x16e, %ecx            # imm = 0x16E
leaq 0x8380(%rip), %r8       # 0x27511
movq %rax, (%rsp)
movb $0x0, %al
callq *%r10
jmp 0x1f19c
movq -0x38(%rbp), %rdi
callq 0x1f510
movl -0x2c(%rbp), %eax
addq $0x70, %rsp
popq %rbp
retq
nop