// File: /workspace/github_cpp_makefile_star2_O2/Merulo[P]CompilerJFTT/src/Main.cpp
// Function: main
int main(int argc, char** argv)
{
    if (argc < 3)
    {
        std::cout<<"USAGE: ./kompilator input output"<<std::endl;
        std::cout<<"Not enough arguments\n";
        return 1;
    }
    d.FIR->setSymbolTable(d.ST);
    yyin = fopen(argv[1], "r");
    yyparse();

    bool emulator = true;

    for(int i = 0; i < argc; i++)
    {
        std::string str = argv[i];
        std::string output;
        if (i + 1 < argc)
        {
            output = argv[i+1];
        }
        if (str == "-em")
        {
            emulator = false;
        }        
        if (str == "-FIR")
        {
            d.FIR->print(output);
            return 0;
        }
        if (str == "-SIR")
        {
            d.convertToSIR();
            d.SIR->print(output);   
            return 0;
        }
        if (str == "-TIR")
        {
            d.convertToSIR();
            d.convertToTIR();
            d.TIR->print(output);
            return 0;
        }
        if (str == "-FOIR")
        {
            d.convertToSIR();
            d.convertToTIR();
            d.convertToFOIR(argv[2], emulator);
            d.FOIR->print(output);
            return 0;
        }
    }

    d.convertToSIR();
    d.convertToTIR();
    d.convertToFOIR(argv[2], emulator);
    d.converToFIIR();
    d.FIIR->print(argv[2]);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xa8, %rsp
movq %rsi, -0x38(%rbp)
cmpl $0x2, %edi
jg 0x20e9c
movq 0x1114a(%rip), %rbx     # 0x31fb8
leaq 0x35f8(%rip), %rsi      # 0x2446d
movq %rbx, %rdi
callq 0x4270
movq %rax, %rdi
callq 0x4160
leaq 0x3602(%rip), %rsi      # 0x2448e
movq %rbx, %rdi
callq 0x4270
pushq $0x1
popq %rax
jmp 0x2112b
movl %edi, %r15d
movq 0x11532(%rip), %r14     # 0x323d8
leaq 0x1151b(%rip), %rsi     # 0x323c8
leaq -0x88(%rbp), %r12
movq %r12, %rdi
callq 0x1a180
movq %r14, %rdi
movq %r12, %rsi
callq 0x1b302
leaq -0x80(%rbp), %rdi
callq 0x85a8
movq -0x38(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x3881(%rip), %rsi      # 0x24760
callq 0x4300
movq %rax, 0x11455(%rip)     # 0x32340
callq 0x1f070
movl %r15d, %ebx
negq %rbx
movb $0x1, %r14b
pushq $0x1
popq %r13
leaq -0x78(%rbp), %r12
leaq (%rbx,%r13), %rax
movzbl %r14b, %r14d
cmpq $0x1, %rax
je 0x20fde
movq -0x38(%rbp), %rax
movq -0x8(%rax,%r13,8), %rsi
movq %r12, %rdi
leaq -0x58(%rbp), %rdx
callq 0x4a54
leaq -0x48(%rbp), %rax
movq %rax, -0x58(%rbp)
andq $0x0, -0x50(%rbp)
movb $0x0, -0x48(%rbp)
cmpl %r15d, %r13d
jge 0x20f4f
movq -0x38(%rbp), %rax
movq (%rax,%r13,8), %rsi
leaq -0x58(%rbp), %rdi
callq 0x44e0
movq %r12, %rdi
leaq 0x354b(%rip), %rsi      # 0x244a4
callq 0x8453
testb %al, %al
movl $0x0, %eax
cmovnel %eax, %r14d
movq %r12, %rdi
leaq 0x3535(%rip), %rsi      # 0x244a8
callq 0x8453
testb %al, %al
jne 0x2106c
movq %r12, %rdi
leaq 0x3523(%rip), %rsi      # 0x244ad
callq 0x8453
testb %al, %al
jne 0x21078
movq %r12, %rdi
leaq 0x3511(%rip), %rsi      # 0x244b2
callq 0x8453
testb %al, %al
jne 0x2108d
movq %r12, %rdi
leaq 0x34ff(%rip), %rsi      # 0x244b7
callq 0x8453
testb %al, %al
jne 0x210ae
leaq -0x58(%rbp), %rdi
callq 0x4548
movq %r12, %rdi
callq 0x4548
incq %r13
jmp 0x20f01
leaq 0x113e3(%rip), %r15     # 0x323c8
movq %r15, %rdi
callq 0x2133e
movq %r15, %rdi
callq 0x213ec
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rsi
leaq -0xa8(%rbp), %rdi
leaq -0x78(%rbp), %rdx
callq 0x4a54
andl $0x1, %r14d
leaq 0x113b0(%rip), %rdi     # 0x323c8
leaq -0xa8(%rbp), %rsi
movl %r14d, %edx
callq 0x2149a
leaq -0xa8(%rbp), %rdi
callq 0x4548
leaq 0x1138e(%rip), %rdi     # 0x323c8
callq 0x2157c
movq 0x113d2(%rip), %r14     # 0x32418
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rsi
leaq -0x78(%rbp), %rdi
leaq -0x58(%rbp), %rdx
callq 0x4a54
leaq -0x78(%rbp), %rsi
movq %r14, %rdi
callq 0x1b308
jmp 0x21120
leaq 0x11365(%rip), %rax     # 0x323d8
jmp 0x2110b
leaq 0x11349(%rip), %rdi     # 0x323c8
callq 0x2133e
leaq 0x1135d(%rip), %rax     # 0x323e8
jmp 0x2110b
leaq 0x11334(%rip), %rdi     # 0x323c8
callq 0x2133e
leaq 0x11328(%rip), %rdi     # 0x323c8
callq 0x213ec
leaq 0x1134c(%rip), %rax     # 0x323f8
jmp 0x2110b
leaq 0x11313(%rip), %rdi     # 0x323c8
callq 0x2133e
leaq 0x11307(%rip), %rdi     # 0x323c8
callq 0x213ec
movq -0x38(%rbp), %rax
movq 0x10(%rax), %rsi
leaq -0xc8(%rbp), %rdi
leaq -0x29(%rbp), %rdx
callq 0x4a54
movzbl %r14b, %edx
andl $0x1, %edx
leaq 0x112dc(%rip), %rdi     # 0x323c8
leaq -0xc8(%rbp), %rsi
callq 0x2149a
leaq -0xc8(%rbp), %rdi
callq 0x4548
leaq 0x112fd(%rip), %rax     # 0x32408
movq (%rax), %rdi
leaq -0x58(%rbp), %rsi
callq 0x1b308
leaq -0x58(%rbp), %rdi
callq 0x4548
leaq -0x78(%rbp), %rdi
callq 0x4548
xorl %eax, %eax
addq $0xa8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq %rax, %rbx
leaq -0xc8(%rbp), %rdi
callq 0x4548
jmp 0x21178
jmp 0x21175
movq %rax, %rbx
jmp 0x21181
jmp 0x2118c
movq %rax, %rbx
leaq -0xa8(%rbp), %rdi
jmp 0x21185
jmp 0x2118c
movq %rax, %rbx
leaq -0x80(%rbp), %rdi
callq 0x85a8
jmp 0x2118f
jmp 0x21175
movq %rax, %rbx
leaq -0x58(%rbp), %rdi
callq 0x4548
leaq -0x78(%rbp), %rdi
callq 0x4548
jmp 0x2118f
movq %rax, %rbx
movq %rbx, %rdi
callq 0x4490