// File: /workspace/github_c_makefile_star2_O2/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, %rbx
movl %edi, %ebp
andl $0x0, 0xa9943(%rip)     # 0xaf56c
leaq 0x7c40b(%rip), %r14     # 0x8203b
leaq 0xa89f9(%rip), %r15     # 0xae630
pushq $0x1
popq %r12
leaq 0xa98e2(%rip), %r13     # 0xaf524
movl %ebp, %edi
movq %rbx, %rsi
movq %r14, %rdx
movq %r15, %rcx
xorl %r8d, %r8d
callq 0x48b0
testl %eax, %eax
js 0x5cb3
cmpl $0x43, %eax
je 0x5c92
cmpl $0x48, %eax
je 0x5c9e
cmpl $0x63, %eax
je 0x5ca7
cmpl $0x68, %eax
je 0x5c82
cmpl $0x76, %eax
jne 0x6383
incl (%r13)
incl 0xa98e8(%rip)           # 0xaf568
jmp 0x5c42
movl %r12d, 0xa98db(%rip)    # 0xaf564
movl %r12d, 0xa9890(%rip)    # 0xaf520
jmp 0x5c42
movl $0x3, 0xa98c8(%rip)     # 0xaf564
jmp 0x5c42
andl $0x0, 0xa987b(%rip)     # 0xaf520
jmp 0x5c42
movl $0x2, 0xa98b3(%rip)     # 0xaf564
jmp 0x5c42
movq 0xa931e(%rip), %rax     # 0xaefd8
movslq (%rax), %r14
cmpl %ebp, %r14d
je 0x639e
cmpl $0x3, 0xa9897(%rip)     # 0xaf564
jne 0x5e56
leal 0x2(%r14), %eax
cmpl %ebp, %eax
jne 0x639e
movq (%rbx,%r14,8), %r12
movq 0x8(%rbx,%r14,8), %r14
leaq 0x7c6d4(%rip), %rsi     # 0x823c3
movq %r12, %rdi
xorl %eax, %eax
callq 0x756f
testq %rax, %rax
je 0x62af
movq %rax, %r15
movl $0x100000, %edi         # imm = 0x100000
callq 0x46c0
testq %rax, %rax
je 0x62c5
movq %rax, %rbx
leaq 0x7c30a(%rip), %rsi     # 0x8202c
movq %r14, %rdi
xorl %eax, %eax
callq 0x756f
testq %rax, %rax
je 0x62e0
movq %rax, %r13
movq %r14, 0x8(%rsp)
movq %r12, 0x10(%rsp)
movq 0x8(%r15), %rbp
movq 0x10(%r15), %r12
subq %rbp, %r12
movl $0x100000, %eax         # imm = 0x100000
cmpq %rax, %r12
movl $0x100000, %r14d        # imm = 0x100000
cmovbq %r12, %r14
movq %rbx, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x43d0
addq %r14, %rbp
movq %rbp, 0x8(%r15)
movl $0x100000, %ebp         # imm = 0x100000
cmpq $0xfffff, %r12          # imm = 0xFFFFF
ja 0x5dab
testb $0x2, 0x30(%r15)
je 0x5d9f
movl $0x100000, %edx         # imm = 0x100000
movq %r15, %rdi
movq %rbx, %rsi
movq %r14, %rcx
callq 0x6932
movq %rax, %r12
movq %r12, %rbp
testq %r12, %r12
jle 0x62fb
testb $0x2, 0x30(%r13)
movq 0x8(%r13), %rdi
movq 0x18(%r13), %r12
jne 0x5de3
movq %r12, %rax
subq %rdi, %rax
cmpq %rbp, %rax
jae 0x5de3
addq %rbp, %r12
subq (%r13), %r12
movq %r13, %rdi
movq %r12, %rsi
callq 0x6640
movq 0x8(%r13), %rdi
movq 0x18(%r13), %r12
movq %r12, 0x10(%r13)
subq %rdi, %r12
cmpq %rbp, %r12
ja 0x5df1
cmpq (%r13), %rdi
je 0x5e11
cmpq %rbp, %r12
movq %rbp, %r14
cmovbq %r12, %r14
movq %rbx, %rsi
movq %r14, %rdx
callq 0x43d0
addq %r14, 0x8(%r13)
cmpq %rbp, %r12
jb 0x5e14
jmp 0x5e28
xorl %r14d, %r14d
movq %r13, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movq %r14, %rcx
callq 0x6aeb
movq %rax, %r14
cmpq %rbp, %r14
je 0x5d42
leaq 0x7c4a4(%rip), %rdi     # 0x822dc
movq 0x8(%rsp), %rsi
xorl %eax, %eax
callq 0x5afc
movq %r13, %rdi
callq 0x6d20
movq 0x10(%rsp), %r14
jmp 0x6344
movslq %ebp, %rbp
leaq 0x7c563(%rip), %r12     # 0x823c3
leaq 0x18(%rsp), %r13
movq %rbp, 0x10(%rsp)
cmpq %rbp, %r14
jge 0x6277
movq (%rbx,%r14,8), %rdi
movq %r12, %rsi
xorl %eax, %eax
callq 0x756f
testq %rax, %rax
je 0x5f34
movq %rax, %r15
cmpl $0x0, 0xa96d0(%rip)     # 0xaf564
je 0x5f44
movq (%rbx,%r14,8), %rsi
movq %r15, %rdi
movq %r12, %rdx
callq 0x9e39
testq %rax, %rax
je 0x5f8b
movq %rax, %r13
movq %rax, %rdi
callq 0xba08
movl (%rax), %eax
cmpl $0x2, %eax
je 0x5fd6
cmpl $0x1, %eax
jne 0x603e
movq (%rbx,%r14,8), %r12
movq %r13, %rdi
callq 0x180ee
movq %rax, %rbp
testq %rax, %rax
je 0x6080
leaq 0x7ee75(%rip), %rdi     # 0x84d65
leaq 0x7c135(%rip), %rsi     # 0x8202c
callq 0xa59b
testq %rax, %rax
je 0x6181
movq %rax, %r15
cmpl $0x0, 0xa9611(%rip)     # 0xaf520
je 0x60d1
movq %r15, %rdi
movq %rbp, %rsi
callq 0x18bed
testl %eax, %eax
je 0x60d1
leaq 0x7c41f(%rip), %rdi     # 0x8234e
jmp 0x61d2
movq (%rbx,%r14,8), %rsi
leaq 0x7c13f(%rip), %rdi     # 0x8207e
jmp 0x6221
movq (%rbx,%r14,8), %rsi
movq %r15, %rdi
movq %r13, %rdx
callq 0x8b71
testl %eax, %eax
js 0x5fb7
movq %r13, %rdi
callq 0x97fc
movq %rax, %r12
movq (%rbx,%r14,8), %rsi
leaq 0x7c13e(%rip), %rdi     # 0x820ab
movq %rax, %rdx
xorl %eax, %eax
callq 0x4060
movq %r12, %rdi
leaq 0x7c442(%rip), %r12     # 0x823c3
callq 0x45e0
jmp 0x606b
callq 0x4050
cmpl $0x8, (%rax)
movq (%rbx,%r14,8), %rsi
jne 0x6058
cmpl $0x0, 0xa95c4(%rip)     # 0xaf568
je 0x6058
movq %r15, %rdi
callq 0x63ee
jmp 0x6066
movq (%rbx,%r14,8), %rsi
leaq 0x7c0cc(%rip), %rdi     # 0x8208e
xorl %eax, %eax
callq 0x5afc
movq %r15, %rdi
callq 0x6d20
jmp 0x6228
movq (%rbx,%r14,8), %rbp
movq %r13, %rdi
callq 0x27a46
testq %rax, %rax
je 0x609e
movq %rax, %r15
movq %rbp, 0x8(%rsp)
leaq 0x7ed6b(%rip), %rdi     # 0x84d65
leaq 0x7c02b(%rip), %rsi     # 0x8202c
callq 0xa59b
movq %rax, %rbp
testq %rax, %rax
je 0x6194
cmpl $0x0, 0xa9507(%rip)     # 0xaf520
je 0x612f
movq %rbp, %rdi
movq %r15, %rsi
callq 0x28069
testl %eax, %eax
je 0x612f
leaq 0x7c315(%rip), %rdi     # 0x8234e
jmp 0x619b
cmpl $0x0, 0xa9523(%rip)     # 0xaf568
je 0x60b2
movq (%rbx,%r14,8), %rsi
movq %r15, %rdi
callq 0x63ee
jmp 0x6200
leaq 0x7c088(%rip), %rdi     # 0x820e7
xorl %eax, %eax
callq 0x5afc
leaq 0x18(%rsp), %r13
movq %r15, %rdi
callq 0x6cc2
testl %eax, %eax
jns 0x6228
jmp 0x6216
callq 0x4050
andl $0x0, (%rax)
leaq 0x7c27d(%rip), %rdi     # 0x8230c
movq %r12, %rsi
xorl %eax, %eax
callq 0x5afc
jmp 0x618f
callq 0x4050
andl $0x0, (%rax)
leaq 0x7c25f(%rip), %rdi     # 0x8230c
movq %rbp, %rsi
jmp 0x60c5
callq 0x4050
andl $0x0, (%rax)
movq (%rbx,%r14,8), %rsi
leaq 0x7bfee(%rip), %rdi     # 0x820b3
xorl %eax, %eax
callq 0x5afc
jmp 0x6200
cmpl $0x2, 0xa948c(%rip)     # 0xaf564
jne 0x61d9
movq %r12, 0x8(%rsp)
callq 0x15964
movq %rax, %r12
testq %rax, %rax
je 0x61cb
movq %r13, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x1ae82
testl %eax, %eax
js 0x623c
movq %r15, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x1c809
testl %eax, %eax
jns 0x60f4
leaq 0x7c269(%rip), %rdi     # 0x8238c
xorl %eax, %eax
callq 0x5afc
jmp 0x61dc
cmpl $0x2, 0xa942e(%rip)     # 0xaf564
jne 0x61a2
callq 0x2833e
movq %rax, %r12
testq %rax, %rax
je 0x6230
movq %r13, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x2874e
testl %eax, %eax
js 0x6256
movq %rbp, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x29775
testl %eax, %eax
jns 0x6149
leaq 0x7c214(%rip), %rdi     # 0x8238c
xorl %eax, %eax
callq 0x5afc
jmp 0x61a5
leaq 0x7c1a5(%rip), %rdi     # 0x8232d
xorl %eax, %eax
callq 0x5afc
xorl %r15d, %r15d
jmp 0x61d9
leaq 0x7c192(%rip), %rdi     # 0x8232d
xorl %eax, %eax
callq 0x5afc
xorl %r12d, %r12d
movq %r15, %rdi
callq 0x278d4
testq %r12, %r12
je 0x61ba
movq %r12, %rdi
callq 0x284d0
testq %rbp, %rbp
leaq 0x7c1ff(%rip), %r12     # 0x823c3
je 0x6200
movq %rbp, %rdi
jmp 0x61fb
leaq 0x7c1a6(%rip), %rdi     # 0x82378
xorl %eax, %eax
callq 0x5afc
xorl %r12d, %r12d
movq %rbp, %rdi
callq 0x150be
movq %r12, %rdi
callq 0x15a32
testq %r15, %r15
leaq 0x7c1cd(%rip), %r12     # 0x823c3
je 0x6200
movq %r15, %rdi
callq 0xb771
movq %r13, %rdi
callq 0xb771
testl %eax, %eax
movq 0x10(%rsp), %rbp
leaq 0x18(%rsp), %r13
jns 0x6228
movq (%rbx,%r14,8), %rsi
leaq 0x7beb2(%rip), %rdi     # 0x820d3
xorl %eax, %eax
callq 0x5afc
incq %r14
jmp 0x5e6a
leaq 0x7c141(%rip), %rdi     # 0x82378
jmp 0x619b
cmpl $-0x1, %eax
je 0x61dc
leaq 0x7c166(%rip), %rdi     # 0x823ae
movq 0x8(%rsp), %rsi
xorl %eax, %eax
callq 0x5afc
jmp 0x61dc
cmpl $-0x1, %eax
je 0x61a5
leaq 0x7c148(%rip), %rdi     # 0x823ae
movq 0x8(%rsp), %rsi
xorl %eax, %eax
callq 0x5afc
jmp 0x61a5
movq 0xa8d32(%rip), %rax     # 0xaefb0
movq (%rax), %rdi
callq 0x44c0
testl %eax, %eax
je 0x636e
callq 0x4050
cmpl $0x9, (%rax)
je 0x636e
leaq 0x7be54(%rip), %rdi     # 0x820f7
xorl %eax, %eax
callq 0x5afc
jmp 0x636e
leaq 0x7bdc8(%rip), %rdi     # 0x8207e
movq %r12, %rsi
xorl %eax, %eax
callq 0x5afc
jmp 0x636e
leaq 0x7bfe3(%rip), %rdi     # 0x822af
xorl %eax, %eax
callq 0x5afc
movq %r15, %rdi
callq 0x6d20
jmp 0x636e
leaq 0x7bfe3(%rip), %rdi     # 0x822ca
movq %r14, %rsi
xorl %eax, %eax
callq 0x5afc
movq %r15, %rdi
callq 0x6d20
jmp 0x6366
js 0x6304
movq 0x10(%rsp), %r14
jmp 0x6325
leaq 0x7bfe8(%rip), %rdi     # 0x822f3
movq 0x10(%rsp), %r14
movq %r14, %rsi
xorl %eax, %eax
callq 0x5afc
movq %r15, %rdi
callq 0x6d20
xorl %r15d, %r15d
movq %r13, %rdi
callq 0x6cc2
testl %eax, %eax
jns 0x6344
leaq 0x7bd9b(%rip), %rdi     # 0x820d3
movq 0x8(%rsp), %rsi
xorl %eax, %eax
callq 0x5afc
testq %r15, %r15
je 0x6366
movq %r15, %rdi
callq 0x6cc2
testl %eax, %eax
jns 0x6366
leaq 0x7bd77(%rip), %rdi     # 0x820d3
movq %r14, %rsi
xorl %eax, %eax
callq 0x5afc
movq %rbx, %rdi
callq 0x45e0
movl 0xa91f8(%rip), %eax     # 0xaf56c
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpl $0x1, %eax
je 0x63b0
cmpl $0x2, %eax
jne 0x639e
movq 0xa8c1c(%rip), %rax     # 0xaefb0
movq (%rax), %rdi
xorl %esi, %esi
callq 0x63cd
movq 0xa8c2b(%rip), %rax     # 0xaefd0
movq (%rax), %rdi
pushq $0x1
popq %rsi
callq 0x63cd
callq 0x8a6c
leaq 0x7bc85(%rip), %rdi     # 0x82041
movq %rax, %rsi
xorl %eax, %eax
callq 0x4060
xorl %edi, %edi
callq 0x4610