// File: IlyaSamoylov45[P]MapReduce-Project/main.cpp
// Function: sortPrint(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 sortPrint(std::map<std::string, int> result, std::string path) {
  std::ofstream outputFile;
  outputFile.open (path);
  std::map<int, int> convert; // convert all strings to int for sorting purposes
  for(auto it = result.begin(); it != result.end(); it++){
      int stringToInt = std::stoi(it->first);
      convert[stringToInt] = it->second;
  }

  //numbers are already sorted
  for(auto it = convert.begin(); it != convert.end(); it++){
      //if there are dupes print all the dupes
      for(int i = 0; i < it->second; i++){
	outputFile << it->first << "\n";
      }
  }
  outputFile.close();

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2d0, %rsp            # imm = 0x2D0
movq %rdi, -0x2a8(%rbp)
movq %rsi, -0x298(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
leaq -0x210(%rbp), %rdi
movq %rdi, -0x2a0(%rbp)
callq 0x4590
movq -0x2a0(%rbp), %rdi
movq -0x298(%rbp), %rsi
movl $0x10, %edx
callq 0x4160
jmp 0x70ee
leaq -0x250(%rbp), %rdi
callq 0xad40
movq -0x2a8(%rbp), %rdi
callq 0x9cf0
movq %rax, -0x258(%rbp)
movq -0x2a8(%rbp), %rdi
callq 0x9d50
movq %rax, -0x260(%rbp)
leaq -0x258(%rbp), %rdi
leaq -0x260(%rbp), %rsi
callq 0x9d20
testb $0x1, %al
jne 0x713c
jmp 0x7201
leaq -0x258(%rbp), %rdi
callq 0xa290
movq %rax, %rdi
xorl %eax, %eax
movl %eax, %esi
movl $0xa, %edx
callq 0x9650
movl %eax, -0x2ac(%rbp)
jmp 0x7161
movl -0x2ac(%rbp), %eax
movl %eax, -0x264(%rbp)
leaq -0x258(%rbp), %rdi
callq 0xa290
movl 0x20(%rax), %eax
movl %eax, -0x2bc(%rbp)
leaq -0x250(%rbp), %rdi
leaq -0x264(%rbp), %rsi
callq 0xad60
movq %rax, -0x2b8(%rbp)
jmp 0x719e
movq -0x2b8(%rbp), %rax
movl -0x2bc(%rbp), %ecx
movl %ecx, (%rax)
leaq -0x258(%rbp), %rdi
xorl %esi, %esi
callq 0x9d80
movq %rax, -0x270(%rbp)
jmp 0x710d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
jmp 0x7309
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x218(%rbp)
movl %eax, -0x21c(%rbp)
leaq -0x250(%rbp), %rdi
callq 0xaf30
jmp 0x7309
leaq -0x250(%rbp), %rdi
callq 0xae40
movq %rax, -0x278(%rbp)
leaq -0x250(%rbp), %rdi
callq 0xaea0
movq %rax, -0x280(%rbp)
leaq -0x278(%rbp), %rdi
leaq -0x280(%rbp), %rsi
callq 0xae70
testb $0x1, %al
jne 0x7243
jmp 0x72da
movl $0x0, -0x284(%rbp)
movl -0x284(%rbp), %eax
movl %eax, -0x2c0(%rbp)
leaq -0x278(%rbp), %rdi
callq 0xaed0
movq %rax, %rcx
movl -0x2c0(%rbp), %eax
cmpl 0x4(%rcx), %eax
jge 0x72be
leaq -0x278(%rbp), %rdi
callq 0xaed0
movl (%rax), %esi
leaq -0x210(%rbp), %rdi
callq 0x45b0
movq %rax, -0x2c8(%rbp)
jmp 0x7296
movq -0x2c8(%rbp), %rdi
leaq 0x20f48(%rip), %rsi     # 0x281ec
callq 0x4340
jmp 0x72ab
jmp 0x72ad
movl -0x284(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x284(%rbp)
jmp 0x724d
jmp 0x72c0
leaq -0x278(%rbp), %rdi
xorl %esi, %esi
callq 0xaef0
movq %rax, -0x290(%rbp)
jmp 0x7214
leaq -0x210(%rbp), %rdi
callq 0x4470
jmp 0x72e8
leaq -0x250(%rbp), %rdi
callq 0xaf30
leaq -0x210(%rbp), %rdi
callq 0x44c0
addq $0x2d0, %rsp            # imm = 0x2D0
popq %rbp
retq
leaq -0x210(%rbp), %rdi
callq 0x44c0
movq -0x218(%rbp), %rdi
callq 0x45c0
nopw %cs:(%rax,%rax)