// File: /workspace/github_c_makefile_star2_O1/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 0x1d47
testl %eax, %eax
js 0x4d94
leaq 0x18(%rsp), %rcx
movq %rbp, %rdi
movq %r13, %rsi
movq %r15, %rdx
callq 0x1d47
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testl %eax, %eax
js 0x4e01
movq %r14, (%rsp)
leaq 0x1b0(%rsp), %r14
movq (%r15), %rdx
leaq 0x128(%rsp), %rbx
movq %rbx, %rdi
movq %r14, %rsi
callq 0x1ec1
testl %eax, %eax
js 0x4e01
movq (%r15), %rdx
leaq 0x128(%rsp), %rbx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x1ec1
testl %eax, %eax
js 0x4e01
leaq 0x128(%rsp), %rbx
leaq 0x10(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2515
testl %eax, %eax
js 0x4e01
leaq 0xa0(%rsp), %rsi
movq (%r15), %rdx
leaq 0x18(%rsp), %rbx
movq %rbx, %rdi
callq 0x1ec1
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
testl %eax, %eax
js 0x4dec
movq (%r15), %rdx
leaq 0x18(%rsp), %rsi
leaq 0xa0(%rsp), %rdi
callq 0x1ec1
testl %eax, %eax
js 0x4dec
leaq 0x18(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x2515
testl %eax, %eax
js 0x4dec
movq 0x10(%rsp), %rsi
testq %rsi, %rsi
je 0x4d9b
movq 0x8(%rsp), %rcx
testq %rcx, %rcx
je 0x4db4
leaq 0x128(%rsp), %rdi
leaq 0x18(%rsp), %rdx
movq %r15, %r8
movq (%rsp), %r9
callq 0x4e1d
movl %eax, %ebp
jmp 0x4ddd
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x4e09
movq 0x8(%r13), %r14
movq %r14, %rdi
callq 0x10e0
movq (%rsp), %r15
movq %rax, (%r15)
movq (%r13), %rsi
jmp 0x4dcc
movq 0x8(%r12), %r14
movq %r14, %rdi
callq 0x10e0
movq (%rsp), %r15
movq %rax, (%r15)
movq (%r12), %rsi
movq %rax, %rdi
movq %r14, %rdx
callq 0x10d0
movq %r14, 0x8(%r15)
xorl %ebp, %ebp
movq 0x10(%rsp), %rdi
callq 0x264a
leaq 0x8(%rsp), %r14
movq (%r14), %rdi
callq 0x264a
leaq 0x128(%rsp), %rdi
callq 0x41c6
movq %rbx, %rdi
callq 0x41c6
movl %ebp, %eax
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq