// File: /workspace/github_c_makefile_star2_O1/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, 0x40(%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 0x8cf6
xorl %ebx, %ebx
jmp 0x8e59
xorl %ebx, %ebx
xorl %r15d, %r15d
movq 0x18(%rsp), %rax
movq (%rax,%r15,8), %rdi
callq 0x897c
testq %rax, %rax
je 0x8e9a
movq %rax, %r12
movq %rax, %rdi
leaq 0x20(%rsp), %rsi
callq 0x8a33
testl %eax, %eax
movq %r15, 0x38(%rsp)
js 0x8e3e
shlq $0x10, %r15
movq %r15, 0x48(%rsp)
movq %r12, 0x50(%rsp)
movq %rbx, 0x58(%rsp)
movzwl 0x2c(%rsp), %r13d
incq %r13
movq 0x48(%rsp), %rax
orq %rax, %r13
cmpl $0x0, 0x14(%rsp)
cmovneq %rax, %r13
movq 0x20(%rsp), %rdx
movl 0x28(%rsp), %ecx
leaq 0x60(%rsp), %rdi
movq 0x40(%rsp), %rsi
callq 0x83c6
cmpq $0x0, 0x60(%rsp)
movq 0x8(%rsp), %rsi
je 0x8e12
xorl %r12d, %r12d
xorl %ebp, %ebp
movq 0x70(%rsp), %rax
movslq (%rax,%r12), %rax
cmpl $-0x1, %eax
sete %cl
cmpl %esi, %eax
setge %dl
orb %cl, %dl
jne 0x8e00
leaq (%rax,%rax,2), %rax
leaq (%r14,%rax,8), %r15
movq (%r14,%rax,8), %rbx
testq %rbx, %rbx
je 0x8dbe
movq 0x10(%r15), %rax
cmpq %r13, -0x8(%rax,%rbx,8)
je 0x8e00
movq 0x8(%r15), %rax
cmpq %rax, %rbx
jne 0x8df1
movl $0x2, %esi
testq %rax, %rax
je 0x8dd7
addq %rax, %rax
movq %rax, %rsi
movq %rsi, 0x8(%r15)
movq 0x10(%r15), %rdi
shlq $0x3, %rsi
callq 0x1160
movq %rax, 0x10(%r15)
movq 0x8(%rsp), %rsi
movq 0x10(%r15), %rax
leaq 0x1(%rbx), %rcx
movq %rcx, (%r15)
movq %r13, (%rax,%rbx,8)
incq %rbp
addq $0xc, %r12
cmpq 0x60(%rsp), %rbp
jb 0x8d8a
movq 0x58(%rsp), %rbx
incq %rbx
movq 0x70(%rsp), %rdi
callq 0x1040
movq 0x50(%rsp), %r12
movq %r12, %rdi
leaq 0x20(%rsp), %rsi
callq 0x8a33
testl %eax, %eax
jns 0x8d3d
movq %r12, %rdi
callq 0x89ea
movq 0x38(%rsp), %r15
incq %r15
cmpq 0x30(%rsp), %r15
jne 0x8cfb
movq 0x5198(%rip), %rax      # 0xdff8
movq (%rax), %rdi
leaq 0x1b0a(%rip), %rsi      # 0xa974
leaq 0x1af2(%rip), %rdx      # 0xa963
movq %rbx, %rcx
xorl %eax, %eax
callq 0x1100
movq %r14, %rdi
movq 0x8(%rsp), %rsi
callq 0x2826
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 0x2a1f