// File: EmbeddedPaul166[P]SNMP-Agent/src/tree.cpp
// Function: Tree::addNode(unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, DataType, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, AccessType, StatusType, Node*)
Node * Tree::addNode(unsigned int objectIdentifier, std::string name, DataType dataType, std::string description, AccessType accessType, StatusType statusType, Node * pParentElement)
{ 
    std::list <Node *> emptyChildList;
    emptyChildList.clear();
    
    Node newNode(objectIdentifier, name, dataType, description, accessType, statusType, pParentElement, emptyChildList);    
    
    m_nodeList.push_back(newNode);
    
    if (pParentElement -> m_childElementPointerList.empty())
    {
        pParentElement -> m_childElementPointerList.push_back(&m_nodeList.back()); 
    }
    else
    {
        for (std::list<Node *>::iterator it = pParentElement -> m_childElementPointerList.begin(); it != pParentElement -> m_childElementPointerList.end(); it++)
        {
            int childObjectIdentifier = (*it) -> m_objectIdentifier;
            int newChildObjectIdentifier = m_nodeList.back().m_objectIdentifier;
            if (newChildObjectIdentifier < childObjectIdentifier)
            {
                pParentElement -> m_childElementPointerList.insert(it, &m_nodeList.back());
                break;
            }
            else if (pParentElement -> m_childElementPointerList.back() == (*it))
            {
                pParentElement -> m_childElementPointerList.push_back(&m_nodeList.back());
                break;
            }
        }
    }
    Node * pNewNode = &m_nodeList.back();
    return pNewNode;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x2a0, %rsp            # imm = 0x2A0
movq %r8, -0x240(%rbp)
movq %rcx, -0x238(%rbp)
movq %rdx, -0x220(%rbp)
movq 0x18(%rbp), %rax
movl 0x10(%rbp), %eax
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movq %rcx, -0x20(%rbp)
movq %r8, -0x28(%rbp)
movl %r9d, -0x2c(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x230(%rbp)
leaq -0x48(%rbp), %rdi
movq %rdi, -0x228(%rbp)
callq 0x455f0
movq -0x228(%rbp), %rdi
callq 0x45610
movq -0x220(%rbp), %rsi
movl -0xc(%rbp), %eax
movl %eax, -0x214(%rbp)
leaq -0x128(%rbp), %rdi
callq 0x61d0
jmp 0x44e73
movq -0x238(%rbp), %rsi
leaq -0x188(%rbp), %rdi
callq 0xb850
jmp 0x44e88
movq -0x240(%rbp), %rsi
leaq -0x1a8(%rbp), %rdi
callq 0x61d0
jmp 0x44e9d
movl -0x2c(%rbp), %eax
movl %eax, -0x250(%rbp)
movl 0x10(%rbp), %eax
movl %eax, -0x24c(%rbp)
movq 0x18(%rbp), %rax
movq %rax, -0x248(%rbp)
leaq -0x1c0(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x45640
jmp 0x44ecc
movl -0x250(%rbp), %r9d
movl -0x214(%rbp), %esi
movl -0x24c(%rbp), %ecx
movq -0x248(%rbp), %rdx
movq %rsp, %rax
leaq -0x1c0(%rbp), %rdi
movq %rdi, 0x10(%rax)
movq %rdx, 0x8(%rax)
movl %ecx, (%rax)
leaq -0x108(%rbp), %rdi
leaq -0x128(%rbp), %rdx
leaq -0x188(%rbp), %rcx
leaq -0x1a8(%rbp), %r8
callq 0x46bf0
jmp 0x44f1d
leaq -0x1c0(%rbp), %rdi
callq 0x45700
leaq -0x1a8(%rbp), %rdi
callq 0x62e0
leaq -0x188(%rbp), %rdi
callq 0x44a90
leaq -0x128(%rbp), %rdi
callq 0x62e0
movq -0x230(%rbp), %rdi
addq $0x8, %rdi
leaq -0x108(%rbp), %rsi
callq 0x45720
jmp 0x44f66
movq 0x18(%rbp), %rdi
addq $0xa8, %rdi
callq 0x45760
testb $0x1, %al
jne 0x44f7f
jmp 0x4507e
movq -0x230(%rbp), %rdi
movq 0x18(%rbp), %rax
addq $0xa8, %rax
movq %rax, -0x258(%rbp)
addq $0x8, %rdi
callq 0x457c0
movq -0x258(%rbp), %rdi
movq %rax, -0x1c8(%rbp)
leaq -0x1c8(%rbp), %rsi
callq 0x45780
jmp 0x44fbc
jmp 0x4520a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x45254
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x4504a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x4503e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
jmp 0x45032
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
leaq -0x1c0(%rbp), %rdi
callq 0x45700
leaq -0x1a8(%rbp), %rdi
callq 0x62e0
leaq -0x188(%rbp), %rdi
callq 0x44a90
leaq -0x128(%rbp), %rdi
callq 0x62e0
jmp 0x45254
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x130(%rbp)
movl %eax, -0x134(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x46dd0
jmp 0x45254
movq 0x18(%rbp), %rdi
addq $0xa8, %rdi
callq 0x45800
movq %rax, -0x1d0(%rbp)
movq 0x18(%rbp), %rdi
addq $0xa8, %rdi
callq 0x45860
movq %rax, -0x1d8(%rbp)
leaq -0x1d0(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x45830
testb $0x1, %al
jne 0x450c8
jmp 0x45208
leaq -0x1d0(%rbp), %rdi
callq 0x45890
movq -0x230(%rbp), %rdi
movq (%rax), %rax
movl (%rax), %eax
movl %eax, -0x1dc(%rbp)
addq $0x8, %rdi
callq 0x457c0
movl (%rax), %eax
movl %eax, -0x1e0(%rbp)
movl -0x1e0(%rbp), %eax
cmpl -0x1dc(%rbp), %eax
jge 0x45176
movq 0x18(%rbp), %rax
addq $0xa8, %rax
movq %rax, -0x268(%rbp)
leaq -0x1e8(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x458f0
movq -0x230(%rbp), %rdi
addq $0x8, %rdi
callq 0x457c0
movq -0x268(%rbp), %rdi
movq %rax, -0x1f0(%rbp)
movq -0x1e8(%rbp), %rsi
leaq -0x1f0(%rbp), %rdx
callq 0x458b0
movq %rax, -0x260(%rbp)
jmp 0x45163
movq -0x260(%rbp), %rax
movq %rax, -0x1f8(%rbp)
jmp 0x45208
movq 0x18(%rbp), %rdi
addq $0xa8, %rdi
callq 0x45910
movq (%rax), %rax
movq %rax, -0x270(%rbp)
leaq -0x1d0(%rbp), %rdi
callq 0x45890
movq %rax, %rcx
movq -0x270(%rbp), %rax
cmpq (%rcx), %rax
jne 0x451ea
movq -0x230(%rbp), %rdi
movq 0x18(%rbp), %rax
addq $0xa8, %rax
movq %rax, -0x278(%rbp)
addq $0x8, %rdi
callq 0x457c0
movq -0x278(%rbp), %rdi
movq %rax, -0x200(%rbp)
leaq -0x200(%rbp), %rsi
callq 0x45780
jmp 0x451e8
jmp 0x45208
jmp 0x451ec
jmp 0x451ee
leaq -0x1d0(%rbp), %rdi
xorl %esi, %esi
callq 0x45950
movq %rax, -0x208(%rbp)
jmp 0x45095
jmp 0x4520a
movq -0x230(%rbp), %rdi
addq $0x8, %rdi
callq 0x457c0
movq %rax, -0x210(%rbp)
movq -0x210(%rbp), %rax
movq %rax, -0x280(%rbp)
leaq -0x108(%rbp), %rdi
callq 0x46dd0
leaq -0x48(%rbp), %rdi
callq 0x45700
movq -0x280(%rbp), %rax
addq $0x2a0, %rsp            # imm = 0x2A0
popq %rbp
retq
leaq -0x48(%rbp), %rdi
callq 0x45700
movq -0x130(%rbp), %rdi
callq 0x6790
nopl (%rax)