// File: /workspace/github_c_makefile_star2_O1/LemonBoy[P]autobahn/xdiff/xdiffi.c
// Function: xdl_do_diff
int xdl_do_diff(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
		xdfenv_t *xe) {
	long ndiags;
	long *kvd, *kvdf, *kvdb;
	xdalgoenv_t xenv;
	diffdata_t dd1, dd2;

	if (XDF_DIFF_ALG(xpp->flags) == XDF_PATIENCE_DIFF)
		return xdl_do_patience_diff(mf1, mf2, xpp, xe);

	if (XDF_DIFF_ALG(xpp->flags) == XDF_HISTOGRAM_DIFF)
		return xdl_do_histogram_diff(mf1, mf2, xpp, xe);

	if (xdl_prepare_env(mf1, mf2, xpp, xe) < 0) {

		return -1;
	}

	/*
	 * Allocate and setup K vectors to be used by the differential algorithm.
	 * One is to store the forward path and one to store the backward path.
	 */
	ndiags = xe->xdf1.nreff + xe->xdf2.nreff + 3;
	if (!(kvd = (long *) xdl_malloc((2 * ndiags + 2) * sizeof(long)))) {

		xdl_free_env(xe);
		return -1;
	}
	kvdf = kvd;
	kvdb = kvdf + ndiags;
	kvdf += xe->xdf2.nreff + 1;
	kvdb += xe->xdf2.nreff + 1;

	xenv.mxcost = xdl_bogosqrt(ndiags);
	if (xenv.mxcost < XDL_MAX_COST_MIN)
		xenv.mxcost = XDL_MAX_COST_MIN;
	xenv.snake_cnt = XDL_SNAKE_CNT;
	xenv.heur_min = XDL_HEUR_MIN_COST;

	dd1.nrec = xe->xdf1.nreff;
	dd1.ha = xe->xdf1.ha;
	dd1.rchg = xe->xdf1.rchg;
	dd1.rindex = xe->xdf1.rindex;
	dd2.nrec = xe->xdf2.nreff;
	dd2.ha = xe->xdf2.ha;
	dd2.rchg = xe->xdf2.rchg;
	dd2.rindex = xe->xdf2.rindex;

	if (xdl_recs_cmp(&dd1, 0, dd1.nrec, &dd2, 0, dd2.nrec,
			 kvdf, kvdb, (xpp->flags & XDF_NEED_MINIMAL) != 0, &xenv) < 0) {

		xdl_free(kvd);
		xdl_free_env(xe);
		return -1;
	}

	xdl_free(kvd);

	return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rcx, %rbx
movq %rdx, %r14
movq (%rdx), %rax
andl $0x60, %eax
cmpq $0x40, %rax
je 0x1d85
cmpl $0x20, %eax
jne 0x1d9e
movq %r14, %rdx
movq %rbx, %rcx
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2964
movq %r14, %rdx
movq %rbx, %rcx
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x605c
movq %r14, %rdx
movq %rbx, %rcx
callq 0x37e4
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
testl %eax, %eax
js 0x1eaf
movq 0x78(%rbx), %rax
movq 0x100(%rbx), %r13
leaq (%rax,%r13), %r12
addq $0x3, %r12
movq %r12, %rdi
shlq $0x4, %rdi
addq $0x10, %rdi
callq 0x10e0
testq %rax, %rax
je 0x1ea1
movq %rax, %r15
leaq (%rax,%r13,8), %r13
addq $0x8, %r13
leaq (,%r12,8), %rbp
addq %r13, %rbp
movq %r12, %rdi
callq 0x429c
cmpq $0x101, %rax            # imm = 0x101
movl $0x100, %ecx            # imm = 0x100
cmovlq %rcx, %rax
movq %rsp, %r10
movq %rax, (%r10)
movq $0x14, 0x8(%r10)
movq %rcx, 0x10(%r10)
movq 0x78(%rbx), %rdx
leaq 0x38(%rsp), %rdi
movq %rdx, (%rdi)
movq 0x80(%rbx), %rax
movq %rax, 0x8(%rdi)
movdqu 0x68(%rbx), %xmm0
pshufd $0x4e, %xmm0, %xmm0     # xmm0 = xmm0[2,3,0,1]
movdqu %xmm0, 0x10(%rdi)
movq 0x100(%rbx), %r9
leaq 0x18(%rsp), %rcx
movq %r9, (%rcx)
movq 0x108(%rbx), %rax
movq %rax, 0x8(%rcx)
movdqu 0xf0(%rbx), %xmm0
pshufd $0x4e, %xmm0, %xmm0     # xmm0 = xmm0[2,3,0,1]
movdqu %xmm0, 0x10(%rcx)
movl (%r14), %eax
shrl %eax
andl $0x1, %eax
xorl %r12d, %r12d
xorl %esi, %esi
xorl %r8d, %r8d
pushq %r10
pushq %rax
pushq %rbp
pushq %r13
callq 0x136c
addq $0x20, %rsp
movl %eax, %ebp
movq %r15, %rdi
callq 0x1030
testl %ebp, %ebp
jns 0x1eaf
movq %rbx, %rdi
callq 0x41c6
movl $0xffffffff, %r12d      # imm = 0xFFFFFFFF
movl %r12d, %eax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq