// File: /workspace/github_cpp_makefile_star2_O3/ke6jjj[P]r-dat/DDSFrameReceiver.cc
// Function: DDSFrameReceiver::ReceiveFrame(Track const&, Track const&)
void
DDSFrameReceiver::ReceiveFrame(const Track& a, const Track& b)
{
  //
  // Construct a new DDS Group 3 object to receive the track pair
  //
  DDSGroup3 frame;
  
  //
  // Combine the tracks into a frame and do all the necessary
  // de-interleaving.
  //
  DDSGroup3::DecodeError result = frame.DecodeFrame(a, b);
  
  //
  // Dump information about the frame.
  //
  const char *area_name;
  switch (frame.Area()) {
  case DDSGroup3::DEVICE_AREA:
    area_name = "DEVICE";
    break;
  case DDSGroup3::REFERENCE_AREA:
    area_name = "REFERENCE";
    break;
  case DDSGroup3::SYSTEM_AREA:
    area_name = "SYSTEM";
    break;
  case DDSGroup3::DATA_AREA:
    area_name = "DATA";
    break;
  case DDSGroup3::EOD_AREA:
    area_name = "END-OF-DATA";
    break;
  default:
    area_name = "?";
    break;
  }
  
  printf("\n");

  if (result != DDSGroup3::DECODE_OK) {
    printf("Group 3 decode: %s\n",
      DDSGroup3::ErrorDescription(result)
    );
  }
  
  printf("Area          : %s\n", area_name);
  printf("Absolute frame: %06d\n", frame.AbsoluteFrameID());
  printf("Basic Group   : %05d\n", frame.BasicGroupID());
  printf("Sub frame     : %02d", frame.LogicalFrameID());
  if (frame.IsLastLogicalFrame())
    printf(" (Last of group)");
  if (frame.IsECC3Frame())
    printf(" (ECC3)");
  printf("\n");
  printf("File          : %04d\n", frame.Separator1Count());
  printf("Record        : 0x%08x\n", frame.RecordCount());

  //
  // Print out error statistics for the frame.
  //
  const DATFrame& underFrame = frame.Frame();

  unsigned int c1_errors = underFrame.C1Errors();
  unsigned int c1_uncorrectable = underFrame.C1UncorrectableErrors();
  unsigned int c1_corrected = c1_errors - c1_uncorrectable;
  unsigned int c2_uncorrectable = underFrame.C2UncorrectableErrors();
  unsigned int c2_corrected = c1_uncorrectable - c2_uncorrectable;

  printf("Errors  C1/C2 : %d/%d",
    c1_corrected,
    c2_corrected
  );

  if (c2_uncorrectable > 0)
    printf(" %d UNCORRECTED\n", c2_uncorrectable);
  else
    printf(" (all corrected)\n");

  switch (mState) {
  case DATA:
    //
    // In data state until we see an END-OF-DATA marker.
    //
    if (frame.Area() == DDSGroup3::EOD_AREA)
      mState = EOT;
    break;
  case EOT:
    //
    // We're in EOT state until we see another area.
    //
    if (frame.Area() != DDSGroup3::EOD_AREA) {
      //
      // We're in a new tape session.
      //
      mCurrentSession++;
      mState = DATA;
      printf("------------------------ START OF SESSION %d\n", mCurrentSession);
    }
  }
  
  //
  // If we hit an End-of-File mark we need to stop; any data after this mark
  // may have duplicate group identifiers and will corrupt any existing
  // groups before it.
  //
  if (mOutputDirectory != NULL && mCurrentSession == mDumpSession) {
    if (frame.Area() == DDSGroup3::EOD_AREA) {
      if (mHaveGroup) {
        DumpGroup();
      }
    } else if (frame.Area() == DDSGroup3::DATA_AREA) {
      AddFrame(frame);
    }
  }

  fflush(stdout);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x2dc0, %rsp           # imm = 0x2DC0
movq %rdx, %r14
movq %rsi, %r15
movq %rdi, %rbx
leaq 0x8(%rsp), %r12
movq %r12, %rdi
callq 0x5000
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x504a
movl %eax, %ebp
leaq 0x8(%rsp), %rdi
callq 0x5026
cmpl $0x6, %eax
jae 0x4a98
movl %eax, %eax
leaq 0x584d(%rip), %rcx      # 0xa2dc
movslq (%rcx,%rax,4), %r14
addq %rcx, %r14
jmp 0x4a9f
leaq 0x5688(%rip), %r14      # 0xa127
movl $0xa, %edi
callq 0x2170
testl %ebp, %ebp
je 0x4ac5
movl %ebp, %edi
callq 0x52a2
leaq 0x566e(%rip), %rdi      # 0xa129
movq %rax, %rsi
xorl %eax, %eax
callq 0x2040
leaq 0x5671(%rip), %rdi      # 0xa13d
movq %r14, %rsi
xorl %eax, %eax
callq 0x2040
leaq 0x8(%rsp), %rdi
callq 0x502e
leaq 0x566a(%rip), %rdi      # 0xa151
movl %eax, %esi
xorl %eax, %eax
callq 0x2040
leaq 0x8(%rsp), %rdi
callq 0x5032
leaq 0x5666(%rip), %rdi      # 0xa167
movl %eax, %esi
xorl %eax, %eax
callq 0x2040
leaq 0x8(%rsp), %rdi
callq 0x5036
movzbl %al, %esi
leaq 0x565f(%rip), %rdi      # 0xa17d
xorl %eax, %eax
callq 0x2040
leaq 0x8(%rsp), %rdi
callq 0x503a
testb %al, %al
je 0x4b41
leaq 0x5658(%rip), %rdi      # 0xa192
xorl %eax, %eax
callq 0x2040
leaq 0x8(%rsp), %rdi
callq 0x503e
testb %al, %al
je 0x4b5d
leaq 0x564d(%rip), %rdi      # 0xa1a3
xorl %eax, %eax
callq 0x2040
movl $0xa, %edi
callq 0x2170
leaq 0x8(%rsp), %rdi
callq 0x5042
leaq 0x5633(%rip), %rdi      # 0xa1ab
movl %eax, %esi
xorl %eax, %eax
callq 0x2040
leaq 0x8(%rsp), %rdi
callq 0x5046
leaq 0x562f(%rip), %rdi      # 0xa1c1
movl %eax, %esi
xorl %eax, %eax
callq 0x2040
leaq 0x8(%rsp), %rdi
callq 0x5020
movq %rax, %r15
movq %rax, %rdi
callq 0x5b44
movq %rax, %r14
movq %r15, %rdi
callq 0x5b4c
movq %rax, %r12
movq %r15, %rdi
callq 0x5b54
movq %rax, %r15
subl %r12d, %r14d
subl %r15d, %r12d
leaq 0x5603(%rip), %rdi      # 0xa1d9
movl %r14d, %esi
movl %r12d, %edx
xorl %eax, %eax
callq 0x2040
testl %r15d, %r15d
je 0x4bfb
leaq 0x5298(%rip), %rdi      # 0x9e87
movl %r15d, %esi
xorl %eax, %eax
callq 0x2040
jmp 0x4c07
leaq 0x5384(%rip), %rdi      # 0x9f86
callq 0x21b0
movl 0x18(%rbx), %eax
cmpl $0x1, %eax
je 0x4c2b
testl %eax, %eax
jne 0x4c57
leaq 0x8(%rsp), %rdi
callq 0x5026
cmpl $0x5, %eax
jne 0x4c57
movl $0x1, 0x18(%rbx)
jmp 0x4c57
leaq 0x8(%rsp), %rdi
callq 0x5026
cmpl $0x5, %eax
je 0x4c57
movl 0x2c(%rbx), %esi
incl %esi
movl %esi, 0x2c(%rbx)
movl $0x0, 0x18(%rbx)
leaq 0x559f(%rip), %rdi      # 0xa1ef
xorl %eax, %eax
callq 0x2040
cmpq $0x0, 0x20(%rbx)
je 0x4ca1
movl 0x2c(%rbx), %eax
cmpl 0x28(%rbx), %eax
jne 0x4ca1
leaq 0x8(%rsp), %rdi
callq 0x5026
cmpl $0x5, %eax
jne 0x4c85
cmpb $0x1, 0x10(%rbx)
jne 0x4ca1
movq %rbx, %rdi
callq 0x4cec
jmp 0x4ca1
leaq 0x8(%rsp), %rdi
callq 0x5026
cmpl $0x4, %eax
jne 0x4ca1
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x4df6
movq 0xb318(%rip), %rax      # 0xffc0
movq (%rax), %rdi
callq 0x2110
leaq 0x8(%rsp), %rdi
callq 0x5016
addq $0x2dc0, %rsp           # imm = 0x2DC0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4cd6
jmp 0x4cd6
jmp 0x4cd6
jmp 0x4cd6
jmp 0x4cd6
jmp 0x4cd6
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x5016
movq %rbx, %rdi
callq 0x21d0
nop