// File: /workspace/github_c_makefile_star2_O3/samtools[P]htslib/cram/cram_io.c
// Function: sanitise_SQ_lines
static void sanitise_SQ_lines(cram_fd *fd) {
    int i;

    if (!fd->header || !fd->header->hrecs)
        return;

    if (!fd->refs || !fd->refs->h_meta)
        return;

    for (i = 0; i < fd->header->hrecs->nref; i++) {
        const char *name = fd->header->hrecs->ref[i].name;
        khint_t k = kh_get(refs, fd->refs->h_meta, name);
        ref_entry *r;

        // We may have @SQ lines which have no known .fai, but do not
        // in themselves pose a problem because they are unused in the file.
        if (k == kh_end(fd->refs->h_meta))
            continue;

        if (!(r = (ref_entry *)kh_val(fd->refs->h_meta, k)))
            continue;

        if (r->length && r->length != fd->header->hrecs->ref[i].len) {
            assert(strcmp(r->name, fd->header->hrecs->ref[i].name) == 0);

            // Should we also check MD5sums here to ensure the correct
            // reference was given?
            hts_log_warning("Header @SQ length mismatch for ref %s, %"PRIhts_pos" vs %d",
                            r->name, fd->header->hrecs->ref[i].len, (int)r->length);

            // Fixing the parsed @SQ header will make MD:Z: strings work
            // and also stop it producing N for the sequence.
            fd->header->hrecs->ref[i].len = r->length;
        }
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq 0x18(%rdi), %rdx
testq %rdx, %rdx
je 0x4fbfa
movq 0x38(%rdx), %rax
testq %rax, %rax
je 0x4fbfa
movq %rdi, %r15
movq 0x50(%rdi), %rcx
testq %rcx, %rcx
je 0x4fbfa
cmpq $0x0, 0x8(%rcx)
je 0x4fbfa
cmpl $0x0, 0x28(%rax)
jle 0x4fbfa
xorl %r12d, %r12d
movq %r15, 0x10(%rsp)
movq 0x30(%rax), %r8
leaq (%r12,%r12,2), %rdi
movq (%r8,%rdi,8), %rsi
movq 0x50(%r15), %rax
movq 0x8(%rax), %rax
movq %rax, 0x8(%rsp)
movl (%rax), %r9d
movl $0x0, %ebx
testl %r9d, %r9d
je 0x4fb68
movq %r8, 0x30(%rsp)
movq %rdi, (%rsp)
movq %rdx, 0x20(%rsp)
movb (%rsi), %cl
testb %cl, %cl
movq %r12, 0x18(%rsp)
je 0x4faae
leaq 0x1(%rsi), %rax
movl $0x811c9dc5, %r14d      # imm = 0x811C9DC5
movzbl %cl, %ecx
xorl %r14d, %ecx
imull $0x1000193, %ecx, %r14d # imm = 0x1000193
movb (%rax), %cl
incq %rax
testb %cl, %cl
jne 0x4fa96
jmp 0x4fab4
movl $0x811c9dc5, %r14d      # imm = 0x811C9DC5
movq %r9, 0x28(%rsp)
leal -0x1(%r9), %r12d
andl %r12d, %r14d
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rdi
movl $0x1, %r13d
movl %r14d, %ebx
movq %rsi, 0x40(%rsp)
movq %rdi, 0x38(%rsp)
movl %ebx, %eax
shrl $0x4, %eax
movl (%rdi,%rax,4), %r15d
leal (%rbx,%rbx), %ebp
andl $0x1e, %ebp
movl %r15d, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x4fb3e
testb $0x1, %al
jne 0x4fb1c
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movl %ebx, %ecx
movq (%rax,%rcx,8), %rdi
callq 0x46c0
movq 0x38(%rsp), %rdi
movq 0x40(%rsp), %rsi
testl %eax, %eax
je 0x4fb3e
addl %r13d, %ebx
andl %r12d, %ebx
incl %r13d
cmpl %r14d, %ebx
jne 0x4fadc
movq 0x10(%rsp), %r15
movq 0x20(%rsp), %rdx
movq 0x18(%rsp), %r12
jmp 0x4fbe6
movl %ebp, %ecx
shrl %cl, %r15d
testb $0x3, %r15b
movq 0x28(%rsp), %r9
cmovnel %r9d, %ebx
movq 0x10(%rsp), %r15
movq 0x20(%rsp), %rdx
movq 0x18(%rsp), %r12
movq (%rsp), %rdi
movq 0x30(%rsp), %r8
cmpl %r9d, %ebx
je 0x4fbe6
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
movl %ebx, %ecx
movq (%rax,%rcx,8), %rbx
testq %rbx, %rbx
je 0x4fbe6
movq 0x10(%rbx), %r13
testq %r13, %r13
je 0x4fbe6
leaq (%r8,%rdi,8), %rax
movq 0x8(%rax), %rbp
cmpq %rbp, %r13
je 0x4fbe6
movq %rdi, (%rsp)
movq (%rbx), %r14
movq %r14, %rdi
callq 0x46c0
testl %eax, %eax
jne 0x4fc09
movl $0x3, %edi
leaq 0x4bc35(%rip), %rsi     # 0x9b7eb
leaq 0x4bc40(%rip), %rdx     # 0x9b7fd
movq %r14, %rcx
movq %rbp, %r8
movl %r13d, %r9d
xorl %eax, %eax
callq 0x13de5
movq 0x10(%rbx), %rax
movq 0x18(%r15), %rdx
movq 0x38(%rdx), %rcx
movq 0x30(%rcx), %rcx
movq (%rsp), %rsi
movq %rax, 0x8(%rcx,%rsi,8)
incq %r12
movq 0x38(%rdx), %rax
movslq 0x28(%rax), %rcx
cmpq %rcx, %r12
jl 0x4fa49
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4bb84(%rip), %rdi     # 0x9b794
leaq 0x4b223(%rip), %rsi     # 0x9ae3a
leaq 0x4bbab(%rip), %rcx     # 0x9b7c9
movl $0xa98, %edx            # imm = 0xA98
callq 0x42f0