// File: /workspace/github_cpp_makefile_star2_O3/IlyaSamoylov45[P]MapReduce-Project/main.cpp
// Function: map_words_to_array(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, int)
std::vector<std::string> map_words_to_array(std::string file, int total_maps, int total_words) {
  int words_per_map = total_words/total_maps;
  int remaining_words = total_words%total_maps;


  std::string word;
  std::ifstream infile(file.c_str());

  int count = words_per_map;
  int current_map = 0;
  std::vector<std::string> ary(total_maps);

  if(remaining_words > 0){
    count++;
    remaining_words--;
  }
  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());
    std::transform(word.begin(), word.end(), word.begin(), ::tolower);
    if(word != ""){
      if(count > 0){
        ary[current_map] = ary[current_map] + " " + word;
        //std::cout << ary[current_map] << std::endl;
        count--;
      }
      else{
        //std::cout <<" else" << std::endl;
        //std::cout << ary[current_map] << std::endl;
        count = words_per_map;
        if(remaining_words > 0){
          count++;
          remaining_words--;
        }
        current_map++;
        ary[current_map] = ary[current_map] + " " +  word;
        //std::cout << ary[current_map] << std::endl;
        count--;
      }
    }
  }
  //std::cout << ary[current_map] << std::endl;
  return ary;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x298, %rsp            # imm = 0x298
movl %ecx, %eax
movl %edx, %r14d
movq %rdi, %rbx
cltd
idivl %r14d
movl %eax, %r15d
movl %edx, %r12d
leaq -0x48(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq (%rsi), %rsi
leaq -0x2c0(%rbp), %rdi
movl $0x8, %edx
callq 0x35a0
movslq %r14d, %rsi
leaq -0xb0(%rbp), %rdx
movq %rbx, -0x38(%rbp)
movq %rbx, %rdi
callq 0x71c6
leal 0x1(%r15), %ecx
xorl %eax, %eax
testl %r12d, %r12d
setg %al
movq %r15, -0xb8(%rbp)
movl %r15d, %edx
movl %ecx, -0x8c(%rbp)
cmovgl %ecx, %edx
movl %edx, -0x2c(%rbp)
subl %eax, %r12d
movl %r12d, -0x5c(%rbp)
leaq -0xa0(%rbp), %rbx
xorl %r14d, %r14d
leaq -0x58(%rbp), %r15
movl %r14d, %r14d
movq %r14, %rax
shlq $0x5, %rax
movq %rax, -0x68(%rbp)
leaq -0x2c0(%rbp), %rdi
movq %r15, %rsi
callq 0x33a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x6351
movq %r14, %r13
movq %rbx, %r12
movq -0x50(%rbp), %rax
testq %rax, %rax
je 0x6142
movq -0x58(%rbp), %rcx
xorl %edx, %edx
cmpb $0x2d, (%rcx,%rdx)
jne 0x603e
movb $0x20, (%rcx,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x6034
movq -0x50(%rbp), %rax
testq %rax, %rax
je 0x6142
movq -0x58(%rbp), %rcx
xorl %edx, %edx
cmpb $0x3b, (%rcx,%rdx)
jne 0x6063
movb $0x20, (%rcx,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x6059
movq -0x50(%rbp), %rax
testq %rax, %rax
je 0x6142
movq -0x58(%rbp), %rcx
xorl %edx, %edx
cmpb $0x2e, (%rcx,%rdx)
jne 0x6088
movb $0x20, (%rcx,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x607e
movq -0x50(%rbp), %rax
testq %rax, %rax
je 0x6142
movq -0x58(%rbp), %rcx
xorl %edx, %edx
cmpb $0x3a, (%rcx,%rdx)
jne 0x60ad
movb $0x20, (%rcx,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x60a3
movq -0x50(%rbp), %rax
testq %rax, %rax
je 0x6142
movq -0x58(%rbp), %rcx
xorl %edx, %edx
cmpb $0x21, (%rcx,%rdx)
jne 0x60d2
movb $0x20, (%rcx,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x60c8
movq -0x50(%rbp), %rax
testq %rax, %rax
je 0x6142
movq -0x58(%rbp), %rcx
xorl %edx, %edx
cmpb $0x29, (%rcx,%rdx)
jne 0x60f3
movb $0x20, (%rcx,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x60e9
movq -0x50(%rbp), %rax
testq %rax, %rax
je 0x6142
movq -0x58(%rbp), %rcx
xorl %edx, %edx
cmpb $0x2c, (%rcx,%rdx)
jne 0x6114
movb $0x20, (%rcx,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x610a
movq -0x50(%rbp), %rbx
testq %rbx, %rbx
je 0x6142
movq -0x58(%rbp), %r15
xorl %r14d, %r14d
movsbl (%r15,%r14), %edi
callq 0x3410
movb %al, (%r15,%r14)
incq %r14
cmpq %r14, %rbx
jne 0x612c
leaq -0x58(%rbp), %r15
movq %r15, %rdi
leaq 0xeed1(%rip), %rsi      # 0x15021
callq 0x30b0
testl %eax, %eax
movq %r12, %rbx
movq %r13, %r14
leaq -0x88(%rbp), %r12
je 0x5ffa
cmpl $0x0, -0x2c(%rbp)
jle 0x624b
movq -0x38(%rbp), %rax
movq (%rax), %rax
leaq -0x78(%rbp), %rcx
movq %rcx, -0x88(%rbp)
movq -0x68(%rbp), %rcx
movq (%rax,%rcx), %rsi
movq 0x8(%rax,%rcx), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x7a0c
movq %r12, %rdi
leaq 0xef8c(%rip), %rsi      # 0x15134
callq 0x35f0
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq %r12, %rdi
callq 0x30d0
movq %rbx, -0xb0(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x61e6
movq %rdx, -0xb0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xa0(%rbp)
jmp 0x61ec
movups (%rcx), %xmm0
movups %xmm0, (%rbx)
movq 0x8(%rax), %rdx
movq %rdx, -0xa8(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq -0x38(%rbp), %rax
movq (%rax), %rdi
addq -0x68(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x3380
movq -0xb0(%rbp), %rdi
cmpq %rbx, %rdi
je 0x622e
callq 0x32f0
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x6243
callq 0x32f0
decl -0x2c(%rbp)
jmp 0x5ffa
xorl %r15d, %r15d
cmpl $0x0, -0x5c(%rbp)
movq -0xb8(%rbp), %rax
cmovgl -0x8c(%rbp), %eax
movl %eax, -0x2c(%rbp)
setg -0x68(%rbp)
leaq 0x1(%r14), %rdx
movq -0x38(%rbp), %rax
movq (%rax), %rax
shlq $0x5, %rdx
leaq -0x78(%rbp), %rcx
movq %rcx, -0x88(%rbp)
movq (%rax,%rdx), %rsi
movq %rdx, %r13
movq 0x8(%rax,%rdx), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x7a0c
movq %r12, %rdi
leaq 0xee92(%rip), %rsi      # 0x15134
callq 0x35f0
movq -0x58(%rbp), %rsi
movq -0x50(%rbp), %rdx
movq %r12, %rdi
callq 0x30d0
movq %rbx, -0xb0(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x62e0
movq %rdx, -0xb0(%rbp)
movq (%rcx), %rdx
movq %rdx, -0xa0(%rbp)
jmp 0x62e6
movups (%rcx), %xmm0
movups %xmm0, (%rbx)
movq 0x8(%rax), %rdx
movq %rdx, -0xa8(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq -0x38(%rbp), %rax
addq (%rax), %r13
movq %r13, %rdi
leaq -0xb0(%rbp), %rsi
callq 0x3380
movq -0xb0(%rbp), %rdi
cmpq %rbx, %rdi
je 0x6327
callq 0x32f0
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x633c
callq 0x32f0
movb -0x68(%rbp), %al
movb %al, %r15b
subl %r15d, -0x5c(%rbp)
incl %r14d
decl -0x2c(%rbp)
jmp 0x5fe8
leaq -0x2c0(%rbp), %rdi
callq 0x3080
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x636f
callq 0x32f0
movq -0x38(%rbp), %rax
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x638d
jmp 0x638d
jmp 0x63b3
jmp 0x638d
movq %rax, %r14
movq -0x88(%rbp), %rdi
leaq -0x78(%rbp), %rax
cmpq %rax, %rdi
je 0x63b6
callq 0x32f0
jmp 0x63b6
jmp 0x63b3
movq %rax, %r14
jmp 0x63bf
movq %rax, %r14
jmp 0x63cb
movq %rax, %r14
movq -0x38(%rbp), %rdi
callq 0x6e22
leaq -0x2c0(%rbp), %rdi
callq 0x3080
movq -0x58(%rbp), %rdi
leaq -0x48(%rbp), %rax
cmpq %rax, %rdi
je 0x63dd
callq 0x32f0
movq %r14, %rdi
callq 0x3560