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

    switch (greater.lhs->type) {
    case Type::U0:
        assert(0 && "Type Checking step didn't work correctly. There is no greater operation defined for Type::U0");
    case Type::Bool:
        assert(0 && "Type Checking step didn't work correctly. There is no greater operation defined for Type::Bool");
    case Type::U8:
        return list(atom("i32.gt_u"_sv), compile_expression(greater.lhs), compile_expression(greater.rhs));
    case Type::U32:
        return list(atom("i32.gt_u"_sv), compile_expression(greater.lhs), compile_expression(greater.rhs));
    case Type::U64:
        return list(atom("i64.gt_u"_sv), compile_expression(greater.lhs), compile_expression(greater.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 $0xa0, %rsp
movq %rsi, -0x18(%rbp)
movq %rdx, -0x10(%rbp)
movq %rdi, -0x20(%rbp)
movq -0x20(%rbp), %rax
movq %rax, -0x60(%rbp)
movq -0x18(%rbp), %rax
movl 0x4(%rax), %ecx
movq -0x10(%rbp), %rdx
xorl %eax, %eax
cmpl 0x4(%rdx), %ecx
movb %al, -0x51(%rbp)
jne 0x7e9b
movb $0x1, %al
movb %al, -0x51(%rbp)
jmp 0x7e9b
movb -0x51(%rbp), %al
testb $0x1, %al
jne 0x7ea4
jmp 0x7ea6
jmp 0x7ec5
leaq 0x79a0(%rip), %rdi      # 0xf84d
leaq 0x7004(%rip), %rsi      # 0xeeb8
movl $0x112, %edx            # imm = 0x112
leaq 0x79e3(%rip), %rcx      # 0xf8a3
callq 0x10c0
movq -0x18(%rbp), %rax
movl 0x4(%rax), %eax
movq %rax, -0x68(%rbp)
subq $0x5, %rax
ja 0x8095
movq -0x68(%rbp), %rax
leaq 0x659b(%rip), %rcx      # 0xe480
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0x79df(%rip), %rdi      # 0xf8d4
leaq 0x6fbc(%rip), %rsi      # 0xeeb8
movl $0x116, %edx            # imm = 0x116
leaq 0x799b(%rip), %rcx      # 0xf8a3
callq 0x10c0
leaq 0x7a24(%rip), %rdi      # 0xf938
leaq 0x6f9d(%rip), %rsi      # 0xeeb8
movl $0x118, %edx            # imm = 0x118
leaq 0x797c(%rip), %rcx      # 0xf8a3
callq 0x10c0
leaq 0x7a6b(%rip), %rdi      # 0xf99e
movl $0x8, %esi
callq 0x12e0
movq -0x60(%rbp), %rdi
movq %rax, -0x30(%rbp)
movq %rdx, -0x28(%rbp)
movq -0x30(%rbp), %rsi
movq -0x28(%rbp), %rdx
callq 0xb5c0
movq -0x60(%rbp), %rdi
movq %rax, -0x78(%rbp)
movq -0x18(%rbp), %rsi
callq 0x70d0
movq -0x60(%rbp), %rdi
movq %rax, -0x70(%rbp)
movq -0x10(%rbp), %rsi
callq 0x70d0
movq -0x60(%rbp), %rdi
movq -0x78(%rbp), %rsi
movq -0x70(%rbp), %rdx
movq %rax, %rcx
callq 0xb6d0
movq %rax, -0x8(%rbp)
jmp 0x80b4
leaq 0x7a02(%rip), %rdi      # 0xf99e
movl $0x8, %esi
callq 0x12e0
movq -0x60(%rbp), %rdi
movq %rax, -0x40(%rbp)
movq %rdx, -0x38(%rbp)
movq -0x40(%rbp), %rsi
movq -0x38(%rbp), %rdx
callq 0xb5c0
movq -0x60(%rbp), %rdi
movq %rax, -0x88(%rbp)
movq -0x18(%rbp), %rsi
callq 0x70d0
movq -0x60(%rbp), %rdi
movq %rax, -0x80(%rbp)
movq -0x10(%rbp), %rsi
callq 0x70d0
movq -0x60(%rbp), %rdi
movq -0x88(%rbp), %rsi
movq -0x80(%rbp), %rdx
movq %rax, %rcx
callq 0xb6d0
movq %rax, -0x8(%rbp)
jmp 0x80b4
leaq 0x799c(%rip), %rdi      # 0xf9a7
movl $0x8, %esi
callq 0x12e0
movq -0x60(%rbp), %rdi
movq %rax, -0x50(%rbp)
movq %rdx, -0x48(%rbp)
movq -0x50(%rbp), %rsi
movq -0x48(%rbp), %rdx
callq 0xb5c0
movq -0x60(%rbp), %rdi
movq %rax, -0x98(%rbp)
movq -0x18(%rbp), %rsi
callq 0x70d0
movq -0x60(%rbp), %rdi
movq %rax, -0x90(%rbp)
movq -0x10(%rbp), %rsi
callq 0x70d0
movq -0x60(%rbp), %rdi
movq -0x98(%rbp), %rsi
movq -0x90(%rbp), %rdx
movq %rax, %rcx
callq 0xb6d0
movq %rax, -0x8(%rbp)
jmp 0x80b4
leaq 0x7215(%rip), %rdi      # 0xf292
leaq 0x6e34(%rip), %rsi      # 0xeeb8
movl $0x120, %edx            # imm = 0x120
leaq 0x7813(%rip), %rcx      # 0xf8a3
callq 0x10c0
leaq 0x7083(%rip), %rdi      # 0xf11f
leaq 0x6e15(%rip), %rsi      # 0xeeb8
movl $0x124, %edx            # imm = 0x124
leaq 0x77f4(%rip), %rcx      # 0xf8a3
callq 0x10c0
movq -0x8(%rbp), %rax
addq $0xa0, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)