// File: /workspace/github_cpp_makefile_star2_O2/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 $0x288, %rsp            # imm = 0x288
movl %esi, %r15d
movq %rdi, -0x68(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
andq $0x0, -0x40(%rbp)
leaq -0x2a8(%rbp), %rdi
callq 0x5450
testb %r15b, %r15b
je 0x14b13
movq 0x214b9(%rip), %rdi     # 0x35fb8
leaq 0x117f5(%rip), %rsi     # 0x262fb
callq 0x53f0
movq %rax, %rdi
callq 0x51c0
xorl %ecx, %ecx
leaq -0x2a8(%rbp), %r13
movl %r15d, -0x5c(%rbp)
movq -0x68(%rbp), %rax
movq (%rax), %rsi
movq 0x8(%rax), %r14
subq %rsi, %r14
sarq $0x5, %r14
movq %rcx, -0x58(%rbp)
cmpq %rcx, %r14
jbe 0x14f28
testb %r15b, %r15b
je 0x14b75
movq -0x58(%rbp), %rbx
movq %rbx, %rax
shlq $0x5, %rax
addq %rax, %rsi
leaq -0xa0(%rbp), %r15
movq %r15, %rdi
callq 0x7320
movq 0x21450(%rip), %rdi     # 0x35fb8
movq %r15, %rsi
callq 0x53a0
jmp 0x14c0a
movq 0x2143c(%rip), %rdi     # 0x35fb8
callq 0x51c0
movq %rax, %rbx
movq -0x58(%rbp), %r15
shlq $0x5, %r15
movq -0x68(%rbp), %rax
movq (%rax), %rsi
addq %r15, %rsi
leaq -0xa0(%rbp), %r12
movq %r12, %rdi
callq 0x7320
movq %rbx, %rdi
movq %r12, %rsi
callq 0x53a0
movq %rax, %rdi
callq 0x51c0
leaq -0xa0(%rbp), %rbx
movq %rbx, %rdi
callq 0x5778
movq -0x68(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax,%r15), %rsi
movq %rbx, %r15
leaq -0x90(%rbp), %rax
movq %rax, -0xa0(%rbp)
movq %rbx, %rdi
pushq $0x3d
popq %rdx
callq 0x5470
movq 0x213c2(%rip), %rdi     # 0x35fb8
movq %r15, %rsi
callq 0x53a0
movq -0x58(%rbp), %rbx
movq %rax, %rdi
callq 0x51c0
movq %r15, %rdi
callq 0x5778
movq %rbx, %rdi
shlq $0x5, %rdi
movq -0x68(%rbp), %rax
addq (%rax), %rdi
movq %r13, %rsi
xorl %edx, %edx
callq 0x73fe
testl %eax, %eax
jne 0x14f28
movq %r13, %rdi
leaq -0x2c(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x832b
cmpb $0x0, -0x5c(%rbp)
je 0x14ccf
movq 0x21365(%rip), %rdi     # 0x35fb8
leaq 0x11667(%rip), %rsi     # 0x262c1
callq 0x53f0
movl -0x2c(%rbp), %esi
movq %rax, %rdi
callq 0x56a0
movq %rax, %rdi
leaq 0x1164d(%rip), %rsi     # 0x262c1
callq 0x53f0
movq -0x48(%rbp), %rsi
subq -0x50(%rbp), %rsi
sarq $0x5, %rsi
movq %rax, %rdi
callq 0x5280
movq %rsp, -0x70(%rbp)
movl -0x2c(%rbp), %eax
addl %eax, %eax
cltd
pushq $0x3
popq %rcx
idivl %ecx
movl %eax, %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 0x14dce
cvtsi2ss %rax, %xmm0
jmp 0x14de3
movq 0x212e2(%rip), %rdi     # 0x35fb8
leaq 0x11651(%rip), %rsi     # 0x2632e
callq 0x53f0
movl -0x2c(%rbp), %esi
movq %rax, %rdi
callq 0x56a0
movq %rax, %rdi
callq 0x51c0
movq 0x212bc(%rip), %rdi     # 0x35fb8
leaq 0x11637(%rip), %rsi     # 0x2633a
callq 0x53f0
movq -0x48(%rbp), %rsi
subq -0x50(%rbp), %rsi
sarq $0x5, %rsi
movq %rax, %rdi
callq 0x5280
movq %rax, %rdi
callq 0x51c0
movq 0x2128d(%rip), %rdi     # 0x35fb8
leaq 0x1161c(%rip), %rsi     # 0x2634e
callq 0x53f0
movq %rax, %rdi
callq 0x51c0
xorl %ebx, %ebx
xorl %r14d, %r14d
pushq $0x1
popq %r15
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rax
subq %rsi, %rax
sarq $0x5, %rax
cmpq %r14, %rax
jbe 0x14c8d
addq %rbx, %rsi
movq 0x2124e(%rip), %rdi     # 0x35fb8
callq 0x53a0
movq -0x48(%rbp), %rax
subq -0x50(%rbp), %rax
sarq $0x5, %rax
decq %rax
cmpq %rax, %r14
je 0x14d96
movq 0x2122e(%rip), %rdi     # 0x35fb8
leaq 0x115cb(%rip), %rsi     # 0x2635c
callq 0x53f0
cmpl $0x8, %r15d
je 0x14db0
movq -0x48(%rbp), %rax
subq -0x50(%rbp), %rax
sarq $0x5, %rax
decq %rax
cmpq %rax, %r14
jne 0x14dbf
xorl %r15d, %r15d
movq 0x211fe(%rip), %rdi     # 0x35fb8
callq 0x51c0
incq %r14
incl %r15d
addq $0x20, %rbx
jmp 0x14d48
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
divss 0x10885(%rip), %xmm0    # 0x25670
callq 0x5220
cvttss2si %xmm0, %eax
movq %rax, -0x80(%rbp)
addq $0xf, %rax
andq $-0x10, %rax
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, -0x78(%rbp)
movq %rcx, %rsp
xorl %r12d, %r12d
xorl %ebx, %ebx
movq %r13, %rdi
movq -0x78(%rbp), %rsi
movq -0x80(%rbp), %rdx
callq 0x54c0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x14e72
incl %ebx
movq %r13, %rdi
callq 0x5140
cmpl $0xa, %eax
je 0x14e60
movq %r13, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x54c0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x14e60
incl %r12d
jmp 0x14e32
movl $0x100, %esi            # imm = 0x100
movq %r13, %rdi
pushq $0xa
popq %rdx
callq 0x5260
jmp 0x14e12
movl -0x5c(%rbp), %r15d
testb %r15b, %r15b
je 0x14eb4
movq 0x21136(%rip), %rdi     # 0x35fb8
leaq 0x11438(%rip), %rsi     # 0x262c1
callq 0x53f0
movq %rax, %rdi
movl %r12d, %esi
callq 0x56a0
movq %rax, %rdi
leaq 0x1141e(%rip), %rsi     # 0x262c1
callq 0x53f0
movq %rax, %rdi
movl %ebx, %esi
callq 0x56a0
jmp 0x14eff
movq 0x210fd(%rip), %rdi     # 0x35fb8
leaq 0x1149d(%rip), %rsi     # 0x2635f
callq 0x53f0
movq %rax, %rdi
movl %r12d, %esi
callq 0x56a0
movq %rax, %rdi
callq 0x51c0
movq 0x210d7(%rip), %rdi     # 0x35fb8
leaq 0x11489(%rip), %rsi     # 0x26371
callq 0x53f0
movq %rax, %rdi
movl %ebx, %esi
callq 0x56a0
movq %rax, %rdi
callq 0x51c0
movq %rax, %rdi
callq 0x51c0
leaq -0x50(%rbp), %rdi
callq 0xbe96
movq %r13, %rdi
callq 0x50a0
movq -0x70(%rbp), %rsp
movq -0x58(%rbp), %rcx
incq %rcx
jmp 0x14b20
xorl %ebx, %ebx
cmpq -0x58(%rbp), %r14
seta %bl
leaq -0x2a8(%rbp), %rdi
callq 0x50e0
leaq -0x50(%rbp), %rdi
callq 0x911e
movl %ebx, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x14f81
movq %rax, %rbx
jmp 0x14f90
jmp 0x14f81
jmp 0x14f81
jmp 0x14f68
jmp 0x14f81
jmp 0x14f68
movq %rax, %rbx
leaq -0xa0(%rbp), %rdi
callq 0x5778
jmp 0x14f84
jmp 0x14f81
jmp 0x14f81
jmp 0x14f81
jmp 0x14f81
movq %rax, %rbx
leaq -0x2a8(%rbp), %rdi
callq 0x50e0
leaq -0x50(%rbp), %rdi
callq 0x911e
movq %rbx, %rdi
callq 0x56c0
nopl (%rax)