// File: eniac[P]Mantis/src/ast/ast_nodes_p4.cpp
// Function: P4RegisterNode::P4RegisterNode(AstNode*, AstNode*)
P4RegisterNode::P4RegisterNode(AstNode* name, AstNode* body) {
    nodeType_ = typeid(*this).name();
    name_ = dynamic_cast<NameNode*>(name);
    if(body->nodeType_.find("EmptyNode")!=string::npos) {
        body_ = new BodyNode(NULL, NULL, new BodyWordNode(BodyWordNode::STRING, new StrNode(new string(""))));
        width_ = -1;
        instanceCount_ = -1;        
    } else {
        body_ = dynamic_cast<BodyNode*>(body);
        std::stringstream ss(body_->toString());
        std::string item;
        while (std::getline(ss, item, ';'))
        {
            std::stringstream ss_(item);
            std::string item_;
            while (std::getline(ss_, item_, ':')) {
                boost::algorithm::trim(item_);
                if(item_.compare("width")==0) {
                    std::getline(ss_, item_, ':');
                    boost::algorithm::trim(item_);
                    width_ = stoi(item_);
                } else if (item_.compare("instance_count")==0) {
                    std::getline(ss_, item_, ':');
                    boost::algorithm::trim(item_);
                    instanceCount_ = stoi(item_);
                }
            }
        }        
    }
    if (body_) body_->parent_ = this;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x460, %rsp            # imm = 0x460
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq %rdx, -0x18(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x3c0(%rbp)
callq 0xb2f00
movq -0x3c0(%rbp), %rax
leaq 0xb757b(%rip), %rcx     # 0x172ab0
addq $0x10, %rcx
movq %rcx, (%rax)
cmpq $0x0, %rax
jne 0xbb549
callq 0xaa640
jmp 0xbb549
movq -0x3c0(%rbp), %rax
movq (%rax), %rax
movq -0x8(%rax), %rdi
callq 0xb2f90
movq -0x3c0(%rbp), %rdi
movq %rax, %rsi
addq $0x10, %rdi
callq 0xaa7c0
jmp 0xbb571
movq -0x10(%rbp), %rax
movq %rax, -0x3c8(%rbp)
cmpq $0x0, %rax
je 0xbb5ba
movq -0x3c8(%rbp), %rdi
leaq 0xb7050(%rip), %rsi     # 0x1725e0
leaq 0xb73f9(%rip), %rdx     # 0x172990
xorl %eax, %eax
movl %eax, %ecx
callq 0xaa660
movq %rax, -0x3d0(%rbp)
jmp 0xbb5c5
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0xbbbcd
xorl %eax, %eax
movq %rax, -0x3d0(%rbp)
jmp 0xbb5c5
movq -0x3c0(%rbp), %rax
movq -0x3d0(%rbp), %rcx
movq %rcx, 0x40(%rax)
movq -0x18(%rbp), %rdi
addq $0x10, %rdi
leaq 0x7e7a1(%rip), %rsi     # 0x139d87
xorl %eax, %eax
movl %eax, %edx
callq 0xaab90
cmpq $-0x1, %rax
je 0xbb7ab
movl $0x60, %edi
callq 0xaa560
movq %rax, -0x3d8(%rbp)
jmp 0xbb60c
movb $0x1, -0x29(%rbp)
movl $0x50, %edi
callq 0xaa560
movq %rax, -0x3e0(%rbp)
jmp 0xbb623
movb $0x1, -0x28(%rbp)
movl $0x48, %edi
callq 0xaa560
movq %rax, -0x3e8(%rbp)
jmp 0xbb63a
movb $0x1, -0x27(%rbp)
movl $0x20, %edi
callq 0xaa560
movq %rax, -0x3f0(%rbp)
jmp 0xbb651
movb $0x1, -0x26(%rbp)
leaq -0x25(%rbp), %rdi
movq %rdi, -0x3f8(%rbp)
callq 0xaaa70
movq -0x3f0(%rbp), %rdi
movq -0x3f8(%rbp), %rdx
leaq 0x80529(%rip), %rsi     # 0x13bba3
callq 0xaa7d0
jmp 0xbb681
movq -0x3f0(%rbp), %rsi
movq -0x3e8(%rbp), %rdi
movb $0x0, -0x26(%rbp)
callq 0xb2890
jmp 0xbb69a
movq -0x3e8(%rbp), %rdx
movq -0x3e0(%rbp), %rdi
movb $0x0, -0x27(%rbp)
movl $0x3, %esi
callq 0xba4d0
jmp 0xbb6b8
movq -0x3e0(%rbp), %rcx
movq -0x3d8(%rbp), %rdi
movb $0x0, -0x28(%rbp)
xorl %eax, %eax
movl %eax, %edx
movq %rdx, %rsi
callq 0xbaed0
jmp 0xbb6d8
movq -0x3c0(%rbp), %rax
movq -0x3d8(%rbp), %rcx
movb $0x0, -0x29(%rbp)
movq %rcx, 0x48(%rax)
leaq -0x25(%rbp), %rdi
callq 0xaa5f0
movq -0x3c0(%rbp), %rax
movl $0xffffffff, 0x50(%rax) # imm = 0xFFFFFFFF
movl $0xffffffff, 0x54(%rax) # imm = 0xFFFFFFFF
jmp 0xbbba7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0xbb792
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0xbb77c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0xbb766
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x25(%rbp), %rdi
callq 0xaa5f0
testb $0x1, -0x26(%rbp)
jne 0xbb758
jmp 0xbb764
movq -0x3f0(%rbp), %rdi
callq 0xaa4e0
jmp 0xbb766
testb $0x1, -0x27(%rbp)
jne 0xbb76e
jmp 0xbb77a
movq -0x3e8(%rbp), %rdi
callq 0xaa4e0
jmp 0xbb77c
testb $0x1, -0x28(%rbp)
jne 0xbb784
jmp 0xbb790
movq -0x3e0(%rbp), %rdi
callq 0xaa4e0
jmp 0xbb792
testb $0x1, -0x29(%rbp)
jne 0xbb79a
jmp 0xbb7a6
movq -0x3d8(%rbp), %rdi
callq 0xaa4e0
jmp 0xbbbcd
movq -0x18(%rbp), %rax
movq %rax, -0x400(%rbp)
cmpq $0x0, %rax
je 0xbb7e3
movq -0x400(%rbp), %rdi
leaq 0xb6e16(%rip), %rsi     # 0x1725e0
leaq 0xb72f7(%rip), %rdx     # 0x172ac8
xorl %eax, %eax
movl %eax, %ecx
callq 0xaa660
movq %rax, -0x408(%rbp)
jmp 0xbb7ee
xorl %eax, %eax
movq %rax, -0x408(%rbp)
jmp 0xbb7ee
movq -0x3c0(%rbp), %rax
movq -0x408(%rbp), %rcx
movq %rcx, 0x48(%rax)
movq 0x48(%rax), %rsi
movq (%rsi), %rax
movq (%rax), %rax
leaq -0x1d8(%rbp), %rdi
callq *%rax
jmp 0xbb815
movl $0x10, %edi
movl $0x8, %esi
callq 0xbff00
movl %eax, -0x40c(%rbp)
jmp 0xbb82c
movl -0x40c(%rbp), %edx
leaq -0x1b8(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0xaa920
jmp 0xbb847
leaq -0x1d8(%rbp), %rdi
callq 0xaabe8
leaq -0x1f8(%rbp), %rdi
callq 0xaa7f0
leaq -0x1b8(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
movl $0x3b, %edx
callq 0xaaae0
movq %rax, -0x418(%rbp)
jmp 0xbb880
movq -0x418(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0xaa6f0
movb %al, -0x419(%rbp)
jmp 0xbb89e
movb -0x419(%rbp), %al
testb $0x1, %al
jne 0xbb8ad
jmp 0xbbb73
movl $0x10, %edi
movl $0x8, %esi
callq 0xbff00
movl %eax, -0x420(%rbp)
jmp 0xbb8c4
movl -0x420(%rbp), %edx
leaq -0x380(%rbp), %rdi
leaq -0x1f8(%rbp), %rsi
callq 0xaa920
jmp 0xbb8df
leaq -0x3a0(%rbp), %rdi
callq 0xaa7f0
leaq -0x380(%rbp), %rdi
leaq -0x3a0(%rbp), %rsi
movl $0x3a, %edx
callq 0xaaae0
movq %rax, -0x428(%rbp)
jmp 0xbb90c
movq -0x428(%rbp), %rdi
movq (%rdi), %rax
movq -0x18(%rax), %rax
addq %rax, %rdi
callq 0xaa6f0
movb %al, -0x429(%rbp)
jmp 0xbb92a
movb -0x429(%rbp), %al
testb $0x1, %al
jne 0xbb939
jmp 0xbbb3c
leaq -0x3a8(%rbp), %rdi
movq %rdi, -0x438(%rbp)
callq 0xaabc0
movq -0x438(%rbp), %rsi
leaq -0x3a0(%rbp), %rdi
callq 0xbff20
jmp 0xbb961
leaq -0x3a8(%rbp), %rdi
callq 0xaa810
leaq -0x3a0(%rbp), %rdi
leaq 0x7ce64(%rip), %rsi     # 0x1387df
callq 0xaa180
cmpl $0x0, %eax
jne 0xbba82
leaq -0x380(%rbp), %rdi
leaq -0x3a0(%rbp), %rsi
movl $0x3a, %edx
callq 0xaaae0
jmp 0xbb9a3
leaq -0x3b0(%rbp), %rdi
movq %rdi, -0x440(%rbp)
callq 0xaabc0
movq -0x440(%rbp), %rsi
leaq -0x3a0(%rbp), %rdi
callq 0xbff20
jmp 0xbb9cb
leaq -0x3b0(%rbp), %rdi
callq 0xaa810
xorl %eax, %eax
movl %eax, %esi
leaq -0x3a0(%rbp), %rdi
movl $0xa, %edx
callq 0xbff90
movl %eax, -0x444(%rbp)
jmp 0xbb9f4
movq -0x3c0(%rbp), %rax
movl -0x444(%rbp), %ecx
movl %ecx, 0x50(%rax)
jmp 0xbbb37
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0xaabe8
jmp 0xbbbcd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0xbbb8d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0xbbb59
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x3a8(%rbp), %rdi
callq 0xaa810
jmp 0xbbb59
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x3b0(%rbp), %rdi
callq 0xaa810
jmp 0xbbb59
leaq -0x3a0(%rbp), %rdi
leaq 0x7e301(%rip), %rsi     # 0x139d91
callq 0xaa180
cmpl $0x0, %eax
jne 0xbbb35
leaq -0x380(%rbp), %rdi
leaq -0x3a0(%rbp), %rsi
movl $0x3a, %edx
callq 0xaaae0
jmp 0xbbab8
leaq -0x3b8(%rbp), %rdi
movq %rdi, -0x450(%rbp)
callq 0xaabc0
movq -0x450(%rbp), %rsi
leaq -0x3a0(%rbp), %rdi
callq 0xbff20
jmp 0xbbae0
leaq -0x3b8(%rbp), %rdi
callq 0xaa810
xorl %eax, %eax
movl %eax, %esi
leaq -0x3a0(%rbp), %rdi
movl $0xa, %edx
callq 0xbff90
movl %eax, -0x454(%rbp)
jmp 0xbbb09
movq -0x3c0(%rbp), %rax
movl -0x454(%rbp), %ecx
movl %ecx, 0x54(%rax)
jmp 0xbbb35
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x3b8(%rbp), %rdi
callq 0xaa810
jmp 0xbbb59
jmp 0xbbb37
jmp 0xbb8eb
leaq -0x3a0(%rbp), %rdi
callq 0xaabe8
leaq -0x380(%rbp), %rdi
callq 0xaa440
jmp 0xbb85f
leaq -0x3a0(%rbp), %rdi
callq 0xaabe8
leaq -0x380(%rbp), %rdi
callq 0xaa440
jmp 0xbbb8d
leaq -0x1f8(%rbp), %rdi
callq 0xaabe8
leaq -0x1b8(%rbp), %rdi
callq 0xaa440
jmp 0xbbba7
leaq -0x1f8(%rbp), %rdi
callq 0xaabe8
leaq -0x1b8(%rbp), %rdi
callq 0xaa440
jmp 0xbbbcd
movq -0x3c0(%rbp), %rax
cmpq $0x0, 0x48(%rax)
je 0xbbbc4
movq -0x3c0(%rbp), %rcx
movq 0x48(%rcx), %rax
movq %rcx, 0x30(%rax)
addq $0x460, %rsp            # imm = 0x460
popq %rbp
retq
movq -0x3c0(%rbp), %rdi
callq 0xb2fd0
movq -0x20(%rbp), %rdi
callq 0xaaa60
nopw %cs:(%rax,%rax)