// File: /workspace/github_c_makefile_star2_O2/findstr[P]version-database/dc3.c
// Function: dc3_r
void
dc3_r(const int *buf, int *SA, int size, int space)
{
	int i, lexname, v[3];
	int n0, n1, n2, n12;
	int *p, *SA0, *s0, *SA12, *s12;
	n0 = (2+size) / 3;
	n1 = (2+size - 1) / 3;
	n2 = (2+size - 2) / 3;
	n12 = n0 + n2;
	//sort S1 S2
	s0 = NEW(int, n0);
	SA0 = NEW(int, n0);
	s12 = NEW(int, n12 + 3);
	SA12 = NEW(int, n12 + 3);
	s12[n12] = s12[n12+1] = s12[n12+2] = TERM;
	SA12[n12] = SA12[n12+1] = SA12[n12+2] = TERM;
	p = s12;
	for (i = 0; i < size + (n0 - n1); i++) {
		if (i % 3 != 0)
			*p++ = i;
	}
	assert(p - s12 == n12);
	radix_pass(s12, SA12, n12, buf+2, space); //tri[i+2]
	radix_pass(SA12, s12, n12, buf+1, space); //tri[i+1]
	radix_pass(s12, SA12, n12, buf+0, space); //tri[i+0]
	//build lexname for s12
	lexname = 0;
	s12[n12] = s12[n12 + 1] = s12[n12+2] = TERM;
	v[0] = v[1] = v[2] = -1;
	for (i = 0; i < n12; i++) {
		int idx12;
		int abs= SA12[i];
		if (V(abs) != v[0] || V(abs+1) != v[1] || V(abs+2) != v[2]) {
			++lexname;
			v[0] = V(abs);
			v[1] = V(abs+1);
			v[2] = V(abs+2);
		}
		assert(lexname > 0);
		assert(abs % 3 != 0);
		idx12 = ABS_TO_S12(abs);
		s12[idx12] = lexname;
	}
	assert(s12[n12] == s12[n12 + 1]);
	assert(s12[n12+1] == s12[n12+2] && s12[n12 + 2] == TERM);
	//now s12[idx] = rank which idx % 3 != 0
	if (lexname < n12) { //lexname conflict
		dc3_r(s12, SA12, n12, lexname);
		for (i = 0; i < n12; i++)
			s12[SA12[i]] = i + 1;
	} else {
		for (i = 0; i < n12; i++)
			SA12[s12[i] - 1] = i;
	}
	//sort S0
	p = s0;
	//radix pass 4
	for (i = 0; i < n12; i++) {
		int n = SA12[i];
		if (S12_IS_LEFT(n))
			*p++ = S12_TO_LABS(n) - 1;
	}
	assert(p - s0 == n0);
	radix_pass(s0, SA0, n0, buf, space);
	int k, r0 = 0, r12 = n0 - n1;
	for (k = 0; k < size; k++) {
		int i, j, i12, j12;
		i = SA12[r12];
		j = SA0[r0];
		assert(r12 < n12);
		assert(r0 < n0);
		int leq = 0;
		if (S12_IS_LEFT(i)) {	//k mod 3 == 1, i+n1 ==> k mod 3 == 2
			i = S12_TO_LABS(i);
			i12 = ABS_TO_S12(i+1);
			j12 = ABS_TO_S12(j+1);
			leq = leq2(buf[i], s12[i12], buf[j], s12[j12]);
		} else {	//k mod 3 == 2, k mode 3 + 2 => (k mod 3 == 1)+1
			i = S12_TO_RABS(i);
			i12 = ABS_TO_S12(i+2);
			j12 = ABS_TO_S12(j+2);
			leq = leq3(buf[i], buf[i+1], s12[i12], buf[j], buf[j+1], s12[j12]);
		}
		if (leq) {
			SA[k] = i;
			r12++;
			if (r12 == n12)
				break;
		} else {
			SA[k] = j;
			++r0;
			if (r0 == n0)
				break;
		}
	}
	while (r0 < n0)
		SA[++k] = SA0[r0++];
	while (r12 < n12) {
		int ii = SA12[r12++];
		SA[++k] = S12_TO_ABS(ii);
	}
	//free buffer
	free(s0);
	free(s12);
	free(SA0);
	free(SA12);
	return ;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %ecx, -0x44(%rbp)
movq %rsi, -0x78(%rbp)
movq %rdi, %r14
movq %rdx, %rsi
movq %rdx, -0x60(%rbp)
leal 0x2(%rdx), %eax
pushq $0x3
popq %rcx
cltd
idivl %ecx
movl %ecx, %edi
movl %eax, %r13d
leal 0x1(%rsi), %eax
pushq $-0x3
popq %rcx
cltd
idivl %ecx
movq %rax, -0x40(%rbp)
movl %esi, %eax
cltd
idivl %edi
movl %eax, %ebx
addl %r13d, %ebx
movslq %r13d, %rax
movq %rax, -0x50(%rbp)
leaq (,%rax,4), %r15
movq %r15, %rdi
callq 0x21f0
movq %rax, -0x68(%rbp)
movq %r15, %rdi
callq 0x21f0
movq %rax, -0x58(%rbp)
movl %ebx, -0x2c(%rbp)
movslq %ebx, %rbx
leaq 0xc(,%rbx,4), %r15
movq %r15, %rdi
callq 0x21f0
movq %rax, %r12
movq %r15, %rdi
callq 0x21f0
pushq $0x3
popq %r9
movq %r12, %rdi
andl $0x0, 0x8(%r12,%rbx,4)
andl $0x0, 0x4(%r12,%rbx,4)
andl $0x0, (%r12,%rbx,4)
movq %rax, %r15
andl $0x0, 0x8(%rax,%rbx,4)
andl $0x0, 0x4(%rax,%rbx,4)
leaq 0x2(%rbx), %rax
movq %rax, -0x80(%rbp)
andl $0x0, (%r15,%rbx,4)
movq %rbx, -0x70(%rbp)
leaq 0x1(%rbx), %rax
movq %rax, -0x88(%rbp)
movq -0x40(%rbp), %rax
movq -0x50(%rbp), %rcx
leal (%rcx,%rax), %r10d
movq -0x60(%rbp), %rax
leal (%r10,%rax), %r8d
xorl %ecx, %ecx
testl %r8d, %r8d
cmovlel %ecx, %r8d
movq %r12, %rsi
movl %ecx, %eax
xorl %edx, %edx
divl %r9d
cmpl %ecx, %r8d
je 0x5f95
leal (%rax,%rax,2), %eax
cmpl %ecx, %eax
je 0x5f91
movl %ecx, (%rsi)
addq $0x4, %rsi
incl %ecx
jmp 0x5f78
movq %r10, -0x40(%rbp)
subq %rdi, %rsi
sarq $0x2, %rsi
movq -0x70(%rbp), %rbx
cmpq %rbx, %rsi
jne 0x63f4
leaq 0x8(%r14), %rcx
movq %r15, %rsi
movl %ebx, %edx
movl -0x44(%rbp), %r12d
movl %r12d, %r8d
movq %rdi, -0x38(%rbp)
callq 0x6458
leaq 0x4(%r14), %rcx
movq %r15, %rdi
movq -0x38(%rbp), %rsi
movl %ebx, %edx
movl %r12d, %r8d
callq 0x6458
movq -0x38(%rbp), %rdi
movq %r15, %rsi
movl %ebx, %edx
movq %r14, %rcx
movl %r12d, %r8d
callq 0x6458
movq -0x38(%rbp), %rdi
movq -0x80(%rbp), %rax
andl $0x0, (%rdi,%rax,4)
movq -0x88(%rbp), %rax
andl $0x0, (%rdi,%rax,4)
andl $0x0, (%rdi,%rbx,4)
xorl %r11d, %r11d
testl %ebx, %ebx
movl $0x0, %r12d
cmovgl -0x2c(%rbp), %r12d
pushq $-0x1
popq %rax
movl %eax, %r9d
movl %eax, %r8d
xorl %ecx, %ecx
pushq $0x3
popq %rbx
cmpq %r11, %r12
je 0x608d
movslq (%r15,%r11,4), %rsi
movl (%r14,%rsi,4), %r10d
movl 0x4(%r14,%rsi,4), %edx
cmpl %eax, %r10d
jne 0x605a
cmpl %r9d, %edx
jne 0x605a
cmpl %r8d, 0x8(%r14,%rsi,4)
jne 0x6057
movl %eax, %r10d
testl %ecx, %ecx
jne 0x6064
jmp 0x63d7
movl %r9d, %edx
incl %ecx
movl 0x8(%r14,%rsi,4), %r8d
movl %edx, %r9d
movl %esi, %eax
cltd
idivl %ebx
cmpl $0x1, %edx
je 0x607b
testl %edx, %edx
je 0x63be
addl %r13d, %eax
jmp 0x6080
movl %esi, %eax
cltd
idivl %ebx
cltq
movl %ecx, (%rdi,%rax,4)
incq %r11
movl %r10d, %eax
jmp 0x6028
movq -0x70(%rbp), %rax
movl (%rdi,%rax,4), %eax
movq -0x88(%rbp), %rdx
cmpl (%rdi,%rdx,4), %eax
jne 0x640d
movq -0x80(%rbp), %rdx
orl (%rdi,%rdx,4), %eax
jne 0x6426
movl -0x2c(%rbp), %edx
cmpl %edx, %ecx
jge 0x60df
movq %r15, %rsi
callq 0x5e88
movq -0x38(%rbp), %rdx
xorl %eax, %eax
movq -0x50(%rbp), %rsi
movq -0x68(%rbp), %r8
cmpq %rax, %r12
je 0x60fc
movslq (%r15,%rax,4), %rcx
incq %rax
movl %eax, (%rdx,%rcx,4)
jmp 0x60ce
xorl %eax, %eax
movq -0x50(%rbp), %rsi
movq -0x68(%rbp), %r8
cmpq %rax, %r12
je 0x60fc
movslq (%rdi,%rax,4), %rcx
movl %eax, -0x4(%r15,%rcx,4)
incq %rax
jmp 0x60e9
xorl %ecx, %ecx
movq %r8, %rax
cmpq %rcx, %r12
je 0x611d
movl (%r15,%rcx,4), %edx
cmpl %r13d, %edx
jge 0x6118
leal (%rdx,%rdx,2), %edx
movl %edx, (%rax)
addq $0x4, %rax
incq %rcx
jmp 0x6101
subq %r8, %rax
sarq $0x2, %rax
cmpq %rsi, %rax
jne 0x643f
movq %r8, %rdi
movq -0x58(%rbp), %rbx
movq %rbx, %rsi
movl %r13d, %edx
movq %r14, %rcx
movl -0x44(%rbp), %r8d
callq 0x6458
xorl %eax, %eax
movq -0x60(%rbp), %rdi
testl %edi, %edi
cmovlel %eax, %edi
xorl %r8d, %r8d
xorl %esi, %esi
movl -0x2c(%rbp), %eax
movq -0x40(%rbp), %r10
movq %rdi, -0x60(%rbp)
movq %r15, -0x90(%rbp)
cmpq %r8, %rdi
je 0x62f2
cmpl %eax, %r10d
jge 0x6380
cmpl %r13d, %esi
jge 0x639f
movq %r10, -0x40(%rbp)
movslq %r10d, %rax
movslq (%r15,%rax,4), %r11
movslq %esi, %rax
movl (%rbx,%rax,4), %r9d
movslq %r9d, %r10
cmpl %r13d, %r11d
jge 0x6219
leaq (%r11,%r11,2), %r12
leal 0x2(%r12), %eax
cltd
pushq $0x3
popq %r15
idivl %r15d
movl %eax, %ecx
cmpl $0x1, %edx
movl %r13d, %ebx
movl $0x0, %edi
cmovel %edi, %ebx
leal 0x1(%r10), %eax
cltd
idivl %r15d
addl %ecx, %ebx
cmpl $0x1, %edx
movl %r13d, %ecx
cmovel %edi, %ecx
addl %eax, %ecx
movl 0x4(%r14,%r12,4), %r12d
movslq %ebx, %rax
movq -0x38(%rbp), %rbx
movl (%rbx,%rax,4), %edx
movslq %ecx, %rcx
movl (%r14,%r10,4), %r10d
cmpl %r10d, %r12d
sete %al
cmpl (%rbx,%rcx,4), %edx
setle %dl
leaq (%r11,%r11,2), %rcx
incq %rcx
cmpl %r10d, %r12d
jl 0x62b2
andb %dl, %al
movq -0x90(%rbp), %r15
je 0x629a
jmp 0x62b9
subl %r13d, %r11d
leal (%r11,%r11,2), %eax
addl $0x4, %eax
cltd
pushq $0x3
popq %rbx
idivl %ebx
movl %eax, %ecx
cmpl $0x1, %edx
movl %r13d, %r12d
movl $0x0, %edi
cmovel %edi, %r12d
movl %r10d, %eax
addl $0x2, %eax
cltd
idivl %ebx
addl %ecx, %r12d
leal (%r11,%r11,2), %ebx
leal (%r11,%r11,2), %ecx
addl $0x2, %ecx
cmpl $0x1, %edx
movl %r13d, %edx
cmovel %edi, %edx
addl %eax, %edx
movslq %ebx, %rax
movl (%r14,%r10,4), %r11d
cmpl %r11d, 0x8(%r14,%rax,4)
jl 0x62b9
jne 0x629a
movl 0xc(%r14,%rax,4), %r11d
movslq %r12d, %rbx
movl 0x4(%r14,%r10,4), %r10d
movslq %edx, %rax
movq -0x38(%rbp), %r12
movl (%r12,%rax,4), %edx
cmpl %r10d, %r11d
sete %al
cmpl %edx, (%r12,%rbx,4)
setle %dl
cmpl %r10d, %r11d
jl 0x62b9
andb %dl, %al
jne 0x62b9
movq -0x78(%rbp), %rax
movl %r9d, (%rax,%r8,4)
incl %esi
cmpl %r13d, %esi
movl -0x2c(%rbp), %eax
movq -0x40(%rbp), %r10
jne 0x62d0
jmp 0x62e8
movq -0x90(%rbp), %r15
movq -0x78(%rbp), %rax
movl %ecx, (%rax,%r8,4)
movq -0x40(%rbp), %r10
incl %r10d
movl -0x2c(%rbp), %eax
cmpl %eax, %r10d
je 0x62e0
incq %r8
movq -0x58(%rbp), %rbx
movq -0x60(%rbp), %rdi
jmp 0x6168
movq %r8, %rdi
movl %eax, %r10d
jmp 0x62ee
movq %r8, %rdi
movl %r13d, %esi
movq -0x58(%rbp), %rbx
movslq %esi, %rcx
movq -0x78(%rbp), %rax
leaq (%rax,%rdi,4), %rax
addq $0x4, %rax
movq -0x70(%rbp), %r9
movq -0x50(%rbp), %rsi
cmpq %rsi, %rcx
jge 0x631c
movl (%rbx,%rcx,4), %edx
incq %rcx
movl %edx, (%rax)
addq $0x4, %rax
jmp 0x6309
movslq %r10d, %rcx
xorl %edx, %edx
cmpq %r9, %rcx
jge 0x6350
movl (%r15,%rcx,4), %esi
incq %rcx
xorl %edi, %edi
cmpl %r13d, %esi
setl %dil
movl %r13d, %r8d
cmovll %edx, %r8d
subl %r8d, %esi
leal (%rsi,%rsi,2), %esi
subl %edi, %esi
addl $0x2, %esi
movl %esi, (%rax)
addq $0x4, %rax
jmp 0x6321
movq -0x68(%rbp), %rdi
callq 0x2030
movq -0x38(%rbp), %rdi
callq 0x2030
movq %rbx, %rdi
callq 0x2030
movq %r15, %rdi
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2030
leaq 0x266a(%rip), %rdi      # 0x89f1
leaq 0x25c4(%rip), %rsi      # 0x8952
leaq 0x25c3(%rip), %rcx      # 0x8958
movl $0x85, %edx
callq 0x2130
leaq 0x2655(%rip), %rdi      # 0x89fb
leaq 0x25a5(%rip), %rsi      # 0x8952
leaq 0x25a4(%rip), %rcx      # 0x8958
movl $0x86, %edx
callq 0x2130
leaq 0x25c8(%rip), %rdi      # 0x898d
leaq 0x2586(%rip), %rsi      # 0x8952
leaq 0x2585(%rip), %rcx      # 0x8958
pushq $0x67
jmp 0x63ee
leaq 0x25a3(%rip), %rdi      # 0x8981
leaq 0x256d(%rip), %rsi      # 0x8952
leaq 0x256c(%rip), %rcx      # 0x8958
pushq $0x66
popq %rdx
callq 0x2130
leaq 0x2548(%rip), %rdi      # 0x8943
leaq 0x2550(%rip), %rsi      # 0x8952
leaq 0x254f(%rip), %rcx      # 0x8958
pushq $0x55
jmp 0x63ee
leaq 0x2586(%rip), %rdi      # 0x899a
leaq 0x2537(%rip), %rsi      # 0x8952
leaq 0x2536(%rip), %rcx      # 0x8958
pushq $0x6b
jmp 0x63ee
leaq 0x2586(%rip), %rdi      # 0x89b3
leaq 0x251e(%rip), %rsi      # 0x8952
leaq 0x251d(%rip), %rcx      # 0x8958
pushq $0x6c
jmp 0x63ee
leaq 0x259e(%rip), %rdi      # 0x89e4
leaq 0x2505(%rip), %rsi      # 0x8952
leaq 0x2504(%rip), %rcx      # 0x8958
pushq $0x7e
jmp 0x63ee