// File: /workspace/github_cpp_makefile_star2_O3/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 $0x248, %rsp            # imm = 0x248
movq %rsi, %rbx
movq %rdi, %r13
leaq -0x268(%rbp), %r14
movq %r14, %rdi
callq 0x3530
movq %r14, %rdi
movq %rbx, %rsi
movl $0x10, %edx
callq 0x3160
movq 0x18(%r13), %r14
leaq 0x8(%r13), %rax
movq %rax, -0x40(%rbp)
cmpq %rax, %r14
je 0x5305
movq $0x0, -0x38(%rbp)
leaq -0x50(%rbp), %rbx
movq %rbx, -0x60(%rbp)
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdx
addq %rsi, %rdx
leaq -0x60(%rbp), %rdi
callq 0x7a0c
cmpq $0x0, -0x58(%rbp)
je 0x5428
leaq 0x20(%r14), %rax
movq %rax, -0x68(%rbp)
movq -0x60(%rbp), %rax
movsbl (%rax), %ebx
movq 0x20(%r14), %r15
movq 0x28(%r14), %r12
testq %r12, %r12
je 0x51e0
xorl %eax, %eax
movsbl (%r15,%rax), %ecx
addl $-0x30, %ecx
cmpl $0x9, %ecx
ja 0x51d7
incq %rax
cmpq %rax, %r12
jne 0x51bd
jmp 0x5265
cmpq %rax, %r12
je 0x5265
movl %ebx, %edi
callq 0x34d0
testl %eax, %eax
sete %al
cmpb $0x28, %bl
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x52d8
leaq -0x268(%rbp), %rdi
movq %r15, %rsi
movq %r12, %rdx
leaq -0x50(%rbp), %rbx
callq 0x3340
movb $0x9, -0x29(%rbp)
movl $0x1, %edx
movq %rax, %rdi
leaq -0x29(%rbp), %rsi
callq 0x3340
movl 0x40(%r14), %esi
movq %rax, %rdi
callq 0x3550
movl $0x1, %edx
movq %rax, %rdi
leaq 0xfddd(%rip), %rsi      # 0x15020
callq 0x3340
movl 0x40(%r14), %r15d
movq %r13, %rdi
movq -0x68(%rbp), %rsi
callq 0x13dd8
movq %r13, %rdi
movq %rax, %rsi
callq 0x13e94
jmp 0x52cb
leaq -0x268(%rbp), %rdi
movq %r15, %rsi
movq %r12, %rdx
leaq -0x50(%rbp), %rbx
callq 0x3340
movb $0x9, -0x29(%rbp)
movl $0x1, %edx
movq %rax, %rdi
leaq -0x29(%rbp), %rsi
callq 0x3340
movl 0x40(%r14), %esi
movq %rax, %rdi
callq 0x3550
movl $0x1, %edx
movq %rax, %rdi
leaq 0xfd75(%rip), %rsi      # 0x15020
callq 0x3340
movl 0x40(%r14), %r15d
movq %r13, %rdi
movq -0x68(%rbp), %rsi
callq 0x13dd8
movq %r13, %rdi
movq %rax, %rsi
callq 0x13e94
movq -0x38(%rbp), %rax
addl %r15d, %eax
movq %rax, -0x38(%rbp)
jmp 0x52dc
leaq -0x50(%rbp), %rbx
movq -0x60(%rbp), %rdi
cmpq %rbx, %rdi
je 0x52ea
callq 0x32f0
movq %r14, %rdi
callq 0x3210
movq %rax, %r14
cmpq -0x40(%rbp), %rax
jne 0x517c
movq 0x18(%r13), %r14
jmp 0x530d
movq $0x0, -0x38(%rbp)
cmpq -0x40(%rbp), %r14
je 0x5382
leaq -0x268(%rbp), %r15
leaq -0x60(%rbp), %r12
leaq 0xfcfb(%rip), %r13      # 0x15020
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdx
movq %r15, %rdi
callq 0x3340
movb $0x9, -0x60(%rbp)
movl $0x1, %edx
movq %rax, %rdi
movq %r12, %rsi
callq 0x3340
movl 0x40(%r14), %esi
movq %rax, %rdi
callq 0x3550
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x3340
movq -0x38(%rbp), %rax
addl 0x40(%r14), %eax
movq %rax, -0x38(%rbp)
movq %r14, %rdi
callq 0x3210
movq %rax, %r14
cmpq -0x40(%rbp), %rax
jne 0x5325
movq 0x19c47(%rip), %rdi     # 0x1efd0
leaq 0x10020(%rip), %rsi     # 0x153b0
movl $0x11, %edx
callq 0x3340
movq 0x19c2f(%rip), %rdi     # 0x1efd0
movq -0x38(%rbp), %rsi
callq 0x3550
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x3300
movsbl %al, %esi
movq %rbx, %rdi
callq 0x3030
movq %rax, %rdi
callq 0x3200
leaq -0x268(%rbp), %rdi
callq 0x33f0
movq 0x19be1(%rip), %rax     # 0x1efc8
movq (%rax), %rcx
movq 0x18(%rax), %rax
leaq -0x260(%rbp), %rdi
movq %rcx, -0x8(%rdi)
movq -0x18(%rcx), %rcx
movq %rax, -0x268(%rbp,%rcx)
callq 0x3290
leaq -0x170(%rbp), %rdi
callq 0x30e0
addq $0x248, %rsp            # imm = 0x248
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x144a4(%rip), %rdi     # 0x198d3
xorl %esi, %esi
xorl %edx, %edx
xorl %eax, %eax
callq 0x3490
jmp 0x5449
jmp 0x5449
movq %rax, %r14
leaq -0x50(%rbp), %rbx
jmp 0x5451
jmp 0x5449
movq %rax, %r14
jmp 0x545f
movq %rax, %r14
movq -0x60(%rbp), %rdi
cmpq %rbx, %rdi
je 0x545f
callq 0x32f0
leaq -0x268(%rbp), %rdi
callq 0x3450
movq %r14, %rdi
callq 0x3560