// File: /workspace/github_c_makefile_star2_O2/samtools[P]htslib/test/test_view.c
// Function: vcf_loop
int vcf_loop(int argc, char **argv, int optind, struct opts *opts, htsFile *in, htsFile *out) {
    bcf_hdr_t *h = bcf_hdr_read(in);
    bcf1_t *b = bcf_init1();
    hts_idx_t *idx;
    int i, exit_code = 0, r = 0;

    if (!h)
        return 1;
    if (!b)
        return 1;

    if (!opts->benchmark && bcf_hdr_write(out, h) < 0)
        return 1;

    if (opts->index) {
        if (bcf_idx_init(out, h, opts->min_shift, opts->index) < 0) {
            fprintf(stderr, "Failed to initialise index\n");
            return 1;
        }
    }

    if (optind + 1 < argc) {
        // A series of regions.
        if ((idx = bcf_index_load(argv[optind])) == 0) {
            fprintf(stderr, "[E::%s] fail to load the BVCF index\n", __func__);
            return 1;
        }

        for (i = optind + 1; i < argc; i++) {
            hts_itr_t *iter;
            if ((iter = bcf_itr_querys(idx, h, argv[i])) == 0) {
                fprintf(stderr, "[E::%s] fail to parse region '%s'\n", __func__, argv[i]);
                exit_code = 1;
                break;
            }
            while ((r = bcf_itr_next(in, iter, b)) >= 0) {
                if (!opts->benchmark && bcf_write1(out, h, b) < 0) {
                    fprintf(stderr, "Error writing output.\n");
                    exit_code = 1;
                    break;
                }
                if (opts->nreads && --opts->nreads == 0)
                    break;
            }
            if (r < -1) {
                fprintf(stderr, "Error reading input.\n");
                exit_code = 1;
            }
            hts_itr_destroy(iter);
            if (exit_code != 0) break;
        }

        hts_idx_destroy(idx);

    } else {
        // Whole file
        while ((r = bcf_read1(in, h, b)) >= 0) {
            if (!opts->benchmark && bcf_write1(out, h, b) < 0) {
                fprintf(stderr, "Error writing output.\n");
                exit_code = 1;
                break;
            }
            if (opts->nreads && --opts->nreads == 0)
                break;
        }
        if (r < -1) {
            fprintf(stderr, "Error reading input.\n");
            exit_code = 1;
        }
    }

    if (exit_code == 0 && opts->index) {
        if (bcf_idx_save(out) < 0) {
            fprintf(stderr, "Error saving index\n");
            exit_code = 1;
        }
    }

    bcf_destroy1(b);
    bcf_hdr_destroy(h);
    return exit_code;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r9, %r15
movq %r8, %r13
movq %rcx, %r12
movl %edx, %ebp
movq %rsi, 0x20(%rsp)
movl %edi, 0x10(%rsp)
movq %r8, %rdi
callq 0x262e6
movq %rax, %rbx
callq 0x26bde
movq %rax, %r14
movq %rbx, 0x8(%rsp)
testq %rbx, %rbx
sete %al
testq %r14, %r14
sete %cl
orb %al, %cl
pushq $0x1
popq %rbx
jne 0x62eb
cmpl $0x0, 0x1c(%r12)
jne 0x60c3
movq %r15, %rdi
movq 0x8(%rsp), %rsi
callq 0x26909
testl %eax, %eax
js 0x62eb
movq 0x28(%r12), %rcx
testq %rcx, %rcx
je 0x60e7
movl 0x30(%r12), %edx
movq %r15, %rdi
movq 0x8(%rsp), %rsi
callq 0x2d501
testl %eax, %eax
js 0x62fc
leal 0x1(%rbp), %ebx
cmpl 0x10(%rsp), %ebx
jge 0x61d3
movslq %ebp, %rax
movq 0x20(%rsp), %rcx
movq (%rcx,%rax,8), %rdi
xorl %esi, %esi
callq 0xf034
movq %rax, 0x18(%rsp)
testq %rax, %rax
je 0x631a
movslq %ebx, %rbx
movslq 0x10(%rsp), %rax
movq %rax, 0x10(%rsp)
cmpq 0x10(%rsp), %rbx
jge 0x6270
movq 0x20(%rsp), %rax
movq (%rax,%rbx,8), %rsi
movq 0x18(%rsp), %rdi
leaq 0x24a(%rip), %rdx       # 0x638c
movq 0x8(%rsp), %rcx
leaq 0x6117(%rip), %r8       # 0xc265
leaq 0x21850(%rip), %r9      # 0x279a5
callq 0xe205
movq %rax, %rbp
testq %rax, %rax
je 0x633e
testb $0x10, (%r13)
je 0x6238
movq 0x38(%r13), %rdi
movq %rbp, %rsi
movq %r14, %rdx
xorl %ecx, %ecx
callq 0xe429
testl %eax, %eax
js 0x61ba
cmpl $0x0, 0x1c(%r12)
jne 0x61a6
movq %r15, %rdi
movq 0x8(%rsp), %rsi
movq %r14, %rdx
callq 0x28015
testl %eax, %eax
js 0x62a8
movl 0x14(%r12), %eax
testl %eax, %eax
je 0x6166
decl %eax
movl %eax, 0x14(%r12)
jne 0x6166
jmp 0x61c3
cmpl $-0x1, %eax
jne 0x625b
movq %rbp, %rdi
callq 0xca25
incq %rbx
jmp 0x6122
movq %r13, %rdi
movq 0x8(%rsp), %rsi
movq %r14, %rdx
callq 0x26fee
testl %eax, %eax
js 0x621b
cmpl $0x0, 0x1c(%r12)
jne 0x6207
movq %r15, %rdi
movq 0x8(%rsp), %rsi
movq %r14, %rdx
callq 0x28015
testl %eax, %eax
js 0x636b
movl 0x14(%r12), %eax
testl %eax, %eax
je 0x61d3
decl %eax
movl %eax, 0x14(%r12)
jne 0x61d3
jmp 0x627a
cmpl $-0x1, %eax
je 0x627a
movq 0xa8db1(%rip), %rax     # 0xaefd8
movq (%rax), %rcx
leaq 0x7bf67(%rip), %rdi     # 0x82198
pushq $0x15
jmp 0x637e
leaq 0x7c65c(%rip), %rsi     # 0x8289b
leaq 0x7c662(%rip), %rdx     # 0x828a8
pushq $0x1
popq %rdi
xorl %eax, %eax
callq 0x8d46
callq 0x4050
movl $0x16, (%rax)
movq 0xa8d76(%rip), %rax     # 0xaefd8
movq (%rax), %rcx
leaq 0x7bf2c(%rip), %rdi     # 0x82198
pushq $0x15
jmp 0x62bb
movq 0x18(%rsp), %rdi
callq 0xa182
xorl %ebx, %ebx
cmpq $0x0, 0x28(%r12)
je 0x62d9
movq %r15, %rdi
callq 0x2d658
testl %eax, %eax
jns 0x62d9
movq 0xa8d41(%rip), %rax     # 0xaefd8
movq (%rax), %rcx
leaq 0x7bf46(%rip), %rdi     # 0x821e7
pushq $0x13
jmp 0x637e
movq 0xa8d29(%rip), %rax     # 0xaefd8
movq (%rax), %rcx
leaq 0x7bec8(%rip), %rdi     # 0x82181
pushq $0x16
popq %rsi
pushq $0x1
popq %rdx
callq 0x49c0
movq %rbp, %rdi
callq 0xca25
movq 0x18(%rsp), %rdi
callq 0xa182
pushq $0x1
popq %rbx
movq %r14, %rdi
callq 0x26d70
movq 0x8(%rsp), %rdi
callq 0x26174
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0xa8cd5(%rip), %rax     # 0xaefd8
movq (%rax), %rcx
leaq 0x7be2b(%rip), %rdi     # 0x82138
pushq $0x1b
popq %rsi
pushq $0x1
popq %rdx
callq 0x49c0
jmp 0x62eb
movq 0xa8cb7(%rip), %rax     # 0xaefd8
movq (%rax), %rdi
leaq 0x7bed0(%rip), %rsi     # 0x821fb
leaq 0x7beee(%rip), %rdx     # 0x82220
xorl %eax, %eax
callq 0x4730
pushq $0x1
popq %rbx
jmp 0x62eb
movq 0xa8c93(%rip), %rax     # 0xaefd8
movq (%rax), %rdi
movq 0x20(%rsp), %rax
movq (%rax,%rbx,8), %rcx
leaq 0x7be56(%rip), %rsi     # 0x821ae
leaq 0x7bec1(%rip), %rdx     # 0x82220
xorl %eax, %eax
callq 0x4730
jmp 0x62cc
movq 0xa8c66(%rip), %rax     # 0xaefd8
movq (%rax), %rcx
leaq 0x7be05(%rip), %rdi     # 0x82181
pushq $0x16
popq %rsi
pushq $0x1
popq %rdx
callq 0x49c0
jmp 0x62d6