// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
cmpq $0x0, 0x18(%rax)
je 0x74486
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
cmpq $0x0, 0x38(%rax)
jne 0x7448b
jmp 0x7464f
movq -0x8(%rbp), %rax
cmpq $0x0, 0x50(%rax)
je 0x744a5
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rax
cmpq $0x0, 0x8(%rax)
jne 0x744aa
jmp 0x7464f
movl $0x0, -0xc(%rbp)
movl -0xc(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
movq 0x38(%rcx), %rcx
cmpl 0x28(%rcx), %eax
jge 0x7464f
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x38(%rax), %rax
movq 0x30(%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rax
movq 0x8(%rax), %rdi
movq -0x18(%rbp), %rsi
callq 0x71b10
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x8(%rbp), %rcx
movq 0x50(%rcx), %rcx
movq 0x8(%rcx), %rcx
cmpl (%rcx), %eax
jne 0x7451b
jmp 0x74641
movq -0x8(%rbp), %rax
movq 0x50(%rax), %rax
movq 0x8(%rax), %rax
movq 0x20(%rax), %rax
movl -0x1c(%rbp), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x28(%rbp)
cmpq $0x0, %rax
jne 0x74541
jmp 0x74641
movq -0x28(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0x7463f
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x8(%rbp), %rcx
movq 0x18(%rcx), %rcx
movq 0x38(%rcx), %rcx
movq 0x30(%rcx), %rcx
movslq -0xc(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rcx
cmpq 0x8(%rcx), %rax
je 0x7463f
movq -0x28(%rbp), %rax
movq (%rax), %rdi
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x38(%rax), %rax
movq 0x30(%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x18, %rcx, %rcx
addq %rcx, %rax
movq (%rax), %rsi
callq 0x4690
cmpl $0x0, %eax
jne 0x745ae
jmp 0x745cd
leaq 0x819b2(%rip), %rdi     # 0xf5f67
leaq 0x81056(%rip), %rsi     # 0xf5612
movl $0xa98, %edx            # imm = 0xA98
leaq 0x819d4(%rip), %rcx     # 0xf5f9c
callq 0x42e0
movq -0x28(%rbp), %rax
movq (%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x38(%rax), %rax
movq 0x30(%rax), %rax
movslq -0xc(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq 0x8(%rax), %r8
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rax
movl %eax, %r9d
movl $0x3, %edi
leaq 0x819b4(%rip), %rsi     # 0xf5fbe
leaq 0x819bf(%rip), %rdx     # 0xf5fd0
movb $0x0, %al
callq 0x1b030
movq -0x28(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x8(%rbp), %rax
movq 0x18(%rax), %rax
movq 0x38(%rax), %rax
movq 0x30(%rax), %rax
movslq -0xc(%rbp), %rdx
imulq $0x18, %rdx, %rdx
addq %rdx, %rax
movq %rcx, 0x8(%rax)
jmp 0x74641
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x744b1
addq $0x30, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)