// File: /workspace/github_c_makefile_star2_O3/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 %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1b8, %rsp            # imm = 0x1B8
movq %r9, 0x80(%rsp)
movq %rcx, %r13
movq %rdx, %rbp
movq %rsi, %r12
movq %rdi, 0x18(%rsp)
movq 0x18(%r8), %rbx
movq 0x20(%r8), %rsi
movq 0x28(%r8), %rdx
movl 0xc(%r8), %eax
testl %eax, %eax
movl $0x1, %ecx
cmovlel %eax, %ecx
movl 0x14(%r8), %edi
cmpl $0x1, %edi
cmovnel %eax, %ecx
movl %ecx, 0x28(%rsp)
movq %r8, 0x8(%rsp)
movl 0x10(%r8), %eax
movl %eax, 0x2c(%rsp)
movq $0x0, 0x10(%rsp)
testq %r13, %r13
sete %al
testq %r12, %r12
sete %cl
orb %al, %cl
movq %rdx, 0x78(%rsp)
movq %rsi, 0x70(%rsp)
movq %rdi, 0x50(%rsp)
jne 0x4eec
leaq 0x10(%rsp), %r15
xorl %r14d, %r14d
testq %r14, %r14
jne 0x4c9d
movq 0x10(%rsp), %r14
movq 0x8(%r12), %rsi
movq 0x18(%r12), %rcx
leaq (%rcx,%rsi), %rax
movq 0x8(%r13), %rdi
cmpq %rdi, %rax
jge 0x4cf6
movslq %esi, %rdx
subl %edi, %esi
addl 0x10(%r13), %esi
movslq 0x10(%r12), %r8
movslq 0x20(%r12), %r9
movslq %ecx, %rcx
movslq %esi, %rax
movq %r15, %rdi
movl $0x1, %esi
pushq %rcx
pushq %rax
callq 0x5504
addq $0x10, %rsp
testl %eax, %eax
jne 0x4f58
movq (%r12), %r12
testq %r12, %r12
jne 0x4c93
jmp 0x4f7e
movq 0x18(%r13), %r8
leaq (%r8,%rdi), %rdx
cmpq %rsi, %rdx
jge 0x4d43
movslq %edi, %rdx
subl %esi, %edi
addl 0x10(%r12), %edi
movslq 0x10(%r13), %rax
movslq 0x20(%r13), %r10
movslq %r8d, %rcx
movslq %edi, %r8
movq %r15, %rdi
movl $0x2, %esi
movq %rcx, %r9
pushq %r10
pushq %rax
callq 0x5504
addq $0x10, %rsp
testl %eax, %eax
jne 0x54c6
movq (%r13), %r13
jmp 0x4edc
cmpl $0x0, 0x28(%rsp)
movq %rbx, 0x20(%rsp)
je 0x4e21
cmpq %rdi, %rsi
jne 0x4e21
cmpq %r8, %rcx
jne 0x4e21
movq 0x20(%r12), %rdx
movq %rcx, %r8
movq %rsi, %rdi
cmpq 0x20(%r13), %rdx
jne 0x4e21
testl %edx, %edx
jle 0x4eb0
movslq 0x10(%r12), %rcx
movslq 0x10(%r13), %rsi
movq 0x8(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x30(%rsp)
shlq $0x3, %rcx
movq 0x18(%rsp), %rax
addq 0xe8(%rax), %rcx
movq %rcx, (%rsp)
shlq $0x3, %rsi
addq 0xe8(%rbp), %rsi
movq %rsi, 0x38(%rsp)
andl $0x7fffffff, %edx       # imm = 0x7FFFFFFF
xorl %ebx, %ebx
movq %rdx, %r15
movq (%rsp), %rax
movq (%rax,%rbx,8), %rax
movq 0x8(%rax), %rdi
movq 0x10(%rax), %rsi
movq 0x38(%rsp), %rax
movq (%rax,%rbx,8), %rax
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rcx
movq 0x30(%rsp), %r8
callq 0x4349
testl %eax, %eax
je 0x4e06
incq %rbx
movq %r15, %rdx
cmpq %rbx, %r15
jne 0x4dc4
jmp 0x4eb0
movq 0x8(%r12), %rsi
movq 0x18(%r12), %rcx
movq 0x8(%r13), %rdi
movq 0x18(%r13), %r8
leaq (%rcx,%rsi), %rax
leaq 0x10(%rsp), %r15
movq %rsi, %r9
subq %rdi, %r9
addq %r9, %rcx
subq %r8, %rcx
movq 0x10(%r12), %r10
testl %r9d, %r9d
movq %r9, %rdx
movl $0x0, %r8d
cmovleq %r8, %rdx
cmovgq %rdi, %rsi
cmovgl %r8d, %r9d
movl 0x10(%r13), %r11d
addl %r9d, %r11d
movq %r10, %rdi
subq %rdx, %rdi
movslq %esi, %rdx
movslq %edi, %r8
movl 0x20(%r13), %edi
movslq %r11d, %r11
movslq %ecx, %rsi
movq %rsi, %rcx
shrq $0x1f, %rcx
andl %esi, %ecx
subl %edx, %eax
subl %ecx, %eax
addl 0x20(%r12), %r10d
addl %r8d, %ecx
subl %ecx, %r10d
subl %r9d, %edi
testl %esi, %esi
movl $0x0, %ecx
cmovsl %ecx, %esi
addl %edi, %esi
movslq %eax, %rcx
movslq %r10d, %r9
movslq %esi, %rax
movq %r15, %rdi
xorl %esi, %esi
pushq %rax
pushq %r11
callq 0x5504
addq $0x10, %rsp
testl %eax, %eax
jne 0x54e5
movl 0x18(%r12), %eax
addl 0x8(%r12), %eax
movl 0x18(%r13), %ecx
addl 0x8(%r13), %ecx
cmpl %ecx, %eax
jl 0x4eca
movq (%r13), %r13
movq 0x20(%rsp), %rbx
cmpl %eax, %ecx
jl 0x4ed7
movq (%r12), %r12
leaq 0x10(%rsp), %r15
testq %r12, %r12
je 0x4eef
testq %r13, %r13
jne 0x4c93
jmp 0x4eef
xorl %r14d, %r14d
testq %r12, %r12
je 0x4f49
leaq 0x10(%rsp), %r15
testq %r14, %r14
jne 0x4f03
movq 0x10(%rsp), %r14
movq 0x8(%r12), %rax
movslq %eax, %rdx
addl 0xc0(%rbp), %eax
subl 0x38(%rbp), %eax
movslq 0x10(%r12), %r8
movslq 0x18(%r12), %rcx
movslq 0x20(%r12), %r9
cltq
movq %r15, %rdi
movl $0x1, %esi
pushq %rcx
pushq %rax
callq 0x5504
addq $0x10, %rsp
testl %eax, %eax
jne 0x5234
movq (%r12), %r12
testq %r12, %r12
jne 0x4ef9
testq %r13, %r13
movq 0x18(%rsp), %r12
jne 0x4f83
jmp 0x4fde
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %r14, %r14
je 0x54b2
movq (%r14), %rbx
movq %r14, %rdi
callq 0x1030
movq %rbx, %r14
testq %rbx, %rbx
jne 0x4f66
jmp 0x54b2
movq 0x18(%rsp), %r12
leaq 0x10(%rsp), %r15
testq %r14, %r14
jne 0x4f92
movq 0x10(%rsp), %r14
movq 0x8(%r13), %rax
movslq %eax, %rdx
addl 0xc0(%r12), %eax
subl 0x38(%r12), %eax
movslq 0x10(%r13), %r10
movslq 0x18(%r13), %rcx
movslq 0x20(%r13), %r11
movslq %eax, %r8
movq %r15, %rdi
movl $0x2, %esi
movq %rcx, %r9
pushq %r11
pushq %r10
callq 0x5504
addq $0x10, %rsp
testl %eax, %eax
jne 0x520e
movq (%r13), %r13
testq %r13, %r13
jne 0x4f88
testq %r14, %r14
jne 0x4fe8
movq 0x10(%rsp), %r14
cmpl $0x2, 0x28(%rsp)
movq 0x8(%rsp), %r13
movq %rbx, 0x20(%rsp)
jl 0x53b9
testq %r14, %r14
je 0x53b9
leaq 0xa8(%rsp), %rcx
movq %r14, %rbx
movq %rbp, 0x40(%rsp)
cmpl $0x0, 0x8(%rbx)
je 0x5029
movq (%rbx), %rbx
testq %rbx, %rbx
jne 0x5016
jmp 0x525a
movq 0x20(%rbx), %rdi
testq %rdi, %rdi
je 0x501c
movq 0x28(%rbx), %rax
testq %rax, %rax
je 0x501c
movq %r12, %rdx
movq 0x10(%rbx), %r12
movq 0x18(%rbx), %r8
movq 0xe8(%rdx), %rdx
leaq (%rdx,%r12,8), %rdx
movq (%rdx), %rsi
movq 0x8(%rsi), %rsi
movq %rsi, 0x98(%rsp)
movq -0x8(%rdx,%rdi,8), %rdi
movq 0x8(%rdi), %rdx
addq 0x10(%rdi), %rdx
subq %rsi, %rdx
movq %rdx, 0xa0(%rsp)
movq 0xe8(%rbp), %rdx
movq %r8, (%rsp)
leaq (%rdx,%r8,8), %rsi
movq (%rsi), %rdx
movq 0x8(%rdx), %rdx
movq %rdx, 0x88(%rsp)
movq -0x8(%rsi,%rax,8), %rax
movq 0x8(%rax), %rsi
addq 0x10(%rax), %rsi
subq %rdx, %rsi
movq %rsi, 0x90(%rsp)
leaq 0x98(%rsp), %rdi
leaq 0x88(%rsp), %rsi
movq %r13, %rdx
movq %rcx, %r15
callq 0x1d2d
testl %eax, %eax
js 0x549a
movq (%r13), %rdx
movq %r15, %rdi
leaq 0x130(%rsp), %r13
movq %r13, %rsi
callq 0x1ea7
testl %eax, %eax
js 0x548d
movq 0x8(%rsp), %rax
movq (%rax), %rdx
movq %r13, %rdi
movq %r15, %rsi
callq 0x1ea7
testl %eax, %eax
js 0x548d
movq %r15, %rdi
leaq 0x48(%rsp), %rsi
callq 0x24b6
testl %eax, %eax
js 0x548d
movq 0x48(%rsp), %rcx
testq %rcx, %rcx
je 0x51bc
movslq %r12d, %r12
movq 0x8(%rcx), %rax
addq %r12, %rax
movq %rax, 0x10(%rbx)
movslq (%rsp), %r13
movq 0x10(%rcx), %rax
addq %r13, %rax
movq %rax, 0x18(%rbx)
movups 0x18(%rcx), %xmm0
movups %xmm0, 0x20(%rbx)
movq %rcx, (%rsp)
movq (%rcx), %rbp
testq %rbp, %rbp
je 0x51d8
movl $0x40, %edi
callq 0x10f0
testq %rax, %rax
je 0x538f
movq %rax, %r15
movq %rbp, 0x48(%rsp)
movq (%rbx), %rax
movq %rax, (%r15)
movq %r15, (%rbx)
movl $0x0, 0x8(%r15)
movq 0x48(%rsp), %rax
movq 0x8(%rax), %rcx
addq %r12, %rcx
movq %rcx, 0x10(%r15)
movq 0x10(%rax), %rcx
addq %r13, %rcx
movq %rcx, 0x18(%r15)
movups 0x18(%rax), %xmm0
movups %xmm0, 0x20(%r15)
movq (%rax), %rbp
movq %r15, %rbx
testq %rbp, %rbp
jne 0x515f
jmp 0x51db
leaq 0xa8(%rsp), %r15
movq %r15, %rdi
callq 0x4075
movq %r15, %rcx
movl $0x4, 0x8(%rbx)
jmp 0x51ff
movq %rbx, %r15
leaq 0xa8(%rsp), %rbx
movq %rbx, %rdi
callq 0x4075
movq (%rsp), %rdi
callq 0x25e6
movq %rbx, %rcx
movq %r15, %rbx
movq 0x40(%rsp), %rbp
movq 0x18(%rsp), %r12
movq 0x8(%rsp), %r13
jmp 0x501c
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %r14, %r14
je 0x54b2
movq (%r14), %rbx
movq %r14, %rdi
callq 0x1030
movq %rbx, %r14
testq %rbx, %rbx
jne 0x521c
jmp 0x54b2
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %r14, %r14
je 0x54b2
movq (%r14), %rbx
movq %r14, %rdi
callq 0x1030
movq %rbx, %r14
testq %rbx, %rbx
jne 0x5242
jmp 0x54b2
movq (%r14), %r15
testq %r15, %r15
movq 0x20(%rsp), %rbx
je 0x53b9
movq $0x0, (%rsp)
movq %r14, %r12
cmpl $0x0, 0x8(%r12)
jne 0x5285
cmpl $0x0, 0x8(%r15)
je 0x5296
movq %r15, %r12
movq (%r12), %r15
testq %r15, %r15
jne 0x5276
jmp 0x53aa
movq 0x10(%r12), %rdx
movq 0x20(%r12), %rax
addq %rdx, %rax
movq 0x10(%r15), %rsi
movl %esi, %edi
subl %eax, %edi
cmpl $0x4, %edi
jl 0x533f
cmpl $0x2, 0x28(%rsp)
jne 0x52c3
movq %r15, %r12
jmp 0x5385
movq 0x18(%rsp), %rcx
movq 0xe8(%rcx), %rcx
cltq
movq %rdx, 0x68(%rsp)
movq %rsi, 0x60(%rsp)
movq %rcx, 0x58(%rsp)
movl %edi, 0x38(%rsp)
movq %rax, 0x30(%rsp)
movq (%rcx,%rax,8), %rax
movq 0x8(%rax), %rbp
movq 0x10(%rax), %rbx
xorl %r13d, %r13d
cmpq %r13, %rbx
je 0x5316
callq 0x1150
movq (%rax), %rax
movzbl (%rbp,%r13), %ecx
incq %r13
testb $0x8, (%rax,%rcx,2)
je 0x52f8
jmp 0x5378
movq 0x30(%rsp), %rax
incq %rax
movl 0x38(%rsp), %edi
decl %edi
movq 0x40(%rsp), %rbp
movq 0x20(%rsp), %rbx
movq 0x68(%rsp), %rdx
movq 0x60(%rsp), %rsi
movq 0x58(%rsp), %rcx
jne 0x52e0
subq %rdx, %rsi
addq 0x20(%r15), %rsi
movq %rsi, 0x20(%r12)
movq 0x28(%r15), %rax
addq 0x18(%r15), %rax
subq 0x18(%r12), %rax
movq (%rsp), %rcx
incl %ecx
movq %rcx, (%rsp)
movq %rax, 0x28(%r12)
movq (%r15), %rax
movq %rax, (%r12)
movq %r15, %rdi
callq 0x1030
jmp 0x5385
movq %r15, %r12
movq 0x40(%rsp), %rbp
movq 0x20(%rsp), %rbx
movq 0x8(%rsp), %r13
jmp 0x5288
leaq 0xa8(%rsp), %rdi
callq 0x4075
movq (%rsp), %rdi
callq 0x25e6
jmp 0x549a
cmpl $0x0, (%rsp)
movq 0x18(%rsp), %r12
js 0x549a
movq 0x80(%rsp), %r15
testq %r15, %r15
je 0x544a
movq %r12, %rdi
movq %rbx, %r8
movl 0x8(%r13), %eax
movq 0x70(%rsp), %r12
movq %r12, %rsi
movq %rbp, %rdx
movq 0x78(%rsp), %rbx
movq %rbx, %rcx
movl 0x2c(%rsp), %r9d
movq %rax, 0x8(%rsp)
pushq %rax
pushq 0x58(%rsp)
pushq $0x0
pushq %r14
callq 0x55eb
addq $0x20, %rsp
movq %r15, %r13
movslq %eax, %r15
movq %r15, %rdi
callq 0x10f0
movq %rax, (%r13)
testq %rax, %rax
je 0x546e
movq %r15, 0x8(%r13)
movq 0x18(%rsp), %rdi
movq %r12, %rsi
movq %rbp, %rdx
movq %rbx, %rcx
movq 0x20(%rsp), %r8
movl 0x2c(%rsp), %r9d
pushq 0x8(%rsp)
pushq 0x58(%rsp)
pushq %rax
pushq %r14
callq 0x55eb
addq $0x20, %rsp
xorl %ebp, %ebp
testq %r14, %r14
je 0x54b2
cmpl $0x1, 0x8(%r14)
adcl $0x0, %ebp
movq (%r14), %rbx
movq %r14, %rdi
callq 0x1030
movq %rbx, %r14
testq %rbx, %rbx
jne 0x5451
jmp 0x54b2
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %r14, %r14
je 0x54b2
movq (%r14), %rbx
movq %r14, %rdi
callq 0x1030
movq %rbx, %r14
testq %rbx, %rbx
jne 0x5478
jmp 0x54b2
leaq 0xa8(%rsp), %rdi
callq 0x4075
movq (%r14), %rbx
movq %r14, %rdi
callq 0x1030
movq %rbx, %r14
testq %rbx, %rbx
jne 0x549a
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movl %ebp, %eax
addq $0x1b8, %rsp            # imm = 0x1B8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %r14, %r14
je 0x54b2
movq (%r14), %rbx
movq %r14, %rdi
callq 0x1030
movq %rbx, %r14
testq %rbx, %rbx
jne 0x54d0
jmp 0x54b2
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testq %r14, %r14
je 0x54b2
movq (%r14), %rbx
movq %r14, %rdi
callq 0x1030
movq %rbx, %r14
testq %rbx, %rbx
jne 0x54ef
jmp 0x54b2