// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl $0x0, 0x1262ac(%rip)    # 0x12bf0c
movl -0x8(%rbp), %edi
movq -0x10(%rbp), %rsi
leaq 0xfe3cd(%rip), %rdx     # 0x10403b
leaq 0x120d9b(%rip), %rcx    # 0x126a10
xorl %eax, %eax
movl %eax, %r8d
callq 0x4890
movl %eax, -0x14(%rbp)
cmpl $0x0, %eax
jl 0x5d8e
movl -0x14(%rbp), %eax
movl %eax, -0x54(%rbp)
subl $0x1, %eax
je 0x5d45
jmp 0x5c9c
movl -0x54(%rbp), %eax
subl $0x2, %eax
je 0x5d62
jmp 0x5caa
movl -0x54(%rbp), %eax
subl $0x43, %eax
je 0x5cee
jmp 0x5cb4
movl -0x54(%rbp), %eax
subl $0x48, %eax
je 0x5d13
jmp 0x5cbe
movl -0x54(%rbp), %eax
subl $0x63, %eax
je 0x5cdf
jmp 0x5cc8
movl -0x54(%rbp), %eax
subl $0x68, %eax
je 0x5cfd
jmp 0x5cd2
movl -0x54(%rbp), %eax
subl $0x76, %eax
je 0x5d1f
jmp 0x5d75
movl $0x2, 0x12621b(%rip)    # 0x12bf04
jmp 0x5d89
movl $0x3, 0x12620c(%rip)    # 0x12bf04
jmp 0x5d89
movl $0x1, 0x1261fd(%rip)    # 0x12bf04
movl $0x1, 0x12181f(%rip)    # 0x127530
jmp 0x5d89
movl $0x0, 0x121813(%rip)    # 0x127530
jmp 0x5d89
leaq 0x12180e(%rip), %rax    # 0x127534
movl (%rax), %ecx
addl $0x1, %ecx
leaq 0x121802(%rip), %rax    # 0x127534
movl %ecx, (%rax)
movl 0x1261ce(%rip), %eax    # 0x12bf08
addl $0x1, %eax
movl %eax, 0x1261c5(%rip)    # 0x12bf08
jmp 0x5d89
callq 0xb230
movq %rax, %rsi
leaq 0xfe2ed(%rip), %rdi     # 0x104041
movb $0x0, %al
callq 0x4060
xorl %edi, %edi
callq 0x45f0
movq 0x12124f(%rip), %rax    # 0x126fb8
movq (%rax), %rdi
xorl %esi, %esi
callq 0x60c0
jmp 0x5d89
movq 0x12125c(%rip), %rax    # 0x126fd8
movq (%rax), %rdi
movl $0x1, %esi
callq 0x60c0
jmp 0x5c60
movq 0x12124b(%rip), %rax    # 0x126fe0
movl (%rax), %eax
cmpl -0x8(%rbp), %eax
jne 0x5db0
movq 0x121235(%rip), %rax    # 0x126fd8
movq (%rax), %rdi
movl $0x1, %esi
callq 0x60c0
cmpl $0x3, 0x12614d(%rip)    # 0x12bf04
jne 0x5e1a
movq 0x121220(%rip), %rax    # 0x126fe0
movl (%rax), %eax
addl $0x2, %eax
cmpl -0x8(%rbp), %eax
je 0x5dde
movq 0x121207(%rip), %rax    # 0x126fd8
movq (%rax), %rdi
movl $0x1, %esi
callq 0x60c0
movq -0x10(%rbp), %rax
movq 0x1211f7(%rip), %rcx    # 0x126fe0
movslq (%rcx), %rcx
movq (%rax,%rcx,8), %rdi
movq -0x10(%rbp), %rax
movq 0x1211e5(%rip), %rcx    # 0x126fe0
movl (%rcx), %ecx
addl $0x1, %ecx
movslq %ecx, %rcx
movq (%rax,%rcx,8), %rsi
callq 0x60f0
movl 0x1260fa(%rip), %eax    # 0x12bf0c
movl %eax, -0x4(%rbp)
jmp 0x60b5
movq 0x1211bf(%rip), %rax    # 0x126fe0
movl (%rax), %eax
movl %eax, -0x18(%rbp)
movl -0x18(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x6080
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
leaq 0xfe57e(%rip), %rsi     # 0x1043c3
movb $0x0, %al
callq 0x89c0
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x5e76
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0xfe214(%rip), %rdi     # 0x10407e
movb $0x0, %al
callq 0x5b00
jmp 0x6072
cmpl $0x0, 0x126087(%rip)    # 0x12bf04
jne 0x5efe
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq -0x40(%rbp), %rdx
callq 0xb560
cmpl $0x0, %eax
jge 0x5ec5
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0xfe1de(%rip), %rdi     # 0x10408e
movb $0x0, %al
callq 0x5b00
movq -0x20(%rbp), %rdi
callq 0x7ae0
jmp 0x6072
leaq -0x40(%rbp), %rdi
callq 0xcd00
movq %rax, -0x48(%rbp)
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x48(%rbp), %rdx
leaq 0xfe1c2(%rip), %rdi     # 0x1040ab
movb $0x0, %al
callq 0x4060
movq -0x48(%rbp), %rdi
callq 0x45c0
jmp 0x6041
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0xfe4ae(%rip), %rdx     # 0x1043c3
callq 0xd860
movq %rax, -0x50(%rbp)
cmpq $0x0, -0x50(%rbp)
je 0x5fef
movq -0x50(%rbp), %rdi
callq 0x10890
movl (%rax), %eax
movl %eax, -0x58(%rbp)
subl $0x1, %eax
je 0x5f48
jmp 0x5f3e
movl -0x58(%rbp), %eax
subl $0x2, %eax
je 0x5f5f
jmp 0x5f76
movq -0x50(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x62a0
jmp 0x5fbd
movq -0x50(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x6420
jmp 0x5fbd
cmpl $0x0, 0x125f8b(%rip)    # 0x12bf08
je 0x5f96
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x65a0
jmp 0x5fbb
callq 0x4050
movl $0x0, (%rax)
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0xfe0ff(%rip), %rdi     # 0x1040b3
movb $0x0, %al
callq 0x5b00
jmp 0x5fbd
movq -0x50(%rbp), %rdi
callq 0x10380
cmpl $0x0, %eax
jge 0x5fe5
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0xfe0f5(%rip), %rdi     # 0x1040d3
movb $0x0, %al
callq 0x5b00
movq $0x0, -0x20(%rbp)
jmp 0x603f
callq 0x4050
cmpl $0x8, (%rax)
je 0x6003
callq 0x4050
cmpl $0x8, (%rax)
jne 0x6023
cmpl $0x0, 0x125efe(%rip)    # 0x12bf08
je 0x6023
movq -0x20(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
callq 0x65a0
jmp 0x603d
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0xfe0b1(%rip), %rdi     # 0x1040e7
movb $0x0, %al
callq 0x5b00
jmp 0x603f
jmp 0x6041
cmpq $0x0, -0x20(%rbp)
je 0x6070
movq -0x20(%rbp), %rdi
callq 0x7a30
cmpl $0x0, %eax
jge 0x6070
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
leaq 0xfe06a(%rip), %rdi     # 0x1040d3
movb $0x0, %al
callq 0x5b00
jmp 0x6072
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x5e26
movq 0x120f31(%rip), %rax    # 0x126fb8
movq (%rax), %rdi
callq 0x44b0
cmpl $0x0, %eax
je 0x60ac
callq 0x4050
cmpl $0x9, (%rax)
je 0x60ac
leaq 0xfe052(%rip), %rdi     # 0x1040f7
movb $0x0, %al
callq 0x5b00
movl 0x125e5a(%rip), %eax    # 0x12bf0c
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nop