// File: /workspace/github_cpp_makefile_star2_O3/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 0x43dce
cmpb $0x1, 0x5c42(%rax)
jne 0x22cce
callq 0x43dce
cmpb $0x0, 0x5c40(%rax)
jne 0x22cce
movq 0x120(%rbx), %rdi
testq %rdi, %rdi
je 0x22cce
movq 0x58(%rbx), %r12
movq 0x60(%rbx), %r13
movq %r13, %r15
subq %r12, %r15
movq %r15, %r14
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 0x22a52
movq %r13, -0x38(%rbp)
movq %r12, -0x40(%rbp)
movq %r15, -0x30(%rbp)
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 0x229df
movq 0x120(%rbx), %rdi
movq -0x30(%rbp), %r15
movq -0x40(%rbp), %r12
movq -0x38(%rbp), %r13
callq 0x9030
movq %rax, 0x20(%rbx)
movq %r14, %rax
shrq $0x3b, %rax
xorl %edi, %edi
negq %rax
sbbq %rdi, %rdi
orq %r15, %rdi
callq 0x9050
cmpq %r12, %r13
je 0x22a91
movq %rax, %rcx
addq %r15, %rcx
movl $0xfffffffd, %edx       # imm = 0xFFFFFFFD
movq %rax, %rsi
movq %rdx, (%rsi)
addq $0x20, %rsi
cmpq %rcx, %rsi
jne 0x22a85
movq %rax, 0xd0(%rbx)
testq %r14, %r14
jle 0x22acc
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 0x22a9f
movq 0xd0(%rbx), %rax
movabsq $0xfffffffffffffff, %r13 # imm = 0xFFFFFFFFFFFFFFF
movq 0x120(%rbx), %rcx
movl $0x1, %edx
movq %rax, %rdi
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 0x22b50
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 0x22b2d
movq 0xd8(%rbx), %rax
movq 0x120(%rbx), %rcx
movl $0x1, %edx
movq %rax, %rdi
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 0x22bd1
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 0x22ba6
movq %r13, %r14
movq 0xe0(%rbx), %rax
jmp 0x22bd4
movq %r13, %r14
leaq 0x10(%rbx), %rcx
movq %rcx, -0x30(%rbp)
movq 0x120(%rbx), %rcx
movl $0x1, %edx
movq %rax, %rdi
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
cmpq %r14, %r12
cmovbeq %r13, %r15
movq %r15, %rdi
callq 0x9050
movq %rax, 0xe8(%rbx)
testq %r12, %r12
jle 0x22c51
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 0x22c2b
movq 0xe8(%rbx), %rax
movq 0x120(%rbx), %rcx
movl $0x1, %edx
movq %rax, %rdi
movq %r13, %rsi
callq 0x99a0
movq 0x120(%rbx), %rdi
xorl %esi, %esi
xorl %edx, %edx
callq 0x9530
movq 0x120(%rbx), %rcx
leaq 0x478a8(%rip), %rdi     # 0x6a52e
movl $0x2, %esi
movl $0x1, %edx
callq 0x99a0
movq 0x120(%rbx), %rcx
movl $0x48, %esi
movl $0x1, %edx
movq -0x30(%rbp), %rdi
callq 0x99a0
movq 0x120(%rbx), %rdi
testq %rdi, %rdi
je 0x22cce
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