// File: tap3edit[P]tap3xml/Asn.cpp
// Function: Asn::decode()
void Asn::decode()
{

    /* 1. Decode Specification */

    _decode_spec();


    /* 2. Prepare Tree to decode */

    if (!_tree)
    {
        cerr << "treenode structure was not set with tree() method";
        err_trace(__FILE__, __LINE__);
    }

    if (!_spec_rootnode.size())
    {
        cerr << "Error. The root node should be specified with the method \"specroot\"";
        err_trace(__FILE__, __LINE__);
    }

    _tree->pc=1;
    _tree->children=NULL;
    _tree->tagname=_spec_rootnode;
    _tree->indef = false;
    _tree->size_d = _bfin->get_end();


    /* 3. Read initial tag if needed */

    _bfin->set_pos(0);

    if ( _spec_tree[_spec_rootnode]->tagid )
    {
        /* The rootnode could have its own tag but not necessarily (like in case of CHOICE)  */
        /* In case it has, we read it here, because in _decode() we assume that the rootnode */
        /* is already decoded. E.g. "DataInterChange" has no own tag, but "Nrtrde" has.      */

        /* 3.1 Eat up the first tag */

        treenode *child=new treenode();

        _asnitem->tree(child);
        _asnitem->decode();

        if (_spec_tree[_spec_rootnode]->tagid == child->tag_d)
        {

            /* 3.1.1. Tag matches */

            _tree->tag_d = child->tag_d;
            _tree->size_d = child->size_d;
            _tree->indef = child->indef;
        }
        else
        {
            /* 3.1.2. Tag does not match */

            delete child; 
            child = NULL;

            cerr << "Error: File does not match the specifications";
            cerr << " tag: " << child->tag_d << " pos: " << _bfin->get_pos() << endl;
            err_trace(__FILE__, __LINE__);
        }

        delete child; 
        child = NULL;

    }

    /* 4. Decode file */

    _decode(_spec_tree[_spec_rootnode], _tree, _tree->size_d, _tree->indef);

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0xf0, %rsp
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0xa8(%rbp)
callq 0x18460
movq -0xa8(%rbp), %rax
cmpq $0x0, 0x18(%rax)
jne 0x18ab8
movq 0x185c0(%rip), %rdi     # 0x30fe8
leaq 0xd28b(%rip), %rsi      # 0x25cba
callq 0x4340
leaq -0x29(%rbp), %rdi
movq %rdi, -0xb0(%rbp)
callq 0x46e0
movq -0xb0(%rbp), %rdx
leaq 0xd241(%rip), %rsi      # 0x25c93
leaq -0x28(%rbp), %rdi
callq 0x7670
jmp 0x18a5d
movl $0xd2, -0x40(%rbp)
leaq -0x28(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x151c0
jmp 0x18a73
leaq -0x28(%rbp), %rdi
callq 0x41e0
leaq -0x29(%rbp), %rdi
callq 0x43d0
jmp 0x18ab8
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x18aaa
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x28(%rbp), %rdi
callq 0x41e0
leaq -0x29(%rbp), %rdi
callq 0x43d0
jmp 0x18ee1
movq -0xa8(%rbp), %rdi
addq $0x40, %rdi
callq 0x4250
cmpq $0x0, %rax
jne 0x18b69
movq 0x1850f(%rip), %rdi     # 0x30fe8
leaq 0xd20c(%rip), %rsi      # 0x25cec
callq 0x4340
leaq -0x61(%rbp), %rdi
movq %rdi, -0xb8(%rbp)
callq 0x46e0
movq -0xb8(%rbp), %rdx
leaq 0xd190(%rip), %rsi      # 0x25c93
leaq -0x60(%rbp), %rdi
callq 0x7670
jmp 0x18b0e
movl $0xd8, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x151c0
jmp 0x18b24
leaq -0x60(%rbp), %rdi
callq 0x41e0
leaq -0x61(%rbp), %rdi
callq 0x43d0
jmp 0x18b69
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x18b5b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x60(%rbp), %rdi
callq 0x41e0
leaq -0x61(%rbp), %rdi
callq 0x43d0
jmp 0x18ee1
movq -0xa8(%rbp), %rax
movq 0x18(%rax), %rcx
movw 0x20(%rcx), %dx
andw $-0x5, %dx
orw $0x4, %dx
movw %dx, 0x20(%rcx)
movq 0x18(%rax), %rcx
movq $0x0, 0x50(%rcx)
movq %rax, %rsi
addq $0x40, %rsi
movq 0x18(%rax), %rdi
callq 0x4050
movq -0xa8(%rbp), %rax
movq 0x18(%rax), %rcx
movw 0x20(%rcx), %dx
andw $0xfeff, %dx            # imm = 0xFEFF
orw $0x0, %dx
movw %dx, 0x20(%rcx)
movq (%rax), %rdi
callq 0x17a60
movq %rax, %rdx
movq -0xa8(%rbp), %rax
movq 0x18(%rax), %rcx
movq %rdx, 0x30(%rcx)
movq (%rax), %rdi
movq $0x0, -0x70(%rbp)
leaq -0x70(%rbp), %rsi
callq 0x178f0
movq -0xa8(%rbp), %rsi
movq %rsi, %rdi
addq $0x60, %rdi
addq $0x40, %rsi
callq 0xf160
movq (%rax), %rax
cmpl $0x0, 0x40(%rax)
je 0x18e87
movl $0x58, %edi
callq 0x4360
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xc0(%rbp)
callq 0x7850
jmp 0x18c2c
movq -0xa8(%rbp), %rax
movq -0xc0(%rbp), %rcx
movq %rcx, -0x78(%rbp)
movq 0x10(%rax), %rdi
movq -0x78(%rbp), %rsi
movq (%rdi), %rax
callq *0x8(%rax)
movq -0xa8(%rbp), %rax
movq 0x10(%rax), %rdi
callq 0x20df0
movq -0xa8(%rbp), %rsi
movq %rsi, %rdi
addq $0x60, %rdi
addq $0x40, %rsi
callq 0xf160
movq (%rax), %rax
movl 0x40(%rax), %eax
movq -0x78(%rbp), %rcx
cmpl 0x24(%rcx), %eax
jne 0x18cfa
movq -0xa8(%rbp), %rax
movq -0x78(%rbp), %rcx
movl 0x24(%rcx), %edx
movq 0x18(%rax), %rcx
movl %edx, 0x24(%rcx)
movq -0x78(%rbp), %rcx
movq 0x30(%rcx), %rdx
movq 0x18(%rax), %rcx
movq %rdx, 0x30(%rcx)
movq -0x78(%rbp), %rcx
movw 0x20(%rcx), %dx
shrw $0x8, %dx
andw $0x1, %dx
movq 0x18(%rax), %rax
movw 0x20(%rax), %cx
andw $0x1, %dx
shlw $0x8, %dx
andw $0xfeff, %cx            # imm = 0xFEFF
orw %dx, %cx
movw %cx, 0x20(%rax)
jmp 0x18e51
movq -0xc0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
movl $0x58, %esi
callq 0x4370
jmp 0x18ee1
movq -0x78(%rbp), %rax
movq %rax, -0xc8(%rbp)
cmpq $0x0, %rax
je 0x18d28
movq -0xc8(%rbp), %rdi
callq 0x12bb0
movq -0xc8(%rbp), %rdi
movl $0x58, %esi
callq 0x4370
movq $0x0, -0x78(%rbp)
movq 0x182b1(%rip), %rdi     # 0x30fe8
movq %rdi, -0xe0(%rbp)
leaq 0xcfeb(%rip), %rsi      # 0x25d30
callq 0x4340
movq -0xe0(%rbp), %rdi
leaq 0xd006(%rip), %rsi      # 0x25d5e
callq 0x4340
movq %rax, %rdi
movq -0x78(%rbp), %rax
movl 0x24(%rax), %esi
callq 0x46a0
movq %rax, %rdi
leaq 0xd065(%rip), %rsi      # 0x25ddb
callq 0x4340
movq %rax, %rcx
movq -0xa8(%rbp), %rax
movq %rcx, -0xd8(%rbp)
movq (%rax), %rdi
callq 0x178d0
movq -0xd8(%rbp), %rdi
movq %rax, %rsi
callq 0x4720
movq %rax, %rdi
movq 0x181fb(%rip), %rsi     # 0x30fa8
callq 0x43b0
leaq -0x99(%rbp), %rdi
movq %rdi, -0xd0(%rbp)
callq 0x46e0
movq -0xd0(%rbp), %rdx
leaq 0xcec0(%rip), %rsi      # 0x25c93
leaq -0x98(%rbp), %rdi
callq 0x7670
jmp 0x18de1
movl $0x105, -0xa0(%rbp)     # imm = 0x105
leaq -0x98(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x151c0
jmp 0x18e00
leaq -0x98(%rbp), %rdi
callq 0x41e0
leaq -0x99(%rbp), %rdi
callq 0x43d0
jmp 0x18e51
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x18e40
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x98(%rbp), %rdi
callq 0x41e0
leaq -0x99(%rbp), %rdi
callq 0x43d0
jmp 0x18ee1
movq -0x78(%rbp), %rax
movq %rax, -0xe8(%rbp)
cmpq $0x0, %rax
je 0x18e7f
movq -0xe8(%rbp), %rdi
callq 0x12bb0
movq -0xe8(%rbp), %rdi
movl $0x58, %esi
callq 0x4370
movq $0x0, -0x78(%rbp)
movq -0xa8(%rbp), %rsi
movq %rsi, %rdi
addq $0x60, %rdi
addq $0x40, %rsi
callq 0xf160
movq -0xa8(%rbp), %rdi
movq (%rax), %rsi
movq 0x18(%rdi), %rdx
movq 0x18(%rdi), %rax
movq 0x30(%rax), %rcx
movq 0x18(%rdi), %rax
movw 0x20(%rax), %ax
shrw $0x8, %ax
andw $0x1, %ax
cmpw $0x0, %ax
setne %al
movzbl %al, %r8d
andl $0x1, %r8d
callq 0x18ef0
addq $0xf0, %rsp
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x46d0
nopw (%rax,%rax)