// File: /workspace/github_c_makefile_star2_O0/lh3[P]fermi-lite/rope.c
// Function: split_node
static inline rpnode_t *split_node(rope_t *rope, rpnode_t *u, rpnode_t *v)
{ // split $v's child. $u is the first node in the bucket. $v and $u are in the same bucket. IMPORTANT: there is always enough room in $u
	int j, i = v - u;
	rpnode_t *w; // $w is the sibling of $v
	if (u == 0) { // only happens at the root; add a new root
		u = v = mp_alloc(rope->node);
		v->n = 1; v->p = rope->root; // the new root has the old root as the only child
		memcpy(v->c, rope->c, 48);
		for (j = 0; j < 6; ++j) v->l += v->c[j];
		rope->root = v;
	}
	if (i != u->n - 1) // then make room for a new node
		memmove(v + 2, v + 1, sizeof(rpnode_t) * (u->n - i - 1));
	++u->n; w = v + 1;
	memset(w, 0, sizeof(rpnode_t));
	w->p = mp_alloc(u->is_bottom? rope->leaf : rope->node);
	if (u->is_bottom) { // we are at the bottom level; $v->p is a string instead of a node
		uint8_t *p = (uint8_t*)v->p, *q = (uint8_t*)w->p;
		rle_split(p, q);
		rle_count(q, w->c);
	} else { // $v->p is a node, not a string
		rpnode_t *p = v->p, *q = w->p; // $v and $w are siblings and thus $p and $q are cousins
		p->n -= rope->max_nodes>>1;
		memcpy(q, p + p->n, sizeof(rpnode_t) * (rope->max_nodes>>1));
		q->n = rope->max_nodes>>1; // NB: this line must below memcpy() as $q->n and $q->is_bottom are modified by memcpy()
		q->is_bottom = p->is_bottom;
		for (i = 0; i < q->n; ++i)
			for (j = 0; j < 6; ++j)
				w->c[j] += q[i].c[j];
	}
	for (j = 0; j < 6; ++j) // compute $w->l and update $v->c
		w->l += w->c[j], v->c[j] -= w->c[j];
	v->l -= w->l; // update $v->c
	return v;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
subq %rcx, %rax
sarq $0x6, %rax
movl %eax, -0x20(%rbp)
cmpq $0x0, -0x10(%rbp)
jne 0x22b5d
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rdi
callq 0x22450
movq %rax, -0x18(%rbp)
movq %rax, -0x10(%rbp)
movq -0x18(%rbp), %rax
movabsq $-0x7fc0000000000001, %rcx # imm = 0x803FFFFFFFFFFFFF
andq 0x8(%rax), %rcx
movabsq $0x40000000000000, %rdx # imm = 0x40000000000000
orq %rdx, %rcx
movq %rcx, 0x8(%rax)
movq -0x8(%rbp), %rax
movq 0x38(%rax), %rcx
movq -0x18(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rdi
addq $0x10, %rdi
movq -0x8(%rbp), %rsi
addq $0x8, %rsi
movl $0x30, %edx
callq 0x2190
movl $0x0, -0x1c(%rbp)
cmpl $0x6, -0x1c(%rbp)
jge 0x22b51
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq 0x10(%rax,%rcx,8), %rcx
movq -0x18(%rbp), %rax
movabsq $0x3fffffffffffff, %rdx # imm = 0x3FFFFFFFFFFFFF
andq 0x8(%rax), %rdx
addq %rcx, %rdx
movq 0x8(%rax), %rcx
movabsq $0x3fffffffffffff, %rsi # imm = 0x3FFFFFFFFFFFFF
andq %rsi, %rdx
movabsq $-0x40000000000000, %rsi # imm = 0xFFC0000000000000
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, 0x8(%rax)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x22af9
movq -0x18(%rbp), %rcx
movq -0x8(%rbp), %rax
movq %rcx, 0x38(%rax)
movl -0x20(%rbp), %eax
movq -0x10(%rbp), %rcx
movq 0x8(%rcx), %rcx
shrq $0x36, %rcx
andq $0x1ff, %rcx            # imm = 0x1FF
subl $0x1, %ecx
cmpl %ecx, %eax
je 0x22bb1
movq -0x18(%rbp), %rdi
addq $0x80, %rdi
movq -0x18(%rbp), %rsi
addq $0x40, %rsi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
shrq $0x36, %rax
andq $0x1ff, %rax            # imm = 0x1FF
subl -0x20(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rdx
shlq $0x6, %rdx
callq 0x2220
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
shrq $0x36, %rdx
andq $0x1ff, %rdx            # imm = 0x1FF
addq $0x1, %rdx
movq 0x8(%rax), %rcx
andq $0x1ff, %rdx            # imm = 0x1FF
shlq $0x36, %rdx
movabsq $-0x7fc0000000000001, %rsi # imm = 0x803FFFFFFFFFFFFF
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
addq $0x40, %rax
movq %rax, -0x28(%rbp)
movq -0x28(%rbp), %rdi
xorl %esi, %esi
movl $0x40, %edx
callq 0x2110
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
shrq $0x3f, %rax
cmpl $0x0, %eax
je 0x22c26
movq -0x8(%rbp), %rax
movq 0x48(%rax), %rax
movq %rax, -0x50(%rbp)
jmp 0x22c32
movq -0x8(%rbp), %rax
movq 0x40(%rax), %rax
movq %rax, -0x50(%rbp)
movq -0x50(%rbp), %rdi
callq 0x22450
movq %rax, %rcx
movq -0x28(%rbp), %rax
movq %rcx, (%rax)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
shrq $0x3f, %rax
cmpq $0x0, %rax
je 0x22c90
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x30(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x38(%rbp)
movq -0x30(%rbp), %rdi
movq -0x38(%rbp), %rsi
callq 0x24090
movq -0x38(%rbp), %rdi
movq -0x28(%rbp), %rsi
addq $0x10, %rsi
callq 0x24150
jmp 0x22df4
movq -0x18(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x40(%rbp)
movq -0x28(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rax
movl (%rax), %edx
sarl %edx
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rcx
shrq $0x36, %rcx
andq $0x1ff, %rcx            # imm = 0x1FF
subl %edx, %ecx
movslq %ecx, %rdx
movq 0x8(%rax), %rcx
andq $0x1ff, %rdx            # imm = 0x1FF
shlq $0x36, %rdx
movabsq $-0x7fc0000000000001, %rsi # imm = 0x803FFFFFFFFFFFFF
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, 0x8(%rax)
movq -0x48(%rbp), %rdi
movq -0x40(%rbp), %rsi
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rax
shrq $0x36, %rax
andq $0x1ff, %rax            # imm = 0x1FF
cltq
shlq $0x6, %rax
addq %rax, %rsi
movq -0x8(%rbp), %rax
movl (%rax), %eax
sarl %eax
movslq %eax, %rdx
shlq $0x6, %rdx
callq 0x2190
movq -0x8(%rbp), %rax
movl (%rax), %eax
sarl %eax
movslq %eax, %rdx
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rcx
andq $0x1ff, %rdx            # imm = 0x1FF
shlq $0x36, %rdx
movabsq $-0x7fc0000000000001, %rsi # imm = 0x803FFFFFFFFFFFFF
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, 0x8(%rax)
movq -0x40(%rbp), %rax
movq 0x8(%rax), %rdx
shrq $0x3f, %rdx
movq -0x48(%rbp), %rax
movq 0x8(%rax), %rcx
andq $0x1, %rdx
shlq $0x3f, %rdx
movabsq $0x7fffffffffffffff, %rsi # imm = 0x7FFFFFFFFFFFFFFF
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, 0x8(%rax)
movl $0x0, -0x20(%rbp)
movl -0x20(%rbp), %eax
movq -0x48(%rbp), %rcx
movq 0x8(%rcx), %rcx
shrq $0x36, %rcx
andq $0x1ff, %rcx            # imm = 0x1FF
cmpl %ecx, %eax
jge 0x22df2
movl $0x0, -0x1c(%rbp)
cmpl $0x6, -0x1c(%rbp)
jge 0x22de5
movq -0x48(%rbp), %rax
movslq -0x20(%rbp), %rcx
shlq $0x6, %rcx
addq %rcx, %rax
movslq -0x1c(%rbp), %rcx
movq 0x10(%rax,%rcx,8), %rdx
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rcx
addq 0x10(%rax,%rcx,8), %rdx
movq %rdx, 0x10(%rax,%rcx,8)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x22daa
jmp 0x22de7
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x22d89
jmp 0x22df4
movl $0x0, -0x1c(%rbp)
cmpl $0x6, -0x1c(%rbp)
jge 0x22e75
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq 0x10(%rax,%rcx,8), %rcx
movq -0x28(%rbp), %rax
movabsq $0x3fffffffffffff, %rdx # imm = 0x3FFFFFFFFFFFFF
andq 0x8(%rax), %rdx
addq %rcx, %rdx
movq 0x8(%rax), %rcx
movabsq $0x3fffffffffffff, %rsi # imm = 0x3FFFFFFFFFFFFF
andq %rsi, %rdx
movabsq $-0x40000000000000, %rsi # imm = 0xFFC0000000000000
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, 0x8(%rax)
movq -0x28(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq 0x10(%rax,%rcx,8), %rsi
movq -0x18(%rbp), %rax
movslq -0x1c(%rbp), %rcx
movq 0x10(%rax,%rcx,8), %rdx
subq %rsi, %rdx
movq %rdx, 0x10(%rax,%rcx,8)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x22dfb
movq -0x28(%rbp), %rax
movabsq $0x3fffffffffffff, %rcx # imm = 0x3FFFFFFFFFFFFF
andq 0x8(%rax), %rcx
movq -0x18(%rbp), %rax
movabsq $0x3fffffffffffff, %rdx # imm = 0x3FFFFFFFFFFFFF
andq 0x8(%rax), %rdx
subq %rcx, %rdx
movq 0x8(%rax), %rcx
movabsq $0x3fffffffffffff, %rsi # imm = 0x3FFFFFFFFFFFFF
andq %rsi, %rdx
movabsq $-0x40000000000000, %rsi # imm = 0xFFC0000000000000
andq %rsi, %rcx
orq %rdx, %rcx
movq %rcx, 0x8(%rax)
movq -0x18(%rbp), %rax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax,%rax)