// File: /workspace/github_cpp_makefile_star2_O2/marxn[P]pupp/src/pupp.cpp
// Function: main
int main(int argc, char * argv[])
{
        FILE * fp = NULL;

        if(argc==1)
        {
                fp = stdin;
        }
        else
        {
                fp = fopen(argv[1],"r");
                if(fp==NULL)
                {
                        fprintf(stderr, "Could not open file: '%s'\n", argv[1]);
                        return -1;
                }
        }

        yyin = fp;

        ContainerNode * bean = parse();

        if(bean == NULL)
        {
                return -1;
        }

        MapValue * para = new MapValue();

        for(int i = 0; i<argc; i++)
        {
                IntegerValue * key = new IntegerValue(i);
                StringValue * value = new StringValue(string(argv[i]));

                ValueBox * vb = new ValueBox(value);
                KVValue * kv = new KVValue(key, vb);
                para->AddKV(kv);

                delete kv;
                delete vb;
                delete value;
                delete key;
        }

        string   para_name = "args";
        VariableType para_type(Map, Null);

        VarDefinitionStatement * defstmt = new VarDefinitionStatement(&para_name, &para_type);
        defstmt->SetParentNode(bean);
        defstmt->SetInitExpr(new ConstValueExpression(para));

        bean->AddNode(defstmt);

        if(bean->Provision()==false || bean->Check()==false)
        {
                return -2;
        }

        NodeContext context;
        context.AddFrame(bean);

        bean->Execute(&context);

        fclose(fp);

        int ret = 0;

        ConstValue * retval = context.FunctionRet;

        if(retval!=NULL && retval->GetType()==Integer)
        {
                ret = static_cast<int>(static_cast<IntegerValue*>(retval)->GetValue());
        }

        return ret;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xf8, %rsp
movq %rsi, %r14
pushq $-0x1
popq %r15
movq %rdi, %r12
cmpl $0x1, %edi
jne 0x6868
movq 0x3c765(%rip), %rax     # 0x42fc8
movq (%rax), %rbx
jmp 0x6884
movq 0x8(%r14), %rdi
leaq 0x2a01e(%rip), %rsi     # 0x30891
callq 0x6300
movq %rax, %rbx
testq %rax, %rax
je 0x6ad8
leaq 0x3ca5d(%rip), %rax     # 0x432e8
movq %rbx, (%rax)
callq 0x11ad8
testq %rax, %rax
je 0x6ac3
movq %rax, 0x8(%rsp)
movq %rbx, 0x10(%rsp)
pushq $0x40
popq %rdi
callq 0x6260
movq %rax, (%rsp)
movq %rax, %rdi
callq 0x76dc
xorl %ebx, %ebx
testl %r12d, %r12d
cmovlel %ebx, %r12d
movq %r12, 0x18(%rsp)
leaq 0xd8(%rsp), %r13
cmpq %rbx, 0x18(%rsp)
je 0x69ab
pushq $0x18
popq %rdi
callq 0x6260
movq %rax, %r15
movq %rax, %rdi
movq %rbx, %rsi
callq 0x6f90
pushq $0x30
popq %rdi
callq 0x6260
movq %rax, %r12
movq (%r14,%rbx,8), %rsi
movq %r13, %rdi
leaq 0x68(%rsp), %rdx
callq 0x6b9e
movq %rbx, 0x20(%rsp)
movq %r12, %rdi
movq %r13, %rsi
callq 0x6e18
movq %r14, %rbx
movq %r13, %rbp
movq %r13, %rdi
callq 0x6130
pushq $0x10
popq %rdi
callq 0x6260
movq %rax, %r13
movq %rax, %rdi
movq %r12, %rsi
callq 0x6cce
pushq $0x20
popq %rdi
callq 0x6260
movq %rax, %r14
movq %rax, %rdi
movq %r15, %rsi
movq %r13, %rdx
callq 0x7554
movq (%rsp), %rdi
movq %r14, %rsi
callq 0x782c
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
movq %r13, %rdi
callq 0x6cf2
movq %r13, %rdi
pushq $0x10
popq %rsi
callq 0x6270
movq (%r12), %rax
movq %r12, %rdi
callq *0x8(%rax)
movq (%r15), %rax
movq %r15, %rdi
callq *0x8(%rax)
movq 0x20(%rsp), %rax
incq %rax
movq %rbx, %r14
movq %rax, %rbx
movq %rbp, %r13
jmp 0x68d0
leaq 0x2866d(%rip), %rsi     # 0x2f01f
leaq 0x48(%rsp), %rdi
leaq 0x68(%rsp), %rdx
callq 0x6b9e
leaq 0x28(%rsp), %rdi
pushq $0x6
popq %rsi
xorl %edx, %edx
callq 0x13f1e
movq 0x10(%rsp), %rbx
movq 0x8(%rsp), %r12
movl $0x80, %edi
callq 0x6260
movq %rax, %r14
leaq 0x48(%rsp), %rsi
leaq 0x28(%rsp), %rdx
movq %rax, %rdi
callq 0x13f62
movq %r14, %rdi
movq %r12, %rsi
callq 0xa9b6
pushq $0x20
popq %rdi
callq 0x6260
movq %rax, %r15
movq %rax, %rdi
movq (%rsp), %rsi
callq 0x8a20
movq %r14, %rdi
movq %r15, %rsi
callq 0x141de
movq %r12, %rdi
movq %r14, %rsi
callq 0x887c
movq (%r12), %rax
movq %r12, %rdi
callq *0x10(%rax)
pushq $-0x2
popq %r15
testb %al, %al
je 0x6aaf
movq (%r12), %rax
movq %r12, %rdi
callq *0x18(%rax)
testb %al, %al
je 0x6aaf
leaq 0x68(%rsp), %rdi
callq 0xab3c
leaq 0x68(%rsp), %rdi
movq %r12, %rsi
callq 0xac22
leaq 0x68(%rsp), %rsi
movq %r12, %rdi
callq 0xa98a
movq %rbx, %rdi
callq 0x6250
movq 0xb8(%rsp), %rbx
xorl %r15d, %r15d
testq %rbx, %rbx
je 0x6aa5
movq %rbx, %rdi
callq 0x6cbc
cmpl $0x1, %eax
jne 0x6aa5
movq %rbx, %rdi
callq 0x6fe4
movq %rax, %r15
leaq 0x68(%rsp), %rdi
callq 0xab84
leaq 0x30(%rsp), %rdi
callq 0x6bda
leaq 0x48(%rsp), %rdi
callq 0x6130
movl %r15d, %eax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x3c4f1(%rip), %rax     # 0x42fd0
movq (%rax), %rdi
movq 0x8(%r14), %rdx
leaq 0x28517(%rip), %rsi     # 0x2f004
xorl %eax, %eax
callq 0x63a0
jmp 0x6ac3
jmp 0x6afa
jmp 0x6b3c
movq %rax, %rbx
leaq 0x68(%rsp), %rdi
callq 0xab84
jmp 0x6b3f
movq %rax, %rbx
pushq $0x20
popq %rsi
movq %r15, %rdi
jmp 0x6b1f
movq %rax, %rbx
movl $0x80, %esi
movq %r14, %rdi
callq 0x6270
jmp 0x6b3f
movq %rax, %rbx
jmp 0x6b49
movq %rax, %rbx
jmp 0x6b96
movq %rax, %rbx
pushq $0x40
popq %rsi
movq (%rsp), %rdi
jmp 0x6b91
movq %rax, %rbx
leaq 0x30(%rsp), %rdi
callq 0x6bda
leaq 0x48(%rsp), %rdi
callq 0x6130
jmp 0x6b96
movq %rax, %rbx
jmp 0x6b6a
movq %rax, %rbx
leaq 0xd8(%rsp), %rdi
callq 0x6130
pushq $0x30
popq %rsi
movq %r12, %rdi
jmp 0x6b91
movq %rax, %rbx
pushq $0x10
popq %rsi
movq %r13, %rdi
jmp 0x6b91
movq %rax, %rbx
pushq $0x20
popq %rsi
movq %r14, %rdi
jmp 0x6b91
movq %rax, %rbx
pushq $0x18
popq %rsi
movq %r15, %rdi
callq 0x6270
movq %rbx, %rdi
callq 0x6460