// File: rossy[P]crossc/SPIRV-Cross/spirv_glsl.cpp
// Function: spirv_cross::CompilerGLSL::emit_binary_func_op_cast(unsigned int, unsigned int, unsigned int, unsigned int, char const*, spirv_cross::SPIRType::BaseType, bool)
void CompilerGLSL::emit_binary_func_op_cast(uint32_t result_type, uint32_t result_id, uint32_t op0, uint32_t op1,
                                            const char *op, SPIRType::BaseType input_type, bool skip_cast_if_equal_type)
{
	string cast_op0, cast_op1;
	auto expected_type = binary_op_bitcast_helper(cast_op0, cast_op1, input_type, op0, op1, skip_cast_if_equal_type);
	auto &out_type = get<SPIRType>(result_type);

	// Special case boolean outputs since relational opcodes output booleans instead of int/uint.
	string expr;
	if (out_type.basetype != input_type && out_type.basetype != SPIRType::Boolean)
	{
		expected_type.basetype = input_type;
		expr = bitcast_glsl_op(out_type, expected_type);
		expr += '(';
		expr += join(op, "(", cast_op0, ", ", cast_op1, ")");
		expr += ')';
	}
	else
	{
		expr += join(op, "(", cast_op0, ", ", cast_op1, ")");
	}

	emit_op(result_type, result_id, expr, should_forward(op0) && should_forward(op1));
	inherit_expression_dependencies(result_id, op0);
	inherit_expression_dependencies(result_id, op1);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x230, %rsp            # imm = 0x230
movb 0x18(%rbp), %al
movl 0x10(%rbp), %r10d
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movl %r8d, -0x18(%rbp)
movq %r9, -0x20(%rbp)
andb $0x1, %al
movb %al, -0x21(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x1f0(%rbp)
leaq -0x48(%rbp), %rdi
movq %rdi, -0x1e8(%rbp)
callq 0x7530
leaq -0x68(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0x7530
movq -0x1f0(%rbp), %rsi
movq -0x1e8(%rbp), %rdx
movq -0x1e0(%rbp), %rcx
movl -0x14(%rbp), %r9d
movl -0x18(%rbp), %edi
movzbl -0x21(%rbp), %r8d
andl $0x1, %r8d
movq %rsp, %rax
movl %r8d, 0x8(%rax)
movl %edi, (%rax)
leaq -0x140(%rbp), %rdi
leaq 0x10(%rbp), %r8
callq 0x747a0
jmp 0x79577
movq -0x1f0(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xea90
movq %rax, -0x1f8(%rbp)
jmp 0x7958f
movq -0x1f8(%rbp), %rax
movq %rax, -0x158(%rbp)
leaq -0x178(%rbp), %rdi
callq 0x7530
movq -0x158(%rbp), %rax
movl 0xc(%rax), %eax
cmpl 0x10(%rbp), %eax
je 0x79716
movq -0x158(%rbp), %rax
cmpl $0x2, 0xc(%rax)
je 0x79716
movq -0x1f0(%rbp), %rsi
movl 0x10(%rbp), %eax
movl %eax, -0x134(%rbp)
movq -0x158(%rbp), %rdx
movq (%rsi), %rax
movq 0x168(%rax), %rax
leaq -0x198(%rbp), %rdi
leaq -0x140(%rbp), %rcx
callq *%rax
jmp 0x79600
leaq -0x178(%rbp), %rdi
movq %rdi, -0x200(%rbp)
leaq -0x198(%rbp), %rsi
movq %rsi, -0x208(%rbp)
callq 0x7430
movq -0x208(%rbp), %rdi
callq 0x7708
movq -0x200(%rbp), %rdi
movl $0x28, %esi
callq 0x7220
jmp 0x79640
leaq 0xcb8b2(%rip), %rcx     # 0x144ef9
movq %rsp, %rax
movq %rcx, (%rax)
leaq 0xd3cd9(%rip), %rdx     # 0x14d32d
leaq 0xcaf34(%rip), %r8      # 0x14458f
leaq -0x1b8(%rbp), %rdi
leaq -0x20(%rbp), %rsi
leaq -0x48(%rbp), %rcx
leaq -0x68(%rbp), %r9
callq 0xa2bd0
jmp 0x79675
leaq -0x178(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x7470
jmp 0x7968a
leaq -0x1b8(%rbp), %rdi
callq 0x7708
leaq -0x178(%rbp), %rdi
movl $0x29, %esi
callq 0x7220
jmp 0x796a9
jmp 0x79791
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x148(%rbp)
movl %eax, -0x14c(%rbp)
jmp 0x79899
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x148(%rbp)
movl %eax, -0x14c(%rbp)
jmp 0x7988d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x148(%rbp)
movl %eax, -0x14c(%rbp)
jmp 0x79881
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x148(%rbp)
movl %eax, -0x14c(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0x7708
jmp 0x79881
leaq 0xcb7dc(%rip), %rcx     # 0x144ef9
movq %rsp, %rax
movq %rcx, (%rax)
leaq 0xd3c03(%rip), %rdx     # 0x14d32d
leaq 0xcae5e(%rip), %r8      # 0x14458f
leaq -0x1d8(%rbp), %rdi
leaq -0x20(%rbp), %rsi
leaq -0x48(%rbp), %rcx
leaq -0x68(%rbp), %r9
callq 0xa2bd0
jmp 0x7974b
leaq -0x178(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x7470
jmp 0x79760
leaq -0x1d8(%rbp), %rdi
callq 0x7708
jmp 0x79791
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x148(%rbp)
movl %eax, -0x14c(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x7708
jmp 0x79881
movq -0x1f0(%rbp), %rdi
movl -0xc(%rbp), %eax
movl %eax, -0x214(%rbp)
movl -0x10(%rbp), %eax
movl %eax, -0x210(%rbp)
movl -0x14(%rbp), %esi
callq 0x78810
movb %al, -0x209(%rbp)
jmp 0x797ba
movb -0x209(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x215(%rbp)
jne 0x797cf
jmp 0x797f4
movq -0x1f0(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x78810
movb %al, -0x216(%rbp)
jmp 0x797e6
movb -0x216(%rbp), %al
movb %al, -0x215(%rbp)
jmp 0x797f4
movl -0x210(%rbp), %edx
movl -0x214(%rbp), %esi
movq -0x1f0(%rbp), %rdi
movb -0x215(%rbp), %al
movzbl %al, %r8d
andl $0x1, %r8d
leaq -0x178(%rbp), %rcx
xorl %r9d, %r9d
callq 0x784f0
jmp 0x79826
movq -0x1f0(%rbp), %rdi
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
callq 0x25500
jmp 0x7983a
movq -0x1f0(%rbp), %rdi
movl -0x10(%rbp), %esi
movl -0x18(%rbp), %edx
callq 0x25500
jmp 0x7984e
leaq -0x178(%rbp), %rdi
callq 0x7708
leaq -0x140(%rbp), %rdi
callq 0x314e0
leaq -0x68(%rbp), %rdi
callq 0x7708
leaq -0x48(%rbp), %rdi
callq 0x7708
addq $0x230, %rsp            # imm = 0x230
popq %rbp
retq
leaq -0x178(%rbp), %rdi
callq 0x7708
leaq -0x140(%rbp), %rdi
callq 0x314e0
leaq -0x68(%rbp), %rdi
callq 0x7708
leaq -0x48(%rbp), %rdi
callq 0x7708
movq -0x148(%rbp), %rdi
callq 0x7640
nopw (%rax,%rax)