// File: /workspace/github_c_makefile_star2_O0/aerospike[P]aerospike-common/src/main/aerospike/ssl_util.c
// Function: modssl_X509_getSAN
static BOOL modssl_X509_getSAN(apr_pool_t *p, X509 *x509, int type, const char *onf,
                        int idx, apr_array_header_t **entries)
{
    STACK_OF(GENERAL_NAME) *names;
    int nid = onf ? OBJ_txt2nid(onf) : NID_undef;

    if (!x509 || (type < GEN_OTHERNAME) ||
        ((type == GEN_OTHERNAME) && (nid == NID_undef)) ||
        (type > GEN_RID) || (idx < -1) ||
        !(*entries = as_apr_array_make(p, 0, sizeof(char *)))) {
        *entries = NULL;
        return FALSE;
    }

    if ((names = X509_get_ext_d2i(x509, NID_subject_alt_name, NULL, NULL))) {
        int i, n = 0;
        GENERAL_NAME *name;
        const char *utf8str;

        for (i = 0; i < sk_GENERAL_NAME_num(names); i++) {
            name = sk_GENERAL_NAME_value(names, i);

            if (name->type != type)
                continue;

            switch (type) {
            case GEN_EMAIL:
            case GEN_DNS:
                if (((idx == -1) || (n == idx)) &&
                    (utf8str = asn1_string_to_utf8(p, name->d.ia5))) {
                    APR_ARRAY_PUSH(*entries, const char *) = utf8str;
                }
                n++;
                break;
            case GEN_OTHERNAME:
                if (OBJ_obj2nid(name->d.otherName->type_id) == nid) {
                    if (((idx == -1) || (n == idx))) {
                        parse_otherName_value(p, name->d.otherName->value,
                                              onf, entries);
                    }
                    n++;
                }
                break;
            default:
                /*
                 * Not implemented right now:
                 * GEN_X400 (x400Address)
                 * GEN_DIRNAME (directoryName)
                 * GEN_EDIPARTY (ediPartyName)
                 * GEN_URI (uniformResourceIdentifier)
                 * GEN_IPADD (iPAddress)
                 * GEN_RID (registeredID)
                 */
                break;
            }

            if ((idx != -1) && (n > idx))
               break;
        }

        sk_GENERAL_NAME_pop_free(names, GENERAL_NAME_free);
    }

    return as_apr_is_empty_array(*entries) ? FALSE : TRUE;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq %rcx, -0x28(%rbp)
movl %r8d, -0x2c(%rbp)
movq %r9, -0x38(%rbp)
cmpq $0x0, -0x28(%rbp)
je 0x1f5c7
movq -0x28(%rbp), %rdi
callq 0x8130
movl %eax, -0x64(%rbp)
jmp 0x1f5ce
xorl %eax, %eax
movl %eax, -0x64(%rbp)
jmp 0x1f5ce
movl -0x64(%rbp), %eax
movl %eax, -0x44(%rbp)
cmpq $0x0, -0x18(%rbp)
je 0x1f618
cmpl $0x0, -0x1c(%rbp)
jl 0x1f618
cmpl $0x0, -0x1c(%rbp)
jne 0x1f5ed
cmpl $0x0, -0x44(%rbp)
je 0x1f618
cmpl $0x8, -0x1c(%rbp)
jg 0x1f618
cmpl $-0x1, -0x2c(%rbp)
jl 0x1f618
movq -0x10(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0x8, %edx
callq 0x1f8f0
movq -0x38(%rbp), %rcx
movq %rax, (%rcx)
cmpq $0x0, %rax
jne 0x1f62f
movq -0x38(%rbp), %rax
movq $0x0, (%rax)
movl $0x0, -0x4(%rbp)
jmp 0x1f7c7
movq -0x18(%rbp), %rdi
movl $0x55, %esi
xorl %eax, %eax
movl %eax, %ecx
movq %rcx, %rdx
callq 0x8870
movq %rax, -0x40(%rbp)
cmpq $0x0, %rax
je 0x1f7a9
movl $0x0, -0x4c(%rbp)
movl $0x0, -0x48(%rbp)
movl -0x48(%rbp), %eax
movl %eax, -0x68(%rbp)
movq -0x40(%rbp), %rdi
callq 0x1f3f0
movq %rax, %rdi
callq 0x8990
movl %eax, %ecx
movl -0x68(%rbp), %eax
cmpl %ecx, %eax
jge 0x1f784
movq -0x40(%rbp), %rdi
callq 0x1f3f0
movq %rax, %rdi
movl -0x48(%rbp), %esi
callq 0x8c80
movq %rax, -0x58(%rbp)
movq -0x58(%rbp), %rax
movl (%rax), %eax
cmpl -0x1c(%rbp), %eax
je 0x1f6ac
jmp 0x1f776
movl -0x1c(%rbp), %eax
movl %eax, -0x6c(%rbp)
testl %eax, %eax
je 0x1f717
jmp 0x1f6b8
movl -0x6c(%rbp), %eax
decl %eax
subl $0x1, %eax
ja 0x1f762
jmp 0x1f6c8
cmpl $-0x1, -0x2c(%rbp)
je 0x1f6d6
movl -0x4c(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jne 0x1f70c
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rsi
callq 0x1f990
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
je 0x1f70c
movq -0x60(%rbp), %rax
movq %rax, -0x78(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rdi
callq 0x1f820
movq -0x78(%rbp), %rcx
movq %rcx, (%rax)
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x1f764
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rax
movq (%rax), %rdi
callq 0x8180
cmpl -0x44(%rbp), %eax
jne 0x1f760
cmpl $-0x1, -0x2c(%rbp)
je 0x1f73a
movl -0x4c(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jne 0x1f757
movq -0x10(%rbp), %rdi
movq -0x58(%rbp), %rax
movq 0x8(%rax), %rax
movq 0x8(%rax), %rsi
movq -0x28(%rbp), %rdx
movq -0x38(%rbp), %rcx
callq 0x1fa50
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x1f764
jmp 0x1f764
cmpl $-0x1, -0x2c(%rbp)
je 0x1f774
movl -0x4c(%rbp), %eax
cmpl -0x2c(%rbp), %eax
jle 0x1f774
jmp 0x1f784
jmp 0x1f776
movl -0x48(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x48(%rbp)
jmp 0x1f660
movq -0x40(%rbp), %rdi
callq 0x1f400
movq %rax, -0x80(%rbp)
movq 0x10818(%rip), %rdi     # 0x2ffb0
callq 0x1f410
movq -0x80(%rbp), %rdi
movq %rax, %rsi
callq 0x88f0
movq -0x38(%rbp), %rax
movq (%rax), %rdi
callq 0x1f8d0
movl %eax, %edx
movl $0x1, %eax
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovnel %ecx, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nopl (%rax)