// File: /workspace/github_cpp_makefile_star2_O2/iamlouk[P]asbi/src/ast.cc
// Function: ast::InfixOperator::to_vmops(asbi::Context*, std::vector<asbi::OpCode, std::allocator<asbi::OpCode>>&) const
void InfixOperator::to_vmops(Context* ctx, std::vector<OpCode> &ops) const {
	switch (type) {
	case InfixOperator::Add:
		lhs->to_vmops(ctx, ops);
		rhs->to_vmops(ctx, ops);
		ops.push_back(OpCode::ADD);
		return;
	case InfixOperator::Sub:
		lhs->to_vmops(ctx, ops);
		rhs->to_vmops(ctx, ops);
		ops.push_back(OpCode::SUB);
		return;
	case InfixOperator::Mul:
		lhs->to_vmops(ctx, ops);
		rhs->to_vmops(ctx, ops);
		ops.push_back(OpCode::MUL);
		return;
	case InfixOperator::Div:
		lhs->to_vmops(ctx, ops);
		rhs->to_vmops(ctx, ops);
		ops.push_back(OpCode::DIV);
		return;
	case InfixOperator::Or:{
		// a | b <-> if a { true } else { b }
		lhs->to_vmops(ctx, ops);
		ops.push_back(OpCode::IF_TRUE_GOTO);
		auto pos_iftrue = ops.size();
		ops.push_back(OpCode::NOOP);
		rhs->to_vmops(ctx, ops);
		ops.push_back(OpCode::GOTO);
		auto pos_end = ops.size();
		ops.push_back(OpCode::NOOP);
		*(ops.data() + pos_iftrue) = static_cast<OpCode>(ops.size());
		ops.push_back(OpCode::PUSH_TRUE);
		*(ops.data() + pos_end) = static_cast<OpCode>(ops.size());
		return;
	}
	case InfixOperator::And:{
		// a & b <-> if a { b } else { false }
		lhs->to_vmops(ctx, ops);
		ops.push_back(OpCode::IF_TRUE_GOTO);
		auto pos_iftrue = ops.size();
		ops.push_back(OpCode::NOOP);
		ops.push_back(OpCode::PUSH_FALSE);
		ops.push_back(OpCode::GOTO);
		auto pos_end = ops.size();
		ops.push_back(OpCode::NOOP);
		*(ops.data() + pos_iftrue) = static_cast<OpCode>(ops.size());
		rhs->to_vmops(ctx, ops);
		*(ops.data() + pos_end) = static_cast<OpCode>(ops.size());
		return;
	}
	case InfixOperator::Equals:
		lhs->to_vmops(ctx, ops);
		rhs->to_vmops(ctx, ops);
		ops.push_back(OpCode::EQUALS);
		return;
	case InfixOperator::EqualsNot:
		lhs->to_vmops(ctx, ops);
		rhs->to_vmops(ctx, ops);
		ops.push_back(OpCode::EQUALS_NOT);
		return;
	case InfixOperator::Bigger:
		lhs->to_vmops(ctx, ops);
		rhs->to_vmops(ctx, ops);
		ops.push_back(OpCode::BIGGER);
		return;
	case InfixOperator::BiggerOrEqual:
		lhs->to_vmops(ctx, ops);
		rhs->to_vmops(ctx, ops);
		ops.push_back(OpCode::BIGGER_OR_EQUAL);
		return;
	case InfixOperator::Smaller:
		lhs->to_vmops(ctx, ops);
		rhs->to_vmops(ctx, ops);
		ops.push_back(OpCode::SMALLER);
		return;
	case InfixOperator::SmallerOrEqual:
		lhs->to_vmops(ctx, ops);
		rhs->to_vmops(ctx, ops);
		ops.push_back(OpCode::SMALLER_OR_EQUAL);
		return;
	}
}

// Assembly:
movl 0x8(%rdi), %eax
cmpq $0xb, %rax
ja 0xc75f
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdx, %rbx
movq %rsi, %r14
movq %rdi, %r15
leaq 0x891e(%rip), %rcx      # 0x14d18
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq 0x10(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x18(%rax)
movq 0x18(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x18(%rax)
movq %rsp, %rsi
movq $0x10, (%rsi)
jmp 0xc749
movq 0x10(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x18(%rax)
movq 0x18(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x18(%rax)
movq %rsp, %rsi
movq $0x18, (%rsi)
jmp 0xc749
movq 0x10(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x18(%rax)
movq %rsp, %r12
movq $0x21, (%r12)
movq %rbx, %rdi
movq %r12, %rsi
callq 0xd2e0
movq 0x8(%rbx), %r13
subq (%rbx), %r13
pushq $0x23
popq %rax
movq %rax, (%r12)
movq %rsp, %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0xd2e0
movq $0x3, (%r12)
movq %rsp, %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0xd2e0
movq $0x20, (%r12)
movq %rsp, %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0xd2e0
movq 0x8(%rbx), %rbp
subq (%rbx), %rbp
pushq $0x23
popq %rax
movq %rax, (%r12)
movq %rsp, %rsi
movq %rbx, %rdi
callq 0xd2e0
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movq %rcx, (%rax,%r13)
movq 0x18(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x18(%rax)
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movq %rcx, (%rax,%rbp)
jmp 0xc751
movq 0x10(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x18(%rax)
movq 0x18(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x18(%rax)
movq %rsp, %rsi
movq $0x19, (%rsi)
jmp 0xc749
movq 0x10(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x18(%rax)
movq 0x18(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x18(%rax)
movq %rsp, %rsi
movq $0x12, (%rsi)
jmp 0xc749
movq 0x10(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x18(%rax)
movq 0x18(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x18(%rax)
movq %rsp, %rsi
movq $0x13, (%rsi)
jmp 0xc749
movq 0x10(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x18(%rax)
movq 0x18(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x18(%rax)
movq %rsp, %rsi
movq $0x15, (%rsi)
jmp 0xc749
movq 0x10(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x18(%rax)
movq 0x18(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x18(%rax)
movq %rsp, %rsi
movq $0x11, (%rsi)
jmp 0xc749
movq 0x10(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x18(%rax)
movq %rsp, %r12
movq $0x21, (%r12)
movq %rbx, %rdi
movq %r12, %rsi
callq 0xd2e0
movq 0x8(%rbx), %r13
subq (%rbx), %r13
pushq $0x23
popq %rbp
movq %rbp, (%r12)
movq %rsp, %r12
movq %rbx, %rdi
movq %r12, %rsi
callq 0xd2e0
movq 0x18(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x18(%rax)
movq $0x20, (%r12)
movq %rsp, %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0xd2e0
movq 0x8(%rbx), %r15
subq (%rbx), %r15
movq %rbp, (%r14)
movq %rsp, %r14
movq %rbx, %rdi
movq %r14, %rsi
callq 0xd2e0
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movq %rcx, (%rax,%r13)
movq $0x2, (%r14)
movq %rsp, %rsi
movq %rbx, %rdi
callq 0xd2e0
movq (%rbx), %rax
movq 0x8(%rbx), %rcx
subq %rax, %rcx
sarq $0x3, %rcx
movq %rcx, (%rax,%r15)
jmp 0xc751
movq 0x10(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x18(%rax)
movq 0x18(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x18(%rax)
movq %rsp, %rsi
movq $0x14, (%rsi)
jmp 0xc749
movq 0x10(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x18(%rax)
movq 0x18(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x18(%rax)
movq %rsp, %rsi
movq $0x16, (%rsi)
jmp 0xc749
movq 0x10(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x18(%rax)
movq 0x18(%r15), %rdi
movq (%rdi), %rax
movq %r14, %rsi
movq %rbx, %rdx
callq *0x18(%rax)
movq %rsp, %rsi
movq $0x17, (%rsi)
movq %rbx, %rdi
callq 0xd2e0
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq