// File: /workspace/github_c_makefile_star2_O1/samtools[P]htslib/htsfile.c
// Function: main
int main(int argc, char **argv)
{
    static const struct option options[] = {
        { "copy", no_argument, NULL, 'C' },
        { "header-only", no_argument, NULL, 'h' },
        { "no-header", no_argument, NULL, 'H' },
        { "view", no_argument, NULL, 'c' },
        { "verbose", no_argument, NULL, 'v' },
        { "help", no_argument, NULL, 2 },
        { "version", no_argument, NULL, 1 },
        { NULL, 0, NULL, 0 }
    };

    int c, i;

    status = EXIT_SUCCESS;
    while ((c = getopt_long(argc, argv, "cChHv", options, NULL)) >= 0)
        switch (c) {
        case 'c': mode = view_all; break;
        case 'C': mode = copy; break;
        case 'h': mode = view_headers; show_headers = 1; break;
        case 'H': show_headers = 0; break;
        case 'v': hts_verbose++; verbose++; break;
        case 1:
            printf(
"htsfile (htslib) %s\n"
"Copyright (C) 2025 Genome Research Ltd.\n",
                   hts_version());
            exit(EXIT_SUCCESS);
            break;
        case 2:   usage(stdout, EXIT_SUCCESS); break;
        default:  usage(stderr, EXIT_FAILURE); break;
        }

    if (optind == argc) usage(stderr, EXIT_FAILURE);

    if (mode == copy) {
        if (optind + 2 != argc) usage(stderr, EXIT_FAILURE);
        copy_raw(argv[optind], argv[optind + 1]);
        return status;
    }

    for (i = optind; i < argc; i++) {
        hFILE *fp = hopen(argv[i], "r");
        if (fp == NULL) {
            error("can't open \"%s\"", argv[i]);
            continue;
        }

        if (mode == identify) {
            htsFormat fmt;
            if (hts_detect_format2(fp, argv[i], &fmt) < 0) {
                error("detecting \"%s\" format failed", argv[i]);
                hclose_abruptly(fp);
                continue;
            }

            char *description = hts_format_description(&fmt);
            printf("%s:\t%s\n", argv[i], description);
            free(description);
        }
        else {
            htsFile *hts = hts_hopen(fp, argv[i], "r");
            if (hts) {
                switch (hts_get_format(hts)->category) {
                case sequence_data:
                    view_sam(hts, argv[i]);
                    break;
                case variant_data:
                    view_vcf(hts, argv[i]);
                    break;
                default:
                    if (verbose)
                        view_raw(fp, argv[i]);
                    else {
                        errno = 0;
                        error("can't view \"%s\": unknown format", argv[i]);
                    }
                    break;
                }

                if (hts_close(hts) < 0) error("closing \"%s\" failed", argv[i]);
                fp = NULL;
            }
            else if ((errno == EFTYPE || errno == ENOEXEC) && verbose)
                view_raw(fp, argv[i]);
            else
                error("can't view \"%s\"", argv[i]);
        }

        if (fp && hclose(fp) < 0) error("closing \"%s\" failed", argv[i]);
    }

    if (fclose(stdout) != 0 && errno != EBADF)
        error("closing standard output failed");

    return status;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x38, %rsp
movq %rsi, %r13
movl %edi, %r12d
movl $0x0, 0xca4d2(%rip)     # 0xd056c
leaq 0xa3f9a(%rip), %rdx     # 0xaa03b
leaq 0xc9558(%rip), %rcx     # 0xcf600
xorl %r8d, %r8d
callq 0x48b0
testl %eax, %eax
js 0x6158
leaq 0xa3f7c(%rip), %rbx     # 0xaa03b
leaq 0xc953a(%rip), %r14     # 0xcf600
leaq 0xca457(%rip), %r15     # 0xd0524
movl $0x1, %ebp
cmpl $0x62, %eax
jle 0x60f6
cmpl $0x76, %eax
je 0x6125
cmpl $0x68, %eax
je 0x6130
cmpl $0x63, %eax
jne 0x68a3
movl $0x2, 0xca470(%rip)     # 0xd0564
jmp 0x613c
cmpl $0x47, %eax
jg 0x6110
cmpl $0x43, %eax
jne 0x685a
movl $0x3, 0xca456(%rip)     # 0xd0564
jmp 0x613c
cmpl $0x48, %eax
jne 0x68a3
movl $0x0, 0xca3fd(%rip)     # 0xd0520
jmp 0x613c
incl (%r15)
incl 0xca43a(%rip)           # 0xd0568
jmp 0x613c
movl %ebp, 0xca42e(%rip)     # 0xd0564
movl %ebp, 0xca3e4(%rip)     # 0xd0520
movl %r12d, %edi
movq %r13, %rsi
movq %rbx, %rdx
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x48b0
testl %eax, %eax
jns 0x60d2
movq 0xc9e79(%rip), %rax     # 0xcffd8
movslq (%rax), %rbp
cmpl %r12d, %ebp
je 0x68a8
cmpl $0x3, 0xca3f2(%rip)     # 0xd0564
jne 0x6322
leal 0x2(%rbp), %eax
cmpl %r12d, %eax
jne 0x68ad
movq (%r13,%rbp,8), %rbx
movq 0x8(%r13,%rbp,8), %r14
leaq 0xa422e(%rip), %rsi     # 0xaa3c3
movq %rbx, %rdi
xorl %eax, %eax
callq 0x7b90
testq %rax, %rax
je 0x67ab
movq %rax, %r15
movq %rbx, 0x8(%rsp)
movl $0x100000, %edi         # imm = 0x100000
callq 0x46c0
testq %rax, %rax
je 0x67be
movq %rax, %rbx
leaq 0xa3e5f(%rip), %rsi     # 0xaa02c
movq %r14, (%rsp)
movq %r14, %rdi
xorl %eax, %eax
callq 0x7b90
testq %rax, %rax
je 0x67d6
movq %rax, %r13
movq 0x8(%r15), %rsi
movq 0x10(%r15), %r12
subq %rsi, %r12
movl $0x100000, %eax         # imm = 0x100000
cmpq %rax, %r12
movl $0x100000, %r14d        # imm = 0x100000
cmovbq %r12, %r14
movq %rbx, %rdi
movq %r14, %rdx
callq 0x43d0
addq %r14, 0x8(%r15)
cmpq $0xfffff, %r12          # imm = 0xFFFFF
ja 0x6239
testb $0x2, 0x30(%r15)
je 0x6239
movl $0x100000, %edx         # imm = 0x100000
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rcx
callq 0x6e49
movq %rax, %r14
testq %r14, %r14
jle 0x62e2
testb $0x2, 0x30(%r13)
jne 0x6270
movq 0x18(%r13), %rsi
movq %rsi, %rax
subq 0x8(%r13), %rax
cmpq %r14, %rax
jae 0x6270
addq %r14, %rsi
subq (%r13), %rsi
movq %r13, %rdi
callq 0x6b59
movq 0x18(%r13), %rax
movq %rax, 0x10(%r13)
movq 0x8(%r13), %rdi
movq 0x18(%r13), %r12
subq %rdi, %r12
cmpq %r14, %r12
ja 0x6286
cmpq (%r13), %rdi
je 0x62a6
cmpq %r14, %r12
movq %r14, %rbp
cmovbq %r12, %rbp
movq %rbx, %rsi
movq %rbp, %rdx
callq 0x43d0
addq %rbp, 0x8(%r13)
cmpq %r14, %r12
jb 0x62a8
jmp 0x62bc
xorl %ebp, %ebp
movq %r13, %rdi
movq %rbx, %rsi
movq %r14, %rdx
movq %rbp, %rcx
callq 0x7042
movq %rax, %rbp
cmpq %r14, %rbp
je 0x61e7
leaq 0xa4010(%rip), %rdi     # 0xaa2dc
movq (%rsp), %rsi
xorl %eax, %eax
callq 0x4a20
movq %r13, %rdi
callq 0x72ac
xorl %r13d, %r13d
testq %r14, %r14
js 0x67f5
testq %r13, %r13
je 0x6300
movq %r13, %rdi
callq 0x724c
testl %eax, %eax
js 0x682b
testq %r15, %r15
je 0x6315
movq %r15, %rdi
callq 0x724c
testl %eax, %eax
js 0x6842
movq %rbx, %rdi
callq 0x45e0
jmp 0x6796
cmpl %r12d, %ebp
jge 0x6775
leaq 0xa4091(%rip), %r15     # 0xaa3c3
leaq 0x18(%rsp), %rbx
movq %r13, (%rsp)
movl %r12d, 0x8(%rsp)
leaq (,%rbp,8), %r12
addq %r13, %r12
movq (%r12), %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x7b90
leaq 0xa3d1e(%rip), %rdi     # 0xaa07e
testq %rax, %rax
je 0x672e
movq %rax, %r14
cmpl $0x0, 0xca1f1(%rip)     # 0xd0564
je 0x645a
movq (%r12), %rsi
movq %r14, %rdi
movq %r15, %rdx
callq 0xb84a
testq %rax, %rax
je 0x64b4
movq %rax, %r13
movq %rax, %rdi
callq 0xd519
movl (%rax), %eax
cmpl $0x2, %eax
je 0x64e4
cmpl $0x1, %eax
jne 0x658a
movq (%r12), %rbx
movq %r13, %rdi
callq 0x1be9d
movq %rax, %r15
testq %rax, %rax
je 0x661c
leaq 0xa6a18(%rip), %rdi     # 0xacde7
leaq 0xa3c56(%rip), %rsi     # 0xaa02c
callq 0xbff7
testq %rax, %rax
je 0x6665
movq %rax, %r14
cmpl $0x0, 0xca132(%rip)     # 0xd0520
je 0x6403
movq %r14, %rdi
movq %r15, %rsi
callq 0x1d21e
testl %eax, %eax
jne 0x668b
cmpl $0x2, 0xca15a(%rip)     # 0xd0564
jne 0x6699
movq %rbx, 0x10(%rsp)
callq 0x190e7
movq %rax, %rbx
testq %rax, %rax
je 0x674f
movq %r13, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x20079
testl %eax, %eax
js 0x65a8
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x23863
testl %eax, %eax
jns 0x6426
leaq 0xa3f37(%rip), %rdi     # 0xaa38c
jmp 0x6756
movq (%r12), %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0x9491
movq %rbx, %rdi
movl %eax, %ebx
testl %eax, %eax
js 0x65ea
callq 0xa29f
movq %rax, %r15
movq (%r12), %rsi
leaq 0xa3c22(%rip), %rdi     # 0xaa0ab
movq %rax, %rdx
xorl %eax, %eax
callq 0x4060
movq %r15, %rdi
leaq 0xa3f26(%rip), %r15     # 0xaa3c3
callq 0x45e0
testl %ebx, %ebx
leaq 0x18(%rsp), %rbx
jns 0x6703
jmp 0x671b
callq 0x4050
cmpl $0x8, (%rax)
movq (%r12), %rsi
movq (%rsp), %r13
jne 0x6609
cmpl $0x0, 0xca097(%rip)     # 0xd0568
je 0x6609
movq %r14, %rdi
callq 0x68b2
jmp 0x6703
movq (%r12), %rbx
movq %r13, %rdi
callq 0x31faf
movq %rax, %r15
testq %rax, %rax
je 0x663a
leaq 0xa68e4(%rip), %rdi     # 0xacde7
leaq 0xa3b22(%rip), %rsi     # 0xaa02c
callq 0xbff7
testq %rax, %rax
je 0x6678
movq %rax, %r14
cmpl $0x0, 0xc9ffe(%rip)     # 0xd0520
je 0x6537
movq %r14, %rdi
movq %r15, %rsi
callq 0x32bf4
testl %eax, %eax
jne 0x66ad
cmpl $0x2, 0xca026(%rip)     # 0xd0564
jne 0x66bb
movq %rbx, 0x10(%rsp)
callq 0x32fb3
movq %rax, %rbx
testq %rax, %rax
je 0x6762
movq %r13, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x3358e
testl %eax, %eax
js 0x65c9
movq %r14, %rdi
movq %r15, %rsi
movq %rbx, %rdx
callq 0x34ee3
testl %eax, %eax
jns 0x655a
leaq 0xa3e07(%rip), %rdi     # 0xaa38c
jmp 0x6769
cmpl $0x0, 0xc9fd7(%rip)     # 0xd0568
je 0x6658
movq (%r12), %rsi
movq %r14, %rdi
callq 0x68b2
jmp 0x66f0
cmpl $-0x1, %eax
je 0x669b
leaq 0xa3df6(%rip), %rdi     # 0xaa3ae
movq 0x10(%rsp), %rsi
xorl %eax, %eax
callq 0x4a20
jmp 0x669b
cmpl $-0x1, %eax
je 0x66bd
leaq 0xa3dd5(%rip), %rdi     # 0xaa3ae
movq 0x10(%rsp), %rsi
xorl %eax, %eax
callq 0x4a20
jmp 0x66bd
movq (%r12), %rsi
leaq 0xa3a99(%rip), %rdi     # 0xaa08e
xorl %eax, %eax
callq 0x4a20
movq %r14, %rdi
callq 0x72ac
jmp 0x64a2
leaq 0xa3ad7(%rip), %rdi     # 0xaa0e7
xorl %eax, %eax
callq 0x4a20
jmp 0x6703
callq 0x4050
movl $0x0, (%rax)
leaq 0xa3cde(%rip), %rdi     # 0xaa30c
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4a20
jmp 0x6673
callq 0x4050
movl $0x0, (%rax)
leaq 0xa3cc0(%rip), %rdi     # 0xaa30c
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4a20
jmp 0x6686
movq %r12, %rdi
callq 0x4b33
jmp 0x66f0
leaq 0xa3cc1(%rip), %rdi     # 0xaa32d
xorl %eax, %eax
callq 0x4a20
xorl %r14d, %r14d
jmp 0x6699
leaq 0xa3cae(%rip), %rdi     # 0xaa32d
xorl %eax, %eax
callq 0x4a20
xorl %r14d, %r14d
jmp 0x66bb
leaq 0xa3cbc(%rip), %rdi     # 0xaa34e
xorl %eax, %eax
callq 0x4a20
xorl %ebx, %ebx
movq %r15, %rdi
callq 0x18766
movq %rbx, %rdi
callq 0x191c4
jmp 0x66d7
leaq 0xa3c9a(%rip), %rdi     # 0xaa34e
xorl %eax, %eax
callq 0x4a20
xorl %ebx, %ebx
testq %r15, %r15
je 0x66ca
movq %r15, %rdi
callq 0x31e16
testq %rbx, %rbx
je 0x66d7
movq %rbx, %rdi
callq 0x33156
testq %r14, %r14
leaq 0xa3ce2(%rip), %r15     # 0xaa3c3
leaq 0x18(%rsp), %rbx
je 0x66f0
movq %r14, %rdi
callq 0xd261
movq %r13, %rdi
callq 0xd261
testl %eax, %eax
js 0x673b
xorl %r14d, %r14d
movq (%rsp), %r13
testq %r14, %r14
je 0x671b
movq %r14, %rdi
callq 0x724c
leaq 0xa39bc(%rip), %rdi     # 0xaa0d3
testl %eax, %eax
js 0x672e
incq %rbp
movl 0x8(%rsp), %r12d
cmpl %r12d, %ebp
jne 0x6340
jmp 0x6775
movq (%r12), %rsi
xorl %eax, %eax
callq 0x4a20
jmp 0x671b
movq (%r12), %rsi
leaq 0xa398d(%rip), %rdi     # 0xaa0d3
xorl %eax, %eax
callq 0x4a20
jmp 0x66fc
leaq 0xa3c22(%rip), %rdi     # 0xaa378
xorl %eax, %eax
callq 0x4a20
jmp 0x669b
leaq 0xa3c0f(%rip), %rdi     # 0xaa378
xorl %eax, %eax
callq 0x4a20
jmp 0x66bd
movq 0xc9834(%rip), %rax     # 0xcffb0
movq (%rax), %rdi
callq 0x44c0
testl %eax, %eax
je 0x6796
callq 0x4050
cmpl $0x9, (%rax)
jne 0x6818
movl 0xc9dd0(%rip), %eax     # 0xd056c
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xa38cc(%rip), %rdi     # 0xaa07e
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4a20
jmp 0x6796
leaq 0xa3aea(%rip), %rdi     # 0xaa2af
xorl %eax, %eax
callq 0x4a20
movq %r15, %rdi
callq 0x72ac
jmp 0x6796
leaq 0xa3aed(%rip), %rdi     # 0xaa2ca
movq (%rsp), %rsi
xorl %eax, %eax
callq 0x4a20
movq %r15, %rdi
callq 0x72ac
jmp 0x6315
leaq 0xa3af7(%rip), %rdi     # 0xaa2f3
movq 0x8(%rsp), %rsi
xorl %eax, %eax
callq 0x4a20
movq %r15, %rdi
callq 0x72ac
xorl %r15d, %r15d
jmp 0x62eb
leaq 0xa38d8(%rip), %rdi     # 0xaa0f7
xorl %eax, %eax
callq 0x4a20
jmp 0x6796
leaq 0xa38a1(%rip), %rdi     # 0xaa0d3
movq (%rsp), %rsi
xorl %eax, %eax
callq 0x4a20
jmp 0x6300
leaq 0xa388a(%rip), %rdi     # 0xaa0d3
movq 0x8(%rsp), %rsi
xorl %eax, %eax
callq 0x4a20
jmp 0x6315
cmpl $0x1, %eax
je 0x6886
cmpl $0x2, %eax
jne 0x68a3
movq 0xc9745(%rip), %rax     # 0xcffb0
movq (%rax), %rcx
leaq 0xa38a1(%rip), %rdi     # 0xaa116
movl $0x198, %esi            # imm = 0x198
movl $0x1, %edx
callq 0x49f0
jmp 0x689c
callq 0x936b
leaq 0xa37af(%rip), %rdi     # 0xaa041
movq %rax, %rsi
xorl %eax, %eax
callq 0x4060
xorl %edi, %edi
callq 0x4610
callq 0x4ba0
callq 0x4b79
callq 0x4b52