// File: /workspace/github_c_makefile_star2_O1/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), %rax
testq %rax, %rax
je 0x526e5
cmpq $0x0, 0x38(%rax)
je 0x526e5
movq %rdi, %r14
movq 0x50(%rdi), %rax
testq %rax, %rax
je 0x526e5
cmpq $0x0, 0x8(%rax)
je 0x526e5
movq 0x18(%r14), %rax
movq 0x38(%rax), %rax
cmpl $0x0, 0x28(%rax)
jle 0x526e5
xorl %r15d, %r15d
movq %r14, 0x18(%rsp)
movq 0x30(%rax), %rax
leaq (%r15,%r15,2), %r12
movq %rax, 0x38(%rsp)
movq (%rax,%r12,8), %rsi
movq 0x50(%r14), %rax
movq 0x8(%rax), %rax
movq %rax, 0x8(%rsp)
movl (%rax), %edx
movl $0x0, %ebx
testl %edx, %edx
je 0x5264c
movb (%rsi), %cl
testb %cl, %cl
movq %r15, 0x30(%rsp)
movq %r12, 0x28(%rsp)
je 0x525a6
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 0x5258e
jmp 0x525ac
movl $0x811c9dc5, %r14d      # imm = 0x811C9DC5
movq %rdx, 0x20(%rsp)
decl %edx
andl %edx, %r14d
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rdi
movl $0x1, %r13d
movl %r14d, %ebx
movl %edx, 0x14(%rsp)
movq %rdi, 0x40(%rsp)
movl %ebx, %eax
shrl $0x4, %eax
movl (%rdi,%rax,4), %r12d
leal (%rbx,%rbx), %ebp
andl $0x1e, %ebp
movl %r12d, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x5262c
testb $0x1, %al
jne 0x52616
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movl %ebx, %ecx
movq (%rax,%rcx,8), %rdi
movq %rsi, %r15
callq 0x46c0
movq 0x40(%rsp), %rdi
movl 0x14(%rsp), %edx
movq %r15, %rsi
testl %eax, %eax
je 0x5262c
addl %r13d, %ebx
andl %edx, %ebx
incl %r13d
cmpl %r14d, %ebx
jne 0x525d1
movq 0x20(%rsp), %rdx
movl %edx, %ebx
jmp 0x5263d
movl %ebp, %ecx
shrl %cl, %r12d
testb $0x3, %r12b
movq 0x20(%rsp), %rdx
cmovnel %edx, %ebx
movq 0x18(%rsp), %r14
movq 0x30(%rsp), %r15
movq 0x28(%rsp), %r12
cmpl %edx, %ebx
je 0x526cd
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
movl %ebx, %ecx
movq (%rax,%rcx,8), %rbx
testq %rbx, %rbx
je 0x526cd
movq 0x10(%rbx), %r13
testq %r13, %r13
je 0x526cd
movq 0x38(%rsp), %rax
leaq (%rax,%r12,8), %rax
movq 0x8(%rax), %rax
cmpq %rax, %r13
je 0x526cd
movq %rax, 0x8(%rsp)
movq (%rbx), %rbp
movq %rbp, %rdi
callq 0x46c0
testl %eax, %eax
jne 0x526f4
movl $0x3, %edi
leaq 0x4bf54(%rip), %rsi     # 0x9e5f3
leaq 0x4bf5f(%rip), %rdx     # 0x9e605
movq %rbp, %rcx
movq 0x8(%rsp), %r8
movl %r13d, %r9d
xorl %eax, %eax
callq 0x14378
movq 0x10(%rbx), %rax
movq 0x18(%r14), %rcx
movq 0x38(%rcx), %rcx
movq 0x30(%rcx), %rcx
movq %rax, 0x8(%rcx,%r12,8)
incq %r15
movq 0x18(%r14), %rax
movq 0x38(%rax), %rax
movslq 0x28(%rax), %rcx
cmpq %rcx, %r15
jl 0x52547
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4bea1(%rip), %rdi     # 0x9e59c
leaq 0x4b540(%rip), %rsi     # 0x9dc42
leaq 0x4bec8(%rip), %rcx     # 0x9e5d1
movl $0xa98, %edx            # imm = 0xA98
callq 0x42f0