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

    if (!fd->header)
	return;

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

    for (i = 0; i < fd->header->nref; i++) {
	char *name = fd->header->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->ref[i].len) {
	    assert(strcmp(r->name, fd->header->ref[i].name) == 0);

	    // Should we also check MD5sums here to ensure the correct
	    // reference was given?
	    fprintf(stderr, "WARNING: Header @SQ length mismatch for "
		    "ref %s, %d vs %d\n",
		    r->name, fd->header->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->ref[i].len = r->length;
	}
    }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
cmpq $0x0, 0x18(%rdi)
je 0x5915b
movq %rdi, %r14
movq 0x48(%rdi), %rax
testq %rax, %rax
je 0x5915b
cmpq $0x0, 0x8(%rax)
je 0x5915b
movq 0x18(%r14), %rax
cmpl $0x0, 0x38(%rax)
jle 0x5915b
xorl %r15d, %r15d
movq %r14, 0x18(%rsp)
movq 0x40(%rax), %rcx
movq %r15, %rax
shlq $0x5, %rax
movq %rax, 0x20(%rsp)
movq %rcx, 0x38(%rsp)
movq (%rcx,%rax), %rsi
movq 0x48(%r14), %rax
movq 0x8(%rax), %rax
movq %rax, 0x8(%rsp)
movl (%rax), %edi
movl $0x0, %ebx
testl %edi, %edi
je 0x590cd
movsbl (%rsi), %r13d
testl %r13d, %r13d
movq %r15, 0x30(%rsp)
je 0x5902e
movb 0x1(%rsi), %al
testb %al, %al
je 0x59031
leaq 0x2(%rsi), %rcx
movl %r13d, %edx
shll $0x5, %edx
subl %r13d, %edx
movsbl %al, %r13d
addl %edx, %r13d
movb (%rcx), %al
incq %rcx
testb %al, %al
jne 0x59013
jmp 0x59031
xorl %r13d, %r13d
movq %rdi, 0x28(%rsp)
leal -0x1(%rdi), %edx
andl %edx, %r13d
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rdi
movl $0x1, %r12d
movl %r13d, %ebx
movl %edx, 0x14(%rsp)
movq %rdi, 0x40(%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 0x590b2
testb $0x1, %al
jne 0x5909c
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movl %ebx, %ecx
movq (%rax,%rcx,8), %rdi
movq %rsi, %r14
callq 0x6a50
movq 0x40(%rsp), %rdi
movl 0x14(%rsp), %edx
movq %r14, %rsi
testl %eax, %eax
je 0x590b2
addl %r12d, %ebx
andl %edx, %ebx
incl %r12d
cmpl %r13d, %ebx
jne 0x59057
movq 0x28(%rsp), %rdi
movl %edi, %ebx
jmp 0x590c3
movl %ebp, %ecx
shrl %cl, %r15d
testb $0x3, %r15b
movq 0x28(%rsp), %rdi
cmovnel %edi, %ebx
movq 0x18(%rsp), %r14
movq 0x30(%rsp), %r15
cmpl %edi, %ebx
je 0x59100
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
movl %ebx, %ecx
movq (%rax,%rcx,8), %rbx
testq %rbx, %rbx
je 0x59100
movq 0x10(%rbx), %r12
testq %r12, %r12
je 0x59100
movq 0x38(%rsp), %rax
addq 0x20(%rsp), %rax
movl 0x8(%rax), %ebp
cmpq %rbp, %r12
jne 0x59116
incq %r15
movq 0x18(%r14), %rax
movslq 0x38(%rax), %rcx
cmpq %rcx, %r15
jl 0x58fc5
jmp 0x5915b
movq (%rbx), %r13
movq %r13, %rdi
callq 0x6a50
testl %eax, %eax
jne 0x5916a
movq 0x65eac(%rip), %rax     # 0xbefd8
movq (%rax), %rdi
leaq 0x401b8(%rip), %rsi     # 0x992ee
movq %r13, %rdx
movl %ebp, %ecx
movl %r12d, %r8d
xorl %eax, %eax
callq 0x6a90
movl 0x10(%rbx), %eax
movq 0x18(%r14), %rcx
movq 0x40(%rcx), %rcx
movq 0x20(%rsp), %rdx
movl %eax, 0x8(%rcx,%rdx)
jmp 0x59100
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x4012d(%rip), %rdi     # 0x9929e
leaq 0x3fb56(%rip), %rsi     # 0x98cce
leaq 0x4014d(%rip), %rcx     # 0x992cc
movl $0x7a6, %edx            # imm = 0x7A6
callq 0x6460