// File: /workspace/github_c_makefile_star2_O0/LemonBoy[P]autobahn/xdiff/xprepare.c
// Function: xdl_prepare_env
int xdl_prepare_env(mmfile_t *mf1, mmfile_t *mf2, xpparam_t const *xpp,
		    xdfenv_t *xe) {
	long enl1, enl2, sample;
	xdlclassifier_t cf;

	memset(&cf, 0, sizeof(cf));

	/*
	 * For histogram diff, we can afford a smaller sample size and
	 * thus a poorer estimate of the number of lines, as the hash
	 * table (rhash) won't be filled up/grown. The number of lines
	 * (nrecs) will be updated correctly anyway by
	 * xdl_prepare_ctx().
	 */
	sample = (XDF_DIFF_ALG(xpp->flags) == XDF_HISTOGRAM_DIFF
		  ? XDL_GUESS_NLINES2 : XDL_GUESS_NLINES1);

	enl1 = xdl_guess_lines(mf1, sample) + 1;
	enl2 = xdl_guess_lines(mf2, sample) + 1;

	if (XDF_DIFF_ALG(xpp->flags) != XDF_HISTOGRAM_DIFF &&
	    xdl_init_classifier(&cf, enl1 + enl2 + 1, xpp->flags) < 0)
		return -1;

	if (xdl_prepare_ctx(1, mf1, enl1, xpp, &cf, &xe->xdf1) < 0) {

		xdl_free_classifier(&cf);
		return -1;
	}
	if (xdl_prepare_ctx(2, mf2, enl2, xpp, &cf, &xe->xdf2) < 0) {

		xdl_free_ctx(&xe->xdf1);
		xdl_free_classifier(&cf);
		return -1;
	}

	if ((XDF_DIFF_ALG(xpp->flags) != XDF_PATIENCE_DIFF) &&
	    (XDF_DIFF_ALG(xpp->flags) != XDF_HISTOGRAM_DIFF) &&
	    xdl_optimize_ctxs(&cf, &xe->xdf1, &xe->xdf2) < 0) {

		xdl_free_ctx(&xe->xdf2);
		xdl_free_ctx(&xe->xdf1);
		xdl_free_classifier(&cf);
		return -1;
	}

	if (XDF_DIFF_ALG(xpp->flags) != XDF_HISTOGRAM_DIFF)
		xdl_free_classifier(&cf);

	return 0;
}

// Assembly:
subq $0xb8, %rsp
movq %rdi, 0xa8(%rsp)
movq %rsi, 0xa0(%rsp)
movq %rdx, 0x98(%rsp)
movq %rcx, 0x90(%rsp)
leaq 0x8(%rsp), %rdi
xorl %esi, %esi
movl $0x70, %edx
callq 0x1090
movq 0x98(%rsp), %rax
movq (%rax), %rdx
andq $0x60, %rdx
movl $0x100, %eax            # imm = 0x100
movl $0x14, %ecx
cmpq $0x40, %rdx
cmovel %ecx, %eax
cltq
movq %rax, 0x78(%rsp)
movq 0xa8(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0x6f90
addq $0x1, %rax
movq %rax, 0x88(%rsp)
movq 0xa0(%rsp), %rdi
movq 0x78(%rsp), %rsi
callq 0x6f90
addq $0x1, %rax
movq %rax, 0x80(%rsp)
movq 0x98(%rsp), %rax
movq (%rax), %rax
andq $0x60, %rax
cmpq $0x40, %rax
je 0x585e
movq 0x88(%rsp), %rsi
addq 0x80(%rsp), %rsi
addq $0x1, %rsi
movq 0x98(%rsp), %rax
movq (%rax), %rdx
leaq 0x8(%rsp), %rdi
callq 0x59d0
cmpl $0x0, %eax
jge 0x585e
movl $0xffffffff, 0xb4(%rsp) # imm = 0xFFFFFFFF
jmp 0x59c0
movq 0xa8(%rsp), %rsi
movq 0x88(%rsp), %rdx
movq 0x98(%rsp), %rcx
movq 0x90(%rsp), %r9
movl $0x1, %edi
leaq 0x8(%rsp), %r8
callq 0x5b30
cmpl $0x0, %eax
jge 0x58ac
leaq 0x8(%rsp), %rdi
callq 0x5f90
movl $0xffffffff, 0xb4(%rsp) # imm = 0xFFFFFFFF
jmp 0x59c0
movq 0xa0(%rsp), %rsi
movq 0x80(%rsp), %rdx
movq 0x98(%rsp), %rcx
movq 0x90(%rsp), %r9
addq $0x88, %r9
movl $0x2, %edi
leaq 0x8(%rsp), %r8
callq 0x5b30
cmpl $0x0, %eax
jge 0x590e
movq 0x90(%rsp), %rdi
callq 0x5fc0
leaq 0x8(%rsp), %rdi
callq 0x5f90
movl $0xffffffff, 0xb4(%rsp) # imm = 0xFFFFFFFF
jmp 0x59c0
movq 0x98(%rsp), %rax
movq (%rax), %rax
andq $0x60, %rax
cmpq $0x20, %rax
je 0x5996
movq 0x98(%rsp), %rax
movq (%rax), %rax
andq $0x60, %rax
cmpq $0x40, %rax
je 0x5996
movq 0x90(%rsp), %rsi
movq 0x90(%rsp), %rdx
addq $0x88, %rdx
leaq 0x8(%rsp), %rdi
callq 0x6020
cmpl $0x0, %eax
jge 0x5996
movq 0x90(%rsp), %rdi
addq $0x88, %rdi
callq 0x5fc0
movq 0x90(%rsp), %rdi
callq 0x5fc0
leaq 0x8(%rsp), %rdi
callq 0x5f90
movl $0xffffffff, 0xb4(%rsp) # imm = 0xFFFFFFFF
jmp 0x59c0
movq 0x98(%rsp), %rax
movq (%rax), %rax
andq $0x60, %rax
cmpq $0x40, %rax
je 0x59b5
leaq 0x8(%rsp), %rdi
callq 0x5f90
movl $0x0, 0xb4(%rsp)
movl 0xb4(%rsp), %eax
addq $0xb8, %rsp
retq
nop