// File: /workspace/github_cpp_makefile_star2_O3/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
movl %ecx, 0x8(%rsp)
movl %edx, 0xc(%rsp)
movq (%rdi), %rax
movq %rdi, 0xa8(%rsp)
cmpq %rax, 0x8(%rdi)
je 0x2f0e
movq %rsi, %rbx
leaq 0x30(%rsp), %r12
xorl %ecx, %ecx
xorl %r14d, %r14d
movq %r8, 0xa0(%rsp)
movq %rsi, 0x50(%rsp)
movq %r14, 0xb0(%rsp)
shlq $0x5, %rcx
leaq 0x90(%rsp), %rdx
movq %rdx, 0x80(%rsp)
movq (%rax,%rcx), %rsi
movq 0x8(%rax,%rcx), %rdx
addq %rsi, %rdx
leaq 0x80(%rsp), %rdi
callq 0x4a70
movq 0x80(%rsp), %rsi
leaq 0x360(%rsp), %rdi
movl $0x8, %edx
callq 0x2350
leaq 0x70(%rsp), %rax
movq %rax, 0x60(%rsp)
movq $0x0, 0x68(%rsp)
movb $0x0, 0x70(%rsp)
xorl %r13d, %r13d
leaq 0x60(%rsp), %r14
leaq 0x360(%rsp), %rdi
movq %r14, %rsi
callq 0x2250
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2a6e
leaq 0x60(%rsp), %r14
movq %r14, %rdi
leaq 0x377c(%rip), %rsi      # 0x60c8
callq 0x20a0
testl %eax, %eax
jne 0x291b
leaq 0x168(%rsp), %rax
movq %rax, 0x158(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x160(%rsp)
movb %cl, 0x168(%rsp)
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
movq %rcx, 0x38(%rsp)
movb %cl, 0x40(%rsp)
leaq 0x20(%rsp), %rax
movq %rax, 0x10(%rsp)
movq %rcx, 0x18(%rsp)
movb %cl, 0x20(%rsp)
leaq 0x360(%rsp), %rdi
movq %r12, %rsi
callq 0x2250
movq %rax, %rdi
leaq 0x158(%rsp), %rsi
callq 0x2250
movq %rax, %rdi
movq %r12, %rsi
callq 0x2250
movq %rax, %rdi
movq %r12, %rsi
callq 0x2250
movq %rax, %rdi
leaq 0x10(%rsp), %rsi
callq 0x2250
movq 0x10(%rsp), %rdi
callq 0x22b0
movl %eax, %ebp
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
leaq 0x158(%rsp), %rdx
callq 0x4b05
cmpq 0x8(%rbx), %rax
setne %bl
cmpl 0xc(%rsp), %ebp
setge %r14b
cmpl 0x8(%rsp), %ebp
setle %bpl
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x2a2a
callq 0x21b0
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x2a3e
callq 0x21b0
movq 0x158(%rsp), %rdi
leaq 0x168(%rsp), %rax
cmpq %rax, %rdi
je 0x2a58
callq 0x21b0
andb %bpl, %r14b
andb %r14b, %bl
movzbl %bl, %eax
addl %eax, %r13d
movq 0x50(%rsp), %rbx
jmp 0x2916
leaq 0x360(%rsp), %rdi
callq 0x2060
movl $0x10, %edi
callq 0x21e0
movq %rax, %r15
movq %rax, %rdi
movl %r13d, %esi
movl $0x3, %edx
callq 0x24fc
movq 0x80(%rsp), %rsi
leaq 0x158(%rsp), %rdi
movl $0x8, %edx
callq 0x2350
leaq 0x40(%rsp), %rax
movq %rax, 0x30(%rsp)
movq $0x0, 0x38(%rsp)
movb $0x0, 0x40(%rsp)
xorl %r13d, %r13d
movq 0x158(%rsp), %rax
movq -0x18(%rax), %rdi
leaq 0x158(%rsp), %r14
addq %r14, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %edx
movq %r14, %rdi
movq %r12, %rsi
callq 0x2360
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2cee
movl $0x4, %ecx
movq %r12, %rdi
leaq 0x35ab(%rip), %rsi      # 0x60c8
xorl %edx, %edx
callq 0x2320
testq %rax, %rax
jne 0x2acd
movl $0xc, %edx
movl $0x5, %ecx
leaq 0x10(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x2200
movq %r14, %rdi
callq 0x30c3
movq %r14, %rdi
movq %r14, %rsi
callq 0x2110
movl $0x16, %edx
movl $0x5, %ecx
leaq 0x138(%rsp), %r14
movq %r14, %rdi
movq %r12, %rsi
callq 0x2200
movq %r14, %rdi
callq 0x30c3
movq %r14, %rdi
movq %r14, %rsi
callq 0x2110
movq 0x138(%rsp), %rdi
callq 0x22b0
movl %eax, %ebp
movq (%rbx), %rdi
movq 0x8(%rbx), %rsi
leaq 0x10(%rsp), %rdx
callq 0x4b05
cmpq 0x8(%rbx), %rax
je 0x2cb7
cmpl 0xc(%rsp), %ebp
jl 0x2cb7
cmpl 0x8(%rsp), %ebp
jg 0x2cb7
movl $0x1e, %edx
movl $0x8, %ecx
leaq 0x118(%rsp), %rdi
movq %r12, %rsi
callq 0x2200
movl $0x26, %edx
movl $0x8, %ecx
leaq 0xf8(%rsp), %rdi
movq %r12, %rsi
callq 0x2200
movl $0x2e, %edx
movl $0x8, %ecx
leaq 0xd8(%rsp), %rdi
movq %r12, %rsi
callq 0x2200
movq 0x118(%rsp), %rdi
callq 0x2240
movq %r15, %rdi
movl %r13d, %esi
xorl %edx, %edx
callq 0x2666
movq 0xf8(%rsp), %rdi
callq 0x2240
movq %r15, %rdi
movl %r13d, %esi
movl $0x1, %edx
callq 0x2666
movq 0xd8(%rsp), %rdi
callq 0x2240
movq %r15, %rdi
movl %r13d, %esi
movl $0x2, %edx
callq 0x2666
movq 0xd8(%rsp), %rdi
leaq 0xe8(%rsp), %rax
cmpq %rax, %rdi
je 0x2c80
callq 0x21b0
movq 0xf8(%rsp), %rdi
leaq 0x108(%rsp), %rax
cmpq %rax, %rdi
je 0x2c9a
callq 0x21b0
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
je 0x2cb4
callq 0x21b0
incl %r13d
movq 0x138(%rsp), %rdi
leaq 0x148(%rsp), %rax
cmpq %rax, %rdi
je 0x2cd1
callq 0x21b0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x2acd
callq 0x21b0
jmp 0x2acd
leaq 0x158(%rsp), %rdi
callq 0x2060
movl $0x10, %edi
callq 0x21e0
movq %rax, %r14
movq %rax, %rdi
movl %r13d, %esi
movl %r13d, %edx
callq 0x24fc
movq %r14, 0x10(%rsp)
testl %r13d, %r13d
jle 0x2e40
xorl %ebx, %ebx
movl %ebx, %r14d
leal 0x1(%r14), %ebx
cmpl %r13d, %ebx
jge 0x2e37
movl %ebx, %ebp
movq %r15, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x25c6
movsd %xmm0, 0x58(%rsp)
movq %r15, %rdi
movl %ebp, %esi
xorl %edx, %edx
callq 0x25c6
movsd %xmm0, 0xd0(%rsp)
movq %r15, %rdi
movl %r14d, %esi
movl $0x1, %edx
callq 0x25c6
movsd %xmm0, 0xc8(%rsp)
movq %r15, %rdi
movl %ebp, %esi
movl $0x1, %edx
callq 0x25c6
movsd %xmm0, 0xc0(%rsp)
movq %r15, %rdi
movl %r14d, %esi
movl $0x2, %edx
callq 0x25c6
movsd %xmm0, 0xb8(%rsp)
movq %r15, %rdi
movl %ebp, %esi
movl $0x2, %edx
callq 0x25c6
movsd 0x58(%rsp), %xmm1
subsd 0xd0(%rsp), %xmm1
movsd 0xc8(%rsp), %xmm2
subsd 0xc0(%rsp), %xmm2
movsd 0xb8(%rsp), %xmm3
subsd %xmm0, %xmm3
mulsd %xmm2, %xmm2
mulsd %xmm1, %xmm1
addsd %xmm2, %xmm1
mulsd %xmm3, %xmm3
addsd %xmm1, %xmm3
xorps %xmm0, %xmm0
sqrtsd %xmm3, %xmm0
movq 0x10(%rsp), %rdi
movl %r14d, %esi
movl %ebp, %edx
movsd %xmm0, 0x58(%rsp)
callq 0x2666
movq 0x10(%rsp), %rdi
movl %ebp, %esi
movl %r14d, %edx
movsd 0x58(%rsp), %xmm0
callq 0x2666
incl %ebp
cmpl %ebp, %r13d
jne 0x2d38
cmpl %r13d, %ebx
jne 0x2d26
movq 0xa0(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x2e66
movq 0x10(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
movq 0x50(%rsp), %rbx
jmp 0x2e75
leaq 0x10(%rsp), %rdx
callq 0x4cc2
movq 0x50(%rsp), %rbx
movq %r15, %rdi
callq 0x25b0
movq %r15, %rdi
callq 0x21b0
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x2e99
callq 0x21b0
leaq 0x158(%rsp), %rdi
callq 0x2070
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x2eba
callq 0x21b0
leaq 0x360(%rsp), %rdi
callq 0x2070
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
movq 0xb0(%rsp), %r14
je 0x2ee9
callq 0x21b0
incl %r14d
movq 0xa8(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x5, %rdx
movq %r14, %rcx
cmpq %r14, %rdx
ja 0x28ac
addq $0x568, %rsp            # imm = 0x568
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x2f9a
movq %rax, %rbx
jmp 0x2fb4
jmp 0x2fd5
jmp 0x2fd5
jmp 0x305c
jmp 0x2fd0
jmp 0x3008
jmp 0x305c
movq %rax, %rbx
movq %r14, %rdi
jmp 0x3001
jmp 0x304f
jmp 0x304f
movq %rax, %rbx
movq %r15, %rdi
jmp 0x3048
jmp 0x304f
movq %rax, %rbx
jmp 0x30a1
jmp 0x305c
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
leaq 0xe8(%rsp), %rax
cmpq %rax, %rdi
je 0x2f9a
callq 0x21b0
movq 0xf8(%rsp), %rdi
leaq 0x108(%rsp), %rax
cmpq %rax, %rdi
je 0x2fb4
callq 0x21b0
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
je 0x2fd8
callq 0x21b0
jmp 0x2fd8
movq %rax, %rbx
jmp 0x2ff2
movq %rax, %rbx
movq 0x138(%rsp), %rdi
leaq 0x148(%rsp), %rax
cmpq %rax, %rdi
je 0x2ff2
callq 0x21b0
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x305f
callq 0x21b0
jmp 0x305f
movq %rax, %rbx
movq 0x10(%rsp), %rdi
leaq 0x20(%rsp), %rax
cmpq %rax, %rdi
je 0x301f
callq 0x21b0
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x3033
callq 0x21b0
movq 0x158(%rsp), %rdi
leaq 0x168(%rsp), %rax
cmpq %rax, %rdi
je 0x3080
callq 0x21b0
jmp 0x3080
movq %rax, %rbx
jmp 0x3080
jmp 0x305c
jmp 0x305c
jmp 0x305c
jmp 0x305c
movq %rax, %rbx
movq 0x30(%rsp), %rdi
leaq 0x40(%rsp), %rax
cmpq %rax, %rdi
je 0x3073
callq 0x21b0
leaq 0x158(%rsp), %rdi
callq 0x2070
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x3094
callq 0x21b0
leaq 0x360(%rsp), %rdi
callq 0x2070
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x30bb
callq 0x21b0
movq %rbx, %rdi
callq 0x2330