// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x60, %rsp
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movq %r9, -0x30(%rbp)
movq -0x28(%rbp), %rdi
callq 0x40ef0
movq %rax, -0x38(%rbp)
callq 0x41af0
movq %rax, -0x40(%rbp)
movl $0x0, -0x50(%rbp)
movl $0x0, -0x54(%rbp)
cmpq $0x0, -0x38(%rbp)
jne 0x6225
movl $0x1, -0x4(%rbp)
jmp 0x6558
cmpq $0x0, -0x40(%rbp)
jne 0x6238
movl $0x1, -0x4(%rbp)
jmp 0x6558
movq -0x20(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
jne 0x6260
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x41650
cmpl $0x0, %eax
jge 0x6260
movl $0x1, -0x4(%rbp)
jmp 0x6558
movq -0x20(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x62b2
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x20(%rbp), %rax
movl 0x30(%rax), %edx
movq -0x20(%rbp), %rax
movq 0x28(%rax), %rcx
callq 0x4bc00
cmpl $0x0, %eax
jge 0x62b0
movq 0x120d3d(%rip), %rax    # 0x126fd0
movq (%rax), %rdi
leaq 0xfded3(%rip), %rsi     # 0x104170
movb $0x0, %al
callq 0x4700
movl $0x1, -0x4(%rbp)
jmp 0x6558
jmp 0x62b2
movl -0x14(%rbp), %eax
addl $0x1, %eax
cmpl -0x8(%rbp), %eax
jge 0x645d
movq -0x10(%rbp), %rax
movslq -0x14(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
xorl %esi, %esi
callq 0x15740
movq %rax, -0x48(%rbp)
cmpq $0x0, %rax
jne 0x6309
movq 0x120ceb(%rip), %rax    # 0x126fd0
movq (%rax), %rdi
leaq 0xfdf44(%rip), %rsi     # 0x104233
leaq 0xfdf62(%rip), %rdx     # 0x104258
movb $0x0, %al
callq 0x4700
movl $0x1, -0x4(%rbp)
jmp 0x6558
movl -0x14(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
movl -0x4c(%rbp), %eax
cmpl -0x8(%rbp), %eax
jge 0x644f
movq -0x48(%rbp), %rdi
movq -0x10(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movq (%rax,%rcx,8), %rsi
movq -0x38(%rbp), %rcx
leaq 0x237(%rip), %rdx       # 0x6570
leaq 0xa750(%rip), %r8       # 0x10a90
leaq 0x3d039(%rip), %r9      # 0x43380
callq 0x13bb0
movq %rax, -0x60(%rbp)
cmpq $0x0, %rax
jne 0x638d
movq 0x120c73(%rip), %rax    # 0x126fd0
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movslq -0x4c(%rbp), %rcx
movq (%rax,%rcx,8), %rcx
leaq 0xfde73(%rip), %rsi     # 0x1041e6
leaq 0xfdede(%rip), %rdx     # 0x104258
movb $0x0, %al
callq 0x4700
movl $0x1, -0x50(%rbp)
jmp 0x644f
jmp 0x638f
movq -0x28(%rbp), %rdi
movq -0x60(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0x65a0
movl %eax, -0x54(%rbp)
cmpl $0x0, %eax
jl 0x6409
movq -0x20(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
jne 0x63e9
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0x44040
cmpl $0x0, %eax
jge 0x63e9
movq 0x120c01(%rip), %rax    # 0x126fd0
movq (%rax), %rdi
leaq 0xfdde0(%rip), %rsi     # 0x1041b9
movb $0x0, %al
callq 0x4700
movl $0x1, -0x50(%rbp)
jmp 0x6409
movq -0x20(%rbp), %rax
cmpl $0x0, 0x14(%rax)
je 0x6407
movq -0x20(%rbp), %rcx
movl 0x14(%rcx), %eax
addl $-0x1, %eax
movl %eax, 0x14(%rcx)
cmpl $0x0, %eax
jne 0x6407
jmp 0x6409
jmp 0x638f
cmpl $-0x1, -0x54(%rbp)
jge 0x642e
movq 0x120bba(%rip), %rax    # 0x126fd0
movq (%rax), %rdi
leaq 0xfddb0(%rip), %rsi     # 0x1041d0
movb $0x0, %al
callq 0x4700
movl $0x1, -0x50(%rbp)
movq -0x60(%rbp), %rdi
callq 0x11760
cmpl $0x0, -0x50(%rbp)
je 0x643f
jmp 0x644f
jmp 0x6441
movl -0x4c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x4c(%rbp)
jmp 0x6312
movq -0x48(%rbp), %rdi
callq 0xd1f0
jmp 0x6500
jmp 0x645f
movq -0x28(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0x424e0
movl %eax, -0x54(%rbp)
cmpl $0x0, %eax
jl 0x64d9
movq -0x20(%rbp), %rax
cmpl $0x0, 0x1c(%rax)
jne 0x64b9
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
movq -0x40(%rbp), %rdx
callq 0x44040
cmpl $0x0, %eax
jge 0x64b9
movq 0x120b31(%rip), %rax    # 0x126fd0
movq (%rax), %rdi
leaq 0xfdd10(%rip), %rsi     # 0x1041b9
movb $0x0, %al
callq 0x4700
movl $0x1, -0x50(%rbp)
jmp 0x64d9
movq -0x20(%rbp), %rax
cmpl $0x0, 0x14(%rax)
je 0x64d7
movq -0x20(%rbp), %rcx
movl 0x14(%rcx), %eax
addl $-0x1, %eax
movl %eax, 0x14(%rcx)
cmpl $0x0, %eax
jne 0x64d7
jmp 0x64d9
jmp 0x645f
cmpl $-0x1, -0x54(%rbp)
jge 0x64fe
movq 0x120aea(%rip), %rax    # 0x126fd0
movq (%rax), %rdi
leaq 0xfdce0(%rip), %rsi     # 0x1041d0
movb $0x0, %al
callq 0x4700
movl $0x1, -0x50(%rbp)
jmp 0x6500
cmpl $0x0, -0x50(%rbp)
jne 0x6540
movq -0x20(%rbp), %rax
cmpq $0x0, 0x28(%rax)
je 0x6540
movq -0x30(%rbp), %rdi
callq 0x4bea0
cmpl $0x0, %eax
jge 0x653e
movq 0x120aaa(%rip), %rax    # 0x126fd0
movq (%rax), %rdi
leaq 0xfdcef(%rip), %rsi     # 0x10421f
movb $0x0, %al
callq 0x4700
movl $0x1, -0x50(%rbp)
jmp 0x6540
movq -0x40(%rbp), %rdi
callq 0x41ee0
movq -0x38(%rbp), %rdi
callq 0x40c90
movl -0x50(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)