// File: /workspace/github_cpp_makefile_star2_O1/karel-brinda[P]ococo/ext/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 0x35a65
movq %rdi, %r14
movq 0x48(%rdi), %rax
testq %rax, %rax
je 0x35a65
cmpq $0x0, 0x8(%rax)
je 0x35a65
movq 0x18(%r14), %rax
cmpl $0x0, 0x38(%rax)
jle 0x35a65
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 0x359d7
movsbl (%rsi), %r13d
testl %r13d, %r13d
movq %r15, 0x30(%rsp)
je 0x35938
movb 0x1(%rsi), %al
testb %al, %al
je 0x3593b
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 0x3591d
jmp 0x3593b
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 0x359bc
testb $0x1, %al
jne 0x359a6
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movl %ebx, %ecx
movq (%rax,%rcx,8), %rdi
movq %rsi, %r14
callq 0x4750
movq 0x40(%rsp), %rdi
movl 0x14(%rsp), %edx
movq %r14, %rsi
testl %eax, %eax
je 0x359bc
addl %r12d, %ebx
andl %edx, %ebx
incl %r12d
cmpl %r13d, %ebx
jne 0x35961
movq 0x28(%rsp), %rdi
movl %edi, %ebx
jmp 0x359cd
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 0x35a0a
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
movl %ebx, %ecx
movq (%rax,%rcx,8), %rbx
testq %rbx, %rbx
je 0x35a0a
movq 0x10(%rbx), %r12
testq %r12, %r12
je 0x35a0a
movq 0x38(%rsp), %rax
addq 0x20(%rsp), %rax
movl 0x8(%rax), %ebp
cmpq %rbp, %r12
jne 0x35a20
incq %r15
movq 0x18(%r14), %rax
movslq 0x38(%rax), %rcx
cmpq %rcx, %r15
jl 0x358cf
jmp 0x35a65
movq (%rbx), %r13
movq %r13, %rdi
callq 0x4750
testl %eax, %eax
jne 0x35a74
movq 0x2e592(%rip), %rax     # 0x63fc8
movq (%rax), %rdi
leaq 0x1f646(%rip), %rsi     # 0x55086
movq %r13, %rdx
movl %ebp, %ecx
movl %r12d, %r8d
xorl %eax, %eax
callq 0x4770
movl 0x10(%rbx), %eax
movq 0x18(%r14), %rcx
movq 0x40(%rcx), %rcx
movq 0x20(%rsp), %rdx
movl %eax, 0x8(%rcx,%rdx)
jmp 0x35a0a
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1f5bb(%rip), %rdi     # 0x55036
leaq 0x1eef4(%rip), %rsi     # 0x54976
leaq 0x1f5db(%rip), %rcx     # 0x55064
movl $0x790, %edx            # imm = 0x790
callq 0x4350