// File: xocoder[P]m_kcptun/vendor/m_foundation/src/model/m_mem.c
// Function: mm_report
void mm_report(int brief_level) {
   memhead_t *mh = &g_mh;
   _lock(mh->lock);
   if (mh->head) {
      mem_t *m = mh->head;
      _log("[mem] ---- active %d, size %luKb ----\n", mh->count, mh->size>>10);
      if (brief_level == 2) {
         int i = mh->count;
         while (i-- > 0) {
            _log("[mem] (%d:%s), %lu bytes\n", m->line, m->fname, m->size);
            m = m->next;
         };
      }
      else if (brief_level == 1) {
         mrec_t mrec[128];
         memset(mrec, 0, 128*sizeof(mrec_t));
         int i, count=mh->count, top = 0;
         while (count-- > 0) {
            mrec_t *mt = &mrec[top];
            for (i=0; i<top; i++) {
               if (mrec[i].fname == m->fname) {
                  mt = &mrec[i]; mt->size += m->size;
                  goto m_next;
               }
            }
            mt->fname=m->fname;  mt->size=m->size;  top++;
           m_next: m = m->next;
         }
         qsort(mrec, top, sizeof(mrec_t), _rec_compare);
         for (i=0; i<top; i++) {
            mrec_t *mt = &mrec[i];
            _log("[mem] %s, %luKb\n", mt->fname, mt->size>>10);
         }
      }
      else {
         goto report_end;
      }
      _log("[mem] ---- end report ----\n");
   }
   else {
      _log("[mem] no more active\n");
   }
  report_end:
   _unlock(mh->lock);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x840, %rsp            # imm = 0x840
movl %edi, -0x4(%rbp)
leaq 0xe403(%rip), %rax      # 0x18368
movq %rax, -0x10(%rbp)
jmp 0x9f6b
movq -0x10(%rbp), %rcx
xorl %eax, %eax
movl $0x1, %edx
lock
cmpxchgl %edx, (%rcx)
movl %eax, %ecx
sete %al
xorb $-0x1, %al
testb $0x1, %al
jne 0x9f69
movq -0x10(%rbp), %rax
cmpq $0x0, 0x10(%rax)
je 0xa1ec
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x18(%rbp)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %esi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
shrq $0xa, %rdx
leaq 0x98e3(%rip), %rdi      # 0x1389d
movb $0x0, %al
callq 0x3050
cmpl $0x2, -0x4(%rbp)
jne 0xa01a
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x1c(%rbp)
movl -0x1c(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x1c(%rbp)
cmpl $0x0, %eax
jle 0xa015
movq -0x18(%rbp), %rax
movzwl 0x20(%rax), %esi
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rdx
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rcx
leaq 0x98c4(%rip), %rdi      # 0x138c4
movb $0x0, %al
callq 0x3050
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0x9fd1
jmp 0xa1dc
cmpl $0x1, -0x4(%rbp)
jne 0xa1d8
leaq -0x820(%rbp), %rdi
xorl %esi, %esi
movl $0x800, %edx            # imm = 0x800
callq 0x31c0
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movl %eax, -0x828(%rbp)
movl $0x0, -0x82c(%rbp)
movl -0x828(%rbp), %eax
movl %eax, %ecx
addl $-0x1, %ecx
movl %ecx, -0x828(%rbp)
cmpl $0x0, %eax
jle 0xa14b
movslq -0x82c(%rbp), %rcx
leaq -0x820(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x838(%rbp)
movl $0x0, -0x824(%rbp)
movl -0x824(%rbp), %eax
cmpl -0x82c(%rbp), %eax
jge 0xa106
movslq -0x824(%rbp), %rcx
leaq -0x820(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq -0x18(%rbp), %rcx
cmpq 0x10(%rcx), %rax
jne 0xa0f3
movslq -0x824(%rbp), %rcx
leaq -0x820(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x838(%rbp)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x838(%rbp), %rax
addq 0x8(%rax), %rcx
movq %rcx, 0x8(%rax)
jmp 0xa13a
jmp 0xa0f5
movl -0x824(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x824(%rbp)
jmp 0xa08e
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rcx
movq -0x838(%rbp), %rax
movq %rcx, (%rax)
movq -0x18(%rbp), %rax
movq 0x18(%rax), %rcx
movq -0x838(%rbp), %rax
movq %rcx, 0x8(%rax)
movl -0x82c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x82c(%rbp)
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x18(%rbp)
jmp 0xa04e
leaq -0x820(%rbp), %rdi
movslq -0x82c(%rbp), %rsi
movl $0x10, %edx
leaq 0xbb(%rip), %rcx        # 0xa220
callq 0x3560
movl $0x0, -0x824(%rbp)
movl -0x824(%rbp), %eax
cmpl -0x82c(%rbp), %eax
jge 0xa1d6
movslq -0x824(%rbp), %rcx
leaq -0x820(%rbp), %rax
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, -0x840(%rbp)
movq -0x840(%rbp), %rax
movq (%rax), %rsi
movq -0x840(%rbp), %rax
movq 0x8(%rax), %rdx
shrq $0xa, %rdx
leaq 0x9720(%rip), %rdi      # 0x138de
movb $0x0, %al
callq 0x3050
movl -0x824(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x824(%rbp)
jmp 0xa174
jmp 0xa1da
jmp 0xa1fc
jmp 0xa1dc
leaq 0x970c(%rip), %rdi      # 0x138ef
movb $0x0, %al
callq 0x3050
jmp 0xa1fa
leaq 0x9718(%rip), %rdi      # 0x1390b
movb $0x0, %al
callq 0x3050
jmp 0xa1fc
movq -0x10(%rbp), %rcx
movl $0x1, %eax
xorl %edx, %edx
lock
cmpxchgl %edx, (%rcx)
addq $0x840, %rsp            # imm = 0x840
popq %rbp
retq
nopw %cs:(%rax,%rax)