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

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

    // Build our trie, also counting input lines
    for (nlines = i = 0; i < len; i++, nlines++) {
        t = ctx->t_head;
        t->count++;
        while (i < len && (unsigned char)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, *l = NULL;
            while (x && x->c != c) {
                l = x; x = x->sibling;
            }
            if (!x) {
                if (!ctx->pool)
                    ctx->pool = pool_create(sizeof(trie_t));
                if (!(x = (trie_t *)pool_alloc(ctx->pool)))
                    return -1;
                memset(x, 0, sizeof(*x));
                if (!l)
                    x = t->next    = x;
                else
                    x = l->sibling = x;
                x->n = n;
                x->c = c;
            }
            t = x;
            t->c = c;
            t->count++;
        }
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl %ecx, -0x24(%rbp)
movl $0x0, -0x28(%rbp)
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
jne 0xc936c
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 0xc936a
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xc957e
jmp 0xc936c
movq $0x0, -0x30(%rbp)
movl $0x0, -0x28(%rbp)
movq -0x30(%rbp), %rax
cmpq -0x20(%rbp), %rax
jae 0xc9577
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
movq -0x30(%rbp), %rcx
xorl %eax, %eax
cmpq -0x20(%rbp), %rcx
movb %al, -0x51(%rbp)
jae 0xc93c6
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %rcx
movzbl (%rax,%rcx), %eax
cmpl $0xa, %eax
setg %al
movb %al, -0x51(%rbp)
movb -0x51(%rbp), %al
testb $0x1, %al
jne 0xc93d2
jmp 0xc955b
movq -0x18(%rbp), %rax
movq -0x30(%rbp), %rcx
movq %rcx, %rdx
addq $0x1, %rdx
movq %rdx, -0x30(%rbp)
movb (%rax,%rcx), %al
movb %al, -0x39(%rbp)
movzbl -0x39(%rbp), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0xc9405
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xc957e
movzbl -0x39(%rbp), %eax
andl $0x7f, %eax
movb %al, -0x39(%rbp)
movq -0x38(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq $0x0, -0x50(%rbp)
xorl %eax, %eax
cmpq $0x0, -0x48(%rbp)
movb %al, -0x52(%rbp)
je 0xc9446
movq -0x48(%rbp), %rax
movl 0x14(%rax), %eax
andl $0xff, %eax
movzbl -0x39(%rbp), %ecx
cmpl %ecx, %eax
setne %al
movb %al, -0x52(%rbp)
movb -0x52(%rbp), %al
testb $0x1, %al
jne 0xc944f
jmp 0xc9465
movq -0x48(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x48(%rbp)
jmp 0xc9422
cmpq $0x0, -0x48(%rbp)
jne 0xc9525
movq -0x10(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0xc9490
movl $0x18, %edi
callq 0xcc420
movq %rax, %rcx
movq -0x10(%rbp), %rax
movq %rcx, 0x18(%rax)
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0xcc4c0
movq %rax, -0x48(%rbp)
cmpq $0x0, %rax
jne 0xc94b3
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0xc957e
movq -0x48(%rbp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x4250
cmpq $0x0, -0x50(%rbp)
jne 0xc94db
movq -0x48(%rbp), %rax
movq -0x38(%rbp), %rcx
movq %rax, (%rcx)
movq %rax, -0x48(%rbp)
jmp 0xc94eb
movq -0x48(%rbp), %rax
movq -0x50(%rbp), %rcx
movq %rax, 0x8(%rcx)
movq %rax, -0x48(%rbp)
movl -0x24(%rbp), %edx
movq -0x48(%rbp), %rax
movl 0x14(%rax), %ecx
andl $0xffffff, %edx         # imm = 0xFFFFFF
shll $0x8, %edx
andl $0xff, %ecx
orl %edx, %ecx
movl %ecx, 0x14(%rax)
movzbl -0x39(%rbp), %edx
movq -0x48(%rbp), %rax
movl 0x14(%rax), %ecx
andl $0xff, %edx
andl $0xffffff00, %ecx       # imm = 0xFFFFFF00
orl %edx, %ecx
movl %ecx, 0x14(%rax)
movq -0x48(%rbp), %rax
movq %rax, -0x38(%rbp)
movzbl -0x39(%rbp), %edx
movq -0x38(%rbp), %rax
movl 0x14(%rax), %ecx
andl $0xff, %edx
andl $0xffffff00, %ecx       # imm = 0xFFFFFF00
orl %edx, %ecx
movl %ecx, 0x14(%rax)
movq -0x38(%rbp), %rax
movl 0x10(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x10(%rax)
jmp 0xc93a2
jmp 0xc955d
movq -0x30(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x30(%rbp)
movl -0x28(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x28(%rbp)
jmp 0xc937b
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw (%rax,%rax)