// File: /workspace/github_cpp_makefile_star2_O1/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, %r15
movl %edi, %ebx
cmpl $0x1, %edi
jne 0x7943
movq 0x4068a(%rip), %rax     # 0x47fc8
movq (%rax), %r14
jmp 0x795f
movq 0x8(%r15), %rdi
leaq 0x2ff43(%rip), %rsi     # 0x37891
callq 0x6330
movq %rax, %r14
testq %rax, %rax
je 0x7bed
leaq 0x40982(%rip), %rax     # 0x482e8
movq %r14, (%rax)
callq 0x14e2b
testq %rax, %rax
je 0x7bf9
movq %rax, 0x10(%rsp)
movl $0x40, %edi
callq 0x6260
movq %rax, (%rsp)
movq %rax, %rdi
callq 0x8a9a
movq %r14, 0x8(%rsp)
testl %ebx, %ebx
jle 0x7a96
movl %ebx, %eax
movq %rax, 0x20(%rsp)
xorl %r13d, %r13d
leaq 0x48(%rsp), %rbp
movq %r15, 0x18(%rsp)
movl $0x18, %edi
callq 0x6260
movq %rax, %rbx
movq %rax, %rdi
movq %r13, %rsi
callq 0x815a
movl $0x30, %edi
callq 0x6260
movq %rax, %r14
movq (%r15,%r13,8), %rsi
movq %rbp, %rdi
leaq 0x88(%rsp), %rdx
callq 0x7cfe
movq %r14, %rdi
movq %rbp, %rsi
callq 0x7f9a
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x7a13
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x6270
movl $0x10, %edi
callq 0x6260
movq %rax, %r15
movq %rax, %rdi
movq %r14, %rsi
callq 0x7e02
movl $0x20, %edi
callq 0x6260
movq %rax, %r12
movq %rax, %rdi
movq %rbx, %rsi
movq %r15, %rdx
callq 0x886e
movq (%rsp), %rdi
movq %r12, %rsi
callq 0x8c26
movq (%r12), %rax
movq %r12, %rdi
callq *0x8(%rax)
movq %r15, %rdi
callq 0x7e28
movl $0x10, %esi
movq %r15, %rdi
callq 0x6270
movq (%r14), %rax
movq %r14, %rdi
callq *0x8(%rax)
movq (%rbx), %rax
movq %rbx, %rdi
callq *0x8(%rax)
incq %r13
cmpq %r13, 0x20(%rsp)
movq 0x18(%rsp), %r15
jne 0x79b3
leaq 0x38(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x2e579(%rip), %rsi     # 0x3601f
leaq 0x2e576(%rip), %rdx     # 0x36023
leaq 0x28(%rsp), %rdi
callq 0x7d3c
leaq 0x68(%rsp), %rdi
movl $0x6, %esi
xorl %edx, %edx
callq 0x17682
movq 0x10(%rsp), %r12
movl $0x80, %edi
callq 0x6260
movq %rax, %rbx
leaq 0x28(%rsp), %rsi
leaq 0x68(%rsp), %rdx
movq %rax, %rdi
callq 0x176e4
movq %rbx, %rdi
movq %r12, %rsi
callq 0xc3ee
movl $0x20, %edi
callq 0x6260
movq %rax, %r14
movq %rax, %rdi
movq (%rsp), %rsi
callq 0xa01a
movq %rbx, %rdi
movq %r14, %rsi
callq 0x17a6c
movq %r12, %rdi
movq %rbx, %rsi
callq 0x9f18
movq (%r12), %rax
movq %r12, %rdi
callq *0x10(%rax)
movl $0xfffffffe, %ebx       # imm = 0xFFFFFFFE
testb %al, %al
je 0x7bb2
movq (%r12), %rax
movq %r12, %rdi
callq *0x18(%rax)
testb %al, %al
je 0x7bb2
leaq 0x88(%rsp), %rdi
callq 0xc638
leaq 0x88(%rsp), %rdi
movq %r12, %rsi
callq 0xc748
leaq 0x88(%rsp), %rsi
movq %r12, %rdi
callq 0xc3c2
movq 0x8(%rsp), %rdi
callq 0x6250
movq 0xd8(%rsp), %r14
xorl %ebx, %ebx
testq %r14, %r14
je 0x7ba5
movq %r14, %rdi
callq 0x7dee
cmpl $0x1, %eax
jne 0x7ba5
movq %r14, %rdi
callq 0x81ae
movq %rax, %rbx
leaq 0x88(%rsp), %rdi
callq 0xc69a
leaq 0x70(%rsp), %r14
movq (%r14), %rdi
cmpq %r14, %rdi
je 0x7bd4
movq (%rdi), %r12
movl $0x18, %esi
callq 0x6270
movq %r12, %rdi
cmpq %r14, %r12
jne 0x7bbf
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x7bfe
movq 0x38(%rsp), %rsi
incq %rsi
callq 0x6270
jmp 0x7bfe
addq $0x8, %r15
movq %r15, %rdi
callq 0x6500
movl $0xffffffff, %ebx       # imm = 0xFFFFFFFF
movl %ebx, %eax
addq $0xf8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x7c16
jmp 0x7c65
movq %rax, %r13
leaq 0x88(%rsp), %rdi
callq 0xc69a
jmp 0x7c68
movq %rax, %r13
movl $0x20, %esi
movq %r14, %rdi
jmp 0x7c40
movq %rax, %r13
movl $0x80, %esi
movq %rbx, %rdi
callq 0x6270
jmp 0x7c68
movq %rax, %r13
jmp 0x7c8a
movq %rax, %r13
jmp 0x7cf6
movq %rax, %r13
movl $0x40, %esi
movq (%rsp), %rdi
jmp 0x7cf1
movq %rax, %r13
leaq 0x70(%rsp), %rbx
movq (%rbx), %rdi
cmpq %rbx, %rdi
je 0x7c8a
movq (%rdi), %r14
movl $0x18, %esi
callq 0x6270
movq %r14, %rdi
cmpq %rbx, %r14
jne 0x7c75
movq 0x28(%rsp), %rdi
cmpq %r15, %rdi
je 0x7cf6
movq 0x38(%rsp), %rsi
incq %rsi
jmp 0x7cf1
movq %rax, %r13
movl $0x18, %esi
movq %rbx, %rdi
jmp 0x7cf1
movq %rax, %r13
jmp 0x7ccf
movq %rax, %r13
movq 0x48(%rsp), %rdi
leaq 0x58(%rsp), %rax
cmpq %rax, %rdi
je 0x7ccf
movq 0x58(%rsp), %rsi
incq %rsi
callq 0x6270
movl $0x30, %esi
movq %r14, %rdi
jmp 0x7cf1
movq %rax, %r13
movl $0x10, %esi
movq %r15, %rdi
jmp 0x7cf1
movq %rax, %r13
movl $0x20, %esi
movq %r12, %rdi
callq 0x6270
movq %r13, %rdi
callq 0x6470