// File: /workspace/github_c_makefile_star2_O0/samtools[P]htslib/htscodecs/htscodecs/tokenise_name3.c
// Function: search_trie
static
int search_trie(name_context *ctx, char *data, size_t len, int n, int *exact, int *is_fixed, int *fixed_len) {
    int nlines = 0;
    size_t i;
    trie_t *t;
    int from = -1, p3 = -1;
    *exact = 0;
    *fixed_len = 0;
    *is_fixed = 0;

    // Horrid hack for the encoder only.
    // We optimise per known name format here.
    int prefix_len;
    char *d = *data == '@' ? data+1 : data;
    int l   = *data == '@' ? len-1  : len;
    int f = (*data == '>') ? 1 : 0;
    if (l > 70 && d[f+0] == 'm' && d[7] == '_' && d[f+14] == '_' && d[f+61] == '/') {
        prefix_len = 60; // PacBio
        *is_fixed = 0;
    } else if (l == 17 && d[f+5] == ':' && d[f+11] == ':') {
        prefix_len = 6;  // IonTorrent
        *fixed_len = 6;
        *is_fixed = 1;
    } else if (l >= 36
               && d[f+8]=='-' && d[f+13]=='-' && d[f+18]=='-' && d[f+23]=='-'
               && isxdigit((uint8_t)d[f+0])  && isxdigit((uint8_t)d[f+7])
               && isxdigit((uint8_t)d[f+9])  && isxdigit((uint8_t)d[f+12])
               && isxdigit((uint8_t)d[f+14]) && isxdigit((uint8_t)d[f+17])
               && isxdigit((uint8_t)d[f+19]) && isxdigit((uint8_t)d[f+22])
               && isxdigit((uint8_t)d[f+24]) && isxdigit((uint8_t)d[f+35])) {
        // ONT: f33d30d5-6eb8-4115-8f46-154c2620a5da_Basecall_1D_template...
        prefix_len = 36;
        *fixed_len = 36;
        *is_fixed = 1;
    } else {
        // Check Illumina and trim back to lane:tile:x:y.
        int colons = 0;
        for (i = 0; i < len && data[i] > ' '; i++)
            ;
        while (i > 0 && colons < 4)
            if (data[--i] == ':')
                colons++;

        if (colons == 4) {
            // Constant illumina prefix
            *fixed_len = i+1;
            prefix_len = i+1;
            *is_fixed = 1;
        } else {
            // Unknown, don't use a fixed len, but still search
            // for any exact matches.
            prefix_len = INT_MAX;
            *is_fixed = 0;
        }
    }

    if (!ctx->t_head) {
        ctx->t_head = calloc(1, sizeof(*ctx->t_head));
        if (!ctx->t_head)
            return -1;
    }

    // Find an item in the trie
    int from_punct = from;
    for (nlines = i = 0; i < len; i++, nlines++) {
        t = ctx->t_head;
        while (i < len && data[i] > '\n') {
            unsigned char c = data[i++];
            if (c & 0x80)
                //fprintf(stderr, "8-bit ASCII is unsupported\n");
                return -1;
            c &= 127;

            trie_t *x = t->next;
            while (x && x->c != c)
                x = x->sibling;
            t = x;

            from = t->n;
            if ((ispunct(c) || isspace(c)) && t->n != n)
                from_punct = t->n;
            if (i == prefix_len) p3 = t->n;
            t->n = n;
        }
    }

    //printf("Looked for %d, found %d, prefix %d\n", n, from, p3);

    *exact = (n != from) && len;
    return *exact ? from : (p3 != -1 ? p3 : from_punct);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xb0, %rsp
movq 0x10(%rbp), %rax
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movq %r8, -0x30(%rbp)
movq %r9, -0x38(%rbp)
movl $0x0, -0x3c(%rbp)
movl $0xffffffff, -0x54(%rbp) # imm = 0xFFFFFFFF
movl $0xffffffff, -0x58(%rbp) # imm = 0xFFFFFFFF
movq -0x30(%rbp), %rax
movl $0x0, (%rax)
movq 0x10(%rbp), %rax
movl $0x0, (%rax)
movq -0x38(%rbp), %rax
movl $0x0, (%rax)
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x40, %eax
jne 0xcc786
movq -0x18(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x90(%rbp)
jmp 0xcc791
movq -0x18(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rax
movq %rax, -0x68(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %eax
cmpl $0x40, %eax
jne 0xcc7b9
movq -0x20(%rbp), %rax
subq $0x1, %rax
movq %rax, -0x98(%rbp)
jmp 0xcc7c4
movq -0x20(%rbp), %rax
movq %rax, -0x98(%rbp)
movq -0x98(%rbp), %rax
movl %eax, -0x6c(%rbp)
movq -0x18(%rbp), %rax
movsbl (%rax), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x3e, %edx
cmovel %ecx, %eax
movl %eax, -0x70(%rbp)
cmpl $0x46, -0x6c(%rbp)
jle 0xcc850
movq -0x68(%rbp), %rax
movl -0x70(%rbp), %ecx
addl $0x0, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x6d, %eax
jne 0xcc850
movq -0x68(%rbp), %rax
movsbl 0x7(%rax), %eax
cmpl $0x5f, %eax
jne 0xcc850
movq -0x68(%rbp), %rax
movl -0x70(%rbp), %ecx
addl $0xe, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x5f, %eax
jne 0xcc850
movq -0x68(%rbp), %rax
movl -0x70(%rbp), %ecx
addl $0x3d, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2f, %eax
jne 0xcc850
movl $0x3c, -0x5c(%rbp)
movq -0x38(%rbp), %rax
movl $0x0, (%rax)
jmp 0xccbdf
cmpl $0x11, -0x6c(%rbp)
jne 0xcc8a2
movq -0x68(%rbp), %rax
movl -0x70(%rbp), %ecx
addl $0x5, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x3a, %eax
jne 0xcc8a2
movq -0x68(%rbp), %rax
movl -0x70(%rbp), %ecx
addl $0xb, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x3a, %eax
jne 0xcc8a2
movl $0x6, -0x5c(%rbp)
movq 0x10(%rbp), %rax
movl $0x6, (%rax)
movq -0x38(%rbp), %rax
movl $0x1, (%rax)
jmp 0xccbdd
cmpl $0x24, -0x6c(%rbp)
jl 0xccaf4
movq -0x68(%rbp), %rax
movl -0x70(%rbp), %ecx
addl $0x8, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2d, %eax
jne 0xccaf4
movq -0x68(%rbp), %rax
movl -0x70(%rbp), %ecx
addl $0xd, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2d, %eax
jne 0xccaf4
movq -0x68(%rbp), %rax
movl -0x70(%rbp), %ecx
addl $0x12, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2d, %eax
jne 0xccaf4
movq -0x68(%rbp), %rax
movl -0x70(%rbp), %ecx
addl $0x17, %ecx
movslq %ecx, %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2d, %eax
jne 0xccaf4
callq 0x44f0
movq (%rax), %rax
movq -0x68(%rbp), %rcx
movl -0x70(%rbp), %edx
addl $0x0, %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
je 0xccaf4
callq 0x44f0
movq (%rax), %rax
movq -0x68(%rbp), %rcx
movl -0x70(%rbp), %edx
addl $0x7, %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
je 0xccaf4
callq 0x44f0
movq (%rax), %rax
movq -0x68(%rbp), %rcx
movl -0x70(%rbp), %edx
addl $0x9, %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
je 0xccaf4
callq 0x44f0
movq (%rax), %rax
movq -0x68(%rbp), %rcx
movl -0x70(%rbp), %edx
addl $0xc, %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
je 0xccaf4
callq 0x44f0
movq (%rax), %rax
movq -0x68(%rbp), %rcx
movl -0x70(%rbp), %edx
addl $0xe, %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
je 0xccaf4
callq 0x44f0
movq (%rax), %rax
movq -0x68(%rbp), %rcx
movl -0x70(%rbp), %edx
addl $0x11, %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
je 0xccaf4
callq 0x44f0
movq (%rax), %rax
movq -0x68(%rbp), %rcx
movl -0x70(%rbp), %edx
addl $0x13, %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
je 0xccaf4
callq 0x44f0
movq (%rax), %rax
movq -0x68(%rbp), %rcx
movl -0x70(%rbp), %edx
addl $0x16, %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
je 0xccaf4
callq 0x44f0
movq (%rax), %rax
movq -0x68(%rbp), %rcx
movl -0x70(%rbp), %edx
addl $0x18, %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
je 0xccaf4
callq 0x44f0
movq (%rax), %rax
movq -0x68(%rbp), %rcx
movl -0x70(%rbp), %edx
addl $0x23, %edx
movslq %edx, %rdx
movzbl (%rcx,%rdx), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x1000, %eax           # imm = 0x1000
cmpl $0x0, %eax
je 0xccaf4
movl $0x24, -0x5c(%rbp)
movq 0x10(%rbp), %rax
movl $0x24, (%rax)
movq -0x38(%rbp), %rax
movl $0x1, (%rax)
jmp 0xccbdb
movl $0x0, -0x74(%rbp)
movq $0x0, -0x48(%rbp)
movq -0x48(%rbp), %rcx
xorl %eax, %eax
cmpq -0x20(%rbp), %rcx
movb %al, -0x99(%rbp)
jae 0xccb2d
movq -0x18(%rbp), %rax
movq -0x48(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x20, %eax
setg %al
movb %al, -0x99(%rbp)
movb -0x99(%rbp), %al
testb $0x1, %al
jne 0xccb39
jmp 0xccb49
jmp 0xccb3b
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
jmp 0xccb03
jmp 0xccb4b
xorl %eax, %eax
cmpq $0x0, -0x48(%rbp)
movb %al, -0x9a(%rbp)
jbe 0xccb67
cmpl $0x4, -0x74(%rbp)
setl %al
movb %al, -0x9a(%rbp)
movb -0x9a(%rbp), %al
testb $0x1, %al
jne 0xccb73
jmp 0xccb9b
movq -0x18(%rbp), %rax
movq -0x48(%rbp), %rcx
movq %rcx, %rdx
addq $-0x1, %rdx
movq %rdx, -0x48(%rbp)
movsbl -0x1(%rax,%rcx), %eax
cmpl $0x3a, %eax
jne 0xccb99
movl -0x74(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x74(%rbp)
jmp 0xccb4b
cmpl $0x4, -0x74(%rbp)
jne 0xccbc8
movq -0x48(%rbp), %rax
addq $0x1, %rax
movl %eax, %ecx
movq 0x10(%rbp), %rax
movl %ecx, (%rax)
movq -0x48(%rbp), %rax
addq $0x1, %rax
movl %eax, -0x5c(%rbp)
movq -0x38(%rbp), %rax
movl $0x1, (%rax)
jmp 0xccbd9
movl $0x7fffffff, -0x5c(%rbp) # imm = 0x7FFFFFFF
movq -0x38(%rbp), %rax
movl $0x0, (%rax)
jmp 0xccbdb
jmp 0xccbdd
jmp 0xccbdf
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0xccc1d
movl $0x1, %edi
movl $0x18, %esi
callq 0x42f0
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x10(%rax)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0xccc1b
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xcce57
jmp 0xccc1d
movl -0x54(%rbp), %eax
movl %eax, -0x78(%rbp)
movq $0x0, -0x48(%rbp)
movl $0x0, -0x3c(%rbp)
movq -0x48(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0xccde5
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rcx
xorl %eax, %eax
cmpq -0x20(%rbp), %rcx
movb %al, -0x9b(%rbp)
jae 0xccc76
movq -0x18(%rbp), %rax
movq -0x48(%rbp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0xa, %eax
setg %al
movb %al, -0x9b(%rbp)
movb -0x9b(%rbp), %al
testb $0x1, %al
jne 0xccc85
jmp 0xccdc9
movq -0x18(%rbp), %rax
movq -0x48(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x48(%rbp)
movb (%rax,%rcx), %al
movb %al, -0x79(%rbp)
movzbl -0x79(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0xcccb8
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xcce57
movzbl -0x79(%rbp), %eax
andl $0x7f, %eax
movb %al, -0x79(%rbp)
movq -0x50(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x88(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x88(%rbp)
movb %al, -0x9c(%rbp)
je 0xccd00
movq -0x88(%rbp), %rax
movl 0x14(%rax), %eax
andl $0xff, %eax
movzbl -0x79(%rbp), %ecx
cmpl %ecx, %eax
setne %al
movb %al, -0x9c(%rbp)
movb -0x9c(%rbp), %al
testb $0x1, %al
jne 0xccd0c
jmp 0xccd20
movq -0x88(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x88(%rbp)
jmp 0xcccd0
movq -0x88(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rax
movl 0x14(%rax), %eax
shrl $0x8, %eax
movl %eax, -0x54(%rbp)
callq 0x44f0
movq (%rax), %rax
movzbl -0x79(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x4, %eax
cmpl $0x0, %eax
jne 0xccd70
callq 0x44f0
movq (%rax), %rax
movzbl -0x79(%rbp), %ecx
movslq %ecx, %rcx
movzwl (%rax,%rcx,2), %eax
andl $0x2000, %eax           # imm = 0x2000
cmpl $0x0, %eax
je 0xccd8c
movq -0x50(%rbp), %rax
movl 0x14(%rax), %eax
shrl $0x8, %eax
cmpl -0x24(%rbp), %eax
je 0xccd8c
movq -0x50(%rbp), %rax
movl 0x14(%rax), %eax
shrl $0x8, %eax
movl %eax, -0x78(%rbp)
movq -0x48(%rbp), %rax
movslq -0x5c(%rbp), %rcx
cmpq %rcx, %rax
jne 0xccda6
movq -0x50(%rbp), %rax
movl 0x14(%rax), %eax
shrl $0x8, %eax
movl %eax, -0x58(%rbp)
movl -0x24(%rbp), %edx
movq -0x50(%rbp), %rax
movl 0x14(%rax), %ecx
andl $0xffffff, %edx         # imm = 0xFFFFFF
shll $0x8, %edx
andl $0xff, %ecx
orl %edx, %ecx
movl %ecx, 0x14(%rax)
jmp 0xccc4c
jmp 0xccdcb
movq -0x48(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x48(%rbp)
movl -0x3c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x3c(%rbp)
jmp 0xccc32
movl -0x24(%rbp), %ecx
xorl %eax, %eax
cmpl -0x54(%rbp), %ecx
movb %al, -0x9d(%rbp)
je 0xcce03
cmpq $0x0, -0x20(%rbp)
setne %al
movb %al, -0x9d(%rbp)
movb -0x9d(%rbp), %al
andb $0x1, %al
movzbl %al, %ecx
movq -0x30(%rbp), %rax
movl %ecx, (%rax)
movq -0x30(%rbp), %rax
cmpl $0x0, (%rax)
je 0xcce28
movl -0x54(%rbp), %eax
movl %eax, -0xa4(%rbp)
jmp 0xcce4e
cmpl $-0x1, -0x58(%rbp)
je 0xcce39
movl -0x58(%rbp), %eax
movl %eax, -0xa8(%rbp)
jmp 0xcce42
movl -0x78(%rbp), %eax
movl %eax, -0xa8(%rbp)
movl -0xa8(%rbp), %eax
movl %eax, -0xa4(%rbp)
movl -0xa4(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0xb0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)