// File: /workspace/github_cpp_makefile_star2_O2/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 $0x2a8, %rsp            # imm = 0x2A8
movl %ecx, %eax
movl %edx, %ebx
movq %rdi, %r14
cltd
idivl %ebx
movl %eax, %r15d
movl %edx, %r12d
leaq -0x58(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
movq (%rsi), %rsi
leaq -0x2c8(%rbp), %rdi
pushq $0x8
popq %rdx
callq 0x3510
movslq %ebx, %rsi
leaq -0xb0(%rbp), %rdx
movq %r14, -0x38(%rbp)
movq %r14, %rdi
callq 0x62f8
leal 0x1(%r15), %ecx
xorl %eax, %eax
testl %r12d, %r12d
setg %al
movq %r15, -0xb8(%rbp)
movl %r15d, %edx
movl %ecx, -0x6c(%rbp)
cmovgl %ecx, %edx
movl %edx, -0x2c(%rbp)
subl %eax, %r12d
movl %r12d, -0x3c(%rbp)
xorl %ebx, %ebx
leaq -0x68(%rbp), %r12
leaq -0xb0(%rbp), %r13
movl %ebx, %ebx
movq %rbx, %rax
shlq $0x5, %rax
movq %rax, -0x48(%rbp)
movq %rbx, -0xc0(%rbp)
leaq -0x2c8(%rbp), %rdi
movq %r12, %rsi
callq 0x3340
movq (%rax), %rcx
movq -0x18(%rcx), %rcx
testb $0x5, 0x20(%rax,%rcx)
jne 0x56dc
movq %r12, %r15
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rsi
addq %rdi, %rsi
movb $0x2d, -0xb0(%rbp)
movb $0x20, %bl
movb %bl, -0x90(%rbp)
movq %r13, %rdx
leaq -0x90(%rbp), %r12
movq %r12, %rcx
callq 0x6349
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rsi
addq %rdi, %rsi
movb $0x3b, -0xb0(%rbp)
movb %bl, -0x90(%rbp)
movq %r13, %rdx
movq %r12, %rcx
callq 0x6349
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rsi
addq %rdi, %rsi
movb $0x2e, -0xb0(%rbp)
movb %bl, -0x90(%rbp)
movq %r13, %rdx
movq %r12, %rcx
callq 0x6349
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rsi
addq %rdi, %rsi
movb $0x3a, -0xb0(%rbp)
movb %bl, -0x90(%rbp)
movq %r13, %rdx
movq %r12, %rcx
callq 0x6349
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rsi
addq %rdi, %rsi
movb $0x21, -0xb0(%rbp)
movb %bl, -0x90(%rbp)
movq %r13, %rdx
movq %r12, %rcx
callq 0x6349
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rsi
addq %rdi, %rsi
movb $0x29, -0xb0(%rbp)
movb %bl, -0x90(%rbp)
movq %r13, %rdx
movq %r12, %rcx
callq 0x6349
movq -0x68(%rbp), %rdi
movq -0x60(%rbp), %rsi
addq %rdi, %rsi
movb $0x2c, -0xb0(%rbp)
movb %bl, -0x90(%rbp)
movq %r13, %r14
movq %r13, %rdx
movq %r12, %rcx
callq 0x6349
movq -0x68(%rbp), %r12
movq -0x60(%rbp), %r13
xorl %ebx, %ebx
cmpq %rbx, %r13
je 0x55d6
movsbl (%r12,%rbx), %edi
callq 0x33b0
movb %al, (%r12,%rbx)
incq %rbx
jmp 0x55be
movq %r15, %r12
movq %r15, %rdi
leaq 0xca3e(%rip), %rsi      # 0x12021
callq 0x6363
movq -0xc0(%rbp), %rbx
movq %r14, %r13
testb %al, %al
je 0x548f
cmpl $0x0, -0x2c(%rbp)
jle 0x565a
movq -0x38(%rbp), %rax
movq (%rax), %rsi
addq -0x48(%rbp), %rsi
leaq -0x90(%rbp), %r14
movq %r14, %rdi
leaq 0xcb18(%rip), %rdx      # 0x12134
callq 0x6399
movq %r13, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x6370
movq -0x38(%rbp), %rax
movq (%rax), %rdi
addq -0x48(%rbp), %rdi
movq %r13, %rsi
callq 0x3320
movq %r13, %rdi
callq 0x3120
movq %r14, %rdi
callq 0x3120
decl -0x2c(%rbp)
jmp 0x548f
cmpl $0x0, -0x3c(%rbp)
setg -0x48(%rbp)
movq -0xb8(%rbp), %rax
cmovgl -0x6c(%rbp), %eax
movl %eax, -0x2c(%rbp)
leaq 0x1(%rbx), %r15
shlq $0x5, %r15
movq -0x38(%rbp), %rax
movq (%rax), %rsi
addq %r15, %rsi
leaq -0x90(%rbp), %r14
movq %r14, %rdi
leaq 0xcaa1(%rip), %rdx      # 0x12134
callq 0x6399
movq %r13, %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x6370
xorl %eax, %eax
movb -0x48(%rbp), %cl
movb %cl, %al
subl %eax, -0x3c(%rbp)
incl %ebx
movq -0x38(%rbp), %rax
addq (%rax), %r15
movq %r15, %rdi
movq %r13, %rsi
callq 0x3320
movq %r13, %rdi
callq 0x3120
movq %r14, %rdi
callq 0x3120
decl -0x2c(%rbp)
jmp 0x547b
leaq -0x2c8(%rbp), %rdi
callq 0x3070
leaq -0x68(%rbp), %rdi
callq 0x3120
movq -0x38(%rbp), %rax
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x570b
jmp 0x5728
movq %rax, %rbx
leaq -0x90(%rbp), %rdi
callq 0x3120
jmp 0x572b
jmp 0x5728
movq %rax, %rbx
jmp 0x5734
movq %rax, %rbx
jmp 0x5740
movq %rax, %rbx
movq -0x38(%rbp), %rdi
callq 0x5fd4
leaq -0x2c8(%rbp), %rdi
callq 0x3070
leaq -0x68(%rbp), %rdi
callq 0x3120
movq %rbx, %rdi
callq 0x34e0