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

    switch (plus.lhs->type) {
    case Type::U0:
        assert(0 && "Type Checking step didn't work correctly. There is no plus operation defined for Type::U0");
        break;
    case Type::Bool:
        assert(0 && "Type Checking step didn't work correctly. There is no plus operation defined for Type::Bool");
        break;
    case Type::U8:
    case Type::U32:
        return list(atom("i32.add"_sv), compile_expression(plus.lhs), compile_expression(plus.rhs));
    case Type::U64:
        return list(atom("i64.add"_sv), compile_expression(plus.lhs), compile_expression(plus.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 $0x80, %rsp
movq %rsi, -0x18(%rbp)
movq %rdx, -0x10(%rbp)
movq %rdi, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x50(%rbp)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x10(%rbp), %rdx
xorl %eax, %eax
cmpl 0x4(%rdx), %ecx
movb %al, -0x41(%rbp)
jne 0x77cb
movb $0x1, %al
movb %al, -0x41(%rbp)
jmp 0x77cb
movb -0x41(%rbp), %al
testb $0x1, %al
jne 0x77d4
jmp 0x77d6
jmp 0x77f5
leaq 0x7c4d(%rip), %rdi      # 0xf42a
leaq 0x76d4(%rip), %rsi      # 0xeeb8
movl $0xc7, %edx
leaq 0x7c8a(%rip), %rcx      # 0xf47a
callq 0x10c0
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movq %rax, -0x58(%rbp)
subq $0x5, %rax
ja 0x794a
movq -0x58(%rbp), %rax
leaq 0x6c23(%rip), %rcx      # 0xe438
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x7c83(%rip), %rdi      # 0xf4a8
leaq 0x768c(%rip), %rsi      # 0xeeb8
movl $0xcb, %edx
leaq 0x7c42(%rip), %rcx      # 0xf47a
callq 0x10c0
leaq 0x7cc5(%rip), %rdi      # 0xf509
leaq 0x766d(%rip), %rsi      # 0xeeb8
movl $0xce, %edx
leaq 0x7c23(%rip), %rcx      # 0xf47a
callq 0x10c0
leaq 0x7d09(%rip), %rdi      # 0xf56c
movl $0x7, %esi
callq 0x12e0
movq -0x50(%rbp), %rdi
movq %rax, -0x30(%rbp)
movq %rdx, -0x28(%rbp)
movq -0x30(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0xb5c0
movq -0x50(%rbp), %rdi
movq %rax, -0x68(%rbp)
movq -0x18(%rbp), %rsi
callq 0x70d0
movq -0x50(%rbp), %rdi
movq %rax, -0x60(%rbp)
movq -0x10(%rbp), %rsi
callq 0x70d0
movq -0x50(%rbp), %rdi
movq -0x68(%rbp), %rsi
movq -0x60(%rbp), %rdx
movq %rax, %rcx
callq 0xb6d0
movq %rax, -0x8(%rbp)
jmp 0x7969
leaq 0x7ca8(%rip), %rdi      # 0xf574
movl $0x7, %esi
callq 0x12e0
movq -0x50(%rbp), %rdi
movq %rax, -0x40(%rbp)
movq %rdx, -0x38(%rbp)
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0xb5c0
movq -0x50(%rbp), %rdi
movq %rax, -0x78(%rbp)
movq -0x18(%rbp), %rsi
callq 0x70d0
movq -0x50(%rbp), %rdi
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rsi
callq 0x70d0
movq -0x50(%rbp), %rdi
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
movq %rax, %rcx
callq 0xb6d0
movq %rax, -0x8(%rbp)
jmp 0x7969
leaq 0x7960(%rip), %rdi      # 0xf292
leaq 0x757f(%rip), %rsi      # 0xeeb8
movl $0xd6, %edx
leaq 0x7b35(%rip), %rcx      # 0xf47a
callq 0x10c0
leaq 0x77ce(%rip), %rdi      # 0xf11f
leaq 0x7560(%rip), %rsi      # 0xeeb8
movl $0xda, %edx
leaq 0x7b16(%rip), %rcx      # 0xf47a
callq 0x10c0
movq -0x8(%rbp), %rax
addq $0x80, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)