// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/annot-tsv.c
// Function: main
int main(int argc, char **argv)
{
    args_t *args = (args_t*) calloc(1,sizeof(args_t));
    static struct option loptions[] =
    {
        {"core",required_argument,NULL,'c'},
        {"coords",required_argument,NULL,'C'},
        {"transfer",required_argument,NULL,'f'},
        {"match",required_argument,NULL,'m'},
        {"output",required_argument,NULL,'o'},
        {"source-file",required_argument,NULL,'s'},
        {"target-file",required_argument,NULL,'t'},
        {"allow-dups",no_argument,NULL,0},
        {"max-annots",required_argument,NULL,2},
        {"no-header-idx",required_argument,NULL,'I'},
        {"version",no_argument,NULL,1},
        {"annotate",required_argument,NULL,'a'},
        {"headers",no_argument,NULL,'h'},
        {"ignore-headers",no_argument,NULL,'H'},
        {"overlap",required_argument,NULL,'O'},
        {"reciprocal",no_argument,NULL,'r'},
        {"drop-overlaps",no_argument,NULL,'x'},
        {"delim",required_argument,NULL,'d'},
        {"help",no_argument,NULL,4},
        {NULL,0,NULL,0}
    };
    char *tmp = NULL;
    int c;
    int reciprocal = 0;
    while ((c = getopt_long(argc, argv, "c:C:f:m:o:s:t:a:HO:rxh:Id:",loptions,NULL)) >= 0)
    {
        switch (c)
        {
            case  0 : args->allow_dups = 1; break;
            case  1 :
                printf(
"annot-tsv (htslib) %s\n"
"Copyright (C) 2025 Genome Research Ltd.\n", hts_version());
                return EXIT_SUCCESS;
                break;
            case  2 :
                args->max_annots = strtod(optarg, &tmp);
                if ( tmp==optarg || *tmp ) error("Could not parse --max-annots  %s\n", optarg);
                break;
            case 'I': args->no_write_hdr++; break;
            case 'd': args->delim_str = optarg; break;
            case 'h': args->headers_str = optarg; break;
            case 'H': args->headers_str = "0:0"; break;
            case 'r': reciprocal = 1; break;
            case 'c': args->core_str  = optarg; break;
            case 'C': args->coords_str  = optarg; break;
            case 't': args->dst.fname = optarg; break;
            case 'm': args->match_str = optarg; break;
            case 'a': args->annots_str = optarg; break;
            case 'o': args->out_fname = optarg; break;
            case 'O':
                args->overlap_src = strtod(optarg, &tmp);
                if ( tmp==optarg || (*tmp && *tmp!=',') ) error("Could not parse --overlap %s\n", optarg);
                if ( args->overlap_src<0 || args->overlap_src>1 ) error("Expected value(s) from the interval [0,1]: --overlap %s\n", optarg);
                if ( *tmp )
                {
                    args->overlap_dst = strtod(tmp+1, &tmp);
                    if ( *tmp ) error("Could not parse --overlap %s\n", optarg);
                    if ( args->overlap_dst<0 || args->overlap_dst>1 ) error("Expected value(s) from the interval [0,1]: --overlap %s\n", optarg);
                }
                else
                    args->overlap_either = 1;
                break;
            case 's': args->src.fname = optarg; break;
            case 'f': args->transfer_str = optarg; break;
            case 'x': args->mode = PRINT_NONMATCHING; break;
            case  4 : printf("\nVersion: %s\n%s\n",hts_version(),usage_text()); exit(EXIT_SUCCESS); break;
            case '?': // fall through
            default: error("\nVersion: %s\n%s\n",hts_version(),usage_text()); break;
        }
    }
    if ( argc==1 ) error("\nVersion: %s\n%s\n",hts_version(),usage_text());
    if ( !args->dst.fname && !args->src.fname ) error("Missing the -s and -t options\n");
    if ( !args->dst.fname || !args->src.fname )
    {
        if ( isatty(fileno((FILE *)stdin)) ) error("Missing the %s option\n",args->dst.fname?"-s":"-t");
        // reading from stdin
        if ( !args->dst.fname ) args->dst.fname = "-";
        if ( !args->src.fname ) args->src.fname = "-";
    }
    if ( !args->mode )
    {
        if ( !args->transfer_str && !args->annots_str ) args->mode = PRINT_MATCHING;
        else args->mode = PRINT_MATCHING|PRINT_NONMATCHING;
    }
    if ( (args->transfer_str || args->annots_str) && !(args->mode & PRINT_MATCHING) ) error("The option -x cannot be combined with -f and -a\n");
    if ( reciprocal )
    {
        if ( args->overlap_dst && args->overlap_src && args->overlap_dst!=args->overlap_src )
            error("The combination of --reciprocal with --overlap %f,%f makes no sense: expected single value or identical values\n",args->overlap_src,args->overlap_dst);
        if ( !args->overlap_src )
            args->overlap_src = args->overlap_dst;
        else
            args->overlap_dst = args->overlap_src;
        args->overlap_either = 0;
    }

    init_data(args);
    write_header(args, &args->dst);
    while ( read_next_line(&args->dst) )
    {
        int i;
        for (i=0; i<args->dst.grow_n; i++)
        {
            kputc(args->dst.delim, &args->dst.line);
            kputc('.', &args->dst.line);
        }
        process_line(args, args->dst.line.s, args->dst.line.l);
        args->dst.line.l = 0;
    }
    destroy_data(args);
    free(args);

    return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, %r15
movl %edi, %ebp
movl $0x1, %edi
movl $0x1f8, %esi            # imm = 0x1F8
callq 0x4300
movq %rax, %rbx
movq %rax, 0x8(%rsp)
movq $0x0, (%rsp)
leaq 0x8db3e(%rip), %rdx     # 0x96604
leaq 0xb0a33(%rip), %rcx     # 0xb9500
movl %ebp, %edi
movq %r15, %rsi
xorl %r8d, %r8d
callq 0x4860
testl %eax, %eax
js 0x8d6e
movq $0x0, 0x10(%rsp)
leaq 0x8db12(%rip), %r14     # 0x96604
leaq 0xb0a07(%rip), %r12     # 0xb9500
leaq 0x8d544(%rip), %r13     # 0x96044
cmpl $0x48, %eax
jle 0x8b2d
leal -0x61(%rax), %ecx
cmpl $0x17, %ecx
ja 0x8b71
movslq (%r13,%rcx,4), %rax
addq %r13, %rax
jmpq *%rax
movq 0xb04a2(%rip), %rax     # 0xb8fc0
movq (%rax), %rax
movq %rax, 0x168(%rbx)
jmp 0x8d48
cmpl $0x4, %eax
ja 0x8b53
movl %eax, %eax
leaq 0x8d4f5(%rip), %rcx     # 0x96030
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x1, 0x198(%rbx)
jmp 0x8d48
cmpl $0x43, %eax
je 0x8c6a
cmpl $0x48, %eax
jne 0x9075
leaq 0x8db14(%rip), %rax     # 0x96680
jmp 0x8d11
cmpl $0x49, %eax
je 0x8d36
cmpl $0x4f, %eax
jne 0x9075
movq 0xb0436(%rip), %r14     # 0xb8fc0
movq (%r14), %rdi
movq %rsp, %rsi
callq 0x4350
movsd %xmm0, 0x1b0(%rbx)
movq (%rsp), %rdi
movq (%r14), %rsi
cmpq %rsi, %rdi
je 0x90c9
movzbl (%rdi), %eax
testl %eax, %eax
je 0x8bbd
cmpl $0x2c, %eax
jne 0x90c9
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
ja 0x90dc
ucomisd 0x8d43d(%rip), %xmm0    # 0x96010
ja 0x90dc
testb %al, %al
leaq 0x8da22(%rip), %r14     # 0x96604
je 0x8d3e
incq %rdi
movq %rsp, %rsi
callq 0x4350
movsd %xmm0, 0x1b8(%rbx)
movq (%rsp), %rax
cmpb $0x0, (%rax)
jne 0x90bf
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
ja 0x90d2
ucomisd 0x8d3f2(%rip), %xmm0    # 0x96010
jbe 0x8d48
jmp 0x90d2
movq 0xb0390(%rip), %r14     # 0xb8fc0
movq (%r14), %rdi
movq %rsp, %rsi
callq 0x4350
cvttsd2si %xmm0, %eax
movl %eax, 0x19c(%rbx)
movq (%rsp), %rax
movq (%r14), %rsi
leaq 0x8d9b1(%rip), %r14     # 0x96604
cmpq %rsi, %rax
je 0x9069
cmpb $0x0, (%rax)
je 0x8d48
jmp 0x9069
movq 0xb034f(%rip), %rax     # 0xb8fc0
movq (%rax), %rax
movq %rax, 0x150(%rbx)
jmp 0x8d48
movq 0xb0339(%rip), %rax     # 0xb8fc0
movq (%rax), %rax
movq %rax, 0x188(%rbx)
jmp 0x8d48
movq 0xb0323(%rip), %rax     # 0xb8fc0
movq (%rax), %rax
movq %rax, 0x148(%rbx)
jmp 0x8d48
movl $0x1, %eax
movq %rax, 0x10(%rsp)
jmp 0x8d48
movq 0xb02fe(%rip), %rax     # 0xb8fc0
movq (%rax), %rax
movq %rax, 0x178(%rbx)
jmp 0x8d48
movq 0xb02eb(%rip), %rax     # 0xb8fc0
movq (%rax), %rax
movq %rax, 0xa8(%rbx)
jmp 0x8d48
movq 0xb02d8(%rip), %rax     # 0xb8fc0
movq (%rax), %rax
movq %rax, 0x160(%rbx)
jmp 0x8d48
movq 0xb02c5(%rip), %rax     # 0xb8fc0
movq (%rax), %rax
movq %rax, 0x158(%rbx)
jmp 0x8d48
movq 0xb02b2(%rip), %rax     # 0xb8fc0
movq (%rax), %rax
movq %rax, 0x170(%rbx)
jmp 0x8d48
movq 0xb029f(%rip), %rax     # 0xb8fc0
movq (%rax), %rax
movq %rax, 0x8(%rbx)
jmp 0x8d48
movl $0x2, 0x1a0(%rbx)
jmp 0x8d48
incl 0x1a4(%rbx)
jmp 0x8d48
movl $0x1, 0x1a8(%rbx)
movl %ebp, %edi
movq %r15, %rsi
movq %r14, %rdx
movq %r12, %rcx
xorl %r8d, %r8d
callq 0x4860
testl %eax, %eax
jns 0x8b00
cmpl $0x0, 0x10(%rsp)
sete %r15b
jmp 0x8d71
movb $0x1, %r15b
cmpl $0x1, %ebp
je 0x9075
addq $0x8, 0x8(%rsp)
movq 0x8(%rbx), %rax
testq %rax, %rax
jne 0x8d9c
cmpq $0x0, 0xa8(%rbx)
je 0x9108
testq %rax, %rax
je 0x8da6
cmpq $0x0, 0xa8(%rbx)
jne 0x8df8
movq 0xb0223(%rip), %rax     # 0xb8fd0
movq (%rax), %rdi
callq 0x44f0
movl %eax, %edi
callq 0x48c0
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
testl %eax, %eax
jne 0x90e5
testq %rcx, %rcx
jne 0x8de0
leaq 0x920ec(%rip), %rax     # 0x9aec4
movq 0x8(%rsp), %rcx
movq %rax, (%rcx)
cmpq $0x0, 0xa8(%rbx)
jne 0x8df8
leaq 0x920d3(%rip), %rax     # 0x9aec4
movq %rax, 0xa8(%rbx)
cmpl $0x0, 0x1a0(%rbx)
jne 0x8e24
cmpq $0x0, 0x160(%rbx)
jne 0x8e19
cmpq $0x0, 0x168(%rbx)
je 0x905f
movl $0x3, %eax
movl %eax, 0x1a0(%rbx)
cmpq $0x0, 0x160(%rbx)
jne 0x8e38
cmpq $0x0, 0x168(%rbx)
je 0x8e45
testb $0x1, 0x1a0(%rbx)
je 0x90b6
testb %r15b, %r15b
jne 0x8eaa
movsd 0x1b8(%rbx), %xmm1
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
jne 0x8e5e
jnp 0x8e7e
movsd 0x1b0(%rbx), %xmm0
ucomisd %xmm2, %xmm0
jne 0x8e6e
jnp 0x8e7e
ucomisd %xmm0, %xmm1
jne 0x9116
jp 0x9116
movsd 0x1b0(%rbx), %xmm0
ucomisd %xmm2, %xmm0
jne 0x8e8e
jnp 0x8e98
movsd %xmm0, 0x1b8(%rbx)
jmp 0x8ea0
movsd %xmm1, 0x1b0(%rbx)
movl $0x0, 0x1a8(%rbx)
movq %rbx, %rdi
callq 0x7274
movq %rbx, %rdi
movq 0x8(%rsp), %r14
movq %r14, %rsi
callq 0x6b6f
movq %r14, %rdi
callq 0x7b57
testl %eax, %eax
je 0x9026
movabsq $0x3fffffffffffffff, %r12 # imm = 0x3FFFFFFFFFFFFFFF
xorl %r13d, %r13d
cmpl $0x0, 0x84(%rbx)
jle 0x8ff3
xorl %ebp, %ebp
movb 0x80(%rbx), %r14b
movq 0x88(%rbx), %rax
addq $0x2, %rax
cmpq %rax, 0x90(%rbx)
jae 0x8f3b
movq %rax, %r15
shrq %r15
cmpq %r12, %rax
cmovaq %r13, %r15
addq %rax, %r15
movq 0x98(%rbx), %rdi
movq %r15, %rsi
callq 0x4840
testq %rax, %rax
je 0x8f6a
movq %rax, 0x98(%rbx)
movq %r15, 0x90(%rbx)
movq 0x88(%rbx), %rax
movq 0x98(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x88(%rbx)
movb %r14b, (%rcx,%rax)
movq 0x88(%rbx), %rax
movq 0x98(%rbx), %rcx
movb $0x0, (%rcx,%rax)
movq 0x88(%rbx), %rax
addq $0x2, %rax
cmpq %rax, 0x90(%rbx)
jae 0x8fb6
movq %rax, %rcx
shrq %rcx
cmpq %r12, %rax
movl $0x0, %r15d
cmovbeq %rcx, %r15
addq %rax, %r15
movq 0x98(%rbx), %rdi
movq %r15, %rsi
callq 0x4840
testq %rax, %rax
je 0x8fe5
movq %rax, 0x98(%rbx)
movq %r15, 0x90(%rbx)
movq 0x88(%rbx), %rax
movq 0x98(%rbx), %rcx
leaq 0x1(%rax), %rdx
movq %rdx, 0x88(%rbx)
movb $0x2e, (%rcx,%rax)
movq 0x88(%rbx), %rax
movq 0x98(%rbx), %rcx
movb $0x0, (%rcx,%rax)
incl %ebp
cmpl 0x84(%rbx), %ebp
jl 0x8eee
movq 0x88(%rbx), %rdx
movq 0x98(%rbx), %rsi
movq %rbx, %rdi
callq 0x7df0
movq $0x0, 0x88(%rbx)
movq 0x8(%rsp), %rdi
callq 0x7b57
testl %eax, %eax
jne 0x8edf
movq %rbx, %rdi
callq 0x7bb0
movq %rbx, %rdi
callq 0x45c0
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x117ef
leaq 0x8d5cc(%rip), %rdi     # 0x9661f
movq %rax, %rsi
xorl %eax, %eax
callq 0x4060
jmp 0x9036
movl $0x1, %eax
jmp 0x8e1e
leaq 0x8d5ee(%rip), %rdi     # 0x9665e
jmp 0x9101
callq 0x117ef
leaq 0x8d65a(%rip), %rdi     # 0x966db
leaq 0x8d78c(%rip), %rdx     # 0x96814
movq %rax, %rsi
xorl %eax, %eax
callq 0x5ed4
callq 0x117ef
leaq 0x8d63d(%rip), %rdi     # 0x966db
leaq 0x8d76f(%rip), %rdx     # 0x96814
movq %rax, %rsi
xorl %eax, %eax
callq 0x4060
xorl %edi, %edi
callq 0x45e0
leaq 0x8d66b(%rip), %rdi     # 0x96728
jmp 0x910f
movq 0xafefa(%rip), %rax     # 0xb8fc0
movq (%rax), %rsi
leaq 0x8d5b4(%rip), %rdi     # 0x96684
jmp 0x9101
movq 0xafee7(%rip), %rax     # 0xb8fc0
movq (%rax), %rsi
leaq 0x8d5bf(%rip), %rdi     # 0x966a2
jmp 0x9101
testq %rcx, %rcx
leaq 0x8d636(%rip), %rax     # 0x96725
leaq 0x8d62c(%rip), %rsi     # 0x96722
cmoveq %rax, %rsi
leaq 0x8d60a(%rip), %rdi     # 0x9670b
xorl %eax, %eax
callq 0x5ed4
leaq 0x8d5dd(%rip), %rdi     # 0x966ec
xorl %eax, %eax
callq 0x5ed4
leaq 0x8d63c(%rip), %rdi     # 0x96759
movb $0x2, %al
callq 0x5ed4