// File: /workspace/github_c_makefile_star2_O2/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, %rbx
movq %rdx, %r15
movq %rsi, %r13
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
pushq $0x14
popq %rax
movl $0x100, %r14d           # imm = 0x100
cmoveq %rax, %r14
movq %r14, %rsi
callq 0x3c19
movq %rax, %rbp
movq %r13, 0x18(%rsp)
movq %r13, %rdi
movq %r14, %rsi
callq 0x3c19
movq %rax, %r13
incq %r13
movq (%r15), %rax
movl %eax, %ecx
andl $0x60, %ecx
pushq $-0x1
popq %r14
cmpl $0x40, %ecx
jne 0x32f3
incq %rbp
pushq $0x1
popq %rdi
leaq 0x20(%rsp), %r8
movq %r12, %rsi
movq %rbp, %rdx
movq %r15, %rcx
movq %rbx, %r9
callq 0x3640
testl %eax, %eax
js 0x3621
leaq 0x88(%rbx), %r12
pushq $0x2
popq %rdi
leaq 0x20(%rsp), %r8
movq 0x18(%rsp), %rsi
movq %r13, %rdx
movq %r15, %rcx
movq %r12, %r9
callq 0x3640
testl %eax, %eax
js 0x3619
movq (%r15), %rax
andl $0x60, %eax
cmpq $0x20, %rax
je 0x3607
cmpl $0x40, %eax
je 0x3607
movq 0x38(%rbx), %r13
movq 0x60(%rbx), %rdx
movq 0xe8(%rbx), %rsi
movq 0xc0(%rbx), %rax
cmpq %rax, %r13
movq %rax, %rcx
cmovlq %r13, %rcx
xorl %r8d, %r8d
testq %rcx, %rcx
movl $0x0, %edi
cmovgq %rcx, %rdi
cmpq %r8, %rdi
je 0x33bf
movq (%rdx,%r8,8), %r9
movq 0x18(%r9), %r9
movq (%rsi,%r8,8), %r10
cmpq 0x18(%r10), %r9
jne 0x33bc
incq %r8
jmp 0x32cf
movq %r12, 0x10(%rsp)
leaq 0x2(,%r13), %r14
addq %rbp, %r14
leaq 0x38(%rsp), %r12
movq %rax, 0x50(%r12)
movl %r14d, %edi
callq 0x40c7
movl %eax, -0x18(%r12)
pushq $0x1
popq %rdx
movl %eax, %ecx
shll %cl, %edx
movslq %edx, %rax
movq %rax, -0x10(%r12)
pushq $0x4
popq %rcx
movq %r14, %rax
cqto
idivq %rcx
leaq 0x1(%rax), %rdx
pushq $0x38
popq %rsi
movq %r12, %rdi
callq 0x3b7a
testl %eax, %eax
js 0x33b3
movq %r15, 0x8(%rsp)
movq 0x28(%rsp), %rsi
shlq $0x3, %rsi
pushq $0x1
popq %rdi
callq 0x10b0
movq %rax, 0x30(%rsp)
testq %rax, %rax
je 0x33a9
movq %rax, %r15
movq %r14, 0x78(%rsp)
shlq $0x3, %r14
movq %r14, %rdi
callq 0x10f0
movq %rax, 0x70(%rsp)
testq %rax, %rax
je 0x33a1
andq $0x0, 0x80(%rsp)
movq 0x8(%rsp), %r15
pushq $-0x1
popq %r14
movq 0x10(%rsp), %r12
jmp 0x3239
movq %r15, %rdi
callq 0x1030
leaq 0x38(%rsp), %rdi
callq 0x3b98
pushq $-0x1
popq %r14
jmp 0x362b
movq %r8, %rdi
movq %rdi, 0xd8(%rbx)
movq %rdi, 0x50(%rbx)
leaq (%rdx,%r13,8), %rdx
leaq (%rsi,%rax,8), %rsi
subq %rdi, %rcx
xorl %edi, %edi
testq %rcx, %rcx
cmovleq %rdi, %rcx
pushq $-0x8
popq %r8
movq %r15, 0x8(%rsp)
cmpq %rdi, %rcx
je 0x340a
movq (%rdx,%r8), %r9
movq 0x18(%r9), %r9
movq (%rsi,%r8), %r10
cmpq 0x18(%r10), %r9
jne 0x3407
incq %rdi
addq $-0x8, %r8
jmp 0x33e7
movq %rdi, %rcx
notq %rcx
leaq (%rcx,%r13), %rdx
movq %rdx, 0x58(%rbx)
addq %rax, %rcx
movq %rcx, 0xe0(%rbx)
leaq (%rax,%r13), %rsi
addq $0x2, %rsi
pushq $0x1
popq %rdi
callq 0x10b0
testq %rax, %rax
je 0x3611
movq %rax, %r15
movq %r13, %rdi
callq 0x3b08
movl $0x400, %ecx            # imm = 0x400
cmpq %rcx, %rax
cmovlq %rax, %rcx
movq 0x50(%rbx), %rax
movq 0x58(%rbx), %rdx
movq 0x60(%rbx), %rsi
movq 0x70(%rsp), %rdi
cmpq %rdx, %rax
jg 0x349a
movq (%rsi,%rax,8), %r8
movq 0x18(%r8), %r8
movq (%rdi,%r8,8), %r8
testq %r8, %r8
je 0x348e
movq 0x30(%r8), %r8
cmpq %rcx, %r8
setl %r9b
testq %r8, %r8
je 0x348e
movb $0x2, %r8b
subb %r9b, %r8b
jmp 0x3491
xorl %r8d, %r8d
movb %r8b, (%r15,%rax)
incq %rax
jmp 0x3460
leaq (%r15,%r13), %r12
incq %r12
movq 0xc0(%rbx), %rdi
callq 0x3b08
movl $0x400, %ecx            # imm = 0x400
cmpq %rcx, %rax
cmovlq %rax, %rcx
movq 0xd8(%rbx), %rax
movq 0xe0(%rbx), %rdx
movq 0xe8(%rbx), %rsi
movq 0x70(%rsp), %rdi
cmpq %rdx, %rax
jg 0x350d
movq (%rsi,%rax,8), %r8
movq 0x18(%r8), %r8
movq (%rdi,%r8,8), %r8
testq %r8, %r8
je 0x3501
movq 0x28(%r8), %r8
cmpq %rcx, %r8
setl %r9b
testq %r8, %r8
je 0x3501
movb $0x2, %r8b
subb %r9b, %r8b
jmp 0x3504
xorl %r8d, %r8d
movb %r8b, (%r12,%rax)
incq %rax
jmp 0x34d3
movq 0x50(%rbx), %r14
movq 0x60(%rbx), %rbp
xorl %r13d, %r13d
movq 0x58(%rbx), %rcx
cmpq %rcx, %r14
jg 0x3572
movzbl (%r15,%r14), %eax
cmpl $0x1, %eax
je 0x354e
cmpl $0x2, %eax
jne 0x3543
movq 0x50(%rbx), %rdx
movq %r15, %rdi
movq %r14, %rsi
callq 0x3a68
testl %eax, %eax
je 0x354e
movq 0x68(%rbx), %rax
movb $0x1, (%rax,%r14)
jmp 0x356d
movq 0x70(%rbx), %rax
movq %r14, (%rax,%r13,8)
movq (%rbp,%r14,8), %rax
movq 0x18(%rax), %rax
movq 0x80(%rbx), %rcx
movq %rax, (%rcx,%r13,8)
incq %r13
incq %r14
jmp 0x3518
movq %r13, 0x78(%rbx)
movq 0xd8(%rbx), %r14
movq 0xe8(%rbx), %rbp
xorl %r13d, %r13d
movq 0xe0(%rbx), %rcx
cmpq %rcx, %r14
jg 0x35ed
movzbl (%r12,%r14), %eax
cmpl $0x1, %eax
je 0x35c6
cmpl $0x2, %eax
jne 0x35b8
movq 0xd8(%rbx), %rdx
movq %r12, %rdi
movq %r14, %rsi
callq 0x3a68
testl %eax, %eax
je 0x35c6
movq 0xf0(%rbx), %rax
movb $0x1, (%rax,%r14)
jmp 0x35e8
movq 0xf8(%rbx), %rax
movq %r14, (%rax,%r13,8)
movq (%rbp,%r14,8), %rax
movq 0x18(%rax), %rax
movq 0x108(%rbx), %rcx
movq %rax, (%rcx,%r13,8)
incq %r13
incq %r14
jmp 0x3587
movq %r13, 0x100(%rbx)
movq %r15, %rdi
callq 0x1030
movq 0x8(%rsp), %rax
movq (%rax), %rax
andl $0x60, %eax
xorl %r14d, %r14d
cmpl $0x40, %eax
jne 0x3621
jmp 0x362b
movq %r12, %rdi
callq 0x3a12
movq %rbx, %rdi
callq 0x3a12
leaq 0x20(%rsp), %rdi
callq 0x39ef
movl %r14d, %eax
addq $0x98, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq