// File: /workspace/github_cpp_makefile_star2_O1/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, -0x50(%rbp)
movaps %xmm0, -0x60(%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 -0x78(%rbp), %rdi
leaq -0x180(%rbp), %rsi
callq 0x2c99
xorps %xmm0, %xmm0
leaq -0xa0(%rbp), %rdi
movaps %xmm0, (%rdi)
movaps -0xe0(%rbp), %xmm0
movq -0xd0(%rbp), %rax
leaq -0x78(%rbp), %rbx
movups (%rbx), %xmm1
movaps %xmm1, -0xe0(%rbp)
movq 0x10(%rbx), %rcx
movq %rcx, -0xd0(%rbp)
movaps (%rdi), %xmm1
movaps %xmm0, (%rdi)
movq %rax, 0x10(%rdi)
movups %xmm1, (%rbx)
movq $0x0, 0x10(%rbx)
callq 0x3faa
movq %rbx, %rdi
callq 0x3faa
leaq -0x78(%rbp), %rdi
leaq -0x160(%rbp), %rsi
callq 0x2c99
leaq -0xa0(%rbp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, (%rdi)
movaps -0xc0(%rbp), %xmm0
movq -0xb0(%rbp), %rax
movups (%rbx), %xmm1
movaps %xmm1, -0xc0(%rbp)
movq 0x10(%rbx), %rcx
movq %rcx, -0xb0(%rbp)
movaps (%rdi), %xmm1
movaps %xmm0, (%rdi)
movq %rax, 0x10(%rdi)
movups %xmm1, (%rbx)
movq $0x0, 0x10(%rbx)
callq 0x3faa
movq %rbx, %rdi
callq 0x3faa
leaq -0x78(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x3029
xorps %xmm0, %xmm0
leaq -0xa0(%rbp), %rdi
movaps %xmm0, (%rdi)
movaps -0x140(%rbp), %xmm0
movq -0x130(%rbp), %rax
movups (%rbx), %xmm1
movaps %xmm1, -0x140(%rbp)
movq 0x10(%rbx), %rcx
movq %rcx, -0x130(%rbp)
movaps (%rdi), %xmm1
movaps %xmm0, (%rdi)
movq %rax, 0x10(%rdi)
movups %xmm1, (%rbx)
movq $0x0, 0x10(%rbx)
callq 0x3faa
movq %rbx, %rdi
callq 0x3faa
leaq -0x78(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x3029
leaq -0xa0(%rbp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, (%rdi)
leaq -0x1a0(%rbp), %rbx
movaps (%rbx), %xmm0
movq 0x10(%rbx), %rax
leaq -0x78(%rbp), %r14
movups (%r14), %xmm1
movaps %xmm1, (%rbx)
movq 0x10(%r14), %rcx
movq %rcx, 0x10(%rbx)
movaps (%rdi), %xmm1
movaps %xmm0, (%rdi)
movq %rax, 0x10(%rdi)
movups %xmm1, (%r14)
movq $0x0, 0x10(%r14)
callq 0x3faa
movq %r14, %rdi
callq 0x3faa
leaq -0x78(%rbp), %rdi
leaq -0x140(%rbp), %rsi
movq %rbx, %rdx
callq 0x30db
xorps %xmm0, %xmm0
leaq -0xa0(%rbp), %rdi
movaps %xmm0, (%rdi)
movaps -0x60(%rbp), %xmm0
movq -0x50(%rbp), %rax
leaq -0x78(%rbp), %rbx
movups (%rbx), %xmm1
movaps %xmm1, -0x60(%rbp)
movq 0x10(%rbx), %rcx
movq %rcx, -0x50(%rbp)
movaps (%rdi), %xmm1
movaps %xmm0, (%rdi)
movq %rax, 0x10(%rdi)
movups %xmm1, (%rbx)
movq $0x0, 0x10(%rbx)
callq 0x3faa
movq %rbx, %rdi
callq 0x3faa
leaq -0x78(%rbp), %rdi
leaq -0xe0(%rbp), %rsi
callq 0x317d
leaq -0xa0(%rbp), %rdi
xorps %xmm0, %xmm0
movaps %xmm0, (%rdi)
movaps -0x120(%rbp), %xmm0
movq -0x110(%rbp), %rax
movups (%rbx), %xmm1
movaps %xmm1, -0x120(%rbp)
movq 0x10(%rbx), %rcx
movq %rcx, -0x110(%rbp)
movaps (%rdi), %xmm1
movaps %xmm0, (%rdi)
movq %rax, 0x10(%rdi)
movups %xmm1, (%rbx)
movq $0x0, 0x10(%rbx)
callq 0x3faa
movq %rbx, %rdi
callq 0x3faa
leaq -0x78(%rbp), %rdi
leaq -0xc0(%rbp), %rsi
callq 0x317d
xorps %xmm0, %xmm0
leaq -0xa0(%rbp), %rdi
movaps %xmm0, (%rdi)
movaps -0x100(%rbp), %xmm0
movq -0xf0(%rbp), %rax
movups (%rbx), %xmm1
movaps %xmm1, -0x100(%rbp)
movq 0x10(%rbx), %rcx
movq %rcx, -0xf0(%rbp)
movaps (%rdi), %xmm1
movaps %xmm0, (%rdi)
movq %rax, 0x10(%rdi)
movups %xmm1, (%rbx)
movq $0x0, 0x10(%rbx)
callq 0x3faa
movq %rbx, %rdi
callq 0x3faa
leaq -0x90(%rbp), %r14
movq %r14, -0x10(%r14)
leaq 0x388e(%rip), %rsi      # 0x6037
leaq 0x3888(%rip), %rdx      # 0x6038
leaq -0xa0(%rbp), %rdi
callq 0x44e2
leaq -0x1d0(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x3ff8
movb $0x0, (%rax)
movq -0xa0(%rbp), %rdi
cmpq %r14, %rdi
je 0x27e3
callq 0x2120
leaq -0xa0(%rbp), %rdi
movq %r14, (%rdi)
leaq 0x39ee(%rip), %rsi      # 0x61e2
leaq 0x39e8(%rip), %rdx      # 0x61e3
callq 0x44e2
leaq -0x1d0(%rbp), %rdi
leaq -0xa0(%rbp), %rsi
callq 0x3ff8
movb $0x1, (%rax)
movq -0xa0(%rbp), %rdi
cmpq %r14, %rdi
je 0x2827
callq 0x2120
movq -0x60(%rbp), %r12
movq -0x58(%rbp), %rax
subq %r12, %rax
je 0x284e
sarq $0x5, %rax
cmpq $0x1, %rax
adcq $0x0, %rax
movl $0x1, %ebx
addl %ebx, %ebx
decq %rax
jne 0x2845
jmp 0x2853
movl $0x1, %ebx
movl -0x178(%rbp), %eax
movl %eax, -0x34(%rbp)
movl -0x158(%rbp), %eax
movl %eax, -0x30(%rbp)
cmpq -0x58(%rbp), %r12
je 0x28a4
movq 0x675e(%rip), %r14      # 0x8fd0
leaq 0x37af(%rip), %r15      # 0x6028
movq (%r12), %rsi
movq 0x8(%r12), %rdx
movq %r14, %rdi
callq 0x2180
movl $0x1, %edx
movq %rax, %rdi
movq %r15, %rsi
callq 0x2180
addq $0x20, %r12
cmpq -0x58(%rbp), %r12
jne 0x2879
movq 0x6725(%rip), %rdi      # 0x8fd0
leaq 0x3788(%rip), %rsi      # 0x603a
movl $0x2, %edx
callq 0x2180
movq -0x180(%rbp), %rsi
movq -0x178(%rbp), %rdx
movq 0x66ff(%rip), %rdi      # 0x8fd0
callq 0x2180
movq %rax, %r14
leaq 0x3759(%rip), %rsi      # 0x6039
movl $0x3, %edx
movq %rax, %rdi
callq 0x2180
movq -0x160(%rbp), %rsi
movq -0x158(%rbp), %rdx
movq %r14, %rdi
callq 0x2180
leaq 0x3806(%rip), %rsi      # 0x6110
movl $0x1, %edx
movq %rax, %rdi
callq 0x2180
movl -0x34(%rbp), %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
movl %ecx, -0x40(%rbp)
movl -0x30(%rbp), %eax
movl %eax, %ecx
shrl $0x1f, %ecx
addl %eax, %ecx
sarl %ecx
movl %ecx, -0x3c(%rbp)
movb $0x1, %al
movl %eax, -0x38(%rbp)
leaq -0x1d0(%rbp), %r14
movq 0x6688(%rip), %r15      # 0x8fd0
leaq 0x36d9(%rip), %r13      # 0x6028
testl %ebx, %ebx
jle 0x2ae2
decl %ebx
movq %r14, %rdi
leaq -0x60(%rbp), %rsi
movl %ebx, %edx
callq 0x3419
leaq -0x120(%rbp), %rdi
movq %r14, %rsi
callq 0x3469
movb %al, -0x2a(%rbp)
leaq -0x100(%rbp), %rdi
movq %r14, %rsi
callq 0x3469
movb %al, -0x29(%rbp)
movq -0x60(%rbp), %r12
cmpq -0x58(%rbp), %r12
je 0x29be
movq %r14, %rdi
movq %r12, %rsi
callq 0x4078
movzbl (%rax), %edi
callq 0x397b
movl $0x1, %edx
movq %r15, %rdi
movq %r13, %rsi
callq 0x2180
addq $0x20, %r12
jmp 0x298f
movl $0x1, %edx
movq %r15, %rdi
leaq 0x3671(%rip), %rsi      # 0x603e
callq 0x2180
cmpl $0x2, -0x34(%rbp)
jl 0x29f1
movl -0x40(%rbp), %r12d
movl $0x1, %edx
movq %r15, %rdi
movq %r13, %rsi
callq 0x2180
decl %r12d
jne 0x29dc
testb $0x1, -0x178(%rbp)
je 0x2a0a
movl $0x1, %edx
movq %r15, %rdi
movq %r13, %rsi
callq 0x2180
movzbl -0x2a(%rbp), %edi
callq 0x397b
cmpl $0x2, -0x34(%rbp)
jl 0x2a32
movl -0x40(%rbp), %r12d
movl $0x1, %edx
movq %r15, %rdi
movq %r13, %rsi
callq 0x2180
decl %r12d
jne 0x2a1d
movl $0x2, %edx
movq %r15, %rdi
leaq 0x35fc(%rip), %rsi      # 0x603d
callq 0x2180
cmpl $0x2, -0x30(%rbp)
jl 0x2a65
movl -0x3c(%rbp), %r12d
movl $0x1, %edx
movq %r15, %rdi
movq %r13, %rsi
callq 0x2180
decl %r12d
jne 0x2a50
testb $0x1, -0x158(%rbp)
je 0x2a7e
movl $0x1, %edx
movq %r15, %rdi
movq %r13, %rsi
callq 0x2180
movzbl -0x29(%rbp), %edi
callq 0x397b
cmpl $0x2, -0x30(%rbp)
jl 0x2aa6
movl -0x3c(%rbp), %r12d
movl $0x1, %edx
movq %r15, %rdi
movq %r13, %rsi
callq 0x2180
decl %r12d
jne 0x2a91
movb -0x29(%rbp), %al
cmpb %al, -0x2a(%rbp)
je 0x2ac9
movl $0x9, %edx
movq %r15, %rdi
leaq 0x3583(%rip), %rsi      # 0x6040
callq 0x2180
movl $0x0, -0x38(%rbp)
movl $0x1, %edx
movq %r15, %rdi
leaq 0x3638(%rip), %rsi      # 0x6110
callq 0x2180
jmp 0x294f
testb $0x1, -0x38(%rbp)
je 0x2af6
movl $0x31, %edx
leaq 0x3556(%rip), %rsi      # 0x604a
jmp 0x2b1a
movq 0x64d3(%rip), %rdi      # 0x8fd0
leaq 0x3578(%rip), %rsi      # 0x607c
movl $0x32, %edx
callq 0x2180
movl $0xa, %edx
leaq 0x3595(%rip), %rsi      # 0x60af
movq 0x64af(%rip), %rdi      # 0x8fd0
callq 0x2180
leaq -0x1d0(%rbp), %rdi
callq 0x42e2
movq -0x160(%rbp), %rdi
leaq -0x150(%rbp), %rax
cmpq %rax, %rdi
je 0x2b4a
callq 0x2120
movq -0x180(%rbp), %rdi
leaq -0x170(%rbp), %rax
cmpq %rax, %rdi
je 0x2b62
callq 0x2120
leaq -0x100(%rbp), %rdi
callq 0x3faa
leaq -0x120(%rbp), %rdi
callq 0x3faa
leaq -0x60(%rbp), %rdi
callq 0x3faa
leaq -0x1a0(%rbp), %rdi
callq 0x3faa
leaq -0x140(%rbp), %rdi
callq 0x3faa
leaq -0xc0(%rbp), %rdi
callq 0x3faa
leaq -0xe0(%rbp), %rdi
callq 0x3faa
xorl %eax, %eax
addq $0x1a8, %rsp            # imm = 0x1A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
jmp 0x2bcb
jmp 0x2c01
movq %rax, %rbx
movq -0xa0(%rbp), %rdi
cmpq %r14, %rdi
je 0x2c04
callq 0x2120
jmp 0x2c04
jmp 0x2c01
jmp 0x2c01
jmp 0x2c01
jmp 0x2c01
jmp 0x2c01
jmp 0x2c01
jmp 0x2c01
jmp 0x2c01
jmp 0x2c01
jmp 0x2c01
jmp 0x2c01
jmp 0x2c01
jmp 0x2c01
jmp 0x2c01
jmp 0x2c01
jmp 0x2c01
movq %rax, %rbx
leaq -0x1d0(%rbp), %rdi
callq 0x42e2
movq -0x160(%rbp), %rdi
leaq -0x150(%rbp), %rax
cmpq %rax, %rdi
je 0x2c28
callq 0x2120
movq -0x180(%rbp), %rdi
leaq -0x170(%rbp), %rax
cmpq %rax, %rdi
je 0x2c40
callq 0x2120
leaq -0x100(%rbp), %rdi
callq 0x3faa
leaq -0x120(%rbp), %rdi
callq 0x3faa
leaq -0x60(%rbp), %rdi
callq 0x3faa
leaq -0x1a0(%rbp), %rdi
callq 0x3faa
leaq -0x140(%rbp), %rdi
callq 0x3faa
leaq -0xc0(%rbp), %rdi
callq 0x3faa
leaq -0xe0(%rbp), %rdi
callq 0x3faa
movq %rbx, %rdi
callq 0x2220