// File: BlinfoldKing[P]lisval/src/lib/evaluator.cpp
// Function: Evaluator::and_()
pair<Token*, function<Token*(Token*)>> Evaluator::and_() {
    Token* op = new BinaryOperator(BinaryOperatorType::AND);
    Token* var1 = new Variable("L");
    Token* var2 = new Variable("R");
    List* signature = new List();
    signature->list.push_back(op);
    signature->list.push_back(var1);
    signature->list.push_back(var2);
    Token* token = signature;
    auto res = make_pair(token, [this](Token* input) {
            List* list = static_cast<List*>(input);

            Token* a_token = this->eval(list->list[1]);
            Token* b_token = this->eval(list->list[2]);

            if (a_token->type != TokenType::BOOLEAN) {
                Token* t = new Error("expect a boolean, got: " + a_token->debug(), input);
                return t;
            }

            if (b_token->type != TokenType::BOOLEAN) {
                Token* t = new Error("expect a boolean, got: " + b_token->debug(), input);
                return t;
            }

            Boolean* a = static_cast<Boolean*>(a_token);
            Boolean* b = static_cast<Boolean*>(b_token);

            Token* res = new Boolean(a->value && b->value);
            return res;
    });

    return res;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0xd0(%rbp)
movq %rdi, %rax
movq %rax, -0xc8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xc0(%rbp)
movl $0x8, %edi
callq 0x32b0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xb8(%rbp)
movl $0x5, %esi
callq 0x11920
jmp 0x7172
movq -0xb8(%rbp), %rax
movq %rax, -0x18(%rbp)
movl $0x28, %edi
callq 0x32b0
movq %rax, -0xe0(%rbp)
movb $0x1, -0x52(%rbp)
leaq -0x51(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x34a0
movq -0xd8(%rbp), %rdx
leaq 0x1c1d7(%rip), %rsi     # 0x23387
leaq -0x50(%rbp), %rdi
callq 0x33b0
jmp 0x71bb
movq -0xe0(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x11830
jmp 0x71cd
movb $0x0, -0x52(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x31c0
leaq -0x51(%rbp), %rdi
callq 0x3300
movq -0xe0(%rbp), %rax
movq %rax, -0x30(%rbp)
movl $0x28, %edi
callq 0x32b0
movq %rax, -0xf0(%rbp)
movb $0x1, -0x82(%rbp)
leaq -0x81(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x34a0
movq -0xe8(%rbp), %rdx
leaq 0x1c399(%rip), %rsi     # 0x235c0
leaq -0x80(%rbp), %rdi
callq 0x33b0
jmp 0x7232
movq -0xf0(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x11830
jmp 0x7244
movb $0x0, -0x82(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x31c0
leaq -0x81(%rbp), %rdi
callq 0x3300
movq -0xf0(%rbp), %rax
movq %rax, -0x60(%rbp)
movl $0x20, %edi
callq 0x32b0
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0xf8(%rbp)
callq 0x11870
jmp 0x7289
movq -0xf8(%rbp), %rax
movq %rax, -0x90(%rbp)
movq -0x90(%rbp), %rdi
addq $0x8, %rdi
leaq -0x18(%rbp), %rsi
callq 0x118b0
movq -0x90(%rbp), %rdi
addq $0x8, %rdi
leaq -0x30(%rbp), %rsi
callq 0x118b0
movq -0x90(%rbp), %rdi
addq $0x8, %rdi
leaq -0x60(%rbp), %rsi
callq 0x118b0
movq -0xc0(%rbp), %rax
movq -0x90(%rbp), %rcx
movq %rcx, -0x98(%rbp)
movq %rax, -0xb0(%rbp)
leaq -0x98(%rbp), %rdi
leaq -0xb0(%rbp), %rsi
callq 0x7410
movq -0xd0(%rbp), %rdi
movq %rax, -0xa8(%rbp)
movq %rdx, -0xa0(%rbp)
leaq -0xa8(%rbp), %rsi
callq 0x7440
movq -0xc8(%rbp), %rax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
movq -0xb8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x8, %esi
callq 0x32c0
jmp 0x7406
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x7378
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x31c0
leaq -0x51(%rbp), %rdi
callq 0x3300
testb $0x1, -0x52(%rbp)
jne 0x7389
jmp 0x739a
movq -0xe0(%rbp), %rdi
movl $0x28, %esi
callq 0x32c0
jmp 0x7406
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
jmp 0x73bf
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x31c0
leaq -0x81(%rbp), %rdi
callq 0x3300
testb $0x1, -0x82(%rbp)
jne 0x73d6
jmp 0x73e7
movq -0xf0(%rbp), %rdi
movl $0x28, %esi
callq 0x32c0
jmp 0x7406
movq -0xf8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x20(%rbp)
movl %eax, -0x24(%rbp)
movl $0x20, %esi
callq 0x32c0
movq -0x20(%rbp), %rdi
callq 0x3490
nop