// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/regidx.c
// Function: regidx_init_string
regidx_t *regidx_init_string(const char *str, regidx_parse_f parser, regidx_free_f free_f, size_t payload_size, void *usr_dat)
{
    kstring_t tmp = KS_INITIALIZE;
    regidx_t *idx = (regidx_t*) calloc(1,sizeof(regidx_t));
    if ( !idx ) return NULL;

    idx->free  = free_f;
    idx->parse = parser ? parser : regidx_parse_tab;
    idx->usr   = usr_dat;
    idx->seq2regs = khash_str2int_init();
    if (!idx->seq2regs) goto fail;
    idx->payload_size = payload_size;
    if ( payload_size ) {
        idx->payload = malloc(payload_size);
        if (!idx->payload) goto fail;
    }

    const char *ss = str;
    while ( *ss )
    {
        while ( *ss && isspace_c(*ss) ) ss++;
        const char *se = ss;
        while ( *se && *se!='\r' && *se!='\n' ) se++;
        if (kputsn(ss, se-ss, ks_clear(&tmp)) < 0) goto fail;
        if (regidx_insert(idx, tmp.s) < 0) goto fail;
        while ( *se && isspace_c(*se) ) se++;
        ss = se;
    }
    ks_free(&tmp);
    return idx;

 fail:
    regidx_destroy(idx);
    ks_free(&tmp);
    return NULL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %r8, %r12
movq %rcx, %rbx
movq %rdx, %rbp
movq %rsi, %r13
movq %rdi, %r15
movl $0x1, %edi
movl $0x60, %esi
callq 0x4300
testq %rax, %rax
je 0x20c91
movq %rax, %r14
movq %rbp, 0x20(%rax)
testq %r13, %r13
leaq 0x1b8(%rip), %rax       # 0x20cbd
cmovneq %r13, %rax
movq %rax, 0x28(%r14)
movq %r12, 0x30(%r14)
movl $0x1, %edi
movl $0x28, %esi
callq 0x4300
movq %rax, 0x10(%r14)
testq %rax, %rax
movq %r14, %r12
je 0x20c96
movl %ebx, 0x38(%r12)
testq %rbx, %rbx
je 0x20b50
movq %rbx, %rdi
callq 0x4680
movq %rax, 0x40(%r12)
testq %rax, %rax
je 0x20c96
movq $0x0, 0x10(%rsp)
movl $0x2401, %r13d          # imm = 0x2401
xorl %ebp, %ebp
movq %r12, 0x8(%rsp)
cmpb $0x0, (%r15)
je 0x20ca3
movb (%r15), %bl
testb %bl, %bl
je 0x20b94
callq 0x4510
movq (%rax), %rax
movzbl %bl, %ecx
testb $0x20, 0x1(%rax,%rcx,2)
je 0x20b94
movb 0x1(%r15), %bl
incq %r15
testb %bl, %bl
jne 0x20b7f
movl $0x2, %ebx
movq %r15, %r14
movzbl (%r14), %eax
cmpl $0xd, %eax
ja 0x20bab
btl %eax, %r13d
jb 0x20bb3
incq %r14
incq %rbx
jmp 0x20b9c
testq %rbx, %rbx
je 0x20c1c
movq 0x10(%rsp), %r12
cmpq %rbx, %r12
jae 0x20bf5
movq %rbx, %rax
shrq $0x3e, %rax
movq %rbx, %rcx
shrq %rcx
testq %rax, %rax
movl $0x0, %r12d
cmoveq %rcx, %r12
addq %rbx, %r12
movq %rbp, %rdi
movq %r12, %rsi
callq 0x4840
movq %rbp, %rcx
movq %rax, %rbp
testq %rax, %rax
je 0x20c2c
leaq -0x2(%rbx), %r13
movq %rbp, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x43c0
movb $0x0, -0x2(%rbp,%rbx)
shrl $0x1f, %r13d
movq %r12, 0x10(%rsp)
movq 0x8(%rsp), %r12
jmp 0x20c37
callq 0x4050
movl $0x4b, (%rax)
movb $0x1, %r13b
jmp 0x20c37
movb $0x1, %r13b
movq 0x8(%rsp), %r12
movq %rcx, %rbp
testb %r13b, %r13b
jne 0x20c7f
movq %r12, %rdi
movq %rbp, %rsi
callq 0x2042f
testl %eax, %eax
js 0x20c7f
movq %rbp, %r13
movb (%r14), %bpl
movb $0x1, %bl
testb %bpl, %bpl
je 0x20c77
callq 0x4510
movq (%rax), %rax
movzbl %bpl, %ecx
testb $0x20, 0x1(%rax,%rcx,2)
je 0x20c77
movb 0x1(%r14), %bpl
incq %r14
testb %bpl, %bpl
jne 0x20c60
movq %r14, %r15
movq %r13, %rbp
jmp 0x20c81
xorl %ebx, %ebx
testb %bl, %bl
movl $0x2401, %r13d          # imm = 0x2401
jne 0x20b66
jmp 0x20c98
xorl %r12d, %r12d
jmp 0x20cab
xorl %ebp, %ebp
movq %r12, %rdi
callq 0x20e99
xorl %r12d, %r12d
movq %rbp, %rdi
callq 0x45c0
movq %r12, %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq