// File: yueww[P]TSR/exportDataAndIndex.cpp
// Function: exportIpIndexFile(innerNode*, int)
int exportIpIndexFile(innerNode *rootNode,int flag){
    void *pNode=rootNode;
    q.push(pNode);
    void *firstLeafNode=getFirstLeafNode(rootNode);
    int i;
    while((!q.empty())&&q.front()!=firstLeafNode){
        pNode=q.front();
        for(i=0;i<256;i++){
            if(((innerNode *)pNode)->nextLevelNodes[i]){
                trieNodeArr[trieNodeArrIndex].offset[i]=sizeof(trieNodeOffset)*(trieNodeNum+1);
                trieNodeNum++;
                q.push(((innerNode *)pNode)->nextLevelNodes[i]);
            }
        }
        trieNodeArrIndex++;
        q.pop();
    } 
    int base=sizeof(trieNodeOffset)*trieNodeNum;
    //printf("trie node consume %d bytes!\n",base);
    while(!q.empty()){
        pNode=q.front();
        for(i=0;i<256;i++){
            if(((leafNode *)pNode)->indexList[i]){
                trieNodeArr[trieNodeArrIndex].offset[i]=base+indexOffset*sizeof(unsigned);
                compressIndexLink(((leafNode *)pNode)->indexList[i]);
            } 
        }
        trieNodeArrIndex++;
        q.pop();
    }
    int id;
    int indexFileBytes;
    if(flag==1){
        id=countFiles("./index/","srcIpIndex");
        strcpy(srcIpIndexFileName,"srcIpIndex");
        char idStr[16];
        iToStr(id,idStr);
        strcat(srcIpIndexFileName,idStr);
        char path[128];
        strcpy(path,"./index/");
        strcat(path,srcIpIndexFileName);
        indexFileBytes=writeIpIndexFile(path);
    }
    if(flag==2){
        id=countFiles("./index/","dstIpIndex");
        strcpy(dstIpIndexFileName,"dstIpIndex");
        char idStr[16];
        iToStr(id,idStr);
        strcat(dstIpIndexFileName,idStr);
        char path[128];
        strcpy(path,"./index/");
        strcat(path,dstIpIndexFileName);
        indexFileBytes=writeIpIndexFile(path);  
    }
    trieNodeNum=0;
    trieNodeArrIndex=0;
    memset(trieNodeArr,0,sizeof(trieNodeOffset)*trieNodeNum);
    memset(compressedIndexArr,0,sizeof(unsigned)*indexOffset);
    indexOffset=0;
    return indexFileBytes;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x160, %rsp            # imm = 0x160
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x18(%rbp)
leaq 0x6aacf39f(%rip), %rdi  # 0x6aad5f40
leaq -0x18(%rbp), %rsi
callq 0x7330
movq -0x8(%rbp), %rdi
callq 0x70c0
movq %rax, -0x20(%rbp)
leaq 0x6aacf382(%rip), %rdi  # 0x6aad5f40
callq 0x7360
movb %al, %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x151(%rbp)
jne 0x6bee
leaq 0x6aacf367(%rip), %rdi  # 0x6aad5f40
callq 0x7380
movq (%rax), %rax
cmpq -0x20(%rbp), %rax
setne %al
movb %al, -0x151(%rbp)
movb -0x151(%rbp), %al
testb $0x1, %al
jne 0x6bfd
jmp 0x6cb3
leaq 0x6aacf33c(%rip), %rdi  # 0x6aad5f40
callq 0x7380
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movl $0x0, -0x24(%rbp)
cmpl $0x100, -0x24(%rbp)     # imm = 0x100
jge 0x6c93
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x6c86
movl 0x679fb2fb(%rip), %eax  # 0x67a01f30
addl $0x1, %eax
cltq
shlq $0xa, %rax
movl %eax, %edx
movslq 0x679fb2ed(%rip), %rcx  # 0x67a01f34
leaq 0x679fb2f2(%rip), %rax  # 0x67a01f40
shlq $0xa, %rcx
addq %rcx, %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movl 0x679fb2ce(%rip), %eax  # 0x67a01f30
addl $0x1, %eax
movl %eax, 0x679fb2c5(%rip)  # 0x67a01f30
movq -0x18(%rbp), %rsi
movslq -0x24(%rbp), %rax
shlq $0x3, %rax
addq %rax, %rsi
leaq 0x6aacf2bf(%rip), %rdi  # 0x6aad5f40
callq 0x7330
jmp 0x6c88
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x6c17
movl 0x679fb29b(%rip), %eax  # 0x67a01f34
addl $0x1, %eax
movl %eax, 0x679fb292(%rip)  # 0x67a01f34
leaq 0x6aacf297(%rip), %rdi  # 0x6aad5f40
callq 0x73a0
jmp 0x6bb7
movslq 0x679fb276(%rip), %rax  # 0x67a01f30
shlq $0xa, %rax
movl %eax, -0x28(%rbp)
leaq 0x6aacf278(%rip), %rdi  # 0x6aad5f40
callq 0x7360
xorb $-0x1, %al
testb $0x1, %al
jne 0x6cd8
jmp 0x6d7b
leaq 0x6aacf261(%rip), %rdi  # 0x6aad5f40
callq 0x7380
movq (%rax), %rax
movq %rax, -0x18(%rbp)
movl $0x0, -0x24(%rbp)
cmpl $0x100, -0x24(%rbp)     # imm = 0x100
jge 0x6d5b
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
cmpq $0x0, (%rax,%rcx,8)
je 0x6d4e
movslq -0x28(%rbp), %rax
leaq 0x679fb20b(%rip), %rcx  # 0x67a01f20
movslq (%rcx), %rcx
shlq $0x2, %rcx
addq %rcx, %rax
movl %eax, %edx
movslq 0x679fb20c(%rip), %rcx  # 0x67a01f34
leaq 0x679fb211(%rip), %rax  # 0x67a01f40
shlq $0xa, %rcx
addq %rcx, %rax
movslq -0x24(%rbp), %rcx
movl %edx, (%rax,%rcx,4)
movq -0x18(%rbp), %rax
movslq -0x24(%rbp), %rcx
movq (%rax,%rcx,8), %rdi
callq 0x6160
jmp 0x6d50
movl -0x24(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x24(%rbp)
jmp 0x6cf2
movl 0x679fb1d3(%rip), %eax  # 0x67a01f34
addl $0x1, %eax
movl %eax, 0x679fb1ca(%rip)  # 0x67a01f34
leaq 0x6aacf1cf(%rip), %rdi  # 0x6aad5f40
callq 0x73a0
jmp 0x6cc1
cmpl $0x1, -0xc(%rbp)
jne 0x6dfb
leaq 0x3548(%rip), %rdi      # 0xa2d0
leaq 0x354a(%rip), %rsi      # 0xa2d9
callq 0x5f90
movl %eax, -0x2c(%rbp)
leaq 0x6ab0f212(%rip), %rdi  # 0x6ab15fb0
leaq 0x3534(%rip), %rsi      # 0xa2d9
callq 0x22c0
movl -0x2c(%rbp), %edi
leaq -0x40(%rbp), %rsi
callq 0x6040
leaq -0x40(%rbp), %rsi
leaq 0x6ab0f1ef(%rip), %rdi  # 0x6ab15fb0
callq 0x2510
leaq -0xc0(%rbp), %rdi
leaq 0x34fc(%rip), %rsi      # 0xa2d0
callq 0x22c0
leaq -0xc0(%rbp), %rdi
leaq 0x6ab0f1c9(%rip), %rsi  # 0x6ab15fb0
callq 0x2510
leaq -0xc0(%rbp), %rdi
callq 0x7130
movl %eax, -0x30(%rbp)
cmpl $0x2, -0xc(%rbp)
jne 0x6e85
leaq 0x34c4(%rip), %rdi      # 0xa2d0
leaq 0x34d1(%rip), %rsi      # 0xa2e4
callq 0x5f90
movl %eax, -0x2c(%rbp)
leaq 0x6ab0f1ae(%rip), %rdi  # 0x6ab15fd0
leaq 0x34bb(%rip), %rsi      # 0xa2e4
callq 0x22c0
movl -0x2c(%rbp), %edi
leaq -0xd0(%rbp), %rsi
callq 0x6040
leaq -0xd0(%rbp), %rsi
leaq 0x6ab0f185(%rip), %rdi  # 0x6ab15fd0
callq 0x2510
leaq -0x150(%rbp), %rdi
leaq 0x3472(%rip), %rsi      # 0xa2d0
callq 0x22c0
leaq -0x150(%rbp), %rdi
leaq 0x6ab0f15f(%rip), %rsi  # 0x6ab15fd0
callq 0x2510
leaq -0x150(%rbp), %rdi
callq 0x7130
movl %eax, -0x30(%rbp)
movl $0x0, 0x679fb0a1(%rip)  # 0x67a01f30
movl $0x0, 0x679fb09b(%rip)  # 0x67a01f34
movslq 0x679fb090(%rip), %rdx  # 0x67a01f30
shlq $0xa, %rdx
leaq 0x679fb095(%rip), %rdi  # 0x67a01f40
xorl %esi, %esi
callq 0x2170
leaq 0x679fb067(%rip), %rax  # 0x67a01f20
movslq (%rax), %rdx
shlq $0x2, %rdx
leaq 0x653d5659(%rip), %rdi  # 0x653dc520
xorl %esi, %esi
callq 0x2170
leaq 0x679fb04b(%rip), %rax  # 0x67a01f20
movl $0x0, (%rax)
movl -0x30(%rbp), %eax
addq $0x160, %rsp            # imm = 0x160
popq %rbp
retq
nopw (%rax,%rax)