// File: /workspace/github_c_makefile_star2_O2/lh3[P]fermi-lite/mrope.c
// Function: mr_insert_multi_aux
static void mr_insert_multi_aux(rope_t *rope, int64_t m, triple64_t *a, int is_comp)
{
	int64_t k, beg;
	rpcache_t cache;
	memset(&cache, 0, sizeof(rpcache_t));
	for (k = 0; k != m; ++k) // set the base to insert
		a[k].c = *a[k].p++;
	for (k = 1, beg = 0; k <= m; ++k) {
		if (k == m || a[k].u != a[k-1].u) {
			int64_t x, i, l = a[beg].l, u = a[beg].u, tl[6], tu[6], c[6];
			int start, end, step, b;
			if (l == u && k == beg + 1) { // special case; still works without the following block
				a[beg].l = a[beg].u = rope_insert_run(rope, l, a[beg].c, 1, &cache);
				beg = k;
				continue;
			} else if (l == u) {
				memset(tl, 0, 48);
				memset(tu, 0, 48);
			} else rope_rank2a(rope, l, u, tl, tu);
			memset(c, 0, 48);
			for (i = beg; i < k; ++i) ++c[a[i].c];
			// insert sentinel
			if (c[0]) rope_insert_run(rope, l, 0, c[0], &cache);
			// insert A/C/G/T
			x =  l + c[0] + (tu[0] - tl[0]);
			if (is_comp) start = 4, end = 0, step = -1;
			else start = 1, end = 5, step = 1;
			for (b = start; b != end; b += step) {
				int64_t size = tu[b] - tl[b];
				if (c[b]) {
					tl[b] = rope_insert_run(rope, x, b, c[b], &cache);
					tu[b] = tl[b] + size;
				}
				x += c[b] + size;
			}
			// insert N
			if (c[5]) {
				tu[5] -= tl[5];
				tl[5] = rope_insert_run(rope, x, 5, c[5], &cache);
				tu[5] += tl[5];
			}
			// update a[]
			for (i = beg; i < k; ++i) {
				triple64_t *p = &a[i];
				p->l = tl[p->c], p->u = tu[p->c];
			}
			beg = k;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x128, %rsp            # imm = 0x128
movq %rdx, %r14
movq %rsi, %r12
movq %rdi, (%rsp)
movabsq $0x1fffffffffffffff, %r13 # imm = 0x1FFFFFFFFFFFFFFF
xorps %xmm0, %xmm0
movaps %xmm0, 0x110(%rsp)
movaps %xmm0, 0x100(%rsp)
movaps %xmm0, 0xf0(%rsp)
movaps %xmm0, 0xe0(%rsp)
leaq 0x10(%rdx), %rax
movq %rsi, %rdx
subq $0x1, %rdx
jb 0x6ffb
movq (%rax), %rsi
leaq 0x1(%rsi), %rdi
movq %rdi, (%rax)
movzbl (%rsi), %esi
shlq $0x3d, %rsi
movq -0x8(%rax), %rdi
andq %r13, %rdi
orq %rsi, %rdi
movq %rdi, -0x8(%rax)
addq $0x18, %rax
jmp 0x6fd0
leaq -0x10(%r14), %rax
movq %rax, 0x30(%rsp)
xorl %eax, %eax
xorl %edx, %edx
testl %ecx, %ecx
sete %al
setne %dl
leaq (%rdx,%rdx,2), %rcx
incq %rcx
movq %rcx, 0x18(%rsp)
leaq (%rax,%rax,4), %rax
movq %rax, 0x48(%rsp)
negq %rdx
orq $0x1, %rdx
movq %rdx, 0x40(%rsp)
xorl %r15d, %r15d
testq %r12, %r12
movl $0x0, %eax
cmovgq %r12, %rax
incq %rax
movq %rax, 0x38(%rsp)
leaq 0x8(%r14), %rax
movq %rax, 0x10(%rsp)
pushq $0x1
popq %rdi
xorps %xmm0, %xmm0
movq %r14, 0x28(%rsp)
movq %r12, 0x20(%rsp)
cmpq 0x38(%rsp), %rdi
je 0x72d8
cmpq %r12, %rdi
je 0x7088
imulq $0x18, %rdi, %rax
movq 0x30(%rsp), %rcx
movq (%rcx,%rax), %rcx
xorq 0x8(%r14,%rax), %rcx
testq %r13, %rcx
je 0x70f9
imulq $0x18, %r15, %rbx
movq (%r14,%rbx), %rbp
movq 0x8(%r14,%rbx), %rdx
movq %rdx, %rax
andq %r13, %rax
movq %rbp, %rcx
xorq %rax, %rcx
leaq 0x1(%r15), %rsi
xorq %rdi, %rsi
orq %rcx, %rsi
movq %rdi, 0x8(%rsp)
jne 0x7101
addq %r14, %rbx
shrq $0x3d, %rdx
movq (%rsp), %rdi
movq %rbp, %rsi
pushq $0x1
popq %rcx
leaq 0xe0(%rsp), %r8
callq 0x126f1
movq 0x8(%rsp), %rdi
xorps %xmm0, %xmm0
andq %r13, %rax
movq 0x8(%rbx), %rcx
movabsq $-0x2000000000000000, %rdx # imm = 0xE000000000000000
andq %rdx, %rcx
orq %rax, %rcx
movq %rcx, 0x8(%rbx)
movq %rax, (%rbx)
movq %rdi, %r15
incq %rdi
jmp 0x7061
cmpq %rax, %rbp
jne 0x712f
movaps %xmm0, 0xa0(%rsp)
movaps %xmm0, 0x90(%rsp)
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x70(%rsp)
jmp 0x7153
movq (%rsp), %rdi
movq %rbp, %rsi
movq %rax, %rdx
leaq 0x80(%rsp), %rcx
leaq 0x50(%rsp), %r8
callq 0x12c58
movq 0x8(%rsp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, 0xd0(%rsp)
movaps %xmm0, 0xc0(%rsp)
movaps %xmm0, 0xb0(%rsp)
addq 0x10(%rsp), %rbx
movq %rbx, %rax
movq %r15, %rcx
cmpq %rdi, %rcx
jge 0x7193
movq (%rax), %rdx
shrq $0x3d, %rdx
incq 0xb0(%rsp,%rdx,8)
incq %rcx
addq $0x18, %rax
jmp 0x7176
movq 0xb0(%rsp), %r13
testq %r13, %r13
je 0x71c1
movq (%rsp), %rdi
movq %rbp, %rsi
xorl %edx, %edx
movq %r13, %rcx
leaq 0xe0(%rsp), %r8
callq 0x126f1
movq 0x8(%rsp), %rdi
xorps %xmm0, %xmm0
addq %rbp, %r13
addq 0x50(%rsp), %r13
subq 0x80(%rsp), %r13
movq 0x18(%rsp), %rbp
cmpq %rbp, 0x48(%rsp)
je 0x7238
movq 0x50(%rsp,%rbp,8), %r12
subq 0x80(%rsp,%rbp,8), %r12
movq 0xb0(%rsp,%rbp,8), %r14
testq %r14, %r14
je 0x7228
movq (%rsp), %rdi
movq %r13, %rsi
movl %ebp, %edx
movq %r14, %rcx
leaq 0xe0(%rsp), %r8
callq 0x126f1
movq 0x8(%rsp), %rdi
xorps %xmm0, %xmm0
movq %rax, 0x80(%rsp,%rbp,8)
addq %r12, %rax
movq %rax, 0x50(%rsp,%rbp,8)
addq %r13, %r12
addq %r14, %r12
addq 0x40(%rsp), %rbp
movq %r12, %r13
jmp 0x71d6
movq 0xd8(%rsp), %rcx
testq %rcx, %rcx
je 0x727e
movq 0xa8(%rsp), %rax
subq %rax, 0x78(%rsp)
movq (%rsp), %rdi
movq %r13, %rsi
pushq $0x5
popq %rdx
leaq 0xe0(%rsp), %r8
callq 0x126f1
movq 0x8(%rsp), %rdi
xorps %xmm0, %xmm0
movq %rax, 0xa8(%rsp)
addq %rax, 0x78(%rsp)
movq 0x28(%rsp), %r14
movq 0x20(%rsp), %r12
movabsq $0x1fffffffffffffff, %r13 # imm = 0x1FFFFFFFFFFFFFFF
movabsq $-0x2000000000000000, %rsi # imm = 0xE000000000000000
cmpq %rdi, %r15
jge 0x70f6
movq (%rbx), %rax
movq %rax, %rcx
shrq $0x3d, %rcx
shll $0x3, %ecx
movq 0x80(%rsp,%rcx), %rdx
movq %rdx, -0x8(%rbx)
movq 0x50(%rsp,%rcx), %rcx
andq %r13, %rcx
andq %rsi, %rax
orq %rcx, %rax
movq %rax, (%rbx)
incq %r15
addq $0x18, %rbx
jmp 0x729c
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq