// File: /workspace/github_c_makefile_star2_O0/xtanitfy[P]Murphy/src/muti_tree.c
// Function: MTREE_forward
int MTREE_forward(MTREE_s *pTree,int (*callback)(void *usr,int idCurr,int *_idPrev,int _nIdPrev))
{
	MTREE_ITEM_s *pItemTmp = NULL;
	MTREE_ITEM_s *pRoot = pTree->root;
	int idPrev[MTREE_MAX_MUX];
	int nIdPrev = 0;

	/*syncPrev ��Ҫ��������*/
	//MTREEResetSyncNext(pTree);
	MTREEResetSyncPrev(pTree);
	
	QUEUE_reset(pTree->pQForward);

	CHECK_EXPR_RET(pRoot == NULL,-1);
	if (callback != NULL) {
		callback(pTree->usr,pRoot->valCurr,NULL,0);
	}
	
	//printf("curr:%d \n",pRoot->valCurr);
	for (int i = 0;i < pRoot->nNext;i++) {
		QUEUE_enqueue(pTree->pQForward,&pRoot->next[i]);
	}
	while(QUEUE_dequeue(pTree->pQForward,&pItemTmp) != QUEUE_EMPTY) {
		nIdPrev = 0;
		for (int i = 0;i < pItemTmp->nPrev;i++) {
			CHECK_EXPR_RET(pItemTmp->prev[i] == NULL,-1);
			idPrev[nIdPrev++] = pItemTmp->prev[i]->valCurr;
		}
		if (callback != NULL) {
			callback(pTree->usr,pItemTmp->valCurr,idPrev,nIdPrev);
		}
		for (int i = 0;i < pItemTmp->nNext;i++) {
			if (--pItemTmp->next[i]->syncPrev == 0) {
				QUEUE_enqueue(pTree->pQForward,&pItemTmp->next[i]);
			}
		}
	}
	return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x60, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq $0x0, -0x20(%rbp)
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x28(%rbp)
movl $0x0, -0x54(%rbp)
movq -0x10(%rbp), %rdi
callq 0x1a90
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
callq 0x25d0
cmpq $0x0, -0x28(%rbp)
jne 0x18f5
leaq 0x175f(%rip), %rdi      # 0x302e
leaq 0x176e(%rip), %rsi      # 0x3044
leaq 0x17cb(%rip), %rdx      # 0x30a8
movl $0xa0, %ecx
movb $0x0, %al
callq 0x1030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1a84
cmpq $0x0, -0x18(%rbp)
je 0x1916
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x70(%rcx), %rdi
movq -0x28(%rbp), %rcx
movl (%rcx), %esi
xorl %ecx, %ecx
movl %ecx, %edx
xorl %ecx, %ecx
callq *%rax
movl $0x0, -0x58(%rbp)
movl -0x58(%rbp), %eax
movq -0x28(%rbp), %rcx
cmpl 0x48(%rcx), %eax
jge 0x1954
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x28(%rbp), %rsi
addq $0x8, %rsi
movslq -0x58(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x2430
movl -0x58(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x58(%rbp)
jmp 0x191d
jmp 0x1956
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
leaq -0x20(%rbp), %rsi
callq 0x2510
cmpl $-0x2, %eax
je 0x1a7d
movl $0x0, -0x54(%rbp)
movl $0x0, -0x5c(%rbp)
movl -0x5c(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x90(%rcx), %eax
jge 0x19f5
movq -0x20(%rbp), %rax
movslq -0x5c(%rbp), %rcx
cmpq $0x0, 0x50(%rax,%rcx,8)
jne 0x19ca
leaq 0x168a(%rip), %rdi      # 0x302e
leaq 0x1699(%rip), %rsi      # 0x3044
leaq 0x16f6(%rip), %rdx      # 0x30a8
movl $0xac, %ecx
movb $0x0, %al
callq 0x1030
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x1a84
movq -0x20(%rbp), %rax
movslq -0x5c(%rbp), %rcx
movq 0x50(%rax,%rcx,8), %rax
movl (%rax), %ecx
movl -0x54(%rbp), %eax
movl %eax, %edx
addl $0x1, %edx
movl %edx, -0x54(%rbp)
cltq
movl %ecx, -0x50(%rbp,%rax,4)
movl -0x5c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x5c(%rbp)
jmp 0x197e
cmpq $0x0, -0x18(%rbp)
je 0x1a17
movq -0x18(%rbp), %rax
movq -0x10(%rbp), %rcx
movq 0x70(%rcx), %rdi
movq -0x20(%rbp), %rcx
movl (%rcx), %esi
leaq -0x50(%rbp), %rdx
movl -0x54(%rbp), %ecx
callq *%rax
movl $0x0, -0x60(%rbp)
movl -0x60(%rbp), %eax
movq -0x20(%rbp), %rcx
cmpl 0x48(%rcx), %eax
jge 0x1a78
movq -0x20(%rbp), %rax
movslq -0x60(%rbp), %rcx
movq 0x8(%rax,%rcx,8), %rcx
movl 0x94(%rcx), %eax
addl $-0x1, %eax
movl %eax, 0x94(%rcx)
cmpl $0x0, %eax
jne 0x1a6b
movq -0x10(%rbp), %rax
movq 0x18(%rax), %rdi
movq -0x20(%rbp), %rsi
addq $0x8, %rsi
movslq -0x60(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
callq 0x2430
jmp 0x1a6d
movl -0x60(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x60(%rbp)
jmp 0x1a1e
jmp 0x1956
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x60, %rsp
popq %rbp
retq
nopl (%rax)