// File: /workspace/github_c_makefile_star2_O1/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, %r12
movq %rsi, %r13
movq %rdi, %r15
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 0x43c3
movq %rax, %rbp
movq %r13, 0x18(%rsp)
movq %r13, %rdi
movq %rbx, %rsi
callq 0x43c3
movq %rax, %r13
incq %r13
movq (%r12), %rax
movl %eax, %ecx
andl $0x60, %ecx
cmpl $0x40, %ecx
movq %r14, (%rsp)
jne 0x397e
incq %rbp
leaq 0x20(%rsp), %r8
movl $0x1, %edi
movq %r15, %rsi
movq %rbp, %rdx
movq %r12, %rcx
movq %r14, %r9
callq 0x3d15
testl %eax, %eax
js 0x3cf0
leaq 0x88(%r14), %r15
leaq 0x20(%rsp), %r8
movl $0x2, %edi
movq 0x18(%rsp), %rsi
movq %r13, %rdx
movq %r12, %rcx
movq %r15, %r9
callq 0x3d15
testl %eax, %eax
js 0x3a50
movq %r12, 0x8(%rsp)
movq (%r12), %rax
andl $0x60, %eax
cmpq $0x20, %rax
je 0x3cc1
cmpl $0x40, %eax
je 0x3cc1
movq (%rsp), %r11
movq 0x38(%r11), %r13
movq 0x60(%r11), %rdx
movq 0xe8(%r11), %rsi
movq 0xc0(%r11), %rax
cmpq %rax, %r13
movq %rax, %rcx
cmovlq %r13, %rcx
xorl %edi, %edi
testq %rcx, %rcx
jle 0x3930
movq (%rdx,%rdi,8), %r8
movq 0x18(%r8), %r8
movq (%rsi,%rdi,8), %r9
cmpq 0x18(%r9), %r8
jne 0x3930
incq %rdi
cmpq %rdi, %rcx
jne 0x3913
movq %rcx, %rdi
movq %rdi, 0xd8(%r11)
movq %rdi, 0x50(%r11)
subq %rdi, %rcx
jle 0x3a6f
leaq (%rsi,%rax,8), %rsi
leaq (%rdx,%r13,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 0x3976
incq %rdx
addq $-0x8, %r8
cmpq %rdx, %rcx
jne 0x3955
movq %rcx, %rdx
notq %rdx
jmp 0x3a76
movq %r15, 0x10(%rsp)
leaq 0x2(,%r13), %rbx
addq %rbp, %rbx
leaq 0x38(%rsp), %r14
movq %rax, 0x50(%r14)
movl %ebx, %edi
callq 0x4939
movl %eax, -0x18(%r14)
movl $0x1, %edx
movl %eax, %ecx
shll %cl, %edx
movslq %edx, %rax
movq %rax, -0x10(%r14)
leaq 0x5(,%r13), %rdx
addq %rbp, %rdx
testq %rbx, %rbx
cmovnsq %rbx, %rdx
sarq $0x2, %rdx
incq %rdx
movl $0x38, %esi
movq %r14, %rdi
callq 0x431e
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
testl %eax, %eax
js 0x3d00
movq %r12, 0x8(%rsp)
movq 0x28(%rsp), %r15
shlq $0x3, %r15
movq %r15, %rdi
callq 0x10e0
movq %rax, 0x30(%rsp)
testq %rax, %rax
je 0x3a60
movq %rax, %r12
movq %rax, %rdi
xorl %esi, %esi
movq %r15, %rdx
callq 0x1090
movq %rbx, 0x78(%rsp)
shlq $0x3, %rbx
movq %rbx, %rdi
callq 0x10e0
movq %rax, 0x70(%rsp)
testq %rax, %rax
je 0x3a58
movq $0x0, 0x80(%rsp)
movq (%rsp), %r14
movq 0x8(%rsp), %r12
movq 0x10(%rsp), %r15
jmp 0x3877
movq %r14, %rdi
jmp 0x3ceb
movq %r12, %rdi
callq 0x1030
leaq 0x38(%rsp), %rdi
callq 0x433f
jmp 0x3d00
movq $-0x1, %rdx
leaq (%rdx,%r13), %rcx
movq %rcx, 0x58(%r11)
addq %rax, %rdx
movq %rdx, 0xe0(%r11)
leaq (%rax,%r13), %rbx
addq $0x2, %rbx
movq %rbx, %rdi
callq 0x10e0
testq %rax, %rax
je 0x3cdf
movq %rax, %r12
xorl %r14d, %r14d
movq %rax, %rdi
xorl %esi, %esi
movq %rbx, %rdx
callq 0x1090
movq %r13, %rdi
callq 0x429c
movl $0x400, %ebx            # imm = 0x400
cmpq %rbx, %rax
cmovgeq %rbx, %rax
movq (%rsp), %r11
movq 0x50(%r11), %rcx
movq 0x58(%r11), %rdx
cmpq %rdx, %rcx
jg 0x3b23
movq 0x60(%r11), %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 0x3afc
movq 0x30(%r8), %r8
jmp 0x3aff
xorl %r8d, %r8d
cmpq %rax, %r8
setl %r9b
movb $0x2, %r10b
subb %r9b, %r10b
testq %r8, %r8
movzbl %r10b, %r8d
cmovel %r14d, %r8d
movb %r8b, (%r12,%rcx)
incq %rcx
cmpq %rcx, %rdx
jne 0x3ae5
addq %r12, %r13
incq %r13
movq 0xc0(%r11), %rdi
callq 0x429c
movq (%rsp), %r11
cmpq %rbx, %rax
cmovlq %rax, %rbx
movq 0xd8(%r11), %rax
movq 0xe0(%r11), %rcx
cmpq %rcx, %rax
jg 0x3ba3
movq 0xe8(%r11), %rdx
movq 0x70(%rsp), %rsi
incq %rcx
xorl %edi, %edi
movq (%rdx,%rax,8), %r8
movq 0x18(%r8), %r8
movq (%rsi,%r8,8), %r8
testq %r8, %r8
je 0x3b7b
movq 0x28(%r8), %r8
jmp 0x3b7e
xorl %r8d, %r8d
cmpq %rbx, %r8
setl %r9b
movb $0x2, %r10b
subb %r9b, %r10b
testq %r8, %r8
movzbl %r10b, %r8d
cmovel %edi, %r8d
movb %r8b, (%r13,%rax)
incq %rax
cmpq %rax, %rcx
jne 0x3b64
movq 0x50(%r11), %rbx
movq 0x58(%r11), %rcx
cmpq %rcx, %rbx
jle 0x3bb5
xorl %r14d, %r14d
jmp 0x3c1b
movq 0x60(%r11), %rbp
xorl %r14d, %r14d
movzbl (%r12,%rbx), %eax
cmpl $0x1, %eax
je 0x3bec
cmpl $0x2, %eax
jne 0x3be2
movq 0x50(%r11), %rdx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x41dc
movq (%rsp), %r11
testl %eax, %eax
je 0x3bec
movq 0x68(%r11), %rax
movb $0x1, (%rax,%rbx)
jmp 0x3c0b
movq 0x70(%r11), %rax
movq %rbx, (%rax,%r14,8)
movq (%rbp,%rbx,8), %rax
movq 0x18(%rax), %rax
movq 0x80(%r11), %rcx
movq %rax, (%rcx,%r14,8)
incq %r14
leaq 0x1(%rbx), %rax
movq 0x58(%r11), %rcx
cmpq %rcx, %rbx
movq %rax, %rbx
jl 0x3bbc
movq %r14, 0x78(%r11)
movq 0xd8(%r11), %rbx
movq 0xe0(%r11), %rcx
cmpq %rcx, %rbx
jle 0x3c37
xorl %r14d, %r14d
jmp 0x3cad
movq 0xe8(%r11), %rbp
xorl %r14d, %r14d
movzbl (%r13,%rbx), %eax
cmpl $0x1, %eax
je 0x3c78
cmpl $0x2, %eax
jne 0x3c6b
movq 0xd8(%r11), %rdx
movq %r13, %rdi
movq %rbx, %rsi
callq 0x41dc
movq (%rsp), %r11
testl %eax, %eax
je 0x3c78
movq 0xf0(%r11), %rax
movb $0x1, (%rax,%rbx)
jmp 0x3c9a
movq 0xf8(%r11), %rax
movq %rbx, (%rax,%r14,8)
movq (%rbp,%rbx,8), %rax
movq 0x18(%rax), %rax
movq 0x108(%r11), %rcx
movq %rax, (%rcx,%r14,8)
incq %r14
leaq 0x1(%rbx), %rax
movq 0xe0(%r11), %rcx
cmpq %rcx, %rbx
movq %rax, %rbx
jl 0x3c41
movq %r14, 0x100(%r11)
movq %r12, %rdi
callq 0x1030
testq %r12, %r12
je 0x3cdf
movq 0x8(%rsp), %rax
movl (%rax), %eax
andl $0x60, %eax
xorl %r14d, %r14d
cmpl $0x40, %eax
je 0x3d00
leaq 0x20(%rsp), %rdi
callq 0x4163
jmp 0x3d00
movq %r15, %rdi
callq 0x4186
movq (%rsp), %rdi
callq 0x4186
leaq 0x20(%rsp), %rdi
callq 0x4163
movl $0xffffffff, %r14d      # imm = 0xFFFFFFFF
movl %r14d, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq