// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x278, %rsp            # imm = 0x278
movq %rdi, 0x268(%rsp)
movq %rsi, 0x260(%rsp)
movq %rdx, 0x258(%rsp)
movq %rcx, 0x250(%rsp)
movq %r8, 0x248(%rsp)
movq 0x250(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x248(%rsp), %rax
movq $0x0, (%rax)
movq 0x248(%rsp), %rax
movq $0x0, 0x8(%rax)
movq 0x268(%rsp), %rdi
movq 0x260(%rsp), %rsi
movq 0x8(%rsp), %rdx
leaq 0x128(%rsp), %rcx
callq 0x2330
cmpl $0x0, %eax
jge 0x81b2
movl $0xffffffff, 0x274(%rsp) # imm = 0xFFFFFFFF
jmp 0x8462
movq 0x268(%rsp), %rdi
movq 0x258(%rsp), %rsi
movq 0x8(%rsp), %rdx
leaq 0x18(%rsp), %rcx
callq 0x2330
cmpl $0x0, %eax
jge 0x81f3
leaq 0x128(%rsp), %rdi
callq 0x6080
movl $0xffffffff, 0x274(%rsp) # imm = 0xFFFFFFFF
jmp 0x8462
leaq 0x128(%rsp), %rdi
leaq 0x128(%rsp), %rsi
addq $0x88, %rsi
movq 0x8(%rsp), %rax
movq (%rax), %rdx
callq 0x2690
cmpl $0x0, %eax
jl 0x825f
leaq 0x128(%rsp), %rdi
addq $0x88, %rdi
leaq 0x128(%rsp), %rsi
movq 0x8(%rsp), %rax
movq (%rax), %rdx
callq 0x2690
cmpl $0x0, %eax
jl 0x825f
leaq 0x128(%rsp), %rdi
leaq 0x240(%rsp), %rsi
callq 0x3110
cmpl $0x0, %eax
jge 0x827c
leaq 0x128(%rsp), %rdi
callq 0x6080
movl $0xffffffff, 0x274(%rsp) # imm = 0xFFFFFFFF
jmp 0x8462
leaq 0x18(%rsp), %rdi
leaq 0x18(%rsp), %rsi
addq $0x88, %rsi
movq 0x8(%rsp), %rax
movq (%rax), %rdx
callq 0x2690
cmpl $0x0, %eax
jl 0x82d9
leaq 0x18(%rsp), %rdi
addq $0x88, %rdi
leaq 0x18(%rsp), %rsi
movq 0x8(%rsp), %rax
movq (%rax), %rdx
callq 0x2690
cmpl $0x0, %eax
jl 0x82d9
leaq 0x18(%rsp), %rdi
leaq 0x238(%rsp), %rsi
callq 0x3110
cmpl $0x0, %eax
jge 0x830d
movq 0x240(%rsp), %rdi
callq 0x3360
leaq 0x128(%rsp), %rdi
callq 0x6080
leaq 0x18(%rsp), %rdi
callq 0x6080
movl $0xffffffff, 0x274(%rsp) # imm = 0xFFFFFFFF
jmp 0x8462
movl $0x0, 0x14(%rsp)
cmpq $0x0, 0x240(%rsp)
jne 0x8383
movq 0x258(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x10f0
movq %rax, %rcx
movq 0x248(%rsp), %rax
movq %rcx, (%rax)
movq 0x248(%rsp), %rax
movq (%rax), %rdi
movq 0x258(%rsp), %rax
movq (%rax), %rsi
movq 0x258(%rsp), %rax
movq 0x8(%rax), %rdx
callq 0x10e0
movq 0x258(%rsp), %rax
movq 0x8(%rax), %rcx
movq 0x248(%rsp), %rax
movq %rcx, 0x8(%rax)
jmp 0x8426
cmpq $0x0, 0x238(%rsp)
jne 0x83ee
movq 0x260(%rsp), %rax
movq 0x8(%rax), %rdi
callq 0x10f0
movq %rax, %rcx
movq 0x248(%rsp), %rax
movq %rcx, (%rax)
movq 0x248(%rsp), %rax
movq (%rax), %rdi
movq 0x260(%rsp), %rax
movq (%rax), %rsi
movq 0x260(%rsp), %rax
movq 0x8(%rax), %rdx
callq 0x10e0
movq 0x260(%rsp), %rax
movq 0x8(%rax), %rcx
movq 0x248(%rsp), %rax
movq %rcx, 0x8(%rax)
jmp 0x8424
movq 0x240(%rsp), %rsi
movq 0x238(%rsp), %rcx
movq 0x250(%rsp), %r8
movq 0x248(%rsp), %r9
leaq 0x128(%rsp), %rdi
leaq 0x18(%rsp), %rdx
callq 0x8480
movl %eax, 0x14(%rsp)
jmp 0x8426
movq 0x240(%rsp), %rdi
callq 0x3360
movq 0x238(%rsp), %rdi
callq 0x3360
leaq 0x128(%rsp), %rdi
callq 0x6080
leaq 0x18(%rsp), %rdi
callq 0x6080
movl 0x14(%rsp), %eax
movl %eax, 0x274(%rsp)
movl 0x274(%rsp), %eax
addq $0x278, %rsp            # imm = 0x278
retq
nopw %cs:(%rax,%rax)