// File: /workspace/github_c_makefile_star2_O3/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 0x8ab24(%rip), %rdx     # 0x93604
leaq 0xada19(%rip), %rcx     # 0xb6500
movl %ebp, %edi
movq %r15, %rsi
xorl %r8d, %r8d
callq 0x4860
testl %eax, %eax
js 0x8d88
movq $0x0, 0x10(%rsp)
leaq 0x8aaf8(%rip), %r14     # 0x93604
leaq 0xad9ed(%rip), %r12     # 0xb6500
leaq 0x8a52a(%rip), %r13     # 0x93044
cmpl $0x48, %eax
jle 0x8b47
leal -0x61(%rax), %ecx
cmpl $0x17, %ecx
ja 0x8b8b
movslq (%r13,%rcx,4), %rax
addq %r13, %rax
jmpq *%rax
movq 0xad488(%rip), %rax     # 0xb5fc0
movq (%rax), %rax
movq %rax, 0x168(%rbx)
jmp 0x8d62
cmpl $0x4, %eax
ja 0x8b6d
movl %eax, %eax
leaq 0x8a4db(%rip), %rcx     # 0x93030
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl $0x1, 0x198(%rbx)
jmp 0x8d62
cmpl $0x43, %eax
je 0x8c84
cmpl $0x48, %eax
jne 0x908c
leaq 0x8aafa(%rip), %rax     # 0x93680
jmp 0x8d2b
cmpl $0x49, %eax
je 0x8d50
cmpl $0x4f, %eax
jne 0x908c
movq 0xad41c(%rip), %r14     # 0xb5fc0
movq (%r14), %rdi
movq %rsp, %rsi
callq 0x4350
movsd %xmm0, 0x1b0(%rbx)
movq (%rsp), %rdi
movq (%r14), %rsi
cmpq %rsi, %rdi
je 0x90fe
movzbl (%rdi), %eax
testl %eax, %eax
je 0x8bd7
cmpl $0x2c, %eax
jne 0x90fe
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
ja 0x9111
ucomisd 0x8a423(%rip), %xmm0    # 0x93010
ja 0x9111
testb %al, %al
leaq 0x8aa08(%rip), %r14     # 0x93604
je 0x8d58
incq %rdi
movq %rsp, %rsi
callq 0x4350
movsd %xmm0, 0x1b8(%rbx)
movq (%rsp), %rax
cmpb $0x0, (%rax)
jne 0x90f4
xorpd %xmm1, %xmm1
ucomisd %xmm0, %xmm1
ja 0x9107
ucomisd 0x8a3d8(%rip), %xmm0    # 0x93010
jbe 0x8d62
jmp 0x9107
movq 0xad376(%rip), %r14     # 0xb5fc0
movq (%r14), %rdi
movq %rsp, %rsi
callq 0x4350
cvttsd2si %xmm0, %eax
movl %eax, 0x19c(%rbx)
movq (%rsp), %rax
movq (%r14), %rsi
leaq 0x8a997(%rip), %r14     # 0x93604
cmpq %rsi, %rax
je 0x9080
cmpb $0x0, (%rax)
je 0x8d62
jmp 0x9080
movq 0xad335(%rip), %rax     # 0xb5fc0
movq (%rax), %rax
movq %rax, 0x150(%rbx)
jmp 0x8d62
movq 0xad31f(%rip), %rax     # 0xb5fc0
movq (%rax), %rax
movq %rax, 0x188(%rbx)
jmp 0x8d62
movq 0xad309(%rip), %rax     # 0xb5fc0
movq (%rax), %rax
movq %rax, 0x148(%rbx)
jmp 0x8d62
movl $0x1, %eax
movq %rax, 0x10(%rsp)
jmp 0x8d62
movq 0xad2e4(%rip), %rax     # 0xb5fc0
movq (%rax), %rax
movq %rax, 0x178(%rbx)
jmp 0x8d62
movq 0xad2d1(%rip), %rax     # 0xb5fc0
movq (%rax), %rax
movq %rax, 0xa8(%rbx)
jmp 0x8d62
movq 0xad2be(%rip), %rax     # 0xb5fc0
movq (%rax), %rax
movq %rax, 0x160(%rbx)
jmp 0x8d62
movq 0xad2ab(%rip), %rax     # 0xb5fc0
movq (%rax), %rax
movq %rax, 0x158(%rbx)
jmp 0x8d62
movq 0xad298(%rip), %rax     # 0xb5fc0
movq (%rax), %rax
movq %rax, 0x170(%rbx)
jmp 0x8d62
movq 0xad285(%rip), %rax     # 0xb5fc0
movq (%rax), %rax
movq %rax, 0x8(%rbx)
jmp 0x8d62
movl $0x2, 0x1a0(%rbx)
jmp 0x8d62
incl 0x1a4(%rbx)
jmp 0x8d62
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 0x8b1a
cmpl $0x0, 0x10(%rsp)
sete %r15b
jmp 0x8d8b
movb $0x1, %r15b
cmpl $0x1, %ebp
je 0x908c
addq $0x8, 0x8(%rsp)
cmpq $0x0, 0x8(%rbx)
movq 0xa8(%rbx), %rax
je 0x8daf
testq %rax, %rax
jne 0x8e0a
jmp 0x8db8
testq %rax, %rax
je 0x911f
movq 0xad211(%rip), %rax     # 0xb5fd0
movq (%rax), %rdi
callq 0x44f0
movl %eax, %edi
callq 0x48c0
movq 0x8(%rsp), %rcx
movq (%rcx), %rcx
testl %eax, %eax
jne 0x90d6
testq %rcx, %rcx
jne 0x8df2
leaq 0x8f0ed(%rip), %rax     # 0x97ed7
movq 0x8(%rsp), %rcx
movq %rax, (%rcx)
cmpq $0x0, 0xa8(%rbx)
jne 0x8e0a
leaq 0x8f0d4(%rip), %rax     # 0x97ed7
movq %rax, 0xa8(%rbx)
movl 0x1a0(%rbx), %ecx
movq 0x160(%rbx), %rax
testl %ecx, %ecx
je 0x8e23
testb $0x1, %cl
sete %cl
jmp 0x8e42
testq %rax, %rax
jne 0x8e36
cmpq $0x0, 0x168(%rbx)
je 0x906f
movl $0x3, 0x1a0(%rbx)
xorl %ecx, %ecx
testq %rax, %rax
jne 0x8e51
cmpq $0x0, 0x168(%rbx)
je 0x8e59
testb %cl, %cl
jne 0x90cd
testb %r15b, %r15b
jne 0x8eb6
movsd 0x1b0(%rbx), %xmm0
movsd 0x1b8(%rbx), %xmm1
xorpd %xmm2, %xmm2
ucomisd %xmm2, %xmm1
jne 0x8e7a
jnp 0x8e92
ucomisd %xmm2, %xmm0
jne 0x8e82
jnp 0x8e92
ucomisd %xmm0, %xmm1
jne 0x912d
jp 0x912d
ucomisd %xmm2, %xmm0
jne 0x8e9a
jnp 0x8ea4
movsd %xmm0, 0x1b8(%rbx)
jmp 0x8eac
movsd %xmm1, 0x1b0(%rbx)
movl $0x0, 0x1a8(%rbx)
movq %rbx, %rdi
callq 0x72b4
movq %rbx, %rdi
movq 0x8(%rsp), %r14
movq %r14, %rsi
callq 0x6bf4
movq %r14, %rdi
callq 0x7b7f
testl %eax, %eax
je 0x9036
movabsq $0x3fffffffffffffff, %r12 # imm = 0x3FFFFFFFFFFFFFFF
xorl %r13d, %r13d
cmpl $0x0, 0x84(%rbx)
jle 0x9003
xorl %ebp, %ebp
movb 0x80(%rbx), %r14b
movq 0x88(%rbx), %rcx
leaq 0x2(%rcx), %rax
cmpq %rax, 0x90(%rbx)
jae 0x8f50
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 0x8f78
movq %rax, 0x98(%rbx)
movq %r15, 0x90(%rbx)
movq 0x88(%rbx), %rcx
jmp 0x8f57
movq 0x98(%rbx), %rax
leaq 0x1(%rcx), %rdx
movq %rdx, 0x88(%rbx)
movb %r14b, (%rax,%rcx)
movq 0x88(%rbx), %rax
movq 0x98(%rbx), %rcx
movb $0x0, (%rcx,%rax)
movq 0x88(%rbx), %rcx
leaq 0x2(%rcx), %rax
cmpq %rax, 0x90(%rbx)
jae 0x8fcd
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 0x8ff5
movq %rax, 0x98(%rbx)
movq %r15, 0x90(%rbx)
movq 0x88(%rbx), %rcx
jmp 0x8fd4
movq 0x98(%rbx), %rax
leaq 0x1(%rcx), %rdx
movq %rdx, 0x88(%rbx)
movb $0x2e, (%rax,%rcx)
movq 0x88(%rbx), %rax
movq 0x98(%rbx), %rcx
movb $0x0, (%rcx,%rax)
incl %ebp
cmpl 0x84(%rbx), %ebp
jl 0x8efa
movq 0x88(%rbx), %rdx
movq 0x98(%rbx), %rsi
movq %rbx, %rdi
callq 0x7e1b
movq $0x0, 0x88(%rbx)
movq 0x8(%rsp), %rdi
callq 0x7b7f
testl %eax, %eax
jne 0x8eeb
movq %rbx, %rdi
callq 0x7bd8
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 0x11585
leaq 0x8a5bc(%rip), %rdi     # 0x9361f
movq %rax, %rsi
xorl %eax, %eax
callq 0x4060
jmp 0x9046
movl $0x1, 0x1a0(%rbx)
xorl %ecx, %ecx
jmp 0x8e47
leaq 0x8a5d7(%rip), %rdi     # 0x9365e
jmp 0x9118
callq 0x11585
leaq 0x8a643(%rip), %rdi     # 0x936db
leaq 0x8a775(%rip), %rdx     # 0x93814
movq %rax, %rsi
xorl %eax, %eax
callq 0x5edc
callq 0x11585
leaq 0x8a626(%rip), %rdi     # 0x936db
leaq 0x8a758(%rip), %rdx     # 0x93814
movq %rax, %rsi
xorl %eax, %eax
callq 0x4060
xorl %edi, %edi
callq 0x45e0
leaq 0x8a654(%rip), %rdi     # 0x93728
jmp 0x9126
testq %rcx, %rcx
leaq 0x8a645(%rip), %rax     # 0x93725
leaq 0x8a63b(%rip), %rsi     # 0x93722
cmoveq %rax, %rsi
leaq 0x8a619(%rip), %rdi     # 0x9370b
jmp 0x9118
movq 0xacec5(%rip), %rax     # 0xb5fc0
movq (%rax), %rsi
leaq 0x8a57f(%rip), %rdi     # 0x93684
jmp 0x9118
movq 0xaceb2(%rip), %rax     # 0xb5fc0
movq (%rax), %rsi
leaq 0x8a58a(%rip), %rdi     # 0x936a2
xorl %eax, %eax
callq 0x5edc
leaq 0x8a5c6(%rip), %rdi     # 0x936ec
xorl %eax, %eax
callq 0x5edc
leaq 0x8a625(%rip), %rdi     # 0x93759
movb $0x2, %al
callq 0x5edc