// File: /workspace/github_cpp_makefile_star2_O3/ivanzamanov[P]kmeans/src/kmeans/kmeans_main.cpp
// Function: processFile(char const*, char const*, ptree<int>&, list<article_entry*>&)
void processFile(const char* path, const char* name, ptree<int>& p, list<article_entry*> &entries) {
	if(*name == '.')
		return;
	int fd = open(path, O_RDONLY);
	if(fd < 0) {
		printf("Cannot open file %s\nCode = %d\n", path, fd);
		return;
	}
	char* fullData = 0;
	readFullData(fd, &fullData);
	close(fd);

	char buffer[4096];
	int offset = 0;
	
	hash<double> h;
	int* index_ptr = 0;
	int index = 0;
	while(readToken(fullData, offset, buffer, 4096)) {
		if(strlen(buffer) <= 3)
			continue;
		index_ptr = p.get(buffer);
		if(index_ptr == 0) {
			p.add(buffer, tokenCount);
			index = tokenCount;
			tokenCount++;
		} else {
			index = *index_ptr;
		}

		int tf = h.get(index, 0);
		tf++;
		h.insert(index, tf);
	}

	save(entries, h, name);

	delete fullData;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1048, %rsp           # imm = 0x1048
cmpb $0x2e, (%rsi)
je 0x2104
movq %rcx, %r12
movq %rdx, %r15
movq %rsi, %rbx
movq %rdi, %r14
xorl %r13d, %r13d
xorl %esi, %esi
xorl %eax, %eax
callq 0x1090
movl %eax, %ebp
testl %eax, %eax
js 0x2116
movq %r12, 0x38(%rsp)
leaq 0x30(%rsp), %r14
movq $0x0, (%r14)
movl %ebp, %edi
movq %r14, %rsi
callq 0x29e4
movl %ebp, %edi
callq 0x1180
leaq 0xc(%rsp), %r12
movl %r13d, (%r12)
movq $0x2, 0x18(%rsp)
movl $0x8, %edi
callq 0x1030
movq %rax, 0x28(%rsp)
movq $-0x1, (%rax)
movl $0x10, %edi
callq 0x1030
movq %rax, 0x20(%rsp)
movl %r13d, 0x8(%rsp)
movq (%r14), %rdi
leaq 0x40(%rsp), %rdx
movq %r12, %rsi
movl $0x1000, %ecx           # imm = 0x1000
callq 0x2909
testb %al, %al
je 0x20e8
leaq 0x40(%rsp), %r12
leaq 0xc(%rsp), %r13
leaq 0x8(%rsp), %r14
leaq 0x10(%rsp), %rbp
movq %r12, %rdi
callq 0x1070
cmpq $0x4, %rax
jb 0x20cb
movq %r15, %rdi
movq %r12, %rsi
callq 0x23e0
testq %rax, %rax
je 0x2026
movl (%rax), %ecx
jmp 0x2046
movl 0x30bc(%rip), %edx      # 0x50e8
movq %r15, %rdi
movq %r12, %rsi
callq 0x242e
movl 0x30ab(%rip), %ecx      # 0x50e8
leal 0x1(%rcx), %eax
movl %eax, 0x30a2(%rip)      # 0x50e8
movl %ecx, 0x8(%rsp)
movq $0x0, 0x10(%rsp)
movl 0x1c(%rsp), %eax
testl %eax, %eax
jle 0x208a
movq 0x28(%rsp), %rsi
xorl %edi, %edi
leal (%rdi,%rax), %edx
shrl %edx
movl (%rsi,%rdx,4), %r8d
cmpl %ecx, %r8d
je 0x209f
leal 0x1(%rdx), %r9d
cmpl %ecx, %r8d
cmovgel %edi, %r9d
cmovgl %edi, %r9d
cmovgl %edx, %eax
movl %r9d, %edi
cmpl %eax, %r9d
jl 0x2062
movl %eax, %edx
notl %edx
shlq $0x3, %rdx
addq 0x20(%rsp), %rdx
testl %eax, %eax
cmovnsq %rbp, %rdx
jmp 0x20a8
shlq $0x3, %rdx
addq 0x20(%rsp), %rdx
cvttsd2si (%rdx), %eax
incl %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x10(%rsp)
leaq 0x18(%rsp), %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0x24ac
movq 0x30(%rsp), %rdi
movq %r13, %rsi
movq %r12, %rdx
movl $0x1000, %ecx           # imm = 0x1000
callq 0x2909
testb %al, %al
jne 0x2000
leaq 0x18(%rsp), %rsi
movq 0x38(%rsp), %rdi
movq %rbx, %rdx
callq 0x1e08
movq 0x30(%rsp), %rdi
callq 0x10d0
addq $0x1048, %rsp           # imm = 0x1048
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xfab(%rip), %rdi       # 0x30c8
movq %r14, %rsi
movl %ebp, %edx
xorl %eax, %eax
addq $0x1048, %rsp           # imm = 0x1048
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1040