// File: /workspace/github_cpp_makefile_star2_O1/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 0x2155
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 0x2167
movq %r12, 0x30(%rsp)
leaq 0x10(%rsp), %r14
movq $0x0, (%r14)
movl %ebp, %edi
movq %r14, %rsi
callq 0x2ab6
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 0x29d9
testb %al, %al
je 0x2134
leaq 0x40(%rsp), %r12
leaq 0xc(%rsp), %r13
leaq 0x8(%rsp), %r14
leaq 0x38(%rsp), %rbp
movq %r12, %rdi
callq 0x1070
cmpq $0x4, %rax
jb 0x2117
movq %r15, %rdi
movq %r12, %rsi
callq 0x243c
testq %rax, %rax
je 0x207e
movl (%rax), %eax
movl %eax, 0x8(%rsp)
jmp 0x20a1
movl 0x3064(%rip), %edx      # 0x50e8
movq %r15, %rdi
movq %r12, %rsi
callq 0x248a
movl 0x3053(%rip), %eax      # 0x50e8
movl %eax, 0x8(%rsp)
incl %eax
movl %eax, 0x3047(%rip)      # 0x50e8
movl 0x1c(%rsp), %eax
testl %eax, %eax
jle 0x20dc
movq 0x28(%rsp), %rcx
xorl %edi, %edi
movl 0x8(%rsp), %edx
leal (%rdi,%rax), %esi
shrl %esi
movl (%rcx,%rsi,4), %r8d
cmpl %edx, %r8d
je 0x20e0
leal 0x1(%rsi), %r9d
cmpl %edx, %r8d
cmovgel %edi, %r9d
cmovgl %edi, %r9d
cmovgl %esi, %eax
movl %r9d, %edi
cmpl %eax, %r9d
jl 0x20b4
notl %eax
movl %eax, %esi
movsd 0xfd8(%rip), %xmm0      # 0x30c0
testl %esi, %esi
js 0x2101
movq 0x20(%rsp), %rax
movl %esi, %ecx
cvttsd2si (%rax,%rcx,8), %eax
incl %eax
xorps %xmm0, %xmm0
cvtsi2sd %eax, %xmm0
movsd %xmm0, 0x38(%rsp)
leaq 0x18(%rsp), %rdi
movq %r14, %rsi
movq %rbp, %rdx
callq 0x2526
movq 0x10(%rsp), %rdi
movq %r13, %rsi
movq %r12, %rdx
movl $0x1000, %ecx           # imm = 0x1000
callq 0x29d9
testb %al, %al
jne 0x2054
leaq 0x18(%rsp), %rsi
movq 0x30(%rsp), %rdi
movq %rbx, %rdx
callq 0x1e5c
movq 0x10(%rsp), %rdi
testq %rdi, %rdi
je 0x2155
callq 0x10d0
addq $0x1048, %rsp           # imm = 0x1048
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0xf5a(%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