// File: /workspace/github_cpp_makefile_star2_O3/simonrharris[P]SKA/src/sk_info.cpp
// Function: getKmerFileInfo(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>>>> const&, bool)
int getKmerFileInfo(const std::vector< std::string > & kmerfiles, const bool tabulated){

	std::vector < std::string > sampleNames;
	int kmersize;
	int namesPerLine=8;
	std::ifstream fileStream;

	if (tabulated){
		std::cout << "File\tKmer size\t# samples\t# kmers\t# sample patterns" << std::endl;
	}

	for (int s = 0; s < kmerfiles.size(); ++s){//for each input kmer or kmerge file
		
		if (tabulated){//print the file name
			std::cout << splitFileName(kmerfiles[s]);
		}
		else {
			std::cout << std::endl << splitFileName(kmerfiles[s]) << std::endl;
			std::cout << std::string(kmerfiles[s].size(), '=') << std::endl;
		}

		if (openFileStream(kmerfiles[s], fileStream, false)){return 1;};//open the file
		
		readKmerHeader(fileStream, kmersize, sampleNames);//read the header to get the kmer size and sample names

		if (tabulated){//print the kmer size and sample information
			std::cout << "\t" << kmersize << "\t" << sampleNames.size();
		}
		else {
			std::cout << "Kmer size: " << kmersize << std::endl;
			std::cout << "Number of samples: " << sampleNames.size() << std::endl;
			std::cout << "Sample names:"<< std::endl;
			int j=1;
			for (int i=0; i<sampleNames.size(); ++i, ++j){//print the sample names with namesPerLine sample names per line
				std::cout << sampleNames[i];
				if (i!=sampleNames.size()-1){
					std::cout << ", ";
				}
				if (j==namesPerLine || i==sampleNames.size()-1){
					std::cout << std::endl;
					j=0;
				}
			}
		}

		int kmercount=0;
		int patterncount=0;
		char kmerbuffer[(kmersize*2/3)+1];
		char asciibuffer[int(std::ceil(float(sampleNames.size())/6))];

		while (fileStream.read(asciibuffer, sizeof(asciibuffer))){//read the ascii representation of the samples
			patterncount++;//increment the number of patterns
			while (fileStream.peek()!='\n' && fileStream.read(kmerbuffer, sizeof(kmerbuffer))){//read the kmers on the line
				kmercount++;//increment the number of kmers
			}
			fileStream.ignore(256,'\n');//skip the end ofline character
		}
		if (tabulated){//print the number of kmers and patterns
			std::cout << "\t" << kmercount << "\t" << patterncount << std::endl;
		}
		else {
			std::cout << "Number of kmers: " << kmercount << std::endl;
			std::cout << "Number of sample patterns: " << patterncount << std::endl << std::endl;
		}
		sampleNames.clear();//clear the sample names vector
		fileStream.close();//close the file
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x278, %rsp            # imm = 0x278
movl %esi, %r14d
movq %rdi, -0x78(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
leaq -0x2a0(%rbp), %rdi
callq 0x5410
testb %r14b, %r14b
je 0x19d59
movq 0x272a6(%rip), %rbx     # 0x40fc0
leaq 0x1a605(%rip), %rsi     # 0x34326
movl $0x32, %edx
movq %rbx, %rdi
callq 0x5420
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq 0x27274(%rip), %rdi     # 0x40fc0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq -0x78(%rbp), %rax
movq (%rax), %rsi
cmpq %rsi, 0x8(%rax)
je 0x1a39d
movl %r14d, -0x2c(%rbp)
movq $0x0, -0x80(%rbp)
movq 0x27243(%rip), %r12     # 0x40fc0
leaq -0x2a0(%rbp), %r13
cmpb $0x0, -0x2c(%rbp)
je 0x19db3
movq -0x80(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rsi
leaq -0x70(%rbp), %rdi
callq 0x7dec
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
movq %r12, %rdi
callq 0x5420
jmp 0x19ea8
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %r12, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %rbx
movq -0x80(%rbp), %r14
shlq $0x5, %r14
movq -0x78(%rbp), %rax
movq (%rax), %rsi
addq %r14, %rsi
leaq -0x70(%rbp), %rdi
callq 0x7dec
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
movq %rbx, %rdi
callq 0x5420
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x19e4c
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x53c0
movq -0x78(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax,%r14), %rsi
leaq -0x60(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq -0x70(%rbp), %rdi
movl $0x3d, %edx
callq 0x5440
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
movq %r12, %rdi
callq 0x5420
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x19ec1
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x53c0
movq -0x80(%rbp), %rdi
shlq $0x5, %rdi
movq -0x78(%rbp), %rax
addq (%rax), %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x7f3f
movl %eax, -0x84(%rbp)
cmpl $0x0, -0x84(%rbp)
jne 0x1a38f
movq %r13, %rdi
leaq -0x34(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x9684
cmpb $0x0, -0x2c(%rbp)
je 0x19f52
movl $0x1, %edx
movq %r12, %rdi
leaq 0x1a38f(%rip), %rsi     # 0x342a1
callq 0x5420
movl -0x34(%rbp), %esi
movq %r12, %rdi
callq 0x5690
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1a36d(%rip), %rsi     # 0x342a1
callq 0x5420
movq -0x48(%rbp), %rsi
subq -0x50(%rbp), %rsi
sarq $0x5, %rsi
movq %rbx, %rdi
callq 0x5240
jmp 0x1a0e9
movl $0xb, %edx
movq %r12, %rdi
leaq 0x1a3f8(%rip), %rsi     # 0x34359
callq 0x5420
movl -0x34(%rbp), %esi
movq %r12, %rdi
callq 0x5690
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movl $0x13, %edx
movq %r12, %rdi
leaq 0x1a3bb(%rip), %rsi     # 0x34365
callq 0x5420
movq -0x48(%rbp), %rsi
subq -0x50(%rbp), %rsi
sarq $0x5, %rsi
movq %r12, %rdi
callq 0x5240
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movl $0xd, %edx
movq %r12, %rdi
leaq 0x1a37d(%rip), %rsi     # 0x34379
callq 0x5420
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %r12, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq -0x50(%rbp), %rax
cmpq %rax, -0x48(%rbp)
je 0x1a0e9
movl $0x1, %r15d
movl $0x8, %ebx
xorl %r14d, %r14d
movq -0x8(%rax,%rbx), %rsi
movq (%rax,%rbx), %rdx
movq %r12, %rdi
callq 0x5420
movq -0x48(%rbp), %rax
subq -0x50(%rbp), %rax
sarq $0x5, %rax
decq %rax
cmpq %rax, %r14
je 0x1a07e
movl $0x2, %edx
movq %r12, %rdi
leaq 0x1a30e(%rip), %rsi     # 0x34387
callq 0x5420
cmpl $0x8, %r15d
je 0x1a09c
movq -0x50(%rbp), %rax
movq -0x48(%rbp), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
leaq -0x1(%rcx), %rdx
cmpq %rdx, %r14
jne 0x1a0d6
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %r12, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq -0x50(%rbp), %rax
movq -0x48(%rbp), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
xorl %r15d, %r15d
incq %r14
incl %r15d
addq $0x20, %rbx
cmpq %r14, %rcx
ja 0x1a045
movq %rsp, -0x90(%rbp)
movl -0x34(%rbp), %eax
addl %eax, %eax
cltq
imulq $0x55555556, %rax, %rax # imm = 0x55555556
movq %rax, %rcx
shrq $0x20, %rcx
shrq $0x3f, %rax
leal (%rcx,%rax), %r14d
incl %r14d
leaq 0xf(%r14), %rax
andq $-0x10, %rax
movq %rsp, %r15
subq %rax, %r15
movq %r15, %rsp
movq -0x48(%rbp), %rax
subq -0x50(%rbp), %rax
sarq $0x5, %rax
js 0x1a136
cvtsi2ss %rax, %xmm0
jmp 0x1a14b
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
divss 0x1952d(%rip), %xmm0    # 0x33680
callq 0x51e0
cvttss2si %xmm0, %eax
movq %rax, -0x98(%rbp)
addq $0xf, %rax
andq $-0x10, %rax
movq %rsp, %rbx
subq %rax, %rbx
movq %rbx, %rsp
xorl %r12d, %r12d
movl $0x0, -0x30(%rbp)
movq %r13, %rdi
movq %rbx, %rsi
movq -0x98(%rbp), %rdx
callq 0x5480
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x1a1e3
incl -0x30(%rbp)
movq %r13, %rdi
callq 0x5140
cmpl $0xa, %eax
je 0x1a1cf
movq %r13, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x5480
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x1a1cf
incl %r12d
jmp 0x1a1a1
movl $0x100, %esi            # imm = 0x100
movq %r13, %rdi
movl $0xa, %edx
callq 0x5220
jmp 0x1a17e
cmpb $0x0, -0x2c(%rbp)
je 0x1a24e
movl $0x1, %edx
movq 0x26dcb(%rip), %rdi     # 0x40fc0
leaq 0x1a0a5(%rip), %rsi     # 0x342a1
callq 0x5420
movq 0x26db8(%rip), %rdi     # 0x40fc0
movl %r12d, %esi
callq 0x5690
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1a07f(%rip), %rsi     # 0x342a1
callq 0x5420
movq %rbx, %rdi
movl -0x30(%rbp), %esi
callq 0x5690
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
jmp 0x1a307
movl $0x11, %edx
movq 0x26d66(%rip), %rdi     # 0x40fc0
leaq 0x1a129(%rip), %rsi     # 0x3438a
callq 0x5420
movq 0x26d53(%rip), %rdi     # 0x40fc0
movl %r12d, %esi
callq 0x5690
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movl $0x1b, %edx
movq 0x26d15(%rip), %rdi     # 0x40fc0
leaq 0x1a0ea(%rip), %rsi     # 0x3439c
callq 0x5420
movq 0x26d02(%rip), %rdi     # 0x40fc0
movl -0x30(%rbp), %esi
callq 0x5690
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %rbx, %rdi
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq -0x50(%rbp), %rbx
movq -0x48(%rbp), %r14
cmpq %rbx, %r14
je 0x1a353
leaq 0x10(%rbx), %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x1a33f
movq (%r15), %rsi
incq %rsi
callq 0x53c0
leaq 0x20(%r15), %rax
addq $0x10, %r15
cmpq %r14, %r15
movq %rax, %r15
jne 0x1a32b
movq %rbx, -0x48(%rbp)
movq %r13, %rdi
callq 0x50b0
movq -0x90(%rbp), %rsp
movq -0x80(%rbp), %rdx
incq %rdx
movq -0x78(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %rax
subq %rsi, %rax
sarq $0x5, %rax
movq %rdx, -0x80(%rbp)
cmpq %rdx, %rax
movq 0x26c37(%rip), %r12     # 0x40fc0
ja 0x19d84
xorl %ebx, %ebx
cmpl $0x0, -0x84(%rbp)
setne %bl
jmp 0x1a39f
xorl %ebx, %ebx
leaq -0x2a0(%rbp), %rdi
callq 0x50d0
leaq -0x50(%rbp), %rdi
callq 0xab8e
movl %ebx, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x1a40b
jmp 0x1a3fc
jmp 0x1a3d6
jmp 0x1a3fc
jmp 0x1a3fc
jmp 0x1a3fc
jmp 0x1a3d6
movq %rax, %rbx
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x1a3ff
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0x1a3ff
jmp 0x1a3fc
jmp 0x1a3fc
jmp 0x1a3fc
jmp 0x1a3fc
movq %rax, %rbx
leaq -0x2a0(%rbp), %rdi
callq 0x50d0
leaq -0x50(%rbp), %rdi
callq 0xab8e
movq %rbx, %rdi
callq 0x56a0