// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/test/test_view.c
// Function: main
int main(int argc, char *argv[])
{
    htsFile *in, *out;
    char moder[8];
    char modew[800];
    int c, exit_code = EXIT_SUCCESS;
    hts_opt *in_opts = NULL, *out_opts = NULL;
    char *out_fn = "-";

    struct opts opts;
    opts.fn_ref = NULL;
    opts.flag = 0;
    opts.clevel = -1;
    opts.ignore_sam_err = 0;
    opts.nreads = 0;
    opts.extra_hdr_nuls = 0;
    opts.benchmark = 0;
    opts.nthreads = 0; // shared pool
    opts.multi_reg = 0;
    opts.index = NULL;
    opts.min_shift = 0;

    while ((c = getopt(argc, argv, "DSIt:i:bzCfFul:o:N:BZ:@:Mx:m:p:v")) >= 0) {
        switch (c) {
        case 'D': opts.flag |= READ_CRAM; break;
        case 'S': opts.flag |= READ_COMPRESSED; break;
        case 'I': opts.ignore_sam_err = 1; break;
        case 't': opts.fn_ref = optarg; break;
        case 'i': if (hts_opt_add(&in_opts, optarg)) return 1; break;
        case 'b': opts.flag |= WRITE_BINARY_COMP; break;
        case 'z': opts.flag |= WRITE_COMPRESSED; break;
        case 'C': opts.flag |= WRITE_CRAM; break;
        case 'f': opts.flag |= WRITE_FASTQ; break;
        case 'F': opts.flag |= WRITE_FASTA; break;
        case 'u': opts.flag |= WRITE_UNCOMPRESSED; break; // eg u-BAM not SAM
        case 'l': opts.clevel = atoi(optarg); break;
        case 'o': if (hts_opt_add(&out_opts, optarg)) return 1; break;
        case 'N': opts.nreads = atoi(optarg); break;
        case 'B': opts.benchmark = 1; break;
        case 'Z': opts.extra_hdr_nuls = atoi(optarg); break;
        case 'M': opts.multi_reg = 1; break;
        case '@': opts.nthreads = atoi(optarg); break;
        case 'x': opts.index = optarg; break;
        case 'm': opts.min_shift = atoi(optarg); break;
        case 'p': out_fn = optarg; break;
        case 'v': hts_verbose++; break;
        }
    }
    if (argc == optind) {
        fprintf(stderr, "Usage: test_view [-DSI] [-t fn_ref] [-i option=value] [-bC] [-l level] [-o option=value] [-N num_reads] [-B] [-Z hdr_nuls] [-@ num_threads] [-x index_fn] [-m min_shift] [-p out] [-v] <in.bam>|<in.sam>|<in.cram> [region]\n");
        fprintf(stderr, "\n");
        fprintf(stderr, "-D: read CRAM format (mode 'c')\n");
        fprintf(stderr, "-S: read compressed BCF, BAM, FAI (mode 'b')\n");
        fprintf(stderr, "-I: ignore SAM parsing errors\n");
        fprintf(stderr, "-t: fn_ref: load CRAM references from the specified fasta file instead of @SQ headers when writing a CRAM file\n");
        fprintf(stderr, "-i: option=value: set an option for CRAM input\n");
        fprintf(stderr, "\n");
        fprintf(stderr, "-b: write binary compressed BCF, BAM, FAI (mode 'b')\n");
        fprintf(stderr, "-z: write text compressed VCF.gz, SAM.gz or FASTQ.gz (mode 'z')\n");
        fprintf(stderr, "-C: write CRAM format (mode 'c')\n");
        fprintf(stderr, "-f: write FASTQ format (mode 'f')\n");
        fprintf(stderr, "-l 0-9: set zlib compression level\n");
        fprintf(stderr, "-o option=value: set an option for CRAM output\n");
        fprintf(stderr, "-N: num_reads: limit the output to the first num_reads reads\n");
        fprintf(stderr, "\n");
        fprintf(stderr, "-B: enable benchmarking\n");
        fprintf(stderr, "-M: use hts_itr_multi iterator\n");
        fprintf(stderr, "-Z hdr_nuls: append specified number of null bytes to the SAM header\n");
        fprintf(stderr, "-@ num_threads: use thread pool with specified number of threads\n\n");
        fprintf(stderr, "-x fn: write index to fn\n");
        fprintf(stderr, "-m min_shift: specifies BAI/CSI bin size; 0 is BAI(BAM) or TBI(VCF), 14 is CSI default\n");
        fprintf(stderr, "-p out_fn: output to out_fn instead of stdout\n");
        fprintf(stderr, "-v: increase verbosity\n");
        fprintf(stderr, "The region list entries should be specified as 'reg:beg-end', with intervals of a region being disjunct and sorted by the starting coordinate.\n");
        return 1;
    }
    strcpy(moder, "r");
    if (opts.flag & READ_CRAM) strcat(moder, "c");
    else if ((opts.flag & READ_COMPRESSED) == 0) strcat(moder, "b");

    in = hts_open(argv[optind], moder);
    if (in == NULL) {
        fprintf(stderr, "Error opening \"%s\"\n", argv[optind]);
        return EXIT_FAILURE;
    }

    strcpy(modew, "w");
    if (opts.clevel >= 0 && opts.clevel <= 9)
        snprintf(modew + 1, sizeof(modew) - 1, "%d", opts.clevel);
    if (opts.flag & WRITE_CRAM) strcat(modew, "c");
    else if (opts.flag & WRITE_BINARY_COMP) strcat(modew, "b");
    else if (opts.flag & WRITE_COMPRESSED) strcat(modew, "z");
    else if (opts.flag & WRITE_UNCOMPRESSED) strcat(modew, "bu");
    if (opts.flag & WRITE_FASTQ) strcat(modew, "f");
    else if (opts.flag & WRITE_FASTA) strcat(modew, "F");
    out = hts_open(out_fn, modew);
    if (out == NULL) {
        fprintf(stderr, "Error opening standard output\n");
        return EXIT_FAILURE;
    }

    // Process any options; currently cram only.
    if (hts_opt_apply(in, in_opts))
        return EXIT_FAILURE;
    hts_opt_free(in_opts);

    if (hts_opt_apply(out, out_opts))
        return EXIT_FAILURE;
    hts_opt_free(out_opts);

    // Create and share the thread pool
    htsThreadPool p = {NULL, 0};
    if (opts.nthreads > 0) {
        p.pool = hts_tpool_init(opts.nthreads);
        if (!p.pool) {
            fprintf(stderr, "Error creating thread pool\n");
            exit_code = 1;
        } else {
            hts_set_opt(in,  HTS_OPT_THREAD_POOL, &p);
            hts_set_opt(out, HTS_OPT_THREAD_POOL, &p);
        }
    }

    int ret;
    switch (hts_get_format(in)->category) {
    case sequence_data:
        ret = sam_loop(argc, argv, optind, &opts, in, out);
        break;

    case variant_data:
        ret = vcf_loop(argc, argv, optind, &opts, in, out);
        break;

    default:
        fprintf(stderr, "Unsupported or unknown category of data in input file\n");
        return EXIT_FAILURE;
    }

    if (ret != 0)
        exit_code = EXIT_FAILURE;

    ret = hts_close(out);
    if (ret < 0) {
        fprintf(stderr, "Error closing output.\n");
        exit_code = EXIT_FAILURE;
    }
    ret = hts_close(in);
    if (ret < 0) {
        fprintf(stderr, "Error closing input.\n");
        exit_code = EXIT_FAILURE;
    }

    if (p.pool)
        hts_tpool_destroy(p.pool);

    if (fclose(stdout) != 0 && errno != EBADF) {
        fprintf(stderr, "Error closing standard output.\n");
        exit_code = EXIT_FAILURE;
    }

    return exit_code;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3d8, %rsp            # imm = 0x3D8
leaq 0x30(%rsp), %rax
andq $0x0, (%rax)
leaq 0x28(%rsp), %rax
andq $0x0, (%rax)
movq %rsi, %r14
movl %edi, %ebp
leaq 0x7ec4f(%rip), %rax     # 0x85015
movq %rax, 0x40(%rsp)
pushq $-0x1
popq %rax
movl %eax, 0xc(%rsp)
movq $0x0, 0x48(%rsp)
leaq 0x7be47(%rip), %r13     # 0x82229
leaq 0x7bc1b(%rip), %r12     # 0x82004
pushq $0x1
popq %rax
movl %eax, 0x8(%rsp)
leaq 0x7bc5d(%rip), %rbx     # 0x82054
movq $0x0, 0x58(%rsp)
xorl %r15d, %r15d
movl $0x0, 0x20(%rsp)
movl $0x0, 0x1c(%rsp)
movl $0x0, 0x10(%rsp)
movl $0x0, 0x18(%rsp)
movl $0x0, 0x14(%rsp)
movq $0x0, 0x50(%rsp)
movl $0x0, 0x24(%rsp)
movl %ebp, %edi
movq %r14, %rsi
movq %r13, %rdx
callq 0x40e0
testl %eax, %eax
js 0x65d0
leal -0x62(%rax), %ecx
cmpl $0x18, %ecx
ja 0x6468
movslq (%rbx,%rcx,4), %rax
addq %rbx, %rax
jmpq *%rax
orl $0x2, %r15d
jmp 0x643c
leal -0x40(%rax), %ecx
cmpl $0x13, %ecx
ja 0x648e
movslq (%r12,%rcx,4), %rax
addq %r12, %rax
jmpq *%rax
movq 0xa8b40(%rip), %rax     # 0xaefc0
movq (%rax), %rdi
callq 0x4810
movl %eax, 0x14(%rsp)
jmp 0x643c
cmpl $0x5a, %eax
jne 0x643c
movq 0xa8b26(%rip), %rax     # 0xaefc0
movq (%rax), %rdi
callq 0x4810
movl %eax, 0x10(%rsp)
jmp 0x643c
orl $0x20, %r15d
jmp 0x643c
movq 0xa8b0b(%rip), %rax     # 0xaefc0
movq (%rax), %rdi
callq 0x4810
movl %eax, 0x24(%rsp)
jmp 0x643c
leaq 0xa9033(%rip), %rax     # 0xaf500
incl (%rax)
jmp 0x643c
movq 0xa8ae5(%rip), %rax     # 0xaefc0
movq (%rax), %rsi
leaq 0x30(%rsp), %rdi
jmp 0x6529
movq 0xa8ad4(%rip), %rax     # 0xaefc0
movq (%rax), %rdi
callq 0x4810
movl %eax, 0xc(%rsp)
jmp 0x643c
movq 0xa8abc(%rip), %rax     # 0xaefc0
movq (%rax), %rax
movq %rax, 0x58(%rsp)
jmp 0x643c
orl $0x40, %r15d
jmp 0x643c
movq 0xa8a9f(%rip), %rax     # 0xaefc0
movq (%rax), %rsi
leaq 0x28(%rsp), %rdi
callq 0x8e4e
testl %eax, %eax
je 0x643c
jmp 0x6b25
movq 0xa8a7e(%rip), %rax     # 0xaefc0
movq (%rax), %rax
movq %rax, 0x40(%rsp)
jmp 0x643c
movq 0xa8a6a(%rip), %rax     # 0xaefc0
movq (%rax), %rax
movq %rax, 0x50(%rsp)
jmp 0x643c
orl $0x10, %r15d
jmp 0x643c
orl $0x80, %r15d
jmp 0x643c
orl $0x8, %r15d
jmp 0x643c
orl $0x4, %r15d
jmp 0x643c
movq 0xa8a2f(%rip), %rax     # 0xaefc0
movq (%rax), %rdi
callq 0x4810
movl %eax, 0x20(%rsp)
jmp 0x643c
pushq $0x1
popq %rax
movl %eax, 0x1c(%rsp)
jmp 0x643c
pushq $0x1
popq %rax
movq %rax, 0x48(%rsp)
jmp 0x643c
pushq $0x1
popq %rax
movl %eax, 0x18(%rsp)
jmp 0x643c
orl $0x1, %r15d
jmp 0x643c
movl 0x24(%rsp), %eax
movl %eax, 0xa8(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0xa0(%rsp)
movl 0x14(%rsp), %eax
movl %eax, 0x98(%rsp)
movl 0x18(%rsp), %eax
movl %eax, 0x9c(%rsp)
movl 0x10(%rsp), %eax
movl %eax, 0x90(%rsp)
movl 0x1c(%rsp), %eax
movl %eax, 0x94(%rsp)
movl 0x20(%rsp), %eax
movl %eax, 0x8c(%rsp)
movl 0xc(%rsp), %eax
movl %eax, 0x84(%rsp)
movl %r15d, 0x80(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0x78(%rsp)
movq 0x48(%rsp), %rax
movl %eax, 0x88(%rsp)
movq 0xa8991(%rip), %r12     # 0xaefe0
movslq (%r12), %rbx
cmpl %ebp, %ebx
je 0x6835
movw $0x72, 0x38(%rsp)
movw $0x63, %r13w
testb $0x4, %r15b
jne 0x6678
movw $0x62, %r13w
testb $0x1, %r15b
jne 0x6688
leaq 0x38(%rsp), %rdi
callq 0x41d0
movw %r13w, 0x38(%rsp,%rax)
movq (%r14,%rbx,8), %rdi
leaq 0x38(%rsp), %rsi
callq 0x8e47
testq %rax, %rax
je 0x6a33
movq %rax, %rbx
movw $0x77, 0xb0(%rsp)
movl 0xc(%rsp), %ecx
cmpl $0x9, %ecx
ja 0x66d0
leaq 0xb1(%rsp), %rdi
leaq 0x8b8a5(%rip), %rdx     # 0x91f69
movl $0x31f, %esi            # imm = 0x31F
xorl %eax, %eax
callq 0x4830
testb $0x8, %r15b
jne 0x6709
testb $0x2, %r15b
jne 0x6722
testb $0x20, %r15b
jne 0x673b
testb $0x10, %r15b
je 0x6752
leaq 0xb0(%rsp), %rdi
callq 0x41d0
movw $0x7562, 0xb0(%rsp,%rax) # imm = 0x7562
movb $0x0, 0xb2(%rsp,%rax)
jmp 0x6752
leaq 0xb0(%rsp), %rdi
callq 0x41d0
movw $0x63, 0xb0(%rsp,%rax)
jmp 0x6752
leaq 0xb0(%rsp), %rdi
callq 0x41d0
movw $0x62, 0xb0(%rsp,%rax)
jmp 0x6752
leaq 0xb0(%rsp), %rdi
callq 0x41d0
movw $0x7a, 0xb0(%rsp,%rax)
movw $0x66, %r13w
testb $0x40, %r15b
jne 0x6767
movw $0x46, %r13w
testb %r15b, %r15b
jns 0x677d
leaq 0xb0(%rsp), %rdi
callq 0x41d0
movw %r13w, 0xb0(%rsp,%rax)
leaq 0xb0(%rsp), %rsi
movq 0x40(%rsp), %rdi
callq 0x8e47
testq %rax, %rax
je 0x6a58
movq %rax, %r15
movq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0x8cb9
testl %eax, %eax
jne 0x6b25
movq 0x30(%rsp), %rdi
callq 0x9d01
movq 0x28(%rsp), %rsi
movq %r15, %rdi
callq 0x8cb9
testl %eax, %eax
jne 0x6b25
movq 0x28(%rsp), %rdi
callq 0x9d01
xorps %xmm0, %xmm0
movaps %xmm0, 0x60(%rsp)
movl 0x98(%rsp), %edi
testl %edi, %edi
jle 0x6a79
callq 0x2260f
movq %rax, 0x60(%rsp)
testq %rax, %rax
je 0x6b88
movl $0x0, 0x8(%rsp)
pushq $0x66
popq %rsi
leaq 0x60(%rsp), %r13
movq %rbx, %rdi
movq %r13, %rdx
xorl %eax, %eax
callq 0x97bf
movq %r15, %rdi
pushq $0x66
popq %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0x97bf
jmp 0x6a81
movq 0xa879c(%rip), %r15     # 0xaefd8
movq (%r15), %rcx
leaq 0x7ba04(%rip), %rdi     # 0x8224a
pushq $0x1
popq %rbx
movl $0xdc, %esi
movq %rbx, %rdx
callq 0x49c0
movq (%r15), %rsi
pushq $0xa
popq %rbp
movl %ebp, %edi
callq 0x4660
movq (%r15), %rcx
leaq 0x7baba(%rip), %rdi     # 0x82327
pushq $0x20
popq %rsi
movq %rbx, %rdx
callq 0x49c0
movq (%r15), %rcx
leaq 0x7bac6(%rip), %rdi     # 0x82348
pushq $0x2d
popq %rsi
movq %rbx, %rdx
callq 0x49c0
movq (%r15), %rcx
leaq 0x7badf(%rip), %rdi     # 0x82376
pushq $0x1e
popq %rsi
movq %rbx, %rdx
callq 0x49c0
movq (%r15), %rcx
leaq 0x7bae9(%rip), %rdi     # 0x82395
pushq $0x6f
popq %rsi
movq %rbx, %rdx
callq 0x49c0
movq (%r15), %rcx
leaq 0x7bb44(%rip), %rdi     # 0x82405
pushq $0x2f
popq %r14
movq %r14, %rsi
movq %rbx, %rdx
callq 0x49c0
movq (%r15), %rsi
movl %ebp, %edi
callq 0x4660
movq (%r15), %rcx
leaq 0x7bb51(%rip), %rdi     # 0x82435
pushq $0x35
popq %rsi
movq %rbx, %rdx
callq 0x49c0
movq (%r15), %rcx
leaq 0x7bb72(%rip), %rdi     # 0x8246b
pushq $0x40
popq %rsi
movq %rbx, %rdx
callq 0x49c0
movq (%r15), %rcx
leaq 0x7bb9e(%rip), %rdi     # 0x824ac
pushq $0x21
popq %rsi
movq %rbx, %rdx
callq 0x49c0
movq (%r15), %rcx
leaq 0x7bbab(%rip), %rdi     # 0x824ce
pushq $0x22
popq %rsi
movq %rbx, %rdx
callq 0x49c0
movq (%r15), %rcx
leaq 0x7bbb9(%rip), %rdi     # 0x824f1
pushq $0x23
popq %rsi
movq %rbx, %rdx
callq 0x49c0
movq (%r15), %rcx
leaq 0x7bbc8(%rip), %rdi     # 0x82515
movq %r14, %rsi
movq %rbx, %rdx
callq 0x49c0
movq (%r15), %rcx
leaq 0x7bbe3(%rip), %rdi     # 0x82545
pushq $0x3d
popq %rsi
movq %rbx, %rdx
callq 0x49c0
movq (%r15), %rsi
movl %ebp, %edi
callq 0x4660
movq (%r15), %rcx
leaq 0x7bc02(%rip), %rdi     # 0x82583
pushq $0x18
popq %rsi
movq %rbx, %rdx
callq 0x49c0
movq (%r15), %rcx
leaq 0x7bc06(%rip), %rdi     # 0x8259c
pushq $0x1f
popq %rsi
movq %rbx, %rdx
callq 0x49c0
movq (%r15), %rcx
leaq 0x7bc11(%rip), %rdi     # 0x825bc
pushq $0x45
popq %rsi
movq %rbx, %rdx
callq 0x49c0
movq (%r15), %rcx
leaq 0x7bc42(%rip), %rdi     # 0x82602
pushq $0x42
popq %rsi
movq %rbx, %rdx
callq 0x49c0
movq (%r15), %rcx
leaq 0x7bc70(%rip), %rdi     # 0x82645
pushq $0x19
popq %rsi
movq %rbx, %rdx
callq 0x49c0
movq (%r15), %rcx
leaq 0x7bc75(%rip), %rdi     # 0x8265f
pushq $0x57
popq %rsi
movq %rbx, %rdx
callq 0x49c0
movq (%r15), %rcx
leaq 0x7bcb8(%rip), %rdi     # 0x826b7
pushq $0x2e
popq %rsi
movq %rbx, %rdx
callq 0x49c0
movq (%r15), %rcx
leaq 0x7bcd2(%rip), %rdi     # 0x826e6
pushq $0x17
popq %rsi
movq %rbx, %rdx
callq 0x49c0
movq (%r15), %rcx
leaq 0x7bcd5(%rip), %rdi     # 0x826fe
movl $0x8f, %esi
movq %rbx, %rdx
jmp 0x6a6f
movq 0xa859e(%rip), %rax     # 0xaefd8
movq (%rax), %rdi
movslq (%r12), %rax
movq (%r14,%rax,8), %rdx
leaq 0x7bd42(%rip), %rsi     # 0x8278e
xorl %eax, %eax
callq 0x4730
jmp 0x6b25
movq 0xa8579(%rip), %rax     # 0xaefd8
movq (%rax), %rcx
leaq 0x7bd3c(%rip), %rdi     # 0x827a5
pushq $0x1e
popq %rsi
pushq $0x1
popq %rdx
callq 0x49c0
jmp 0x6b25
movl $0x0, 0x8(%rsp)
movq %rbx, %rdi
callq 0xa2b4
movl (%rax), %eax
cmpl $0x2, %eax
je 0x6ab4
cmpl $0x1, %eax
jne 0x6bd5
movl (%r12), %edx
leaq 0x78(%rsp), %rcx
movl %ebp, %edi
movq %r14, %rsi
movq %rbx, %r8
movq %r15, %r9
callq 0x5adc
jmp 0x6acd
movl (%r12), %edx
leaq 0x78(%rsp), %rcx
movl %ebp, %edi
movq %r14, %rsi
movq %rbx, %r8
movq %r15, %r9
callq 0x6055
testl %eax, %eax
pushq $0x1
popq %rbp
movl 0x8(%rsp), %eax
cmovnel %ebp, %eax
movl %eax, 0x8(%rsp)
movq %r15, %rdi
callq 0xa01d
testl %eax, %eax
js 0x6b3b
movq %rbx, %rdi
callq 0xa01d
testl %eax, %eax
js 0x6b60
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x6b04
callq 0x22fcf
movq 0xa84a5(%rip), %rax     # 0xaefb0
movq (%rax), %rdi
callq 0x44c0
testl %eax, %eax
je 0x6b25
callq 0x4050
cmpl $0x9, (%rax)
jne 0x6bb0
movl 0x8(%rsp), %eax
addq $0x3d8, %rsp            # imm = 0x3D8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xa8496(%rip), %rax     # 0xaefd8
movq (%rax), %rcx
leaq 0x7bccb(%rip), %rdi     # 0x82817
pushq $0x16
popq %rsi
pushq $0x1
popq %rdx
callq 0x49c0
pushq $0x1
popq %rax
movl %eax, 0x8(%rsp)
jmp 0x6ae9
movq 0xa8471(%rip), %rax     # 0xaefd8
movq (%rax), %rcx
leaq 0x7bcbd(%rip), %rdi     # 0x8282e
pushq $0x15
popq %rsi
pushq $0x1
popq %rdx
callq 0x49c0
pushq $0x1
popq %rax
movl %eax, 0x8(%rsp)
jmp 0x6af5
movq 0xa8449(%rip), %rax     # 0xaefd8
movq (%rax), %rcx
leaq 0x7bc2b(%rip), %rdi     # 0x827c4
pushq $0x1b
popq %rsi
pushq $0x1
popq %rdx
callq 0x49c0
pushq $0x1
popq %rax
movl %eax, 0x8(%rsp)
jmp 0x6a81
movq 0xa8421(%rip), %rax     # 0xaefd8
movq (%rax), %rcx
leaq 0x7bc83(%rip), %rdi     # 0x82844
pushq $0x1f
popq %rsi
pushq $0x1
popq %rdx
callq 0x49c0
movl %ebp, 0x8(%rsp)
jmp 0x6b25
movq 0xa83fc(%rip), %rax     # 0xaefd8
movq (%rax), %rcx
leaq 0x7bbfa(%rip), %rdi     # 0x827e0
pushq $0x36
popq %rsi
pushq $0x1
popq %rdx
callq 0x49c0
pushq $0x1
popq %rax
movl %eax, 0x8(%rsp)
jmp 0x6b25
nopl (%rax)