// File: /workspace/github_cpp_makefile_star2_O2/IlyaSamoylov45[P]MapReduce-Project/main.cpp
// Function: wordCountPrint(std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, int, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, int>>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>)
void wordCountPrint(std::map<std::string, int> result, std::string path) {
  std::ofstream outputFile;
  outputFile.open (path);
  int wordCountFinal = 0;
  //first print numbers
  for(auto it = result.begin(); it != result.end(); it++){
    std::string str = it->first;
    char alphaCheck = str.at(0);
    if(is_number(it->first)){
      outputFile << it->first << '\t' << it->second << "\n";
      wordCountFinal += it->second;
      result.erase(it->first);
    } else if (isalpha(alphaCheck) == 0 && alphaCheck != '(') {
      outputFile << it->first << '\t' << it->second << "\n";
      wordCountFinal += it->second;
      result.erase(it->first);
      
    }
  }
  // next words
  for(auto it = result.begin(); it != result.end(); it++){

      outputFile << it->first << '\t' << it->second << "\n";
      wordCountFinal += it->second;
  }
  std::cout << "final word count " << wordCountFinal << std::endl;
  outputFile.close();
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x238, %rsp            # imm = 0x238
movq %rsi, %rbx
movq %rdi, %r12
leaq -0x258(%rbp), %r14
movq %r14, %rdi
callq 0x34b0
pushq $0x10
popq %rdx
movq %r14, %rdi
movq %rbx, %rsi
callq 0x3140
movq 0x18(%r12), %r15
movq %r12, -0x30(%rbp)
leaq 0x8(%r12), %rax
movq %rax, -0x38(%rbp)
xorl %ebx, %ebx
leaq -0x58(%rbp), %r14
cmpq -0x38(%rbp), %r15
je 0x4a7e
leaq 0x20(%r15), %r13
movq %r14, %rdi
movq %r13, %rsi
callq 0x3370
movq %r14, %r12
movq %r14, %rdi
xorl %esi, %esi
callq 0x3570
movq %rax, %r14
movq %r13, %rdi
callq 0x5e5c
testb %al, %al
je 0x4a08
leaq -0x258(%rbp), %rdi
movq %r13, %rsi
callq 0x3260
movq %rax, %rdi
pushq $0x9
popq %rsi
callq 0x32f0
movl 0x40(%r15), %esi
movq %rax, %rdi
callq 0x34d0
movq %rax, %rdi
leaq 0xd62f(%rip), %rsi      # 0x12020
callq 0x32b0
addl 0x40(%r15), %ebx
movq -0x30(%rbp), %rdi
movq %r13, %rsi
callq 0x11a26
jmp 0x4a63
movsbl (%r14), %r14d
movl %r14d, %edi
callq 0x3450
cmpl $0x28, %r14d
je 0x4a63
testl %eax, %eax
jne 0x4a63
leaq -0x258(%rbp), %rdi
movq %r13, %rsi
callq 0x3260
movq %rax, %rdi
pushq $0x9
popq %rsi
callq 0x32f0
movl 0x40(%r15), %esi
movq %rax, %rdi
callq 0x34d0
movq %rax, %rdi
leaq 0xd5d2(%rip), %rsi      # 0x12020
callq 0x32b0
addl 0x40(%r15), %ebx
movq -0x30(%rbp), %rdi
movq %r13, %rsi
callq 0x11a26
movq %r12, %r14
movq %r12, %rdi
callq 0x3120
movq %r15, %rdi
callq 0x31e0
movq %rax, %r15
jmp 0x498c
movq -0x30(%rbp), %rax
movq 0x18(%rax), %r13
leaq -0x258(%rbp), %r12
pushq $0x9
popq %r15
leaq 0xd588(%rip), %r14      # 0x12020
cmpq -0x38(%rbp), %r13
je 0x4add
leaq 0x20(%r13), %rsi
movq %r12, %rdi
callq 0x3260
movq %rax, %rdi
movl %r15d, %esi
callq 0x32f0
movl 0x40(%r13), %esi
movq %rax, %rdi
callq 0x34d0
movq %rax, %rdi
movq %r14, %rsi
callq 0x32b0
addl 0x40(%r13), %ebx
movq %r13, %rdi
callq 0x31e0
movq %rax, %r13
jmp 0x4a98
movq 0x1a4e4(%rip), %rdi     # 0x1efc8
leaq 0xd8c5(%rip), %rsi      # 0x123b0
callq 0x32b0
movq %rax, %rdi
movl %ebx, %esi
callq 0x34d0
movq %rax, %rdi
callq 0x3150
leaq -0x258(%rbp), %rdi
callq 0x3390
leaq -0x258(%rbp), %rdi
callq 0x33f0
addq $0x238, %rsp            # imm = 0x238
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4b32
jmp 0x4b32
jmp 0x4b32
movq %rax, %rbx
jmp 0x4b43
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x3120
leaq -0x258(%rbp), %rdi
callq 0x33f0
movq %rbx, %rdi
callq 0x34e0