// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/annot-tsv.c
// Function: init_data
void init_data(args_t *args)
{
    if ( !args->delim_str )
        args->dst.delim = args->src.delim = '\t';
    else if ( strlen(args->delim_str)==1 )
        args->dst.delim = args->src.delim = *args->delim_str;
    else if ( strlen(args->delim_str)==3 && args->delim_str[1]==':' )
        args->src.delim = args->delim_str[0], args->dst.delim = args->delim_str[2];
    else
        error("Could not parse the option --delim %s\n",args->delim_str);

    // --headers, determine header row index
    int isrc = 0, idst = 0, autodetect = 1;
    if ( args->headers_str )
    {
        cols_t *tmp = cols_split(args->headers_str, NULL, ':');
        char *rmme;
        isrc = strtol(tmp->off[0],&rmme,10);
        if ( *rmme || tmp->off[0]==rmme ) error("Could not parse the option --headers %s\n",args->headers_str);
        idst = strtol(tmp->n==2 ? tmp->off[1] : tmp->off[0],&rmme,10);
        if ( *rmme || (tmp->n==2 ? tmp->off[1] : tmp->off[0])==rmme ) error("Could not parse the option --headers %s\n",args->headers_str);
        cols_destroy(tmp);
        autodetect = 0;
    }
    parse_header(&args->dst, args->dst.fname, idst, autodetect);
    parse_header(&args->src, args->src.fname, isrc, autodetect);

    // -c, core columns
    if ( !args->core_str ) args->core_str = "chr,beg,end:chr,beg,end";
    cols_t *tmp = cols_split(args->core_str, NULL, ':');
    args->src.core = cols_split(tmp->off[0],NULL,',');
    args->dst.core = cols_split(tmp->n==2 ? tmp->off[1] : tmp->off[0],NULL,',');
    sanity_check_columns(args->src.fname, &args->src.hdr, args->src.core, &args->src.core_idx, 0);
    sanity_check_columns(args->dst.fname, &args->dst.hdr, args->dst.core, &args->dst.core_idx, 0);
    if ( args->src.core->n!=3 || args->dst.core->n!=3 ) error("Expected three columns: %s\n", args->core_str);
    cols_destroy(tmp);

    // -C, --coordinates, 0 or 1-based
    if ( !args->coords_str ) args->coords_str = ":";
    tmp = cols_split(args->coords_str, NULL, ':');
    parse_coor_base(args, tmp->off[0], &args->src);
    parse_coor_base(args, tmp->n==2 ? tmp->off[1] : tmp->off[0], &args->dst);
    cols_destroy(tmp);

    // -m, match columns
    if ( args->match_str )
    {
        tmp = cols_split(args->match_str, NULL, ':');
        args->src.match = cols_split(tmp->off[0],NULL,',');
        args->dst.match = cols_split(tmp->n==2 ? tmp->off[1] : tmp->off[0],NULL,',');
        sanity_check_columns(args->src.fname, &args->src.hdr, args->src.match, &args->src.match_idx, 0);
        sanity_check_columns(args->dst.fname, &args->dst.hdr, args->dst.match, &args->dst.match_idx, 0);
        if ( args->src.match->n != args->dst.match->n ) error("Expected equal number of columns: %s\n", args->match_str);
        cols_destroy(tmp);
    }

    // -t, transfer columns
    int i;
    if ( args->transfer_str )
    {
        tmp = cols_split(args->transfer_str, NULL, ':');
        args->src.transfer = cols_split(tmp->off[0],NULL,',');
        args->dst.transfer = cols_split(tmp->n==2 ? tmp->off[1] : tmp->off[0],NULL,',');
        sanity_check_columns(args->src.fname, &args->src.hdr, args->src.transfer, &args->src.transfer_idx, 1);
        sanity_check_columns(args->dst.fname, &args->dst.hdr, args->dst.transfer, &args->dst.transfer_idx, 1);
        if ( args->src.transfer->n != args->dst.transfer->n ) error("Expected equal number of columns: %s\n", args->transfer_str);
        for (i=0; i<args->src.transfer->n; i++)
        {
            if ( args->src.transfer_idx[i]==-1 )
            {
                cols_append(args->src.hdr.cols,args->src.transfer->off[i]);
                args->src.transfer_idx[i] = -args->src.hdr.cols->n;    // negative index indicates different ptr location
                args->src.grow_n++;
            }
        }
        for (i=0; i<args->dst.transfer->n; i++)
        {
            if ( args->dst.transfer_idx[i]==-1 )
            {
                cols_append(args->dst.hdr.cols,args->dst.transfer->off[i]);
                args->dst.transfer_idx[i] = args->dst.hdr.cols->n - 1;
                args->dst.grow_n++;
            }
        }
        args->tmp_cols = (cols_t*)calloc(args->src.transfer->n,sizeof(cols_t));
        args->tmp_hash = (khash_t(str2int)**)calloc(args->src.transfer->n,sizeof(khash_t(str2int)*));
        if ( !args->tmp_cols || !args->tmp_hash ) error("Out of memory\n");
        for (i=0; i<args->src.transfer->n; i++)
            args->tmp_hash[i] = khash_str2int_init();
        cols_destroy(tmp);
    }
    else
    {
        args->src.transfer = calloc(1,sizeof(*args->src.transfer));
        if ( !args->src.transfer ) error("Out of memory\n");
    }
    args->src.nannots_added = calloc(args->src.transfer->n,sizeof(*args->src.nannots_added));
    if ( !args->src.nannots_added ) error("Out of memory\n");

    // -a, annotation columns
    if ( args->annots_str )
    {
        tmp = cols_split(args->annots_str, NULL, ':');
        args->src.annots = cols_split(tmp->off[0],NULL,',');
        args->dst.annots = cols_split(tmp->n==2 ? tmp->off[1] : tmp->off[0],NULL,',');
        if ( args->src.annots->n!=args->dst.annots->n ) error("Different number of src and dst columns in %s\n",args->annots_str);
        args->dst.annots_idx = (int*) malloc(sizeof(int)*args->dst.annots->n);
        if ( !args->dst.annots_idx ) error("Out of memory\n");
        for (i=0; i<args->src.annots->n; i++)
        {
            if ( !strcasecmp(args->src.annots->off[i],"nbp") )
            {
                args->dst.annots_idx[i] = ANN_NBP;
                cols_append(args->dst.hdr.cols,tmp->n==2?args->dst.annots->off[i]:"nbp");
            }
            else if ( !strcasecmp(args->src.annots->off[i],"frac") )
            {
                args->dst.annots_idx[i] = ANN_FRAC;
                cols_append(args->dst.hdr.cols,tmp->n==2?args->dst.annots->off[i]:"frac");
            }
            else if ( !strcasecmp(args->src.annots->off[i],"cnt") )
            {
                args->dst.annots_idx[i] = ANN_CNT;
                cols_append(args->dst.hdr.cols,tmp->n==2?args->dst.annots->off[i]:"cnt");
            }
            else error("The annotation \"%s\" is not recognised\n", args->src.annots->off[i]);
        }
        args->nbp = nbp_init();
        cols_destroy(tmp);
    }

    args->idx = regidx_init(NULL, parse_tab_with_payload,free_payload,sizeof(cols_t),&args->src);
    while ( read_next_line(&args->src) )
    {
        if ( regidx_insert(args->idx,args->src.line.s) !=0 ) error("Could not parse the region in %s: %s\n",args->src.fname,args->src.line.s);
        args->src.line.l = 0;
    }
    args->itr = regitr_init(args->idx);
    if ( hts_close(args->src.fp)!=0 ) error("Failed to close: %s\n", args->src.fname);

    int len = args->out_fname ? strlen(args->out_fname) : 0;
    if ( len )
    {
        int compress_output = 0;
        if ( !strcasecmp(".gz",args->out_fname+len-3) || !strcasecmp(".bgz",args->out_fname+len-4) ) compress_output = 1;
        args->out_fp = bgzf_open(args->out_fname, compress_output ? "wg" : "wu");
    }
    else
        args->out_fp = bgzf_open("-","wu");
    if ( !args->out_fp ) error("Could not open file for writing: %s\n",args->out_fname?args->out_fname:"stdout");
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
movq 0x178(%rdi), %r14
testq %r14, %r14
je 0x6b02
movq %r14, %rdi
callq 0x41d0
cmpq $0x3, %rax
je 0x6b0d
cmpq $0x1, %rax
jne 0x72d4
movb (%r14), %al
movb %al, 0x120(%rbx)
jmp 0x6b25
movb $0x9, 0x120(%rbx)
movb $0x9, %al
jmp 0x6b25
cmpb $0x3a, 0x1(%r14)
jne 0x72d4
movb (%r14), %al
movb %al, 0x120(%rbx)
movb 0x2(%r14), %al
movb %al, 0x80(%rbx)
movq 0x170(%rbx), %rdi
testq %rdi, %rdi
je 0x6bcc
pushq $0x3a
popq %rdx
xorl %esi, %esi
callq 0x5abc
movq %rax, %r14
movq 0x8(%rax), %rax
movq (%rax), %rdi
leaq 0x10(%rsp), %r12
pushq $0xa
popq %rdx
movq %r12, %rsi
callq 0x46d0
movq (%r12), %rcx
cmpb $0x0, (%rcx)
jne 0x728a
movq %rax, %r15
movq 0x8(%r14), %rax
movq (%rax), %rdi
cmpq %rcx, %rdi
je 0x728a
cmpl $0x2, (%r14)
jne 0x6b89
movq 0x8(%rax), %rdi
leaq 0x10(%rsp), %r13
pushq $0xa
popq %rdx
movq %r13, %rsi
callq 0x46d0
movq %rax, %r12
movq (%r13), %rax
cmpb $0x0, (%rax)
jne 0x728a
xorl %ecx, %ecx
cmpl $0x2, (%r14)
sete %cl
movq 0x8(%r14), %rdx
cmpq %rax, (%rdx,%rcx,8)
je 0x728a
movq %r14, %rdi
callq 0x5df6
xorl %ebp, %ebp
jmp 0x6bd5
xorl %r12d, %r12d
pushq $0x1
popq %rbp
xorl %r15d, %r15d
leaq 0x8(%rbx), %r13
movq 0x8(%rbx), %rsi
movq %r13, %rdi
movl %r12d, %edx
movl %ebp, %ecx
callq 0x5fc2
leaq 0xa8(%rbx), %rdi
movq 0xa8(%rbx), %rsi
movq %rdi, (%rsp)
movl %r15d, %edx
movl %ebp, %ecx
callq 0x5fc2
movq 0x148(%rbx), %rdi
testq %rdi, %rdi
jne 0x6c20
leaq 0x6e822(%rip), %rdi     # 0x7543b
movq %rdi, 0x148(%rbx)
pushq $0x3a
popq %rdx
xorl %esi, %esi
callq 0x5abc
movq %rax, %rbp
movq 0x8(%rax), %rax
movq (%rax), %rdi
pushq $0x2c
popq %r14
xorl %esi, %esi
movl %r14d, %edx
callq 0x5abc
movq %rax, 0xd0(%rbx)
xorl %eax, %eax
cmpl $0x2, (%rbp)
sete %al
movq 0x8(%rbp), %rcx
movq (%rcx,%rax,8), %rdi
xorl %esi, %esi
movl %r14d, %edx
callq 0x5abc
movq %rax, 0x30(%rbx)
leaq 0xb0(%rbx), %r15
movq 0xa8(%rbx), %rdi
movq 0xd0(%rbx), %rdx
leaq 0xf0(%rbx), %rcx
movq %r15, %rsi
xorl %r8d, %r8d
callq 0x692a
leaq 0x10(%rbx), %r12
movq 0x8(%rbx), %rdi
movq 0x30(%rbx), %rdx
leaq 0x50(%rbx), %rcx
movq %r12, %rsi
xorl %r8d, %r8d
callq 0x692a
movq 0xd0(%rbx), %rax
cmpl $0x3, (%rax)
jne 0x729a
movq 0x30(%rbx), %rax
cmpl $0x3, (%rax)
jne 0x729a
movq %rbp, %rdi
callq 0x5df6
movq 0x150(%rbx), %rdi
testq %rdi, %rdi
jne 0x6ce9
leaq 0x710a1(%rip), %rdi     # 0x77d83
movq %rdi, 0x150(%rbx)
pushq $0x3a
popq %rdx
xorl %esi, %esi
callq 0x5abc
movq %rax, %r14
movq 0x8(%rax), %rax
movq (%rax), %rsi
movq %rbx, %rdi
movq (%rsp), %rdx
callq 0x69eb
xorl %eax, %eax
cmpl $0x2, (%r14)
sete %al
movq 0x8(%r14), %rcx
movq (%rcx,%rax,8), %rsi
movq %rbx, %rdi
movq %r13, %rdx
callq 0x69eb
movq %r14, %rdi
callq 0x5df6
movq 0x158(%rbx), %rdi
testq %rdi, %rdi
je 0x6dd7
pushq $0x3a
popq %rdx
xorl %esi, %esi
callq 0x5abc
movq %rax, %r13
movq 0x8(%rax), %rax
movq (%rax), %rdi
pushq $0x2c
popq %rbp
xorl %esi, %esi
movl %ebp, %edx
callq 0x5abc
movq %rax, 0xd8(%rbx)
xorl %eax, %eax
cmpl $0x2, (%r13)
sete %al
movq 0x8(%r13), %rcx
movq (%rcx,%rax,8), %rdi
xorl %esi, %esi
movl %ebp, %edx
callq 0x5abc
movq %rax, 0x38(%rbx)
movq 0xa8(%rbx), %rdi
movq 0xd8(%rbx), %rdx
leaq 0xf8(%rbx), %rcx
movq %r15, %rsi
xorl %r8d, %r8d
callq 0x692a
movq 0x8(%rbx), %rdi
movq 0x38(%rbx), %rdx
leaq 0x58(%rbx), %rcx
movq %r12, %rsi
xorl %r8d, %r8d
callq 0x692a
movq 0x38(%rbx), %rax
movq 0xd8(%rbx), %rcx
movl (%rcx), %ecx
cmpl (%rax), %ecx
jne 0x72dd
movq %r13, %rdi
callq 0x5df6
movq 0x160(%rbx), %rdi
testq %rdi, %rdi
je 0x6fa6
xorl %r13d, %r13d
pushq $0x3a
popq %rdx
xorl %esi, %esi
callq 0x5abc
movq %rax, %r14
movq 0x8(%rax), %rax
movq (%rax), %rdi
pushq $0x2c
popq %rbp
xorl %esi, %esi
movl %ebp, %edx
callq 0x5abc
movq %rax, 0xe0(%rbx)
xorl %eax, %eax
cmpl $0x2, (%r14)
sete %al
movq %r14, 0x8(%rsp)
movq 0x8(%r14), %rcx
movq (%rcx,%rax,8), %rdi
xorl %esi, %esi
movl %ebp, %edx
callq 0x5abc
movq %rax, 0x40(%rbx)
movq 0xa8(%rbx), %rdi
movq 0xe0(%rbx), %rdx
leaq 0x100(%rbx), %rbp
pushq $0x1
popq %r14
movq %r15, %rsi
movq %rbp, %rcx
movl %r14d, %r8d
callq 0x692a
movq 0x8(%rbx), %rdi
movq 0x40(%rbx), %rdx
leaq 0x60(%rbx), %r15
movq %r12, %rsi
movq %r15, %rcx
movl %r14d, %r8d
callq 0x692a
movq 0x40(%rbx), %rdx
movq 0xe0(%rbx), %rax
movl (%rax), %ecx
cmpl (%rdx), %ecx
je 0x6ed9
movq 0x160(%rbx), %rsi
jmp 0x72e4
movq (%rbp), %rdx
cmpl $-0x1, (%rdx,%r13,4)
jne 0x6ed6
movq 0xb8(%rbx), %rdi
movq 0x8(%rax), %rax
movq (%rax,%r13,8), %rsi
callq 0x5c50
movq 0xb8(%rbx), %rax
movq 0x100(%rbx), %rcx
xorl %edx, %edx
subl (%rax), %edx
movl %edx, (%rcx,%r13,4)
incl 0x124(%rbx)
movq 0xe0(%rbx), %rax
movl (%rax), %ecx
incq %r13
movl %ecx, %edx
cmpq %rdx, %r13
jb 0x6e92
xorl %r14d, %r14d
movq 0x40(%rbx), %rax
movl (%rax), %ecx
cmpq %rcx, %r14
jae 0x6f24
movq (%r15), %rcx
cmpl $-0x1, (%rcx,%r14,4)
jne 0x6f1f
movq 0x18(%rbx), %rdi
movq 0x8(%rax), %rax
movq (%rax,%r14,8), %rsi
callq 0x5c50
movq 0x18(%rbx), %rax
movq 0x60(%rbx), %rcx
movl (%rax), %eax
decl %eax
movl %eax, (%rcx,%r14,4)
incl 0x84(%rbx)
incq %r14
jmp 0x6ee3
movq 0xe0(%rbx), %rax
movl (%rax), %r15d
pushq $0x18
popq %rsi
movq %r15, %rdi
callq 0x4300
movq %rax, %r14
movq %rax, 0x1e8(%rbx)
pushq $0x8
popq %rsi
movq %r15, %rdi
callq 0x4300
movq %rax, 0x1f0(%rbx)
testq %r14, %r14
je 0x727c
testq %rax, %rax
je 0x727c
xorl %r14d, %r14d
movl %r15d, %eax
cmpq %rax, %r14
jae 0x6f91
callq 0x6545
movq 0x1f0(%rbx), %rcx
movq %rax, (%rcx,%r14,8)
incq %r14
movq 0xe0(%rbx), %rax
movl (%rax), %r15d
jmp 0x6f6a
movq 0x8(%rsp), %rdi
callq 0x5df6
movq 0xe0(%rbx), %rax
movl (%rax), %edi
jmp 0x6fc3
pushq $0x1
popq %rdi
pushq $0x18
popq %rsi
callq 0x4300
movq %rax, 0xe0(%rbx)
testq %rax, %rax
je 0x727c
xorl %edi, %edi
movq (%rsp), %r14
pushq $0x4
popq %rsi
callq 0x4300
movq %rax, 0x110(%rbx)
testq %rax, %rax
je 0x727c
movq 0x168(%rbx), %rdi
testq %rdi, %rdi
je 0x714e
pushq $0x3a
popq %rdx
xorl %esi, %esi
callq 0x5abc
movq %rax, %r15
movq 0x8(%rax), %rax
movq (%rax), %rdi
pushq $0x2c
popq %rbp
xorl %esi, %esi
movl %ebp, %edx
callq 0x5abc
movq %rax, 0xe8(%rbx)
xorl %eax, %eax
cmpl $0x2, (%r15)
sete %al
movq 0x8(%r15), %rcx
movq (%rcx,%rax,8), %rdi
xorl %esi, %esi
movl %ebp, %edx
callq 0x5abc
movq %rax, 0x48(%rbx)
movq 0xe8(%rbx), %r14
movl (%r14), %r13d
cmpl (%rax), %r13d
jne 0x72ed
leaq (,%r13,4), %rdi
callq 0x4680
movq %rax, 0x68(%rbx)
testq %rax, %rax
je 0x727c
xorl %ebp, %ebp
leaq 0x6e45a(%rip), %r12     # 0x754c4
movl %r13d, %eax
cmpq %rax, %rbp
jae 0x712b
movq 0x8(%r14), %rax
movq (%rax,%rbp,8), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x4520
testl %eax, %eax
je 0x70ca
movq %r14, %rdi
leaq 0x6e431(%rip), %r13     # 0x754c8
movq %r13, %rsi
callq 0x4520
testl %eax, %eax
je 0x70f0
movq %r14, %rdi
leaq 0x6e420(%rip), %r13     # 0x754cd
movq %r13, %rsi
callq 0x4520
testl %eax, %eax
jne 0x726d
movq 0x68(%rbx), %rax
movl $0x4, (%rax,%rbp,4)
jmp 0x70fb
movq 0x68(%rbx), %rax
movl $0x1, (%rax,%rbp,4)
cmpl $0x2, (%r15)
movq %r12, %rsi
jne 0x70ea
movq 0x48(%rbx), %rax
movq 0x8(%rax), %rax
movq (%rax,%rbp,8), %rsi
movq 0x18(%rbx), %rdi
jmp 0x7114
movq 0x68(%rbx), %rax
movl $0x2, (%rax,%rbp,4)
cmpl $0x2, (%r15)
jne 0x710d
movq 0x48(%rbx), %rax
movq 0x8(%rax), %rax
movq (%rax,%rbp,8), %r13
movq 0x18(%rbx), %rdi
movq %r13, %rsi
callq 0x5c50
incq %rbp
movq 0xe8(%rbx), %r14
movl (%r14), %r13d
jmp 0x706a
pushq $0x1
popq %rdi
pushq $0x28
popq %rsi
callq 0x4300
testq %rax, %rax
je 0x72fd
movq %rax, (%rbx)
movq %r15, %rdi
callq 0x5df6
movq (%rsp), %r14
leaq -0x1347(%rip), %rsi     # 0x5e0e
leaq -0x11a2(%rip), %rdx     # 0x5fba
pushq $0x18
popq %rcx
xorl %edi, %edi
movq %r14, %r8
callq 0x1bea2
movq %rax, 0x1c0(%rbx)
movq %r14, %rdi
callq 0x730e
movq 0x1c0(%rbx), %rdi
testl %eax, %eax
je 0x71a1
movq 0x138(%rbx), %rsi
callq 0x1b57a
testl %eax, %eax
jne 0x7251
andq $0x0, 0x128(%rbx)
jmp 0x7170
callq 0x1c774
movq %rax, 0x1c8(%rbx)
movq 0x140(%rbx), %rdi
callq 0x1239d
testl %eax, %eax
jne 0x72aa
movq 0x188(%rbx), %r14
testq %r14, %r14
je 0x7217
movq %r14, %rdi
callq 0x41d0
testl %eax, %eax
je 0x7217
movslq %eax, %r15
leaq (%r14,%r15), %rsi
addq $-0x3, %rsi
leaq 0x7107b(%rip), %rdi     # 0x78266
callq 0x4520
testl %eax, %eax
je 0x7227
addq %r14, %r15
addq $-0x4, %r15
leaq 0x71d3b(%rip), %rdi     # 0x78f3d
movq %r15, %rsi
callq 0x4520
testl %eax, %eax
je 0x7227
leaq 0x6e321(%rip), %rsi     # 0x75536
jmp 0x722e
leaq 0x72c14(%rip), %rdi     # 0x79e32
leaq 0x6e311(%rip), %rsi     # 0x75536
jmp 0x7231
leaq 0x6e305(%rip), %rsi     # 0x75533
movq %r14, %rdi
callq 0x9596
movq %rax, 0x190(%rbx)
testq %rax, %rax
je 0x72b6
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xa8(%rbx), %rsi
movq 0x138(%rbx), %rdx
leaq 0x6e292(%rip), %rdi     # 0x754f8
xorl %eax, %eax
callq 0x5b9e
leaq 0x6e25d(%rip), %rdi     # 0x754d1
movq %r14, %rsi
jmp 0x7307
leaq 0x6df5a(%rip), %rdi     # 0x751dd
xorl %eax, %eax
callq 0x5b9e
movq 0x170(%rbx), %rsi
leaq 0x6e17a(%rip), %rdi     # 0x75412
jmp 0x7307
movq 0x148(%rbx), %rsi
leaq 0x6e1ab(%rip), %rdi     # 0x75453
jmp 0x7307
movq (%r14), %rsi
leaq 0x6e26a(%rip), %rdi     # 0x7551e
jmp 0x7307
movq 0x188(%rbx), %rax
testq %rax, %rax
leaq 0x6e297(%rip), %rsi     # 0x7555e
cmovneq %rax, %rsi
leaq 0x6e267(%rip), %rdi     # 0x75539
jmp 0x7307
leaq 0x6e110(%rip), %rdi     # 0x753eb
jmp 0x7274
movq 0x158(%rbx), %rsi
leaq 0x6e184(%rip), %rdi     # 0x7546f
jmp 0x7307
movq 0x168(%rbx), %rsi
leaq 0x6e19a(%rip), %rdi     # 0x75495
jmp 0x7307
leaq 0x6deac(%rip), %rdi     # 0x751b0
pushq $0x28
popq %rsi
xorl %eax, %eax
callq 0x5b9e