// File: 4n6ist[P]usn_analytics/lib/usnjrnl.cpp
// Function: UsnJrnl::PreProcess()
int UsnJrnl::PreProcess() {
  uint64_t usn_num = usn_set.size();

  printf("%8lu corrupt records skipped\n", corrupt_offset_set.size());
  printf("%8llu records found\n", usn_num);
  fprintf(fp_ofreport, "%8lu corrupt records skipped\n", corrupt_offset_set.size());
  fprintf(fp_ofreport, "%8llu records\n", usn_num);   

  // USN Sort & Deduplication
  sort(usn_set.begin(), usn_set.end());
  usn_set.erase(std::unique(usn_set.begin(), usn_set.end()), usn_set.end());
  
  if (usn_num != usn_set.size()) {
    printf("%8llu duplicate records found\n", usn_num - usn_set.size()); 
    printf("%8lu unique records found\n", usn_set.size()); 
    fprintf(fp_ofreport, "%8llu duplicate records\n", usn_num - usn_set.size()); 
    fprintf(fp_ofreport, "%8lu unique records\n", usn_set.size()); 
  }
  
  return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xa0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x68(%rbp)
addq $0x20, %rdi
callq 0xa620
movq -0x68(%rbp), %rdi
movq %rax, -0x10(%rbp)
addq $0x38, %rdi
callq 0xa620
movq %rax, %rsi
leaq 0x18241(%rip), %rdi     # 0x1c0ec
movb $0x0, %al
callq 0x3060
movq -0x10(%rbp), %rsi
leaq 0x1824d(%rip), %rdi     # 0x1c10a
movb $0x0, %al
callq 0x3060
movq -0x68(%rbp), %rdi
movq 0x18(%rdi), %rax
movq %rax, -0x78(%rbp)
addq $0x38, %rdi
callq 0xa620
movq -0x78(%rbp), %rdi
movq %rax, %rdx
leaq 0x18205(%rip), %rsi     # 0x1c0ec
movb $0x0, %al
callq 0x34d0
movq -0x68(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x10(%rbp), %rdx
leaq 0x1821e(%rip), %rsi     # 0x1c11f
movb $0x0, %al
callq 0x34d0
movq -0x68(%rbp), %rdi
addq $0x20, %rdi
callq 0xa680
movq -0x68(%rbp), %rdi
movq %rax, -0x18(%rbp)
addq $0x20, %rdi
callq 0xa6b0
movq %rax, -0x20(%rbp)
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0xa640
movq -0x68(%rbp), %rdi
movq %rdi, %rax
addq $0x20, %rax
movq %rax, -0x70(%rbp)
addq $0x20, %rdi
callq 0xa680
movq -0x68(%rbp), %rdi
movq %rax, -0x38(%rbp)
addq $0x20, %rdi
callq 0xa6b0
movq %rax, -0x40(%rbp)
movq -0x38(%rbp), %rdi
movq -0x40(%rbp), %rsi
callq 0xa770
movq %rax, -0x30(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0xa7b0
movq -0x68(%rbp), %rdi
addq $0x20, %rdi
callq 0xa6b0
movq %rax, -0x50(%rbp)
leaq -0x48(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0xa7b0
movq -0x70(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0xa6e0
movq -0x68(%rbp), %rdi
movq %rax, -0x58(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x60(%rbp)
addq $0x20, %rdi
callq 0xa620
movq %rax, %rcx
movq -0x60(%rbp), %rax
cmpq %rcx, %rax
je 0x4094
movq -0x68(%rbp), %rdi
movq -0x10(%rbp), %rax
movq %rax, -0x98(%rbp)
addq $0x20, %rdi
callq 0xa620
movq -0x98(%rbp), %rsi
subq %rax, %rsi
leaq 0x1812b(%rip), %rdi     # 0x1c12e
movb $0x0, %al
callq 0x3060
movq -0x68(%rbp), %rdi
addq $0x20, %rdi
callq 0xa620
movq %rax, %rsi
leaq 0x1812c(%rip), %rdi     # 0x1c14d
movb $0x0, %al
callq 0x3060
movq -0x68(%rbp), %rdi
movq 0x18(%rdi), %rax
movq %rax, -0x88(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x90(%rbp)
addq $0x20, %rdi
callq 0xa620
movq -0x90(%rbp), %rdx
movq -0x88(%rbp), %rdi
subq %rax, %rdx
leaq 0x18105(%rip), %rsi     # 0x1c168
movb $0x0, %al
callq 0x34d0
movq -0x68(%rbp), %rdi
movq 0x18(%rdi), %rax
movq %rax, -0x80(%rbp)
addq $0x20, %rdi
callq 0xa620
movq -0x80(%rbp), %rdi
movq %rax, %rdx
leaq 0x180f4(%rip), %rsi     # 0x1c181
movb $0x0, %al
callq 0x34d0
xorl %eax, %eax
addq $0xa0, %rsp
popq %rbp
retq
nop