// File: /workspace/github_cpp_makefile_star2_O3/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 0x240b(%rip), %rsi      # 0x6111
movq %rcx, %rdi
callq 0x2060
testl %eax, %eax
je 0x3de0
leaq 0x232b(%rip), %rsi      # 0x6048
movq %r14, %rdi
callq 0x2060
testl %eax, %eax
je 0x3e17
movq %r15, %rdi
movq %r13, %rsi
callq 0x414a
movb (%rax), %r13b
movq %r15, %rdi
movq %r12, %rsi
callq 0x414a
movb (%rax), %r15b
leaq 0x2374(%rip), %rsi      # 0x60c4
movq %r14, %rdi
callq 0x2060
testl %eax, %eax
je 0x3e5c
leaq 0x235b(%rip), %rsi      # 0x60c2
movq %r14, %rdi
callq 0x2060
testl %eax, %eax
je 0x3e73
leaq 0x233c(%rip), %rsi      # 0x60ba
movq %r14, %rdi
callq 0x2060
testl %eax, %eax
je 0x3f01
leaq 0x232a(%rip), %rsi      # 0x60bf
movq %r14, %rdi
callq 0x2060
testl %eax, %eax
je 0x3f0f
leaq 0x2312(%rip), %rsi      # 0x60be
movq %r14, %rdi
callq 0x2060
testl %eax, %eax
je 0x3f3e
movq 0x520d(%rip), %rdi      # 0x8fd0
leaq 0x23d1(%rip), %rsi      # 0x619b
movl $0x12, %edx
callq 0x2180
leaq 0x225c(%rip), %rsi      # 0x6037
jmp 0x3f53
movq %r15, %rdi
movq %r13, %rsi
callq 0x414a
movb (%rax), %al
leaq 0x10(%rbx), %rcx
movq %rcx, (%rbx)
cmpb $0x1, %al
jne 0x3e3d
leaq 0x23e3(%rip), %rsi      # 0x61e2
leaq 0x23dd(%rip), %rdx      # 0x61e3
movq %rbx, %rdi
leaq -0x38(%rbp), %r14
callq 0x44d6
jmp 0x3ee1
movq %r15, %rdi
movq %r13, %rsi
callq 0x414a
movq -0x40(%rbp), %rdx
leaq 0x220a(%rip), %rsi      # 0x6037
leaq 0x23ae(%rip), %rcx      # 0x61e2
cmpb $0x0, (%rax)
cmovneq %rsi, %rcx
jmp 0x3e90
leaq 0x21f3(%rip), %rsi      # 0x6037
leaq 0x21ed(%rip), %rdx      # 0x6038
movq %rbx, %rdi
leaq -0x38(%rbp), %r14
callq 0x44d6
jmp 0x3ee1
movq -0x40(%rbp), %rdx
leaq 0x237b(%rip), %rax      # 0x61e2
leaq 0x21c9(%rip), %rcx      # 0x6037
testb %r15b, %r13b
jmp 0x3e8c
orb %r15b, %r13b
movq -0x40(%rbp), %rdx
leaq 0x2361(%rip), %rax      # 0x61e2
leaq 0x21af(%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 0x3ec2
movq %rcx, (%rbx)
movq -0x38(%rbp), %rax
movq %rax, 0x10(%rbx)
jmp 0x3ec9
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 0x3eef
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 0x3f2e
leaq 0x22d5(%rip), %rsi      # 0x61e2
jmp 0x3f53
leaq 0x22cc(%rip), %rax      # 0x61e2
leaq 0x211a(%rip), %rsi      # 0x6037
testb $0x1, %r15b
cmovneq %rax, %rsi
testb %r13b, %r13b
cmoveq %rax, %rsi
jmp 0x3f53
leaq 0x2102(%rip), %rcx      # 0x6037
movq -0x40(%rbp), %rdx
jmp 0x3e90
xorb %r15b, %r13b
leaq 0x20ef(%rip), %rax      # 0x6037
leaq 0x2293(%rip), %rsi      # 0x61e2
cmovneq %rax, %rsi
leaq -0x48(%rbp), %rdi
callq 0x21a0
jmp 0x3ea1
jmp 0x3f65
jmp 0x3f65
movq %rax, %rbx
movq -0x48(%rbp), %rdi
leaq -0x38(%rbp), %rax
cmpq %rax, %rdi
je 0x3f7a
callq 0x2120
movq %rbx, %rdi
callq 0x2220