// File: /workspace/github_cpp_makefile_star2_O1/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 -0x38(%rbp), %rax
movq %rax, -0x10(%rax)
movq $0x0, -0x8(%rax)
movb $0x0, (%rax)
leaq 0x23e3(%rip), %rsi      # 0x6111
movq %rcx, %rdi
callq 0x2060
testl %eax, %eax
je 0x3e08
leaq 0x2303(%rip), %rsi      # 0x6048
movq %r14, %rdi
callq 0x2060
testl %eax, %eax
je 0x3e3f
movq %r15, %rdi
movq %r13, %rsi
callq 0x4168
movb (%rax), %r13b
movq %r15, %rdi
movq %r12, %rsi
callq 0x4168
movb (%rax), %r15b
leaq 0x234c(%rip), %rsi      # 0x60c4
movq %r14, %rdi
callq 0x2060
testl %eax, %eax
je 0x3e84
leaq 0x2333(%rip), %rsi      # 0x60c2
movq %r14, %rdi
callq 0x2060
testl %eax, %eax
je 0x3e9b
leaq 0x2314(%rip), %rsi      # 0x60ba
movq %r14, %rdi
callq 0x2060
testl %eax, %eax
je 0x3f29
leaq 0x2302(%rip), %rsi      # 0x60bf
movq %r14, %rdi
callq 0x2060
testl %eax, %eax
je 0x3f37
leaq 0x22ea(%rip), %rsi      # 0x60be
movq %r14, %rdi
callq 0x2060
testl %eax, %eax
je 0x3f66
movq 0x51e5(%rip), %rdi      # 0x8fd0
leaq 0x23a9(%rip), %rsi      # 0x619b
movl $0x12, %edx
callq 0x2180
leaq 0x2234(%rip), %rsi      # 0x6037
jmp 0x3f7b
movq %r15, %rdi
movq %r13, %rsi
callq 0x4168
movb (%rax), %al
leaq 0x10(%rbx), %rcx
movq %rcx, (%rbx)
cmpb $0x1, %al
jne 0x3e65
leaq 0x23bb(%rip), %rsi      # 0x61e2
leaq 0x23b5(%rip), %rdx      # 0x61e3
movq %rbx, %rdi
leaq -0x38(%rbp), %r14
callq 0x44e2
jmp 0x3f09
movq %r15, %rdi
movq %r13, %rsi
callq 0x4168
movq -0x40(%rbp), %rdx
leaq 0x21e2(%rip), %rsi      # 0x6037
leaq 0x2386(%rip), %rcx      # 0x61e2
cmpb $0x0, (%rax)
cmovneq %rsi, %rcx
jmp 0x3eb8
leaq 0x21cb(%rip), %rsi      # 0x6037
leaq 0x21c5(%rip), %rdx      # 0x6038
movq %rbx, %rdi
leaq -0x38(%rbp), %r14
callq 0x44e2
jmp 0x3f09
movq -0x40(%rbp), %rdx
leaq 0x2353(%rip), %rax      # 0x61e2
leaq 0x21a1(%rip), %rcx      # 0x6037
testb %r15b, %r13b
jmp 0x3eb4
orb %r15b, %r13b
movq -0x40(%rbp), %rdx
leaq 0x2339(%rip), %rax      # 0x61e2
leaq 0x2187(%rip), %rcx      # 0x6037
testb $0x1, %r13b
cmovneq %rax, %rcx
leaq -0x48(%rbp), %rdi
movl $0x1, %r8d
xorl %esi, %esi
callq 0x21e0
leaq 0x10(%rbx), %rax
movq %rax, (%rbx)
movq -0x48(%rbp), %rcx
leaq -0x38(%rbp), %r14
cmpq %r14, %rcx
je 0x3eea
movq %rcx, (%rbx)
movq -0x38(%rbp), %rax
movq %rax, 0x10(%rbx)
jmp 0x3ef1
movups (%r14), %xmm0
movups %xmm0, (%rax)
movq -0x40(%rbp), %rax
movq %rax, 0x8(%rbx)
movq %r14, -0x48(%rbp)
movq $0x0, -0x40(%rbp)
movb $0x0, -0x38(%rbp)
movq -0x48(%rbp), %rdi
cmpq %r14, %rdi
je 0x3f17
callq 0x2120
movq %rbx, %rax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
cmpb %r15b, %r13b
je 0x3f56
leaq 0x22ad(%rip), %rsi      # 0x61e2
jmp 0x3f7b
leaq 0x22a4(%rip), %rax      # 0x61e2
leaq 0x20f2(%rip), %rsi      # 0x6037
testb $0x1, %r15b
cmovneq %rax, %rsi
testb %r13b, %r13b
cmoveq %rax, %rsi
jmp 0x3f7b
leaq 0x20da(%rip), %rcx      # 0x6037
movq -0x40(%rbp), %rdx
jmp 0x3eb8
xorb %r15b, %r13b
leaq 0x20c7(%rip), %rax      # 0x6037
leaq 0x226b(%rip), %rsi      # 0x61e2
cmovneq %rax, %rsi
leaq -0x48(%rbp), %rdi
callq 0x21a0
jmp 0x3ec9
jmp 0x3f8d
jmp 0x3f8d
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x3fa2
callq 0x2120
movq %rbx, %rdi
callq 0x2220