// File: deprekate[P]RepeatFinder/src/repeatfinder.cpp
// Function: get_repeats(_object*, _object*, _object*)
static PyObject* get_repeats (PyObject* self, PyObject* args, PyObject *kwargs)
{
	repeat R;
	std::vector<repeat> rep;
	static std::vector<int> allrepeats[HASH_LEN];
	char *dna;
	int gap = 0;
	int i,j;
        //var is not used, its just a placeholder in case we add an extra feature
	int var = 1;

	// This clears out the vector
	for (auto& v : allrepeats) {
		   v.clear();
	}

	const Py_ssize_t tuple_length = 4;
	PyObject *repeat_list = PyList_New(0);
	
	static char *kwlist[] = {(char *)"dna", (char *)"gap", (char *)"var", NULL};

	if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|ii", kwlist, &dna, &gap, &var)) 
	{
		return NULL;
	}
	//initialize
	converter[(unsigned char)'A'] = 0;
	converter[(unsigned char)'a'] = 0;
	converter[(unsigned char)'C'] = 1;
	converter[(unsigned char)'c'] = 1;
	converter[(unsigned char)'G'] = 2;
	converter[(unsigned char)'g'] = 2;
	converter[(unsigned char)'T'] = 3;
	converter[(unsigned char)'t'] = 3;
	complement[(unsigned char)'A'] = 'T';
	complement[(unsigned char)'a'] = 't';
	complement[(unsigned char)'C'] = 'G';
	complement[(unsigned char)'c'] = 'g';
	complement[(unsigned char)'G'] = 'C';
	complement[(unsigned char)'g'] = 'c';
	complement[(unsigned char)'T'] = 'A';
	complement[(unsigned char)'t'] = 'a';

	find_repeats(dna, allrepeats);

	extend_repeats(dna, allrepeats, R, rep);

	if(gap){
		extend_gapped_repeat(rep, gap+1);
	}
	// create the return list of tuples that will hold the pairs of repeats
	j = (int)rep.size();
	for(i=0;i<j;i++){
		if(rep[i].visited==0 && rep[i].len>= REPEAT_LEN){
			PyObject *the_tuple = PyTuple_New(tuple_length);
			PyTuple_SET_ITEM(the_tuple, 0, PyLong_FromLong(rep[i].fst));
			PyTuple_SET_ITEM(the_tuple, 1, PyLong_FromLong(rep[i].fst+rep[i].len-1));
			if(rep[i].sec>-1){
				PyTuple_SET_ITEM(the_tuple, 2, PyLong_FromLong(rep[i].sec));
				PyTuple_SET_ITEM(the_tuple, 3, PyLong_FromLong(rep[i].sec+rep[i].seclen-1));
			}
			else{
				PyTuple_SET_ITEM(the_tuple, 2, PyLong_FromLong(rep[i].sec*(-1)));
				PyTuple_SET_ITEM(the_tuple, 3, PyLong_FromLong((rep[i].sec+rep[i].seclen-1)*(-1)));
			}
			PyList_Append(repeat_list, the_tuple);
		}
	}

	return repeat_list;
}

// Assembly:
subq $0x188, %rsp            # imm = 0x188
movq %rdi, 0x178(%rsp)
movq %rsi, 0x170(%rsp)
movq %rdx, 0x168(%rsp)
leaq 0x138(%rsp), %rdi
callq 0x5bc0
cmpb $0x0, 0x60063cd(%rip)   # 0x600b600
jne 0x52ba
leaq 0x60063c0(%rip), %rdi   # 0x600b600
callq 0x41c0
cmpl $0x0, %eax
je 0x52ba
leaq 0x63af(%rip), %rax      # 0xb600
movq %rax, 0xd0(%rsp)
jmp 0x525b
movq 0xd0(%rsp), %rdi
movq %rdi, 0xc8(%rsp)
callq 0x5bd0
movq 0xc8(%rsp), %rax
addq $0x18, %rax
leaq 0x637d(%rip), %rcx      # 0xb600
addq $0x6000000, %rcx        # imm = 0x6000000
cmpq %rcx, %rax
movq %rax, 0xd0(%rsp)
jne 0x525b
leaq -0x109e(%rip), %rdi     # 0x4200
xorl %eax, %eax
movl %eax, %esi
leaq 0x5e57(%rip), %rdx      # 0xb100
callq 0x4110
leaq 0x600634b(%rip), %rdi   # 0x600b600
callq 0x40b0
movl $0x0, 0x12c(%rsp)
movl $0x1, 0x120(%rsp)
leaq 0x6329(%rip), %rax      # 0xb600
movq %rax, 0x118(%rsp)
leaq 0x631a(%rip), %rax      # 0xb600
movq %rax, 0x110(%rsp)
leaq 0x630b(%rip), %rax      # 0xb600
addq $0x6000000, %rax        # imm = 0x6000000
movq %rax, 0x108(%rsp)
movq 0x110(%rsp), %rax
cmpq 0x108(%rsp), %rax
je 0x5348
movq 0x110(%rsp), %rax
movq %rax, 0x100(%rsp)
movq 0x100(%rsp), %rdi
callq 0x5c40
movq 0x110(%rsp), %rax
addq $0x18, %rax
movq %rax, 0x110(%rsp)
jmp 0x5303
movq $0x4, 0xf8(%rsp)
xorl %eax, %eax
movl %eax, %edi
callq 0x40f0
movq %rax, 0xc0(%rsp)
jmp 0x5367
movq 0xc0(%rsp), %rax
movq %rax, 0xf0(%rsp)
movq 0x170(%rsp), %rdi
movq 0x168(%rsp), %rsi
movq %rsp, %rax
leaq 0x120(%rsp), %rcx
movq %rcx, (%rax)
leaq 0x2ce2(%rip), %rdx      # 0x807e
leaq 0x5e1d(%rip), %rcx      # 0xb1c0
xorl %eax, %eax
leaq 0x130(%rsp), %r8
leaq 0x12c(%rsp), %r9
callq 0x40a0
movl %eax, 0xbc(%rsp)
jmp 0x53c3
movl 0xbc(%rsp), %eax
cmpl $0x0, %eax
jne 0x5411
movq $0x0, 0x180(%rsp)
movl $0x1, 0xe0(%rsp)
jmp 0x59b8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0xe8(%rsp)
movl %eax, 0xe4(%rsp)
leaq 0x138(%rsp), %rdi
callq 0x5c60
jmp 0x59d5
movq 0x5bb8(%rip), %rax      # 0xafd0
movq %rax, 0xa8(%rsp)
movl $0x0, 0x104(%rax)
movl $0x0, 0x184(%rax)
movl $0x1, 0x10c(%rax)
movl $0x1, 0x18c(%rax)
movl $0x2, 0x11c(%rax)
movl $0x2, 0x19c(%rax)
movl $0x3, 0x150(%rax)
movl $0x3, 0x1d0(%rax)
movq 0x5b61(%rip), %rax      # 0xafd8
movq %rax, 0xb0(%rsp)
movl $0x54, 0x104(%rax)
movl $0x74, 0x184(%rax)
movl $0x47, 0x10c(%rax)
movl $0x67, 0x18c(%rax)
movl $0x43, 0x11c(%rax)
movl $0x63, 0x19c(%rax)
movl $0x41, 0x150(%rax)
movl $0x61, 0x1d0(%rax)
movq 0x130(%rsp), %rdi
leaq 0x6122(%rip), %rsi      # 0xb600
callq 0x4f10
jmp 0x54e5
movq 0x130(%rsp), %rdi
leaq 0x610c(%rip), %rsi      # 0xb600
leaq 0x150(%rsp), %rdx
leaq 0x138(%rsp), %rcx
callq 0x4b00
jmp 0x550b
cmpl $0x0, 0x12c(%rsp)
je 0x552c
movl 0x12c(%rsp), %esi
addl $0x1, %esi
leaq 0x138(%rsp), %rdi
callq 0x4940
leaq 0x138(%rsp), %rdi
callq 0x5aa0
movl %eax, 0x124(%rsp)
movl $0x0, 0x128(%rsp)
movl 0x128(%rsp), %eax
cmpl 0x124(%rsp), %eax
jge 0x599d
movslq 0x128(%rsp), %rsi
leaq 0x138(%rsp), %rdi
callq 0x5ac0
cmpl $0x0, 0x10(%rax)
jne 0x5985
movslq 0x128(%rsp), %rsi
leaq 0x138(%rsp), %rdi
callq 0x5ac0
cmpl $0xb, 0x8(%rax)
jl 0x5985
movl $0x4, %edi
callq 0x4070
movq %rax, 0xa0(%rsp)
jmp 0x55b1
movq 0xa0(%rsp), %rax
movq %rax, 0xd8(%rsp)
movslq 0x128(%rsp), %rsi
leaq 0x138(%rsp), %rdi
callq 0x5ac0
movslq (%rax), %rdi
callq 0x4180
movq %rax, 0x98(%rsp)
jmp 0x55e8
movq 0xd8(%rsp), %rax
movq 0x8(%rax), %rdi
movl $0x4000000, %esi        # imm = 0x4000000
callq 0x59f0
movl %eax, 0x94(%rsp)
jmp 0x5607
movl 0x94(%rsp), %eax
cmpl $0x0, %eax
je 0x5615
jmp 0x5634
leaq 0x2a67(%rip), %rdi      # 0x8083
leaq 0x2a79(%rip), %rsi      # 0x809c
movl $0x11e, %edx            # imm = 0x11E
leaq 0x2a82(%rip), %rcx      # 0x80b1
callq 0x40c0
movq 0x98(%rsp), %rcx
movq 0xd8(%rsp), %rax
movq %rcx, 0x18(%rax)
movslq 0x128(%rsp), %rsi
leaq 0x138(%rsp), %rdi
movq %rdi, 0x78(%rsp)
callq 0x5ac0
movq 0x78(%rsp), %rdi
movl (%rax), %eax
movl %eax, 0x84(%rsp)
movslq 0x128(%rsp), %rsi
callq 0x5ac0
movl 0x84(%rsp), %ecx
movl 0x8(%rax), %edx
movl %ecx, %eax
movl %edx, %ecx
leal -0x1(%rax,%rcx), %eax
movslq %eax, %rdi
callq 0x4180
movq %rax, 0x88(%rsp)
jmp 0x56a1
movq 0xd8(%rsp), %rax
movq 0x8(%rax), %rdi
movl $0x4000000, %esi        # imm = 0x4000000
callq 0x59f0
movl %eax, 0x74(%rsp)
jmp 0x56bd
movl 0x74(%rsp), %eax
cmpl $0x0, %eax
je 0x56c8
jmp 0x56e7
leaq 0x29b4(%rip), %rdi      # 0x8083
leaq 0x29c6(%rip), %rsi      # 0x809c
movl $0x11f, %edx            # imm = 0x11F
leaq 0x29cf(%rip), %rcx      # 0x80b1
callq 0x40c0
movq 0x88(%rsp), %rcx
movq 0xd8(%rsp), %rax
movq %rcx, 0x20(%rax)
movslq 0x128(%rsp), %rsi
leaq 0x138(%rsp), %rdi
callq 0x5ac0
cmpl $-0x1, 0x4(%rax)
jle 0x5843
movslq 0x128(%rsp), %rsi
leaq 0x138(%rsp), %rdi
callq 0x5ac0
movslq 0x4(%rax), %rdi
callq 0x4180
movq %rax, 0x68(%rsp)
jmp 0x573f
movq 0xd8(%rsp), %rax
movq 0x8(%rax), %rdi
movl $0x4000000, %esi        # imm = 0x4000000
callq 0x59f0
movl %eax, 0x64(%rsp)
jmp 0x575b
movl 0x64(%rsp), %eax
cmpl $0x0, %eax
je 0x5766
jmp 0x5785
leaq 0x2916(%rip), %rdi      # 0x8083
leaq 0x2928(%rip), %rsi      # 0x809c
movl $0x121, %edx            # imm = 0x121
leaq 0x2931(%rip), %rcx      # 0x80b1
callq 0x40c0
movq 0x68(%rsp), %rcx
movq 0xd8(%rsp), %rax
movq %rcx, 0x28(%rax)
movslq 0x128(%rsp), %rsi
leaq 0x138(%rsp), %rdi
movq %rdi, 0x48(%rsp)
callq 0x5ac0
movq 0x48(%rsp), %rdi
movl 0x4(%rax), %eax
movl %eax, 0x54(%rsp)
movslq 0x128(%rsp), %rsi
callq 0x5ac0
movl 0x54(%rsp), %ecx
movl 0xc(%rax), %edx
movl %ecx, %eax
movl %edx, %ecx
leal -0x1(%rax,%rcx), %eax
movslq %eax, %rdi
callq 0x4180
movq %rax, 0x58(%rsp)
jmp 0x57e7
movq 0xd8(%rsp), %rax
movq 0x8(%rax), %rdi
movl $0x4000000, %esi        # imm = 0x4000000
callq 0x59f0
movl %eax, 0x44(%rsp)
jmp 0x5803
movl 0x44(%rsp), %eax
cmpl $0x0, %eax
je 0x580e
jmp 0x582d
leaq 0x286e(%rip), %rdi      # 0x8083
leaq 0x2880(%rip), %rsi      # 0x809c
movl $0x122, %edx            # imm = 0x122
leaq 0x2889(%rip), %rcx      # 0x80b1
callq 0x40c0
movq 0x58(%rsp), %rcx
movq 0xd8(%rsp), %rax
movq %rcx, 0x30(%rax)
jmp 0x596c
movslq 0x128(%rsp), %rsi
leaq 0x138(%rsp), %rdi
callq 0x5ac0
movl 0x4(%rax), %eax
negl %eax
movslq %eax, %rdi
callq 0x4180
movq %rax, 0x38(%rsp)
jmp 0x586c
movq 0xd8(%rsp), %rax
movq 0x8(%rax), %rdi
movl $0x4000000, %esi        # imm = 0x4000000
callq 0x59f0
movl %eax, 0x34(%rsp)
jmp 0x5888
movl 0x34(%rsp), %eax
cmpl $0x0, %eax
je 0x5893
jmp 0x58b2
leaq 0x27e9(%rip), %rdi      # 0x8083
leaq 0x27fb(%rip), %rsi      # 0x809c
movl $0x125, %edx            # imm = 0x125
leaq 0x2804(%rip), %rcx      # 0x80b1
callq 0x40c0
movq 0x38(%rsp), %rcx
movq 0xd8(%rsp), %rax
movq %rcx, 0x28(%rax)
movslq 0x128(%rsp), %rsi
leaq 0x138(%rsp), %rdi
movq %rdi, 0x18(%rsp)
callq 0x5ac0
movq 0x18(%rsp), %rdi
movl 0x4(%rax), %eax
movl %eax, 0x24(%rsp)
movslq 0x128(%rsp), %rsi
callq 0x5ac0
movl 0x24(%rsp), %ecx
movl 0xc(%rax), %eax
addl %eax, %ecx
movl $0x1, %eax
subl %ecx, %eax
movslq %eax, %rdi
callq 0x4180
movq %rax, 0x28(%rsp)
jmp 0x5915
movq 0xd8(%rsp), %rax
movq 0x8(%rax), %rdi
movl $0x4000000, %esi        # imm = 0x4000000
callq 0x59f0
movl %eax, 0x14(%rsp)
jmp 0x5931
movl 0x14(%rsp), %eax
cmpl $0x0, %eax
je 0x593c
jmp 0x595b
leaq 0x2740(%rip), %rdi      # 0x8083
leaq 0x2752(%rip), %rsi      # 0x809c
movl $0x126, %edx            # imm = 0x126
leaq 0x275b(%rip), %rcx      # 0x80b1
callq 0x40c0
movq 0x28(%rsp), %rcx
movq 0xd8(%rsp), %rax
movq %rcx, 0x30(%rax)
movq 0xf0(%rsp), %rdi
movq 0xd8(%rsp), %rsi
callq 0x4090
jmp 0x5983
jmp 0x5985
jmp 0x5987
movl 0x128(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x128(%rsp)
jmp 0x554b
movq 0xf0(%rsp), %rax
movq %rax, 0x180(%rsp)
movl $0x1, 0xe0(%rsp)
leaq 0x138(%rsp), %rdi
callq 0x5c60
movq 0x180(%rsp), %rax
addq $0x188, %rsp            # imm = 0x188
retq
movq 0xe8(%rsp), %rdi
callq 0x41b0
nopw %cs:(%rax,%rax)