// File: /workspace/github_c_makefile_star2_O0/LemonBoy[P]autobahn/xdiff/xmerge.c
// Function: xdl_do_merge
static int xdl_do_merge(xdfenv_t *xe1, xdchange_t *xscr1,
		xdfenv_t *xe2, xdchange_t *xscr2,
		xmparam_t const *xmp, mmbuffer_t *result)
{
	xdmerge_t *changes, *c;
	xpparam_t const *xpp = &xmp->xpp;
	const char *const ancestor_name = xmp->ancestor;
	const char *const name1 = xmp->file1;
	const char *const name2 = xmp->file2;
	int i0, i1, i2, chg0, chg1, chg2;
	int level = xmp->level;
	int style = xmp->style;
	int favor = xmp->favor;

	if (style == XDL_MERGE_DIFF3) {
		/*
		 * "diff3 -m" output does not make sense for anything
		 * more aggressive than XDL_MERGE_EAGER.
		 */
		if (XDL_MERGE_EAGER < level)
			level = XDL_MERGE_EAGER;
	}

	c = changes = NULL;

	while (xscr1 && xscr2) {
		if (!changes)
			changes = c;
		if (xscr1->i1 + xscr1->chg1 < xscr2->i1) {
			i0 = xscr1->i1;
			i1 = xscr1->i2;
			i2 = xscr2->i2 - xscr2->i1 + xscr1->i1;
			chg0 = xscr1->chg1;
			chg1 = xscr1->chg2;
			chg2 = xscr1->chg1;
			if (xdl_append_merge(&c, 1,
					     i0, chg0, i1, chg1, i2, chg2)) {
				xdl_cleanup_merge(changes);
				return -1;
			}
			xscr1 = xscr1->next;
			continue;
		}
		if (xscr2->i1 + xscr2->chg1 < xscr1->i1) {
			i0 = xscr2->i1;
			i1 = xscr1->i2 - xscr1->i1 + xscr2->i1;
			i2 = xscr2->i2;
			chg0 = xscr2->chg1;
			chg1 = xscr2->chg1;
			chg2 = xscr2->chg2;
			if (xdl_append_merge(&c, 2,
					     i0, chg0, i1, chg1, i2, chg2)) {
				xdl_cleanup_merge(changes);
				return -1;
			}
			xscr2 = xscr2->next;
			continue;
		}
		if (level == XDL_MERGE_MINIMAL || xscr1->i1 != xscr2->i1 ||
				xscr1->chg1 != xscr2->chg1 ||
				xscr1->chg2 != xscr2->chg2 ||
				xdl_merge_cmp_lines(xe1, xscr1->i2,
					xe2, xscr2->i2,
					xscr1->chg2, xpp->flags)) {
			/* conflict */
			int off = xscr1->i1 - xscr2->i1;
			int ffo = off + xscr1->chg1 - xscr2->chg1;

			i0 = xscr1->i1;
			i1 = xscr1->i2;
			i2 = xscr2->i2;
			if (off > 0) {
				i0 -= off;
				i1 -= off;
			}
			else
				i2 += off;
			chg0 = xscr1->i1 + xscr1->chg1 - i0;
			chg1 = xscr1->i2 + xscr1->chg2 - i1;
			chg2 = xscr2->i2 + xscr2->chg2 - i2;
			if (ffo < 0) {
				chg0 -= ffo;
				chg1 -= ffo;
			} else
				chg2 += ffo;
			if (xdl_append_merge(&c, 0,
					     i0, chg0, i1, chg1, i2, chg2)) {
				xdl_cleanup_merge(changes);
				return -1;
			}
		}

		i1 = xscr1->i1 + xscr1->chg1;
		i2 = xscr2->i1 + xscr2->chg1;

		if (i1 >= i2)
			xscr2 = xscr2->next;
		if (i2 >= i1)
			xscr1 = xscr1->next;
	}
	while (xscr1) {
		if (!changes)
			changes = c;
		i0 = xscr1->i1;
		i1 = xscr1->i2;
		i2 = xscr1->i1 + xe2->xdf2.nrec - xe2->xdf1.nrec;
		chg0 = xscr1->chg1;
		chg1 = xscr1->chg2;
		chg2 = xscr1->chg1;
		if (xdl_append_merge(&c, 1,
				     i0, chg0, i1, chg1, i2, chg2)) {
			xdl_cleanup_merge(changes);
			return -1;
		}
		xscr1 = xscr1->next;
	}
	while (xscr2) {
		if (!changes)
			changes = c;
		i0 = xscr2->i1;
		i1 = xscr2->i1 + xe1->xdf2.nrec - xe1->xdf1.nrec;
		i2 = xscr2->i2;
		chg0 = xscr2->chg1;
		chg1 = xscr2->chg1;
		chg2 = xscr2->chg2;
		if (xdl_append_merge(&c, 2,
				     i0, chg0, i1, chg1, i2, chg2)) {
			xdl_cleanup_merge(changes);
			return -1;
		}
		xscr2 = xscr2->next;
	}
	if (!changes)
		changes = c;
	/* refine conflicts */
	if (XDL_MERGE_ZEALOUS <= level &&
	    (xdl_refine_conflicts(xe1, xe2, changes, xpp) < 0 ||
	     xdl_simplify_non_conflicts(xe1, changes,
					XDL_MERGE_ZEALOUS < level) < 0)) {
		xdl_cleanup_merge(changes);
		return -1;
	}
	/* output */
	if (result) {
		int marker_size = xmp->marker_size;
		int size = xdl_fill_merge_buffer(xe1, name1, xe2, name2,
						 ancestor_name,
						 favor, changes, NULL, style,
						 marker_size);
		result->ptr = xdl_malloc(size);
		if (!result->ptr) {
			xdl_cleanup_merge(changes);
			return -1;
		}
		result->size = size;
		xdl_fill_merge_buffer(xe1, name1, xe2, name2,
				      ancestor_name, favor, changes,
				      result->ptr, style, marker_size);
	}
	return xdl_cleanup_merge(changes);
}

// Assembly:
pushq %rbx
subq $0xc0, %rsp
movq %rdi, 0xb0(%rsp)
movq %rsi, 0xa8(%rsp)
movq %rdx, 0xa0(%rsp)
movq %rcx, 0x98(%rsp)
movq %r8, 0x90(%rsp)
movq %r9, 0x88(%rsp)
movq 0x90(%rsp), %rax
movq %rax, 0x70(%rsp)
movq 0x90(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x68(%rsp)
movq 0x90(%rsp), %rax
movq 0x20(%rax), %rax
movq %rax, 0x60(%rsp)
movq 0x90(%rsp), %rax
movq 0x28(%rax), %rax
movq %rax, 0x58(%rsp)
movq 0x90(%rsp), %rax
movl 0xc(%rax), %eax
movl %eax, 0x3c(%rsp)
movq 0x90(%rsp), %rax
movl 0x14(%rax), %eax
movl %eax, 0x38(%rsp)
movq 0x90(%rsp), %rax
movl 0x10(%rax), %eax
movl %eax, 0x34(%rsp)
cmpl $0x1, 0x38(%rsp)
jne 0x8541
movl $0x1, %eax
cmpl 0x3c(%rsp), %eax
jge 0x853f
movl $0x1, 0x3c(%rsp)
jmp 0x8541
movq $0x0, 0x80(%rsp)
movq $0x0, 0x78(%rsp)
xorl %eax, %eax
cmpq $0x0, 0xa8(%rsp)
movb %al, 0x23(%rsp)
je 0x8577
cmpq $0x0, 0x98(%rsp)
setne %al
movb %al, 0x23(%rsp)
movb 0x23(%rsp), %al
testb $0x1, %al
jne 0x8584
jmp 0x8a77
cmpq $0x0, 0x80(%rsp)
jne 0x859c
movq 0x78(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0xa8(%rsp), %rax
movq 0x8(%rax), %rax
movq 0xa8(%rsp), %rcx
addq 0x18(%rcx), %rax
movq 0x98(%rsp), %rcx
cmpq 0x8(%rcx), %rax
jge 0x86ae
movq 0xa8(%rsp), %rax
movq 0x8(%rax), %rax
movl %eax, 0x54(%rsp)
movq 0xa8(%rsp), %rax
movq 0x10(%rax), %rax
movl %eax, 0x50(%rsp)
movq 0x98(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x98(%rsp), %rcx
subq 0x8(%rcx), %rax
movq 0xa8(%rsp), %rcx
addq 0x8(%rcx), %rax
movl %eax, 0x4c(%rsp)
movq 0xa8(%rsp), %rax
movq 0x18(%rax), %rax
movl %eax, 0x48(%rsp)
movq 0xa8(%rsp), %rax
movq 0x20(%rax), %rax
movl %eax, 0x44(%rsp)
movq 0xa8(%rsp), %rax
movq 0x18(%rax), %rax
movl %eax, 0x40(%rsp)
movslq 0x54(%rsp), %rdx
movslq 0x48(%rsp), %rcx
movslq 0x50(%rsp), %r8
movslq 0x44(%rsp), %r9
movslq 0x4c(%rsp), %r10
movslq 0x40(%rsp), %rax
leaq 0x78(%rsp), %rdi
movl $0x1, %esi
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x8e80
cmpl $0x0, %eax
je 0x8696
movq 0x80(%rsp), %rdi
callq 0x9040
movl $0xffffffff, 0xbc(%rsp) # imm = 0xFFFFFFFF
jmp 0x8e61
movq 0xa8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0xa8(%rsp)
jmp 0x8556
movq 0x98(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x98(%rsp), %rcx
addq 0x18(%rcx), %rax
movq 0xa8(%rsp), %rcx
cmpq 0x8(%rcx), %rax
jge 0x87c0
movq 0x98(%rsp), %rax
movq 0x8(%rax), %rax
movl %eax, 0x54(%rsp)
movq 0xa8(%rsp), %rax
movq 0x10(%rax), %rax
movq 0xa8(%rsp), %rcx
subq 0x8(%rcx), %rax
movq 0x98(%rsp), %rcx
addq 0x8(%rcx), %rax
movl %eax, 0x50(%rsp)
movq 0x98(%rsp), %rax
movq 0x10(%rax), %rax
movl %eax, 0x4c(%rsp)
movq 0x98(%rsp), %rax
movq 0x18(%rax), %rax
movl %eax, 0x48(%rsp)
movq 0x98(%rsp), %rax
movq 0x18(%rax), %rax
movl %eax, 0x44(%rsp)
movq 0x98(%rsp), %rax
movq 0x20(%rax), %rax
movl %eax, 0x40(%rsp)
movslq 0x54(%rsp), %rdx
movslq 0x48(%rsp), %rcx
movslq 0x50(%rsp), %r8
movslq 0x44(%rsp), %r9
movslq 0x4c(%rsp), %r10
movslq 0x40(%rsp), %rax
leaq 0x78(%rsp), %rdi
movl $0x2, %esi
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x8e80
cmpl $0x0, %eax
je 0x87a8
movq 0x80(%rsp), %rdi
callq 0x9040
movl $0xffffffff, 0xbc(%rsp) # imm = 0xFFFFFFFF
jmp 0x8e61
movq 0x98(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x98(%rsp)
jmp 0x8556
cmpl $0x0, 0x3c(%rsp)
je 0x886e
movq 0xa8(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x98(%rsp), %rcx
cmpq 0x8(%rcx), %rax
jne 0x886e
movq 0xa8(%rsp), %rax
movq 0x18(%rax), %rax
movq 0x98(%rsp), %rcx
cmpq 0x18(%rcx), %rax
jne 0x886e
movq 0xa8(%rsp), %rax
movq 0x20(%rax), %rax
movq 0x98(%rsp), %rcx
cmpq 0x20(%rcx), %rax
jne 0x886e
movq 0xb0(%rsp), %rdi
movq 0xa8(%rsp), %rax
movq 0x10(%rax), %rax
movl %eax, %esi
movq 0xa0(%rsp), %rdx
movq 0x98(%rsp), %rax
movq 0x10(%rax), %rax
movl %eax, %ecx
movq 0xa8(%rsp), %rax
movq 0x20(%rax), %rax
movl %eax, %r8d
movq 0x70(%rsp), %rax
movq (%rax), %r9
callq 0x90a0
cmpl $0x0, %eax
je 0x8a00
movq 0xa8(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x98(%rsp), %rcx
subq 0x8(%rcx), %rax
movl %eax, 0x30(%rsp)
movslq 0x30(%rsp), %rax
movq 0xa8(%rsp), %rcx
addq 0x18(%rcx), %rax
movq 0x98(%rsp), %rcx
subq 0x18(%rcx), %rax
movl %eax, 0x2c(%rsp)
movq 0xa8(%rsp), %rax
movq 0x8(%rax), %rax
movl %eax, 0x54(%rsp)
movq 0xa8(%rsp), %rax
movq 0x10(%rax), %rax
movl %eax, 0x50(%rsp)
movq 0x98(%rsp), %rax
movq 0x10(%rax), %rax
movl %eax, 0x4c(%rsp)
cmpl $0x0, 0x30(%rsp)
jle 0x8900
movl 0x30(%rsp), %ecx
movl 0x54(%rsp), %eax
subl %ecx, %eax
movl %eax, 0x54(%rsp)
movl 0x30(%rsp), %ecx
movl 0x50(%rsp), %eax
subl %ecx, %eax
movl %eax, 0x50(%rsp)
jmp 0x890c
movl 0x30(%rsp), %eax
addl 0x4c(%rsp), %eax
movl %eax, 0x4c(%rsp)
movq 0xa8(%rsp), %rax
movq 0x8(%rax), %rax
movq 0xa8(%rsp), %rcx
addq 0x18(%rcx), %rax
movslq 0x54(%rsp), %rcx
subq %rcx, %rax
movl %eax, 0x48(%rsp)
movq 0xa8(%rsp), %rax
movq 0x10(%rax), %rax
movq 0xa8(%rsp), %rcx
addq 0x20(%rcx), %rax
movslq 0x50(%rsp), %rcx
subq %rcx, %rax
movl %eax, 0x44(%rsp)
movq 0x98(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x98(%rsp), %rcx
addq 0x20(%rcx), %rax
movslq 0x4c(%rsp), %rcx
subq %rcx, %rax
movl %eax, 0x40(%rsp)
cmpl $0x0, 0x2c(%rsp)
jge 0x899d
movl 0x2c(%rsp), %ecx
movl 0x48(%rsp), %eax
subl %ecx, %eax
movl %eax, 0x48(%rsp)
movl 0x2c(%rsp), %ecx
movl 0x44(%rsp), %eax
subl %ecx, %eax
movl %eax, 0x44(%rsp)
jmp 0x89a9
movl 0x2c(%rsp), %eax
addl 0x40(%rsp), %eax
movl %eax, 0x40(%rsp)
movslq 0x54(%rsp), %rdx
movslq 0x48(%rsp), %rcx
movslq 0x50(%rsp), %r8
movslq 0x44(%rsp), %r9
movslq 0x4c(%rsp), %r10
movslq 0x40(%rsp), %rax
leaq 0x78(%rsp), %rdi
xorl %esi, %esi
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x8e80
cmpl $0x0, %eax
je 0x89fe
movq 0x80(%rsp), %rdi
callq 0x9040
movl $0xffffffff, 0xbc(%rsp) # imm = 0xFFFFFFFF
jmp 0x8e61
jmp 0x8a00
movq 0xa8(%rsp), %rax
movq 0x8(%rax), %rax
movq 0xa8(%rsp), %rcx
addq 0x18(%rcx), %rax
movl %eax, 0x50(%rsp)
movq 0x98(%rsp), %rax
movq 0x8(%rax), %rax
movq 0x98(%rsp), %rcx
addq 0x18(%rcx), %rax
movl %eax, 0x4c(%rsp)
movl 0x50(%rsp), %eax
cmpl 0x4c(%rsp), %eax
jl 0x8a55
movq 0x98(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x98(%rsp)
movl 0x4c(%rsp), %eax
cmpl 0x50(%rsp), %eax
jl 0x8a72
movq 0xa8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0xa8(%rsp)
jmp 0x8556
jmp 0x8a79
cmpq $0x0, 0xa8(%rsp)
je 0x8b8b
cmpq $0x0, 0x80(%rsp)
jne 0x8aa0
movq 0x78(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0xa8(%rsp), %rax
movq 0x8(%rax), %rax
movl %eax, 0x54(%rsp)
movq 0xa8(%rsp), %rax
movq 0x10(%rax), %rax
movl %eax, 0x50(%rsp)
movq 0xa8(%rsp), %rax
movq 0x8(%rax), %rax
movq 0xa0(%rsp), %rcx
addq 0xc0(%rcx), %rax
movq 0xa0(%rsp), %rcx
subq 0x38(%rcx), %rax
movl %eax, 0x4c(%rsp)
movq 0xa8(%rsp), %rax
movq 0x18(%rax), %rax
movl %eax, 0x48(%rsp)
movq 0xa8(%rsp), %rax
movq 0x20(%rax), %rax
movl %eax, 0x44(%rsp)
movq 0xa8(%rsp), %rax
movq 0x18(%rax), %rax
movl %eax, 0x40(%rsp)
movslq 0x54(%rsp), %rdx
movslq 0x48(%rsp), %rcx
movslq 0x50(%rsp), %r8
movslq 0x44(%rsp), %r9
movslq 0x4c(%rsp), %r10
movslq 0x40(%rsp), %rax
leaq 0x78(%rsp), %rdi
movl $0x1, %esi
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x8e80
cmpl $0x0, %eax
je 0x8b73
movq 0x80(%rsp), %rdi
callq 0x9040
movl $0xffffffff, 0xbc(%rsp) # imm = 0xFFFFFFFF
jmp 0x8e61
movq 0xa8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0xa8(%rsp)
jmp 0x8a79
jmp 0x8b8d
cmpq $0x0, 0x98(%rsp)
je 0x8c9f
cmpq $0x0, 0x80(%rsp)
jne 0x8bb4
movq 0x78(%rsp), %rax
movq %rax, 0x80(%rsp)
movq 0x98(%rsp), %rax
movq 0x8(%rax), %rax
movl %eax, 0x54(%rsp)
movq 0x98(%rsp), %rax
movq 0x8(%rax), %rax
movq 0xb0(%rsp), %rcx
addq 0xc0(%rcx), %rax
movq 0xb0(%rsp), %rcx
subq 0x38(%rcx), %rax
movl %eax, 0x50(%rsp)
movq 0x98(%rsp), %rax
movq 0x10(%rax), %rax
movl %eax, 0x4c(%rsp)
movq 0x98(%rsp), %rax
movq 0x18(%rax), %rax
movl %eax, 0x48(%rsp)
movq 0x98(%rsp), %rax
movq 0x18(%rax), %rax
movl %eax, 0x44(%rsp)
movq 0x98(%rsp), %rax
movq 0x20(%rax), %rax
movl %eax, 0x40(%rsp)
movslq 0x54(%rsp), %rdx
movslq 0x48(%rsp), %rcx
movslq 0x50(%rsp), %r8
movslq 0x44(%rsp), %r9
movslq 0x4c(%rsp), %r10
movslq 0x40(%rsp), %rax
leaq 0x78(%rsp), %rdi
movl $0x2, %esi
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x8e80
cmpl $0x0, %eax
je 0x8c87
movq 0x80(%rsp), %rdi
callq 0x9040
movl $0xffffffff, 0xbc(%rsp) # imm = 0xFFFFFFFF
jmp 0x8e61
movq 0x98(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x98(%rsp)
jmp 0x8b8d
cmpq $0x0, 0x80(%rsp)
jne 0x8cb7
movq 0x78(%rsp), %rax
movq %rax, 0x80(%rsp)
movl $0x2, %eax
cmpl 0x3c(%rsp), %eax
jg 0x8d31
movq 0xb0(%rsp), %rdi
movq 0xa0(%rsp), %rsi
movq 0x80(%rsp), %rdx
movq 0x70(%rsp), %rcx
callq 0x91a0
cmpl $0x0, %eax
jl 0x8d14
movq 0xb0(%rsp), %rdi
movq 0x80(%rsp), %rsi
movl $0x2, %eax
cmpl 0x3c(%rsp), %eax
setl %al
andb $0x1, %al
movzbl %al, %edx
callq 0x9600
cmpl $0x0, %eax
jge 0x8d31
movq 0x80(%rsp), %rdi
callq 0x9040
movl $0xffffffff, 0xbc(%rsp) # imm = 0xFFFFFFFF
jmp 0x8e61
cmpq $0x0, 0x88(%rsp)
je 0x8e4d
movq 0x90(%rsp), %rax
movl 0x8(%rax), %eax
movl %eax, 0x28(%rsp)
movq 0xb0(%rsp), %rdi
movq 0x60(%rsp), %rsi
movq 0xa0(%rsp), %rdx
movq 0x58(%rsp), %rcx
movq 0x68(%rsp), %r8
movl 0x34(%rsp), %r9d
movq 0x80(%rsp), %r11
movl 0x38(%rsp), %r10d
movl 0x28(%rsp), %eax
xorl %ebx, %ebx
movq %r11, (%rsp)
movq $0x0, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movl %eax, 0x18(%rsp)
callq 0x96f0
movl %eax, 0x24(%rsp)
movslq 0x24(%rsp), %rdi
callq 0x10f0
movq %rax, %rcx
movq 0x88(%rsp), %rax
movq %rcx, (%rax)
movq 0x88(%rsp), %rax
cmpq $0x0, (%rax)
jne 0x8de5
movq 0x80(%rsp), %rdi
callq 0x9040
movl $0xffffffff, 0xbc(%rsp) # imm = 0xFFFFFFFF
jmp 0x8e61
movslq 0x24(%rsp), %rcx
movq 0x88(%rsp), %rax
movq %rcx, 0x8(%rax)
movq 0xb0(%rsp), %rdi
movq 0x60(%rsp), %rsi
movq 0xa0(%rsp), %rdx
movq 0x58(%rsp), %rcx
movq 0x68(%rsp), %r8
movl 0x34(%rsp), %r9d
movq 0x80(%rsp), %rbx
movq 0x88(%rsp), %rax
movq (%rax), %r11
movl 0x38(%rsp), %r10d
movl 0x28(%rsp), %eax
movq %rbx, (%rsp)
movq %r11, 0x8(%rsp)
movl %r10d, 0x10(%rsp)
movl %eax, 0x18(%rsp)
callq 0x96f0
movq 0x80(%rsp), %rdi
callq 0x9040
movl %eax, 0xbc(%rsp)
movl 0xbc(%rsp), %eax
addq $0xc0, %rsp
popq %rbx
retq
nopw %cs:(%rax,%rax)