// File: arush15june[P]DFA-CPP/dfa.cpp
// Function: main
int main(int argc, char** argv) {
    
    if(argc < 3) {
        std::cout<<"Invalid Input!"<<std::endl;
        std::cout<<"Usage: "<<std::endl;
        std::cout<<"./dfa <dfa_filename> <input_string>"<<std::endl;
        
        return 1;
    }

    std::string dfa_filename = std::string(argv[1]);
    std::string input_string = std::string(argv[2]);

    std::cout<<"Building DFA from "<<dfa_filename<<std::endl;
    auto dfa = build_dfa_from_file(dfa_filename);

    auto evaluate = dfa.execute(input_string);

    std::cout<<"Input: "<<input_string<<std::endl;
    if(evaluate) {
        std::cout<<"Evaluation: True"<<std::endl;
        return 0;
    }
    else {
        std::cout<<"Evaluation: False"<<std::endl;
        return 1;
    }
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x6eb0, %rsp           # imm = 0x6EB0
movl $0x0, -0x4(%rbp)
movl %edi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
cmpl $0x3, -0x8(%rbp)
jge 0x2bf1
movq 0x844a(%rip), %rdi      # 0xafd0
leaq 0x4497(%rip), %rsi      # 0x7024
callq 0x2180
movq %rax, %rdi
movq 0x8424(%rip), %rsi      # 0xafc0
callq 0x21b0
movq 0x8428(%rip), %rdi      # 0xafd0
leaq 0x4484(%rip), %rsi      # 0x7033
callq 0x2180
movq %rax, %rdi
movq 0x8402(%rip), %rsi      # 0xafc0
callq 0x21b0
movq 0x8406(%rip), %rdi      # 0xafd0
leaq 0x446a(%rip), %rsi      # 0x703b
callq 0x2180
movq %rax, %rdi
movq 0x83e0(%rip), %rsi      # 0xafc0
callq 0x21b0
movl $0x1, -0x4(%rbp)
jmp 0x2ee1
movq -0x10(%rbp), %rax
movq 0x8(%rax), %rax
movq %rax, -0x6e60(%rbp)
leaq -0x31(%rbp), %rdi
movq %rdi, -0x6e58(%rbp)
callq 0x2290
movq -0x6e60(%rbp), %rsi
movq -0x6e58(%rbp), %rdx
leaq -0x30(%rbp), %rdi
callq 0x21f0
jmp 0x2c29
leaq -0x31(%rbp), %rdi
callq 0x21c0
movq -0x10(%rbp), %rax
movq 0x10(%rax), %rax
movq %rax, -0x6e70(%rbp)
leaq -0x69(%rbp), %rdi
movq %rdi, -0x6e68(%rbp)
callq 0x2290
movq -0x6e70(%rbp), %rsi
movq -0x6e68(%rbp), %rdx
leaq -0x68(%rbp), %rdi
callq 0x21f0
jmp 0x2c6a
leaq -0x69(%rbp), %rdi
callq 0x21c0
movq 0x8356(%rip), %rdi      # 0xafd0
leaq 0x43de(%rip), %rsi      # 0x705f
callq 0x2180
movq %rax, -0x6e78(%rbp)
jmp 0x2c8f
movq -0x6e78(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x2170
movq %rax, -0x6e80(%rbp)
jmp 0x2ca8
movq -0x6e80(%rbp), %rdi
movq 0x830a(%rip), %rsi      # 0xafc0
callq 0x21b0
jmp 0x2cbd
leaq -0x6e20(%rbp), %rdi
leaq -0x30(%rbp), %rsi
callq 0x20c0
jmp 0x2ccf
leaq -0x6e00(%rbp), %rdi
leaq -0x6e20(%rbp), %rsi
callq 0x2550
jmp 0x2ce4
leaq -0x6e20(%rbp), %rdi
callq 0x2110
leaq -0x6e48(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x20c0
jmp 0x2d02
leaq -0x6e00(%rbp), %rdi
leaq -0x6e48(%rbp), %rsi
callq 0x3b50
movb %al, -0x6e81(%rbp)
jmp 0x2d1d
leaq -0x6e48(%rbp), %rdi
callq 0x2110
movb -0x6e81(%rbp), %al
andb $0x1, %al
movb %al, -0x6e21(%rbp)
movq 0x8292(%rip), %rdi      # 0xafd0
leaq 0x432d(%rip), %rsi      # 0x7072
callq 0x2180
movq %rax, -0x6e90(%rbp)
jmp 0x2d53
movq -0x6e90(%rbp), %rdi
leaq -0x68(%rbp), %rsi
callq 0x2170
movq %rax, -0x6e98(%rbp)
jmp 0x2d6c
movq -0x6e98(%rbp), %rdi
movq 0x8246(%rip), %rsi      # 0xafc0
callq 0x21b0
jmp 0x2d81
testb $0x1, -0x6e21(%rbp)
je 0x2e5f
movq 0x823b(%rip), %rdi      # 0xafd0
leaq 0x42de(%rip), %rsi      # 0x707a
callq 0x2180
movq %rax, -0x6ea0(%rbp)
jmp 0x2daa
movq -0x6ea0(%rbp), %rdi
movq 0x8208(%rip), %rsi      # 0xafc0
callq 0x21b0
jmp 0x2dbf
movl $0x0, -0x4(%rbp)
movl $0x1, -0x6e4c(%rbp)
jmp 0x2ea1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x31(%rbp), %rdi
callq 0x21c0
jmp 0x2eed
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x69(%rbp), %rdi
callq 0x21c0
jmp 0x2ed6
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2ecd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x6e20(%rbp), %rdi
callq 0x2110
jmp 0x2ecd
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
jmp 0x2ec1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x40(%rbp)
movl %eax, -0x44(%rbp)
leaq -0x6e48(%rbp), %rdi
callq 0x2110
jmp 0x2ec1
movq 0x816a(%rip), %rdi      # 0xafd0
leaq 0x421e(%rip), %rsi      # 0x708b
callq 0x2180
movq %rax, -0x6ea8(%rbp)
jmp 0x2e7b
movq -0x6ea8(%rbp), %rdi
movq 0x8137(%rip), %rsi      # 0xafc0
callq 0x21b0
jmp 0x2e90
movl $0x1, -0x4(%rbp)
movl $0x1, -0x6e4c(%rbp)
leaq -0x6e00(%rbp), %rdi
callq 0x3b30
leaq -0x68(%rbp), %rdi
callq 0x2110
leaq -0x30(%rbp), %rdi
callq 0x2110
jmp 0x2ee1
leaq -0x6e00(%rbp), %rdi
callq 0x3b30
leaq -0x68(%rbp), %rdi
callq 0x2110
leaq -0x30(%rbp), %rdi
callq 0x2110
jmp 0x2eed
movl -0x4(%rbp), %eax
addq $0x6eb0, %rsp           # imm = 0x6EB0
popq %rbp
retq
movq -0x40(%rbp), %rdi
callq 0x2280
nopw %cs:(%rax,%rax)