// File: /workspace/github_cpp_makefile_star2_O2/mbottini[P]CS250lab2/main.cpp
// Function: evalExpression(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, std::map<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, bool, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>, std::allocator<std::pair<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const, bool>>> const&)
string evalExpression(const string& arg1, const string& arg2,
                           const string& op, const boolMap& bmap) {
    bool bArg1, bArg2;
    std::string result;

    if(op == "") {
        bArg1 = bmap.at(arg1);
        if(bArg1) {
            return "t";
        }

        else {
            return "c";
        }
    }

    else if(op == "!") {
        bArg1 = bmap.at(arg1);
        if(bArg1) {
            result = "c";
        }

        else {
            result = "t";
        }
    }

    else {
        bArg1 = bmap.at(arg1);
        bArg2 = bmap.at(arg2);

        // Logical AND.
        if(op == "^") {
            if(bArg1 && bArg2) {
                result = "t";
            }

            else {
                result = "c";
            }
        }

        // Logical OR.
        else if(op == "v") {
            if(bArg1 || bArg2) {
                result = "t";
            }

            else {
                result = "c";
            }
        }

        // Logical XOR.
        else if(op == "XOR") {
            if((bArg1 || bArg2) && !(bArg1 && bArg2)) {
                result = "t";
            }

            else {
                result = "c";
            }
        }

        // Implies operator.
        else if(op == "->") {
            if(!bArg1 || bArg2) {
                result = "t";
            }

            else {
                result = "c";
            }
        }

        // If and only if operator.
        else if(op == "<->") {
            if((bArg1 && bArg2) || (!bArg1 && !bArg2)) {
                result = "t";
            }

            else {
                result = "c";
            }
        }

        else {
            std::cout << "Invalid operator!\n";
            result = "c";
        }
    }

    // std::cout << result << "\n";
    return result;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq %r8, %r15
movq %rcx, %r14
movq %rdx, %r12
movq %rsi, %r13
movq %rdi, %rbx
leaq -0x40(%rbp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x2a96(%rip), %rsi      # 0x60f5
movq %rcx, %rdi
callq 0x3955
testb %al, %al
je 0x3697
movq %r15, %rdi
movq %r13, %rsi
callq 0x39fe
cmpb $0x1, (%rax)
jne 0x3711
leaq 0x2b16(%rip), %rsi      # 0x619c
leaq -0x29(%rbp), %rdx
movq %rbx, %rdi
callq 0x2090
jmp 0x37c0
leaq 0x298e(%rip), %rsi      # 0x602c
movq %r14, %rdi
callq 0x3955
testb %al, %al
je 0x36cf
movq %r15, %rdi
movq %r13, %rsi
callq 0x39fe
leaq 0x295f(%rip), %rcx      # 0x601b
leaq 0x2ad9(%rip), %rsi      # 0x619c
cmpb $0x0, (%rax)
cmovneq %rcx, %rsi
jmp 0x377b
movq %r15, %rdi
movq %r13, %rsi
callq 0x39fe
movb (%rax), %r13b
movq %r15, %rdi
movq %r12, %rsi
callq 0x39fe
movb (%rax), %r15b
leaq 0x29b6(%rip), %rsi      # 0x60a8
movq %r14, %rdi
callq 0x3955
testb %al, %al
je 0x3729
leaq 0x2a97(%rip), %rax      # 0x619c
leaq 0x290f(%rip), %rsi      # 0x601b
testb %r15b, %r13b
jmp 0x3777
leaq 0x2903(%rip), %rsi      # 0x601b
leaq -0x29(%rbp), %rdx
movq %rbx, %rdi
callq 0x2090
jmp 0x37c0
leaq 0x2976(%rip), %rsi      # 0x60a6
movq %r14, %rdi
callq 0x3955
testb %al, %al
je 0x3753
orb %r15b, %r13b
leaq 0x2a56(%rip), %rax      # 0x619c
leaq 0x28ce(%rip), %rsi      # 0x601b
testb $0x1, %r13b
jmp 0x3777
leaq 0x2944(%rip), %rsi      # 0x609e
movq %r14, %rdi
callq 0x3955
testb %al, %al
je 0x37db
xorb %r15b, %r13b
leaq 0x2a2c(%rip), %rax      # 0x619c
leaq 0x28a4(%rip), %rsi      # 0x601b
cmovneq %rax, %rsi
leaq -0x50(%rbp), %rdi
callq 0x2250
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movq -0x50(%rbp), %rcx
leaq -0x40(%rbp), %rdx
cmpq %rdx, %rcx
je 0x37a5
movq %rcx, (%rbx)
movq -0x40(%rbp), %rax
movq %rax, 0x10(%rbx)
jmp 0x37ab
movups (%rdx), %xmm0
movups %xmm0, (%rax)
movq -0x48(%rbp), %rax
movq %rax, 0x8(%rbx)
movq %rdx, -0x50(%rbp)
andq $0x0, -0x48(%rbp)
movb $0x0, -0x40(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x20c0
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x28c1(%rip), %rsi      # 0x60a3
movq %r14, %rdi
callq 0x3955
testb %al, %al
je 0x3810
leaq 0x29a7(%rip), %rax      # 0x619c
leaq 0x281f(%rip), %rsi      # 0x601b
testb $0x1, %r15b
cmovneq %rax, %rsi
testb %r13b, %r13b
cmoveq %rax, %rsi
jmp 0x377b
leaq 0x288b(%rip), %rsi      # 0x60a2
movq %r14, %rdi
callq 0x3955
testb %al, %al
je 0x3839
xorb %r15b, %r13b
leaq 0x27ee(%rip), %rax      # 0x601b
leaq 0x2968(%rip), %rsi      # 0x619c
jmp 0x3777
movq 0x5790(%rip), %rdi      # 0x8fd0
leaq 0x2938(%rip), %rsi      # 0x617f
callq 0x2160
leaq 0x27c8(%rip), %rsi      # 0x601b
jmp 0x377b
jmp 0x385c
jmp 0x385c
movq %rax, %rbx
leaq -0x50(%rbp), %rdi
callq 0x20c0
movq %rbx, %rdi
callq 0x2240