// File: /workspace/github_c_makefile_star2_O3/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x98, %rsp
movq %rcx, %r14
movq %rdx, %r15
movq %rsi, %rbp
movq %rdi, %r12
xorps %xmm0, %xmm0
movaps %xmm0, 0x80(%rsp)
movaps %xmm0, 0x70(%rsp)
movaps %xmm0, 0x60(%rsp)
movaps %xmm0, 0x50(%rsp)
movaps %xmm0, 0x40(%rsp)
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movl (%rdx), %eax
andl $0x60, %eax
cmpl $0x40, %eax
movl $0x14, %eax
movl $0x100, %ebx            # imm = 0x100
cmoveq %rax, %rbx
movq %rbx, %rsi
callq 0x426b
movq %rax, %r13
movq %rbp, 0x18(%rsp)
movq %rbp, %rdi
movq %rbx, %rsi
callq 0x426b
movq %rax, %rbp
incq %rbp
movq (%r15), %rax
movl %eax, %ecx
andl $0x60, %ecx
cmpl $0x40, %ecx
jne 0x386b
incq %r13
leaq 0x20(%rsp), %r8
movl $0x1, %edi
movq %r12, %rsi
movq %r13, %rdx
movq %r15, %rcx
movq %r14, %r9
callq 0x3bca
testl %eax, %eax
js 0x3936
leaq 0x88(%r14), %r13
leaq 0x20(%rsp), %r8
movl $0x2, %edi
movq 0x18(%rsp), %rsi
movq %rbp, %rdx
movq %r15, %rcx
movq %r13, %r9
callq 0x3bca
testl %eax, %eax
js 0x392e
movq (%r15), %rax
andl $0x60, %eax
cmpq $0x20, %rax
je 0x3ba3
cmpl $0x40, %eax
je 0x3ba3
movq %r14, %rbp
movq 0x38(%r14), %r12
movq 0x60(%r14), %rdx
movq 0xe8(%r14), %rsi
movq 0xc0(%r14), %rax
cmpq %rax, %r12
movq %rax, %rcx
cmovlq %r12, %rcx
xorl %edi, %edi
testq %rcx, %rcx
jle 0x3818
movq (%rdx,%rdi,8), %r8
movq 0x18(%r8), %r8
movq (%rsi,%rdi,8), %r9
cmpq 0x18(%r9), %r8
jne 0x3818
incq %rdi
cmpq %rdi, %rcx
jne 0x37fb
movq %rcx, %rdi
movq %rdi, 0xd8(%rbp)
movq %rdi, 0x50(%rbp)
subq %rdi, %rcx
movq %r15, 0x8(%rsp)
jle 0x3962
leaq (%rsi,%rax,8), %rsi
leaq (%rdx,%r12,8), %rdi
movq $-0x8, %r8
xorl %edx, %edx
movq (%rdi,%r8), %r9
movq 0x18(%r9), %r9
movq (%rsi,%r8), %r10
cmpq 0x18(%r10), %r9
jne 0x3863
incq %rdx
addq $-0x8, %r8
cmpq %rdx, %rcx
jne 0x3842
movq %rcx, %rdx
notq %rdx
jmp 0x3969
movq %r14, 0x10(%rsp)
leaq 0x2(,%rbp), %rbx
addq %r13, %rbx
leaq 0x38(%rsp), %r14
movq %rax, 0x50(%r14)
movl %ebx, %edi
callq 0x4715
movl %eax, -0x18(%r14)
movl $0x1, %edx
movl %eax, %ecx
shll %cl, %edx
movslq %edx, %rax
movq %rax, -0x10(%r14)
leaq 0x5(,%rbp), %rdx
addq %r13, %rdx
testq %rbx, %rbx
cmovnsq %rbx, %rdx
sarq $0x2, %rdx
incq %rdx
movl $0x38, %esi
movq %r14, %rdi
callq 0x41c6
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
testl %eax, %eax
js 0x3bb5
movq %r15, 0x8(%rsp)
movq 0x28(%rsp), %rsi
shlq $0x3, %rsi
movl $0x1, %edi
callq 0x10b0
movq %rax, 0x30(%rsp)
testq %rax, %rax
je 0x3953
movq %rax, %r15
movq %rbx, 0x78(%rsp)
shlq $0x3, %rbx
movq %rbx, %rdi
callq 0x10f0
movq %rax, 0x70(%rsp)
testq %rax, %rax
je 0x394b
movq $0x0, 0x80(%rsp)
movq 0x10(%rsp), %r14
movq 0x8(%rsp), %r15
jmp 0x3766
movq %r14, %rdi
callq 0x4035
leaq 0x20(%rsp), %rdi
callq 0x4012
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
jmp 0x3bb5
movq %r15, %rdi
callq 0x1030
leaq 0x38(%rsp), %rdi
callq 0x41e7
jmp 0x3bb5
movq $-0x1, %rdx
leaq (%rdx,%r12), %rcx
movq %rcx, 0x58(%rbp)
addq %rax, %rdx
movq %rdx, 0xe0(%rbp)
leaq (%r12,%rax), %rsi
addq $0x2, %rsi
movl $0x1, %edi
callq 0x10b0
testq %rax, %rax
je 0x3a89
movq %rax, %r15
movq %r12, %rdi
callq 0x4144
movl $0x400, %ebx            # imm = 0x400
cmpq %rbx, %rax
cmovgeq %rbx, %rax
movq 0x50(%rbp), %rcx
movq 0x58(%rbp), %rdx
cmpq %rdx, %rcx
jg 0x39fe
movq 0x60(%rbp), %rsi
movq 0x70(%rsp), %rdi
incq %rdx
movq (%rsi,%rcx,8), %r8
movq 0x18(%r8), %r8
movq (%rdi,%r8,8), %r8
testq %r8, %r8
je 0x39ef
movq 0x30(%r8), %r8
cmpq %rax, %r8
setl %r9b
testq %r8, %r8
je 0x39ef
movb $0x2, %r8b
subb %r9b, %r8b
jmp 0x39f2
xorl %r8d, %r8d
movb %r8b, (%r15,%rcx)
incq %rcx
cmpq %rcx, %rdx
jne 0x39c6
addq %r15, %r12
incq %r12
movq 0xc0(%rbp), %rdi
callq 0x4144
cmpq %rbx, %rax
cmovlq %rax, %rbx
movq 0xd8(%rbp), %r13
movq 0xe0(%rbp), %rcx
cmpq %rcx, %r13
jg 0x3a75
movq 0xe8(%rbp), %rax
movq 0x70(%rsp), %rdx
leaq 0x1(%rcx), %rsi
movq %r13, %rdi
movq (%rax,%rdi,8), %r8
movq 0x18(%r8), %r8
movq (%rdx,%r8,8), %r8
testq %r8, %r8
je 0x3a66
movq 0x28(%r8), %r8
cmpq %rbx, %r8
setl %r9b
testq %r8, %r8
je 0x3a66
movb $0x2, %r8b
subb %r9b, %r8b
jmp 0x3a69
xorl %r8d, %r8d
movb %r8b, (%r12,%rdi)
incq %rdi
cmpq %rdi, %rsi
jne 0x3a3d
movq 0x50(%rbp), %r14
movq 0x58(%rbp), %rax
cmpq %rax, %r14
jle 0x3a99
xorl %ebx, %ebx
jmp 0x3b0c
movq %r13, %rdi
callq 0x4035
movq %rbp, %rdi
jmp 0x3931
movq 0x60(%rbp), %r13
xorl %ebx, %ebx
movzbl (%r15,%r14), %ecx
cmpl $0x1, %ecx
je 0x3acf
cmpl $0x2, %ecx
jne 0x3ac4
movq 0x50(%rbp), %rdx
movq %r15, %rdi
movq %r14, %rsi
movq %rax, %rcx
callq 0x408b
testl %eax, %eax
je 0x3acf
movq 0x68(%rbp), %rax
movb $0x1, (%rax,%r14)
jmp 0x3aee
movq 0x70(%rbp), %rax
movq %r14, (%rax,%rbx,8)
movq (%r13,%r14,8), %rax
movq 0x18(%rax), %rax
movq 0x80(%rbp), %rcx
movq %rax, (%rcx,%rbx,8)
incq %rbx
leaq 0x1(%r14), %rcx
movq 0x58(%rbp), %rax
cmpq %rax, %r14
movq %rcx, %r14
jl 0x3a9f
movq 0xd8(%rbp), %r13
movq 0xe0(%rbp), %rcx
movq %rbx, 0x78(%rbp)
cmpq %rcx, %r13
jle 0x3b19
xorl %ebx, %ebx
jmp 0x3b89
movq 0xe8(%rbp), %r14
xorl %ebx, %ebx
movzbl (%r12,%r13), %eax
cmpl $0x1, %eax
je 0x3b55
cmpl $0x2, %eax
jne 0x3b47
movq 0xd8(%rbp), %rdx
movq %r12, %rdi
movq %r13, %rsi
callq 0x408b
testl %eax, %eax
je 0x3b55
movq 0xf0(%rbp), %rax
movb $0x1, (%rax,%r13)
jmp 0x3b76
movq 0xf8(%rbp), %rax
movq %r13, (%rax,%rbx,8)
movq (%r14,%r13,8), %rax
movq 0x18(%rax), %rax
movq 0x108(%rbp), %rcx
movq %rax, (%rcx,%rbx,8)
incq %rbx
leaq 0x1(%r13), %rax
movq 0xe0(%rbp), %rcx
cmpq %rcx, %r13
movq %rax, %r13
jl 0x3b22
movq %rbx, 0x100(%rbp)
movq %r15, %rdi
callq 0x1030
movq 0x8(%rsp), %rax
movq (%rax), %rax
andl $0x60, %eax
xorl %r14d, %r14d
cmpl $0x40, %eax
je 0x3bb5
leaq 0x20(%rsp), %rdi
callq 0x4012
movl %r14d, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq