// File: /workspace/github_cpp_makefile_star2_O2/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x48, %rsp
movq %rdi, %rbx
callq 0x4656
movq 0x58(%rbx), %rax
subq 0x50(%rbx), %rax
movl $0xca, %r15d
cqto
idivq %r15
leaq 0x7267(%rip), %r14      # 0xc1df
xorl %ebp, %ebp
movq %r14, %rdi
movq %rax, %rsi
xorl %eax, %eax
callq 0x3040
movq 0x18(%rbx), %rdi
movq 0x58(%rbx), %rax
subq 0x50(%rbx), %rax
cqto
idivq %r15
movq %r14, %rsi
movq %rax, %rdx
xorl %eax, %eax
callq 0x3380
leaq 0x38(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
leaq 0x18(%rsp), %rcx
movq %rcx, -0x10(%rcx)
andq $0x0, -0x8(%rcx)
movb %bpl, (%rax)
movb %bpl, (%rcx)
movq 0x50(%rbx), %rsi
addq $0x12, %rsi
leaq 0x28(%rsp), %rdi
callq 0x3150
movq $-0xb8, %rsi
addq 0x58(%rbx), %rsi
leaq 0x8(%rsp), %rdi
callq 0x3150
movq 0x18(%rbx), %rcx
leaq 0x7202(%rip), %rdi      # 0xc1fb
pushq $0x64
popq %r15
pushq $0x1
popq %r14
movq %r15, %rsi
movq %r14, %rdx
callq 0x34d0
movq 0x58(%rbx), %rsi
movq 0x18(%rbx), %rdi
movq 0x50(%rbx), %r9
movq %rsi, %rax
subq %r9, %rax
movl $0xca, %r13d
cqto
idivq %r13
leaq 0x28(%rsp), %rcx
movq (%rcx), %rcx
leaq 0x8(%rsp), %rdx
movq (%rdx), %r8
movq (%r9), %r9
movq -0xca(%rsi), %rdx
movq %rdx, (%rsp)
leaq 0x7212(%rip), %rsi      # 0xc260
movq %rax, %rdx
xorl %eax, %eax
callq 0x3380
movq 0x18(%rbx), %rcx
leaq 0x7220(%rip), %rdi      # 0xc283
movq %r15, %rsi
movq %r14, %rdx
callq 0x34d0
movq 0x50(%rbx), %rcx
movq (%rcx), %r12
movl $0xdc, %ebp
xorl %r15d, %r15d
movq 0x58(%rbx), %rax
subq %rcx, %rax
cqto
idivq %r13
cmpq %r14, %rax
jb 0x5152
movq -0x12(%rcx,%rbp), %rax
subq -0xdc(%rcx,%rbp), %rax
cmpq $0x100001, %rax         # imm = 0x100001
jb 0x5143
leaq (%rcx,%rbp), %rsi
addq $-0xca, %rsi
leaq 0x8(%rsp), %rdi
callq 0x3150
movq 0x18(%rbx), %rdi
movl %r14d, %edx
subl %r15d, %edx
leaq 0x7217(%rip), %rsi      # 0xc2e8
xorl %eax, %eax
callq 0x3380
movq 0x18(%rbx), %rdi
movq 0x28(%rsp), %rdx
movq 0x8(%rsp), %rcx
leaq 0x7201(%rip), %rsi      # 0xc2ee
xorl %eax, %eax
callq 0x3380
movq 0x18(%rbx), %rdi
movq 0x50(%rbx), %rax
movq -0xdc(%rax,%rbp), %rcx
leaq 0x7165(%rip), %rsi      # 0xc270
movq %r12, %rdx
xorl %eax, %eax
callq 0x3380
movq 0x50(%rbx), %rsi
movq 0x58(%rbx), %rax
subq %rsi, %rax
cqto
idivq %r13
cmpq %rax, %r14
je 0x5152
movq -0x12(%rsi,%rbp), %r12
addq %rbp, %rsi
leaq 0x28(%rsp), %rdi
callq 0x3150
movq 0x50(%rbx), %rcx
movl %r14d, %r15d
incq %r14
addq $0xca, %rbp
jmp 0x507d
leaq 0x8(%rsp), %rdi
callq 0x3100
leaq 0x28(%rsp), %rdi
callq 0x3100
xorl %eax, %eax
addq $0x48, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x5179
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x3100
leaq 0x28(%rsp), %rdi
callq 0x3100
movq %rbx, %rdi
callq 0x3480