// File: /workspace/github_cpp_makefile_star2_O1/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, %ebx
movq %rdi, %r14
cltd
idivl %ebx
movl %eax, %r15d
movl %edx, %r12d
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq (%rsi), %rsi
leaq -0x2b8(%rbp), %rdi
movl $0x8, %edx
callq 0x35a0
movslq %ebx, %rsi
leaq -0xa8(%rbp), %rdx
movq %r14, -0x58(%rbp)
movq %r14, %rdi
callq 0x7300
leal 0x1(%r15), %ecx
xorl %eax, %eax
testl %r12d, %r12d
setg %al
movq %r15, -0xb0(%rbp)
movl %r15d, %edx
movl %ecx, -0x84(%rbp)
cmovgl %ecx, %edx
movl %edx, -0x30(%rbp)
subl %eax, %r12d
movl %r12d, -0x5c(%rbp)
leaq -0x98(%rbp), %r14
xorl %r15d, %r15d
leaq -0x50(%rbp), %rbx
movl %r15d, %r15d
leaq -0x2b8(%rbp), %rdi
movq %rbx, %rsi
callq 0x33a0
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x6318
movq -0x48(%rbp), %rax
testq %rax, %rax
je 0x6021
movq -0x50(%rbp), %rcx
xorl %edx, %edx
cmpb $0x2d, (%rcx,%rdx)
jne 0x6019
movb $0x20, (%rcx,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x600f
movq -0x48(%rbp), %rax
testq %rax, %rax
je 0x6042
movq -0x50(%rbp), %rcx
xorl %edx, %edx
cmpb $0x3b, (%rcx,%rdx)
jne 0x603a
movb $0x20, (%rcx,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x6030
movq -0x48(%rbp), %rax
testq %rax, %rax
je 0x6063
movq -0x50(%rbp), %rcx
xorl %edx, %edx
cmpb $0x2e, (%rcx,%rdx)
jne 0x605b
movb $0x20, (%rcx,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x6051
movq -0x48(%rbp), %rax
testq %rax, %rax
je 0x6084
movq -0x50(%rbp), %rcx
xorl %edx, %edx
cmpb $0x3a, (%rcx,%rdx)
jne 0x607c
movb $0x20, (%rcx,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x6072
movq -0x48(%rbp), %rax
testq %rax, %rax
je 0x60a5
movq -0x50(%rbp), %rcx
xorl %edx, %edx
cmpb $0x21, (%rcx,%rdx)
jne 0x609d
movb $0x20, (%rcx,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x6093
movq %r14, %r12
movq -0x48(%rbp), %rax
testq %rax, %rax
je 0x60c9
movq -0x50(%rbp), %rcx
xorl %edx, %edx
cmpb $0x29, (%rcx,%rdx)
jne 0x60c1
movb $0x20, (%rcx,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x60b7
movq %r15, %r13
movq -0x48(%rbp), %rax
testq %rax, %rax
je 0x60ed
movq -0x50(%rbp), %rcx
xorl %edx, %edx
cmpb $0x2c, (%rcx,%rdx)
jne 0x60e5
movb $0x20, (%rcx,%rdx)
incq %rdx
cmpq %rdx, %rax
jne 0x60db
movq -0x48(%rbp), %rbx
testq %rbx, %rbx
je 0x6113
movq -0x50(%rbp), %r15
xorl %r14d, %r14d
movsbl (%r15,%r14), %edi
callq 0x3410
movb %al, (%r15,%r14)
incq %r14
cmpq %r14, %rbx
jne 0x60fd
leaq -0x50(%rbp), %rbx
movq %rbx, %rdi
leaq 0xff00(%rip), %rsi      # 0x16021
callq 0x30b0
testl %eax, %eax
movq %r12, %r14
movq %r13, %r15
leaq -0x80(%rbp), %r12
je 0x5fdf
cmpl $0x0, -0x30(%rbp)
jle 0x621a
movq -0x58(%rbp), %rax
movq (%rax), %rax
movq %r15, %rbx
shlq $0x5, %rbx
leaq -0x70(%rbp), %rcx
movq %rcx, -0x80(%rbp)
movq (%rax,%rbx), %rsi
movq 0x8(%rax,%rbx), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x7b88
movq %r12, %rdi
leaq 0xffbe(%rip), %rsi      # 0x16134
callq 0x35f0
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq %r12, %rdi
callq 0x30d0
movq %r14, -0xa8(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x61b4
movq %rdx, -0xa8(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x98(%rbp)
jmp 0x61bb
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
movq %rdx, -0xa0(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq -0x58(%rbp), %rax
addq (%rax), %rbx
movq %rbx, %rdi
leaq -0xa8(%rbp), %rsi
callq 0x3380
movq -0xa8(%rbp), %rdi
cmpq %r14, %rdi
je 0x61fc
callq 0x32f0
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
leaq -0x50(%rbp), %rbx
je 0x6212
callq 0x32f0
decl -0x30(%rbp)
jmp 0x5fdf
xorl %ebx, %ebx
cmpl $0x0, -0x5c(%rbp)
movq -0xb0(%rbp), %rax
cmovgl -0x84(%rbp), %eax
movl %eax, -0x30(%rbp)
setg -0x29(%rbp)
leaq 0x1(%r15), %rdx
movq -0x58(%rbp), %rax
movq (%rax), %rax
shlq $0x5, %rdx
leaq -0x70(%rbp), %rcx
movq %rcx, -0x80(%rbp)
movq (%rax,%rdx), %rsi
movq %rdx, %r13
movq 0x8(%rax,%rdx), %rdx
addq %rsi, %rdx
movq %r12, %rdi
callq 0x7b88
movq %r12, %rdi
leaq 0xfec7(%rip), %rsi      # 0x16134
callq 0x35f0
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq %r12, %rdi
callq 0x30d0
movq %r14, -0xa8(%rbp)
movq (%rax), %rdx
movq %rax, %rcx
addq $0x10, %rcx
cmpq %rcx, %rdx
je 0x62ab
movq %rdx, -0xa8(%rbp)
movq (%rcx), %rdx
movq %rdx, -0x98(%rbp)
jmp 0x62b2
movups (%rcx), %xmm0
movups %xmm0, (%r14)
movq 0x8(%rax), %rdx
movq %rdx, -0xa0(%rbp)
movq %rcx, (%rax)
movq $0x0, 0x8(%rax)
movb $0x0, 0x10(%rax)
movq -0x58(%rbp), %rax
addq (%rax), %r13
movq %r13, %rdi
leaq -0xa8(%rbp), %rsi
callq 0x3380
movq -0xa8(%rbp), %rdi
cmpq %r14, %rdi
je 0x62f3
callq 0x32f0
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x6305
callq 0x32f0
movb -0x29(%rbp), %al
movb %al, %bl
subl %ebx, -0x5c(%rbp)
incl %r15d
decl -0x30(%rbp)
jmp 0x5fd8
leaq -0x2b8(%rbp), %rdi
callq 0x3080
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x6336
callq 0x32f0
movq -0x58(%rbp), %rax
addq $0x298, %rsp            # imm = 0x298
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x6354
jmp 0x6354
jmp 0x6377
jmp 0x6354
movq %rax, %r14
movq -0x80(%rbp), %rdi
leaq -0x70(%rbp), %rax
cmpq %rax, %rdi
je 0x637a
callq 0x32f0
jmp 0x637a
jmp 0x6377
movq %rax, %r14
jmp 0x6383
movq %rax, %r14
jmp 0x638f
movq %rax, %r14
movq -0x58(%rbp), %rdi
callq 0x6f70
leaq -0x2b8(%rbp), %rdi
callq 0x3080
movq -0x50(%rbp), %rdi
leaq -0x40(%rbp), %rax
cmpq %rax, %rdi
je 0x63a1
callq 0x32f0
movq %r14, %rdi
callq 0x3560