// File: /workspace/github_cpp_makefile_star2_O2/RasmusFonseca[P]PDBCluster/main.cpp
// Function: fillMatrices(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>>&, int, int, std::vector<Matrix*, std::allocator<Matrix*>>&)
void fillMatrices(vector<string> &files, vector<string> &atomTypes, int firstRes, int lastRes, vector<Matrix*> &ret)
{
	//for( string fName: files ){
	for(unsigned int i=0;i<files.size(); i++){
		string fName = files[i];
		//cout<<fName<<endl;
		int atomCount = 0;
		ifstream fs(fName.c_str(), ifstream::in);
		string token;
		while (fs>>token) {
			if(token=="ATOM"){
				string name, tmp, resiStr;
				fs>>tmp>>name>>tmp>>tmp>>resiStr;
				int resi = atoi(resiStr.c_str());
				if(find(atomTypes.begin(), atomTypes.end(), name) != atomTypes.end() && resi>=firstRes && resi<=lastRes)
					atomCount++;
			}
		}
		fs.close();

		Matrix* coords = new Matrix(atomCount,3);
		atomCount=0;
		ifstream fs2(fName.c_str(), ifstream::in);
		string line;
		while (std::getline(fs2, line)){
			if(line.find("ATOM")==0){
				string name = line.substr(12,5);
				name = trim(name);
				string resiStr = line.substr(22,5);
				resiStr = trim(resiStr);
				int resi = atoi(resiStr.c_str());
				if(find(atomTypes.begin(), atomTypes.end(), name) != atomTypes.end() && resi>=firstRes && resi<=lastRes){
					string x = line.substr(30,8);
					string y = line.substr(38,8);
					string z = line.substr(46,8);
					coords->set(atomCount,0, atof(x.c_str()));
					coords->set(atomCount,1, atof(y.c_str()));
					coords->set(atomCount,2, atof(z.c_str()));
					atomCount++;
				}
			}
		}
		fs2.close();

		Matrix* d = new Matrix(atomCount, atomCount);
		for(int i=0;i<atomCount;i++){
			for(int j=i+1;j<atomCount;j++){
				double dx = coords->get(i,0)-coords->get(j,0);
				double dy = coords->get(i,1)-coords->get(j,1);
				double dz = coords->get(i,2)-coords->get(j,2);
				double dist = sqrt(dx*dx+dy*dy+dz*dz);
				d->set( i,j,dist );
				d->set( j,i,dist );
			}
		}
		ret.push_back(d);
		delete coords;
		//delete cTrans;
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x568, %rsp            # imm = 0x568
movq %r8, 0x60(%rsp)
movl %ecx, (%rsp)
movl %edx, 0x4(%rsp)
movq %rsi, 0x58(%rsp)
movq %rdi, 0x68(%rsp)
leaq 0x360(%rsp), %rbx
pushq $0x1
popq %r15
pushq $0x2
popq %r13
xorl %ecx, %ecx
movl %ecx, %ecx
movq 0x68(%rsp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rax
subq %rsi, %rax
sarq $0x5, %rax
cmpq %rcx, %rax
jbe 0x2d26
movq %rcx, 0x70(%rsp)
movq %rcx, %rax
shlq $0x5, %rax
addq %rax, %rsi
leaq 0xb8(%rsp), %rdi
callq 0x2260
movq 0xb8(%rsp), %rsi
movq %rbx, %rdi
pushq $0x8
popq %rdx
callq 0x2330
leaq 0xa8(%rsp), %rax
movq %rax, 0x98(%rsp)
andq $0x0, 0xa0(%rsp)
movb $0x0, 0xa8(%rsp)
xorl %ebp, %ebp
leaq 0x98(%rsp), %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0x2230
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2965
leaq 0x98(%rsp), %r14
movq %r14, %rdi
leaq 0x2868(%rip), %rsi      # 0x50c8
callq 0x3ff1
testb %al, %al
je 0x2831
leaq 0x168(%rsp), %rax
movq %rax, 0x158(%rsp)
andq $0x0, 0x160(%rsp)
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
andq $0x0, 0x10(%rsp)
xorl %ecx, %ecx
movb %cl, 0x168(%rsp)
movb %cl, 0x18(%rsp)
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
andq $0x0, 0x38(%rsp)
movb %cl, 0x40(%rsp)
movq %rbx, %rdi
leaq 0x8(%rsp), %rsi
callq 0x2230
movq %rax, %rdi
leaq 0x158(%rsp), %rsi
callq 0x2230
movq %rax, %rdi
leaq 0x8(%rsp), %rsi
callq 0x2230
movq %rax, %rdi
leaq 0x8(%rsp), %rsi
callq 0x2230
movq %rax, %rdi
leaq 0x30(%rsp), %rsi
callq 0x2230
movq 0x30(%rsp), %rdi
callq 0x22b0
movl %eax, %ebx
movq 0x58(%rsp), %r14
movq (%r14), %rdi
movq 0x8(%r14), %rsi
leaq 0x158(%rsp), %r12
movq %r12, %rdx
callq 0x42a4
cmpq 0x8(%r14), %rax
setne %al
cmpl 0x4(%rsp), %ebx
setge %cl
cmpl (%rsp), %ebx
setle %dl
andb %cl, %dl
andb %al, %dl
movzbl %dl, %eax
addl %eax, %ebp
leaq 0x30(%rsp), %rdi
callq 0x20f0
leaq 0x8(%rsp), %rdi
callq 0x20f0
movq %r12, %rdi
callq 0x20f0
leaq 0x360(%rsp), %rbx
jmp 0x2829
movq %rbx, %rdi
callq 0x2050
pushq $0x10
popq %rdi
callq 0x21e0
movq %rax, %r12
movq %rax, %rdi
movl %ebp, %esi
pushq $0x3
popq %rdx
callq 0x249c
movq 0xb8(%rsp), %rsi
leaq 0x158(%rsp), %rdi
pushq $0x8
popq %rdx
callq 0x2330
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
andq $0x0, 0x10(%rsp)
movb $0x0, 0x18(%rsp)
xorl %ebp, %ebp
leaq 0x8(%rsp), %rbx
leaq 0x158(%rsp), %rdi
movq %rbx, %rsi
callq 0x2040
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2b6f
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
leaq 0x26de(%rip), %rsi      # 0x50c8
xorl %edx, %edx
callq 0x2340
testq %rax, %rax
jne 0x29b9
leaq 0x30(%rsp), %r14
movq %r14, %rdi
movq %rbx, %rsi
pushq $0xc
popq %rdx
pushq $0x5
popq %rbx
movq %rbx, %rcx
callq 0x21f0
movq %r14, %rdi
callq 0x2e59
movq %r14, %rdi
movq %r14, %rsi
callq 0x2130
leaq 0x138(%rsp), %r14
movq %r14, %rdi
leaq 0x8(%rsp), %rsi
pushq $0x16
popq %rdx
movq %rbx, %rcx
callq 0x21f0
movq %r14, %rdi
callq 0x2e59
movq %r14, %rdi
movq %r14, %rsi
callq 0x2130
movq 0x138(%rsp), %rdi
callq 0x22b0
movl %eax, %ebx
movq 0x58(%rsp), %r14
movq (%r14), %rdi
movq 0x8(%r14), %rsi
leaq 0x30(%rsp), %rdx
callq 0x42a4
cmpq 0x8(%r14), %rax
je 0x2b53
cmpl 0x4(%rsp), %ebx
jl 0x2b53
cmpl (%rsp), %ebx
jg 0x2b53
leaq 0x118(%rsp), %rdi
leaq 0x8(%rsp), %rbx
movq %rbx, %rsi
pushq $0x1e
popq %rdx
pushq $0x8
popq %r14
movq %r14, %rcx
callq 0x21f0
leaq 0xf8(%rsp), %rdi
movq %rbx, %rsi
pushq $0x26
popq %rdx
movq %r14, %rcx
callq 0x21f0
leaq 0xd8(%rsp), %rdi
movq %rbx, %rsi
pushq $0x2e
popq %rdx
movq %r14, %rcx
callq 0x21f0
movq 0x118(%rsp), %rdi
callq 0x2220
movq %r12, %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x25ea
movq 0xf8(%rsp), %rdi
callq 0x2220
movq %r12, %rdi
movl %ebp, %esi
movl %r15d, %edx
callq 0x25ea
movq 0xd8(%rsp), %rdi
callq 0x2220
movq %r12, %rdi
movl %ebp, %esi
movl %r13d, %edx
callq 0x25ea
incl %ebp
leaq 0xd8(%rsp), %rdi
callq 0x20f0
leaq 0xf8(%rsp), %rdi
callq 0x20f0
leaq 0x118(%rsp), %rdi
callq 0x20f0
leaq 0x138(%rsp), %rdi
callq 0x20f0
leaq 0x30(%rsp), %rdi
callq 0x20f0
jmp 0x29b4
leaq 0x158(%rsp), %rdi
callq 0x2050
pushq $0x10
popq %rdi
callq 0x21e0
movq %rax, %r14
movq %rax, %rdi
movl %ebp, %esi
movl %ebp, %edx
callq 0x249c
movq %r14, 0x30(%rsp)
xorl %ebx, %ebx
testl %ebp, %ebp
movl $0x0, %eax
cmovgl %ebp, %eax
movl %eax, 0x50(%rsp)
cmpl 0x50(%rsp), %ebx
je 0x2cba
leal 0x1(%rbx), %r14d
movl %r14d, 0x54(%rsp)
cmpl %ebp, %r14d
jge 0x2caf
movq %r12, %rdi
movl %ebx, %esi
xorl %edx, %edx
callq 0x255e
movsd %xmm0, 0x28(%rsp)
movq %r12, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x255e
movsd %xmm0, 0x90(%rsp)
movq %r12, %rdi
movl %ebx, %esi
movl %r15d, %edx
callq 0x255e
movsd %xmm0, 0x88(%rsp)
movq %r12, %rdi
movl %r14d, %esi
movl %r15d, %edx
callq 0x255e
movsd %xmm0, 0x80(%rsp)
movq %r12, %rdi
movl %ebx, %esi
movl %r13d, %edx
callq 0x255e
movsd %xmm0, 0x78(%rsp)
movq %r12, %rdi
movl %r14d, %esi
movl %r13d, %edx
callq 0x255e
movsd 0x28(%rsp), %xmm1
subsd 0x90(%rsp), %xmm1
movsd 0x88(%rsp), %xmm2
subsd 0x80(%rsp), %xmm2
movsd 0x78(%rsp), %xmm3
subsd %xmm0, %xmm3
mulsd %xmm2, %xmm2
mulsd %xmm1, %xmm1
addsd %xmm2, %xmm1
mulsd %xmm3, %xmm3
addsd %xmm1, %xmm3
sqrtsd %xmm3, %xmm0
movq 0x30(%rsp), %rdi
movl %ebx, %esi
movl %r14d, %edx
movsd %xmm0, 0x28(%rsp)
callq 0x25ea
movq 0x30(%rsp), %rdi
movl %r14d, %esi
movl %ebx, %edx
movsd 0x28(%rsp), %xmm0
callq 0x25ea
incl %r14d
jmp 0x2bbb
movl 0x54(%rsp), %eax
movl %eax, %ebx
jmp 0x2ba8
movq 0x60(%rsp), %rdi
leaq 0x30(%rsp), %rsi
callq 0x3ffe
leaq 0x360(%rsp), %rbx
movq %r12, %rdi
callq 0x2548
movq %r12, %rdi
callq 0x21c0
leaq 0x8(%rsp), %rdi
callq 0x20f0
leaq 0x158(%rsp), %rdi
callq 0x2070
leaq 0x98(%rsp), %rdi
callq 0x20f0
movq %rbx, %rdi
callq 0x2070
leaq 0xb8(%rsp), %rdi
callq 0x20f0
movq 0x70(%rsp), %rcx
incl %ecx
jmp 0x27b9
addq $0x568, %rsp            # imm = 0x568
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x2d9e
movq %rax, %rbx
jmp 0x2dab
jmp 0x2dba
jmp 0x2dba
jmp 0x2dcc
jmp 0x2e10
jmp 0x2ddd
jmp 0x2e10
movq %rax, %rbx
movq %r14, %rdi
callq 0x21c0
jmp 0x2e13
movq %rax, %rbx
movq %r12, %rdi
callq 0x21c0
jmp 0x2e2a
jmp 0x2e05
jmp 0x2e05
jmp 0x2e05
movq %rax, %rbx
jmp 0x2e44
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0x20f0
leaq 0xf8(%rsp), %rdi
callq 0x20f0
leaq 0x118(%rsp), %rdi
callq 0x20f0
jmp 0x2dbd
movq %rax, %rbx
leaq 0x138(%rsp), %rdi
callq 0x20f0
jmp 0x2dcf
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x20f0
jmp 0x2e13
jmp 0x2e10
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x20f0
leaq 0x8(%rsp), %rdi
callq 0x20f0
leaq 0x158(%rsp), %rdi
callq 0x20f0
jmp 0x2e2a
jmp 0x2e10
movq %rax, %rbx
jmp 0x2e2a
jmp 0x2e10
jmp 0x2e10
jmp 0x2e10
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x20f0
leaq 0x158(%rsp), %rdi
callq 0x2070
leaq 0x98(%rsp), %rdi
callq 0x20f0
leaq 0x360(%rsp), %rdi
callq 0x2070
leaq 0xb8(%rsp), %rdi
callq 0x20f0
movq %rbx, %rdi
callq 0x2320