// File: 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
subq $0x420, %rsp            # imm = 0x420
movb %sil, %al
movq %rdi, -0x10(%rbp)
andb $0x1, %al
movb %al, -0x11(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x1ab40
movl $0x8, -0x38(%rbp)
leaq -0x240(%rbp), %rdi
callq 0x65f0
jmp 0x33595
testb $0x1, -0x11(%rbp)
je 0x335fc
movq 0x45a06(%rip), %rdi     # 0x78fa8
leaq 0x26d42(%rip), %rsi     # 0x5a2eb
callq 0x6520
movq %rax, -0x2e8(%rbp)
jmp 0x335b7
movq -0x2e8(%rbp), %rdi
movq 0x459cb(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x335cc
jmp 0x335fc
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
jmp 0x33eaf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
jmp 0x33ea3
movl $0x0, -0x250(%rbp)
movslq -0x250(%rbp), %rax
movq %rax, -0x2f0(%rbp)
movq -0x10(%rbp), %rdi
callq 0xb670
movq %rax, %rcx
movq -0x2f0(%rbp), %rax
cmpq %rcx, %rax
jae 0x33e75
testb $0x1, -0x11(%rbp)
je 0x336a0
movq -0x10(%rbp), %rdi
movslq -0x250(%rbp), %rsi
callq 0xf2d0
movq %rax, %rsi
leaq -0x270(%rbp), %rdi
callq 0xa370
jmp 0x33657
movq 0x4594a(%rip), %rdi     # 0x78fa8
leaq -0x270(%rbp), %rsi
callq 0x64d0
jmp 0x3366c
leaq -0x270(%rbp), %rdi
callq 0x6a08
jmp 0x3381e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
leaq -0x270(%rbp), %rdi
callq 0x6a08
jmp 0x33ea3
movq 0x45901(%rip), %rdi     # 0x78fa8
movq 0x458e2(%rip), %rsi     # 0x78f90
callq 0x6570
movq %rax, -0x2f8(%rbp)
jmp 0x336bc
movq -0x10(%rbp), %rdi
movslq -0x250(%rbp), %rsi
callq 0xf2d0
movq %rax, %rsi
leaq -0x290(%rbp), %rdi
callq 0xa370
jmp 0x336dd
movq -0x2f8(%rbp), %rdi
leaq -0x290(%rbp), %rsi
callq 0x64d0
movq %rax, -0x300(%rbp)
jmp 0x336f9
movq -0x300(%rbp), %rdi
movq 0x45889(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x3370e
leaq -0x290(%rbp), %rdi
callq 0x6a08
movq -0x10(%rbp), %rdi
movslq -0x250(%rbp), %rsi
callq 0xf2d0
movq %rax, %rdi
callq 0x6390
movq %rax, -0x310(%rbp)
leaq -0x2b1(%rbp), %rdi
movq %rdi, -0x308(%rbp)
callq 0x6910
movq -0x310(%rbp), %rsi
movq -0x308(%rbp), %rcx
leaq -0x2b0(%rbp), %rdi
movl $0x3d, %edx
callq 0x9150
jmp 0x3376d
movq 0x45834(%rip), %rdi     # 0x78fa8
leaq -0x2b0(%rbp), %rsi
callq 0x64d0
movq %rax, -0x318(%rbp)
jmp 0x33789
movq -0x318(%rbp), %rdi
movq 0x457f9(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x3379e
leaq -0x2b0(%rbp), %rdi
callq 0x6a08
leaq -0x2b1(%rbp), %rdi
callq 0x65a0
jmp 0x3381e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
leaq -0x290(%rbp), %rdi
callq 0x6a08
jmp 0x33ea3
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
jmp 0x3380d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x248(%rbp)
movl %eax, -0x24c(%rbp)
leaq -0x2b0(%rbp), %rdi
callq 0x6a08
leaq -0x2b1(%rbp), %rdi
callq 0x65a0
jmp 0x33ea3
movq -0x10(%rbp), %rdi
movslq -0x250(%rbp), %rsi
callq 0xf2d0
movq %rax, %rdi
leaq -0x240(%rbp), %rsi
xorl %edx, %edx
callq 0xa4f0
movl %eax, -0x31c(%rbp)
jmp 0x33847
movl -0x31c(%rbp), %eax
cmpl $0x0, %eax
je 0x33868
movl $0x1, -0x4(%rbp)
movl $0x1, -0x2b8(%rbp)
jmp 0x33e86
leaq -0x240(%rbp), %rdi
leaq -0x34(%rbp), %rsi
leaq -0x30(%rbp), %rdx
callq 0xcd40
jmp 0x3387e
testb $0x1, -0x11(%rbp)
je 0x338f3
movq 0x4571d(%rip), %rdi     # 0x78fa8
leaq 0x26a1f(%rip), %rsi     # 0x5a2b1
callq 0x6520
movq %rax, -0x328(%rbp)
jmp 0x338a0
movq -0x328(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x68d0
movq %rax, -0x330(%rbp)
jmp 0x338b8
movq -0x330(%rbp), %rdi
leaq 0x269eb(%rip), %rsi     # 0x5a2b1
callq 0x6520
movq %rax, -0x338(%rbp)
jmp 0x338d4
leaq -0x30(%rbp), %rdi
callq 0xb670
movq -0x338(%rbp), %rdi
movq %rax, %rsi
callq 0x6120
jmp 0x338ee
jmp 0x33ada
movq 0x456ae(%rip), %rdi     # 0x78fa8
leaq 0x26a1d(%rip), %rsi     # 0x5a31e
callq 0x6520
movq %rax, -0x340(%rbp)
jmp 0x3390f
movq -0x340(%rbp), %rdi
movl -0x34(%rbp), %esi
callq 0x68d0
movq %rax, -0x348(%rbp)
jmp 0x33927
movq -0x348(%rbp), %rdi
movq 0x4565b(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x3393c
movq 0x45665(%rip), %rdi     # 0x78fa8
leaq 0x269e0(%rip), %rsi     # 0x5a32a
callq 0x6520
movq %rax, -0x350(%rbp)
jmp 0x33958
leaq -0x30(%rbp), %rdi
callq 0xb670
movq -0x350(%rbp), %rdi
movq %rax, %rsi
callq 0x6120
movq %rax, -0x358(%rbp)
jmp 0x33979
movq -0x358(%rbp), %rdi
movq 0x45609(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x3398e
movq 0x45613(%rip), %rdi     # 0x78fa8
leaq 0x269a2(%rip), %rsi     # 0x5a33e
callq 0x6520
movq %rax, -0x360(%rbp)
jmp 0x339aa
movq -0x360(%rbp), %rdi
movq 0x455d8(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x339bf
movl $0x1, -0x2bc(%rbp)
movl $0x0, -0x2c0(%rbp)
movslq -0x2c0(%rbp), %rax
movq %rax, -0x368(%rbp)
leaq -0x30(%rbp), %rdi
callq 0xb670
movq %rax, %rcx
movq -0x368(%rbp), %rax
cmpq %rcx, %rax
jae 0x33ad8
movslq -0x2c0(%rbp), %rsi
leaq -0x30(%rbp), %rdi
callq 0x1ab60
movq %rax, %rsi
movq 0x45591(%rip), %rdi     # 0x78fa8
callq 0x64d0
jmp 0x33a1e
movslq -0x2c0(%rbp), %rax
movq %rax, -0x370(%rbp)
leaq -0x30(%rbp), %rdi
callq 0xb670
movq %rax, %rcx
movq -0x370(%rbp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
je 0x33a5f
movq 0x45559(%rip), %rdi     # 0x78fa8
leaq 0x268f6(%rip), %rsi     # 0x5a34c
callq 0x6520
jmp 0x33a5d
jmp 0x33a5f
movl -0x2bc(%rbp), %eax
cmpl -0x38(%rbp), %eax
je 0x33a94
movslq -0x2c0(%rbp), %rax
movq %rax, -0x378(%rbp)
leaq -0x30(%rbp), %rdi
callq 0xb670
movq %rax, %rcx
movq -0x378(%rbp), %rax
subq $0x1, %rcx
cmpq %rcx, %rax
jne 0x33ab3
movq 0x4550d(%rip), %rdi     # 0x78fa8
movq 0x454ee(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x33aa9
movl $0x0, -0x2bc(%rbp)
jmp 0x33ab5
movl -0x2c0(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c0(%rbp)
movl -0x2bc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2bc(%rbp)
jmp 0x339d3
jmp 0x33ada
movl $0x0, -0x2c4(%rbp)
movl $0x0, -0x2c8(%rbp)
movl -0x34(%rbp), %eax
addl %eax, %eax
cltq
imulq $0x55555556, %rax, %rax # imm = 0x55555556
movq %rax, %rcx
shrq $0x20, %rcx
movl %ecx, %edx
shrq $0x3f, %rax
movl %eax, %ecx
movl %edx, %eax
leal 0x1(%rax,%rcx), %eax
movq %rax, -0x390(%rbp)
movq %rsp, %rcx
movq %rcx, -0x2d0(%rbp)
movq %rax, %rdx
addq $0xf, %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x388(%rbp)
movq %rcx, %rsp
movq %rax, -0x2d8(%rbp)
leaq -0x30(%rbp), %rdi
callq 0xb670
movq %rax, %rdx
shrq %rdx
movl %eax, %ecx
andl $0x1, %ecx
orq %rdx, %rcx
cvtsi2ss %rcx, %xmm0
addss %xmm0, %xmm0
cvtsi2ss %rax, %xmm1
movss %xmm1, -0x380(%rbp)
testq %rax, %rax
movss %xmm0, -0x37c(%rbp)
js 0x33b8e
movss -0x380(%rbp), %xmm0
movss %xmm0, -0x37c(%rbp)
movss -0x37c(%rbp), %xmm0
movss 0x25ade(%rip), %xmm1    # 0x5967c
divss %xmm1, %xmm0
callq 0x33ed0
movss %xmm0, -0x394(%rbp)
jmp 0x33bb1
movss -0x394(%rbp), %xmm0
cvttss2si %xmm0, %eax
movq %rax, -0x3a8(%rbp)
movq %rax, %rdx
addq $0xf, %rdx
andq $-0x10, %rdx
movq %rsp, %rcx
subq %rdx, %rcx
movq %rcx, -0x3a0(%rbp)
movq %rcx, %rsp
movq %rax, -0x2e0(%rbp)
movq -0x3a8(%rbp), %rdx
movq -0x3a0(%rbp), %rsi
leaq -0x240(%rbp), %rdi
callq 0x6680
movq %rax, -0x3b0(%rbp)
jmp 0x33c09
movq -0x3b0(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x6670
movb %al, -0x3b1(%rbp)
jmp 0x33c27
movb -0x3b1(%rbp), %al
testb $0x1, %al
jne 0x33c36
jmp 0x33cf8
movl -0x2c8(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c8(%rbp)
leaq -0x240(%rbp), %rdi
callq 0x61c0
movl %eax, -0x3b8(%rbp)
jmp 0x33c59
movl -0x3b8(%rbp), %ecx
xorl %eax, %eax
cmpl $0xa, %ecx
movb %al, -0x3b9(%rbp)
je 0x33cbb
movq -0x390(%rbp), %rdx
movq -0x388(%rbp), %rsi
leaq -0x240(%rbp), %rdi
callq 0x6680
movq %rax, -0x3c8(%rbp)
jmp 0x33c8f
movq -0x3c8(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x6670
movb %al, -0x3c9(%rbp)
jmp 0x33cad
movb -0x3c9(%rbp), %al
movb %al, -0x3b9(%rbp)
jmp 0x33cbb
movb -0x3b9(%rbp), %al
testb $0x1, %al
jne 0x33cc7
jmp 0x33cdb
movl -0x2c4(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c4(%rbp)
jmp 0x33c45
leaq -0x240(%rbp), %rdi
movl $0x100, %esi            # imm = 0x100
movl $0xa, %edx
callq 0x6340
jmp 0x33cf3
jmp 0x33be6
testb $0x1, -0x11(%rbp)
je 0x33d8a
movq 0x4529f(%rip), %rdi     # 0x78fa8
leaq 0x265a1(%rip), %rsi     # 0x5a2b1
callq 0x6520
movq %rax, -0x3d8(%rbp)
jmp 0x33d1e
movq -0x3d8(%rbp), %rdi
movl -0x2c4(%rbp), %esi
callq 0x68d0
movq %rax, -0x3e0(%rbp)
jmp 0x33d39
movq -0x3e0(%rbp), %rdi
leaq 0x2656a(%rip), %rsi     # 0x5a2b1
callq 0x6520
movq %rax, -0x3e8(%rbp)
jmp 0x33d55
movq -0x3e8(%rbp), %rdi
movl -0x2c8(%rbp), %esi
callq 0x68d0
movq %rax, -0x3f0(%rbp)
jmp 0x33d70
movq -0x3f0(%rbp), %rdi
movq 0x45212(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x33d85
jmp 0x33e40
movq 0x45217(%rip), %rdi     # 0x78fa8
leaq 0x265b7(%rip), %rsi     # 0x5a34f
callq 0x6520
movq %rax, -0x3f8(%rbp)
jmp 0x33da6
movq -0x3f8(%rbp), %rdi
movl -0x2c4(%rbp), %esi
callq 0x68d0
movq %rax, -0x400(%rbp)
jmp 0x33dc1
movq -0x400(%rbp), %rdi
movq 0x451c1(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x33dd6
movq 0x451cb(%rip), %rdi     # 0x78fa8
leaq 0x2657d(%rip), %rsi     # 0x5a361
callq 0x6520
movq %rax, -0x408(%rbp)
jmp 0x33df2
movq -0x408(%rbp), %rdi
movl -0x2c8(%rbp), %esi
callq 0x68d0
movq %rax, -0x410(%rbp)
jmp 0x33e0d
movq -0x410(%rbp), %rdi
movq 0x45175(%rip), %rsi     # 0x78f90
callq 0x6570
movq %rax, -0x418(%rbp)
jmp 0x33e29
movq -0x418(%rbp), %rdi
movq 0x45159(%rip), %rsi     # 0x78f90
callq 0x6570
jmp 0x33e3e
jmp 0x33e40
leaq -0x30(%rbp), %rdi
callq 0x1aca0
leaq -0x240(%rbp), %rdi
callq 0x60f0
jmp 0x33e57
movq -0x2d0(%rbp), %rax
movq %rax, %rsp
movl -0x250(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x250(%rbp)
jmp 0x33606
movl $0x0, -0x4(%rbp)
movl $0x1, -0x2b8(%rbp)
leaq -0x240(%rbp), %rdi
callq 0x6140
leaq -0x30(%rbp), %rdi
callq 0xfe90
movl -0x4(%rbp), %eax
movq %rbp, %rsp
popq %rbp
retq
leaq -0x240(%rbp), %rdi
callq 0x6140
leaq -0x30(%rbp), %rdi
callq 0xfe90
movq -0x248(%rbp), %rdi
callq 0x6900
nopw %cs:(%rax,%rax)
nop