// File: /workspace/github_c_makefile_star2_O3/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, %r12
movl %edi, %r13d
movl $0x0, 0xc74c2(%rip)     # 0xcd56c
leaq 0xa0f8a(%rip), %rdx     # 0xa703b
leaq 0xc6578(%rip), %rcx     # 0xcc630
xorl %r8d, %r8d
callq 0x48b0
testl %eax, %eax
js 0x6168
leaq 0xa0f6c(%rip), %rbx     # 0xa703b
leaq 0xc655a(%rip), %r14     # 0xcc630
leaq 0xc7447(%rip), %r15     # 0xcd524
movl $0x1, %ebp
cmpl $0x62, %eax
jle 0x6106
cmpl $0x76, %eax
je 0x6135
cmpl $0x68, %eax
je 0x6140
cmpl $0x63, %eax
jne 0x6884
movl $0x2, 0xc7460(%rip)     # 0xcd564
jmp 0x614c
cmpl $0x47, %eax
jg 0x6120
cmpl $0x43, %eax
jne 0x683b
movl $0x3, 0xc7446(%rip)     # 0xcd564
jmp 0x614c
cmpl $0x48, %eax
jne 0x6884
movl $0x0, 0xc73ed(%rip)     # 0xcd520
jmp 0x614c
incl (%r15)
incl 0xc742a(%rip)           # 0xcd568
jmp 0x614c
movl %ebp, 0xc741e(%rip)     # 0xcd564
movl %ebp, 0xc73d4(%rip)     # 0xcd520
movl %r13d, %edi
movq %r12, %rsi
movq %rbx, %rdx
movq %r14, %rcx
xorl %r8d, %r8d
callq 0x48b0
testl %eax, %eax
jns 0x60e2
movq 0xc6e69(%rip), %rax     # 0xccfd8
movslq (%rax), %rbp
cmpl %r13d, %ebp
je 0x6889
cmpl $0x3, 0xc73e2(%rip)     # 0xcd564
jne 0x6304
leal 0x2(%rbp), %eax
cmpl %r13d, %eax
jne 0x688e
movq (%r12,%rbp,8), %rbx
movq 0x8(%r12,%rbp,8), %r14
leaq 0xa121f(%rip), %rsi     # 0xa73c3
movq %rbx, %rdi
xorl %eax, %eax
callq 0x7b1c
testq %rax, %rax
je 0x67a2
movq %rax, %r15
movq %rbx, 0x8(%rsp)
movl $0x100000, %edi         # imm = 0x100000
callq 0x46c0
testq %rax, %rax
je 0x67b5
movq %rax, %rbx
leaq 0xa0e50(%rip), %rsi     # 0xa702c
movq %r14, (%rsp)
movq %r14, %rdi
xorl %eax, %eax
callq 0x7b1c
testq %rax, %rax
je 0x67cd
movq %rax, %r13
movq 0x8(%r15), %rbp
movq 0x10(%r15), %r14
subq %rbp, %r14
movl $0x100000, %eax         # imm = 0x100000
cmpq %rax, %r14
movl $0x100000, %r12d        # imm = 0x100000
cmovbq %r14, %r12
movq %rbx, %rdi
movq %rbp, %rsi
movq %r12, %rdx
callq 0x43d0
addq %r12, %rbp
movq %rbp, 0x8(%r15)
movl $0x100000, %ebp         # imm = 0x100000
cmpq $0xfffff, %r14          # imm = 0xFFFFF
ja 0x625f
testb $0x2, 0x30(%r15)
je 0x6253
movl $0x100000, %edx         # imm = 0x100000
movq %r15, %rdi
movq %rbx, %rsi
movq %r12, %rcx
callq 0x6e01
movq %rax, %r14
movq %r14, %rbp
testq %r14, %r14
jle 0x675a
testb $0x2, 0x30(%r13)
movq 0x8(%r13), %rdi
movq 0x18(%r13), %r14
jne 0x6297
movq %r14, %rax
subq %rdi, %rax
cmpq %rbp, %rax
jae 0x6297
addq %rbp, %r14
subq (%r13), %r14
movq %r13, %rdi
movq %r14, %rsi
callq 0x6afc
movq 0x8(%r13), %rdi
movq 0x18(%r13), %r14
movq %r14, 0x10(%r13)
subq %rdi, %r14
cmpq %rbp, %r14
ja 0x62a5
cmpq (%r13), %rdi
je 0x62c5
cmpq %rbp, %r14
movq %rbp, %r12
cmovbq %r14, %r12
movq %rbx, %rsi
movq %r12, %rdx
callq 0x43d0
addq %r12, 0x8(%r13)
cmpq %rbp, %r14
jb 0x62c8
jmp 0x62dc
xorl %r12d, %r12d
movq %r13, %rdi
movq %rbx, %rsi
movq %rbp, %rdx
movq %r12, %rcx
callq 0x6fd8
movq %rax, %r12
cmpq %rbp, %r12
je 0x61f6
leaq 0xa0ff0(%rip), %rdi     # 0xa72dc
movq (%rsp), %rsi
xorl %eax, %eax
callq 0x4a20
movq %r13, %rdi
callq 0x7217
jmp 0x6770
cmpl %r13d, %ebp
jge 0x672d
leaq 0xa10af(%rip), %rbx     # 0xa73c3
movq %r12, (%rsp)
movl %r13d, 0x8(%rsp)
leaq (%r12,%rbp,8), %r15
movq (%r15), %rdi
movq %rbx, %rsi
xorl %eax, %eax
callq 0x7b1c
testq %rax, %rax
je 0x659e
movq %rax, %r14
cmpl $0x0, 0xc7223(%rip)     # 0xcd564
je 0x642d
movq (%r15), %rsi
movq %r14, %rdi
movq %rbx, %rdx
callq 0xb3d9
testq %rax, %rax
je 0x6483
movq %rax, %r13
movq %rax, %rdi
callq 0xd0df
movl (%rax), %eax
cmpl $0x2, %eax
je 0x64c3
cmpl $0x1, %eax
jne 0x6581
movq (%r15), %rbx
movq %r13, %rdi
callq 0x1b741
movq %rax, %r12
testq %rax, %rax
je 0x6647
leaq 0xa39ff(%rip), %rdi     # 0xa9d9a
leaq 0xa0c8a(%rip), %rsi     # 0xa702c
callq 0xbbc0
testq %rax, %rax
je 0x6691
movq %rax, %r14
cmpl $0x0, 0xc7166(%rip)     # 0xcd520
je 0x63cf
movq %r14, %rdi
movq %r12, %rsi
callq 0x1c93a
testl %eax, %eax
jne 0x66a4
cmpl $0x2, 0xc718e(%rip)     # 0xcd564
jne 0x66bb
movq %rbx, 0x10(%rsp)
callq 0x18975
movq %rax, %rbx
testq %rax, %rax
je 0x66ad
movq %r13, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x1f70f
testl %eax, %eax
js 0x65ad
movq %r14, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x22f52
testl %eax, %eax
jns 0x63f2
leaq 0xa0f6b(%rip), %rdi     # 0xa738c
xorl %eax, %eax
callq 0x4a20
jmp 0x66bd
movq (%r15), %rsi
movq %r14, %rdi
movq %r15, %r12
leaq 0x18(%rsp), %r15
movq %r15, %rdx
callq 0x9383
testl %eax, %eax
js 0x65e9
movq %r15, %rdi
callq 0xa188
movq %rax, %rbx
movq (%r12), %rsi
leaq 0xa0c4a(%rip), %rdi     # 0xa70ab
movq %rax, %rdx
xorl %eax, %eax
callq 0x4060
movq %rbx, %rdi
leaq 0xa0f4e(%rip), %rbx     # 0xa73c3
callq 0x45e0
movq %r12, %r15
movq (%rsp), %r12
jmp 0x64ae
callq 0x4050
cmpl $0x8, (%rax)
movq (%r15), %rsi
movl 0x8(%rsp), %r13d
jne 0x6634
cmpl $0x0, 0xc70c8(%rip)     # 0xcd568
je 0x6634
movq %r14, %rdi
callq 0x6893
movq %r14, %rdi
callq 0x71b7
testl %eax, %eax
jns 0x6707
jmp 0x66f6
movq (%r15), %r14
movq %r13, %rdi
callq 0x30c97
testq %rax, %rax
je 0x6665
movq %rax, %r12
movq %r14, 0x10(%rsp)
leaq 0xa38b4(%rip), %rdi     # 0xa9d9a
leaq 0xa0b3f(%rip), %rsi     # 0xa702c
callq 0xbbc0
movq %rax, %r14
leaq 0xa0e31(%rip), %rdi     # 0xa732d
testq %rax, %rax
je 0x660c
cmpl $0x0, 0xc7014(%rip)     # 0xcd520
je 0x6528
movq %r14, %rdi
movq %r12, %rsi
callq 0x3196a
leaq 0xa0e2e(%rip), %rdi     # 0xa734e
testl %eax, %eax
jne 0x660c
cmpl $0x2, 0xc7035(%rip)     # 0xcd564
jne 0x6613
callq 0x31d1e
leaq 0xa0e37(%rip), %rdi     # 0xa7378
testq %rax, %rax
je 0x660c
movq %rax, %rbx
movq %r13, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x322f9
testl %eax, %eax
js 0x65ce
movq %r14, %rdi
movq %r12, %rsi
movq %rbx, %rdx
callq 0x33c66
testl %eax, %eax
jns 0x654d
leaq 0xa0e14(%rip), %rdi     # 0xa738c
xorl %eax, %eax
callq 0x4a20
jmp 0x65d7
cmpl $0x0, 0xc6fe0(%rip)     # 0xcd568
je 0x6687
movq (%r15), %rsi
movq %r14, %rdi
callq 0x6893
jmp 0x66e5
movq (%r15), %rsi
leaq 0xa0ad6(%rip), %rdi     # 0xa707e
jmp 0x6700
cmpl $-0x1, %eax
je 0x66bd
leaq 0xa0df1(%rip), %rdi     # 0xa73ae
movq 0x10(%rsp), %rsi
xorl %eax, %eax
callq 0x4a20
jmp 0x66bd
cmpl $-0x1, %eax
jne 0x6715
movq %r12, %rdi
callq 0x30af4
movq %rbx, %rdi
callq 0x31ec9
jmp 0x661b
movq (%r12), %rsi
leaq 0xa0a9a(%rip), %rdi     # 0xa708e
xorl %eax, %eax
callq 0x4a20
movq %r14, %rdi
callq 0x7217
movq (%rsp), %r12
jmp 0x6707
xorl %eax, %eax
callq 0x4a20
movq %r12, %rdi
callq 0x30af4
leaq 0xa0da1(%rip), %rbx     # 0xa73c3
testq %r14, %r14
movq (%rsp), %r12
jne 0x66dd
jmp 0x66e5
leaq 0xa0aac(%rip), %rdi     # 0xa70e7
xorl %eax, %eax
callq 0x4a20
jmp 0x64ae
callq 0x4050
movl $0x0, (%rax)
leaq 0xa0cb3(%rip), %rdi     # 0xa730c
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4a20
jmp 0x669f
callq 0x4050
movl $0x0, (%rax)
leaq 0xa0c95(%rip), %rdi     # 0xa730c
movq %r14, %rsi
xorl %eax, %eax
callq 0x4a20
movq (%rsp), %r12
jmp 0x66e5
movq %r15, %rdi
callq 0x4b33
jmp 0x66e5
leaq 0xa0c95(%rip), %rdi     # 0xa732d
xorl %eax, %eax
callq 0x4a20
xorl %r14d, %r14d
jmp 0x66bb
leaq 0xa0ca3(%rip), %rdi     # 0xa734e
jmp 0x66b4
leaq 0xa0cc4(%rip), %rdi     # 0xa7378
xorl %eax, %eax
callq 0x4a20
xorl %ebx, %ebx
movq %r12, %rdi
callq 0x18022
movq %rbx, %rdi
callq 0x18a4b
testq %r14, %r14
movq (%rsp), %r12
leaq 0xa0ce8(%rip), %rbx     # 0xa73c3
je 0x66e5
movq %r14, %rdi
callq 0xce22
movq %r13, %rdi
callq 0xce22
testl %eax, %eax
movl 0x8(%rsp), %r13d
jns 0x6707
movq (%r15), %rsi
leaq 0xa09d3(%rip), %rdi     # 0xa70d3
xorl %eax, %eax
callq 0x4a20
incq %rbp
cmpl %r13d, %ebp
jne 0x631d
jmp 0x672d
leaq 0xa0c92(%rip), %rdi     # 0xa73ae
movq 0x10(%rsp), %rsi
xorl %eax, %eax
callq 0x4a20
jmp 0x65d7
movq 0xc687c(%rip), %rax     # 0xccfb0
movq (%rax), %rdi
callq 0x44c0
testl %eax, %eax
je 0x678d
callq 0x4050
cmpl $0x9, (%rax)
je 0x678d
leaq 0xa09a6(%rip), %rdi     # 0xa70f7
xorl %eax, %eax
callq 0x4a20
jmp 0x678d
js 0x67e9
movq %r13, %rdi
callq 0x71b7
testl %eax, %eax
js 0x680c
testq %r15, %r15
je 0x6785
movq %r15, %rdi
callq 0x71b7
testl %eax, %eax
js 0x6823
movq %rbx, %rdi
callq 0x45e0
movl 0xc6dd9(%rip), %eax     # 0xcd56c
addq $0x38, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xa08d5(%rip), %rdi     # 0xa707e
movq %rbx, %rsi
xorl %eax, %eax
callq 0x4a20
jmp 0x678d
leaq 0xa0af3(%rip), %rdi     # 0xa72af
xorl %eax, %eax
callq 0x4a20
movq %r15, %rdi
callq 0x7217
jmp 0x678d
leaq 0xa0af6(%rip), %rdi     # 0xa72ca
movq (%rsp), %rsi
xorl %eax, %eax
callq 0x4a20
movq %r15, %rdi
callq 0x7217
jmp 0x6785
leaq 0xa0b03(%rip), %rdi     # 0xa72f3
movq 0x8(%rsp), %rsi
xorl %eax, %eax
callq 0x4a20
movq %r15, %rdi
callq 0x7217
xorl %r15d, %r15d
jmp 0x6760
leaq 0xa08c0(%rip), %rdi     # 0xa70d3
movq (%rsp), %rsi
xorl %eax, %eax
callq 0x4a20
jmp 0x6770
leaq 0xa08a9(%rip), %rdi     # 0xa70d3
movq 0x8(%rsp), %rsi
xorl %eax, %eax
callq 0x4a20
jmp 0x6785
cmpl $0x1, %eax
je 0x6867
cmpl $0x2, %eax
jne 0x6884
movq 0xc6764(%rip), %rax     # 0xccfb0
movq (%rax), %rcx
leaq 0xa08c0(%rip), %rdi     # 0xa7116
movl $0x198, %esi            # imm = 0x198
movl $0x1, %edx
callq 0x49f0
jmp 0x687d
callq 0x925d
leaq 0xa07ce(%rip), %rdi     # 0xa7041
movq %rax, %rsi
xorl %eax, %eax
callq 0x4060
xorl %edi, %edi
callq 0x4610
callq 0x4ba0
callq 0x4b79
callq 0x4b52