// File: /workspace/github_cpp_makefile_star2_O3/marxn[P]pupp/src/parser/statement.cpp
// Function: AssignStatement::Invoke(NodeContext*)
int AssignStatement::Invoke(NodeContext * context)
{
        Variable * var = context->GetVariable(this->VarLayer, this->VarDef->GetVarIndex());
        if(var==NULL)
        {
                cerr<<"pupp runtime error: cannot find variable: "<<this->VarDef->GetVarName()<<endl;
                return NODE_RET_ERROR;
        }

        if(var->GetVarType()!=Array && var->GetVarType()!=Map && this->Reference->GetExpsList()->size()>0)
        {
                cerr<<"pupp runtime error: Variable "<<this->Reference->GetVarName()<<" is neither an array nor a set."<<endl;
                return false;
        }

        ValueBox * result = var->GetVBox();
        
        if(this->Reference->GetExpsList()->size()==0 && var->GetVarType()==Array)
        {
                cerr<<"pupp runtime error: cannot assign for an array"<<var->GetVarName()<<endl;
                return NODE_RET_ERROR;
        }
        
        bool need_convert = true;
        list<list<Expression*>*> * exprslist = this->Reference->GetExpsList();
        
        for(list<list<Expression*>*>::iterator gitor = exprslist->begin(); gitor!=exprslist->end(); gitor++)
        {
                list<Expression*>* exprlist = *gitor;
                
                if(result==NULL)
                {
                        cerr<<"pupp runtime error: cannot find key for variable "<<var->GetVarName()<<endl;
                        return NODE_RET_ERROR;
                }
                else if(result->GetVal()->GetType()==Array)
                {
                        if(static_cast<ArrayValue*>(result->GetVal())->GetDimensionNum()!=exprlist->size())
                        {
                                cerr<<"pupp runtime error: wrong dimension variable: "<<var->GetVarName()<<endl;
                                return NODE_RET_ERROR;
                        }

                        vector<long> desc;
                        
                        for(list<Expression*>::iterator i = exprlist->begin(); i!=exprlist->end(); i++)
                        {
                                ConstValue * value = (*i)->Calculate(context);
                                if(value->GetType()!=Integer)
                                {
                                        ConstValue * thevalue = ConstValueCast(value, Integer);
                                        delete value;

                                        if(thevalue==NULL)
                                        {
                                                cerr<<"pupp runtime error: invalid index type for variable: "<<var->GetVarName()<<endl;
                                                return NODE_RET_ERROR;
                                        }
                                        
                                        value = thevalue;
                                        
                                }
                                
                                desc.push_back(static_cast<IntegerValue*>(value)->GetValue());
                                delete value;
                        }

                        ArrayValue * val = static_cast<ArrayValue*>(result->GetVal());
                        
                        result = val->GetElementBox(desc);
                }
                else if(result->GetVal()->GetType()==Map)
                {
                        need_convert = false;
                        
                        if(exprlist->size() > 1)
                        {
                                cerr<<"pupp runtime error: invalid key list for a collection"<<endl;
                                return NODE_RET_ERROR;
                        }
                        
                        ConstValue * key = exprlist->front()->Calculate(context);
                        if(key==NULL)
                        {
                                cerr<<"pupp runtime error: invalid key for a collection"<<endl;
                                return NODE_RET_ERROR;
                        }
                        
                        MapValue * val = static_cast<MapValue*>(result->GetVal());
                        result = val->FindByKey(key->toString());
                        
                        if(result==NULL)
                        {
                                MapValue * value = new MapValue();
                                ValueBox * vb = new ValueBox(value);
                                KVValue * kv = new KVValue(key, vb);
                                val->AddKV(kv);

                                delete kv;
                                delete vb;
                                delete value;
                                
                                result = val->FindByKey(key->toString());
                        }
                        
                        delete key;
                }
                else
                {
                        cerr<<"pupp runtime error: cannot accept a non-collection variable: "<<var->GetVarName()<<endl;
                        return NODE_RET_ERROR;
                }
        }
        
        ConstValue * value = Expr->Calculate(context);
        
        if(value==NULL)
        {
                cerr<<"pupp runtime error: cannot calculate the value for the expression"<<endl;
                return NODE_RET_ERROR;
        }

        if(result->GetVal()->GetType()!=value->GetType() && need_convert)
        {
                ConstValue * thevalue = ConstValueCast(value, var->GetVarType());
                delete value;
                value = thevalue;

                if(value==NULL)
                {
                        cerr<<"pupp runtime error: data type mismatch while assigning "<<endl;
                        return NODE_RET_ERROR;
                }
        }
        
        this->AdjustValue(result, value, this->OperType);
                
        return NODE_RET_NORMAL;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, %r15
movq %rdi, %r14
movq 0x78(%rdi), %rdi
movq 0x80(%r14), %rbx
callq 0x189a0
movq %r15, 0x38(%rsp)
movq %r15, %rdi
movq %rbx, %rsi
movq %rax, %rdx
callq 0xc7ec
testq %rax, %rax
je 0x1694f
movq %rax, %r15
movq %rax, %rdi
callq 0x18716
cmpl $0x7, %eax
je 0x168ba
movq %r15, %rdi
callq 0x18716
cmpl $0x6, %eax
je 0x168ba
movq 0x68(%r14), %rax
movq 0x20(%rax), %rax
cmpq $0x0, 0x10(%rax)
je 0x168ba
movq 0x307dc(%rip), %rbx     # 0x46ff0
leaq 0x20472(%rip), %rsi     # 0x36c8d
movl $0x1d, %edx
movq %rbx, %rdi
callq 0x62f0
movq 0x68(%r14), %rax
leaq 0x18(%rsp), %r12
movq %r12, -0x10(%r12)
movq (%rax), %rsi
movq 0x8(%rax), %rdx
addq %rsi, %rdx
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x99a6
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0x62f0
movq %rax, %rbx
leaq 0x20445(%rip), %rsi     # 0x36cab
movl $0x1f, %edx
movq %rax, %rdi
callq 0x62f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x6220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x6040
movq %rax, %rdi
callq 0x61b0
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
je 0x16d97
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6270
jmp 0x16d97
movq %r15, %rdi
callq 0x185ae
movq %rax, %r12
movq 0x68(%r14), %rax
movq 0x20(%rax), %rax
cmpq $0x0, 0x10(%rax)
jne 0x169ca
movq %r15, %rdi
callq 0x18716
cmpl $0x7, %eax
jne 0x169c2
movq 0x30700(%rip), %rbx     # 0x46ff0
leaq 0x203d4(%rip), %rsi     # 0x36ccb
movl $0x2e, %edx
movq %rbx, %rdi
callq 0x62f0
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movq %r15, %rsi
callq 0x1857c
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0x62f0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x6220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x6040
movq %rax, %rdi
callq 0x61b0
jmp 0x169b4
movq 0x3069a(%rip), %rbx     # 0x46ff0
leaq 0x1eac0(%rip), %rsi     # 0x3541d
movl $0x2a, %edx
movq %rbx, %rdi
callq 0x62f0
movq 0x78(%r14), %rsi
leaq 0x8(%rsp), %r14
movq %r14, %rdi
callq 0x1896c
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0x62f0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x6220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x6040
movq %rax, %rdi
callq 0x61b0
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
jmp 0x16ef9
movq 0x68(%r14), %rax
movq 0x20(%rax), %rax
movq %r15, 0x30(%rsp)
movq %r14, 0x58(%rsp)
movq (%rax), %r15
cmpq %rax, %r15
je 0x16d0f
movb $0x1, %cl
movl %ecx, 0x2c(%rsp)
movq %rax, 0x60(%rsp)
testq %r12, %r12
je 0x16db6
movq 0x10(%r15), %r14
movq %r12, %rdi
callq 0x7e76
movq %rax, %rdi
callq 0x7da6
movl %eax, %ebx
movq %r12, %rdi
callq 0x7e76
movq %rax, %rdi
cmpl $0x7, %ebx
jne 0x16ad8
callq 0x951e
cmpq 0x10(%r14), %rax
jne 0x16e21
xorps %xmm0, %xmm0
movaps %xmm0, 0x40(%rsp)
movq $0x0, 0x50(%rsp)
movq (%r14), %rbp
cmpq %r14, %rbp
je 0x16c39
movq 0x10(%rbp), %rdi
movq (%rdi), %rax
movq 0x38(%rsp), %rsi
callq *0x10(%rax)
movq %rax, %r13
movq %rax, %rdi
callq 0x7da6
cmpl $0x1, %eax
je 0x16a8f
movq %r13, %rdi
movl $0x1, %esi
callq 0x952b
movq %rax, %rbx
movq (%r13), %rax
movq %r13, %rdi
callq *0x8(%rax)
movq %rbx, %r13
testq %rbx, %rbx
je 0x16c58
movq %r13, %rdi
callq 0x8160
movq %rax, 0x8(%rsp)
movq 0x48(%rsp), %rsi
cmpq 0x50(%rsp), %rsi
je 0x16ab6
movq %rax, (%rsi)
addq $0x8, %rsi
movq %rsi, 0x48(%rsp)
jmp 0x16ac5
leaq 0x40(%rsp), %rdi
leaq 0x8(%rsp), %rdx
callq 0xba6c
movq (%r13), %rax
movq %r13, %rdi
callq *0x8(%rax)
movq (%rbp), %rbp
jmp 0x16a41
callq 0x7da6
cmpl $0x6, %eax
jne 0x16e89
cmpq $0x2, 0x10(%r14)
jae 0x16f0d
movq (%r14), %rax
movq 0x10(%rax), %rdi
movq (%rdi), %rax
movq 0x38(%rsp), %rsi
callq *0x10(%rax)
testq %rax, %rax
je 0x16f1b
movq %rax, %rbp
movq %r12, %rdi
callq 0x7e76
movq %rax, %r13
movq (%rbp), %rax
leaq 0x88(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
callq *0x18(%rax)
movq %r13, %rdi
movq %rbx, %rsi
callq 0x8d10
movq %rax, %r12
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x16b62
movq 0x98(%rsp), %rsi
incq %rsi
callq 0x6270
testq %r12, %r12
jne 0x16c22
movl $0x40, %edi
callq 0x6260
movq %rax, %r12
movq %rax, %rdi
callq 0x8a52
movl $0x10, %edi
callq 0x6260
movq %rax, %r14
movq %rax, %rdi
movq %r12, %rsi
callq 0x7dba
movl $0x20, %edi
callq 0x6260
movq %rax, %rbx
movq %rax, %rdi
movq %rbp, %rsi
movq %r14, %rdx
callq 0x8826
movq %r13, %rdi
movq %rbx, %rsi
callq 0x8bde
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
movq %r14, %rdi
callq 0x7de0
movl $0x10, %esi
movq %r14, %rdi
callq 0x6270
movq (%r12), %rax
movq %r12, %rdi
callq *0x8(%rax)
movq (%rbp), %rax
leaq 0x68(%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
callq *0x18(%rax)
movq %r13, %rdi
movq %rbx, %rsi
callq 0x8d10
movq %rax, %r12
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x16c22
movq 0x78(%rsp), %rsi
incq %rsi
callq 0x6270
movq (%rbp), %rax
movq %rbp, %rdi
callq *0x8(%rax)
movl $0x0, 0x2c(%rsp)
jmp 0x16cfc
movq %r12, %rdi
callq 0x7e76
movq %rax, %rdi
leaq 0x40(%rsp), %rsi
callq 0x9268
movq %rax, %r12
movb $0x1, %bl
jmp 0x16cdd
movl $0x35, %edx
movq 0x3038c(%rip), %rdi     # 0x46ff0
leaq 0x200c1(%rip), %rsi     # 0x36d2c
callq 0x62f0
leaq 0x8(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq 0x1857c
movq 0x8(%rsp), %rsi
movq 0x10(%rsp), %rdx
movq 0x30360(%rip), %rdi     # 0x46ff0
callq 0x62f0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x6220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x6040
movq %rax, %rdi
callq 0x61b0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x16cdb
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6270
xorl %ebx, %ebx
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x16cf4
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x6270
testb %bl, %bl
je 0x16f5d
movq (%r15), %r15
movq 0x60(%rsp), %rax
cmpq %rax, %r15
jne 0x169eb
jmp 0x16d15
movb $0x1, %al
movl %eax, 0x2c(%rsp)
movq 0x58(%rsp), %rax
movq 0x70(%rax), %rdi
movq (%rdi), %rax
movq 0x38(%rsp), %rsi
callq *0x10(%rax)
testq %rax, %rax
je 0x16d9e
movq %rax, %r15
movq %r12, %rdi
callq 0x7e76
movq %rax, %rdi
callq 0x7da6
movl %eax, %ebx
movq %r15, %rdi
callq 0x7da6
cmpl %eax, %ebx
setne %al
andb 0x2c(%rsp), %al
cmpb $0x1, %al
jne 0x16d84
movq 0x30(%rsp), %rdi
callq 0x18716
movq %r15, %rdi
movl %eax, %esi
callq 0x952b
movq %rax, %rbx
movq (%r15), %rax
movq %r15, %rdi
callq *0x8(%rax)
movq %rbx, %r15
testq %rbx, %rbx
je 0x16f74
movq 0x58(%rsp), %rax
movl 0x60(%rax), %ecx
movq %r12, %rsi
movq %r15, %rdx
callq 0x170a0
xorl %eax, %eax
jmp 0x16f62
movq 0x3024b(%rip), %rbx     # 0x46ff0
leaq 0x2005b(%rip), %rsi     # 0x36e07
movl $0x41, %edx
jmp 0x16f2e
movq 0x30233(%rip), %rbx     # 0x46ff0
leaq 0x1ff36(%rip), %rsi     # 0x36cfa
movl $0x31, %edx
movq %rbx, %rdi
callq 0x62f0
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movq 0x30(%rsp), %rsi
callq 0x1857c
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0x62f0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x6220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x6040
movq %rax, %rdi
callq 0x61b0
jmp 0x16eef
movq 0x301c8(%rip), %rbx     # 0x46ff0
leaq 0x1e33b(%rip), %rsi     # 0x3516a
movl $0x2e, %edx
movq %rbx, %rdi
callq 0x62f0
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movq 0x30(%rsp), %rsi
callq 0x1857c
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0x62f0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x6220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x6040
movq %rax, %rdi
callq 0x61b0
jmp 0x16eef
movq 0x30160(%rip), %rbx     # 0x46ff0
leaq 0x1ff32(%rip), %rsi     # 0x36dc9
movl $0x3d, %edx
movq %rbx, %rdi
callq 0x62f0
leaq 0x8(%rsp), %r14
movq %r14, %rdi
movq 0x30(%rsp), %rsi
callq 0x1857c
movq (%r14), %rsi
movq 0x8(%r14), %rdx
movq %rbx, %rdi
callq 0x62f0
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x6220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x6040
movq %rax, %rdi
callq 0x61b0
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x16f5d
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6270
jmp 0x16f5d
leaq 0x1fe4e(%rip), %rsi     # 0x36d62
movl $0x35, %edx
jmp 0x16f27
leaq 0x1fe76(%rip), %rsi     # 0x36d98
movl $0x30, %edx
movq 0x300c2(%rip), %rbx     # 0x46ff0
movq %rbx, %rdi
callq 0x62f0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x6220
movsbl %al, %esi
movq %rbx, %rdi
callq 0x6040
movq %rax, %rdi
callq 0x61b0
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x30075(%rip), %rbx     # 0x46ff0
leaq 0x1fec7(%rip), %rsi     # 0x36e49
movl $0x37, %edx
movq %rbx, %rdi
callq 0x62f0
movq %rbx, %rdi
callq 0x6140
jmp 0x16f5d
jmp 0x16fa7
jmp 0x16fa7
jmp 0x1707e
jmp 0x1707e
movq %rax, %r15
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
jmp 0x1706b
movq %rax, %r15
movq 0x68(%rsp), %rdi
leaq 0x78(%rsp), %rax
cmpq %rax, %rdi
je 0x17098
movq 0x78(%rsp), %rsi
jmp 0x17075
movq %rax, %r15
movl $0x20, %esi
movq %rbx, %rdi
jmp 0x17093
movq %rax, %r15
movl $0x10, %esi
movq %r14, %rdi
jmp 0x17093
movq %rax, %r15
movl $0x40, %esi
movq %r12, %rdi
jmp 0x17093
jmp 0x1705f
movq %rax, %r15
movq 0x8(%rsp), %rdi
cmpq %r12, %rdi
jne 0x17070
jmp 0x17098
movq %rax, %r15
movq 0x8(%rsp), %rdi
leaq 0x18(%rsp), %rax
cmpq %rax, %rdi
je 0x17081
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x6270
jmp 0x17081
movq %rax, %r15
movq 0x88(%rsp), %rdi
leaq 0x98(%rsp), %rax
cmpq %rax, %rdi
je 0x17098
movq 0x98(%rsp), %rsi
jmp 0x17075
jmp 0x1707e
movq %rax, %r15
leaq 0x18(%rsp), %rax
movq -0x10(%rax), %rdi
cmpq %rax, %rdi
je 0x17098
movq 0x18(%rsp), %rsi
incq %rsi
jmp 0x17093
jmp 0x1707e
jmp 0x1707e
movq %rax, %r15
movq 0x40(%rsp), %rdi
testq %rdi, %rdi
je 0x17098
movq 0x50(%rsp), %rsi
subq %rdi, %rsi
callq 0x6270
movq %r15, %rdi
callq 0x6460