// File: /workspace/github_cpp_makefile_star2_O1/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, %r15d
movq %rdi, -0x78(%rbp)
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movq $0x0, -0x40(%rbp)
leaq -0x298(%rbp), %rdi
callq 0x5410
testb %r15b, %r15b
je 0x19f5d
movq 0x270a2(%rip), %rbx     # 0x40fc0
leaq 0x1a411(%rip), %rsi     # 0x34336
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 0x27070(%rip), %rdi     # 0x40fc0
callq 0x5030
movq %rax, %rdi
callq 0x5250
movq -0x78(%rbp), %rax
movq (%rax), %rsi
cmpq %rsi, 0x8(%rax)
setne %r14b
je 0x1a58a
movl %r15d, -0x2c(%rbp)
movq $0x0, -0x80(%rbp)
movq 0x2703b(%rip), %r12     # 0x40fc0
leaq -0x298(%rbp), %r13
cmpb $0x0, -0x2c(%rbp)
je 0x19fbb
movq -0x80(%rbp), %rax
shlq $0x5, %rax
addq %rax, %rsi
leaq -0x70(%rbp), %rdi
callq 0x7e20
movq -0x70(%rbp), %rsi
movq -0x68(%rbp), %rdx
movq %r12, %rdi
callq 0x5420
jmp 0x1a0b0
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), %r15
shlq $0x5, %r15
movq -0x78(%rbp), %rax
movq (%rax), %rsi
addq %r15, %rsi
leaq -0x70(%rbp), %rdi
callq 0x7e20
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 0x1a054
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x53c0
movq -0x78(%rbp), %rax
movq (%rax), %rax
movq 0x8(%rax,%r15), %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 0x1a0c9
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 0x7f73
testl %eax, %eax
jne 0x1a58a
movq %r13, %rdi
leaq -0x34(%rbp), %rsi
leaq -0x50(%rbp), %rdx
callq 0x96e2
cmpb $0x0, -0x2c(%rbp)
je 0x1a14f
movl $0x1, %edx
movq %r12, %rdi
leaq 0x1a1a2(%rip), %rsi     # 0x342b1
callq 0x5420
movl -0x34(%rbp), %esi
movq %r12, %rdi
callq 0x5690
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
leaq 0x1a180(%rip), %rsi     # 0x342b1
callq 0x5420
movq -0x48(%rbp), %rsi
subq -0x50(%rbp), %rsi
sarq $0x5, %rsi
movq %rbx, %rdi
callq 0x5240
jmp 0x1a2e2
movl $0xb, %edx
movq %r12, %rdi
leaq 0x1a20b(%rip), %rsi     # 0x34369
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 0x1a1ce(%rip), %rsi     # 0x34375
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 0x1a190(%rip), %rsi     # 0x34389
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 0x1a2e2
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 0x1a27b
movl $0x2, %edx
movq %r12, %rdi
leaq 0x1a121(%rip), %rsi     # 0x34397
callq 0x5420
cmpl $0x8, %r15d
je 0x1a295
movq -0x48(%rbp), %rax
subq -0x50(%rbp), %rax
sarq $0x5, %rax
decq %rax
cmpq %rax, %r14
jne 0x1a2c0
movq (%r12), %rax
movq -0x18(%rax), %rdi
addq %r12, %rdi
movl $0xa, %esi
callq 0x53a0
movsbl %al, %esi
movq %r12, %rdi
callq 0x5030
xorl %r15d, %r15d
movq %rax, %rdi
callq 0x5250
incq %r14
incl %r15d
movq -0x50(%rbp), %rax
movq -0x48(%rbp), %rcx
subq %rax, %rcx
sarq $0x5, %rcx
addq $0x20, %rbx
cmpq %r14, %rcx
ja 0x1a242
movq %rsp, -0x88(%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), %ebx
incl %ebx
leaq 0xf(%rbx), %rax
andq $-0x10, %rax
movq %rsp, %r14
subq %rax, %r14
movq %r14, %rsp
movq -0x48(%rbp), %rax
subq -0x50(%rbp), %rax
sarq $0x5, %rax
js 0x1a32d
cvtsi2ss %rax, %xmm0
jmp 0x1a342
movq %rax, %rcx
shrq %rcx
andl $0x1, %eax
orq %rcx, %rax
cvtsi2ss %rax, %xmm0
addss %xmm0, %xmm0
divss 0x19336(%rip), %xmm0    # 0x33680
callq 0x51e0
cvttss2si %xmm0, %eax
movq %rax, -0x90(%rbp)
addq $0xf, %rax
andq $-0x10, %rax
movq %rsp, %r15
subq %rax, %r15
movq %r15, %rsp
xorl %r12d, %r12d
movl $0x0, -0x30(%rbp)
movq %r13, %rdi
movq %r15, %rsi
movq -0x90(%rbp), %rdx
callq 0x5480
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x1a3da
incl -0x30(%rbp)
movq %r13, %rdi
callq 0x5140
cmpl $0xa, %eax
je 0x1a3c6
movq %r13, %rdi
movq %r14, %rsi
movq %rbx, %rdx
callq 0x5480
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x1a3c6
incl %r12d
jmp 0x1a398
movl $0x100, %esi            # imm = 0x100
movq %r13, %rdi
movl $0xa, %edx
callq 0x5220
jmp 0x1a375
cmpb $0x0, -0x2c(%rbp)
je 0x1a445
movl $0x1, %edx
movq 0x26bd4(%rip), %rdi     # 0x40fc0
leaq 0x19ebe(%rip), %rsi     # 0x342b1
callq 0x5420
movq 0x26bc1(%rip), %rdi     # 0x40fc0
movl %r12d, %esi
callq 0x5690
movq %rax, %rbx
movl $0x1, %edx
movq %rax, %rdi
leaq 0x19e98(%rip), %rsi     # 0x342b1
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 0x1a4fe
movl $0x11, %edx
movq 0x26b6f(%rip), %rdi     # 0x40fc0
leaq 0x19f42(%rip), %rsi     # 0x3439a
callq 0x5420
movq 0x26b5c(%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 0x26b1e(%rip), %rdi     # 0x40fc0
leaq 0x19f03(%rip), %rsi     # 0x343ac
callq 0x5420
movq 0x26b0b(%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 0x1a54a
leaq 0x10(%rbx), %r15
movq -0x10(%r15), %rdi
cmpq %rdi, %r15
je 0x1a536
movq (%r15), %rsi
incq %rsi
callq 0x53c0
leaq 0x20(%r15), %rax
addq $0x10, %r15
cmpq %r14, %r15
movq %rax, %r15
jne 0x1a522
movq %rbx, -0x48(%rbp)
movq %r13, %rdi
callq 0x50b0
movq -0x88(%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
seta %r14b
movq 0x26a3c(%rip), %r12     # 0x40fc0
ja 0x19f8c
movzbl %r14b, %ebx
andl $0x1, %ebx
leaq -0x298(%rbp), %rdi
callq 0x50d0
leaq -0x50(%rbp), %rdi
callq 0xabee
movl %ebx, %eax
leaq -0x28(%rbp), %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
jmp 0x1a5fd
jmp 0x1a5ee
jmp 0x1a5c8
jmp 0x1a5ee
jmp 0x1a5ee
jmp 0x1a5ee
jmp 0x1a5c8
movq %rax, %rbx
movq -0x70(%rbp), %rdi
leaq -0x60(%rbp), %rax
cmpq %rax, %rdi
je 0x1a5f1
movq -0x60(%rbp), %rsi
incq %rsi
callq 0x53c0
jmp 0x1a5f1
jmp 0x1a5ee
jmp 0x1a5ee
jmp 0x1a5ee
jmp 0x1a5ee
movq %rax, %rbx
leaq -0x298(%rbp), %rdi
callq 0x50d0
leaq -0x50(%rbp), %rdi
callq 0xabee
movq %rbx, %rdi
callq 0x56a0
nop