// File: /workspace/github_cpp_makefile_star2_O3/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
movq 0x18(%rdi), %rdx
testq %rdx, %rdx
je 0x34cc7
movq %rdi, %r14
movq 0x48(%rdi), %rax
testq %rax, %rax
je 0x34cc7
cmpq $0x0, 0x8(%rax)
je 0x34cc7
cmpl $0x0, 0x38(%rdx)
jle 0x34cc7
xorl %r15d, %r15d
movq %r14, 0x10(%rsp)
movq 0x40(%rdx), %r8
movq %r15, %rdi
shlq $0x5, %rdi
movq (%r8,%rdi), %rsi
movq 0x48(%r14), %rax
movq 0x8(%rax), %rax
movq %rax, 0x8(%rsp)
movl (%rax), %r9d
movl $0x0, %r12d
testl %r9d, %r9d
je 0x34c3d
movsbl (%rsi), %ebx
testl %ebx, %ebx
movq %r15, 0x20(%rsp)
movq %rdx, 0x18(%rsp)
movq %rdi, (%rsp)
movq %r8, 0x30(%rsp)
je 0x34b87
movb 0x1(%rsi), %al
testb %al, %al
je 0x34b89
leaq 0x2(%rsi), %rcx
movl %ebx, %edx
shll $0x5, %edx
subl %ebx, %edx
movsbl %al, %ebx
addl %edx, %ebx
movb (%rcx), %al
incq %rcx
testb %al, %al
jne 0x34b70
jmp 0x34b89
xorl %ebx, %ebx
movq %r9, 0x28(%rsp)
leal -0x1(%r9), %r15d
andl %r15d, %ebx
movq 0x8(%rsp), %rax
movq 0x10(%rax), %rdi
movl $0x1, %r13d
movl %ebx, %r12d
movq %rsi, 0x40(%rsp)
movq %rdi, 0x38(%rsp)
movl %r12d, %eax
shrl $0x4, %eax
movl (%rdi,%rax,4), %r14d
leal (%r12,%r12), %ebp
andl $0x1e, %ebp
movl %r14d, %eax
movl %ebp, %ecx
shrl %cl, %eax
testb $0x2, %al
jne 0x34c13
testb $0x1, %al
jne 0x34bf4
movq 0x8(%rsp), %rax
movq 0x18(%rax), %rax
movl %r12d, %ecx
movq (%rax,%rcx,8), %rdi
callq 0x4750
movq 0x38(%rsp), %rdi
movq 0x40(%rsp), %rsi
testl %eax, %eax
je 0x34c13
addl %r13d, %r12d
andl %r15d, %r12d
incl %r13d
cmpl %ebx, %r12d
jne 0x34bb1
movq 0x10(%rsp), %r14
movq 0x20(%rsp), %r15
movq 0x18(%rsp), %rdx
jmp 0x34c6c
movl %ebp, %ecx
shrl %cl, %r14d
testb $0x3, %r14b
movq 0x28(%rsp), %r9
cmovnel %r9d, %r12d
movq 0x10(%rsp), %r14
movq 0x20(%rsp), %r15
movq 0x18(%rsp), %rdx
movq (%rsp), %rdi
movq 0x30(%rsp), %r8
cmpl %r9d, %r12d
je 0x34c6c
movq 0x8(%rsp), %rax
movq 0x20(%rax), %rax
movl %r12d, %ecx
movq (%rax,%rcx,8), %rbx
testq %rbx, %rbx
je 0x34c6c
movq 0x10(%rbx), %rbp
testq %rbp, %rbp
je 0x34c6c
addq %rdi, %r8
movl 0x8(%r8), %r12d
cmpq %r12, %rbp
jne 0x34c7e
incq %r15
movslq 0x38(%rdx), %rax
cmpq %rax, %r15
jl 0x34b1d
jmp 0x34cc7
movq %rdi, (%rsp)
movq (%rbx), %r13
movq %r13, %rdi
callq 0x4750
testl %eax, %eax
jne 0x34cd6
movq 0x2d330(%rip), %rax     # 0x61fc8
movq (%rax), %rdi
leaq 0x1e68f(%rip), %rsi     # 0x53331
movq %r13, %rdx
movl %r12d, %ecx
movl %ebp, %r8d
xorl %eax, %eax
callq 0x4770
movl 0x10(%rbx), %eax
movq 0x18(%r14), %rdx
movq 0x40(%rdx), %rcx
movq (%rsp), %rsi
movl %eax, 0x8(%rcx,%rsi)
jmp 0x34c6c
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x1e604(%rip), %rdi     # 0x532e1
leaq 0x1df3a(%rip), %rsi     # 0x52c1e
leaq 0x1e624(%rip), %rcx     # 0x5330f
movl $0x790, %edx            # imm = 0x790
callq 0x4350