// File: /workspace/github_c_makefile_star2_O1/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 $0x3c8, %rsp            # imm = 0x3C8
movq %rsi, %rbx
movl %edi, %ebp
xorl %eax, %eax
movq %rax, 0x80(%rsp)
movq %rax, 0x78(%rsp)
movq $0x0, 0x70(%rsp)
movq %rax, 0x20(%rsp)
movabsq $-0x100000000, %rax     # imm = 0xFFFFFFFF00000000
movq %rax, 0x28(%rsp)
xorps %xmm0, %xmm0
movups %xmm0, 0x40(%rsp)
movups %xmm0, 0x30(%rsp)
movl $0x0, 0x50(%rsp)
movl 0x40(%rsp), %eax
movl %eax, 0xc(%rsp)
movl 0x38(%rsp), %eax
movl %eax, 0x8(%rsp)
movl 0x3c(%rsp), %eax
movl %eax, 0x14(%rsp)
movl 0x30(%rsp), %eax
movl %eax, 0x18(%rsp)
movl 0x34(%rsp), %eax
movl %eax, 0x10(%rsp)
movl $0xffffffff, 0x1c(%rsp) # imm = 0xFFFFFFFF
leaq 0xa3543(%rip), %rdx     # 0xaa229
callq 0x40e0
testl %eax, %eax
js 0x6eba
movq $0x0, 0x60(%rsp)
leaq 0xa6384(%rip), %rcx     # 0xad087
movq %rcx, 0x68(%rsp)
leaq 0xa32f5(%rip), %r13     # 0xaa004
leaq 0xa3513(%rip), %r12     # 0xaa229
leaq 0xa3337(%rip), %r14     # 0xaa054
movq $0x0, 0x58(%rsp)
movl $0x0, 0x4(%rsp)
xorl %r15d, %r15d
leal -0x62(%rax), %ecx
cmpl $0x18, %ecx
ja 0x6d4b
movslq (%r14,%rcx,4), %rax
addq %r14, %rax
jmpq *%rax
orl $0x2, %r15d
jmp 0x6ea3
leal -0x40(%rax), %ecx
cmpl $0x13, %ecx
ja 0x6d75
movslq (%r13,%rcx,4), %rax
addq %r13, %rax
jmpq *%rax
movq 0xc925c(%rip), %rax     # 0xcffc0
movq (%rax), %rdi
callq 0x4810
movl %eax, 0xc(%rsp)
jmp 0x6ea3
cmpl $0x5a, %eax
jne 0x6ea3
movq 0xc923b(%rip), %rax     # 0xcffc0
movq (%rax), %rdi
callq 0x4810
movl %eax, 0x8(%rsp)
jmp 0x6ea3
orl $0x20, %r15d
jmp 0x6ea3
movq 0xc921a(%rip), %rax     # 0xcffc0
movq (%rax), %rax
movq %rax, 0x58(%rsp)
jmp 0x6ea3
orl $0x10, %r15d
jmp 0x6ea3
movq 0xc91fd(%rip), %rax     # 0xcffc0
movq (%rax), %rax
movq %rax, 0x68(%rsp)
jmp 0x6ea3
orl $0x40, %r15d
jmp 0x6ea3
leaq 0xc9720(%rip), %rax     # 0xd0500
incl (%rax)
jmp 0x6ea3
movq 0xc91d2(%rip), %rax     # 0xcffc0
movq (%rax), %rsi
leaq 0x80(%rsp), %rdi
jmp 0x6e49
movq 0xc91be(%rip), %rax     # 0xcffc0
movq (%rax), %rax
movq %rax, 0x70(%rsp)
jmp 0x6ea3
movq 0xc91aa(%rip), %rax     # 0xcffc0
movq (%rax), %rdi
callq 0x4810
movl %eax, 0x1c(%rsp)
jmp 0x6ea3
movq 0xc9195(%rip), %rax     # 0xcffc0
movq (%rax), %rdi
callq 0x4810
movq %rax, 0x60(%rsp)
jmp 0x6ea3
movq 0xc917f(%rip), %rax     # 0xcffc0
movq (%rax), %rsi
leaq 0x78(%rsp), %rdi
callq 0xa746
testl %eax, %eax
je 0x6ea3
jmp 0x7160
orl $0x1, %r15d
jmp 0x6ea3
orl $0x80, %r15d
jmp 0x6ea3
movl $0x1, 0x18(%rsp)
jmp 0x6ea3
movq 0xc9149(%rip), %rax     # 0xcffc0
movq (%rax), %rdi
callq 0x4810
movl %eax, 0x10(%rsp)
jmp 0x6ea3
orl $0x4, %r15d
jmp 0x6ea3
orl $0x8, %r15d
jmp 0x6ea3
movl $0x1, 0x4(%rsp)
jmp 0x6ea3
movl $0x1, 0x14(%rsp)
movl %ebp, %edi
movq %rbx, %rsi
movq %r12, %rdx
callq 0x40e0
testl %eax, %eax
jns 0x6d31
jmp 0x6ee3
leaq 0xa61c6(%rip), %rax     # 0xad087
movq %rax, 0x68(%rsp)
xorl %r15d, %r15d
movl $0x0, 0x4(%rsp)
movq $0x0, 0x58(%rsp)
movq $0x0, 0x60(%rsp)
movq 0x60(%rsp), %rax
movl %eax, 0x50(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0x48(%rsp)
movl 0xc(%rsp), %eax
movl %eax, 0x40(%rsp)
movl 0x4(%rsp), %eax
movl %eax, 0x44(%rsp)
movl 0x8(%rsp), %eax
movl %eax, 0x38(%rsp)
movl 0x14(%rsp), %eax
movl %eax, 0x3c(%rsp)
movl 0x10(%rsp), %eax
movl %eax, 0x34(%rsp)
movl 0x1c(%rsp), %eax
movl %eax, 0x2c(%rsp)
movl %r15d, 0x28(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x20(%rsp)
movl 0x18(%rsp), %eax
movl %eax, 0x30(%rsp)
movq 0xc909c(%rip), %r13     # 0xcffe0
movslq (%r13), %r14
cmpl %ebp, %r14d
je 0x714f
movw $0x72, 0x88(%rsp)
movl 0x28(%rsp), %r15d
movw $0x63, %r12w
testb $0x4, %r15b
jne 0x6f76
movw $0x62, %r12w
testb $0x1, %r15b
jne 0x6f8c
leaq 0x88(%rsp), %rdi
callq 0x41d0
movw %r12w, 0x88(%rsp,%rax)
movq (%rbx,%r14,8), %rdi
leaq 0x88(%rsp), %rsi
callq 0xa73f
testq %rax, %rax
je 0x7156
movq %rax, %r14
movw $0x77, 0xa0(%rsp)
movl 0x2c(%rsp), %ecx
cmpl $0x9, %ecx
ja 0x6fd7
leaq 0xa1(%rsp), %rdi
leaq 0xb31b0(%rip), %rdx     # 0xba17b
movl $0x31f, %esi            # imm = 0x31F
xorl %eax, %eax
callq 0x4830
testb $0x8, %r15b
jne 0x7010
testb $0x2, %r15b
jne 0x7029
testb $0x20, %r15b
jne 0x7042
testb $0x10, %r15b
je 0x7059
leaq 0xa0(%rsp), %rdi
callq 0x41d0
movw $0x7562, 0xa0(%rsp,%rax) # imm = 0x7562
movb $0x0, 0xa2(%rsp,%rax)
jmp 0x7059
leaq 0xa0(%rsp), %rdi
callq 0x41d0
movw $0x63, 0xa0(%rsp,%rax)
jmp 0x7059
leaq 0xa0(%rsp), %rdi
callq 0x41d0
movw $0x62, 0xa0(%rsp,%rax)
jmp 0x7059
leaq 0xa0(%rsp), %rdi
callq 0x41d0
movw $0x7a, 0xa0(%rsp,%rax)
movw $0x66, %r12w
testb $0x40, %r15b
jne 0x706e
movw $0x46, %r12w
testb %r15b, %r15b
jns 0x7084
leaq 0xa0(%rsp), %rdi
callq 0x41d0
movw %r12w, 0xa0(%rsp,%rax)
leaq 0xa0(%rsp), %rsi
movq 0x68(%rsp), %rdi
callq 0xa73f
testq %rax, %rax
je 0x71bc
movq %rax, %r12
movq 0x80(%rsp), %rsi
movq %r14, %rdi
callq 0xa5ac
movl $0x1, %r15d
testl %eax, %eax
jne 0x726d
movq 0x80(%rsp), %rdi
callq 0xb6bd
movq 0x78(%rsp), %rsi
movq %r12, %rdi
callq 0xa5ac
testl %eax, %eax
jne 0x726d
movq 0x78(%rsp), %rdi
callq 0xb6bd
xorps %xmm0, %xmm0
movaps %xmm0, 0x90(%rsp)
movl 0x40(%rsp), %edi
testl %edi, %edi
jle 0x71cc
callq 0x2bc6e
movq %rax, 0x90(%rsp)
testq %rax, %rax
je 0x729c
xorl %r15d, %r15d
leaq 0x90(%rsp), %rdx
movq %r14, %rdi
movl $0x66, %esi
xorl %eax, %eax
callq 0xb0d2
movq %r12, %rdi
movl $0x66, %esi
leaq 0x90(%rsp), %rdx
xorl %eax, %eax
callq 0xb0d2
jmp 0x71cf
callq 0x4d79
jmp 0x71c1
movq %rbx, %rdi
callq 0x4d4a
jmp 0x71c1
movq 0x60(%rsp), %rax
movl %eax, 0x50(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0x48(%rsp)
movl 0xc(%rsp), %eax
movl %eax, 0x40(%rsp)
movl 0x4(%rsp), %eax
movl %eax, 0x44(%rsp)
movl 0x8(%rsp), %eax
movl %eax, 0x38(%rsp)
movl 0x14(%rsp), %eax
movl %eax, 0x3c(%rsp)
movl 0x10(%rsp), %eax
movl %eax, 0x34(%rsp)
movl 0x1c(%rsp), %eax
movl %eax, 0x2c(%rsp)
movl %r15d, 0x28(%rsp)
movq 0x70(%rsp), %rax
movq %rax, 0x20(%rsp)
movl 0x18(%rsp), %eax
movl %eax, 0x30(%rsp)
jmp 0x71c1
callq 0x4d28
movl $0x1, %r15d
jmp 0x726d
xorl %r15d, %r15d
movq %r14, %rdi
callq 0xbc61
movl (%rax), %eax
cmpl $0x2, %eax
je 0x7202
cmpl $0x1, %eax
jne 0x72b6
movl (%r13), %edx
leaq 0x20(%rsp), %rcx
movl %ebp, %edi
movq %rbx, %rsi
movq %r14, %r8
movq %r12, %r9
callq 0x643c
jmp 0x721b
movl (%r13), %edx
leaq 0x20(%rsp), %rcx
movl %ebp, %edi
movq %rbx, %rsi
movq %r14, %r8
movq %r12, %r9
callq 0x6975
testl %eax, %eax
movl $0x1, %eax
cmovnel %eax, %r15d
movq %r12, %rdi
callq 0xb9a9
testl %eax, %eax
js 0x7282
movq %r14, %rdi
callq 0xb9a9
testl %eax, %eax
js 0x728f
movq 0x90(%rsp), %rdi
testq %rdi, %rdi
je 0x7250
callq 0x2c6dc
movq 0xc8d59(%rip), %rax     # 0xcffb0
movq (%rax), %rdi
callq 0x44c0
testl %eax, %eax
je 0x726d
callq 0x4050
cmpl $0x9, (%rax)
jne 0x72ac
movl %r15d, %eax
addq $0x3c8, %rsp            # imm = 0x3C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x4ca0
movl $0x1, %r15d
jmp 0x7232
callq 0x4cc2
movl $0x1, %r15d
jmp 0x723e
callq 0x4c7e
movl $0x1, %r15d
jmp 0x71cf
callq 0x4ce4
jmp 0x71c1
callq 0x4d06
jmp 0x71c1