// File: /workspace/github_cpp_makefile_star2_O1/ke6jjj[P]r-dat/AudioFrameReceiver.cc
// Function: AudioFrameReceiver::Stop()
void
AudioFrameReceiver::Stop()
{
  //
  // Processing has stopped. If we were dumping audio to a file, go back
  // and fill in the file headers.
  //
  if (mFile != NULL) {
    //
    // Write WAV header.
    //
    XDR hdr(kWAVHeaderSize);
    hdr.AddString("RIFF", 4);
    hdr.AddU32(kWAVFormatChunkHeaderSize+
               kWAVDataChunkHeaderSize+
               mFramesWritten * 4+
               4);
    hdr.AddString("WAVE", 4);
    
    fseek(mFile, SEEK_SET, 0);
    fwrite(hdr.Data(), hdr.Size(), 1, mFile);

    //
    // Write format chunk.
    //
    XDR xdr(kWAVFormatChunkHeaderSize);
    
    // ID             chunkID;
    xdr.AddString("fmt ", 4);
    // long           chunkSize;
    xdr.AddU32(kWAVFormatChunkHeaderSize-8);
    
    // short          wFormatTag;
    xdr.AddI16(1); // PCM data
    // unsigned short wChannels;
    xdr.AddU16(2);
    // unsigned long  dwSamplesPerSec;
    xdr.AddU32(48000);
    // unsigned long  dwAvgBytesPerSec;
    xdr.AddU32(48000 * 4); // 4 bytes per frame (2 16-bit samples)
    // unsigned short wBlockAlign;
    xdr.AddU16(4); // 4 bytes per frame (2 16-bit samples)
    // unsigned short wBitsPerSample;
    xdr.AddU16(16);

    fwrite(xdr.Data(), xdr.Size(), 1, mFile);

    //
    // Write data chunk.
    //
    XDR data(kWAVDataChunkHeaderSize);

    data.AddString("data", 4);
    data.AddU32(mFramesWritten * 4);

    fwrite(data.Data(), data.Size(), 1, mFile);

    //
    // Close file.
    //
    fclose(mFile);
    mFile = NULL;
  }
}

// Assembly:
pushq %r14
pushq %rbx
subq $0x48, %rsp
cmpq $0x0, 0x8(%rdi)
je 0x484f
movq %rdi, %rbx
leaq 0x30(%rsp), %r14
movl $0xc, %esi
movq %r14, %rdi
callq 0x75ec
leaq 0x586e(%rip), %rsi      # 0x9f1e
movl $0x4, %edx
movq %r14, %rdi
callq 0x7622
movl 0x10(%rbx), %eax
leal 0x24(,%rax,4), %esi
leaq 0x30(%rsp), %rdi
callq 0x772a
leaq 0x584b(%rip), %rsi      # 0x9f23
leaq 0x30(%rsp), %rdi
movl $0x4, %edx
callq 0x7622
movq 0x8(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2100
leaq 0x30(%rsp), %rdi
callq 0x7780
movq %rax, %r14
leaq 0x30(%rsp), %rdi
callq 0x7786
movq 0x8(%rbx), %rcx
movl $0x1, %edx
movq %r14, %rdi
movq %rax, %rsi
callq 0x21f0
movq %rsp, %rdi
movl $0x18, %esi
callq 0x75ec
leaq 0x57f5(%rip), %rsi      # 0x9f28
movq %rsp, %rdi
movl $0x4, %edx
callq 0x7622
movq %rsp, %rdi
movl $0x10, %esi
callq 0x772a
movq %rsp, %rdi
movl $0x1, %esi
callq 0x766c
movq %rsp, %rdi
movl $0x2, %esi
callq 0x76a0
movq %rsp, %rdi
movl $0xbb80, %esi           # imm = 0xBB80
callq 0x772a
movq %rsp, %rdi
movl $0x2ee00, %esi          # imm = 0x2EE00
callq 0x772a
movq %rsp, %rdi
movl $0x4, %esi
callq 0x76a0
movq %rsp, %rdi
movl $0x10, %esi
callq 0x76a0
movq %rsp, %rdi
callq 0x7780
movq %rax, %r14
movq %rsp, %rdi
callq 0x7786
movq 0x8(%rbx), %rcx
movl $0x1, %edx
movq %r14, %rdi
movq %rax, %rsi
callq 0x21f0
leaq 0x18(%rsp), %rdi
movl $0x8, %esi
callq 0x75ec
leaq 0x5755(%rip), %rsi      # 0x9f2d
leaq 0x18(%rsp), %rdi
movl $0x4, %edx
callq 0x7622
movl 0x10(%rbx), %esi
shll $0x2, %esi
leaq 0x18(%rsp), %rdi
callq 0x772a
leaq 0x18(%rsp), %rdi
callq 0x7780
movq %rax, %r14
leaq 0x18(%rsp), %rdi
callq 0x7786
movq 0x8(%rbx), %rcx
movl $0x1, %edx
movq %r14, %rdi
movq %rax, %rsi
callq 0x21f0
movq 0x8(%rbx), %rdi
callq 0x20d0
movq $0x0, 0x8(%rbx)
leaq 0x18(%rsp), %rdi
callq 0x7614
movq %rsp, %rdi
callq 0x7614
leaq 0x30(%rsp), %rdi
callq 0x7614
addq $0x48, %rsp
popq %rbx
popq %r14
retq
jmp 0x486f
jmp 0x486a
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x7614
jmp 0x4872
movq %rax, %rbx
jmp 0x487a
movq %rax, %rbx
movq %rsp, %rdi
callq 0x7614
leaq 0x30(%rsp), %rdi
callq 0x7614
movq %rbx, %rdi
callq 0x21d0