// File: /workspace/github_c_makefile_star2_O0/LemonBoy[P]autobahn/xdiff/xprepare.c
// Function: xdl_cleanup_records
static int xdl_cleanup_records(xdlclassifier_t *cf, xdfile_t *xdf1, xdfile_t *xdf2) {
	long i, nm, nreff, mlim;
	xrecord_t **recs;
	xdlclass_t *rcrec;
	char *dis, *dis1, *dis2;

	if (!(dis = (char *) xdl_malloc(xdf1->nrec + xdf2->nrec + 2))) {

		return -1;
	}
	memset(dis, 0, xdf1->nrec + xdf2->nrec + 2);
	dis1 = dis;
	dis2 = dis1 + xdf1->nrec + 1;

	if ((mlim = xdl_bogosqrt(xdf1->nrec)) > XDL_MAX_EQLIMIT)
		mlim = XDL_MAX_EQLIMIT;
	for (i = xdf1->dstart, recs = &xdf1->recs[xdf1->dstart]; i <= xdf1->dend; i++, recs++) {
		rcrec = cf->rcrecs[(*recs)->ha];
		nm = rcrec ? rcrec->len2 : 0;
		dis1[i] = (nm == 0) ? 0: (nm >= mlim) ? 2: 1;
	}

	if ((mlim = xdl_bogosqrt(xdf2->nrec)) > XDL_MAX_EQLIMIT)
		mlim = XDL_MAX_EQLIMIT;
	for (i = xdf2->dstart, recs = &xdf2->recs[xdf2->dstart]; i <= xdf2->dend; i++, recs++) {
		rcrec = cf->rcrecs[(*recs)->ha];
		nm = rcrec ? rcrec->len1 : 0;
		dis2[i] = (nm == 0) ? 0: (nm >= mlim) ? 2: 1;
	}

	for (nreff = 0, i = xdf1->dstart, recs = &xdf1->recs[xdf1->dstart];
	     i <= xdf1->dend; i++, recs++) {
		if (dis1[i] == 1 ||
		    (dis1[i] == 2 && !xdl_clean_mmatch(dis1, i, xdf1->dstart, xdf1->dend))) {
			xdf1->rindex[nreff] = i;
			xdf1->ha[nreff] = (*recs)->ha;
			nreff++;
		} else
			xdf1->rchg[i] = 1;
	}
	xdf1->nreff = nreff;

	for (nreff = 0, i = xdf2->dstart, recs = &xdf2->recs[xdf2->dstart];
	     i <= xdf2->dend; i++, recs++) {
		if (dis2[i] == 1 ||
		    (dis2[i] == 2 && !xdl_clean_mmatch(dis2, i, xdf2->dstart, xdf2->dend))) {
			xdf2->rindex[nreff] = i;
			xdf2->ha[nreff] = (*recs)->ha;
			nreff++;
		} else
			xdf2->rchg[i] = 1;
	}
	xdf2->nreff = nreff;

	xdl_free(dis);

	return 0;
}

// Assembly:
subq $0x88, %rsp
movq %rdi, 0x78(%rsp)
movq %rsi, 0x70(%rsp)
movq %rdx, 0x68(%rsp)
movq 0x70(%rsp), %rax
movq 0x38(%rax), %rdi
movq 0x68(%rsp), %rax
addq 0x38(%rax), %rdi
addq $0x2, %rdi
callq 0x10f0
movq %rax, 0x30(%rsp)
cmpq $0x0, %rax
jne 0x65ac
movl $0xffffffff, 0x84(%rsp) # imm = 0xFFFFFFFF
jmp 0x6a62
movq 0x30(%rsp), %rdi
movq 0x70(%rsp), %rax
movq 0x38(%rax), %rdx
movq 0x68(%rsp), %rax
addq 0x38(%rax), %rdx
addq $0x2, %rdx
xorl %esi, %esi
callq 0x1090
movq 0x30(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0x28(%rsp), %rax
movq 0x70(%rsp), %rcx
addq 0x38(%rcx), %rax
addq $0x1, %rax
movq %rax, 0x20(%rsp)
movq 0x70(%rsp), %rax
movq 0x38(%rax), %rdi
callq 0x6c60
movq %rax, 0x48(%rsp)
cmpq $0x400, %rax            # imm = 0x400
jle 0x6613
movq $0x400, 0x48(%rsp)      # imm = 0x400
movq 0x70(%rsp), %rax
movq 0x50(%rax), %rax
movq %rax, 0x60(%rsp)
movq 0x70(%rsp), %rax
movq 0x60(%rax), %rax
movq 0x70(%rsp), %rcx
movq 0x50(%rcx), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x40(%rsp)
movq 0x60(%rsp), %rax
movq 0x70(%rsp), %rcx
cmpq 0x58(%rcx), %rax
jg 0x66fe
movq 0x78(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x40(%rsp), %rcx
movq (%rcx), %rcx
movq 0x18(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x38(%rsp)
cmpq $0x0, 0x38(%rsp)
je 0x6689
movq 0x38(%rsp), %rax
movq 0x30(%rax), %rax
movq %rax, 0x18(%rsp)
jmp 0x6692
xorl %eax, %eax
movq %rax, 0x18(%rsp)
jmp 0x6692
movq 0x18(%rsp), %rax
movq %rax, 0x58(%rsp)
cmpq $0x0, 0x58(%rsp)
jne 0x66ac
xorl %eax, %eax
movl %eax, 0x14(%rsp)
jmp 0x66ca
movq 0x58(%rsp), %rdx
movq 0x48(%rsp), %rsi
movl $0x1, %eax
movl $0x2, %ecx
cmpq %rsi, %rdx
cmovgel %ecx, %eax
movl %eax, 0x14(%rsp)
movl 0x14(%rsp), %eax
movb %al, %dl
movq 0x28(%rsp), %rax
movq 0x60(%rsp), %rcx
movb %dl, (%rax,%rcx)
movq 0x60(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x60(%rsp)
movq 0x40(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x40(%rsp)
jmp 0x663f
movq 0x68(%rsp), %rax
movq 0x38(%rax), %rdi
callq 0x6c60
movq %rax, 0x48(%rsp)
cmpq $0x400, %rax            # imm = 0x400
jle 0x6722
movq $0x400, 0x48(%rsp)      # imm = 0x400
movq 0x68(%rsp), %rax
movq 0x50(%rax), %rax
movq %rax, 0x60(%rsp)
movq 0x68(%rsp), %rax
movq 0x60(%rax), %rax
movq 0x68(%rsp), %rcx
movq 0x50(%rcx), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x40(%rsp)
movq 0x60(%rsp), %rax
movq 0x68(%rsp), %rcx
cmpq 0x58(%rcx), %rax
jg 0x680d
movq 0x78(%rsp), %rax
movq 0x50(%rax), %rax
movq 0x40(%rsp), %rcx
movq (%rcx), %rcx
movq 0x18(%rcx), %rcx
movq (%rax,%rcx,8), %rax
movq %rax, 0x38(%rsp)
cmpq $0x0, 0x38(%rsp)
je 0x6798
movq 0x38(%rsp), %rax
movq 0x28(%rax), %rax
movq %rax, 0x8(%rsp)
jmp 0x67a1
xorl %eax, %eax
movq %rax, 0x8(%rsp)
jmp 0x67a1
movq 0x8(%rsp), %rax
movq %rax, 0x58(%rsp)
cmpq $0x0, 0x58(%rsp)
jne 0x67bb
xorl %eax, %eax
movl %eax, 0x4(%rsp)
jmp 0x67d9
movq 0x58(%rsp), %rdx
movq 0x48(%rsp), %rsi
movl $0x1, %eax
movl $0x2, %ecx
cmpq %rsi, %rdx
cmovgel %ecx, %eax
movl %eax, 0x4(%rsp)
movl 0x4(%rsp), %eax
movb %al, %dl
movq 0x20(%rsp), %rax
movq 0x60(%rsp), %rcx
movb %dl, (%rax,%rcx)
movq 0x60(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x60(%rsp)
movq 0x40(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x40(%rsp)
jmp 0x674e
movq $0x0, 0x50(%rsp)
movq 0x70(%rsp), %rax
movq 0x50(%rax), %rax
movq %rax, 0x60(%rsp)
movq 0x70(%rsp), %rax
movq 0x60(%rax), %rax
movq 0x70(%rsp), %rcx
movq 0x50(%rcx), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x40(%rsp)
movq 0x60(%rsp), %rax
movq 0x70(%rsp), %rcx
cmpq 0x58(%rcx), %rax
jg 0x691f
movq 0x28(%rsp), %rax
movq 0x60(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x1, %eax
je 0x68a2
movq 0x28(%rsp), %rax
movq 0x60(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2, %eax
jne 0x68ea
movq 0x28(%rsp), %rdi
movq 0x60(%rsp), %rsi
movq 0x70(%rsp), %rax
movq 0x50(%rax), %rdx
movq 0x70(%rsp), %rax
movq 0x58(%rax), %rcx
callq 0x6a80
cmpl $0x0, %eax
jne 0x68ea
movq 0x60(%rsp), %rdx
movq 0x70(%rsp), %rax
movq 0x70(%rax), %rax
movq 0x50(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rdx
movq 0x70(%rsp), %rax
movq 0x80(%rax), %rax
movq 0x50(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x50(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x50(%rsp)
jmp 0x68fc
movq 0x70(%rsp), %rax
movq 0x68(%rax), %rax
movq 0x60(%rsp), %rcx
movb $0x1, (%rax,%rcx)
jmp 0x68fe
movq 0x60(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x60(%rsp)
movq 0x40(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x40(%rsp)
jmp 0x6842
movq 0x50(%rsp), %rcx
movq 0x70(%rsp), %rax
movq %rcx, 0x78(%rax)
movq $0x0, 0x50(%rsp)
movq 0x68(%rsp), %rax
movq 0x50(%rax), %rax
movq %rax, 0x60(%rsp)
movq 0x68(%rsp), %rax
movq 0x60(%rax), %rax
movq 0x68(%rsp), %rcx
movq 0x50(%rcx), %rcx
shlq $0x3, %rcx
addq %rcx, %rax
movq %rax, 0x40(%rsp)
movq 0x60(%rsp), %rax
movq 0x68(%rsp), %rcx
cmpq 0x58(%rcx), %rax
jg 0x6a3f
movq 0x20(%rsp), %rax
movq 0x60(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x1, %eax
je 0x69c2
movq 0x20(%rsp), %rax
movq 0x60(%rsp), %rcx
movsbl (%rax,%rcx), %eax
cmpl $0x2, %eax
jne 0x6a0a
movq 0x20(%rsp), %rdi
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rax
movq 0x50(%rax), %rdx
movq 0x68(%rsp), %rax
movq 0x58(%rax), %rcx
callq 0x6a80
cmpl $0x0, %eax
jne 0x6a0a
movq 0x60(%rsp), %rdx
movq 0x68(%rsp), %rax
movq 0x70(%rax), %rax
movq 0x50(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq 0x18(%rax), %rdx
movq 0x68(%rsp), %rax
movq 0x80(%rax), %rax
movq 0x50(%rsp), %rcx
movq %rdx, (%rax,%rcx,8)
movq 0x50(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x50(%rsp)
jmp 0x6a1c
movq 0x68(%rsp), %rax
movq 0x68(%rax), %rax
movq 0x60(%rsp), %rcx
movb $0x1, (%rax,%rcx)
jmp 0x6a1e
movq 0x60(%rsp), %rax
addq $0x1, %rax
movq %rax, 0x60(%rsp)
movq 0x40(%rsp), %rax
addq $0x8, %rax
movq %rax, 0x40(%rsp)
jmp 0x6962
movq 0x50(%rsp), %rcx
movq 0x68(%rsp), %rax
movq %rcx, 0x78(%rax)
movq 0x30(%rsp), %rdi
callq 0x1030
movl $0x0, 0x84(%rsp)
movl 0x84(%rsp), %eax
addq $0x88, %rsp
retq
nopw %cs:(%rax,%rax)