// File: murry2018[P]mogazi/mog.cpp
// Function: main
int main(int argc, char **argv) {
  if (argc != 2) {
    string filename = argv[0];
    string::size_type loc=0, ploc;
    while ((ploc = filename.substr(loc).find('/')) != string::npos)
      loc = ploc+1;
    cout << "usage: " << string(filename.begin() + loc, filename.end())
         << " <Kakaotalk datafile>" << endl;
    return 0;
  }
  ifstream chats(argv[1]);
  kakaotalk::room myroom(chats);
  vector<string> mogazi;

  for (auto& each : myroom.enrolls) {
    auto& m_name = each.first;
    auto& m_info = each.second;

    cout << m_name << ", 한 말의 수: " << int(m_info) << endl;
    if (int(m_info) < 20) {
      mogazi.push_back(m_name);
    }
  }

  sort(mogazi.begin(), mogazi.end());
  cout << "안녕히 가세요 " << endl;
  for (auto& each : mogazi) {
    cout << each << " ";
  }
  cout << endl;

  cout << myroom.member_total() - myroom.enrolls.size()
       << " 명이 조사 결과에서 누락되었습니다." << endl;

  typedef std::pair<std::string, kakaotalk::mem_info> pairtype;
  myroom.enrolls.sort([](const pairtype& x, const pairtype& y)
                      { return x.first < y.first; });
  cout << "재적자 목록" << endl;
  int cnt = 0;
  for (auto& each : myroom.enrolls) {
    cout << '[' << each.first << "] ";
    if (cnt++ / 5 > 0) {
      cnt = 0;
      cout << endl;
    }
  }
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x490, %rsp            # imm = 0x490
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x2, -0x8(%rbp)
je 0x5b9e
movq -0x10(%rbp), %rax
movq (%rax), %rax
movq %rax, -0x3e0(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0x3d8(%rbp)
callq 0x56b0
movq -0x3e0(%rbp), %rsi
movq -0x3d8(%rbp), %rdx
leaq -0x30(%rbp), %rdi
callq 0x6700
jmp 0x59ba
leaq -0x31(%rbp), %rdi
callq 0x5470
movq $0x0, -0x50(%rbp)
movq -0x50(%rbp), %rdx
leaq -0x78(%rbp), %rdi
leaq -0x30(%rbp), %rsi
movq $-0x1, %rcx
callq 0x5430
jmp 0x59e5
leaq -0x78(%rbp), %rdi
movl $0x2f, %esi
xorl %eax, %eax
movl %eax, %edx
callq 0x5570
movq %rax, -0x3e8(%rbp)
movq %rax, -0x58(%rbp)
leaq -0x78(%rbp), %rdi
callq 0x5768
movq -0x3e8(%rbp), %rax
cmpq $-0x1, %rax
je 0x5a51
movq -0x58(%rbp), %rax
addq $0x1, %rax
movq %rax, -0x50(%rbp)
jmp 0x59cb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x31(%rbp), %rdi
callq 0x5470
jmp 0x608b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x5b90
movq 0x49550(%rip), %rdi     # 0x4efa8
leaq 0x2f5a5(%rip), %rsi     # 0x35004
callq 0x53f0
movq %rax, -0x3f0(%rbp)
jmp 0x5a6d
leaq -0x30(%rbp), %rdi
movq %rdi, -0x400(%rbp)
callq 0x5390
movq %rax, -0xa8(%rbp)
movq -0x50(%rbp), %rsi
leaq -0xa8(%rbp), %rdi
callq 0x67b0
movq -0x400(%rbp), %rdi
movq %rax, -0xa0(%rbp)
callq 0x5250
movq %rax, -0xb0(%rbp)
leaq -0xb1(%rbp), %rdi
movq %rdi, -0x3f8(%rbp)
callq 0x56b0
movq -0x3f8(%rbp), %rcx
movq -0xa0(%rbp), %rsi
movq -0xb0(%rbp), %rdx
leaq -0x98(%rbp), %rdi
callq 0x67f0
jmp 0x5ae4
movq -0x3f0(%rbp), %rdi
leaq -0x98(%rbp), %rsi
callq 0x53b0
movq %rax, -0x408(%rbp)
jmp 0x5b00
movq -0x408(%rbp), %rdi
leaq 0x2f4fe(%rip), %rsi     # 0x3500c
callq 0x53f0
movq %rax, -0x410(%rbp)
jmp 0x5b1c
movq -0x410(%rbp), %rdi
movq 0x49436(%rip), %rsi     # 0x4ef60
callq 0x5450
jmp 0x5b31
leaq -0x98(%rbp), %rdi
callq 0x5768
leaq -0xb1(%rbp), %rdi
callq 0x5470
movl $0x0, -0x4(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x5768
jmp 0x607f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x5b84
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x5768
leaq -0xb1(%rbp), %rdi
callq 0x5470
leaq -0x30(%rbp), %rdi
callq 0x5768
jmp 0x608b
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rsi
leaq -0x2c0(%rbp), %rdi
movq %rdi, -0x418(%rbp)
movl $0x8, %edx
callq 0x56f0
movq -0x418(%rbp), %rsi
leaq -0x330(%rbp), %rdi
callq 0x32940
jmp 0x5bd3
leaq -0x348(%rbp), %rdi
callq 0x6870
leaq -0x330(%rbp), %rax
movq %rax, -0x350(%rbp)
movq -0x350(%rbp), %rdi
callq 0x6890
movq %rax, -0x358(%rbp)
movq -0x350(%rbp), %rdi
callq 0x68c0
movq %rax, -0x360(%rbp)
leaq -0x358(%rbp), %rdi
leaq -0x360(%rbp), %rsi
callq 0x68f0
testb $0x1, %al
jne 0x5c2f
jmp 0x5d61
leaq -0x358(%rbp), %rdi
callq 0x6920
movq %rax, -0x368(%rbp)
movq -0x368(%rbp), %rax
movq %rax, -0x370(%rbp)
movq -0x368(%rbp), %rax
addq $0x20, %rax
movq %rax, -0x378(%rbp)
movq -0x370(%rbp), %rsi
movq 0x49338(%rip), %rdi     # 0x4efa8
callq 0x53b0
movq %rax, -0x420(%rbp)
jmp 0x5c7e
movq -0x420(%rbp), %rdi
leaq 0x2f396(%rip), %rsi     # 0x35022
callq 0x53f0
movq %rax, -0x428(%rbp)
jmp 0x5c9a
movq -0x378(%rbp), %rdi
callq 0xa100
movl %eax, -0x42c(%rbp)
jmp 0x5cae
movl -0x42c(%rbp), %esi
movq -0x428(%rbp), %rdi
callq 0x5680
movq %rax, -0x438(%rbp)
jmp 0x5cc9
movq -0x438(%rbp), %rdi
movq 0x49289(%rip), %rsi     # 0x4ef60
callq 0x5450
jmp 0x5cde
movq -0x378(%rbp), %rdi
callq 0xa100
movl %eax, -0x43c(%rbp)
jmp 0x5cf2
movl -0x43c(%rbp), %eax
cmpl $0x14, %eax
jge 0x5d4e
movq -0x370(%rbp), %rsi
leaq -0x348(%rbp), %rdi
callq 0x6940
jmp 0x5d12
jmp 0x5d4e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x6071
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x348(%rbp), %rdi
callq 0x6b20
leaq -0x330(%rbp), %rdi
callq 0x6b80
jmp 0x6071
jmp 0x5d50
leaq -0x358(%rbp), %rdi
callq 0x69b0
jmp 0x5c13
leaq -0x348(%rbp), %rdi
movq %rdi, -0x448(%rbp)
callq 0x6a10
movq -0x448(%rbp), %rdi
movq %rax, -0x380(%rbp)
callq 0x6a40
movq %rax, -0x388(%rbp)
movq -0x380(%rbp), %rdi
movq -0x388(%rbp), %rsi
callq 0x69d0
jmp 0x5da3
movq 0x491fe(%rip), %rdi     # 0x4efa8
leaq 0x2f284(%rip), %rsi     # 0x35035
callq 0x53f0
movq %rax, -0x450(%rbp)
jmp 0x5dbf
movq -0x450(%rbp), %rdi
movq 0x49193(%rip), %rsi     # 0x4ef60
callq 0x5450
jmp 0x5dd4
leaq -0x348(%rbp), %rax
movq %rax, -0x390(%rbp)
movq -0x390(%rbp), %rdi
callq 0x6a10
movq %rax, -0x398(%rbp)
movq -0x390(%rbp), %rdi
callq 0x6a40
movq %rax, -0x3a0(%rbp)
leaq -0x398(%rbp), %rdi
leaq -0x3a0(%rbp), %rsi
callq 0x6a70
testb $0x1, %al
jne 0x5e21
jmp 0x5e75
leaq -0x398(%rbp), %rdi
callq 0x6ab0
movq %rax, -0x3a8(%rbp)
movq -0x3a8(%rbp), %rsi
movq 0x49166(%rip), %rdi     # 0x4efa8
callq 0x53b0
movq %rax, -0x458(%rbp)
jmp 0x5e50
movq -0x458(%rbp), %rdi
leaq 0x2f1ac(%rip), %rsi     # 0x3500a
callq 0x53f0
jmp 0x5e65
jmp 0x5e67
leaq -0x398(%rbp), %rdi
callq 0x6ad0
jmp 0x5e08
movq 0x4912c(%rip), %rdi     # 0x4efa8
movq 0x490dd(%rip), %rsi     # 0x4ef60
callq 0x5450
jmp 0x5e8a
leaq -0x330(%rbp), %rdi
callq 0x33420
movq %rax, -0x460(%rbp)
jmp 0x5e9f
leaq -0x330(%rbp), %rdi
callq 0x6af0
movq -0x460(%rbp), %rsi
subq %rax, %rsi
movq 0x490ec(%rip), %rdi     # 0x4efa8
callq 0x53d0
movq %rax, -0x468(%rbp)
jmp 0x5eca
movq -0x468(%rbp), %rdi
leaq 0x2f172(%rip), %rsi     # 0x3504a
callq 0x53f0
movq %rax, -0x470(%rbp)
jmp 0x5ee6
movq -0x470(%rbp), %rdi
movq 0x4906c(%rip), %rsi     # 0x4ef60
callq 0x5450
jmp 0x5efb
leaq -0x330(%rbp), %rdi
callq 0x60a0
jmp 0x5f09
movq 0x49098(%rip), %rdi     # 0x4efa8
leaq 0x2f166(%rip), %rsi     # 0x3507d
callq 0x53f0
movq %rax, -0x478(%rbp)
jmp 0x5f25
movq -0x478(%rbp), %rdi
movq 0x4902d(%rip), %rsi     # 0x4ef60
callq 0x5450
jmp 0x5f3a
movl $0x0, -0x3b0(%rbp)
leaq -0x330(%rbp), %rax
movq %rax, -0x3b8(%rbp)
movq -0x3b8(%rbp), %rdi
callq 0x6890
movq %rax, -0x3c0(%rbp)
movq -0x3b8(%rbp), %rdi
callq 0x68c0
movq %rax, -0x3c8(%rbp)
leaq -0x3c0(%rbp), %rdi
leaq -0x3c8(%rbp), %rsi
callq 0x68f0
testb $0x1, %al
jne 0x5f94
jmp 0x6044
leaq -0x3c0(%rbp), %rdi
callq 0x6920
movq %rax, -0x3d0(%rbp)
movq 0x48ffa(%rip), %rdi     # 0x4efa8
movl $0x5b, %esi
callq 0x54f0
movq %rax, -0x480(%rbp)
jmp 0x5fc1
movq -0x480(%rbp), %rdi
movq -0x3d0(%rbp), %rsi
callq 0x53b0
movq %rax, -0x488(%rbp)
jmp 0x5fdd
movq -0x488(%rbp), %rdi
leaq 0x2f0a3(%rip), %rsi     # 0x3508e
callq 0x53f0
jmp 0x5ff2
movl -0x3b0(%rbp), %eax
movl %eax, %ecx
addl $0x1, %ecx
movl %ecx, -0x3b0(%rbp)
movl $0x5, %ecx
cltd
idivl %ecx
cmpl $0x0, %eax
jle 0x6031
movl $0x0, -0x3b0(%rbp)
movq 0x48f87(%rip), %rdi     # 0x4efa8
movq 0x48f38(%rip), %rsi     # 0x4ef60
callq 0x5450
jmp 0x602f
jmp 0x6031
jmp 0x6033
leaq -0x3c0(%rbp), %rdi
callq 0x69b0
jmp 0x5f78
movl $0x0, -0x4(%rbp)
leaq -0x348(%rbp), %rdi
callq 0x6b20
leaq -0x330(%rbp), %rdi
callq 0x6b80
leaq -0x2c0(%rbp), %rdi
callq 0x50d0
jmp 0x607f
leaq -0x2c0(%rbp), %rdi
callq 0x50d0
jmp 0x608b
movl -0x4(%rbp), %eax
addq $0x490, %rsp            # imm = 0x490
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x56a0
nopw %cs:(%rax,%rax)