// File: /workspace/github_c_makefile_star2_O3/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 $0x238, %rsp            # imm = 0x238
movq %r8, %r14
movq %rcx, %r15
movq %rdx, %r13
movq %rsi, %r12
movq %rdi, %rbp
xorps %xmm0, %xmm0
movups %xmm0, (%r8)
leaq 0x128(%rsp), %rbx
movq %rcx, %rdx
movq %rbx, %rcx
callq 0x1d2d
testl %eax, %eax
js 0x4b65
leaq 0x18(%rsp), %rcx
movq %rbp, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x1d2d
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testl %eax, %eax
js 0x4be7
movq %r14, (%rsp)
leaq 0x1b0(%rsp), %r14
movq (%r15), %rdx
leaq 0x128(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1ea7
testl %eax, %eax
js 0x4be7
movq (%r15), %rdx
leaq 0x128(%rsp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1ea7
testl %eax, %eax
js 0x4be7
leaq 0x128(%rsp), %rbx
leaq 0x10(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x24b6
testl %eax, %eax
js 0x4be7
leaq 0xa0(%rsp), %rsi
movq (%r15), %rdx
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
callq 0x1ea7
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testl %eax, %eax
js 0x4bd2
movq (%r15), %rdx
leaq 0x18(%rsp), %rsi
leaq 0xa0(%rsp), %rdi
callq 0x1ea7
testl %eax, %eax
js 0x4bd2
leaq 0x18(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x24b6
testl %eax, %eax
js 0x4bd2
movq 0x10(%rsp), %rsi
testq %rsi, %rsi
je 0x4b6f
movq 0x8(%rsp), %rcx
testq %rcx, %rcx
je 0x4b99
leaq 0x128(%rsp), %rdi
leaq 0x18(%rsp), %rdx
movq %r15, %r8
movq (%rsp), %r9
callq 0x4c03
movl %eax, %ebp
movq 0x10(%rsp), %rdi
jmp 0x4bc8
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x4bef
movq 0x8(%r13), %r14
movq %r14, %rdi
callq 0x10f0
movq (%rsp), %r15
movq %rax, (%r15)
movq (%r13), %rsi
movq %rax, %rdi
movq %r14, %rdx
callq 0x10e0
movq %r14, 0x8(%r15)
xorl %edi, %edi
jmp 0x4bc6
movq 0x8(%r12), %r14
movq %r14, %rdi
movq %rsi, %r13
callq 0x10f0
movq (%rsp), %r15
movq %rax, (%r15)
movq (%r12), %rsi
movq %rax, %rdi
movq %r14, %rdx
callq 0x10e0
movq %r13, %rdi
movq %r14, 0x8(%r15)
xorl %ebp, %ebp
callq 0x25e6
leaq 0x8(%rsp), %r14
movq (%r14), %rdi
callq 0x25e6
leaq 0x128(%rsp), %rdi
callq 0x4075
movq %rbx, %rdi
callq 0x4075
movl %ebp, %eax
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq