// File: tylerwowen[P]movielens/./movielens/datareader.cpp
// Function: readData(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::unordered_map<int, Ratings, std::hash<int>, std::equal_to<int>, std::allocator<std::pair<int const, Ratings>>>&)
int readData(string const &filename, UsersMap &users) {
  ifstream ifs(filename);
  locale colon(std::locale::classic(), new my_ctype);
  ifs.imbue(colon);
  int ratingCount = 0;
  
  while (true) {
    int userId, itermId, timestamp;
    double rating;
    ifs >>  userId >> itermId >> rating >> timestamp;
    if (ifs.fail()) {
      break;
    }
    Ratings *ratings = &users[userId];
    ratings->insert(itermId, rating);
    ratingCount++;
  }
  for (auto& user: users) {
    user.second.sortList();
  }
  
  return ratingCount;
}

// Assembly:
subq $0x2b8, %rsp            # imm = 0x2B8
movq %rdi, 0x2b0(%rsp)
movq %rsi, 0x2a8(%rsp)
movq 0x2b0(%rsp), %rsi
leaq 0xa0(%rsp), %rdi
movl $0x8, %edx
callq 0x22b0
callq 0x2250
movq %rax, 0x38(%rsp)
jmp 0x520d
movl $0x440, %edi            # imm = 0x440
callq 0x21c0
movq %rax, 0x30(%rsp)
jmp 0x521e
movq 0x30(%rsp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x5470
jmp 0x522e
movq 0x30(%rsp), %rdx
movq 0x38(%rsp), %rsi
leaq 0x98(%rsp), %rdi
callq 0x5520
jmp 0x5247
movq 0xa0(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0xa0(%rsp,%rax), %rsi
leaq 0x80(%rsp), %rdi
leaq 0x98(%rsp), %rdx
callq 0x2070
jmp 0x5272
leaq 0x80(%rsp), %rdi
callq 0x2270
movl $0x0, 0x7c(%rsp)
jmp 0x5289
leaq 0xa0(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x2110
movq %rax, 0x28(%rsp)
jmp 0x52a2
movq 0x28(%rsp), %rdi
leaq 0x74(%rsp), %rsi
callq 0x2110
movq %rax, 0x20(%rsp)
jmp 0x52b8
movq 0x20(%rsp), %rdi
leaq 0x68(%rsp), %rsi
callq 0x2170
movq %rax, 0x18(%rsp)
jmp 0x52ce
movq 0x18(%rsp), %rdi
leaq 0x70(%rsp), %rsi
callq 0x2110
jmp 0x52df
movq 0xa0(%rsp), %rax
movq -0x18(%rax), %rax
leaq 0xa0(%rsp,%rax), %rdi
callq 0x2030
movb %al, 0x17(%rsp)
jmp 0x52fe
movb 0x17(%rsp), %al
testb $0x1, %al
jne 0x5308
jmp 0x536f
jmp 0x53b8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x90(%rsp)
movl %eax, 0x8c(%rsp)
jmp 0x5453
movq 0x30(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x90(%rsp)
movl %eax, 0x8c(%rsp)
callq 0x21a0
jmp 0x5453
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x90(%rsp)
movl %eax, 0x8c(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x2270
jmp 0x5453
movq 0x2a8(%rsp), %rdi
leaq 0x78(%rsp), %rsi
callq 0x5640
movq %rax, 0x8(%rsp)
jmp 0x5388
movq 0x8(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0x60(%rsp), %rdi
movl 0x74(%rsp), %esi
movsd 0x68(%rsp), %xmm0
callq 0x2700
jmp 0x53a8
movl 0x7c(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x7c(%rsp)
jmp 0x5287
movq 0x2a8(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rdi
callq 0x5670
movq %rax, 0x50(%rsp)
movq 0x58(%rsp), %rdi
callq 0x56a0
movq %rax, 0x48(%rsp)
leaq 0x50(%rsp), %rdi
leaq 0x48(%rsp), %rsi
callq 0x56d0
testb $0x1, %al
jne 0x53f8
jmp 0x5425
leaq 0x50(%rsp), %rdi
callq 0x56f0
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rdi
addq $0x8, %rdi
callq 0x2770
jmp 0x5417
jmp 0x5419
leaq 0x50(%rsp), %rdi
callq 0x5710
jmp 0x53e3
movl 0x7c(%rsp), %eax
movl %eax, 0x4(%rsp)
leaq 0x98(%rsp), %rdi
callq 0x2270
leaq 0xa0(%rsp), %rdi
callq 0x2060
movl 0x4(%rsp), %eax
addq $0x2b8, %rsp            # imm = 0x2B8
retq
leaq 0xa0(%rsp), %rdi
callq 0x2060
movq 0x90(%rsp), %rdi
callq 0x2310
nopl (%rax)