// File: 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
movq %rsp, %rbp
subq $0x2e90, %rsp           # imm = 0x2E90
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x2e20(%rbp)
leaq -0x2dd0(%rbp), %rdi
movq %rdi, -0x2e18(%rbp)
callq 0x7600
movq -0x2e18(%rbp), %rdi
movq -0x10(%rbp), %rsi
movq -0x18(%rbp), %rdx
callq 0x7780
movl %eax, -0x2e10(%rbp)
jmp 0x6cf1
movl -0x2e10(%rbp), %eax
movl %eax, -0x2dd4(%rbp)
leaq -0x2dd0(%rbp), %rdi
callq 0x7670
movl %eax, -0x2e24(%rbp)
jmp 0x6d11
movl -0x2e24(%rbp), %eax
movl %eax, %ecx
movq %rcx, -0x2e30(%rbp)
subl $0x5, %eax
ja 0x6db3
movq -0x2e30(%rbp), %rax
leaq 0x8415(%rip), %rcx      # 0xf14c
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x2de0(%rbp)
movl %eax, -0x2de4(%rbp)
leaq -0x2dd0(%rbp), %rdi
callq 0x7630
jmp 0x71c4
leaq 0x840d(%rip), %rax      # 0xf177
movq %rax, -0x2df0(%rbp)
jmp 0x6dc1
leaq 0x8404(%rip), %rax      # 0xf17e
movq %rax, -0x2df0(%rbp)
jmp 0x6dc1
leaq 0x83fe(%rip), %rax      # 0xf188
movq %rax, -0x2df0(%rbp)
jmp 0x6dc1
leaq 0x83fc(%rip), %rax      # 0xf196
movq %rax, -0x2df0(%rbp)
jmp 0x6dc1
leaq 0x83e5(%rip), %rax      # 0xf18f
movq %rax, -0x2df0(%rbp)
jmp 0x6dc1
leaq 0x80aa(%rip), %rax      # 0xee64
movq %rax, -0x2df0(%rbp)
leaq 0x8721(%rip), %rdi      # 0xf4e9
xorl %eax, %eax
callq 0x2040
jmp 0x6dd1
cmpl $0x0, -0x2dd4(%rbp)
je 0x6e07
movl -0x2dd4(%rbp), %edi
callq 0x7eb0
movq %rax, -0x2e38(%rbp)
jmp 0x6dee
movq -0x2e38(%rbp), %rsi
leaq 0x839f(%rip), %rdi      # 0xf19b
xorl %eax, %eax
callq 0x2040
jmp 0x6e05
jmp 0x6e07
movq -0x2df0(%rbp), %rsi
leaq 0x839a(%rip), %rdi      # 0xf1af
xorl %eax, %eax
callq 0x2040
jmp 0x6e1e
leaq -0x2dd0(%rbp), %rdi
callq 0x76a0
movl %eax, -0x2e3c(%rbp)
jmp 0x6e32
movl -0x2e3c(%rbp), %esi
leaq 0x8384(%rip), %rdi      # 0xf1c3
xorl %eax, %eax
callq 0x2040
jmp 0x6e48
leaq -0x2dd0(%rbp), %rdi
callq 0x76c0
movl %eax, -0x2e40(%rbp)
jmp 0x6e5c
movl -0x2e40(%rbp), %esi
leaq 0x8370(%rip), %rdi      # 0xf1d9
xorl %eax, %eax
callq 0x2040
jmp 0x6e72
leaq -0x2dd0(%rbp), %rdi
callq 0x76e0
movb %al, -0x2e41(%rbp)
jmp 0x6e86
movb -0x2e41(%rbp), %al
movzbl %al, %esi
leaq 0x8359(%rip), %rdi      # 0xf1ef
xorl %eax, %eax
callq 0x2040
jmp 0x6e9f
leaq -0x2dd0(%rbp), %rdi
callq 0x7700
movb %al, -0x2e42(%rbp)
jmp 0x6eb3
movb -0x2e42(%rbp), %al
testb $0x1, %al
jne 0x6ebf
jmp 0x6ed1
leaq 0x833e(%rip), %rdi      # 0xf204
xorl %eax, %eax
callq 0x2040
jmp 0x6ecf
jmp 0x6ed1
leaq -0x2dd0(%rbp), %rdi
callq 0x7720
movb %al, -0x2e43(%rbp)
jmp 0x6ee5
movb -0x2e43(%rbp), %al
testb $0x1, %al
jne 0x6ef1
jmp 0x6f03
leaq 0x831d(%rip), %rdi      # 0xf215
xorl %eax, %eax
callq 0x2040
jmp 0x6f01
jmp 0x6f03
leaq 0x85df(%rip), %rdi      # 0xf4e9
xorl %eax, %eax
callq 0x2040
jmp 0x6f13
leaq -0x2dd0(%rbp), %rdi
callq 0x7740
movl %eax, -0x2e48(%rbp)
jmp 0x6f27
movl -0x2e48(%rbp), %esi
leaq 0x82e9(%rip), %rdi      # 0xf21d
xorl %eax, %eax
callq 0x2040
jmp 0x6f3d
leaq -0x2dd0(%rbp), %rdi
callq 0x7760
movl %eax, -0x2e4c(%rbp)
jmp 0x6f51
movl -0x2e4c(%rbp), %esi
leaq 0x82d5(%rip), %rdi      # 0xf233
xorl %eax, %eax
callq 0x2040
jmp 0x6f67
leaq -0x2dd0(%rbp), %rdi
callq 0x7650
movq %rax, -0x2e58(%rbp)
jmp 0x6f7c
movq -0x2e58(%rbp), %rax
movq %rax, -0x2df8(%rbp)
movq -0x2df8(%rbp), %rdi
callq 0x91f0
movq %rax, -0x2e60(%rbp)
jmp 0x6f9f
movq -0x2e60(%rbp), %rax
movl %eax, -0x2dfc(%rbp)
movq -0x2df8(%rbp), %rdi
callq 0x9210
movq %rax, -0x2e68(%rbp)
jmp 0x6fc1
movq -0x2e68(%rbp), %rax
movl %eax, -0x2e00(%rbp)
movl -0x2dfc(%rbp), %eax
movl -0x2e00(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x2e04(%rbp)
movq -0x2df8(%rbp), %rdi
callq 0x9230
movq %rax, -0x2e70(%rbp)
jmp 0x6ff7
movq -0x2e70(%rbp), %rax
movl %eax, -0x2e08(%rbp)
movl -0x2e00(%rbp), %eax
movl -0x2e08(%rbp), %ecx
subl %ecx, %eax
movl %eax, -0x2e0c(%rbp)
movl -0x2e04(%rbp), %esi
movl -0x2e0c(%rbp), %edx
leaq 0x8220(%rip), %rdi      # 0xf24b
xorl %eax, %eax
callq 0x2040
jmp 0x7034
cmpl $0x0, -0x2e08(%rbp)
jbe 0x7055
movl -0x2e08(%rbp), %esi
leaq 0x7f87(%rip), %rdi      # 0xefd1
xorl %eax, %eax
callq 0x2040
jmp 0x7053
jmp 0x7067
leaq 0x7f86(%rip), %rdi      # 0xefe2
xorl %eax, %eax
callq 0x2040
jmp 0x7065
jmp 0x7067
movq -0x2e20(%rbp), %rax
movl 0x18(%rax), %eax
movl %eax, -0x2e74(%rbp)
testl %eax, %eax
je 0x708a
jmp 0x707d
movl -0x2e74(%rbp), %eax
subl $0x1, %eax
je 0x70b9
jmp 0x7105
leaq -0x2dd0(%rbp), %rdi
callq 0x7670
movl %eax, -0x2e78(%rbp)
jmp 0x709e
movl -0x2e78(%rbp), %eax
cmpl $0x5, %eax
jne 0x70b7
movq -0x2e20(%rbp), %rax
movl $0x1, 0x18(%rax)
jmp 0x7105
leaq -0x2dd0(%rbp), %rdi
callq 0x7670
movl %eax, -0x2e7c(%rbp)
jmp 0x70cd
movl -0x2e7c(%rbp), %eax
cmpl $0x5, %eax
je 0x7103
movq -0x2e20(%rbp), %rax
movl 0x2c(%rax), %ecx
incl %ecx
movl %ecx, 0x2c(%rax)
movl $0x0, 0x18(%rax)
movl 0x2c(%rax), %esi
leaq 0x8169(%rip), %rdi      # 0xf261
xorl %eax, %eax
callq 0x2040
jmp 0x7101
jmp 0x7103
jmp 0x7105
movq -0x2e20(%rbp), %rax
cmpq $0x0, 0x20(%rax)
je 0x719e
movq -0x2e20(%rbp), %rcx
movl 0x2c(%rcx), %eax
cmpl 0x28(%rcx), %eax
jne 0x719e
leaq -0x2dd0(%rbp), %rdi
callq 0x7670
movl %eax, -0x2e80(%rbp)
jmp 0x713a
movl -0x2e80(%rbp), %eax
cmpl $0x5, %eax
jne 0x7164
movq -0x2e20(%rbp), %rax
testb $0x1, 0x10(%rax)
je 0x7162
movq -0x2e20(%rbp), %rdi
callq 0x71d0
jmp 0x7160
jmp 0x7162
jmp 0x719c
leaq -0x2dd0(%rbp), %rdi
callq 0x7670
movl %eax, -0x2e84(%rbp)
jmp 0x7178
movl -0x2e84(%rbp), %eax
cmpl $0x4, %eax
jne 0x719a
movq -0x2e20(%rbp), %rdi
leaq -0x2dd0(%rbp), %rsi
callq 0x7300
jmp 0x7198
jmp 0x719a
jmp 0x719c
jmp 0x719e
movq 0xde1b(%rip), %rax      # 0x14fc0
movq (%rax), %rdi
callq 0x2120
jmp 0x71af
leaq -0x2dd0(%rbp), %rdi
callq 0x7630
addq $0x2e90, %rsp           # imm = 0x2E90
popq %rbp
retq
movq -0x2de0(%rbp), %rdi
callq 0x21d0