// File: /workspace/github_cpp_makefile_star2_O1/DuoLife-QNL[P]lexical_analysis/main.cpp
// Function: main
int main(int a, char** b){
    argc = a;
    argv = b;
    keyword k;
    operators o;
    delimiter de;
    strings s;
    characters c;
    error e;
    id i;

    if (argc > 1){
        if(!(yyin = fopen(argv[1], "r"))){
            perror(argv[1]);
            return 1;
        }
        if (argc == 2){
            cout << left << setw(30) << "TOKEN_TYPE" << left << setw(30) << "CONTENT" << endl << endl;
        }else if (argc ==3){
            outfile.open(argv[2]);
            outfile << left << setw(30) << "TOKEN_TYPE" << left << setw(30) << "CONTENT" << endl << endl;
        }
    }else{
        cout << "Please input the token" << endl;        
    }

    int d = yylex();
    while(d){
        if (d == KEYWORD){
            k.detected(yytext);
            ch_cnt += yyleng;
        }else if(d == RELOP){
            o.detected(yytext);
            ch_cnt += yyleng;
        }else if(d == DELIMITER){
            de.detected(yytext);
            ch_cnt += yyleng;
        }else if (d == IDENTIFIER){
            ch_cnt += yyleng;
        }else if(d == STRINGS){
            s.display(yytext);
            ch_cnt += yyleng;
        }else if (d == CHARACTERS){
            c.display(yytext);
            ch_cnt += yyleng;
        }else if(d == NUM){
            ch_cnt += yyleng;
        }else if(d == ERROR){
            e.display(yytext, yylineno);
        }
        else{
            ;
        }
        d = yylex();
    }

    if(argc == 2){
        cout << endl << endl << "STATISTICS" << endl << endl;

        cout << left << setw(30) << "ITEM" << left << setw(30) << "COUNT" << endl;
        cout << left << setw(30) << "Identifier" << left << setw(30) << id::id_cnt << endl;
        cout << left << setw(30) << "Number" << left << setw(30) << num::num_cnt << endl;
        cout << left << setw(30) << "Operator" << left << setw(30) << operators::opr_cnt << endl;
        cout << left << setw(30) << "Delimiter" << left << setw(30) << delimiter::dlmt_cnt << endl;
        cout << left << setw(30) << "Keyword" << left << setw(30) << keyword::kw_cnt << endl;
        cout << left << setw(30) << "Line" << left << setw(30) << line::count << endl;
        cout << left << setw(30) << "Total character number" << left << setw(30) << ch_cnt << endl;
    }else if(argc == 3){
        outfile << endl << endl << "STATISTICS" << endl << endl;

        outfile << left << setw(30) << "ITEM" << left << setw(30) << "COUNT" << endl;
        outfile << left << setw(30) << "Identifier" << left << setw(30) << id::id_cnt << endl;
        outfile << left << setw(30) << "Number" << left << setw(30) << num::num_cnt << endl;
        outfile << left << setw(30) << "Operator" << left << setw(30) << operators::opr_cnt << endl;
        outfile << left << setw(30) << "Delimiter" << left << setw(30) << delimiter::dlmt_cnt << endl;
        outfile << left << setw(30) << "Keyword" << left << setw(30) << keyword::kw_cnt << endl;
        outfile << left << setw(30) << "Line" << left << setw(30) << line::count << endl;
        outfile << left << setw(30) << "Total character number" << left << setw(30) << ch_cnt << endl;  

    }
    i.disp_tbl();

    outfile.close();
    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movl %edi, 0x7c8c(%rip)      # 0xa1ac
movq %rsi, 0x7c89(%rip)      # 0xa1b0
cmpl $0x2, %edi
jl 0x25ea
movq 0x8(%rsi), %rdi
leaq 0x5306(%rip), %rsi      # 0x7841
callq 0x21c0
leaq 0x7e81(%rip), %rcx      # 0xa3c8
movq %rax, (%rcx)
testq %rax, %rax
je 0x2d25
movl 0x7c53(%rip), %eax      # 0xa1ac
cmpl $0x3, %eax
je 0x260a
cmpl $0x2, %eax
jne 0x26f6
movq 0x7a56(%rip), %rbx      # 0x9fc8
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movl $0xffffff4f, %r14d      # imm = 0xFFFFFF4F
movl 0x18(%rbx,%rcx), %edx
andl %r14d, %edx
orl $0x20, %edx
movl %edx, 0x18(%rbx,%rcx)
movq -0x18(%rax), %rax
movl $0x1e, %r15d
movq %r15, 0x10(%rbx,%rax)
leaq 0x3a61(%rip), %rsi      # 0x6004
movl $0xa, %edx
movq %rbx, %rdi
callq 0x21b0
movq (%rbx), %rax
movq -0x18(%rax), %rcx
andl 0x18(%rbx,%rcx), %r14d
orl $0x20, %r14d
movl %r14d, 0x18(%rbx,%rcx)
movq -0x18(%rax), %rax
movq %r15, 0x10(%rbx,%rax)
leaq 0x3a3a(%rip), %rsi      # 0x600f
movl $0x7, %edx
movq %rbx, %rdi
callq 0x21b0
movq (%rbx), %rax
jmp 0x26a8
movq 0x79d7(%rip), %rbx      # 0x9fc8
leaq 0x3a1f(%rip), %rsi      # 0x6017
movl $0x16, %edx
movq %rbx, %rdi
callq 0x21b0
jmp 0x26cf
movq 0x7b9f(%rip), %rax      # 0xa1b0
movq 0x10(%rax), %rsi
leaq 0x7b9c(%rip), %rbx      # 0xa1b8
movq %rbx, %rdi
movl $0x10, %edx
callq 0x2060
movq 0x7b88(%rip), %rax      # 0xa1b8
movq -0x18(%rax), %rcx
movl $0xffffff4f, %r14d      # imm = 0xFFFFFF4F
movl 0x18(%rcx,%rbx), %edx
andl %r14d, %edx
orl $0x20, %edx
movl %edx, 0x18(%rcx,%rbx)
movq -0x18(%rax), %rax
movl $0x1e, %r15d
movq %r15, 0x10(%rax,%rbx)
leaq 0x39a6(%rip), %rsi      # 0x6004
movl $0xa, %edx
movq %rbx, %rdi
callq 0x21b0
movq 0x7b46(%rip), %rax      # 0xa1b8
movq -0x18(%rax), %rcx
andl 0x18(%rcx,%rbx), %r14d
orl $0x20, %r14d
movl %r14d, 0x18(%rcx,%rbx)
movq -0x18(%rax), %rax
movq %r15, 0x10(%rax,%rbx)
leaq 0x397b(%rip), %rsi      # 0x600f
movl $0x7, %edx
movq %rbx, %rdi
callq 0x21b0
movq 0x7b10(%rip), %rax      # 0xa1b8
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
movq %rax, %rbx
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
leaq 0x7ce3(%rip), %r14      # 0xa3e0
leaq 0x7cbc(%rip), %r15      # 0xa3c0
leaq -0x2b(%rbp), %r13
leaq 0x7a79(%rip), %r12      # 0xa188
leaq -0x2a(%rbp), %rbx
callq 0x2d34
cmpl $0x5f, %eax
jg 0x273e
cmpl $0x4e, %eax
jg 0x275b
cmpl $0x23, %eax
je 0x279f
cmpl $0x27, %eax
jne 0x27b9
movq (%r14), %rsi
leaq -0x2e(%rbp), %rdi
callq 0x4d2c
jmp 0x27ab
cmpl $0x6e, %eax
jg 0x2767
cmpl $0x60, %eax
je 0x27ab
cmpl $0x6e, %eax
jne 0x2713
movq (%r14), %rsi
leaq -0x2c(%rbp), %rdi
callq 0x5130
jmp 0x27ab
cmpl $0x4f, %eax
je 0x2784
cmpl $0x5f, %eax
je 0x27ab
jmp 0x2713
cmpl $0x6f, %eax
je 0x2792
cmpl $0xc7, %eax
jne 0x2713
movq (%r14), %rsi
movl (%r12), %edx
movq %rbx, %rdi
callq 0x5514
jmp 0x2713
movq (%r14), %rsi
leaq -0x2d(%rbp), %rdi
callq 0x4ec8
jmp 0x27ab
movq (%r14), %rsi
movq %r13, %rdi
callq 0x5322
jmp 0x27ab
movq (%r14), %rsi
leaq -0x2f(%rbp), %rdi
callq 0x5064
movl (%r15), %eax
addl %eax, 0x7c04(%rip)      # 0xa3b8
jmp 0x2713
testl %eax, %eax
jne 0x2713
movl 0x79e5(%rip), %eax      # 0xa1ac
cmpl $0x2, %eax
je 0x27de
cmpl $0x3, %eax
jne 0x2cff
leaq 0x79dc(%rip), %rbx      # 0xa1b8
jmp 0x27e5
movq 0x77e3(%rip), %rbx      # 0x9fc8
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
movq %rax, %r14
leaq 0x37ee(%rip), %rsi      # 0x602e
movl $0xa, %edx
movq %rax, %rdi
callq 0x21b0
movq (%r14), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movl $0xffffff4f, %r15d      # imm = 0xFFFFFF4F
movl 0x18(%rbx,%rcx), %edx
andl %r15d, %edx
orl $0x20, %edx
movl %edx, 0x18(%rbx,%rcx)
movq -0x18(%rax), %rax
movl $0x1e, %r12d
movq %r12, 0x10(%rbx,%rax)
leaq 0x376a(%rip), %rsi      # 0x6039
movl $0x4, %edx
movq %rbx, %rdi
callq 0x21b0
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movl 0x18(%rbx,%rcx), %edx
andl %r15d, %edx
orl $0x20, %edx
movl %edx, 0x18(%rbx,%rcx)
movq -0x18(%rax), %rax
movq %r12, 0x10(%rbx,%rax)
leaq 0x373d(%rip), %rsi      # 0x603e
movl $0x5, %edx
movq %rbx, %rdi
callq 0x21b0
movq (%rbx), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movl 0x18(%rbx,%rcx), %edx
andl %r15d, %edx
orl $0x20, %edx
movl %edx, 0x18(%rbx,%rcx)
movq -0x18(%rax), %rax
movq %r12, 0x10(%rbx,%rax)
leaq 0x36ea(%rip), %rsi      # 0x6044
movl $0xa, %edx
movq %rbx, %rdi
callq 0x21b0
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movl 0x18(%rbx,%rcx), %edx
andl %r15d, %edx
orl $0x20, %edx
movl %edx, 0x18(%rbx,%rcx)
movq -0x18(%rax), %rax
movq %r12, 0x10(%rbx,%rax)
leaq 0x7aac(%rip), %rax      # 0xa438
movl (%rax), %esi
movq %rbx, %rdi
callq 0x2290
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movl 0x18(%rbx,%rcx), %edx
andl %r15d, %edx
orl $0x20, %edx
movl %edx, 0x18(%rbx,%rcx)
movq -0x18(%rax), %rax
movq %r12, 0x10(%rbx,%rax)
leaq 0x366a(%rip), %rsi      # 0x604f
movl $0x6, %edx
movq %rbx, %rdi
callq 0x21b0
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movl 0x18(%rbx,%rcx), %edx
andl %r15d, %edx
orl $0x20, %edx
movl %edx, 0x18(%rbx,%rcx)
movq -0x18(%rax), %rax
movq %r12, 0x10(%rbx,%rax)
leaq 0x7a59(%rip), %rax      # 0xa470
movl (%rax), %esi
movq %rbx, %rdi
callq 0x2290
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movl 0x18(%rbx,%rcx), %edx
andl %r15d, %edx
orl $0x20, %edx
movl %edx, 0x18(%rbx,%rcx)
movq -0x18(%rax), %rax
movq %r12, 0x10(%rbx,%rax)
leaq 0x35e6(%rip), %rsi      # 0x6056
movl $0x8, %edx
movq %rbx, %rdi
callq 0x21b0
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movl 0x18(%rbx,%rcx), %edx
andl %r15d, %edx
orl $0x20, %edx
movl %edx, 0x18(%rbx,%rcx)
movq -0x18(%rax), %rax
movq %r12, 0x10(%rbx,%rax)
leaq 0x79d2(%rip), %rax      # 0xa474
movl (%rax), %esi
movq %rbx, %rdi
callq 0x2290
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movl 0x18(%rbx,%rcx), %edx
andl %r15d, %edx
orl $0x20, %edx
movl %edx, 0x18(%rbx,%rcx)
movq -0x18(%rax), %rax
movq %r12, 0x10(%rbx,%rax)
leaq 0x3564(%rip), %rsi      # 0x605f
movl $0x9, %edx
movq %rbx, %rdi
callq 0x21b0
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movl 0x18(%rbx,%rcx), %edx
andl %r15d, %edx
orl $0x20, %edx
movl %edx, 0x18(%rbx,%rcx)
movq -0x18(%rax), %rax
movq %r12, 0x10(%rbx,%rax)
leaq 0x794b(%rip), %rax      # 0xa478
movl (%rax), %esi
movq %rbx, %rdi
callq 0x2290
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movl 0x18(%rbx,%rcx), %edx
andl %r15d, %edx
orl $0x20, %edx
movl %edx, 0x18(%rbx,%rcx)
movq -0x18(%rax), %rax
movq %r12, 0x10(%rbx,%rax)
leaq 0x34e3(%rip), %rsi      # 0x6069
movl $0x7, %edx
movq %rbx, %rdi
callq 0x21b0
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movl 0x18(%rbx,%rcx), %edx
andl %r15d, %edx
orl $0x20, %edx
movl %edx, 0x18(%rbx,%rcx)
movq -0x18(%rax), %rax
movq %r12, 0x10(%rbx,%rax)
leaq 0x78c4(%rip), %rax      # 0xa47c
movl (%rax), %esi
movq %rbx, %rdi
callq 0x2290
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movl 0x18(%rbx,%rcx), %edx
andl %r15d, %edx
orl $0x20, %edx
movl %edx, 0x18(%rbx,%rcx)
movq -0x18(%rax), %rax
movq %r12, 0x10(%rbx,%rax)
leaq 0x3460(%rip), %rsi      # 0x6071
movl $0x4, %edx
movq %rbx, %rdi
callq 0x21b0
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movl 0x18(%rbx,%rcx), %edx
andl %r15d, %edx
orl $0x20, %edx
movl %edx, 0x18(%rbx,%rcx)
movq -0x18(%rax), %rax
movq %r12, 0x10(%rbx,%rax)
leaq 0x754d(%rip), %rax      # 0xa190
movl (%rax), %esi
movq %rbx, %rdi
callq 0x2290
movq %rax, %r14
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %r14, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %r14, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
movq (%rbx), %rax
movq -0x18(%rax), %rcx
movl 0x18(%rbx,%rcx), %edx
andl %r15d, %edx
orl $0x20, %edx
movl %edx, 0x18(%rbx,%rcx)
movq -0x18(%rax), %rax
movq %r12, 0x10(%rbx,%rax)
leaq 0x33da(%rip), %rsi      # 0x6076
movl $0x16, %edx
movq %rbx, %rdi
callq 0x21b0
movq (%rbx), %rax
movq -0x18(%rax), %rcx
andl 0x18(%rbx,%rcx), %r15d
orl $0x20, %r15d
movl %r15d, 0x18(%rbx,%rcx)
movq -0x18(%rax), %rax
movq %r12, 0x10(%rbx,%rax)
movl 0x76eb(%rip), %esi      # 0xa3b8
movq %rbx, %rdi
callq 0x2290
movq %rax, %rbx
movq (%rax), %rax
movq -0x18(%rax), %rdi
addq %rbx, %rdi
movl $0xa, %esi
callq 0x2150
movsbl %al, %esi
movq %rbx, %rdi
callq 0x2030
movq %rax, %rdi
callq 0x20e0
leaq -0x29(%rbp), %rdi
callq 0x4726
leaq 0x74a9(%rip), %rdi      # 0xa1b8
callq 0x2200
xorl %eax, %eax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2300
movl $0x1, %eax
jmp 0x2d16
nopl (%rax)