// File: /workspace/github_c_makefile_star2_O3/rikuu[P]kermit/kermit-color.c
// Function: km_align_markers
km_multicolor_t *km_align_markers(char **map_fns, size_t n_maps, km_idx_t *idx, size_t n_reads, int unicolor)
{
	size_t n_markers = 0;
	km_multicolor_t *colors = (km_multicolor_t*) calloc(n_reads, sizeof(km_multicolor_t));
	for (size_t i = 0; i < n_maps; i++) {
		marker_file_t *fp = marker_open(map_fns[i]);
		if (fp == 0) {
			fprintf(stderr, "[E::%s] could not open map file %s\n", __func__, map_fns[i]);
			exit(1);
		}

		marker_rec_t r;
		while (marker_read(fp, &r) >= 0) {
			n_markers++;
			const uint64_t color = unicolor ? (i << 16) : (i << 16 | (r.bin + 1));
			km_hit_v h = km_pileup(idx, r.n, r.p);
			for (size_t j = 0; j < h.n; j++) {
				int32_t id = h.a[j].qn;
				if (id == -1 || id >= (int32_t) n_reads || (colors[id].n > 0 && colors[id].a[colors[id].n - 1] == color)) continue;
				kv_push(uint64_t, colors[id], color);
			}
			free(h.a);
		}
		marker_close(fp);
	}
	fprintf(stderr, "[M::%s] aligned %zu markers\n", __func__, n_markers);
	color_stats(colors, n_reads);
	return colors;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x78, %rsp
movl %r8d, 0x14(%rsp)
movq %rdx, 0x48(%rsp)
movq %rsi, %rbx
movq %rdi, 0x18(%rsp)
movl $0x18, %esi
movq %rcx, 0x8(%rsp)
movq %rcx, %rdi
callq 0x10d0
movq %rax, %r14
movq %rbx, 0x30(%rsp)
testq %rbx, %rbx
jne 0x8d2a
xorl %ebx, %ebx
jmp 0x8e95
xorl %ebx, %ebx
xorl %r15d, %r15d
movq 0x18(%rsp), %rax
movq (%rax,%r15,8), %rdi
callq 0x89d4
testq %rax, %rax
je 0x8ed6
movq %rax, %r12
movq %rax, %rdi
leaq 0x20(%rsp), %rsi
callq 0x8a7e
testl %eax, %eax
movq %r15, 0x38(%rsp)
js 0x8e7a
shlq $0x10, %r15
movq %r15, 0x40(%rsp)
movq %r12, 0x50(%rsp)
movq %rbx, 0x58(%rsp)
movzwl 0x2c(%rsp), %r12d
incq %r12
cmpl $0x0, 0x14(%rsp)
movl $0x0, %eax
cmovneq %rax, %r12
movq 0x20(%rsp), %rdx
movl 0x28(%rsp), %ecx
leaq 0x60(%rsp), %rdi
movq 0x48(%rsp), %rsi
callq 0x83e6
movq 0x60(%rsp), %rax
testq %rax, %rax
movq 0x8(%rsp), %rdi
je 0x8e4e
orq 0x40(%rsp), %r12
xorl %r13d, %r13d
xorl %ebp, %ebp
movq 0x70(%rsp), %rcx
movslq (%rcx,%r13), %rcx
cmpl $-0x1, %ecx
sete %dl
cmpl %edi, %ecx
setge %sil
orb %dl, %sil
jne 0x8e3e
leaq (%rcx,%rcx,2), %rcx
leaq (%r14,%rcx,8), %r15
movq (%r14,%rcx,8), %rbx
testq %rbx, %rbx
je 0x8df8
movq 0x10(%r15), %rcx
cmpq %r12, -0x8(%rcx,%rbx,8)
je 0x8e3e
cmpq 0x8(%r15), %rbx
jne 0x8e2a
leaq (%rbx,%rbx), %rsi
testq %rbx, %rbx
movl $0x2, %eax
cmoveq %rax, %rsi
movq %rsi, 0x8(%r15)
movq 0x10(%r15), %rdi
shlq $0x3, %rsi
callq 0x1160
movq 0x8(%rsp), %rdi
movq %rax, 0x10(%r15)
jmp 0x8e2e
movq 0x10(%r15), %rax
leaq 0x1(%rbx), %rcx
movq %rcx, (%r15)
movq %r12, (%rax,%rbx,8)
movq 0x60(%rsp), %rax
incq %rbp
addq $0xc, %r13
cmpq %rax, %rbp
jb 0x8dc2
movq 0x58(%rsp), %rbx
incq %rbx
movq 0x70(%rsp), %rdi
callq 0x1040
movq 0x50(%rsp), %r12
movq %r12, %rdi
leaq 0x20(%rsp), %rsi
callq 0x8a7e
testl %eax, %eax
jns 0x8d71
movq %r12, %rdi
callq 0x8a3a
movq 0x38(%rsp), %r15
incq %r15
cmpq 0x30(%rsp), %r15
jne 0x8d2f
movq 0x515c(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x1a9e(%rip), %rsi      # 0xa944
leaq 0x1a86(%rip), %rdx      # 0xa933
movq %rbx, %rcx
xorl %eax, %eax
callq 0x1100
movq %r14, %rdi
movq 0x8(%rsp), %rsi
callq 0x2788
movq %r14, %rax
addq $0x78, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x18(%rsp), %rdi
movq %r15, %rsi
callq 0x298f