// File: /workspace/github_cpp_makefile_star2_O1/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, %r12
leaq -0x268(%rbp), %r14
movq %r14, %rdi
callq 0x3530
movq %r14, %rdi
movq %rbx, %rsi
movl $0x10, %edx
callq 0x3160
movq 0x18(%r12), %r15
movq %r12, -0x38(%rbp)
leaq 0x8(%r12), %rax
movq %rax, -0x40(%rbp)
cmpq %rax, %r15
je 0x530b
movl $0x0, -0x30(%rbp)
leaq -0x58(%rbp), %r13
movq %r13, -0x68(%rbp)
movq 0x20(%r15), %rsi
movq 0x28(%r15), %rdx
addq %rsi, %rdx
leaq -0x68(%rbp), %rdi
callq 0x7b88
movq -0x60(%rbp), %rdx
testq %rdx, %rdx
je 0x5432
movq 0x20(%r15), %r14
movq 0x28(%r15), %r12
leaq (%r14,%r12), %rax
movq %r14, %rcx
testq %r12, %r12
je 0x51cf
movq %r12, %rdx
movq %r14, %rcx
movsbl (%rcx), %esi
addl $-0x30, %esi
cmpl $0x9, %esi
ja 0x51cf
incq %rcx
decq %rdx
jne 0x51b9
movq %rax, %rcx
leaq 0x20(%r15), %rdx
movq %rdx, -0x48(%rbp)
testq %r12, %r12
sete %dl
cmpq %rax, %rcx
setne %al
orb %dl, %al
jne 0x5250
leaq -0x268(%rbp), %rdi
movq %r14, %rsi
movq %r12, %rdx
callq 0x3340
movb $0x9, -0x29(%rbp)
movl $0x1, %edx
movq %rax, %rdi
leaq -0x29(%rbp), %rsi
callq 0x3340
movl 0x40(%r15), %esi
movq %rax, %rdi
callq 0x3550
movl $0x1, %edx
movq %rax, %rdi
leaq 0x10df7(%rip), %rsi     # 0x16020
callq 0x3340
movl 0x40(%r15), %r14d
movq -0x38(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x14e54
movq -0x38(%rbp), %rdi
movq %rax, %rsi
callq 0x14f06
jmp 0x52dd
movq %r13, %rbx
movq -0x68(%rbp), %rax
movsbl (%rax), %r13d
movl %r13d, %edi
callq 0x34d0
testl %eax, %eax
sete %al
cmpb $0x28, %r13b
setne %cl
andb %al, %cl
cmpb $0x1, %cl
jne 0x52e3
leaq -0x268(%rbp), %rdi
movq %r14, %rsi
movq %r12, %rdx
movq %rbx, %r13
callq 0x3340
movb $0x9, -0x29(%rbp)
movl $0x1, %edx
movq %rax, %rdi
leaq -0x29(%rbp), %rsi
callq 0x3340
movl 0x40(%r15), %esi
movq %rax, %rdi
callq 0x3550
movl $0x1, %edx
movq %rax, %rdi
leaq 0x10d65(%rip), %rsi     # 0x16020
callq 0x3340
movl 0x40(%r15), %r14d
movq -0x38(%rbp), %rdi
movq -0x48(%rbp), %rsi
callq 0x14e54
movq -0x38(%rbp), %rdi
movq %rax, %rsi
callq 0x14f06
addl %r14d, -0x30(%rbp)
jmp 0x52e6
movq %rbx, %r13
movq -0x68(%rbp), %rdi
cmpq %r13, %rdi
je 0x52f4
callq 0x32f0
movq %r15, %rdi
callq 0x3210
movq %rax, %r15
cmpq -0x40(%rbp), %rax
jne 0x517a
jmp 0x5312
movl $0x0, -0x30(%rbp)
movq -0x38(%rbp), %rax
movq 0x18(%rax), %r14
cmpq -0x40(%rbp), %r14
je 0x538d
leaq -0x268(%rbp), %r15
leaq -0x68(%rbp), %r12
leaq 0x10cee(%rip), %r13     # 0x16020
movq 0x20(%r14), %rsi
movq 0x28(%r14), %rdx
movq %r15, %rdi
callq 0x3340
movb $0x9, -0x68(%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
movl -0x30(%rbp), %eax
addl 0x40(%r14), %eax
movl %eax, -0x30(%rbp)
movq %r14, %rdi
callq 0x3210
movq %rax, %r14
cmpq -0x40(%rbp), %rax
jne 0x5332
movq 0x1ac3c(%rip), %rdi     # 0x1ffd0
leaq 0x11015(%rip), %rsi     # 0x163b0
movl $0x11, %edx
callq 0x3340
movq 0x1ac24(%rip), %rdi     # 0x1ffd0
movl -0x30(%rbp), %esi
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 0x1abd7(%rip), %rax     # 0x1ffc8
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 0x154ea(%rip), %rdi     # 0x1a923
xorl %esi, %esi
xorl %eax, %eax
callq 0x3490
jmp 0x544a
jmp 0x544a
jmp 0x544a
jmp 0x544f
movq %rax, %rbx
jmp 0x5460
movq %rax, %rbx
movq -0x68(%rbp), %rdi
cmpq %r13, %rdi
je 0x5460
callq 0x32f0
leaq -0x268(%rbp), %rdi
callq 0x3450
movq %rbx, %rdi
callq 0x3560