// File: /workspace/github_cpp_makefile_star2_O1/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 0x4fac
movq %r12, %rdi
movq %r15, %rsi
movq %r14, %rdx
callq 0x4ff6
movl %eax, %ebp
leaq 0x8(%rsp), %rdi
callq 0x4fd2
cmpl $0x6, %eax
jae 0x4a44
movl %eax, %eax
leaq 0x5891(%rip), %rcx      # 0xa2cc
movslq (%rcx,%rax,4), %r14
addq %rcx, %r14
jmp 0x4a4b
leaq 0x56cc(%rip), %r14      # 0xa117
movl $0xa, %edi
callq 0x2170
testl %ebp, %ebp
je 0x4a71
movl %ebp, %edi
callq 0x524e
leaq 0x56b2(%rip), %rdi      # 0xa119
movq %rax, %rsi
xorl %eax, %eax
callq 0x2040
leaq 0x56b5(%rip), %rdi      # 0xa12d
movq %r14, %rsi
xorl %eax, %eax
callq 0x2040
leaq 0x8(%rsp), %rdi
callq 0x4fda
leaq 0x56ae(%rip), %rdi      # 0xa141
movl %eax, %esi
xorl %eax, %eax
callq 0x2040
leaq 0x8(%rsp), %rdi
callq 0x4fde
leaq 0x56aa(%rip), %rdi      # 0xa157
movl %eax, %esi
xorl %eax, %eax
callq 0x2040
leaq 0x8(%rsp), %rdi
callq 0x4fe2
movzbl %al, %esi
leaq 0x56a3(%rip), %rdi      # 0xa16d
xorl %eax, %eax
callq 0x2040
leaq 0x8(%rsp), %rdi
callq 0x4fe6
testb %al, %al
je 0x4aed
leaq 0x569c(%rip), %rdi      # 0xa182
xorl %eax, %eax
callq 0x2040
leaq 0x8(%rsp), %rdi
callq 0x4fea
testb %al, %al
je 0x4b09
leaq 0x5691(%rip), %rdi      # 0xa193
xorl %eax, %eax
callq 0x2040
movl $0xa, %edi
callq 0x2170
leaq 0x8(%rsp), %rdi
callq 0x4fee
leaq 0x5677(%rip), %rdi      # 0xa19b
movl %eax, %esi
xorl %eax, %eax
callq 0x2040
leaq 0x8(%rsp), %rdi
callq 0x4ff2
leaq 0x5673(%rip), %rdi      # 0xa1b1
movl %eax, %esi
xorl %eax, %eax
callq 0x2040
leaq 0x8(%rsp), %rdi
callq 0x4fcc
movq %rax, %r15
movq %rax, %rdi
callq 0x5b0a
movq %rax, %r14
movq %r15, %rdi
callq 0x5b12
movq %rax, %r12
movq %r15, %rdi
callq 0x5b1a
movq %rax, %r15
subl %r12d, %r14d
subl %r15d, %r12d
leaq 0x5647(%rip), %rdi      # 0xa1c9
movl %r14d, %esi
movl %r12d, %edx
xorl %eax, %eax
callq 0x2040
testl %r15d, %r15d
je 0x4ba7
leaq 0x52dc(%rip), %rdi      # 0x9e77
movl %r15d, %esi
xorl %eax, %eax
callq 0x2040
jmp 0x4bb3
leaq 0x53c8(%rip), %rdi      # 0x9f76
callq 0x21b0
movl 0x18(%rbx), %eax
cmpl $0x1, %eax
je 0x4bd7
testl %eax, %eax
jne 0x4c03
leaq 0x8(%rsp), %rdi
callq 0x4fd2
cmpl $0x5, %eax
jne 0x4c03
movl $0x1, 0x18(%rbx)
jmp 0x4c03
leaq 0x8(%rsp), %rdi
callq 0x4fd2
cmpl $0x5, %eax
je 0x4c03
movl 0x2c(%rbx), %esi
incl %esi
movl %esi, 0x2c(%rbx)
movl $0x0, 0x18(%rbx)
leaq 0x55e3(%rip), %rdi      # 0xa1df
xorl %eax, %eax
callq 0x2040
cmpq $0x0, 0x20(%rbx)
je 0x4c4d
movl 0x2c(%rbx), %eax
cmpl 0x28(%rbx), %eax
jne 0x4c4d
leaq 0x8(%rsp), %rdi
callq 0x4fd2
cmpl $0x5, %eax
jne 0x4c31
cmpb $0x1, 0x10(%rbx)
jne 0x4c4d
movq %rbx, %rdi
callq 0x4c98
jmp 0x4c4d
leaq 0x8(%rsp), %rdi
callq 0x4fd2
cmpl $0x4, %eax
jne 0x4c4d
leaq 0x8(%rsp), %rsi
movq %rbx, %rdi
callq 0x4da2
movq 0xb36c(%rip), %rax      # 0xffc0
movq (%rax), %rdi
callq 0x2110
leaq 0x8(%rsp), %rdi
callq 0x4fc2
addq $0x2dc0, %rsp           # imm = 0x2DC0
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
jmp 0x4c82
jmp 0x4c82
jmp 0x4c82
jmp 0x4c82
jmp 0x4c82
jmp 0x4c82
movq %rax, %rbx
leaq 0x8(%rsp), %rdi
callq 0x4fc2
movq %rbx, %rdi
callq 0x21d0
nop