// File: yueww[P]TSR/index.cpp
// Function: locateLeafNode(void*, flowRecord, int)
leafNode* locateLeafNode(void *pTrieNode,flowRecord rec,int flag){
    if(flag==1){
        int i;
        for(i=0;i<2;i++){
            if(((innerNode *)pTrieNode)->nextLevelNodes[rec.srcIp[i]]==NULL){
                ((innerNode *)pTrieNode)->nextLevelNodes[rec.srcIp[i]]=&srcIpInnerNodeBuf[currUsedSrcIpInnerNodes++]; 
            }
            pTrieNode=((innerNode *)pTrieNode)->nextLevelNodes[rec.srcIp[i]];
        }
        if(((innerNode *)pTrieNode)->nextLevelNodes[rec.srcIp[i]]==NULL){
            ((innerNode *)pTrieNode)->nextLevelNodes[rec.srcIp[i]]=&srcIpLeafNodeBuf[currUsedSrcIpLeafNodes++]; 
        }
        pTrieNode=((innerNode *)pTrieNode)->nextLevelNodes[rec.srcIp[i]];
        return (leafNode *)pTrieNode;
    }else{
        int i;
        for(i=0;i<2;i++){
            if(((innerNode *)pTrieNode)->nextLevelNodes[rec.destIp[i]]==NULL){
                ((innerNode *)pTrieNode)->nextLevelNodes[rec.destIp[i]]=&dstIpInnerNodeBuf[currUsedDstIpInnerNodes++]; 
            }
            pTrieNode=((innerNode *)pTrieNode)->nextLevelNodes[rec.destIp[i]];
        }
        if(((innerNode *)pTrieNode)->nextLevelNodes[rec.destIp[i]]==NULL){
            ((innerNode *)pTrieNode)->nextLevelNodes[rec.destIp[i]]=&dstIpLeafNodeBuf[currUsedDstIpLeafNodes++]; 
        }
        pTrieNode=((innerNode *)pTrieNode)->nextLevelNodes[rec.destIp[i]];
        return (leafNode *)pTrieNode;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
leaq 0x10(%rbp), %rax
movq %rax, -0x28(%rbp)
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
cmpl $0x1, -0x14(%rbp)
jne 0x5a0a
movl $0x0, -0x18(%rbp)
cmpl $0x2, -0x18(%rbp)
jge 0x5999
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
cmpq $0x0, (%rax,%rcx,8)
jne 0x5976
movq -0x28(%rbp), %rcx
movl 0x653d6bbd(%rip), %eax  # 0x653dc508
movl %eax, %edx
addl $0x1, %edx
movl %edx, 0x653d6bb2(%rip)  # 0x653dc508
cltq
leaq 0x51956b81(%rip), %rdx  # 0x5195c4e0
shlq $0xb, %rax
addq %rax, %rdx
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rsi
movzbl (%rcx,%rsi), %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x10(%rbp)
movl -0x18(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x18(%rbp)
jmp 0x5924
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
cmpq $0x0, (%rax,%rcx,8)
jne 0x59e5
movq -0x28(%rbp), %rcx
movl 0x653d6b52(%rip), %eax  # 0x653dc50c
movl %eax, %edx
addl $0x1, %edx
movl %edx, 0x653d6b47(%rip)  # 0x653dc50c
cltq
leaq 0x56776b12(%rip), %rdx  # 0x5677c4e0
shlq $0xc, %rax
addq %rax, %rdx
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rsi
movzbl (%rcx,%rsi), %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movslq -0x18(%rbp), %rdx
movzbl (%rcx,%rdx), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
jmp 0x5af8
movl $0x0, -0x1c(%rbp)
cmpl $0x2, -0x1c(%rbp)
jge 0x5a89
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rdx
movzbl 0x4(%rcx,%rdx), %ecx
cmpq $0x0, (%rax,%rcx,8)
jne 0x5a65
movq -0x28(%rbp), %rcx
movl 0x653d6ad7(%rip), %eax  # 0x653dc510
movl %eax, %edx
addl $0x1, %edx
movl %edx, 0x653d6acc(%rip)  # 0x653dc510
cltq
leaq 0x54066a93(%rip), %rdx  # 0x5406c4e0
shlq $0xb, %rax
addq %rax, %rdx
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rsi
movzbl 0x4(%rcx,%rsi), %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rdx
movzbl 0x4(%rcx,%rdx), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x10(%rbp)
movl -0x1c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x1c(%rbp)
jmp 0x5a11
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rdx
movzbl 0x4(%rcx,%rdx), %ecx
cmpq $0x0, (%rax,%rcx,8)
jne 0x5ad7
movq -0x28(%rbp), %rcx
movl 0x653d6a69(%rip), %eax  # 0x653dc514
movl %eax, %edx
addl $0x1, %edx
movl %edx, 0x653d6a5e(%rip)  # 0x653dc514
cltq
leaq 0x5dca6a21(%rip), %rdx  # 0x5dcac4e0
shlq $0xc, %rax
addq %rax, %rdx
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rsi
movzbl 0x4(%rcx,%rsi), %ecx
movq %rdx, (%rax,%rcx,8)
movq -0x28(%rbp), %rcx
movq -0x10(%rbp), %rax
movslq -0x1c(%rbp), %rdx
movzbl 0x4(%rcx,%rdx), %ecx
movq (%rax,%rcx,8), %rax
movq %rax, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x8(%rbp)
movq -0x8(%rbp), %rax
popq %rbp
retq
nop