// File: /workspace/github_cpp_makefile_star2_O1/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 $0x18, %rsp
movq %rdi, %rbx
callq 0x450ba
cmpb $0x1, 0x5c42(%rax)
jne 0x23380
callq 0x450ba
cmpb $0x0, 0x5c40(%rax)
jne 0x23380
cmpq $0x0, 0x120(%rbx)
je 0x23361
movq 0x58(%rbx), %rax
movq 0x60(%rbx), %r14
movq %r14, -0x30(%rbp)
movq %rax, -0x38(%rbp)
subq %rax, %r14
movq %r14, -0x40(%rbp)
sarq $0x5, %r14
movq %r14, 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
movq %rax, 0x48(%rbx)
testq %r14, %r14
jle 0x23103
xorl %r12d, %r12d
xorl %r13d, %r13d
movq %r14, %r15
movq 0x120(%rbx), %rdi
callq 0x9030
movq 0x58(%rbx), %rcx
movq %rax, 0x10(%rcx,%r12)
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,%r12), %rsi
movq 0x120(%rbx), %rcx
movl $0x1, %edx
callq 0x99a0
addq $0x28, %r13
addq $0x20, %r12
decq %r15
jne 0x230a3
movq 0x120(%rbx), %rdi
callq 0x9030
movq %rax, 0x20(%rbx)
movq %r14, %rax
shrq $0x3b, %rax
xorl %edi, %edi
negq %rax
sbbq %rdi, %rdi
movq -0x40(%rbp), %r15
orq %r15, %rdi
callq 0x9050
movq -0x30(%rbp), %rcx
cmpq -0x38(%rbp), %rcx
je 0x23152
movq %rax, %rcx
addq %r15, %rcx
movl $0xfffffffd, %edx       # imm = 0xFFFFFFFD
movq %rax, %rsi
movq %rdx, (%rsi)
addq $0x20, %rsi
cmpq %rcx, %rsi
jne 0x23146
movq %rax, 0xd0(%rbx)
testq %r14, %r14
jle 0x23186
xorl %eax, %eax
movq 0x58(%rbx), %rcx
movq 0xd0(%rbx), %rdx
movups (%rcx,%rax), %xmm0
movups 0x10(%rcx,%rax), %xmm1
movups %xmm1, 0x10(%rdx,%rax)
movups %xmm0, (%rdx,%rax)
addq $0x20, %rax
decq %r14
jne 0x23160
movabsq $0xfffffffffffffff, %r13 # imm = 0xFFFFFFFFFFFFFFF
movq 0xd0(%rbx), %rdi
movq 0x120(%rbx), %rcx
movl $0x1, %edx
movq %r15, %rsi
callq 0x99a0
movq 0x120(%rbx), %rdi
callq 0x9030
movq %rax, 0x30(%rbx)
movq 0x28(%rbx), %r15
movq %r15, %rax
shrq $0x3c, %rax
movq %r15, %r14
shlq $0x4, %r14
xorl %edi, %edi
negq %rax
sbbq %rdi, %rdi
orq %r14, %rdi
callq 0x9050
movq %rax, 0xd8(%rbx)
testq %r15, %r15
jle 0x23207
xorl %eax, %eax
movq 0x70(%rbx), %rcx
movq 0xd8(%rbx), %rdx
movups (%rcx,%rax), %xmm0
movups %xmm0, (%rdx,%rax)
addq $0x10, %rax
decq %r15
jne 0x231eb
movq 0xd8(%rbx), %rdi
movq 0x120(%rbx), %rcx
movl $0x1, %edx
movq %r14, %rsi
callq 0x99a0
movq 0x120(%rbx), %rdi
callq 0x9030
movq %rax, 0x40(%rbx)
movq 0x38(%rbx), %r14
movq %r14, %r12
shlq $0x4, %r12
cmpq %r13, %r14
movq $-0x1, %r15
movq %r12, %rdi
cmovaq %r15, %rdi
callq 0x9050
movq %rax, 0xe0(%rbx)
testq %r14, %r14
jle 0x23280
xorl %eax, %eax
movq 0x88(%rbx), %rcx
movq 0xe0(%rbx), %rdx
movups (%rcx,%rax), %xmm0
movups %xmm0, (%rdx,%rax)
addq $0x10, %rax
decq %r14
jne 0x23261
leaq 0x10(%rbx), %r14
movq 0xe0(%rbx), %rdi
movq 0x120(%rbx), %rcx
movl $0x1, %edx
movq %r12, %rsi
callq 0x99a0
movq 0x120(%rbx), %rdi
callq 0x9030
movq %rax, 0x50(%rbx)
movq 0x48(%rbx), %r12
movq %r12, %r13
shlq $0x4, %r13
movabsq $0xfffffffffffffff, %rax # imm = 0xFFFFFFFFFFFFFFF
cmpq %rax, %r12
cmovbeq %r13, %r15
movq %r15, %rdi
callq 0x9050
movq %rax, 0xe8(%rbx)
testq %r12, %r12
jle 0x23300
xorl %eax, %eax
movq 0xa0(%rbx), %rcx
movq 0xe8(%rbx), %rdx
movups (%rcx,%rax), %xmm0
movups %xmm0, (%rdx,%rax)
addq $0x10, %rax
decq %r12
jne 0x232e1
movq 0xe8(%rbx), %rdi
movq 0x120(%rbx), %rcx
movl $0x1, %edx
movq %r13, %rsi
callq 0x99a0
movq 0x120(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x9530
movq 0x120(%rbx), %rcx
leaq 0x49205(%rip), %rdi     # 0x6c53e
movl $0x2, %esi
movl $0x1, %edx
callq 0x99a0
movq 0x120(%rbx), %rcx
movl $0x48, %esi
movl $0x1, %edx
movq %r14, %rdi
callq 0x99a0
movq 0x120(%rbx), %rdi
testq %rdi, %rdi
je 0x23380
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x94b0
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nop