// File: /workspace/github_cpp_makefile_star2_O3/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 0x489d
movq %rdi, %rbx
leaq 0x30(%rsp), %r14
movl $0xc, %esi
movq %r14, %rdi
callq 0x764c
leaq 0x5830(%rip), %rsi      # 0x9f2e
movl $0x4, %edx
movq %r14, %rdi
callq 0x7682
movl 0x10(%rbx), %eax
leal 0x24(,%rax,4), %esi
leaq 0x30(%rsp), %rdi
callq 0x778a
leaq 0x580d(%rip), %rsi      # 0x9f33
leaq 0x30(%rsp), %rdi
movl $0x4, %edx
callq 0x7682
movq 0x8(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x2100
leaq 0x30(%rsp), %rdi
callq 0x77e0
movq %rax, %r14
leaq 0x30(%rsp), %rdi
callq 0x77e6
movq 0x8(%rbx), %rcx
movl $0x1, %edx
movq %r14, %rdi
movq %rax, %rsi
callq 0x21f0
movq %rsp, %rdi
movl $0x18, %esi
callq 0x764c
leaq 0x57b7(%rip), %rsi      # 0x9f38
movq %rsp, %rdi
movl $0x4, %edx
callq 0x7682
movq %rsp, %rdi
movl $0x10, %esi
callq 0x778a
movq %rsp, %rdi
movl $0x1, %esi
callq 0x76cc
movq %rsp, %rdi
movl $0x2, %esi
callq 0x7700
movq %rsp, %rdi
movl $0xbb80, %esi           # imm = 0xBB80
callq 0x778a
movq %rsp, %rdi
movl $0x2ee00, %esi          # imm = 0x2EE00
callq 0x778a
movq %rsp, %rdi
movl $0x4, %esi
callq 0x7700
movq %rsp, %rdi
movl $0x10, %esi
callq 0x7700
movq %rsp, %rdi
callq 0x77e0
movq %rax, %r14
movq %rsp, %rdi
callq 0x77e6
movq 0x8(%rbx), %rcx
movl $0x1, %edx
movq %r14, %rdi
movq %rax, %rsi
callq 0x21f0
leaq 0x18(%rsp), %rdi
movl $0x8, %esi
callq 0x764c
leaq 0x5717(%rip), %rsi      # 0x9f3d
leaq 0x18(%rsp), %rdi
movl $0x4, %edx
callq 0x7682
movl 0x10(%rbx), %esi
shll $0x2, %esi
leaq 0x18(%rsp), %rdi
callq 0x778a
leaq 0x18(%rsp), %rdi
callq 0x77e0
movq %rax, %r14
leaq 0x18(%rsp), %rdi
callq 0x77e6
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 0x7674
movq %rsp, %rdi
callq 0x7674
leaq 0x30(%rsp), %rdi
callq 0x7674
addq $0x48, %rsp
popq %rbx
popq %r14
retq
jmp 0x48bd
jmp 0x48b8
movq %rax, %rbx
leaq 0x18(%rsp), %rdi
callq 0x7674
jmp 0x48c0
movq %rax, %rbx
jmp 0x48c8
movq %rax, %rbx
movq %rsp, %rdi
callq 0x7674
leaq 0x30(%rsp), %rdi
callq 0x7674
movq %rbx, %rdi
callq 0x21d0