// File: /workspace/github_cpp_makefile_star2_O2/wrighteagle2d[P]wrighteaglebase/Debug/../src/DynamicDebug.cpp
// Function: DynamicDebug::Flush()
void DynamicDebug::Flush() {
  if (PlayerParam::instance().SaveServerMessage() &&
      !PlayerParam::instance().DynamicDebugMode()) {
    if (mpFile != 0) {
      long long i = 0; // 循环变量
      // mFileHead.mHeadFlag[0] = 'D';
      // mFileHead.mHeadFlag[1] = 'D';

      // 赋值4个表的大小，后面将要写到文件中
      mFileHead.mIndexTableSize = mIndexTable.size();
      mFileHead.mParserTableSize = mParserTimeTable.size();
      mFileHead.mDecisionTableSize = mDecisionTimeTable.size();
      mFileHead.mCommandSendTableSize = mCommandSendTimeTable.size();

      // message
      long long size = mFileHead.mIndexTableSize;
      for (i = 0; i < size; ++i) {
        mIndexTable[i].mDataOffset = ftell(mpFile);
        fwrite(&mMessageTable[i].mType, 1, 1, mpFile); // 先写入消息类型
        fwrite(mMessageTable[i].mString.c_str(), mIndexTable[i].mDataSize, 1,
               mpFile);
      }

      // index table
      mFileHead.mIndexTableOffset = ftell(mpFile);
      mpIndex = new MessageIndexTableUnit[size];
      for (i = 0; i < size; ++i) {
        memcpy(&mpIndex[i], &mIndexTable[i], sizeof(MessageIndexTableUnit));
      }
      fwrite(mpIndex, size * sizeof(MessageIndexTableUnit), 1, mpFile);

      // observer time
      mFileHead.mParserTableOffset = ftell(mpFile);
      size = mFileHead.mParserTableSize;
      mpParserTime = new timeval[size];
      for (i = 0; i < size; ++i) {
        mpParserTime[i] = mParserTimeTable[i];
      }
      fwrite(mpParserTime, size * sizeof(timeval), 1, mpFile);

      // decision time
      mFileHead.mDecisionTableOffset = ftell(mpFile);
      size = mFileHead.mDecisionTableSize;
      mpDecisionTime = new timeval[size];
      for (i = 0; i < size; ++i) {
        mpDecisionTime[i] = mDecisionTimeTable[i];
      }
      fwrite(mpDecisionTime, size * sizeof(timeval), 1, mpFile);

      // commandsend time
      mFileHead.mCommandSendTableOffset = ftell(mpFile);
      size = mFileHead.mCommandSendTableSize;
      mpCommandSendTime = new timeval[size];
      for (i = 0; i < size; ++i) {
        mpCommandSendTime[i] = mCommandSendTimeTable[i];
      }
      fwrite(mpCommandSendTime, size * sizeof(timeval), 1, mpFile);

      fseek(mpFile, 0, SEEK_SET);
      fprintf(mpFile, "DD");
      fwrite(&mFileHead, sizeof(mFileHead), 1, mpFile);
    }

    if (mpFile != 0) {
      fclose(mpFile);
    }
  }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %rdi, %rbx
callq 0x38d94
cmpb $0x1, 0x5c42(%rax)
jne 0x1d7b4
callq 0x38d94
cmpb $0x0, 0x5c40(%rax)
jne 0x1d7b4
cmpq $0x0, 0x120(%rbx)
je 0x1d7b4
movq 0x58(%rbx), %rcx
movq 0x60(%rbx), %rax
movq %rax, -0x40(%rbp)
movq %rcx, -0x30(%rbp)
subq %rcx, %rax
movq %rax, -0x48(%rbp)
movq %rax, %rcx
sarq $0x5, %rcx
movq %rcx, 0x18(%rbx)
movq 0x78(%rbx), %rax
subq 0x70(%rbx), %rax
sarq $0x4, %rax
movq %rax, 0x28(%rbx)
movq 0x90(%rbx), %rax
subq 0x88(%rbx), %rax
sarq $0x4, %rax
movq %rax, 0x38(%rbx)
movq 0xa8(%rbx), %rax
subq 0xa0(%rbx), %rax
sarq $0x4, %rax
xorl %r13d, %r13d
testq %rcx, %rcx
movl $0x0, %r12d
movq %rcx, -0x38(%rbp)
cmovgq %rcx, %r12
movq %rax, 0x48(%rbx)
shlq $0x5, %r12
pushq $0x1
popq %r14
xorl %r15d, %r15d
cmpq %r15, %r12
je 0x1d53f
movq 0x120(%rbx), %rdi
callq 0x9030
movq 0x58(%rbx), %rcx
movq %rax, 0x10(%rcx,%r15)
movq 0xb8(%rbx), %rax
movq 0x120(%rbx), %rsi
movsbl (%rax,%r13), %edi
callq 0x9600
movq 0x58(%rbx), %rax
movq 0xb8(%rbx), %rcx
movq 0x8(%rcx,%r13), %rdi
movq 0x8(%rax,%r15), %rsi
movq 0x120(%rbx), %rcx
movq %r14, %rdx
callq 0x9990
addq $0x20, %r15
addq $0x28, %r13
jmp 0x1d4df
movq 0x120(%rbx), %rdi
callq 0x9030
movq %rax, 0x20(%rbx)
movq -0x38(%rbp), %rax
shrq $0x3b, %rax
xorl %edi, %edi
negq %rax
sbbq %rdi, %rdi
movq -0x48(%rbp), %r15
orq %r15, %rdi
callq 0x9050
movq -0x40(%rbp), %rcx
cmpq -0x30(%rbp), %rcx
je 0x1d58f
movq %rax, %rcx
addq %r15, %rcx
movl $0xfffffffd, %edx       # imm = 0xFFFFFFFD
movq %rax, %rsi
movq %rdx, (%rsi)
addq $0x20, %rsi
cmpq %rcx, %rsi
jne 0x1d583
leaq 0x10(%rbx), %rcx
movq %rcx, -0x30(%rbp)
movq %rax, 0xd0(%rbx)
xorl %eax, %eax
movq 0xd0(%rbx), %rdi
cmpq %rax, %r12
je 0x1d5c8
movq 0x58(%rbx), %rcx
movups (%rcx,%rax), %xmm0
movups 0x10(%rcx,%rax), %xmm1
movups %xmm1, 0x10(%rdi,%rax)
movups %xmm0, (%rdi,%rax)
addq $0x20, %rax
jmp 0x1d5a0
movabsq $0xfffffffffffffff, %r14 # imm = 0xFFFFFFFFFFFFFFF
movq 0x120(%rbx), %rcx
pushq $0x1
popq %rdx
movq %r15, %rsi
callq 0x9990
movq 0x120(%rbx), %rdi
callq 0x9030
movq %rax, 0x30(%rbx)
movq 0x28(%rbx), %r12
movq %r12, %rax
shrq $0x3c, %rax
movq %r12, %r15
shlq $0x4, %r15
xorl %r13d, %r13d
negq %rax
movl $0x0, %edi
sbbq %rdi, %rdi
orq %r15, %rdi
callq 0x9050
movq %rax, 0xd8(%rbx)
testq %r12, %r12
cmovleq %r13, %r12
subq $0x1, %r12
jb 0x1d64b
movq 0x70(%rbx), %rax
movq 0xd8(%rbx), %rcx
movups (%rax,%r13), %xmm0
movups %xmm0, (%rcx,%r13)
addq $0x10, %r13
jmp 0x1d62a
movq 0xd8(%rbx), %rdi
movq 0x120(%rbx), %rcx
pushq $0x1
popq %rdx
movq %r15, %rsi
callq 0x9990
movq 0x120(%rbx), %rdi
callq 0x9030
movq %rax, 0x40(%rbx)
movq 0x38(%rbx), %r13
movq %r13, %r12
shlq $0x4, %r12
cmpq %r14, %r13
pushq $-0x1
popq %r15
movq %r12, %rdi
cmovaq %r15, %rdi
callq 0x9050
movq %rax, 0xe0(%rbx)
xorl %eax, %eax
testq %r13, %r13
cmovleq %rax, %r13
subq $0x1, %r13
jb 0x1d6c4
movq 0x88(%rbx), %rcx
movq 0xe0(%rbx), %rdx
movups (%rcx,%rax), %xmm0
movups %xmm0, (%rdx,%rax)
addq $0x10, %rax
jmp 0x1d6a2
movq 0xe0(%rbx), %rdi
movq 0x120(%rbx), %rcx
pushq $0x1
popq %rdx
movq %r12, %rsi
callq 0x9990
movq 0x120(%rbx), %rdi
callq 0x9030
movq %rax, 0x50(%rbx)
movq 0x48(%rbx), %r13
movq %r13, %r12
shlq $0x4, %r12
cmpq %r14, %r13
cmovbeq %r12, %r15
movq %r15, %rdi
callq 0x9050
movq %rax, 0xe8(%rbx)
xorl %eax, %eax
testq %r13, %r13
cmovleq %rax, %r13
subq $0x1, %r13
jb 0x1d739
movq 0xa0(%rbx), %rcx
movq 0xe8(%rbx), %rdx
movups (%rcx,%rax), %xmm0
movups %xmm0, (%rdx,%rax)
addq $0x10, %rax
jmp 0x1d717
movq 0xe8(%rbx), %rdi
movq 0x120(%rbx), %rcx
pushq $0x1
popq %r15
movq %r12, %rsi
movq %r15, %rdx
callq 0x9990
movq 0x120(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x9530
movq 0x120(%rbx), %rcx
leaq 0x3ad82(%rip), %rdi     # 0x584f6
pushq $0x2
popq %rsi
movq %r15, %rdx
callq 0x9990
movq 0x120(%rbx), %rcx
pushq $0x48
popq %rsi
movq -0x30(%rbp), %rdi
movq %r15, %rdx
callq 0x9990
movq 0x120(%rbx), %rdi
testq %rdi, %rdi
je 0x1d7b4
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x94c0
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop