// File: /workspace/github_c_makefile_star2_O1/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, %rbx
movq %rdx, %rbp
movq %rsi, %r13
movq %rdi, %r15
cmpq $0x0, 0x88(%rdi)
jne 0x2aeb0
movl $0x1, %edi
movl $0x28, %esi
callq 0x42f0
movq %rax, 0x88(%r15)
movq 0x88(%r15), %rdx
movb $0x1, %al
testq %rdx, %rdx
je 0x2af07
movl (%rdx), %ecx
testl %ecx, %ecx
je 0x2af0c
movq %rbx, 0x30(%rsp)
movq %rcx, 0x18(%rsp)
leal -0x1(%rcx), %esi
movb (%r13), %cl
testb %cl, %cl
movq %rbp, 0x28(%rsp)
movq %r15, 0x20(%rsp)
movq %r13, 0x8(%rsp)
je 0x2af14
leaq 0x1(%r13), %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 0x2aef1
jmp 0x2af19
jmp 0x2afcb
xorl %r12d, %r12d
jmp 0x2afb9
movl $0x811c9dc5, %ebx       # imm = 0x811C9DC5
andl %esi, %ebx
movq 0x10(%rdx), %rdi
movl $0x1, %r15d
movl %ebx, %r12d
movl %esi, 0x14(%rsp)
movq %rdi, 0x38(%rsp)
movl %r12d, %eax
shrl $0x4, %eax
movl (%rdi,%rax,4), %r14d
leal (%r12,%r12), %ebp
andl $0x1e, %ebp
movl %r14d, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x2af91
testb $0x1, %al
jne 0x2af79
movq 0x18(%rdx), %rax
movl %r12d, %ecx
movq (%rax,%rcx,8), %rdi
movq 0x8(%rsp), %rsi
movq %rdx, %r13
callq 0x46f0
movq 0x38(%rsp), %rdi
movl 0x14(%rsp), %esi
movq %r13, %rdx
testl %eax, %eax
je 0x2af91
addl %r15d, %r12d
andl %esi, %r12d
incl %r15d
cmpl %ebx, %r12d
jne 0x2af31
movq 0x18(%rsp), %rcx
movl %ecx, %r12d
jmp 0x2afa3
movl %ebp, %ecx
shrl %cl, %r14d
testb $0x3, %r14b
movq 0x18(%rsp), %rcx
cmovnel %ecx, %r12d
movq 0x30(%rsp), %rbx
movq 0x28(%rsp), %rbp
movq 0x20(%rsp), %r15
movq 0x8(%rsp), %r13
movb $0x1, %al
cmpl %ecx, %r12d
je 0x2afcb
movq 0x20(%rdx), %rax
movl %r12d, %ecx
movl (%rax,%rcx,4), %r14d
xorl %eax, %eax
testb %al, %al
je 0x2b09d
movslq 0x98(%r15), %r14
leaq 0x1(%r14), %rax
movl %eax, 0x98(%r15)
movq 0x90(%r15), %rdi
leaq 0x8(,%r14,8), %rsi
callq 0x4870
movq %rax, 0x90(%r15)
movq 0x80(%r15), %rdi
movslq 0x98(%r15), %rax
shlq $0x3, %rax
leaq (%rax,%rax,2), %rsi
callq 0x4870
movq %rax, 0x80(%r15)
movslq 0x98(%r15), %rcx
leaq (%rcx,%rcx,2), %rcx
xorps %xmm0, %xmm0
movups %xmm0, -0x18(%rax,%rcx,8)
movq $0x0, -0x8(%rax,%rcx,8)
movq %r13, %rdi
callq 0x4950
movq 0x90(%r15), %rcx
movq %rax, (%rcx,%r14,8)
movq 0x80(%r15), %rax
leaq (%r14,%r14,2), %rcx
movl $0xffffffff, 0x10(%rax,%rcx,8) # imm = 0xFFFFFFFF
movq 0x88(%r15), %r12
testq %r12, %r12
je 0x2b09d
movq 0x90(%r15), %rax
movq (%rax,%r14,8), %rsi
leaq 0x44(%rsp), %r13
movq %r12, %rdi
movq %r13, %rdx
callq 0x2d3e5
cmpl $0x0, (%r13)
js 0x2b09d
movq 0x20(%r12), %rcx
movl %eax, %eax
movl %r14d, (%rcx,%rax,4)
movq 0x80(%r15), %rax
movslq %r14d, %rcx
leaq (%rcx,%rcx,2), %rcx
leaq (%rax,%rcx,8), %r15
movl 0x8(%r15), %eax
movslq 0xc(%r15), %rsi
cmpl %esi, %eax
jl 0x2b0ec
leal 0x1(%rax), %ecx
testl %eax, %eax
movl $0x1, %edi
cmovnsl %ecx, %edi
leaq 0x8a1d5(%rip), %rax     # 0xb52a4
movq %rax, (%rsp)
movl $0x4, %edx
movl $0x10, %ecx
xorl %r8d, %r8d
movq %r15, %r9
callq 0x11efc
movl %eax, 0xc(%r15)
movq %rbx, %rax
andq %rbp, %rax
decq %rbp
decq %rbx
xorl %ecx, %ecx
cmpq $-0x1, %rax
cmovneq %rbp, %rcx
movabsq $0xffffffffffe, %rax    # imm = 0xFFFFFFFFFFE
cmovneq %rbx, %rax
movq (%r15), %rdx
movslq 0x8(%r15), %rsi
leal 0x1(%rsi), %edi
shlq $0x4, %rsi
movq %rcx, (%rdx,%rsi)
movq %rax, 0x8(%rdx,%rsi)
movl %edi, 0x8(%r15)
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq