// File: /workspace/github_cpp_makefile_star2_O1/BlinfoldKing[P]lisval/src/lib/evaluator.cpp
// Function: compareList(List*, List*)
bool compareList(List* input, List* signature) {
    if (input->list.size() != signature->list.size()) {
        return false;
    }

    for (size_t i = 0; i < input->list.size(); i++) {
        if (input->list[i]->type != signature->list[i]->type) {
            if (signature->list[i]->type != TokenType::VARIABLE) {
               return false;
            }

            continue;
        } else {
            if (input->list[i]->type == TokenType::NUMBER) {
                Number* inp = static_cast<Number*>(input->list[i]);
                Number* sig = static_cast<Number*>(signature->list[i]);

                if (inp->value != sig->value) {
                    return false;
                }
            }

            if (input->list[i]->type == TokenType::BOOLEAN) {
                Boolean* inp = static_cast<Boolean*>(input->list[i]);
                Boolean* sig = static_cast<Boolean*>(signature->list[i]);

                if (inp->value != sig->value) {
                    return false;
                }
            }

            if (input->list[i]->type == TokenType::ATOM) {
                Atom* inp = static_cast<Atom*>(input->list[i]);
                Atom* sig = static_cast<Atom*>(signature->list[i]);

                if (inp->str != sig->str) {
                    return false;
                }
            }

            if (input->list[i]->type == TokenType::LIST) {
                List* inp = static_cast<List*>(input->list[i]);
                List* sig = static_cast<List*>(signature->list[i]);

                if (!compareList(inp, sig)) {
                    return false;
                }
            }

            if (input->list[i]->type == TokenType::UNARY_OPERATOR) {
                UnaryOperator* inp = static_cast<UnaryOperator*>(input->list[i]);
                UnaryOperator* sig = static_cast<UnaryOperator*>(signature->list[i]);

                if (inp->operator_type != sig->operator_type) {
                    return false;
                }
            }

            if (input->list[i]->type == TokenType::BINARY_OPERATOR) {
                BinaryOperator* inp = static_cast<BinaryOperator*>(input->list[i]);
                BinaryOperator* sig = static_cast<BinaryOperator*>(signature->list[i]);

                if (inp->operator_type != sig->operator_type) {
                    return false;
                }
            }
        }
    }


    return true;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x28, %rsp
movq 0x8(%rdi), %r8
movq 0x10(%rdi), %rax
movq %rax, %rdi
subq %r8, %rdi
movq 0x8(%rsi), %r9
movq 0x10(%rsi), %rcx
subq %r9, %rcx
cmpq %rcx, %rdi
jne 0x7142
cmpq %r8, %rax
sete %bl
je 0x7144
sarq $0x3, %rdi
xorl %esi, %esi
cmpq $0x1, %rdi
sbbq %rdi, %rsi
movl $0x1, %r12d
leaq 0x807a(%rip), %r10      # 0xf058
movq %r8, -0x48(%rbp)
movq %rdi, -0x40(%rbp)
movq %r9, -0x38(%rbp)
movq %rsi, -0x30(%rbp)
movq -0x8(%r8,%r12,8), %r14
movl (%r14), %r13d
movq -0x8(%r9,%r12,8), %r15
movl (%r15), %eax
cmpl %eax, %r13d
jne 0x7077
cmpl $0x7, %r13d
ja 0x7126
movl %r13d, %eax
movslq (%r10,%rax,4), %rcx
addq %r10, %rcx
jmpq *%rcx
movq 0x10(%r14), %rdx
cmpq 0x10(%r15), %rdx
jne 0x7144
testq %rdx, %rdx
je 0x7058
movq 0x8(%r15), %rsi
movq 0x8(%r14), %rdi
callq 0x31d0
leaq 0x8018(%rip), %r10      # 0xf058
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %r9
movq -0x40(%rbp), %rdi
movq -0x48(%rbp), %r8
testl %eax, %eax
jne 0x7144
cmpl $0x5, %r13d
je 0x711c
cmpl $0x4, %r13d
je 0x710c
cmpl $0x1, %r13d
je 0x70da
jmp 0x7126
cmpl $0x3, %eax
je 0x7126
jmp 0x7144
movss 0x4(%r14), %xmm0
ucomiss 0x4(%r15), %xmm0
jne 0x7144
jp 0x7144
cmpl $0x7, %r13d
ja 0x7126
leaq 0x7fcb(%rip), %rdx      # 0xf078
movslq (%rdx,%rax,4), %rcx
addq %rdx, %rcx
jmpq *%rcx
movb 0x4(%r14), %cl
cmpb 0x4(%r15), %cl
jne 0x7144
cmpl $0x5, %r13d
ja 0x7126
leaq 0x7fc7(%rip), %rcx      # 0xf098
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %r14, %rdi
movq %r15, %rsi
callq 0x6f85
testb %al, %al
je 0x7144
cmpl $0x5, %r13d
movq -0x48(%rbp), %r8
movq -0x40(%rbp), %rdi
movq -0x38(%rbp), %r9
movq -0x30(%rbp), %rsi
leaq 0x7f54(%rip), %r10      # 0xf058
je 0x711c
cmpl $0x4, %r13d
jne 0x7126
movl 0x4(%r14), %eax
cmpl 0x4(%r15), %eax
jne 0x7144
cmpl $0x5, %r13d
jne 0x7126
movl 0x4(%r14), %eax
cmpl 0x4(%r15), %eax
jne 0x7144
cmpq %rdi, %r12
setae %bl
leaq (%rsi,%r12), %rax
incq %rax
incq %r12
cmpq $0x1, %rax
jne 0x6fee
jmp 0x7144
xorl %ebx, %ebx
andb $0x1, %bl
movl %ebx, %eax
addq $0x28, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq