// File: /workspace/github_c_makefile_star2_O0/sharmaeklavya2[P]cerplag/driver_sub.c
// Function: main
int main(int argc, char* argv[])
{
    snprintf(usage, USAGE_SIZE, usage_template, argv[0]);
    if(argc < 2 || argc > 3)
        return cry_error();

    // open files
    FILE* ifp = fopen(argv[1], "r");
    if(ifp == NULL)
    {
        fprintf(stderr, "Couldn't open file %s:\n", argv[1]);
        perror(NULL);
        return 1;
    }
    FILE* ofp = stdout;
    if(argc == 3)
    {
        ofp = fopen(argv[2], "w");
        if(ofp == NULL)
        {
            fprintf(stderr, "Couldn't open file %s:\n", argv[2]);
            perror(NULL);
            return 1;
        }
    }

    fprintf(stderr, "Level 4: Symbol table, Type checking, Semantic rules, Assembly code generation.\n");

    fprintf(stderr, "Enter 1 to print token list.\n");
    fprintf(stderr, "Enter 2 to print parse tree in pre-order traversal.\n");
    fprintf(stderr, "Enter 3 to print AST in pre-order traversal.\n");
    fprintf(stderr, "Enter 4 to display compression percent.\n");
    fprintf(stderr, "Enter 5 to display symbol table.\n");
    fprintf(stderr, "Enter 6 to check code for semantic errors.\n");
    fprintf(stderr, "Enter 7 to produce assembly code.\n");
    int choice;
    scanf("%d",&choice);

    switch(choice){
        case 1:
            lexer_main(ifp, stdout, 0, print_token);
            break;
        case 2:
            parser_main(ifp, stdout, 0, print_tree);
            break;
        case 3:
            ast_gen_main(ifp, stdout, NULL, 0);
            break;
        case 4:
            ast_gen_main(ifp, NULL, stdout, 1);
            break;
        case 5:
            print_error_req = false;
            compiler_main(ifp, stdout, stdout, 0, 0);
            break;
        case 6:
            error_stream = stdout;
            compiler_main(ifp, stdout, NULL, 0, 0);
            break;
        case 7:
            compiler_main(ifp, ofp, NULL, 2, 0);
            break;
        default:
            fprintf(stderr, "Invalid choice!\n");
            break;
    }

    fprintf(stderr, "%d errors\n", error_count);
    if(warning_count > 0)
        fprintf(stderr, "%d warnings\n", warning_count);

    if(ifp != stdin)
        fclose(ifp);
    if(ofp != stdout && ofp != stderr)
        fclose(ofp);

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x40, %rsp
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq (%rax), %rcx
leaq 0xd0fc(%rip), %rdi      # 0x20000
movl $0x200, %esi            # imm = 0x200
leaq 0x7e40(%rip), %rdx      # 0x1ad50
movb $0x0, %al
callq 0x30b0
cmpl $0x2, -0x8(%rbp)
jl 0x12f23
cmpl $0x3, -0x8(%rbp)
jle 0x12f30
callq 0x12eb0
movl %eax, -0x4(%rbp)
jmp 0x1328f
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdi
leaq 0x194e(%rip), %rsi      # 0x1488d
callq 0x3150
movq %rax, -0x18(%rbp)
cmpq $0x0, -0x18(%rbp)
jne 0x12f84
movq 0x70a2(%rip), %rax      # 0x19ff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rdx
leaq 0x3078(%rip), %rsi      # 0x15fe0
movb $0x0, %al
callq 0x3120
xorl %eax, %eax
movl %eax, %edi
callq 0x3160
movl $0x1, -0x4(%rbp)
jmp 0x1328f
movq 0x7045(%rip), %rax      # 0x19fd0
movq (%rax), %rax
movq %rax, -0x20(%rbp)
cmpl $0x3, -0x8(%rbp)
jne 0x12fee
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdi
leaq 0x3051(%rip), %rsi      # 0x15ff8
callq 0x3150
movq %rax, -0x20(%rbp)
cmpq $0x0, -0x20(%rbp)
jne 0x12fec
movq 0x703a(%rip), %rax      # 0x19ff8
movq (%rax), %rdi
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rdx
leaq 0x3010(%rip), %rsi      # 0x15fe0
movb $0x0, %al
callq 0x3120
xorl %eax, %eax
movl %eax, %edi
callq 0x3160
movl $0x1, -0x4(%rbp)
jmp 0x1328f
jmp 0x12fee
movq 0x7003(%rip), %rax      # 0x19ff8
movq %rax, -0x40(%rbp)
movq (%rax), %rdi
leaq 0x2ff7(%rip), %rsi      # 0x15ffa
xorl %eax, %eax
movb %al, -0x31(%rbp)
callq 0x3120
movq -0x40(%rbp), %rcx
movb -0x31(%rbp), %al
movq (%rcx), %rdi
leaq 0x302d(%rip), %rsi      # 0x1604b
callq 0x3120
movq -0x40(%rbp), %rcx
movb -0x31(%rbp), %al
movq (%rcx), %rdi
leaq 0x3035(%rip), %rsi      # 0x16069
callq 0x3120
movq -0x40(%rbp), %rcx
movb -0x31(%rbp), %al
movq (%rcx), %rdi
leaq 0x3054(%rip), %rsi      # 0x1609e
callq 0x3120
movq -0x40(%rbp), %rcx
movb -0x31(%rbp), %al
movq (%rcx), %rdi
leaq 0x306c(%rip), %rsi      # 0x160cc
callq 0x3120
movq -0x40(%rbp), %rcx
movb -0x31(%rbp), %al
movq (%rcx), %rdi
leaq 0x307f(%rip), %rsi      # 0x160f5
callq 0x3120
movq -0x40(%rbp), %rcx
movb -0x31(%rbp), %al
movq (%rcx), %rdi
leaq 0x308b(%rip), %rsi      # 0x16117
callq 0x3120
movq -0x40(%rbp), %rcx
movb -0x31(%rbp), %al
movq (%rcx), %rdi
leaq 0x30a1(%rip), %rsi      # 0x16143
callq 0x3120
movb -0x31(%rbp), %al
leaq 0x19d7(%rip), %rdi      # 0x14a88
leaq -0x24(%rbp), %rsi
callq 0x3180
movl -0x24(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x30(%rbp)
subl $0x6, %eax
ja 0x131e0
movq -0x30(%rbp), %rax
leaq 0x2eeb(%rip), %rcx      # 0x15fc4
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq -0x18(%rbp), %rdi
movq 0x6ee3(%rip), %rax      # 0x19fd0
movq (%rax), %rsi
xorl %edx, %edx
leaq -0xd3f9(%rip), %rcx     # 0x5d00
callq 0x5e10
jmp 0x131f8
movq -0x18(%rbp), %rdi
movq 0x6ec2(%rip), %rax      # 0x19fd0
movq (%rax), %rsi
xorl %edx, %edx
leaq -0xa6fa(%rip), %rcx     # 0x8a20
callq 0x8a60
jmp 0x131f8
movq -0x18(%rbp), %rdi
movq 0x6ea1(%rip), %rax      # 0x19fd0
movq (%rax), %rsi
xorl %eax, %eax
movl %eax, %edx
xorl %ecx, %ecx
callq 0xb8f0
jmp 0x131f8
movq -0x18(%rbp), %rdi
movq 0x6e83(%rip), %rax      # 0x19fd0
movq (%rax), %rdx
xorl %eax, %eax
movl %eax, %esi
movl $0x1, %ecx
callq 0xb8f0
jmp 0x131f8
leaq 0x7986(%rip), %rax      # 0x1aaf0
movb $0x0, (%rax)
movq -0x18(%rbp), %rdi
movq 0x6e58(%rip), %rax      # 0x19fd0
movq (%rax), %rsi
movq 0x6e4e(%rip), %rax      # 0x19fd0
movq (%rax), %rdx
xorl %r8d, %r8d
movl %r8d, %ecx
callq 0xfad0
jmp 0x131f8
movq 0x6e37(%rip), %rax      # 0x19fd0
movq (%rax), %rcx
leaq 0xcc2d(%rip), %rax      # 0x1fdd0
movq %rcx, (%rax)
movq -0x18(%rbp), %rdi
movq 0x6e1f(%rip), %rax      # 0x19fd0
movq (%rax), %rsi
xorl %eax, %eax
movl %eax, %edx
xorl %r8d, %r8d
movl %r8d, %ecx
callq 0xfad0
jmp 0x131f8
movq -0x18(%rbp), %rdi
movq -0x20(%rbp), %rsi
xorl %eax, %eax
movl %eax, %edx
movl $0x2, %ecx
xorl %r8d, %r8d
callq 0xfad0
jmp 0x131f8
movq 0x6e11(%rip), %rax      # 0x19ff8
movq (%rax), %rdi
leaq 0x2f75(%rip), %rsi      # 0x16166
movb $0x0, %al
callq 0x3120
movq 0x6df9(%rip), %rax      # 0x19ff8
movq (%rax), %rdi
leaq 0xcbcf(%rip), %rax      # 0x1fdd8
movl (%rax), %edx
leaq 0x2f65(%rip), %rsi      # 0x16177
movb $0x0, %al
callq 0x3120
leaq 0xcbbc(%rip), %rax      # 0x1fddc
cmpl $0x0, (%rax)
jle 0x13246
movq 0x6dcc(%rip), %rax      # 0x19ff8
movq (%rax), %rdi
leaq 0xcba6(%rip), %rax      # 0x1fddc
movl (%rax), %edx
leaq 0x2f43(%rip), %rsi      # 0x16182
movb $0x0, %al
callq 0x3120
movq -0x18(%rbp), %rax
movq 0x6d87(%rip), %rcx      # 0x19fd8
cmpq (%rcx), %rax
je 0x1325f
movq -0x18(%rbp), %rdi
callq 0x3090
movq -0x20(%rbp), %rax
movq 0x6d66(%rip), %rcx      # 0x19fd0
cmpq (%rcx), %rax
je 0x13288
movq -0x20(%rbp), %rax
movq 0x6d7e(%rip), %rcx      # 0x19ff8
cmpq (%rcx), %rax
je 0x13288
movq -0x20(%rbp), %rdi
callq 0x3090
movl $0x0, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x40, %rsp
popq %rbp
retq