// File: 4n6ist[P]usn_analytics/lib/usnjrnl.cpp
// Function: UsnJrnl::PostProcess()
int UsnJrnl::PostProcess(){
  
  // store usnmain_set file_path value
  GetAllDirName();

  printf("%8lu records after packing\n", usnmain_set.size());       
  fprintf(fp_ofreport, "%8lu records after packing\n", usnmain_set.size()); 
  string timestamp_begin, timestamp_end;
  
  timestamp_begin = usnmain_set[0].timestamp_s;
  timestamp_end = usnmain_set[usnmain_set.size()-1].timestamp_s;
  
  fprintf(fp_ofreport, " Records |                         DateTime                        |             USN              |\n");
  fprintf(fp_ofreport, "%8lu | %s - %s |%13llu - %13llu |\n", usnmain_set.size(), timestamp_begin.c_str(), timestamp_end.c_str(), usnmain_set[0].usn, usnmain_set[usnmain_set.size()-1].usn); 
  fprintf(fp_ofreport, "===================================================================================================\n");

  // USN range, Time slot Breakdown
  uint64_t usn_begin;
  usn_begin = usnmain_set[0].usn;
  int j=0;
  for(int i=1; i <= usnmain_set.size(); ++i) {
    if(usnmain_set[i].usn - usnmain_set[i-1].usn > 1048576) {
      timestamp_end = usnmain_set[i-1].timestamp_s;
      fprintf(fp_ofreport, "%8d |", i-j);
      fprintf(fp_ofreport, " %s - %s |", timestamp_begin.c_str(), timestamp_end.c_str());
      fprintf(fp_ofreport, "%13llu - %13llu |\n", usn_begin, usnmain_set[i-1].usn);
      j = i;
      if(i == usnmain_set.size())
        break;
      usn_begin = usnmain_set[i].usn;
      timestamp_begin = usnmain_set[i].timestamp_s;
    }
  }
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x98(%rbp)
callq 0x55b0
movq -0x98(%rbp), %rdi
addq $0x50, %rdi
movq %rdi, -0x78(%rbp)
callq 0xaf20
movq %rax, %rsi
leaq 0x15a54(%rip), %rdi     # 0x1c1e1
movq %rdi, -0x88(%rbp)
xorl %eax, %eax
movl %eax, -0x7c(%rbp)
movb %al, -0x7d(%rbp)
callq 0x3060
movq -0x78(%rbp), %rdi
movq -0x98(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x90(%rbp)
callq 0xaf20
movq -0x90(%rbp), %rdi
movq -0x88(%rbp), %rsi
movq %rax, %rdx
movb -0x7d(%rbp), %al
callq 0x34d0
leaq -0x28(%rbp), %rdi
movq %rdi, -0x70(%rbp)
callq 0x34b0
leaq -0x48(%rbp), %rdi
callq 0x34b0
movl -0x7c(%rbp), %eax
movq -0x78(%rbp), %rdi
movl %eax, %esi
callq 0xaf90
movq -0x70(%rbp), %rdi
movq %rax, %rsi
addq $0x12, %rsi
callq 0x3050
jmp 0x680b
movq -0x98(%rbp), %rdi
addq $0x50, %rdi
movq %rdi, -0xa0(%rbp)
callq 0xaf20
movq -0xa0(%rbp), %rdi
movq %rax, %rsi
decq %rsi
callq 0xaf90
movq %rax, %rsi
addq $0x12, %rsi
leaq -0x48(%rbp), %rdi
callq 0x3050
jmp 0x6846
movq -0x98(%rbp), %rax
movq 0x18(%rax), %rdi
leaq 0x159a5(%rip), %rsi     # 0x1c1fd
movb $0x0, %al
callq 0x34d0
movq -0x98(%rbp), %rdi
movq 0x18(%rdi), %rax
movq %rax, -0xc8(%rbp)
addq $0x50, %rdi
callq 0xaf20
movq %rax, -0xc0(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x3120
movq %rax, -0xb8(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x3120
movq -0x98(%rbp), %rdi
movq %rax, -0xb0(%rbp)
addq $0x50, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xaf90
movq -0x98(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0xa8(%rbp)
movq %rdi, %rax
addq $0x50, %rax
movq %rax, -0xd0(%rbp)
addq $0x50, %rdi
callq 0xaf20
movq -0xd0(%rbp), %rdi
movq %rax, %rsi
subq $0x1, %rsi
callq 0xaf90
movq -0xc8(%rbp), %rdi
movq -0xc0(%rbp), %rdx
movq -0xb8(%rbp), %rcx
movq -0xb0(%rbp), %r8
movq -0xa8(%rbp), %r9
movq (%rax), %rax
leaq 0x15945(%rip), %rsi     # 0x1c262
movq %rax, (%rsp)
movb $0x0, %al
callq 0x34d0
movq -0x98(%rbp), %rax
movq 0x18(%rax), %rdi
leaq 0x1594b(%rip), %rsi     # 0x1c285
movb $0x0, %al
callq 0x34d0
movq -0x98(%rbp), %rdi
addq $0x50, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0xaf90
movq (%rax), %rax
movq %rax, -0x60(%rbp)
movl $0x0, -0x64(%rbp)
movl $0x1, -0x68(%rbp)
movq -0x98(%rbp), %rdi
movslq -0x68(%rbp), %rax
movq %rax, -0xd8(%rbp)
addq $0x50, %rdi
callq 0xaf20
movq %rax, %rcx
movq -0xd8(%rbp), %rax
cmpq %rcx, %rax
ja 0x6b71
movq -0x98(%rbp), %rdi
addq $0x50, %rdi
movslq -0x68(%rbp), %rsi
callq 0xaf90
movq -0x98(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0xe0(%rbp)
addq $0x50, %rdi
movl -0x68(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0xaf90
movq %rax, %rcx
movq -0xe0(%rbp), %rax
subq (%rcx), %rax
cmpq $0x100000, %rax         # imm = 0x100000
jbe 0x6b61
movq -0x98(%rbp), %rdi
addq $0x50, %rdi
movl -0x68(%rbp), %eax
decl %eax
movslq %eax, %rsi
callq 0xaf90
movq %rax, %rsi
addq $0x12, %rsi
leaq -0x48(%rbp), %rdi
callq 0x3050
jmp 0x6a12
movq -0x98(%rbp), %rax
movq 0x18(%rax), %rdi
movl -0x68(%rbp), %edx
subl -0x64(%rbp), %edx
leaq 0x158c0(%rip), %rsi     # 0x1c2ea
movb $0x0, %al
callq 0x34d0
movq -0x98(%rbp), %rax
movq 0x18(%rax), %rax
movq %rax, -0x108(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x3120
movq %rax, -0x100(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x3120
movq -0x108(%rbp), %rdi
movq -0x100(%rbp), %rdx
movq %rax, %rcx
leaq 0x1587c(%rip), %rsi     # 0x1c2f0
movb $0x0, %al
callq 0x34d0
movq -0x98(%rbp), %rdi
movq 0x18(%rdi), %rax
movq %rax, -0xf8(%rbp)
movq -0x60(%rbp), %rax
movq %rax, -0xf0(%rbp)
addq $0x50, %rdi
movl -0x68(%rbp), %eax
subl $0x1, %eax
movslq %eax, %rsi
callq 0xaf90
movq -0xf8(%rbp), %rdi
movq -0xf0(%rbp), %rdx
movq (%rax), %rcx
leaq 0x157b0(%rip), %rsi     # 0x1c272
movb $0x0, %al
callq 0x34d0
movq -0x98(%rbp), %rdi
movl -0x68(%rbp), %eax
movl %eax, -0x64(%rbp)
movslq -0x68(%rbp), %rax
movq %rax, -0xe8(%rbp)
addq $0x50, %rdi
callq 0xaf20
movq %rax, %rcx
movq -0xe8(%rbp), %rax
cmpq %rcx, %rax
jne 0x6b1b
jmp 0x6b71
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x31d0
leaq -0x28(%rbp), %rdi
callq 0x31d0
jmp 0x6b8e
movq -0x98(%rbp), %rdi
addq $0x50, %rdi
movq %rdi, -0x110(%rbp)
movslq -0x68(%rbp), %rsi
callq 0xaf90
movq -0x110(%rbp), %rdi
movq (%rax), %rax
movq %rax, -0x60(%rbp)
movslq -0x68(%rbp), %rsi
callq 0xaf90
movq %rax, %rsi
addq $0x12, %rsi
leaq -0x28(%rbp), %rdi
callq 0x3050
jmp 0x6b5f
jmp 0x6b61
jmp 0x6b63
movl -0x68(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x68(%rbp)
jmp 0x696a
leaq -0x48(%rbp), %rdi
callq 0x31d0
leaq -0x28(%rbp), %rdi
callq 0x31d0
xorl %eax, %eax
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x35c0
nopw (%rax,%rax)