// File: /workspace/github_cpp_makefile_star2_O1/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, 0xa8(%rsp)
movl %ecx, 0x28(%rsp)
movl %edx, 0x2c(%rsp)
movq %rsi, 0x58(%rsp)
movq (%rdi), %rax
movq %rdi, 0xa0(%rsp)
cmpq %rax, 0x8(%rdi)
je 0x2f05
leaq 0x40(%rsp), %r12
leaq 0x158(%rsp), %rbx
xorl %ecx, %ecx
xorl %r14d, %r14d
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 0x4a9a
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 0x2a5b
leaq 0x60(%rsp), %r14
movq %r14, %rdi
leaq 0x37ab(%rip), %rsi      # 0x60f0
callq 0x20a0
testl %eax, %eax
jne 0x2914
leaq 0x168(%rsp), %rax
movq %rax, 0x158(%rsp)
xorl %ecx, %ecx
movq %rcx, 0x160(%rsp)
movb %cl, 0x168(%rsp)
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq %rcx, 0x10(%rsp)
movb %cl, 0x18(%rsp)
movq %r12, 0x30(%rsp)
movq %rcx, 0x38(%rsp)
movb %cl, 0x40(%rsp)
leaq 0x360(%rsp), %rdi
leaq 0x8(%rsp), %rsi
callq 0x2250
movq %rax, %rdi
movq %rbx, %rsi
callq 0x2250
movq %rax, %rdi
leaq 0x8(%rsp), %rsi
callq 0x2250
movq %rax, %rdi
leaq 0x8(%rsp), %rsi
callq 0x2250
movq %rax, %rdi
leaq 0x30(%rsp), %rsi
callq 0x2250
movq 0x30(%rsp), %rdi
callq 0x22b0
movl %eax, %ebp
movq 0x58(%rsp), %r14
movq (%r14), %rdi
movq 0x8(%r14), %rsi
movq %rbx, %rdx
callq 0x4b2a
cmpq 0x8(%r14), %rax
setne %r14b
cmpl 0x2c(%rsp), %ebp
setge %r15b
cmpl 0x28(%rsp), %ebp
setle %bpl
movq 0x30(%rsp), %rdi
cmpq %r12, %rdi
je 0x2a1b
callq 0x21b0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x2a2f
callq 0x21b0
movq 0x158(%rsp), %rdi
leaq 0x168(%rsp), %rax
cmpq %rax, %rdi
je 0x2a49
callq 0x21b0
andb %bpl, %r15b
andb %r15b, %r14b
movzbl %r14b, %eax
addl %eax, %r13d
jmp 0x290f
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
movq %rbx, %rdi
movl $0x8, %edx
callq 0x2350
leaq 0x18(%rsp), %rax
movq %rax, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movb $0x0, 0x18(%rsp)
xorl %r13d, %r13d
movq 0x158(%rsp), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x21c0
movsbl %al, %edx
movq %rbx, %rdi
leaq 0x8(%rsp), %rsi
callq 0x2360
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x2cdb
movl $0x4, %ecx
leaq 0x8(%rsp), %rdi
leaq 0x35ef(%rip), %rsi      # 0x60f0
xorl %edx, %edx
callq 0x2320
testq %rax, %rax
jne 0x2ab5
movl $0xc, %edx
movl $0x5, %ecx
leaq 0x30(%rsp), %r14
movq %r14, %rdi
leaq 0x8(%rsp), %rsi
callq 0x2200
movq %r14, %rdi
callq 0x30b5
movq %r14, %rdi
movq %r14, %rsi
callq 0x2110
movl $0x16, %edx
movl $0x5, %ecx
leaq 0x138(%rsp), %r14
movq %r14, %rdi
leaq 0x8(%rsp), %rsi
callq 0x2200
movq %r14, %rdi
callq 0x30b5
movq %r14, %rdi
movq %r14, %rsi
callq 0x2110
movq 0x138(%rsp), %rdi
callq 0x22b0
movl %eax, %ebp
movq 0x58(%rsp), %r14
movq (%r14), %rdi
movq 0x8(%r14), %rsi
leaq 0x30(%rsp), %rdx
callq 0x4b2a
cmpq 0x8(%r14), %rax
je 0x2ca9
cmpl 0x2c(%rsp), %ebp
jl 0x2ca9
cmpl 0x28(%rsp), %ebp
jg 0x2ca9
movl $0x1e, %edx
movl $0x8, %ecx
leaq 0x118(%rsp), %rdi
leaq 0x8(%rsp), %r14
movq %r14, %rsi
callq 0x2200
movl $0x26, %edx
movl $0x8, %ecx
leaq 0xf8(%rsp), %rdi
movq %r14, %rsi
callq 0x2200
movl $0x2e, %edx
movl $0x8, %ecx
leaq 0xd8(%rsp), %rdi
movq %r14, %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 0x2c72
callq 0x21b0
movq 0xf8(%rsp), %rdi
leaq 0x108(%rsp), %rax
cmpq %rax, %rdi
je 0x2c8c
callq 0x21b0
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
je 0x2ca6
callq 0x21b0
incl %r13d
movq 0x138(%rsp), %rdi
leaq 0x148(%rsp), %rax
cmpq %rax, %rdi
je 0x2cc3
callq 0x21b0
movq 0x30(%rsp), %rdi
cmpq %r12, %rdi
je 0x2ab5
callq 0x21b0
jmp 0x2ab5
movq %rbx, %rdi
callq 0x2060
movl $0x10, %edi
callq 0x21e0
movq %rax, %r14
movq %rax, %rdi
movl %r13d, %esi
movl %r13d, %edx
callq 0x24fc
movq %r14, 0x30(%rsp)
testl %r13d, %r13d
jle 0x2e3c
xorl %r12d, %r12d
movl %r12d, %r14d
leal 0x1(%r14), %r12d
cmpl %r13d, %r12d
jge 0x2e33
movl %r12d, %ebp
movq %r15, %rdi
movl %r14d, %esi
xorl %edx, %edx
callq 0x25c6
movsd %xmm0, 0x50(%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 0x50(%rsp), %xmm1
subsd 0xd0(%rsp), %xmm1
movsd 0xc8(%rsp), %xmm2
subsd 0xc0(%rsp), %xmm2
movsd 0xb8(%rsp), %xmm3
subsd %xmm0, %xmm3
movapd %xmm3, %xmm0
mulsd %xmm2, %xmm2
mulsd %xmm1, %xmm1
addsd %xmm2, %xmm1
mulsd %xmm3, %xmm0
addsd %xmm1, %xmm0
ucomisd 0x32b7(%rip), %xmm0     # 0x60a8
jb 0x2df9
sqrtsd %xmm0, %xmm0
jmp 0x2dfe
callq 0x2180
movq 0x30(%rsp), %rdi
movl %r14d, %esi
movl %ebp, %edx
movsd %xmm0, 0x50(%rsp)
callq 0x2666
movq 0x30(%rsp), %rdi
movl %ebp, %esi
movl %r14d, %edx
movsd 0x50(%rsp), %xmm0
callq 0x2666
incl %ebp
cmpl %ebp, %r13d
jne 0x2d22
cmpl %r13d, %r12d
jne 0x2d0f
movq 0xa8(%rsp), %rdi
movq 0x8(%rdi), %rsi
cmpq 0x10(%rdi), %rsi
je 0x2e62
movq 0x30(%rsp), %rax
movq %rax, (%rsi)
addq $0x8, 0x8(%rdi)
leaq 0x40(%rsp), %r12
jmp 0x2e71
leaq 0x30(%rsp), %rdx
callq 0x4cee
leaq 0x40(%rsp), %r12
movq %r15, %rdi
callq 0x25b0
movq %r15, %rdi
callq 0x21b0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x2e95
callq 0x21b0
movq %rbx, %rdi
callq 0x2070
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x2eb1
callq 0x21b0
leaq 0x360(%rsp), %rdi
callq 0x2070
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
movq 0xb0(%rsp), %r14
je 0x2ee0
callq 0x21b0
incl %r14d
movq 0xa0(%rsp), %rcx
movq (%rcx), %rax
movq 0x8(%rcx), %rdx
subq %rax, %rdx
sarq $0x5, %rdx
movq %r14, %rcx
cmpq %r14, %rdx
ja 0x28a5
addq $0x568, %rsp            # imm = 0x568
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x2f91
movq %rax, %rbx
jmp 0x2fab
jmp 0x2fcc
jmp 0x2fcc
jmp 0x304e
jmp 0x2fc7
jmp 0x2fff
jmp 0x304e
movq %rax, %rbx
movq %r14, %rdi
jmp 0x2ff8
jmp 0x3041
jmp 0x3041
movq %rax, %rbx
movq %r15, %rdi
jmp 0x303a
jmp 0x3041
movq %rax, %rbx
jmp 0x3093
jmp 0x304e
movq %rax, %rbx
movq 0xd8(%rsp), %rdi
leaq 0xe8(%rsp), %rax
cmpq %rax, %rdi
je 0x2f91
callq 0x21b0
movq 0xf8(%rsp), %rdi
leaq 0x108(%rsp), %rax
cmpq %rax, %rdi
je 0x2fab
callq 0x21b0
movq 0x118(%rsp), %rdi
leaq 0x128(%rsp), %rax
cmpq %rax, %rdi
je 0x2fcf
callq 0x21b0
jmp 0x2fcf
movq %rax, %rbx
jmp 0x2fee
movq %rax, %rbx
movq 0x138(%rsp), %rdi
leaq 0x148(%rsp), %rax
cmpq %rax, %rdi
je 0x2fe9
callq 0x21b0
leaq 0x40(%rsp), %r12
movq 0x30(%rsp), %rdi
cmpq %r12, %rdi
je 0x3051
callq 0x21b0
jmp 0x3051
movq %rax, %rbx
movq 0x30(%rsp), %rdi
cmpq %r12, %rdi
je 0x3011
callq 0x21b0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x3025
callq 0x21b0
movq 0x158(%rsp), %rdi
leaq 0x168(%rsp), %rax
cmpq %rax, %rdi
je 0x3072
callq 0x21b0
jmp 0x3072
movq %rax, %rbx
jmp 0x3072
jmp 0x304e
jmp 0x304e
jmp 0x304e
jmp 0x304e
movq %rax, %rbx
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x3065
callq 0x21b0
leaq 0x158(%rsp), %rdi
callq 0x2070
movq 0x60(%rsp), %rdi
leaq 0x70(%rsp), %rax
cmpq %rax, %rdi
je 0x3086
callq 0x21b0
leaq 0x360(%rsp), %rdi
callq 0x2070
movq 0x80(%rsp), %rdi
leaq 0x90(%rsp), %rax
cmpq %rax, %rdi
je 0x30ad
callq 0x21b0
movq %rbx, %rdi
callq 0x2330