// File: /workspace/github_c_makefile_star2_O2/LemonBoy[P]autobahn/xdiff/xmerge.c
// Function: xdl_merge
int xdl_merge(mmfile_t *orig, mmfile_t *mf1, mmfile_t *mf2,
		xmparam_t const *xmp, mmbuffer_t *result)
{
	xdchange_t *xscr1, *xscr2;
	xdfenv_t xe1, xe2;
	int status;
	xpparam_t const *xpp = &xmp->xpp;

	result->ptr = NULL;
	result->size = 0;

	if (xdl_do_diff(orig, mf1, xpp, &xe1) < 0) {
		return -1;
	}
	if (xdl_do_diff(orig, mf2, xpp, &xe2) < 0) {
		xdl_free_env(&xe1);
		return -1;
	}
	if (xdl_change_compact(&xe1.xdf1, &xe1.xdf2, xpp->flags) < 0 ||
	    xdl_change_compact(&xe1.xdf2, &xe1.xdf1, xpp->flags) < 0 ||
	    xdl_build_script(&xe1, &xscr1) < 0) {
		xdl_free_env(&xe1);
		return -1;
	}
	if (xdl_change_compact(&xe2.xdf1, &xe2.xdf2, xpp->flags) < 0 ||
	    xdl_change_compact(&xe2.xdf2, &xe2.xdf1, xpp->flags) < 0 ||
	    xdl_build_script(&xe2, &xscr2) < 0) {
		xdl_free_script(xscr1);
		xdl_free_env(&xe1);
		xdl_free_env(&xe2);
		return -1;
	}
	status = 0;
	if (!xscr1) {
		result->ptr = xdl_malloc(mf2->size);
		memcpy(result->ptr, mf2->ptr, mf2->size);
		result->size = mf2->size;
	} else if (!xscr2) {
		result->ptr = xdl_malloc(mf1->size);
		memcpy(result->ptr, mf1->ptr, mf1->size);
		result->size = mf1->size;
	} else {
		status = xdl_do_merge(&xe1, xscr1,
				      &xe2, xscr2,
				      xmp, result);
	}
	xdl_free_script(xscr1);
	xdl_free_script(xscr2);

	xdl_free_env(&xe1);
	xdl_free_env(&xe2);

	return status;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x3e8, %rsp            # imm = 0x3E8
movq %r8, %rbp
movq %rcx, %r12
movq %rdx, %r15
movq %rsi, %r13
movq %rdi, %r14
xorps %xmm0, %xmm0
movups %xmm0, (%r8)
leaq 0xb8(%rsp), %rbx
movq %rcx, %rdx
movq %rbx, %rcx
callq 0x1a70
testl %eax, %eax
js 0x4775
leaq 0x1c8(%rsp), %rcx
movq %r14, %rdi
movq %r15, %rsi
movq %r12, %rdx
callq 0x1a70
pushq $-0x1
popq %r14
testl %eax, %eax
js 0x4cca
movq %rbp, 0x50(%rsp)
leaq 0x140(%rsp), %rbp
movq (%r12), %rdx
leaq 0xb8(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x1bf4
testl %eax, %eax
js 0x4cca
movq (%r12), %rdx
leaq 0xb8(%rsp), %rbx
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x1bf4
testl %eax, %eax
js 0x4cca
leaq 0xb8(%rsp), %rbx
leaq 0x60(%rsp), %rbp
movq %rbx, %rdi
movq %rbp, %rsi
callq 0x2164
testl %eax, %eax
js 0x4cca
leaq 0x250(%rsp), %rsi
movq (%r12), %rdx
leaq 0x1c8(%rsp), %rbx
movq %rbx, %rdi
callq 0x1bf4
pushq $-0x1
popq %r14
testl %eax, %eax
js 0x4cb4
movq (%r12), %rdx
leaq 0x1c8(%rsp), %rsi
leaq 0x250(%rsp), %rdi
callq 0x1bf4
testl %eax, %eax
js 0x4cb4
leaq 0x1c8(%rsp), %rdi
movq %rsp, %rsi
callq 0x2164
testl %eax, %eax
js 0x4cb4
movq 0x60(%rsp), %rbp
testq %rbp, %rbp
je 0x4831
movq (%rsp), %r15
testq %r15, %r15
je 0x485d
movq 0x18(%r12), %rax
movq %rax, 0xa8(%rsp)
movq 0x20(%r12), %rax
movq %rax, 0x28(%rsp)
movq 0x28(%r12), %r14
movl 0x14(%r12), %ecx
movl 0xc(%r12), %eax
testl %eax, %eax
pushq $0x1
popq %rsi
cmovlel %eax, %esi
movl 0x10(%r12), %edx
movl %edx, 0x3c(%rsp)
movq %rcx, 0xb0(%rsp)
cmpl $0x1, %ecx
cmovnel %eax, %esi
movl %esi, 0x30(%rsp)
leaq 0x10(%rsp), %rax
andq $0x0, (%rax)
xorl %r13d, %r13d
testq %rbp, %rbp
je 0x47c8
testq %r15, %r15
je 0x47c8
testq %r13, %r13
jne 0x4558
movq 0x10(%rsp), %r13
movq 0x8(%rbp), %rsi
movq 0x18(%rbp), %rcx
leaq (%rcx,%rsi), %rax
movq 0x8(%r15), %rdi
cmpq %rdi, %rax
jge 0x45a3
movslq %esi, %rdx
subl %edi, %esi
addl 0x10(%r15), %esi
movslq 0x10(%rbp), %r8
movslq 0x20(%rbp), %r9
movslq %ecx, %rcx
movslq %esi, %rax
leaq 0x10(%rsp), %rdi
pushq $0x1
popq %rsi
pushq %rcx
pushq %rax
callq 0x4ce7
popq %rcx
popq %rdx
testl %eax, %eax
jne 0x4c95
movq (%rbp), %rbp
jmp 0x453c
movq 0x18(%r15), %r8
leaq (%r8,%rdi), %rdx
cmpq %rsi, %rdx
jge 0x45eb
movslq %edi, %rdx
subl %esi, %edi
addl 0x10(%rbp), %edi
movslq 0x10(%r15), %rax
movslq 0x20(%r15), %r10
movslq %r8d, %rcx
movslq %edi, %r8
leaq 0x10(%rsp), %rdi
pushq $0x2
popq %rsi
movq %rcx, %r9
pushq %r10
pushq %rax
callq 0x4ce7
popq %rcx
popq %rdx
testl %eax, %eax
jne 0x4c95
movq (%r15), %r15
jmp 0x453c
cmpl $0x0, 0x30(%rsp)
movq %r14, 0x40(%rsp)
je 0x46c1
cmpq %rdi, %rsi
jne 0x46c1
cmpq %r8, %rcx
jne 0x46c1
movq 0x20(%rbp), %rdx
movq %rcx, %r8
movq %rsi, %rdi
cmpq 0x20(%r15), %rdx
jne 0x46c1
movslq 0x10(%rbp), %rax
movslq 0x10(%r15), %rcx
shlq $0x3, %rax
addq 0x1a0(%rsp), %rax
movq %rax, 0x8(%rsp)
movq (%r12), %rax
movq %rax, 0x18(%rsp)
shlq $0x3, %rcx
addq 0x2b0(%rsp), %rcx
movq %rcx, 0x48(%rsp)
testl %edx, %edx
movl $0x0, %eax
cmovlel %eax, %edx
xorl %r14d, %r14d
movq %r13, 0x20(%rsp)
cmpq %r14, %rdx
je 0x474e
movq 0x8(%rsp), %rax
movq (%rax,%r14,8), %rax
movq 0x8(%rax), %rdi
movq 0x10(%rax), %rsi
movq 0x48(%rsp), %rax
movq (%rax,%r14,8), %rax
movq %rdx, %r13
movq 0x8(%rax), %rdx
movq 0x10(%rax), %rcx
movq 0x18(%rsp), %r8
callq 0x3d01
movq %r13, %rdx
movq 0x20(%rsp), %r13
incq %r14
testl %eax, %eax
jne 0x4666
movq 0x8(%rbp), %rsi
movq 0x18(%rbp), %rcx
movq 0x8(%r15), %rdi
movq 0x18(%r15), %r8
leaq (%rcx,%rsi), %rax
subq %r8, %rcx
movq %rsi, %r10
subq %rdi, %r10
addq %r10, %rcx
movq 0x10(%rbp), %r9
testl %r10d, %r10d
movq %r10, %rdx
movl $0x0, %r8d
cmovleq %r8, %rdx
cmovgq %rdi, %rsi
cmovgl %r8d, %r10d
movl 0x10(%r15), %r11d
addl %r10d, %r11d
movq %r9, %rdi
subq %rdx, %rdi
movslq %esi, %rdx
movslq %edi, %r8
movl 0x20(%r15), %edi
movslq %r11d, %r11
movslq %ecx, %rsi
movq %rsi, %rcx
shrq $0x1f, %rcx
andl %esi, %ecx
subl %edx, %eax
subl %ecx, %eax
addl 0x20(%rbp), %r9d
addl %r8d, %ecx
subl %ecx, %r9d
subl %r10d, %edi
testl %esi, %esi
movl $0x0, %ecx
cmovsl %ecx, %esi
addl %edi, %esi
movslq %eax, %rcx
movslq %r9d, %r9
movslq %esi, %rax
leaq 0x10(%rsp), %rdi
xorl %esi, %esi
pushq %rax
pushq %r11
callq 0x4ce7
popq %rcx
popq %rdx
testl %eax, %eax
jne 0x4c95
movl 0x18(%rbp), %eax
addl 0x8(%rbp), %eax
movl 0x18(%r15), %ecx
addl 0x8(%r15), %ecx
cmpl %ecx, %eax
jl 0x4763
movq (%r15), %r15
movq 0x40(%rsp), %r14
cmpl %eax, %ecx
jl 0x453c
jmp 0x459d
pushq $-0x1
popq %r14
jmp 0x4cd2
testq %r13, %r13
jne 0x4788
movq 0x10(%rsp), %r13
movq 0x8(%rbp), %rax
movslq %eax, %rdx
addl 0x288(%rsp), %eax
subl 0x200(%rsp), %eax
movslq 0x10(%rbp), %r8
movslq 0x18(%rbp), %rcx
movslq 0x20(%rbp), %r9
cltq
leaq 0x10(%rsp), %rdi
pushq $0x1
popq %rsi
pushq %rcx
pushq %rax
callq 0x4ce7
popq %rcx
popq %rdx
testl %eax, %eax
jne 0x4c95
movq (%rbp), %rbp
testq %rbp, %rbp
jne 0x477e
movq %r14, 0x40(%rsp)
leaq 0x10(%rsp), %r14
pushq $0x2
popq %rbp
testq %r13, %r13
jne 0x47e4
movq 0x10(%rsp), %r13
testq %r15, %r15
je 0x488f
movq 0x8(%r15), %rax
movslq %eax, %rdx
addl 0x178(%rsp), %eax
subl 0xf0(%rsp), %eax
movslq 0x10(%r15), %r10
movslq 0x18(%r15), %rcx
movslq 0x20(%r15), %r11
movslq %eax, %r8
movq %r14, %rdi
movl %ebp, %esi
movq %rcx, %r9
pushq %r11
pushq %r10
callq 0x4ce7
popq %rcx
popq %rdx
testl %eax, %eax
jne 0x4c95
movq (%r15), %r15
jmp 0x47da
movq 0x8(%r15), %r14
movq %r14, %rdi
callq 0x10f0
movq 0x50(%rsp), %r12
movq %rax, (%r12)
movq (%r15), %rsi
movq %rax, %rdi
movq %r14, %rdx
callq 0x10e0
movq %r14, 0x8(%r12)
xorl %ebp, %ebp
jmp 0x4884
movq 0x8(%r13), %r14
movq %r14, %rdi
callq 0x10f0
movq 0x50(%rsp), %r15
movq %rax, (%r15)
movq (%r13), %rsi
movq %rax, %rdi
movq %r14, %rdx
callq 0x10e0
movq %r14, 0x8(%r15)
xorl %r14d, %r14d
movq %rsp, %r15
jmp 0x4ca9
cmpl $0x2, 0x30(%rsp)
movq 0x28(%rsp), %r15
jl 0x4be0
leaq 0x78(%rsp), %rdi
leaq 0x68(%rsp), %rsi
leaq 0x2d8(%rsp), %r15
movq %r13, %rbp
testq %rbp, %rbp
je 0x4a98
cmpl $0x0, 0x8(%rbp)
je 0x48c9
movq (%rbp), %rbp
jmp 0x48b4
movq 0x20(%rbp), %rcx
testq %rcx, %rcx
je 0x48c3
movq 0x28(%rbp), %rax
testq %rax, %rax
je 0x48c3
movq 0x10(%rbp), %r14
movq 0x18(%rbp), %r9
movq 0x1a0(%rsp), %rdx
leaq (%rdx,%r14,8), %rdx
movq (%rdx), %r8
movq 0x8(%r8), %r8
movq %r8, 0x78(%rsp)
movq -0x8(%rdx,%rcx,8), %rcx
movq 0x8(%rcx), %rdx
addq 0x10(%rcx), %rdx
subq %r8, %rdx
movq %rdx, 0x80(%rsp)
movq 0x2b0(%rsp), %rcx
movq %r9, 0x8(%rsp)
leaq (%rcx,%r9,8), %rcx
movq (%rcx), %rdx
movq 0x8(%rdx), %rdx
movq %rdx, 0x68(%rsp)
movq -0x8(%rcx,%rax,8), %rax
movq 0x8(%rax), %rcx
addq 0x10(%rax), %rcx
subq %rdx, %rcx
movq %rcx, 0x70(%rsp)
movq %r12, %rdx
movq %r15, %rcx
callq 0x1a70
testl %eax, %eax
js 0x4c95
movq (%r12), %rdx
movq %r15, %rdi
leaq 0x360(%rsp), %rsi
callq 0x1bf4
testl %eax, %eax
js 0x4c88
movq (%r12), %rdx
leaq 0x360(%rsp), %rdi
movq %r15, %rsi
callq 0x1bf4
testl %eax, %eax
js 0x4c88
movq %r15, %rdi
leaq 0x58(%rsp), %rsi
callq 0x2164
testl %eax, %eax
js 0x4c88
movq 0x58(%rsp), %rcx
testq %rcx, %rcx
je 0x4a3a
movslq %r14d, %rdx
movq 0x8(%rcx), %rax
movq %rdx, 0x20(%rsp)
addq %rdx, %rax
movq %rax, 0x10(%rbp)
movslq 0x8(%rsp), %r15
movq 0x10(%rcx), %rax
addq %r15, %rax
movq %rax, 0x18(%rbp)
movups 0x18(%rcx), %xmm0
movups %xmm0, 0x20(%rbp)
movq %rcx, 0x8(%rsp)
movq (%rcx), %r14
testq %r14, %r14
je 0x4a53
pushq $0x40
popq %rdi
callq 0x10f0
testq %rax, %rax
je 0x4a7c
movq %r14, 0x58(%rsp)
movq (%rbp), %rcx
movq %rcx, (%rax)
movq %rax, (%rbp)
andl $0x0, 0x8(%rax)
movq 0x58(%rsp), %rcx
movq 0x8(%rcx), %rdx
addq 0x20(%rsp), %rdx
movq %rdx, 0x10(%rax)
movq 0x10(%rcx), %rdx
addq %r15, %rdx
movq %rdx, 0x18(%rax)
movups 0x18(%rcx), %xmm0
movups %xmm0, 0x20(%rax)
movq %rax, %rbp
jmp 0x49e3
leaq 0x2d8(%rsp), %r15
movq %r15, %rdi
callq 0x3a52
movl $0x4, 0x8(%rbp)
jmp 0x4a6d
leaq 0x2d8(%rsp), %r15
movq %r15, %rdi
callq 0x3a52
movq 0x8(%rsp), %rdi
callq 0x223e
leaq 0x78(%rsp), %rdi
leaq 0x68(%rsp), %rsi
jmp 0x48c3
leaq 0x2d8(%rsp), %rdi
callq 0x3a52
movq 0x8(%rsp), %rdi
callq 0x223e
jmp 0x4c95
testq %r13, %r13
movq 0x28(%rsp), %r15
je 0x4be0
movq $0x0, 0x18(%rsp)
movq %r13, %r14
movq %r14, %rbp
movq (%r14), %r14
testq %r14, %r14
je 0x4bd5
cmpl $0x0, 0x8(%rbp)
jne 0x4ab2
cmpl $0x0, 0x8(%r14)
jne 0x4ab2
movq 0x10(%rbp), %rcx
movq 0x20(%rbp), %rax
addq %rcx, %rax
movq 0x10(%r14), %rdx
movl %edx, %esi
subl %eax, %esi
movl %esi, 0x48(%rsp)
cmpl $0x4, %esi
jl 0x4b8d
cmpl $0x2, 0x30(%rsp)
je 0x4ab2
cltq
movq 0x1a0(%rsp), %rsi
movq %rsi, 0xa0(%rsp)
movq %rcx, 0x90(%rsp)
movq %rdx, 0x88(%rsp)
subl $0x1, 0x48(%rsp)
jb 0x4b8d
movq %rax, 0x98(%rsp)
movq 0xa0(%rsp), %rcx
movq (%rcx,%rax,8), %rax
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x20(%rsp)
xorl %r15d, %r15d
cmpq %r15, 0x20(%rsp)
je 0x4b6b
callq 0x1150
movq (%rax), %rax
movq 0x8(%rsp), %rcx
movzbl (%rcx,%r15), %ecx
incq %r15
testb $0x8, (%rax,%rcx,2)
je 0x4b47
jmp 0x4bcb
movq 0x98(%rsp), %rax
incq %rax
movq 0x28(%rsp), %r15
movq 0x90(%rsp), %rcx
movq 0x88(%rsp), %rdx
jmp 0x4b17
subq %rcx, %rdx
addq 0x20(%r14), %rdx
movq %rdx, 0x20(%rbp)
movq 0x28(%r14), %rax
addq 0x18(%r14), %rax
subq 0x18(%rbp), %rax
movq 0x18(%rsp), %rcx
incl %ecx
movq %rcx, 0x18(%rsp)
movq %rax, 0x28(%rbp)
movq (%r14), %rax
movq %rax, (%rbp)
movq %r14, %rdi
callq 0x1030
movq %rbp, %r14
jmp 0x4ab2
movq 0x28(%rsp), %r15
jmp 0x4ab2
cmpl $0x0, 0x18(%rsp)
js 0x4c95
movl 0x8(%r12), %eax
leaq 0xb8(%rsp), %rdi
leaq 0x1c8(%rsp), %rdx
movq %r15, %rsi
movq 0x40(%rsp), %r15
movq %r15, %rcx
movq 0xa8(%rsp), %rbp
movq %rbp, %r8
movl 0x3c(%rsp), %r9d
movq %rax, 0x30(%rsp)
pushq %rax
movq 0xb8(%rsp), %r12
pushq %r12
pushq $0x0
pushq %r13
callq 0x4ded
addq $0x20, %rsp
movslq %eax, %r14
movq %r14, %rdi
callq 0x10f0
movq 0x50(%rsp), %rcx
movq %rax, (%rcx)
testq %rax, %rax
je 0x4c95
movq %r14, 0x8(%rcx)
leaq 0xb8(%rsp), %rdi
leaq 0x1c8(%rsp), %rdx
movq 0x28(%rsp), %rsi
movq %r15, %rcx
movq %rbp, %r8
movl 0x3c(%rsp), %r9d
pushq 0x30(%rsp)
pushq %r12
pushq %rax
pushq %r13
callq 0x4ded
addq $0x20, %rsp
movq %r13, %rdi
callq 0x4dc4
movl %eax, %r14d
jmp 0x4ca1
leaq 0x2d8(%rsp), %rdi
callq 0x3a52
movq %r13, %rdi
callq 0x4dc4
pushq $-0x1
popq %r14
movq %rsp, %r15
movq 0x60(%rsp), %rbp
movq %rbp, %rdi
callq 0x223e
movq %r15, %rbp
movq (%rbp), %rdi
callq 0x223e
leaq 0xb8(%rsp), %rdi
callq 0x3a52
movq %rbx, %rdi
callq 0x3a52
movl %r14d, %eax
addq $0x3e8, %rsp            # imm = 0x3E8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq