// File: karel-brinda[P]ococo/ext/htslib/cram/cram_encode.c
// Function: add_read_names
static void add_read_names(cram_fd *fd, cram_container *c, cram_slice *s,
			   int bam_start) {
    int r1, r2;
    int keep_names = !fd->lossy_read_names;

    for (r1 = bam_start, r2 = 0;
	 r1 < c->curr_c_rec && r2 < s->hdr->num_records;
	 r1++, r2++) {
	cram_record *cr = &s->crecs[r2];
	bam_seq_t *b = c->bams[r1];

	cr->name        = BLOCK_SIZE(s->name_blk);
	if ((cr->cram_flags & CRAM_FLAG_DETACHED) || keep_names) {
	    BLOCK_APPEND(s->name_blk, bam_name(b), bam_name_len(b));
	    cr->name_len    = bam_name_len(b);
	} else {
	    // Can only discard duplicate names if not detached
	    cr->name_len = 0;
	}
	cram_stats_add(c->stats[DS_RN], cr->name_len);
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x8(%rbp), %rax
cmpl $0x0, 0x88fc(%rax)
setne %al
xorb $-0x1, %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, -0x28(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, -0x20(%rbp)
movl $0x0, -0x24(%rbp)
movl -0x20(%rbp), %ecx
movq -0x10(%rbp), %rdx
xorl %eax, %eax
cmpl 0x64(%rdx), %ecx
movb %al, -0x39(%rbp)
jge 0x38c90
movl -0x24(%rbp), %eax
movq -0x18(%rbp), %rcx
movq (%rcx), %rcx
cmpl 0x10(%rcx), %eax
setl %al
movb %al, -0x39(%rbp)
movb -0x39(%rbp), %al
testb $0x1, %al
jne 0x38c9c
jmp 0x38eb8
movq -0x18(%rbp), %rax
movq 0x28(%rax), %rax
movslq -0x24(%rbp), %rcx
imulq $0x70, %rcx, %rcx
addq %rcx, %rax
movq %rax, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq 0xb8(%rax), %rax
movslq -0x20(%rbp), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, -0x38(%rbp)
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rax
movq 0x30(%rax), %rax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x20(%rax)
movq -0x30(%rbp), %rax
movl 0x10(%rax), %eax
andl $0x2, %eax
cmpl $0x0, %eax
jne 0x38cf8
cmpl $0x0, -0x28(%rbp)
je 0x38e7f
jmp 0x38cfa
jmp 0x38cfc
jmp 0x38cfe
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rax
movq 0x28(%rax), %rax
movq -0x18(%rbp), %rcx
movq 0x60(%rcx), %rcx
movq 0x30(%rcx), %rcx
movq -0x38(%rbp), %rdx
movq 0x8(%rdx), %rdx
shrq $0x18, %rdx
andq $0xff, %rdx
movl %edx, %edx
addq %rdx, %rcx
cmpq %rcx, %rax
ja 0x38dff
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rax
cmpq $0x0, 0x28(%rax)
je 0x38d88
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rax
movq 0x28(%rax), %xmm0
movaps 0x41d86(%rip), %xmm1    # 0x7aae0
punpckldq %xmm1, %xmm0    # xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
movapd 0x41d8a(%rip), %xmm1    # 0x7aaf0
subpd %xmm1, %xmm0
movaps %xmm0, %xmm1
unpckhpd %xmm0, %xmm0            # xmm0 = xmm0[1,1]
addsd %xmm1, %xmm0
movsd 0x42d5b(%rip), %xmm1    # 0x7bad8
mulsd %xmm1, %xmm0
movsd %xmm0, -0x48(%rbp)
jmp 0x38d97
movsd 0x42d40(%rip), %xmm0    # 0x7bad0
movsd %xmm0, -0x48(%rbp)
jmp 0x38d97
movsd -0x48(%rbp), %xmm0
movsd 0x41d1c(%rip), %xmm2    # 0x7aac0
movaps %xmm0, %xmm1
subsd %xmm2, %xmm1
cvttsd2si %xmm1, %rax
cvttsd2si %xmm0, %rcx
movq %rcx, %rdx
sarq $0x3f, %rdx
andq %rdx, %rax
orq %rax, %rcx
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rax
movq %rcx, 0x28(%rax)
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rax
movq 0x20(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rax
movq 0x28(%rax), %rsi
callq 0x4990
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rax
movq %rcx, 0x20(%rax)
jmp 0x38cfe
jmp 0x38e01
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rax
movq 0x20(%rax), %rdi
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rax
addq 0x30(%rax), %rdi
movq -0x38(%rbp), %rax
movq 0x28(%rax), %rsi
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
shrq $0x18, %rax
andq $0xff, %rax
movl %eax, %eax
movl %eax, %edx
callq 0x4460
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
shrq $0x18, %rax
andq $0xff, %rax
movl %eax, %eax
movl %eax, %ecx
movq -0x18(%rbp), %rax
movq 0x60(%rax), %rax
addq 0x30(%rax), %rcx
movq %rcx, 0x30(%rax)
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rax
shrq $0x18, %rax
andq $0xff, %rax
movl %eax, %ecx
movq -0x30(%rbp), %rax
movl %ecx, 0x24(%rax)
jmp 0x38e8a
movq -0x30(%rbp), %rax
movl $0x0, 0x24(%rax)
movq -0x10(%rbp), %rax
movq 0x118(%rax), %rdi
movq -0x30(%rbp), %rax
movl 0x24(%rax), %esi
callq 0x54c30
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x38c6c
addq $0x50, %rsp
popq %rbp
retq
nop