// File: IlyaSamoylov45[P]MapReduce-Project/main.cpp
// Function: count_words(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
int count_words(std::string file){
  int count = 0;
  std::string word;
  std::ifstream infile(file.c_str());
  while(infile >> word) {
    std::replace( word.begin(), word.end(), '-', ' ');
    std::replace( word.begin(), word.end(), ';', ' ');
    std::replace( word.begin(), word.end(), '.', ' ');
    std::replace( word.begin(), word.end(), ':', ' ');
    std::replace( word.begin(), word.end(), '!', ' ');
    std::replace( word.begin(), word.end(), ')', ' ');
    std::replace( word.begin(), word.end(), ',', ' ');
    //std::replace( word.begin(), word.end(), ';', ' ');
    //word.erase(std::remove_if(word.begin(), word.end(), remove_char), word.end());
    if(word != ""){
      count++;
    }

    //std::cout << "word is: " << word << " " << count << "\n";
  }
  return count;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x350, %rsp            # imm = 0x350
movq %rdi, -0x2f8(%rbp)
movq %rdi, -0x8(%rbp)
movl $0x0, -0xc(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x4450
movq -0x2f8(%rbp), %rdi
callq 0x4110
movq %rax, %rsi
leaq -0x238(%rbp), %rdi
movl $0x8, %edx
callq 0x4600
jmp 0x7f38
jmp 0x7f3a
leaq -0x238(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x4400
movq %rax, -0x300(%rbp)
jmp 0x7f53
movq -0x300(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x43f0
movb %al, -0x301(%rbp)
jmp 0x7f71
movb -0x301(%rbp), %al
testb $0x1, %al
jne 0x7f80
jmp 0x8265
leaq -0x30(%rbp), %rdi
movq %rdi, -0x310(%rbp)
callq 0x42a0
movq -0x310(%rbp), %rdi
movq %rax, -0x250(%rbp)
callq 0x41b0
movq %rax, -0x258(%rbp)
movb $0x2d, -0x259(%rbp)
movb $0x20, -0x25a(%rbp)
movq -0x250(%rbp), %rdi
movq -0x258(%rbp), %rsi
leaq -0x259(%rbp), %rdx
leaq -0x25a(%rbp), %rcx
callq 0xa360
jmp 0x7fdb
leaq -0x30(%rbp), %rdi
movq %rdi, -0x318(%rbp)
callq 0x42a0
movq -0x318(%rbp), %rdi
movq %rax, -0x268(%rbp)
callq 0x41b0
movq %rax, -0x270(%rbp)
movb $0x3b, -0x271(%rbp)
movb $0x20, -0x272(%rbp)
movq -0x268(%rbp), %rdi
movq -0x270(%rbp), %rsi
leaq -0x271(%rbp), %rdx
leaq -0x272(%rbp), %rcx
callq 0xa360
jmp 0x8036
leaq -0x30(%rbp), %rdi
movq %rdi, -0x320(%rbp)
callq 0x42a0
movq -0x320(%rbp), %rdi
movq %rax, -0x280(%rbp)
callq 0x41b0
movq %rax, -0x288(%rbp)
movb $0x2e, -0x289(%rbp)
movb $0x20, -0x28a(%rbp)
movq -0x280(%rbp), %rdi
movq -0x288(%rbp), %rsi
leaq -0x289(%rbp), %rdx
leaq -0x28a(%rbp), %rcx
callq 0xa360
jmp 0x8091
leaq -0x30(%rbp), %rdi
movq %rdi, -0x328(%rbp)
callq 0x42a0
movq -0x328(%rbp), %rdi
movq %rax, -0x298(%rbp)
callq 0x41b0
movq %rax, -0x2a0(%rbp)
movb $0x3a, -0x2a1(%rbp)
movb $0x20, -0x2a2(%rbp)
movq -0x298(%rbp), %rdi
movq -0x2a0(%rbp), %rsi
leaq -0x2a1(%rbp), %rdx
leaq -0x2a2(%rbp), %rcx
callq 0xa360
jmp 0x80ec
leaq -0x30(%rbp), %rdi
movq %rdi, -0x330(%rbp)
callq 0x42a0
movq -0x330(%rbp), %rdi
movq %rax, -0x2b0(%rbp)
callq 0x41b0
movq %rax, -0x2b8(%rbp)
movb $0x21, -0x2b9(%rbp)
movb $0x20, -0x2ba(%rbp)
movq -0x2b0(%rbp), %rdi
movq -0x2b8(%rbp), %rsi
leaq -0x2b9(%rbp), %rdx
leaq -0x2ba(%rbp), %rcx
callq 0xa360
jmp 0x8147
leaq -0x30(%rbp), %rdi
movq %rdi, -0x338(%rbp)
callq 0x42a0
movq -0x338(%rbp), %rdi
movq %rax, -0x2c8(%rbp)
callq 0x41b0
movq %rax, -0x2d0(%rbp)
movb $0x29, -0x2d1(%rbp)
movb $0x20, -0x2d2(%rbp)
movq -0x2c8(%rbp), %rdi
movq -0x2d0(%rbp), %rsi
leaq -0x2d1(%rbp), %rdx
leaq -0x2d2(%rbp), %rcx
callq 0xa360
jmp 0x81a2
leaq -0x30(%rbp), %rdi
movq %rdi, -0x340(%rbp)
callq 0x42a0
movq -0x340(%rbp), %rdi
movq %rax, -0x2e0(%rbp)
callq 0x41b0
movq %rax, -0x2e8(%rbp)
movb $0x2c, -0x2e9(%rbp)
movb $0x20, -0x2ea(%rbp)
movq -0x2e0(%rbp), %rdi
movq -0x2e8(%rbp), %rsi
leaq -0x2e9(%rbp), %rdx
leaq -0x2ea(%rbp), %rcx
callq 0xa360
jmp 0x81fd
leaq 0x1ffe9(%rip), %rsi     # 0x281ed
leaq -0x30(%rbp), %rdi
callq 0xa450
movb %al, -0x341(%rbp)
jmp 0x8215
movb -0x341(%rbp), %al
testb $0x1, %al
jne 0x8221
jmp 0x8260
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x8260
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
jmp 0x8292
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x240(%rbp)
movl %eax, -0x244(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x4090
jmp 0x8292
jmp 0x7f3a
movl -0xc(%rbp), %eax
movl %eax, -0x348(%rbp)
leaq -0x238(%rbp), %rdi
callq 0x4090
leaq -0x30(%rbp), %rdi
callq 0x41f0
movl -0x348(%rbp), %eax
addq $0x350, %rsp            # imm = 0x350
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x41f0
movq -0x240(%rbp), %rdi
callq 0x45c0
nopw (%rax,%rax)