// File: tap3edit[P]tap3xml/AsnItem.cpp
// Function: AsnItem::decode()
void AsnItem::decode()
{
    int i;
    string buffin;

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

    if (!_bfin)
    {
        cerr << "buffin was not set with buffin() method";
        err_trace(__FILE__, __LINE__);
    }

    _tree->tag_d=0;
    _tree->tag_l=0;
    memset(_tree->tag_x,  '\0', 4);

    _tree->size_d=0;
    _tree->size_l=0;
    _tree->indef=0;
    memset(_tree->size_x, '\0', 5);


    /* 1. Decode Tag */

    {

        /* 1.1. Read first byte of tag */

        _bfin->read(1);
        buffin=_bfin->get_buf();


        /* 1.2. Store class, primitive/constructed info and hexa tag */

        _tree->cl=buffin[0]>>6;
        _tree->pc=(buffin[0]>>5)&0x1;
        _tree->tag_x[0]=(uchar)buffin[0];
        _tree->tag_l=1;


        /* 1.3. Work according to number of tag octets */

        if ( ( buffin[0]&0x1F ) == 0x1F )
        {
            /* 1.3.1 Tag has more than one octet */


            for(i=1;i<=4;i++)
            {
                _bfin->read(1);
                buffin=_bfin->get_buf();

                _tree->tag_d<<=7;
                _tree->tag_d+=(int)(((uchar)buffin[0])&0x7F);
                _tree->tag_x[i]=(uchar)buffin[0];
                _tree->tag_l+=1;

                if ( ! (buffin[0]>>7) )
                    break;

            }

            if ( i>3 )
            {
                cerr << "Found tag bigger than 4 bytes at file position: " << _bfin->get_pos();
                err_trace(__FILE__, __LINE__);
            }

        } 
        else
        {
            /* 1.3.2 Tag has just one octet */

            _tree->tag_d=(int)buffin[0]&0x1F;
        }

    }


    /* 2. Decode Size */

    {

        /* 2.1. Read first byte of tag */

        _bfin->read(1);
        buffin=_bfin->get_buf();


        /* 2.2. Storing size_x */

        _tree->size_x[0]=buffin[0];
        _tree->size_l=1;


        /* 2.3. Work according the number of octets */

        if (buffin[0]>>7)
        {
            /* 2.3.1. Size with more than one octet */

            for(i=1;(i<=(int)(_tree->size_x[0]&0x7F)) && (i<=4);i++)
            {
                _bfin->read(1);
                buffin=_bfin->get_buf();

                _tree->size_d<<=8;
                _tree->size_d+=(int)((uchar)buffin[0]);
                _tree->size_x[i]=buffin[0];
                _tree->size_l+=1;
            }

            if ( i>7 )
            {
                cerr << "Found size bigger than 8 bytes at file position: " << _bfin->get_pos();
                err_trace(__FILE__, __LINE__);
            }

            /* 2.3.2. If the size is still 0, then it's a tag with indefinite length */
             
            if (_tree->size_d == 0)
            {
                _tree->indef = 1;
            }

        }
        else
        {
            /* 2.3.3. Size with just one octet */

            _tree->size_d=(int)(buffin[0]);

        }

    }

}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x260, %rsp            # imm = 0x260
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x168(%rbp)
leaq -0x30(%rbp), %rdi
callq 0x4570
movq -0x168(%rbp), %rax
cmpq $0x0, 0x40(%rax)
jne 0x20ecf
movq 0x101bc(%rip), %rdi     # 0x30fe8
leaq 0x4e87(%rip), %rsi      # 0x25cba
callq 0x4340
jmp 0x20e3a
leaq -0x61(%rbp), %rdi
movq %rdi, -0x170(%rbp)
callq 0x46e0
movq -0x170(%rbp), %rdx
leaq 0x5314(%rip), %rsi      # 0x2616c
leaq -0x60(%rbp), %rdi
callq 0x7670
jmp 0x20e63
movl $0x3b, -0x68(%rbp)
leaq -0x60(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x151c0
jmp 0x20e79
leaq -0x60(%rbp), %rdi
callq 0x41e0
leaq -0x61(%rbp), %rdi
callq 0x43d0
jmp 0x20ecf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x216e2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x20ec1
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 0x216e2
movq -0x168(%rbp), %rax
cmpq $0x0, 0x30(%rax)
jne 0x20f95
movq 0x10100(%rip), %rdi     # 0x30fe8
leaq 0x5289(%rip), %rsi      # 0x26178
callq 0x4340
jmp 0x20ef6
leaq -0x89(%rbp), %rdi
movq %rdi, -0x178(%rbp)
callq 0x46e0
movq -0x178(%rbp), %rdx
leaq 0x5255(%rip), %rsi      # 0x2616c
leaq -0x88(%rbp), %rdi
callq 0x7670
jmp 0x20f25
movl $0x41, -0x90(%rbp)
leaq -0x88(%rbp), %rdi
leaq -0x90(%rbp), %rsi
callq 0x151c0
jmp 0x20f44
leaq -0x88(%rbp), %rdi
callq 0x41e0
leaq -0x89(%rbp), %rdi
callq 0x43d0
jmp 0x20f95
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x20f84
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x41e0
leaq -0x89(%rbp), %rdi
callq 0x43d0
jmp 0x216e2
movq -0x168(%rbp), %rax
movq 0x40(%rax), %rcx
movl $0x0, 0x24(%rcx)
movq 0x40(%rax), %rcx
movl $0x0, 0x2c(%rcx)
movq 0x40(%rax), %rcx
movl $0x0, 0x28(%rcx)
movq 0x40(%rax), %rcx
movq $0x0, 0x30(%rcx)
movq 0x40(%rax), %rcx
movl $0x0, 0x40(%rcx)
movq 0x40(%rax), %rcx
movw 0x20(%rcx), %dx
andw $0xfeff, %dx            # imm = 0xFEFF
movw %dx, 0x20(%rcx)
movq 0x40(%rax), %rcx
movb $0x0, 0x3c(%rcx)
movl $0x0, 0x38(%rcx)
movq 0x30(%rax), %rdi
movl $0x1, %esi
callq 0x17a80
jmp 0x21004
movq -0x168(%rbp), %rax
movq 0x30(%rax), %rsi
leaq -0xb0(%rbp), %rdi
callq 0x17c90
jmp 0x2101d
leaq -0x30(%rbp), %rdi
movq %rdi, -0x188(%rbp)
leaq -0xb0(%rbp), %rsi
movq %rsi, -0x190(%rbp)
callq 0x4490
movq -0x190(%rbp), %rdi
callq 0x41e0
movq -0x188(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x47b0
movq %rax, -0x180(%rbp)
jmp 0x21060
movq -0x168(%rbp), %rax
movq -0x180(%rbp), %rcx
movzbl (%rcx), %edx
shrl $0x6, %edx
movq 0x40(%rax), %rax
movl 0x20(%rax), %ecx
andl $-0x4, %ecx
orl %edx, %ecx
movw %cx, 0x20(%rax)
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x47b0
movq %rax, -0x198(%rbp)
jmp 0x2109a
movq -0x168(%rbp), %rax
movq -0x198(%rbp), %rcx
movzbl (%rcx), %edx
movq 0x40(%rax), %rax
movl 0x20(%rax), %ecx
shrl $0x3, %edx
andl $0x4, %edx
andl $-0x5, %ecx
orl %edx, %ecx
movw %cx, 0x20(%rax)
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x47b0
movq %rax, -0x1a0(%rbp)
jmp 0x210d7
movq -0x168(%rbp), %rax
movq -0x1a0(%rbp), %rcx
movb (%rcx), %dl
movq 0x40(%rax), %rcx
movb %dl, 0x28(%rcx)
movq 0x40(%rax), %rax
movl $0x1, 0x2c(%rax)
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x47b0
movq %rax, -0x1a8(%rbp)
jmp 0x2110f
movq -0x1a8(%rbp), %rax
movsbl (%rax), %eax
andl $0x1f, %eax
cmpl $0x1f, %eax
jne 0x2134c
movl $0x1, -0xc(%rbp)
cmpl $0x4, -0xc(%rbp)
jg 0x21257
movq -0x168(%rbp), %rax
movq 0x30(%rax), %rdi
movl $0x1, %esi
callq 0x17a80
jmp 0x2114d
movq -0x168(%rbp), %rax
movq 0x30(%rax), %rsi
leaq -0xd0(%rbp), %rdi
callq 0x17c90
jmp 0x21166
leaq -0x30(%rbp), %rdi
movq %rdi, -0x1b8(%rbp)
leaq -0xd0(%rbp), %rsi
movq %rsi, -0x1c0(%rbp)
callq 0x4490
movq -0x1c0(%rbp), %rdi
callq 0x41e0
movq -0x168(%rbp), %rax
movq -0x1b8(%rbp), %rdi
movq 0x40(%rax), %rax
movl 0x24(%rax), %ecx
shll $0x7, %ecx
movl %ecx, 0x24(%rax)
xorl %eax, %eax
movl %eax, %esi
callq 0x47b0
movq %rax, -0x1b0(%rbp)
jmp 0x211bd
movq -0x168(%rbp), %rax
movq -0x1b0(%rbp), %rcx
movzbl (%rcx), %edx
andl $0x7f, %edx
movq 0x40(%rax), %rax
movl 0x24(%rax), %ecx
addl %edx, %ecx
movl %ecx, 0x24(%rax)
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x47b0
movq %rax, -0x1c8(%rbp)
jmp 0x211f3
movq -0x168(%rbp), %rax
movq -0x1c8(%rbp), %rcx
movb (%rcx), %sil
movq 0x40(%rax), %rcx
movslq -0xc(%rbp), %rdx
movb %sil, 0x28(%rcx,%rdx)
movq 0x40(%rax), %rax
movl 0x2c(%rax), %ecx
incl %ecx
movl %ecx, 0x2c(%rax)
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x47b0
movq %rax, -0x1d0(%rbp)
jmp 0x21233
movq -0x1d0(%rbp), %rax
movsbl (%rax), %eax
sarl $0x7, %eax
cmpl $0x0, %eax
jne 0x21247
jmp 0x21257
jmp 0x21249
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x2112c
cmpl $0x3, -0xc(%rbp)
jle 0x2134a
movq 0xfd80(%rip), %rdi      # 0x30fe8
leaq 0x4f31(%rip), %rsi      # 0x261a0
callq 0x4340
movq %rax, -0x1d8(%rbp)
jmp 0x2127d
movq -0x168(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x178d0
movq %rax, -0x1e0(%rbp)
jmp 0x21296
movq -0x1e0(%rbp), %rsi
movq -0x1d8(%rbp), %rdi
callq 0x4720
jmp 0x212ab
leaq -0xf1(%rbp), %rdi
movq %rdi, -0x1e8(%rbp)
callq 0x46e0
movq -0x1e8(%rbp), %rdx
leaq 0x4ea0(%rip), %rsi      # 0x2616c
leaq -0xf0(%rbp), %rdi
callq 0x7670
jmp 0x212da
movl $0x79, -0xf8(%rbp)
leaq -0xf0(%rbp), %rdi
leaq -0xf8(%rbp), %rsi
callq 0x151c0
jmp 0x212f9
leaq -0xf0(%rbp), %rdi
callq 0x41e0
leaq -0xf1(%rbp), %rdi
callq 0x43d0
jmp 0x2134a
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x21339
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xf0(%rbp), %rdi
callq 0x41e0
leaq -0xf1(%rbp), %rdi
callq 0x43d0
jmp 0x216e2
jmp 0x2137d
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x47b0
movq %rax, -0x1f0(%rbp)
jmp 0x21362
movq -0x168(%rbp), %rax
movq -0x1f0(%rbp), %rcx
movsbl (%rcx), %ecx
andl $0x1f, %ecx
movq 0x40(%rax), %rax
movl %ecx, 0x24(%rax)
movq -0x168(%rbp), %rax
movq 0x30(%rax), %rdi
movl $0x1, %esi
callq 0x17a80
jmp 0x21394
movq -0x168(%rbp), %rax
movq 0x30(%rax), %rsi
leaq -0x118(%rbp), %rdi
callq 0x17c90
jmp 0x213ad
leaq -0x30(%rbp), %rdi
movq %rdi, -0x200(%rbp)
leaq -0x118(%rbp), %rsi
movq %rsi, -0x208(%rbp)
callq 0x4490
movq -0x208(%rbp), %rdi
callq 0x41e0
movq -0x200(%rbp), %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x47b0
movq %rax, -0x1f8(%rbp)
jmp 0x213f0
movq -0x168(%rbp), %rax
movq -0x1f8(%rbp), %rcx
movb (%rcx), %dl
movq 0x40(%rax), %rcx
movb %dl, 0x38(%rcx)
movq 0x40(%rax), %rax
movl $0x1, 0x40(%rax)
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x47b0
movq %rax, -0x210(%rbp)
jmp 0x21428
movq -0x210(%rbp), %rax
movsbl (%rax), %eax
sarl $0x7, %eax
cmpl $0x0, %eax
je 0x2169e
movl $0x1, -0xc(%rbp)
movq -0x168(%rbp), %rax
movl -0xc(%rbp), %ecx
movq 0x40(%rax), %rax
movzbl 0x38(%rax), %edx
andl $0x7f, %edx
xorl %eax, %eax
cmpl %edx, %ecx
movb %al, -0x211(%rbp)
jg 0x21473
cmpl $0x4, -0xc(%rbp)
setle %al
movb %al, -0x211(%rbp)
movb -0x211(%rbp), %al
testb $0x1, %al
jne 0x21482
jmp 0x2157d
movq -0x168(%rbp), %rax
movq 0x30(%rax), %rdi
movl $0x1, %esi
callq 0x17a80
jmp 0x21499
movq -0x168(%rbp), %rax
movq 0x30(%rax), %rsi
leaq -0x138(%rbp), %rdi
callq 0x17c90
jmp 0x214b2
leaq -0x30(%rbp), %rdi
movq %rdi, -0x228(%rbp)
leaq -0x138(%rbp), %rsi
movq %rsi, -0x230(%rbp)
callq 0x4490
movq -0x230(%rbp), %rdi
callq 0x41e0
movq -0x168(%rbp), %rax
movq -0x228(%rbp), %rdi
movq 0x40(%rax), %rax
movq 0x30(%rax), %rcx
shlq $0x8, %rcx
movq %rcx, 0x30(%rax)
xorl %eax, %eax
movl %eax, %esi
callq 0x47b0
movq %rax, -0x220(%rbp)
jmp 0x2150c
movq -0x168(%rbp), %rax
movq -0x220(%rbp), %rcx
movzbl (%rcx), %ecx
movl %ecx, %edx
movq 0x40(%rax), %rax
movq 0x30(%rax), %rcx
addq %rdx, %rcx
movq %rcx, 0x30(%rax)
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x47b0
movq %rax, -0x238(%rbp)
jmp 0x21544
movq -0x168(%rbp), %rax
movq -0x238(%rbp), %rcx
movb (%rcx), %sil
movq 0x40(%rax), %rcx
movslq -0xc(%rbp), %rdx
movb %sil, 0x38(%rcx,%rdx)
movq 0x40(%rax), %rax
movl 0x40(%rax), %ecx
addl $0x1, %ecx
movl %ecx, 0x40(%rax)
movl -0xc(%rbp), %eax
addl $0x1, %eax
movl %eax, -0xc(%rbp)
jmp 0x21445
cmpl $0x7, -0xc(%rbp)
jle 0x2166d
movq 0xfa5a(%rip), %rdi      # 0x30fe8
leaq 0x4c3c(%rip), %rsi      # 0x261d1
callq 0x4340
movq %rax, -0x240(%rbp)
jmp 0x215a3
movq -0x168(%rbp), %rax
movq 0x30(%rax), %rdi
callq 0x178d0
movq %rax, -0x248(%rbp)
jmp 0x215bc
movq -0x248(%rbp), %rsi
movq -0x240(%rbp), %rdi
callq 0x4720
jmp 0x215d1
leaq -0x159(%rbp), %rdi
movq %rdi, -0x250(%rbp)
callq 0x46e0
movq -0x250(%rbp), %rdx
leaq 0x4b7a(%rip), %rsi      # 0x2616c
leaq -0x158(%rbp), %rdi
callq 0x7670
jmp 0x21600
movl $0xab, -0x160(%rbp)
leaq -0x158(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0x151c0
jmp 0x2161f
leaq -0x158(%rbp), %rdi
callq 0x41e0
leaq -0x159(%rbp), %rdi
callq 0x43d0
jmp 0x2166d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x2165f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x158(%rbp), %rdi
callq 0x41e0
leaq -0x159(%rbp), %rdi
callq 0x43d0
jmp 0x216e2
movq -0x168(%rbp), %rax
movq 0x40(%rax), %rax
cmpq $0x0, 0x30(%rax)
jne 0x2169c
movq -0x168(%rbp), %rax
movq 0x40(%rax), %rax
movw 0x20(%rax), %cx
andw $0xfeff, %cx            # imm = 0xFEFF
orw $0x100, %cx             # imm = 0x100
movw %cx, 0x20(%rax)
jmp 0x216d0
xorl %eax, %eax
movl %eax, %esi
leaq -0x30(%rbp), %rdi
callq 0x47b0
movq %rax, -0x258(%rbp)
jmp 0x216b4
movq -0x168(%rbp), %rax
movq -0x258(%rbp), %rcx
movsbl (%rcx), %ecx
movslq %ecx, %rcx
movq 0x40(%rax), %rax
movq %rcx, 0x30(%rax)
leaq -0x30(%rbp), %rdi
callq 0x41e0
addq $0x260, %rsp            # imm = 0x260
popq %rbp
retq
leaq -0x30(%rbp), %rdi
callq 0x41e0
movq -0x38(%rbp), %rdi
callq 0x46d0
nopw %cs:(%rax,%rax)