// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/hts.c
// Function: hts_set_opt
int hts_set_opt(htsFile *fp, enum hts_fmt_option opt, ...) {
    int r;
    va_list args;

    switch (opt) {
    case HTS_OPT_NTHREADS: {
        va_start(args, opt);
        int nthreads = va_arg(args, int);
        va_end(args);
        return hts_set_threads(fp, nthreads);
    }

    case HTS_OPT_BLOCK_SIZE: {
        hFILE *hf = hts_hfile(fp);

        if (hf) {
            va_start(args, opt);
            if (hfile_set_blksize(hf, va_arg(args, int)) != 0)
                hts_log_warning("Failed to change block size");
            va_end(args);
        }
        else {
            // To do - implement for vcf/bcf.
            hts_log_warning("Cannot change block size for this format");
        }

        return 0;
    }

    case HTS_OPT_THREAD_POOL: {
        va_start(args, opt);
        htsThreadPool *p = va_arg(args, htsThreadPool *);
        va_end(args);
        return hts_set_thread_pool(fp, p);
    }

    case HTS_OPT_CACHE_SIZE: {
        va_start(args, opt);
        int cache_size = va_arg(args, int);
        va_end(args);
        hts_set_cache_size(fp, cache_size);
        return 0;
    }

    case FASTQ_OPT_CASAVA:
    case FASTQ_OPT_RNUM:
    case FASTQ_OPT_NAME2:
        if (fp->format.format == fastq_format ||
            fp->format.format == fasta_format)
            return fastq_state_set(fp, opt);
        return 0;

    case FASTQ_OPT_AUX:
        if (fp->format.format == fastq_format ||
            fp->format.format == fasta_format) {
            va_start(args, opt);
            char *list = va_arg(args, char *);
            va_end(args);
            return fastq_state_set(fp, opt, list);
        }
        return 0;

    case FASTQ_OPT_BARCODE:
        if (fp->format.format == fastq_format ||
            fp->format.format == fasta_format) {
            va_start(args, opt);
            char *bc = va_arg(args, char *);
            va_end(args);
            return fastq_state_set(fp, opt, bc);
        }
        return 0;

    // Options below here flow through to cram_set_voption
    case HTS_OPT_COMPRESSION_LEVEL: {
        va_start(args, opt);
        int level = va_arg(args, int);
        va_end(args);
        if (fp->is_bgzf)
            fp->fp.bgzf->compress_level = level;
        else if (fp->format.format == cram)
            return cram_set_option(fp->fp.cram, opt, level);
        return 0;
    }

    case HTS_OPT_FILTER: {
        va_start(args, opt);
        char *expr = va_arg(args, char *);
        va_end(args);
        return hts_set_filter_expression(fp, expr);
    }

    case HTS_OPT_PROFILE: {
        va_start(args, opt);
        enum hts_profile_option prof = va_arg(args, int);
        va_end(args);
        if (fp->is_bgzf) {
            switch (prof) {
#ifdef HAVE_LIBDEFLATE
            case HTS_PROFILE_FAST:    fp->fp.bgzf->compress_level =  2; break;
            case HTS_PROFILE_NORMAL:  fp->fp.bgzf->compress_level = -1; break;
            case HTS_PROFILE_SMALL:   fp->fp.bgzf->compress_level = 10; break;
            case HTS_PROFILE_ARCHIVE: fp->fp.bgzf->compress_level = 12; break;
#else
            case HTS_PROFILE_FAST:    fp->fp.bgzf->compress_level =  1; break;
            case HTS_PROFILE_NORMAL:  fp->fp.bgzf->compress_level = -1; break;
            case HTS_PROFILE_SMALL:   fp->fp.bgzf->compress_level =  8; break;
            case HTS_PROFILE_ARCHIVE: fp->fp.bgzf->compress_level =  9; break;
#endif
            }
        } // else CRAM manages this in its own way
        break;
    }

    default:
        break;
    }

    if (fp->format.format != cram)
        return 0;

    va_start(args, opt);
    r = cram_set_voption(fp->fp.cram, opt, args);
    va_end(args);

    return r;
}

// Assembly:
pushq %rbx
subq $0xd0, %rsp
movq %rdx, 0x30(%rsp)
movq %rcx, 0x38(%rsp)
movq %r8, 0x40(%rsp)
movq %r9, 0x48(%rsp)
testb %al, %al
je 0x148cd
movaps %xmm0, 0x50(%rsp)
movaps %xmm1, 0x60(%rsp)
movaps %xmm2, 0x70(%rsp)
movaps %xmm3, 0x80(%rsp)
movaps %xmm4, 0x90(%rsp)
movaps %xmm5, 0xa0(%rsp)
movaps %xmm6, 0xb0(%rsp)
movaps %xmm7, 0xc0(%rsp)
leal -0x64(%rsi), %eax
cmpl $0x6, %eax
ja 0x1492e
leaq 0x80f70(%rip), %rcx     # 0x9584c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0xe0(%rsp), %rax
movq %rax, 0x8(%rsp)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rsp)
movl $0x10, %ecx
cmpq $0x28, %rcx
ja 0x14bfc
movl $0x10, %eax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x14c0a
leal -0x3e8(%rsi), %eax
cmpl $0x4, %eax
ja 0x14e17
leaq 0x80f24(%rip), %rcx     # 0x95868
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movl 0x4c(%rdi), %eax
andl $-0x2, %eax
cmpl $0x10, %eax
jne 0x14e4f
xorl %eax, %eax
addq $0xd0, %rsp
popq %rbx
jmp 0x29406
movl 0x4c(%rdi), %eax
cmpl $0x11, %eax
ja 0x14dc7
movl $0x3010c, %ecx          # imm = 0x3010C
btl %eax, %ecx
jae 0x14ccc
cmpl $0x0, 0x54(%rdi)
movq 0x38(%rdi), %rdi
jne 0x14cde
jmp 0x14ce6
movl 0x4c(%rdi), %eax
andl $-0x2, %eax
cmpl $0x10, %eax
jne 0x14e4f
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0xe0(%rsp), %rax
movq %rax, 0x8(%rsp)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rsp)
movl $0x10, %ecx
cmpq $0x28, %rcx
ja 0x14d6e
movl $0x10, %eax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x14d7c
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0xe0(%rsp), %rax
movq %rax, 0x8(%rsp)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rsp)
movl $0x10, %ecx
cmpq $0x28, %rcx
ja 0x14bb5
movl $0x10, %eax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x14bc3
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0xe0(%rsp), %rax
movq %rax, 0x8(%rsp)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rsp)
movl $0x10, %ecx
cmpq $0x28, %rcx
ja 0x14bd0
movl $0x10, %eax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x14bde
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0xe0(%rsp), %rax
movq %rax, 0x8(%rsp)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rsp)
movl $0x10, %ecx
cmpq $0x28, %rcx
ja 0x14c30
movl $0x10, %eax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x14c3e
movl 0x4c(%rdi), %eax
andl $-0x2, %eax
cmpl $0x10, %eax
jne 0x14e4f
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0xe0(%rsp), %rax
movq %rax, 0x8(%rsp)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rsp)
movl $0x10, %ecx
cmpq $0x28, %rcx
ja 0x14d94
movl $0x10, %eax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x14da2
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0xe0(%rsp), %rax
movq %rax, 0x8(%rsp)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rsp)
movl $0x10, %ecx
cmpq $0x28, %rcx
ja 0x14c67
movl $0x10, %eax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x14c75
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0xe0(%rsp), %rax
movq %rax, 0x8(%rsp)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rsp)
movl $0x10, %ecx
cmpq $0x28, %rcx
ja 0x14c82
movl $0x10, %eax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x14c90
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq (%rax), %rsi
callq 0x1547f
jmp 0x14e4b
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
cmpl $0x2, 0x54(%rdi)
jne 0x14e4f
movl (%rax), %esi
xorl %ebx, %ebx
testb $0x10, (%rdi)
jne 0x14d86
xorl %edi, %edi
jmp 0x14d8a
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movl (%rax), %edx
testb $0x10, (%rdi)
jne 0x14c4a
cmpl $0x6, 0x4c(%rdi)
jne 0x14e4f
movq 0x38(%rdi), %rdi
movl $0x64, %esi
xorl %eax, %eax
callq 0x5348c
jmp 0x14e4b
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movl (%rax), %esi
callq 0x1543b
jmp 0x14e4b
movq 0x38(%rdi), %rax
shll $0x14, %edx
movl $0xe00fffff, %ecx       # imm = 0xE00FFFFF
andl (%rax), %ecx
andl $0x1ff00000, %edx       # imm = 0x1FF00000
orl %edx, %ecx
movl %ecx, (%rax)
jmp 0x14e4f
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq (%rax), %rsi
callq 0x154e5
jmp 0x14e4b
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
testb $0x10, (%rdi)
je 0x14e17
movl (%rax), %eax
cmpl $0x3, %eax
ja 0x14e17
movl %eax, %eax
leaq 0x80bcf(%rip), %rcx     # 0x9587c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x38(%rdi), %rax
movl $0xe00fffff, %ecx       # imm = 0xE00FFFFF
andl (%rax), %ecx
orl $0x100000, %ecx         # imm = 0x100000
jmp 0x14e09
movl $0x212, %ecx            # imm = 0x212
btl %eax, %ecx
jae 0x14db6
movq 0x38(%rdi), %rdi
callq 0xe659
movq %rax, %rdi
testq %rdi, %rdi
je 0x14dc7
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
leaq 0xe0(%rsp), %rax
movq %rax, 0x8(%rsp)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rsp)
movl $0x10, %ecx
cmpq $0x28, %rcx
ja 0x14d31
movl $0x10, %eax
addq 0x10(%rsp), %rax
addl $0x8, %ecx
movl %ecx, (%rsp)
jmp 0x14d3f
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movslq (%rax), %rsi
callq 0xee24
testl %eax, %eax
je 0x14e4f
leaq 0x81587(%rip), %rsi     # 0x962dd
leaq 0x8158c(%rip), %rdx     # 0x962e9
movl $0x3, %edi
xorl %eax, %eax
callq 0x13de5
jmp 0x14e4f
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq (%rax), %rdx
movl $0x3eb, %esi            # imm = 0x3EB
jmp 0x14daa
movq 0x38(%rdi), %rdi
callq 0xd6a4
jmp 0x14e51
movq 0x8(%rsp), %rax
leaq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq (%rax), %rdx
movl $0x3e9, %esi            # imm = 0x3E9
xorl %eax, %eax
callq 0x29406
jmp 0x14e4b
cmpl $0x6, %eax
jne 0x14dc7
movq 0x38(%rdi), %rax
movq (%rax), %rdi
jmp 0x14ce6
leaq 0x8150f(%rip), %rsi     # 0x962dd
leaq 0x81530(%rip), %rdx     # 0x96305
xorl %ebx, %ebx
movl $0x3, %edi
xorl %eax, %eax
callq 0x13de5
jmp 0x14e51
movq 0x38(%rdi), %rax
movl $0xe00fffff, %ecx       # imm = 0xE00FFFFF
andl (%rax), %ecx
orl $0x800000, %ecx         # imm = 0x800000
jmp 0x14e09
movq 0x38(%rdi), %rax
movl $0xe00fffff, %ecx       # imm = 0xE00FFFFF
andl (%rax), %ecx
orl $0x900000, %ecx         # imm = 0x900000
movl %ecx, (%rax)
jmp 0x14e17
movq 0x38(%rdi), %rax
orl $0x1ff00000, (%rax)     # imm = 0x1FF00000
cmpl $0x6, 0x4c(%rdi)
jne 0x14e4f
leaq 0x20(%rsp), %rax
movq %rsp, %rdx
movq %rax, 0x10(%rdx)
leaq 0xe0(%rsp), %rax
movq %rax, 0x8(%rdx)
movabsq $0x3000000010, %rax     # imm = 0x3000000010
movq %rax, (%rdx)
movq 0x38(%rdi), %rdi
callq 0x53510
movl %eax, %ebx
jmp 0x14e51
xorl %ebx, %ebx
movl %ebx, %eax
addq $0xd0, %rsp
popq %rbx
retq