// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/synced_bcf_reader.c
// Function: regions_add
static int _regions_add(bcf_sr_regions_t *reg, const char *chr, hts_pos_t start, hts_pos_t end)
{
    if ( start==-1 && end==-1 )
    {
        start = 0; end = MAX_CSI_COOR-1;
    }
    else
    {
        start--; end--; // store 0-based coordinates
    }

    if ( !reg->seq_hash )
         reg->seq_hash = khash_str2int_init();

    int iseq;
    if ( khash_str2int_get(reg->seq_hash, chr, &iseq)<0 )
    {
        // the chromosome block does not exist
        iseq = reg->nseqs++;
        reg->seq_names = (char**) realloc(reg->seq_names,sizeof(char*)*reg->nseqs);
        reg->regs = (region_t*) realloc(reg->regs,sizeof(region_t)*reg->nseqs);
        memset(&reg->regs[reg->nseqs-1],0,sizeof(region_t));
        reg->seq_names[iseq] = strdup(chr);
        reg->regs[iseq].creg = -1;
        khash_str2int_set(reg->seq_hash,reg->seq_names[iseq],iseq);
    }

    region_t *creg = &reg->regs[iseq];
    hts_expand(region1_t,creg->nregs+1,creg->mregs,creg->regs);
    creg->regs[creg->nregs].start = start;
    creg->regs[creg->nregs].end   = end;
    creg->nregs++;

    return 0; // FIXME: check for errs in this function
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rcx, 0x20(%rsp)
movq %rdx, 0x18(%rsp)
movq 0x88(%rdi), %r13
testq %r13, %r13
movq %rdi, 0x10(%rsp)
movq %rsi, 0x28(%rsp)
je 0x29f5f
movl (%r13), %eax
testl %eax, %eax
je 0x29f7d
movq %rax, 0x30(%rsp)
leal -0x1(%rax), %edi
movb (%rsi), %cl
testb %cl, %cl
je 0x29f87
leaq 0x1(%rsi), %rax
movl $0x811c9dc5, %ebx       # imm = 0x811C9DC5
movzbl %cl, %ecx
xorl %ebx, %ecx
imull $0x1000193, %ecx, %ebx  # imm = 0x1000193
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x29f49
jmp 0x29f8c
movq %rdi, %rbx
movl $0x1, %edi
movl $0x28, %esi
callq 0x42f0
movq %rax, 0x88(%rbx)
jmp 0x2a011
xorl %eax, %eax
xorl %r12d, %r12d
jmp 0x2a008
movl $0x811c9dc5, %ebx       # imm = 0x811C9DC5
andl %edi, %ebx
movq 0x10(%r13), %rsi
movl $0x1, %r14d
movl %ebx, %r12d
movl %edi, 0xc(%rsp)
movq %rsi, 0x38(%rsp)
movl %r12d, %eax
shrl $0x4, %eax
movl (%rsi,%rax,4), %r15d
leal (%r12,%r12), %ebp
andl $0x1e, %ebp
movl %r15d, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x29ff6
testb $0x1, %al
jne 0x29fe6
movq 0x18(%r13), %rax
movl %r12d, %ecx
movq (%rax,%rcx,8), %rdi
movq 0x28(%rsp), %rsi
callq 0x46f0
movq 0x38(%rsp), %rsi
movl 0xc(%rsp), %edi
testl %eax, %eax
je 0x29ff6
addl %r14d, %r12d
andl %edi, %r12d
incl %r14d
cmpl %ebx, %r12d
jne 0x29fa4
jmp 0x2a011
movl %ebp, %ecx
shrl %cl, %r15d
testb $0x3, %r15b
movq 0x30(%rsp), %rax
cmovnel %eax, %r12d
cmpl %eax, %r12d
jne 0x2a0e6
movq 0x10(%rsp), %r14
movl 0x98(%r14), %ebp
movslq %ebp, %rbx
leaq 0x1(%rbx), %rax
movl %eax, 0x98(%r14)
movq 0x90(%r14), %rdi
leaq 0x8(,%rbx,8), %rsi
callq 0x4870
movq %rax, 0x90(%r14)
movq 0x80(%r14), %rdi
movslq 0x98(%r14), %rax
shlq $0x3, %rax
leaq (%rax,%rax,2), %rsi
callq 0x4870
movq %rax, 0x80(%r14)
movslq 0x98(%r14), %rcx
leaq (%rcx,%rcx,2), %rcx
xorps %xmm0, %xmm0
movups %xmm0, -0x18(%rax,%rcx,8)
movq $0x0, -0x8(%rax,%rcx,8)
movq 0x28(%rsp), %rdi
callq 0x4950
movq 0x90(%r14), %rcx
movq %rax, (%rcx,%rbx,8)
movq 0x80(%r14), %rax
leaq (%rbx,%rbx,2), %rcx
movl $0xffffffff, 0x10(%rax,%rcx,8) # imm = 0xFFFFFFFF
movq 0x88(%r14), %r12
testq %r12, %r12
je 0x2a0f6
movq 0x90(%r14), %rax
movq (%rax,%rbx,8), %rsi
leaq 0x44(%rsp), %r13
movq %r12, %rdi
movq %r13, %rdx
callq 0x2c682
cmpl $0x0, (%r13)
js 0x2a0f6
movq 0x20(%r12), %rcx
movl %eax, %eax
movl %ebp, (%rcx,%rax,4)
jmp 0x2a0f6
movq 0x20(%r13), %rax
movl %r12d, %ecx
movslq (%rax,%rcx,4), %rbx
movq 0x10(%rsp), %r14
movq 0x80(%r14), %rax
leaq (%rbx,%rbx,2), %rcx
leaq (%rax,%rcx,8), %r15
movl 0x8(%r15), %eax
movslq 0xc(%r15), %rsi
cmpl %esi, %eax
jl 0x2a146
leal 0x1(%rax), %ecx
testl %eax, %eax
movl $0x1, %edi
cmovnsl %ecx, %edi
leaq 0x8916f(%rip), %rax     # 0xb3294
movq %rax, (%rsp)
movl $0x4, %edx
movl $0x10, %ecx
xorl %r8d, %r8d
movq %r15, %r9
callq 0x11bb5
movl %eax, 0xc(%r15)
movl 0x8(%r15), %eax
movq 0x20(%rsp), %rsi
movq 0x18(%rsp), %rdi
movq %rsi, %rcx
andq %rdi, %rcx
decq %rdi
decq %rsi
xorl %edx, %edx
cmpq $-0x1, %rcx
cmovneq %rdi, %rdx
movabsq $0xffffffffffe, %rcx    # imm = 0xFFFFFFFFFFE
cmovneq %rsi, %rcx
movq (%r15), %rsi
cltq
movq %rax, %rdi
shlq $0x4, %rdi
movq %rdx, (%rsi,%rdi)
movq %rcx, 0x8(%rsi,%rdi)
incl %eax
movl %eax, 0x8(%r15)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq