// File: tsoding[P]wcc/src/./wcc_wat_compiler.cpp
// Function: Wat_Compiler::compile_and(Binary_Op)
S_Expr *Wat_Compiler::compile_and(Binary_Op andd)
{
    assert(andd.lhs->type == andd.rhs->type && "Type Checking step didn't work correctly.");

    switch (andd.lhs->type) {
    case Type::U0:
        assert(0 && "Type Checking step didn't work correctly. There is no and operation defined for Type::U0");
        break;
    case Type::U8:
        assert(0 && "Type Checking step didn't work correctly. There is no and operation defined for Type::U8");
        break;
    case Type::U32:
        assert(0 && "Type Checking step didn't work correctly. There is no and operation defined for Type::U32");
        break;
    case Type::U64:
        assert(0 && "Type Checking step didn't work correctly. There is no and operation defined for Type::U64");
        break;
    case Type::Bool:
        return list(atom("i32.and"_sv), compile_expression(andd.lhs), compile_expression(andd.rhs));
    case Type::Unchecked:
        assert(0 && "Type checking step didn't work correctly");
        break;
    }

    assert(0 && "Memory corruption?");
    return nullptr;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rsi, -0x10(%rbp)
movq %rdx, -0x8(%rbp)
movq %rdi, -0x18(%rbp)
movq -0x18(%rbp), %rax
movq %rax, -0x38(%rbp)
movq -0x10(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x8(%rbp), %rdx
xorl %eax, %eax
cmpl 0x4(%rdx), %ecx
movb %al, -0x29(%rbp)
jne 0x8108
movb $0x1, %al
movb %al, -0x29(%rbp)
jmp 0x8108
movb -0x29(%rbp), %al
testb $0x1, %al
jne 0x8111
jmp 0x8113
jmp 0x8132
leaq 0x7896(%rip), %rdi      # 0xf9b0
leaq 0x6d97(%rip), %rsi      # 0xeeb8
movl $0x12a, %edx            # imm = 0x12A
leaq 0x78d3(%rip), %rcx      # 0xfa00
callq 0x10c0
movq -0x10(%rbp), %rax
movl 0x4(%rax), %eax
movq %rax, -0x40(%rbp)
subq $0x5, %rax
ja 0x825c
movq -0x40(%rbp), %rax
leaq 0x6346(%rip), %rcx      # 0xe498
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x78cb(%rip), %rdi      # 0xfa2d
leaq 0x6d4f(%rip), %rsi      # 0xeeb8
movl $0x12e, %edx            # imm = 0x12E
leaq 0x788b(%rip), %rcx      # 0xfa00
callq 0x10c0
leaq 0x790c(%rip), %rdi      # 0xfa8d
leaq 0x6d30(%rip), %rsi      # 0xeeb8
movl $0x131, %edx            # imm = 0x131
leaq 0x786c(%rip), %rcx      # 0xfa00
callq 0x10c0
leaq 0x794d(%rip), %rdi      # 0xfaed
leaq 0x6d11(%rip), %rsi      # 0xeeb8
movl $0x134, %edx            # imm = 0x134
leaq 0x784d(%rip), %rcx      # 0xfa00
callq 0x10c0
leaq 0x798f(%rip), %rdi      # 0xfb4e
leaq 0x6cf2(%rip), %rsi      # 0xeeb8
movl $0x137, %edx            # imm = 0x137
leaq 0x782e(%rip), %rcx      # 0xfa00
callq 0x10c0
leaq 0x79d1(%rip), %rdi      # 0xfbaf
movl $0x7, %esi
callq 0x12e0
movq -0x38(%rbp), %rdi
movq %rax, -0x28(%rbp)
movq %rdx, -0x20(%rbp)
movq -0x28(%rbp), %rsi
movq -0x20(%rbp), %rdx
callq 0xb5c0
movq -0x38(%rbp), %rdi
movq %rax, -0x50(%rbp)
movq -0x10(%rbp), %rsi
callq 0x70d0
movq -0x38(%rbp), %rdi
movq %rax, -0x48(%rbp)
movq -0x8(%rbp), %rsi
callq 0x70d0
movq -0x38(%rbp), %rdi
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
movq %rax, %rcx
callq 0xb6d0
addq $0x50, %rsp
popq %rbp
retq
leaq 0x704e(%rip), %rdi      # 0xf292
leaq 0x6c6d(%rip), %rsi      # 0xeeb8
movl $0x13c, %edx            # imm = 0x13C
leaq 0x77a9(%rip), %rcx      # 0xfa00
callq 0x10c0
leaq 0x6ebc(%rip), %rdi      # 0xf11f
leaq 0x6c4e(%rip), %rsi      # 0xeeb8
movl $0x140, %edx            # imm = 0x140
leaq 0x778a(%rip), %rcx      # 0xfa00
callq 0x10c0
nopl (%rax,%rax)