// File: sile[P]unf/src/unf/unf-time.cc
// Function: main
int main(int argc, char** argv) {
  UNF::Normalizer norm;

  std::cerr << "= read: " << std::endl;
  std::vector<std::string> lines;
  std::string line;
  unsigned total_length=0;
  while(std::getline(std::cin,line)) {
    lines.push_back(line);
    total_length += line.size();
  }
  std::cerr << "  == " << lines.size() << " lines" << std::endl;
  std::cerr << "  == " << "average(line length): " << total_length/lines.size() << " byte" << std::endl;

  UNF::Normalizer::Form forms[] = {UNF::Normalizer::FORM_NFD, UNF::Normalizer::FORM_NFC,
				   UNF::Normalizer::FORM_NFKD,UNF::Normalizer::FORM_NFKC};
  const char* form_names[5] = {"NFD ","NFC ","NFKD","NFKC"};
  
  std::cerr << "= time: " << std::endl;
  int n=0;
  for(unsigned formid=0; formid < 4; formid++) {
    std::cerr << "  == " << form_names[formid] << ":  ";
    double beg_t = gettime();
    for(unsigned i=0; i < lines.size(); i++) 
      n += strlen(norm.normalize(lines[i].c_str(), forms[formid]));
    std::cerr << gettime()-beg_t << " sec" << std::endl;    
  }

  std::cerr << "DONE" << std::endl;
  return n;
}

// Assembly:
subq $0x298, %rsp            # imm = 0x298
movl $0x0, 0x294(%rsp)
movl %edi, 0x290(%rsp)
movq %rsi, 0x288(%rsp)
leaq 0x180(%rsp), %rdi
callq 0x2920
movq 0x69c3b(%rip), %rdi     # 0x6bff0
leaq 0x4c64(%rip), %rsi      # 0x7020
callq 0x2160
movq %rax, 0xd0(%rsp)
jmp 0x23cb
movq 0xd0(%rsp), %rdi
movq 0x69be6(%rip), %rsi     # 0x6bfc0
callq 0x2180
jmp 0x23e1
leaq 0x158(%rsp), %rdi
callq 0x2ab0
jmp 0x23f0
leaq 0x138(%rsp), %rdi
callq 0x21b0
jmp 0x23ff
movl $0x0, 0x134(%rsp)
movq 0x69bc7(%rip), %rdi     # 0x6bfd8
leaq 0x138(%rsp), %rsi
callq 0x2040
movq %rax, 0xc8(%rsp)
jmp 0x2428
movq 0xc8(%rsp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0x21e0
movq %rax, 0xc0(%rsp)
jmp 0x2449
movq 0xc0(%rsp), %rax
cmpq $0x0, %rax
je 0x24ff
leaq 0x158(%rsp), %rdi
leaq 0x138(%rsp), %rsi
callq 0x2ac0
jmp 0x2472
leaq 0x138(%rsp), %rdi
callq 0x2110
movq %rax, 0xb8(%rsp)
jmp 0x2489
movq 0xb8(%rsp), %rcx
movl 0x134(%rsp), %eax
addq %rcx, %rax
movl %eax, 0x134(%rsp)
jmp 0x240a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x178(%rsp)
movl %eax, 0x174(%rsp)
jmp 0x28f2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x178(%rsp)
movl %eax, 0x174(%rsp)
jmp 0x28e1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x178(%rsp)
movl %eax, 0x174(%rsp)
leaq 0x138(%rsp), %rdi
callq 0x2100
jmp 0x28c3
movq 0x69aea(%rip), %rdi     # 0x6bff0
leaq 0x4b1c(%rip), %rsi      # 0x7029
callq 0x2160
movq %rax, 0xb0(%rsp)
jmp 0x251c
leaq 0x158(%rsp), %rdi
callq 0x2b30
movq %rax, 0xa8(%rsp)
jmp 0x2533
movq 0xa8(%rsp), %rsi
movq 0xb0(%rsp), %rdi
callq 0x2050
movq %rax, 0xa0(%rsp)
jmp 0x2552
movq 0xa0(%rsp), %rdi
leaq 0x4ace(%rip), %rsi      # 0x702f
callq 0x2160
movq %rax, 0x98(%rsp)
jmp 0x2570
movq 0x98(%rsp), %rdi
movq 0x69a41(%rip), %rsi     # 0x6bfc0
callq 0x2180
jmp 0x2586
movq 0x69a63(%rip), %rdi     # 0x6bff0
leaq 0x4a95(%rip), %rsi      # 0x7029
callq 0x2160
movq %rax, 0x90(%rsp)
jmp 0x25a3
movq 0x90(%rsp), %rdi
leaq 0x4a84(%rip), %rsi      # 0x7036
callq 0x2160
movq %rax, 0x88(%rsp)
jmp 0x25c1
movl 0x134(%rsp), %eax
movq %rax, 0x78(%rsp)
leaq 0x158(%rsp), %rdi
callq 0x2b30
movq %rax, 0x80(%rsp)
jmp 0x25e4
movq 0x88(%rsp), %rdi
movq 0x80(%rsp), %rcx
movq 0x78(%rsp), %rax
xorl %edx, %edx
divq %rcx
movq %rax, %rsi
callq 0x2050
movq %rax, 0x70(%rsp)
jmp 0x260d
movq 0x70(%rsp), %rdi
leaq 0x4a34(%rip), %rsi      # 0x704d
callq 0x2160
movq %rax, 0x68(%rsp)
jmp 0x2625
movq 0x68(%rsp), %rdi
movq 0x6998f(%rip), %rsi     # 0x6bfc0
callq 0x2180
jmp 0x2638
movaps 0x4a91(%rip), %xmm0     # 0x70d0
movaps %xmm0, 0x120(%rsp)
movq 0x69752(%rip), %rax     # 0x6bda0
movq %rax, 0x110(%rsp)
movaps 0x69733(%rip), %xmm0    # 0x6bd90
movaps %xmm0, 0x100(%rsp)
movaps 0x69714(%rip), %xmm0    # 0x6bd80
movaps %xmm0, 0xf0(%rsp)
movq 0x69975(%rip), %rdi     # 0x6bff0
leaq 0x49e5(%rip), %rsi      # 0x7067
callq 0x2160
movq %rax, 0x60(%rsp)
jmp 0x268e
movq 0x60(%rsp), %rdi
movq 0x69926(%rip), %rsi     # 0x6bfc0
callq 0x2180
jmp 0x26a1
movl $0x0, 0xec(%rsp)
movl $0x0, 0xe8(%rsp)
cmpl $0x4, 0xe8(%rsp)
jae 0x286c
movq 0x69924(%rip), %rdi     # 0x6bff0
leaq 0x4956(%rip), %rsi      # 0x7029
callq 0x2160
movq %rax, 0x58(%rsp)
jmp 0x26df
movq 0x58(%rsp), %rdi
movl 0xe8(%rsp), %eax
movq 0xf0(%rsp,%rax,8), %rsi
callq 0x2160
movq %rax, 0x50(%rsp)
jmp 0x26ff
movq 0x50(%rsp), %rdi
leaq 0x4965(%rip), %rsi      # 0x7070
callq 0x2160
jmp 0x2712
callq 0x2b50
movsd %xmm0, 0x48(%rsp)
jmp 0x271f
movsd 0x48(%rsp), %xmm0
movsd %xmm0, 0xe0(%rsp)
movl $0x0, 0xdc(%rsp)
movl 0xdc(%rsp), %eax
movq %rax, 0x38(%rsp)
leaq 0x158(%rsp), %rdi
callq 0x2b30
movq %rax, 0x40(%rsp)
jmp 0x2759
movq 0x38(%rsp), %rax
movq 0x40(%rsp), %rcx
cmpq %rcx, %rax
jae 0x27f6
movl 0xdc(%rsp), %eax
movl %eax, %esi
leaq 0x158(%rsp), %rdi
callq 0x2c40
movq %rax, 0x30(%rsp)
jmp 0x2789
movq 0x30(%rsp), %rdi
callq 0x2090
movq %rax, 0x28(%rsp)
jmp 0x279a
movq 0x28(%rsp), %rsi
movl 0xe8(%rsp), %eax
movl 0x120(%rsp,%rax,4), %edx
leaq 0x180(%rsp), %rdi
callq 0x2b90
movq %rax, 0x20(%rsp)
jmp 0x27c1
movq 0x20(%rsp), %rdi
callq 0x20b0
movq %rax, %rcx
movslq 0xec(%rsp), %rax
addq %rcx, %rax
movl %eax, 0xec(%rsp)
movl 0xdc(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xdc(%rsp)
jmp 0x2739
callq 0x2b50
movsd %xmm0, 0x18(%rsp)
jmp 0x2803
movsd 0x18(%rsp), %xmm0
movsd 0xe0(%rsp), %xmm1
subsd %xmm1, %xmm0
movq 0x697d3(%rip), %rdi     # 0x6bff0
callq 0x2230
movq %rax, 0x10(%rsp)
jmp 0x2829
movq 0x10(%rsp), %rdi
leaq 0x483f(%rip), %rsi      # 0x7074
callq 0x2160
movq %rax, 0x8(%rsp)
jmp 0x2841
movq 0x8(%rsp), %rdi
movq 0x69773(%rip), %rsi     # 0x6bfc0
callq 0x2180
jmp 0x2854
jmp 0x2856
movl 0xe8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xe8(%rsp)
jmp 0x26b7
movq 0x6977d(%rip), %rdi     # 0x6bff0
leaq 0x47ff(%rip), %rsi      # 0x7079
callq 0x2160
movq %rax, (%rsp)
jmp 0x2885
movq (%rsp), %rdi
movq 0x69730(%rip), %rsi     # 0x6bfc0
callq 0x2180
jmp 0x2897
movl 0xec(%rsp), %eax
movl %eax, 0x294(%rsp)
leaq 0x138(%rsp), %rdi
callq 0x2100
jmp 0x28b4
leaq 0x158(%rsp), %rdi
callq 0x2c70
jmp 0x28c5
jmp 0x28e1
leaq 0x180(%rsp), %rdi
callq 0x2cf0
movl 0x294(%rsp), %eax
addq $0x298, %rsp            # imm = 0x298
retq
leaq 0x158(%rsp), %rdi
callq 0x2c70
jmp 0x28f0
jmp 0x28f2
leaq 0x180(%rsp), %rdi
callq 0x2cf0
jmp 0x2901
jmp 0x2903
movq 0x178(%rsp), %rdi
callq 0x2220
movq %rax, %rdi
callq 0x2c60
nopl (%rax,%rax)