// File: /workspace/github_c_makefile_star2_O1/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, %r12
movq %rsi, %rbp
movq %rdi, 0x8(%rsp)
movabsq $0x1fffffffffffffff, %r8 # imm = 0x1FFFFFFFFFFFFFFF
xorps %xmm0, %xmm0
movaps %xmm0, 0x110(%rsp)
movaps %xmm0, 0x100(%rsp)
movaps %xmm0, 0xf0(%rsp)
movaps %xmm0, 0xe0(%rsp)
testq %rsi, %rsi
je 0x811f
leaq 0x10(%r12), %rax
movq %rbp, %rdx
movq (%rax), %rsi
leaq 0x1(%rsi), %rdi
movq %rdi, (%rax)
movzbl (%rsi), %esi
shlq $0x3d, %rsi
movq -0x8(%rax), %rdi
andq %r8, %rdi
orq %rsi, %rdi
movq %rdi, -0x8(%rax)
addq $0x18, %rax
decq %rdx
jne 0x80f7
testq %rbp, %rbp
jle 0x8413
leaq -0x10(%r12), %rax
movq %rax, 0x38(%rsp)
xorl %eax, %eax
xorl %edx, %edx
testl %ecx, %ecx
sete %al
setne %dl
leaq (%rdx,%rdx,2), %rcx
incq %rcx
movq %rcx, 0x20(%rsp)
leal (%rax,%rax,4), %eax
movl %eax, 0x14(%rsp)
negq %rdx
orq $0x1, %rdx
movq %rdx, 0x48(%rsp)
leaq 0x8(%r12), %rax
movq %rax, 0x18(%rsp)
movl $0x1, %ebx
xorl %r15d, %r15d
xorps %xmm0, %xmm0
movq %r12, 0x30(%rsp)
movq %rbp, 0x28(%rsp)
cmpq %rbp, %rbx
je 0x81a4
leaq (,%rbx,8), %rax
leaq (%rax,%rax,2), %rax
movq 0x38(%rsp), %rcx
movq (%rcx,%rax), %rcx
xorq 0x8(%r12,%rax), %rcx
testq %r8, %rcx
je 0x8403
leaq (%r15,%r15,2), %r14
movq (%r12,%r14,8), %r13
movq 0x8(%r12,%r14,8), %rdx
movq %rdx, %rax
andq %r8, %rax
movq %r13, %rcx
xorq %rax, %rcx
leaq 0x1(%r15), %rsi
xorq %rbx, %rsi
orq %rcx, %rsi
jne 0x8225
leaq (%r12,%r14,8), %r14
shrq $0x3d, %rdx
movl $0x1, %ecx
movq 0x8(%rsp), %rdi
movq %r13, %rsi
leaq 0xe0(%rsp), %r8
callq 0x14c5a
xorps %xmm0, %xmm0
movabsq $0x1fffffffffffffff, %rcx # imm = 0x1FFFFFFFFFFFFFFF
andq %rcx, %rax
movq 0x8(%r14), %rcx
movabsq $-0x2000000000000000, %rdx # imm = 0xE000000000000000
andq %rdx, %rcx
orq %rax, %rcx
movq %rcx, 0x8(%r14)
movq %rax, (%r14)
movabsq $0x1fffffffffffffff, %r8 # imm = 0x1FFFFFFFFFFFFFFF
jmp 0x8400
cmpq %rax, %r13
jne 0x8253
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 0x8273
movq 0x8(%rsp), %rdi
movq %r13, %rsi
movq %rax, %rdx
leaq 0x80(%rsp), %rcx
leaq 0x50(%rsp), %r8
callq 0x15296
xorps %xmm0, %xmm0
movaps %xmm0, 0xd0(%rsp)
movaps %xmm0, 0xc0(%rsp)
movaps %xmm0, 0xb0(%rsp)
cmpq %rbx, %r15
jge 0x82b7
movq 0x18(%rsp), %rax
leaq (%rax,%r14,8), %rax
movq %r15, %rcx
movq (%rax), %rdx
shrq $0x3d, %rdx
incq 0xb0(%rsp,%rdx,8)
incq %rcx
addq $0x18, %rax
cmpq %rcx, %rbx
jne 0x829c
movq %r14, 0x40(%rsp)
movq 0xb0(%rsp), %rbp
testq %rbp, %rbp
je 0x82e6
movq 0x8(%rsp), %rdi
movq %r13, %rsi
xorl %edx, %edx
movq %rbp, %rcx
leaq 0xe0(%rsp), %r8
callq 0x14c5a
xorps %xmm0, %xmm0
addq %r13, %rbp
addq 0x50(%rsp), %rbp
subq 0x80(%rsp), %rbp
movq 0x20(%rsp), %r13
movq 0x50(%rsp,%r13,8), %r12
subq 0x80(%rsp,%r13,8), %r12
movq 0xb0(%rsp,%r13,8), %r14
testq %r14, %r14
je 0x8343
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
movl %r13d, %edx
movq %r14, %rcx
leaq 0xe0(%rsp), %r8
callq 0x14c5a
xorps %xmm0, %xmm0
movq %rax, 0x80(%rsp,%r13,8)
addq %r12, %rax
movq %rax, 0x50(%rsp,%r13,8)
addq %r12, %rbp
addq %r14, %rbp
addq 0x48(%rsp), %r13
cmpl %r13d, 0x14(%rsp)
jne 0x82fb
movq 0xd8(%rsp), %rcx
testq %rcx, %rcx
je 0x8399
movq 0xa8(%rsp), %rax
subq %rax, 0x78(%rsp)
movq 0x8(%rsp), %rdi
movq %rbp, %rsi
movl $0x5, %edx
leaq 0xe0(%rsp), %r8
callq 0x14c5a
xorps %xmm0, %xmm0
movq %rax, 0xa8(%rsp)
addq %rax, 0x78(%rsp)
cmpq %rbx, %r15
movq 0x30(%rsp), %r12
movq 0x28(%rsp), %rbp
movabsq $0x1fffffffffffffff, %r8 # imm = 0x1FFFFFFFFFFFFFFF
movabsq $-0x2000000000000000, %rdi # imm = 0xE000000000000000
movq 0x40(%rsp), %rcx
jge 0x8400
movq 0x18(%rsp), %rax
leaq (%rax,%rcx,8), %rax
movq (%rax), %rcx
movq %rcx, %rdx
shrq $0x3d, %rdx
shll $0x3, %edx
movq 0x80(%rsp,%rdx), %rsi
movq %rsi, -0x8(%rax)
movq 0x50(%rsp,%rdx), %rdx
andq %r8, %rdx
andq %rdi, %rcx
orq %rdx, %rcx
movq %rcx, (%rax)
incq %r15
addq $0x18, %rax
cmpq %r15, %rbx
jne 0x83ca
movq %rbx, %r15
leaq 0x1(%rbx), %rax
cmpq %rbp, %rbx
movq %rax, %rbx
jne 0x817c
addq $0x128, %rsp            # imm = 0x128
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq