// File: /workspace/github_c_makefile_star2_O0/lh3[P]minigraph/gchain1.c
// Function: resolve_overlap
static void resolve_overlap(mg_lchain_t *l0, mg_lchain_t *l1, const mg128_t *a)
{
	int32_t j, x, y, shift0, shift1;
	// check the end of l0
	x = (int32_t)a[l1->off].x;
	y = (int32_t)a[l1->off].y;
	for (j = l0->cnt - 1; j >= 0; --j)
		if ((int32_t)a[l0->off + j].y <= y && (l0->v != l1->v || (int32_t)a[l0->off + j].x <= x))
			break;
	shift0 = l0->cnt - 1 - j;
	// check the start of l1
	x = (int32_t)a[l0->off + l0->cnt - 1].x;
	y = (int32_t)a[l0->off + l0->cnt - 1].y;
	for (j = 0; j < l1->cnt; ++j)
		if ((int32_t)a[l1->off + j].y >= y && (l0->v != l1->v || (int32_t)a[l1->off + j].x >= x))
			break;
	shift1 = j;
	assert(shift1 < l1->cnt); // this should never happen, or it is a bug
	// update
	if (shift0 > 0) {
		l0->cnt -= shift0;
		if (l0->cnt) { // l0->cnt may be 0 as the start of l0 may be changed and go into l1
			l0->qe = (int32_t)a[l0->off + l0->cnt - 1].y + 1;
			l0->re = (int32_t)a[l0->off + l0->cnt - 1].x + 1;
		}
	}
	if (shift1 > 0) {
		l1->off += shift1, l1->cnt -= shift1;
		l1->qs = (int32_t)a[l1->off].y + 1 - (int32_t)(a[l1->off].y>>32&0xff);
		l1->rs = (int32_t)a[l1->off].x + 1 - (int32_t)(a[l1->off].y>>32&0xff);
	}
	if (l0->cnt == 0) l0->qs = l0->qe = l1->qs, l0->rs = l0->re = l1->rs; // this line should have no effect
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x30, %rsp
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq (%rcx), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq (%rcx), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl %eax, -0x24(%rbp)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
shll %eax
sarl %eax
subl $0x1, %eax
movl %eax, -0x1c(%rbp)
cmpl $0x0, -0x1c(%rbp)
jl 0x287da
movq -0x18(%rbp), %rax
movq -0x8(%rbp), %rcx
movl (%rcx), %ecx
addl -0x1c(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
cmpl -0x24(%rbp), %eax
jg 0x287cd
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jne 0x287cb
movq -0x18(%rbp), %rax
movq -0x8(%rbp), %rcx
movl (%rcx), %ecx
addl -0x1c(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
cmpl -0x20(%rbp), %eax
jg 0x287cd
jmp 0x287da
jmp 0x287cf
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x28776
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
shll %eax
sarl %eax
subl $0x1, %eax
subl -0x1c(%rbp), %eax
movl %eax, -0x28(%rbp)
movq -0x18(%rbp), %rax
movq -0x8(%rbp), %rcx
movl (%rcx), %ecx
movq -0x8(%rbp), %rdx
movl 0x4(%rdx), %edx
shll %edx
sarl %edx
addl %edx, %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, -0x20(%rbp)
movq -0x18(%rbp), %rax
movq -0x8(%rbp), %rcx
movl (%rcx), %ecx
movq -0x8(%rbp), %rdx
movl 0x4(%rdx), %edx
shll %edx
sarl %edx
addl %edx, %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl %eax, -0x24(%rbp)
movl $0x0, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movq -0x10(%rbp), %rcx
movl 0x4(%rcx), %ecx
shll %ecx
sarl %ecx
cmpl %ecx, %eax
jge 0x288ba
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movl (%rcx), %ecx
addl -0x1c(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
cmpl -0x24(%rbp), %eax
jl 0x288ad
movq -0x8(%rbp), %rax
movl 0x8(%rax), %eax
movq -0x10(%rbp), %rcx
cmpl 0x8(%rcx), %eax
jne 0x288ab
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movl (%rcx), %ecx
addl -0x1c(%rbp), %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
cmpl -0x20(%rbp), %eax
jl 0x288ad
jmp 0x288ba
jmp 0x288af
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x2884a
movl -0x1c(%rbp), %eax
movl %eax, -0x2c(%rbp)
movl -0x2c(%rbp), %eax
movq -0x10(%rbp), %rcx
movl 0x4(%rcx), %ecx
shll %ecx
sarl %ecx
cmpl %ecx, %eax
jge 0x288d4
jmp 0x288f3
leaq 0x14e4b(%rip), %rdi     # 0x3d726
leaq 0x14ad2(%rip), %rsi     # 0x3d3b4
movl $0x1aa, %edx            # imm = 0x1AA
leaq 0x14e49(%rip), %rcx     # 0x3d737
callq 0x2170
cmpl $0x0, -0x28(%rbp)
jle 0x2899a
movl -0x28(%rbp), %ecx
movq -0x8(%rbp), %rax
movl 0x4(%rax), %edx
shll %edx
sarl %edx
subl %ecx, %edx
movl 0x4(%rax), %ecx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl $0x80000000, %ecx       # imm = 0x80000000
orl %edx, %ecx
movl %ecx, 0x4(%rax)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
shll %eax
sarl %eax
cmpl $0x0, %eax
je 0x28998
movq -0x18(%rbp), %rax
movq -0x8(%rbp), %rcx
movl (%rcx), %ecx
movq -0x8(%rbp), %rdx
movl 0x4(%rdx), %edx
shll %edx
sarl %edx
addl %edx, %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl %eax, %ecx
addl $0x1, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x18(%rbp), %rax
movq -0x8(%rbp), %rcx
movl (%rcx), %ecx
movq -0x8(%rbp), %rdx
movl 0x4(%rdx), %edx
shll %edx
sarl %edx
addl %edx, %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, %ecx
addl $0x1, %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x10(%rax)
jmp 0x2899a
cmpl $0x0, -0x2c(%rbp)
jle 0x28a5a
movl -0x2c(%rbp), %ecx
movq -0x10(%rbp), %rax
addl (%rax), %ecx
movl %ecx, (%rax)
movl -0x2c(%rbp), %ecx
movq -0x10(%rbp), %rax
movl 0x4(%rax), %edx
shll %edx
sarl %edx
subl %ecx, %edx
movl 0x4(%rax), %ecx
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
andl $0x80000000, %ecx       # imm = 0x80000000
orl %edx, %ecx
movl %ecx, 0x4(%rax)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq (%rcx), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq 0x8(%rax), %rax
movl %eax, %ecx
addl $0x1, %ecx
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rdx
movslq (%rdx), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq 0x8(%rax), %rax
shrq $0x20, %rax
andq $0xff, %rax
subl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movslq (%rcx), %rcx
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movl %eax, %ecx
addl $0x1, %ecx
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rdx
movslq (%rdx), %rdx
shlq $0x4, %rdx
addq %rdx, %rax
movq 0x8(%rax), %rax
shrq $0x20, %rax
andq $0xff, %rax
subl %eax, %ecx
movq -0x10(%rbp), %rax
movl %ecx, 0xc(%rax)
movq -0x8(%rbp), %rax
movl 0x4(%rax), %eax
shll %eax
sarl %eax
cmpl $0x0, %eax
jne 0x28a94
movq -0x10(%rbp), %rax
movl 0x14(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x18(%rax)
movq -0x8(%rbp), %rax
movl %ecx, 0x14(%rax)
movq -0x10(%rbp), %rax
movl 0xc(%rax), %ecx
movq -0x8(%rbp), %rax
movl %ecx, 0x10(%rax)
movq -0x8(%rbp), %rax
movl %ecx, 0xc(%rax)
addq $0x30, %rsp
popq %rbp
retq
nopw (%rax,%rax)