// File: /workspace/github_cpp_makefile_star2_O1/4n6ist[P]usn_analytics/lib/usnjrnl.cpp
// Function: UsnJrnl::GetAllUsnOffset()
int UsnJrnl::GetAllUsnOffset() {
  int result;
  uint64_t progress = file_size / 10; 
  offset = 0;  
    
  while(offset <= file_size-sizeof(USN_RECORD_V2)) {
    
    if(offset >= progress) {
      printf(".");
      progress += file_size / 10;
    }

    UsnRecord* ur = new UsnRecord(fp_in);
    result = ur->IsValidRecord(offset);

    if(result == NOT_RECORD) {
      offset += 8;
      delete ur;
      continue;
    } else if(result == V2_RECORD) {
	    usn_set.push_back(ur->usn_record.Usn);
	    usn_table[ur->usn_record.Usn] = offset;
	  } else if(result == CORRUPT_RECORD) {
      corrupt_offset_set.push_back(offset);
    } else if (result == V3_RECORD) {
      printf("USN_RECORD_V3 found at offset %lld, skip\n", offset);
	  } else if (result == V4_RECORD) {
      printf("USN_RECORD_V4 found at offset %lld, skip\n", offset);
	  } 
	  offset += ur->usn_record.RecordLength;
    delete ur;
  }
  printf("Done\n");
  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, %rbx
leaq 0x8(%rdi), %r14
movq $0x0, 0x8(%rdi)
movabsq $-0x3333333333333333, %r15 # imm = 0xCCCCCCCCCCCCCCCD
movq %r15, %rax
mulq (%rdi)
movq %rdx, %r12
shrq $0x3, %r12
leaq 0x38(%rdi), %rax
movq %rax, 0x8(%rsp)
leaq 0x20(%rdi), %rax
movq %rax, (%rsp)
leaq 0x68(%rdi), %rax
movq %rax, 0x10(%rsp)
leaq 0xb489(%rip), %r13      # 0xf004
xorl %eax, %eax
cmpq %r12, %rax
jb 0x3b99
movl $0x2e, %edi
callq 0x3340
movq %r15, %rax
mulq (%rbx)
shrq $0x3, %rdx
addq %rdx, %r12
movl $0x80, %edi
callq 0x3220
movq %rax, %rbp
movq 0x10(%rbx), %rsi
movq %rax, %rdi
callq 0xbb00
movq (%r14), %rsi
movq %rbp, %rdi
callq 0xbb18
addl $0x2, %eax
cmpl $0x6, %eax
ja 0x3c78
movslq (%r13,%rax,4), %rax
addq %r13, %rax
jmpq *%rax
movq 0x40(%rbx), %rsi
cmpq 0x48(%rbx), %rsi
je 0x3c6b
movq 0x8(%rbx), %rax
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x40(%rbx)
jmp 0x3c78
leaq 0x28(%rbp), %r13
movq 0x28(%rbx), %rsi
cmpq 0x30(%rbx), %rsi
je 0x3c39
movq (%r13), %rax
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x28(%rbx)
jmp 0x3c45
addq $0x8, (%r14)
jmp 0x3c7e
movq (%r14), %rsi
leaq 0xb474(%rip), %rdi      # 0xf098
jmp 0x3c30
movq (%r14), %rsi
leaq 0xb492(%rip), %rdi      # 0xf0c2
xorl %eax, %eax
callq 0x3040
jmp 0x3c78
movq (%rsp), %rdi
movq %r13, %rdx
callq 0x984e
movq (%r14), %r15
movq 0x10(%rsp), %rdi
movq %r13, %rsi
callq 0x8e80
movq %r15, (%rax)
movabsq $-0x3333333333333333, %r15 # imm = 0xCCCCCCCCCCCCCCCD
leaq 0xb39b(%rip), %r13      # 0xf004
jmp 0x3c78
movq 0x8(%rsp), %rdi
movq %r14, %rdx
callq 0x984e
movl 0x10(%rbp), %eax
addq %rax, (%r14)
movq 0x60(%rbp), %rdi
movq %rbp, %rax
addq $0x70, %rax
cmpq %rax, %rdi
je 0x3c99
movq (%rax), %rsi
incq %rsi
callq 0x3230
movl $0x80, %esi
movq %rbp, %rdi
callq 0x3230
movq (%rbx), %rcx
movq 0x8(%rbx), %rax
addq $-0x3c, %rcx
cmpq %rcx, %rax
jbe 0x3b7d
leaq 0xb96f(%rip), %rdi      # 0xf630
callq 0x33e0
xorl %eax, %eax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
movl $0x80, %esi
movq %rbp, %rdi
callq 0x3230
movq %rbx, %rdi
callq 0x3470
nop