// File: /workspace/github_cpp_makefile_star2_O3/mbottini[P]CS250lab2/main.cpp
// Function: main
int main() {
    stringVector tokenVector1, tokenVector2;
    stringVector variableVector1, variableVector2;
    stringVector variableVectorUnion;
    stringVector RPNVector1, RPNVector2;
    string inputString1, inputString2;
    boolMap bmap;
    bool result1, result2;

    std::cout << "Premise: ";
    getline(std::cin, inputString1);
    std::cout << "Conclusion: ";
    getline(std::cin, inputString2);

    tokenVector1 = getTokens(inputString1);
    tokenVector2 = getTokens(inputString2);

    variableVector1 = getVariables(tokenVector1);
    variableVector2 = getVariables(tokenVector2);
    variableVectorUnion = combineVectors(variableVector1, variableVector2);

    RPNVector1 = convertRPN(tokenVector1);
    RPNVector2 = convertRPN(tokenVector2);
    
    bool validConclusion = true;

    // Set initial values of bmap. "c" and "t" never change. ComboGen
    // is initially set to make every variable "true."
    bmap["c"] = false;
    bmap["t"] = true;

    int comboGen = 1;

    for(int i = 0; i < variableVectorUnion.size(); i++) {
        comboGen *= 2;
    }

    comboGen--;

    // Print out the top part of the output table.

    int colWidth1 = inputString1.length();
    int colWidth2 = inputString2.length();

    for(stringIter i = variableVectorUnion.begin(); i !=
            variableVectorUnion.end(); ++i) {
        std::cout << *i << " ";
    }
    std::cout << "| ";

    std::cout << inputString1 << " | " << inputString2 << "\n";

    // Print the truth table values.
    while(comboGen >= 0) {
        setValues(bmap, variableVectorUnion, comboGen);

        result1 = evalRPN(RPNVector1, bmap);
        result2 = evalRPN(RPNVector2, bmap);

        for(stringIter i = variableVectorUnion.begin();
                i != variableVectorUnion.end(); ++i) {
            printBool(bmap.at(*i)); 
            std::cout << " ";
        }

        std::cout << "|";
        printSpaces(colWidth1 / 2);

        if(inputString1.length() % 2 == 1) {
            std::cout << " ";
        }

        printBool(result1);
        printSpaces(colWidth1 / 2);

        std::cout << " |";
        printSpaces(colWidth2 / 2); 

        if(inputString2.length() % 2 == 1) {
            std::cout << " ";
        }

        printBool(result2);
        printSpaces(colWidth2 / 2);

        if(result1 != result2) {
            std::cout << " Invalid!";
            validConclusion = false;
        }

        std::cout << "\n";
        comboGen--;
    }

    if(validConclusion) {
        std::cout << "Valid statement. All truth table values line up.\n";
    }

    else {
        std::cout << "Invalid statement. Invalid truth table values are "
                  << "labelled.\n";
    }

    return 0;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1a8, %rsp            # imm = 0x1A8
xorps %xmm0, %xmm0
movaps %xmm0, -0xe0(%rbp)
xorl %eax, %eax
movq %rax, -0xd0(%rbp)
movq %rax, -0xb0(%rbp)
movaps %xmm0, -0xc0(%rbp)
movq %rax, -0x130(%rbp)
movaps %xmm0, -0x140(%rbp)
movq %rax, -0x190(%rbp)
movaps %xmm0, -0x1a0(%rbp)
movq %rax, -0x40(%rbp)
movaps %xmm0, -0x50(%rbp)
movq %rax, -0x110(%rbp)
movaps %xmm0, -0x120(%rbp)
movq %rax, -0xf0(%rbp)
movaps %xmm0, -0x100(%rbp)
leaq -0x170(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0x150(%rbp), %rcx
movq %rcx, -0x10(%rcx)
movq %rax, -0x8(%rcx)
movb %al, (%rcx)
leaq -0x1c8(%rbp), %rcx
movl $0x0, (%rcx)
movq %rax, 0x8(%rcx)
movq %rcx, 0x10(%rcx)
movq %rcx, 0x18(%rcx)
movq %rax, 0x20(%rcx)
movq 0x6b69(%rip), %rdi      # 0x8fd0
leaq 0x3bb2(%rip), %rsi      # 0x6020
movl $0x9, %edx
callq 0x2180
movq 0x6b61(%rip), %rdi      # 0x8fe0
movq (%rdi), %rax
addq -0x18(%rax), %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %edx
movq 0x6b46(%rip), %rbx      # 0x8fe0
leaq -0x180(%rbp), %rsi
movq %rbx, %rdi
callq 0x2240
movq 0x6b20(%rip), %rdi      # 0x8fd0
leaq 0x3b73(%rip), %rsi      # 0x602a
movl $0xc, %edx
callq 0x2180
movq (%rbx), %rax
addq -0x18(%rax), %rbx
movq %rbx, %rdi
movl $0xa, %esi
callq 0x2130
movsbl %al, %edx
movq 0x6b01(%rip), %rdi      # 0x8fe0
leaq -0x160(%rbp), %rsi
callq 0x2240
leaq -0x80(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0x2d08
movaps -0xe0(%rbp), %xmm0
movq -0xd0(%rbp), %rax
leaq -0x80(%rbp), %rbx
movaps (%rbx), %xmm1
movaps %xmm1, -0xe0(%rbp)
movq 0x10(%rbx), %rcx
movq %rcx, -0xd0(%rbp)
leaq -0xa0(%rbp), %rdi
movups %xmm0, (%rdi)
movq %rax, 0x10(%rdi)
xorps %xmm0, %xmm0
movaps %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
callq 0x3f82
movq %rbx, %rdi
callq 0x3f82
leaq -0x80(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0x2d08
movaps -0xc0(%rbp), %xmm0
movq -0xb0(%rbp), %rax
movaps (%rbx), %xmm1
movaps %xmm1, -0xc0(%rbp)
movq 0x10(%rbx), %rcx
movq %rcx, -0xb0(%rbp)
leaq -0xa0(%rbp), %rdi
movups %xmm0, (%rdi)
movq %rax, 0x10(%rdi)
xorps %xmm0, %xmm0
movaps %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
callq 0x3f82
movq %rbx, %rdi
callq 0x3f82
leaq -0x80(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x3048
movaps -0x140(%rbp), %xmm0
movq -0x130(%rbp), %rax
movaps (%rbx), %xmm1
movaps %xmm1, -0x140(%rbp)
movq 0x10(%rbx), %rcx
movq %rcx, -0x130(%rbp)
leaq -0xa0(%rbp), %rdi
movups %xmm0, (%rdi)
movq %rax, 0x10(%rdi)
xorps %xmm0, %xmm0
movaps %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
callq 0x3f82
movq %rbx, %rdi
callq 0x3f82
leaq -0x80(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x3048
leaq -0x1a0(%rbp), %rbx
movaps (%rbx), %xmm0
movq 0x10(%rbx), %rax
leaq -0x80(%rbp), %r14
movaps (%r14), %xmm1
movaps %xmm1, (%rbx)
movq 0x10(%r14), %rcx
movq %rcx, 0x10(%rbx)
leaq -0xa0(%rbp), %rdi
movups %xmm0, (%rdi)
movq %rax, 0x10(%rdi)
xorps %xmm0, %xmm0
movaps %xmm0, (%r14)
movq $0x0, 0x10(%r14)
callq 0x3f82
movq %r14, %rdi
callq 0x3f82
leaq -0x80(%rbp), %rdi
leaq -0x140(%rbp), %rsi
movq %rbx, %rdx
callq 0x30fa
movaps -0x50(%rbp), %xmm0
movq -0x40(%rbp), %rax
leaq -0x80(%rbp), %rbx
movaps (%rbx), %xmm1
movaps %xmm1, -0x50(%rbp)
movq 0x10(%rbx), %rcx
movq %rcx, -0x40(%rbp)
leaq -0xa0(%rbp), %rdi
movups %xmm0, (%rdi)
movq %rax, 0x10(%rdi)
xorps %xmm0, %xmm0
movaps %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
callq 0x3f82
movq %rbx, %rdi
callq 0x3f82
leaq -0x80(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x319c
movaps -0x120(%rbp), %xmm0
movq -0x110(%rbp), %rax
movaps (%rbx), %xmm1
movaps %xmm1, -0x120(%rbp)
movq 0x10(%rbx), %rcx
movq %rcx, -0x110(%rbp)
leaq -0xa0(%rbp), %rdi
movups %xmm0, (%rdi)
movq %rax, 0x10(%rdi)
xorps %xmm0, %xmm0
movaps %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
callq 0x3f82
movq %rbx, %rdi
callq 0x3f82
leaq -0x80(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x319c
movaps -0x100(%rbp), %xmm0
movq -0xf0(%rbp), %rax
movaps (%rbx), %xmm1
movaps %xmm1, -0x100(%rbp)
movq 0x10(%rbx), %rcx
movq %rcx, -0xf0(%rbp)
leaq -0xa0(%rbp), %rdi
movups %xmm0, (%rdi)
movq %rax, 0x10(%rdi)
xorps %xmm0, %xmm0
movaps %xmm0, (%rbx)
movq $0x0, 0x10(%rbx)
callq 0x3f82
movq %rbx, %rdi
callq 0x3f82
leaq -0x90(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x38b8(%rip), %rsi      # 0x6037
leaq 0x38b2(%rip), %rdx      # 0x6038
leaq -0xa0(%rbp), %rdi
callq 0x44d6
leaq -0x1d0(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x3fda
movb $0x0, (%rax)
movq -0xa0(%rbp), %rdi
cmpq %r14, %rdi
je 0x27b9
callq 0x2120
leaq -0xa0(%rbp), %rdi
movq %r14, (%rdi)
leaq 0x3a18(%rip), %rsi      # 0x61e2
leaq 0x3a12(%rip), %rdx      # 0x61e3
callq 0x44d6
leaq -0x1d0(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x3fda
movb $0x1, (%rax)
movq -0xa0(%rbp), %rdi
cmpq %r14, %rdi
je 0x27fd
callq 0x2120
movq -0x50(%rbp), %r15
movq -0x48(%rbp), %rax
movq %rax, %rcx
subq %r15, %rcx
je 0x287b
sarq $0x5, %rcx
cmpq $0x1, %rcx
adcq $0x0, %rcx
movl $0x1, %r13d
addl %r13d, %r13d
decq %rcx
jne 0x281f
movq -0x178(%rbp), %rcx
movq %rcx, -0x60(%rbp)
movq -0x158(%rbp), %rcx
movq %rcx, -0x58(%rbp)
cmpq %r15, %rax
je 0x2897
movq 0x6787(%rip), %rbx      # 0x8fd0
leaq 0x37d8(%rip), %r14      # 0x6028
movq (%r15), %rsi
movq 0x8(%r15), %rdx
movq %rbx, %rdi
callq 0x2180
movl $0x1, %edx
movq %rax, %rdi
movq %r14, %rsi
callq 0x2180
addq $0x20, %r15
cmpq -0x48(%rbp), %r15
jne 0x2850
jmp 0x2897
movq -0x178(%rbp), %rax
movq %rax, -0x60(%rbp)
movl $0x1, %r13d
movq -0x158(%rbp), %rax
movq %rax, -0x58(%rbp)
movq 0x6732(%rip), %rdi      # 0x8fd0
leaq 0x3795(%rip), %rsi      # 0x603a
movl $0x2, %edx
callq 0x2180
movq -0x180(%rbp), %rsi
movq -0x178(%rbp), %rdx
movq 0x670c(%rip), %rdi      # 0x8fd0
callq 0x2180
movq %rax, %rbx
leaq 0x3766(%rip), %rsi      # 0x6039
movl $0x3, %edx
movq %rax, %rdi
callq 0x2180
movq -0x160(%rbp), %rsi
movq -0x158(%rbp), %rdx
movq %rbx, %rdi
callq 0x2180
leaq 0x3813(%rip), %rsi      # 0x6110
movl $0x1, %edx
movq %rax, %rdi
callq 0x2180
movq -0x60(%rbp), %rax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
movl %ecx, -0x38(%rbp)
movq -0x58(%rbp), %rax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
movl %ecx, -0x34(%rbp)
movb $0x1, %al
movl %eax, -0x30(%rbp)
movq 0x669a(%rip), %r12      # 0x8fd0
leaq 0x36eb(%rip), %rbx      # 0x6028
testl %r13d, %r13d
jle 0x2b4f
decl %r13d
movl %r13d, %r14d
movq -0x50(%rbp), %r15
cmpq -0x48(%rbp), %r15
je 0x297c
xorl %r13d, %r13d
leaq -0x1d0(%rbp), %rdi
movq %r15, %rsi
callq 0x41a8
btl %r13d, %r14d
setb (%rax)
incl %r13d
addq $0x20, %r15
cmpq -0x48(%rbp), %r15
jne 0x2959
leaq -0x120(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x3488
movl %r14d, %r13d
movl %eax, %r14d
leaq -0x100(%rbp), %rdi
leaq -0x1d0(%rbp), %rsi
callq 0x3488
movb %al, -0x29(%rbp)
movq -0x50(%rbp), %r15
cmpq -0x48(%rbp), %r15
je 0x29fa
leaq -0x1d0(%rbp), %rdi
movq %r15, %rsi
callq 0x405a
cmpb $0x0, (%rax)
leaq 0x37e0(%rip), %rsi      # 0x61ae
jne 0x29d7
leaq 0x37d9(%rip), %rsi      # 0x61b0
movl $0x1, %edx
movq %r12, %rdi
callq 0x2180
movl $0x1, %edx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2180
addq $0x20, %r15
jmp 0x29af
movl $0x1, %edx
movq %r12, %rdi
leaq 0x3635(%rip), %rsi      # 0x603e
callq 0x2180
cmpl $0x2, -0x60(%rbp)
jl 0x2a2d
movl -0x38(%rbp), %r15d
movl $0x1, %edx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2180
decl %r15d
jne 0x2a18
testb $0x1, -0x178(%rbp)
je 0x2a46
movl $0x1, %edx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2180
testb %r14b, %r14b
leaq 0x3760(%rip), %rsi      # 0x61b0
leaq 0x3757(%rip), %rax      # 0x61ae
cmovneq %rax, %rsi
movl $0x1, %edx
movq %r12, %rdi
callq 0x2180
cmpl $0x2, -0x60(%rbp)
jl 0x2a87
movl -0x38(%rbp), %r15d
movl $0x1, %edx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2180
decl %r15d
jne 0x2a72
movl $0x2, %edx
movq %r12, %rdi
leaq 0x35a7(%rip), %rsi      # 0x603d
callq 0x2180
cmpl $0x2, -0x58(%rbp)
jl 0x2aba
movl -0x34(%rbp), %r15d
movl $0x1, %edx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2180
decl %r15d
jne 0x2aa5
testb $0x1, -0x158(%rbp)
je 0x2ad3
movl $0x1, %edx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2180
cmpb $0x0, -0x29(%rbp)
leaq 0x36d2(%rip), %rsi      # 0x61b0
leaq 0x36c9(%rip), %rax      # 0x61ae
cmovneq %rax, %rsi
movl $0x1, %edx
movq %r12, %rdi
callq 0x2180
cmpl $0x2, -0x58(%rbp)
jl 0x2b15
movl -0x34(%rbp), %r15d
movl $0x1, %edx
movq %r12, %rdi
movq %rbx, %rsi
callq 0x2180
decl %r15d
jne 0x2b00
cmpb -0x29(%rbp), %r14b
je 0x2b36
movl $0x9, %edx
movq %r12, %rdi
leaq 0x3516(%rip), %rsi      # 0x6040
callq 0x2180
movl $0x0, -0x30(%rbp)
movl $0x1, %edx
movq %r12, %rdi
leaq 0x35cb(%rip), %rsi      # 0x6110
callq 0x2180
jmp 0x293d
testb $0x1, -0x30(%rbp)
je 0x2b63
movl $0x31, %edx
leaq 0x34e9(%rip), %rsi      # 0x604a
jmp 0x2b87
movq 0x6466(%rip), %rdi      # 0x8fd0
leaq 0x350b(%rip), %rsi      # 0x607c
movl $0x32, %edx
callq 0x2180
movl $0xa, %edx
leaq 0x3528(%rip), %rsi      # 0x60af
movq 0x6442(%rip), %rdi      # 0x8fd0
callq 0x2180
leaq -0x1d0(%rbp), %rdi
callq 0x42c4
movq -0x160(%rbp), %rdi
leaq -0x150(%rbp), %rax
cmpq %rax, %rdi
je 0x2bb7
callq 0x2120
movq -0x180(%rbp), %rdi
leaq -0x170(%rbp), %rax
cmpq %rax, %rdi
je 0x2bcf
callq 0x2120
leaq -0x100(%rbp), %rdi
callq 0x3f82
leaq -0x120(%rbp), %rdi
callq 0x3f82
leaq -0x50(%rbp), %rdi
callq 0x3f82
leaq -0x1a0(%rbp), %rdi
callq 0x3f82
leaq -0x140(%rbp), %rdi
callq 0x3f82
leaq -0xc0(%rbp), %rdi
callq 0x3f82
leaq -0xe0(%rbp), %rdi
callq 0x3f82
xorl %eax, %eax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2c38
jmp 0x2c70
movq %rax, %rbx
movq -0xa0(%rbp), %rdi
cmpq %r14, %rdi
je 0x2c73
callq 0x2120
jmp 0x2c73
jmp 0x2c70
jmp 0x2c70
jmp 0x2c70
jmp 0x2c70
jmp 0x2c70
jmp 0x2c70
jmp 0x2c70
jmp 0x2c70
jmp 0x2c70
jmp 0x2c70
jmp 0x2c70
jmp 0x2c70
jmp 0x2c70
jmp 0x2c70
jmp 0x2c70
jmp 0x2c70
jmp 0x2c70
movq %rax, %rbx
leaq -0x1d0(%rbp), %rdi
callq 0x42c4
movq -0x160(%rbp), %rdi
leaq -0x150(%rbp), %rax
cmpq %rax, %rdi
je 0x2c97
callq 0x2120
movq -0x180(%rbp), %rdi
leaq -0x170(%rbp), %rax
cmpq %rax, %rdi
je 0x2caf
callq 0x2120
leaq -0x100(%rbp), %rdi
callq 0x3f82
leaq -0x120(%rbp), %rdi
callq 0x3f82
leaq -0x50(%rbp), %rdi
callq 0x3f82
leaq -0x1a0(%rbp), %rdi
callq 0x3f82
leaq -0x140(%rbp), %rdi
callq 0x3f82
leaq -0xc0(%rbp), %rdi
callq 0x3f82
leaq -0xe0(%rbp), %rdi
callq 0x3f82
movq %rbx, %rdi
callq 0x2220