// File: /workspace/github_c_makefile_star2_O1/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 $0x58, %rsp
movl %ecx, -0x38(%rbp)
movq %rsi, -0x58(%rbp)
movq %rdi, %r15
leal 0x2(%rdx), %eax
cltq
imulq $0x55555556, %rax, %rbx # imm = 0x55555556
movq %rbx, %rax
shrq $0x3f, %rax
shrq $0x20, %rbx
addl %eax, %ebx
leal 0x1(%rdx), %eax
movl %edx, %ecx
movq %rdx, -0x48(%rbp)
notl %ecx
cltq
imulq $0x55555555, %rax, %r12 # imm = 0x55555555
shrq $0x20, %r12
addl %ecx, %r12d
movl %r12d, %eax
shrl $0x1f, %eax
sarl %r12d
addl %eax, %r12d
movslq %edx, %rax
imulq $0x55555556, %rax, %rcx # imm = 0x55555556
movq %rcx, %rax
shrq $0x3f, %rax
shrq $0x20, %rcx
addl %eax, %ecx
movq %rcx, -0x80(%rbp)
leal (%rbx,%rcx), %r13d
movslq %ebx, %rax
movq %rax, -0x68(%rbp)
leaq (,%rax,4), %r14
movq %r14, %rdi
callq 0x21f0
movq %rax, -0x70(%rbp)
movq %r14, %rdi
callq 0x21f0
movq %rax, -0x60(%rbp)
movl %r13d, -0x2c(%rbp)
movslq %r13d, %r14
leaq 0xc(,%r14,4), %r13
movq %r13, %rdi
callq 0x21f0
movq %rax, -0x40(%rbp)
movq %r13, %rdi
callq 0x21f0
movq -0x48(%rbp), %rsi
movq -0x40(%rbp), %rdi
movq %rax, %r13
xorl %eax, %eax
movl %eax, 0x8(%rdi,%r14,4)
movl %eax, 0x4(%rdi,%r14,4)
movl %eax, (%rdi,%r14,4)
movl %eax, 0x8(%r13,%r14,4)
movl %eax, 0x4(%r13,%r14,4)
movl %eax, (%r13,%r14,4)
leal (%r12,%rbx), %r8d
movl %r8d, %edx
movq %rdi, %rcx
addl %esi, %edx
jle 0x74b8
addl %ebx, %r12d
addl %esi, %r12d
movl $0xaaaaaaab, %edx       # imm = 0xAAAAAAAB
movq %rdi, %rcx
movl %eax, %esi
imulq %rdx, %rsi
shrq $0x21, %rsi
leal (%rsi,%rsi,2), %esi
cmpl %eax, %esi
je 0x74b1
movl %eax, (%rcx)
addq $0x4, %rcx
incl %eax
cmpl %eax, %r12d
jne 0x749a
movl %r8d, -0x30(%rbp)
subq %rdi, %rcx
sarq $0x2, %rcx
cmpq %r14, %rcx
jne 0x7a04
leaq 0x2(%r14), %rax
movq %rax, -0x78(%rbp)
leaq 0x1(%r14), %rax
movq %rax, -0x50(%rbp)
leaq 0x8(%r15), %rcx
movq %rdi, %r12
movq %r13, %rsi
movl %r14d, %edx
movl -0x38(%rbp), %r8d
callq 0x7a80
leaq 0x4(%r15), %rcx
movq %r13, %rdi
movq %r12, %rsi
movl %r14d, %edx
movl -0x38(%rbp), %r8d
callq 0x7a80
movq %r12, %rdi
movq %r13, %rsi
movl %r14d, %edx
movq %r15, %rcx
movl -0x38(%rbp), %r8d
callq 0x7a80
xorl %ecx, %ecx
movq -0x78(%rbp), %rax
movl %ecx, (%r12,%rax,4)
movq -0x50(%rbp), %rax
movl %ecx, (%r12,%rax,4)
movl %ecx, (%r12,%r14,4)
cmpl $0x0, -0x2c(%rbp)
jle 0x75d7
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
xorl %eax, %eax
xorl %ecx, %ecx
movl $0xffffffff, %esi       # imm = 0xFFFFFFFF
movl $0xffffffff, %r9d       # imm = 0xFFFFFFFF
movslq (%r13,%rax,4), %r8
movl (%r15,%r8,4), %edi
cmpl %r9d, %edi
jne 0x7572
cmpl %esi, 0x4(%r15,%r8,4)
jne 0x7572
cmpl %edx, 0x8(%r15,%r8,4)
jne 0x7572
movl %r9d, %edi
jmp 0x757e
incl %ecx
movl 0x4(%r15,%r8,4), %esi
movl 0x8(%r15,%r8,4), %edx
testl %ecx, %ecx
jle 0x7988
imulq $0x55555556, %r8, %r9   # imm = 0x55555556
movq %r9, %r10
shrq $0x3f, %r10
shrq $0x20, %r9
leal (%r9,%r10), %r11d
leal (%r11,%r11,2), %r12d
subl %r12d, %r8d
cmpl $0x1, %r8d
je 0x75ba
testl %r8d, %r8d
je 0x79e5
addl %ebx, %r11d
movl %r11d, %r9d
jmp 0x75bd
addl %r10d, %r9d
movslq %r9d, %r8
movq -0x40(%rbp), %r9
movl %ecx, (%r9,%r8,4)
incq %rax
movl %edi, %r9d
cmpq %rax, %r14
jne 0x7551
movq -0x40(%rbp), %rdi
movq -0x50(%rbp), %rax
movl (%rdi,%rax,4), %eax
cmpl %eax, (%rdi,%r14,4)
jne 0x7a23
movq -0x78(%rbp), %rdx
orl (%rdi,%rdx,4), %eax
movl -0x2c(%rbp), %edx
jne 0x7a42
cmpl %edx, %ecx
jge 0x762f
movq -0x40(%rbp), %rdi
movq %r13, %rsi
callq 0x7390
movl -0x2c(%rbp), %edx
movq -0x40(%rbp), %rdi
testl %edx, %edx
movq -0x70(%rbp), %rsi
jle 0x764a
xorl %eax, %eax
movslq (%r13,%rax,4), %rcx
incq %rax
movl %eax, (%rdi,%rcx,4)
cmpq %rax, %r14
jne 0x761d
jmp 0x764a
testl %edx, %edx
movq -0x70(%rbp), %rsi
jle 0x764a
xorl %eax, %eax
movslq (%rdi,%rax,4), %rcx
movl %eax, -0x4(%r13,%rcx,4)
incq %rax
cmpq %rax, %r14
jne 0x7639
movq %rsi, %rax
testl %edx, %edx
jle 0x7670
xorl %ecx, %ecx
movq %rsi, %rax
movl (%r13,%rcx,4), %edx
cmpl %ebx, %edx
jge 0x7668
leal (%rdx,%rdx,2), %edx
movl %edx, (%rax)
addq $0x4, %rax
incq %rcx
cmpq %rcx, %r14
jne 0x7656
subq %rsi, %rax
sarq $0x2, %rax
cmpq -0x68(%rbp), %rax
jne 0x7a61
movq %rsi, %rdi
movq -0x60(%rbp), %rsi
movl %ebx, %edx
movq %r15, %rcx
movl -0x38(%rbp), %r8d
callq 0x7a80
movq -0x48(%rbp), %rax
testl %eax, %eax
jle 0x78a2
movl %eax, %eax
movq %rax, -0x50(%rbp)
xorl %r14d, %r14d
xorl %eax, %eax
movq %r13, -0x38(%rbp)
movl -0x2c(%rbp), %esi
movl -0x30(%rbp), %r8d
cmpl %esi, %r8d
jge 0x79c6
cmpl %ebx, %eax
jge 0x79a7
movl %r8d, -0x30(%rbp)
movslq %r8d, %rcx
movslq (%r13,%rcx,4), %rdi
movslq %eax, %rcx
movq -0x60(%rbp), %rdx
movl (%rdx,%rcx,4), %edx
movslq %edx, %rsi
cmpl %ebx, %edi
jge 0x7793
leaq (%rdi,%rdi,2), %r8
leal 0x2(%r8), %ecx
movslq %ecx, %rcx
imulq $0x55555556, %rcx, %r9  # imm = 0x55555556
movq %r9, %r10
shrq $0x3f, %r10
shrq $0x20, %r9
addl %r10d, %r9d
leal (%r9,%r9,2), %r10d
subl %r10d, %ecx
xorl %r10d, %r10d
movl $0x0, %r11d
cmpl $0x1, %ecx
je 0x7722
movl %ebx, %r11d
leal 0x1(%rdx), %ecx
movslq %ecx, %rcx
imulq $0x55555556, %rcx, %r12 # imm = 0x55555556
movq %r12, %r13
shrq $0x3f, %r13
shrq $0x20, %r12
addl %r13d, %r12d
leal (%r12,%r12,2), %r13d
subl %r13d, %ecx
cmpl $0x1, %ecx
je 0x774c
movl %ebx, %r10d
addl %r11d, %r9d
addl %r10d, %r12d
movl 0x4(%r15,%r8,4), %ecx
movslq %r9d, %r8
movq -0x40(%rbp), %r10
movl (%r10,%r8,4), %r8d
movslq %r12d, %r9
cmpl (%r15,%rsi,4), %ecx
setl %cl
sete %sil
cmpl (%r10,%r9,4), %r8d
leaq 0x1(%rdi,%rdi,2), %rdi
setle %r12b
andb %sil, %r12b
orb %cl, %r12b
movq -0x38(%rbp), %r13
movl -0x2c(%rbp), %esi
movl -0x30(%rbp), %r8d
jmp 0x7862
subl %ebx, %edi
leal (%rdi,%rdi,2), %ecx
addl $0x4, %ecx
movslq %ecx, %rcx
imulq $0x55555556, %rcx, %r8  # imm = 0x55555556
movq %r8, %r9
shrq $0x3f, %r9
shrq $0x20, %r8
addl %r9d, %r8d
leal (%r8,%r8,2), %r9d
subl %r9d, %ecx
xorl %r9d, %r9d
movl $0x0, %r10d
cmpl $0x1, %ecx
je 0x77cb
movl %ebx, %r10d
movq %rax, -0x48(%rbp)
leal 0x2(%rdx), %ecx
movslq %ecx, %rcx
imulq $0x55555556, %rcx, %r11 # imm = 0x55555556
movq %r11, %r12
shrq $0x3f, %r12
shrq $0x20, %r11
addl %r12d, %r11d
leal (%r11,%r11,2), %r12d
subl %r12d, %ecx
cmpl $0x1, %ecx
je 0x77f9
movl %ebx, %r9d
movl %r9d, %eax
leal (%rdi,%rdi,2), %ecx
leal (%rdi,%rdi,2), %edi
addl $0x2, %edi
movslq %ecx, %rcx
movl 0x8(%r15,%rcx,4), %r13d
movl (%r15,%rsi,4), %r9d
movb $0x1, %r12b
cmpl %r9d, %r13d
jl 0x7853
jne 0x7850
addl %r10d, %r8d
addl %eax, %r11d
movslq %r8d, %r8
movl 0x4(%r15,%rsi,4), %esi
movslq %r11d, %r9
movq -0x40(%rbp), %r10
movl (%r10,%r9,4), %r9d
cmpl %esi, 0xc(%r15,%rcx,4)
setl %cl
sete %sil
cmpl %r9d, (%r10,%r8,4)
setle %r12b
andb %sil, %r12b
orb %cl, %r12b
jmp 0x7853
xorl %r12d, %r12d
movq -0x38(%rbp), %r13
movl -0x2c(%rbp), %esi
movl -0x30(%rbp), %r8d
movq -0x48(%rbp), %rax
testb %r12b, %r12b
je 0x787b
movq -0x58(%rbp), %rcx
movl %edi, (%rcx,%r14,4)
incl %r8d
cmpl %esi, %r8d
jne 0x7889
xorl %edx, %edx
jmp 0x788b
movq -0x58(%rbp), %rcx
movl %edx, (%rcx,%r14,4)
incl %eax
cmpl %ebx, %eax
je 0x7877
movb $0x1, %dl
testb %dl, %dl
je 0x78ae
incq %r14
cmpq %r14, -0x50(%rbp)
jne 0x76b8
movq -0x50(%rbp), %r14
jmp 0x78ae
xorl %r14d, %r14d
xorl %eax, %eax
movl -0x2c(%rbp), %esi
movl -0x30(%rbp), %r8d
cmpl %ebx, %eax
jge 0x78f7
movl %r8d, %r12d
leal 0x1(%r14), %ecx
movq -0x58(%rbp), %rdx
leaq (%rdx,%rcx,4), %rdi
movslq %eax, %r15
movq -0x60(%rbp), %rcx
leaq (%rcx,%r15,4), %rsi
notl %eax
addl %ebx, %eax
leaq 0x4(,%rax,4), %rdx
callq 0x21c0
movl %r14d, %r14d
subq -0x68(%rbp), %r15
xorl %eax, %eax
decq %rax
cmpq %rax, %r15
jne 0x78e6
subl %eax, %r14d
movl -0x2c(%rbp), %esi
movl %r12d, %r8d
cmpl %esi, %r8d
jge 0x7957
movslq %r8d, %rsi
movl %r14d, %eax
movq -0x58(%rbp), %rcx
leaq (%rcx,%rax,4), %rax
addq $0x4, %rax
leaq (,%rsi,4), %rcx
addq %r13, %rcx
movslq -0x80(%rbp), %rdx
addq -0x68(%rbp), %rdx
subq %rsi, %rdx
xorl %esi, %esi
xorl %edi, %edi
movl (%rcx,%rdi,4), %r8d
xorl %r9d, %r9d
cmpl %ebx, %r8d
movl %ebx, %r10d
cmovll %esi, %r10d
setl %r9b
subl %r10d, %r8d
leal (%r8,%r8,2), %r8d
subl %r9d, %r8d
addl $0x2, %r8d
movl %r8d, (%rax,%rdi,4)
incq %rdi
cmpq %rdi, %rdx
jne 0x7928
movq -0x70(%rbp), %rdi
callq 0x2030
movq -0x40(%rbp), %rdi
callq 0x2030
movq -0x60(%rbp), %rdi
callq 0x2030
movq %r13, %rdi
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x2030
leaq 0x2fee(%rip), %rdi      # 0xa97d
leaq 0x2fb8(%rip), %rsi      # 0xa94e
leaq 0x2fb7(%rip), %rcx      # 0xa954
movl $0x66, %edx
callq 0x2130
leaq 0x3049(%rip), %rdi      # 0xa9f7
leaq 0x2f99(%rip), %rsi      # 0xa94e
leaq 0x2f98(%rip), %rcx      # 0xa954
movl $0x86, %edx
callq 0x2130
leaq 0x3020(%rip), %rdi      # 0xa9ed
leaq 0x2f7a(%rip), %rsi      # 0xa94e
leaq 0x2f79(%rip), %rcx      # 0xa954
movl $0x85, %edx
callq 0x2130
leaq 0x2f9d(%rip), %rdi      # 0xa989
leaq 0x2f5b(%rip), %rsi      # 0xa94e
leaq 0x2f5a(%rip), %rcx      # 0xa954
movl $0x67, %edx
callq 0x2130
leaq 0x2f34(%rip), %rdi      # 0xa93f
leaq 0x2f3c(%rip), %rsi      # 0xa94e
leaq 0x2f3b(%rip), %rcx      # 0xa954
movl $0x55, %edx
callq 0x2130
leaq 0x2f6c(%rip), %rdi      # 0xa996
leaq 0x2f1d(%rip), %rsi      # 0xa94e
leaq 0x2f1c(%rip), %rcx      # 0xa954
movl $0x6b, %edx
callq 0x2130
leaq 0x2f66(%rip), %rdi      # 0xa9af
leaq 0x2efe(%rip), %rsi      # 0xa94e
leaq 0x2efd(%rip), %rcx      # 0xa954
movl $0x6c, %edx
callq 0x2130
leaq 0x2f78(%rip), %rdi      # 0xa9e0
leaq 0x2edf(%rip), %rsi      # 0xa94e
leaq 0x2ede(%rip), %rcx      # 0xa954
movl $0x7e, %edx
callq 0x2130