// File: rossy[P]crossc/SPIRV-Cross/spirv_glsl.cpp
// Function: spirv_cross::CompilerGLSL::emit_binary_op_cast(unsigned int, unsigned int, unsigned int, unsigned int, char const*, spirv_cross::SPIRType::BaseType, bool)
void CompilerGLSL::emit_binary_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);

	// We might have casted away from the result type, so bitcast again.
	// For example, arithmetic right shift with uint inputs.
	// 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(cast_op0, " ", op, " ", cast_op1);
		expr += ')';
	}
	else
		expr += join(cast_op0, " ", op, " ", 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 0x78ef7
movq -0x1f0(%rbp), %rdi
movl -0xc(%rbp), %esi
callq 0xea90
movq %rax, -0x1f8(%rbp)
jmp 0x78f0f
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 0x79085
movq -0x158(%rbp), %rax
cmpl $0x2, 0xc(%rax)
je 0x79085
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 0x78f80
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 0x78fc0
leaq 0xc58d6(%rip), %r8      # 0x13e89d
leaq -0x1b8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0x20(%rbp), %rcx
leaq -0x68(%rbp), %r9
movq %r8, %rdx
callq 0xa2960
jmp 0x78fe4
leaq -0x178(%rbp), %rdi
leaq -0x1b8(%rbp), %rsi
callq 0x7470
jmp 0x78ff9
leaq -0x1b8(%rbp), %rdi
callq 0x7708
leaq -0x178(%rbp), %rdi
movl $0x29, %esi
callq 0x7220
jmp 0x79018
jmp 0x790ef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x148(%rbp)
movl %eax, -0x14c(%rbp)
jmp 0x791f7
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x148(%rbp)
movl %eax, -0x14c(%rbp)
jmp 0x791eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x148(%rbp)
movl %eax, -0x14c(%rbp)
jmp 0x791df
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x148(%rbp)
movl %eax, -0x14c(%rbp)
leaq -0x1b8(%rbp), %rdi
callq 0x7708
jmp 0x791df
leaq 0xc5811(%rip), %r8      # 0x13e89d
leaq -0x1d8(%rbp), %rdi
leaq -0x48(%rbp), %rsi
leaq -0x20(%rbp), %rcx
leaq -0x68(%rbp), %r9
movq %r8, %rdx
callq 0xa2960
jmp 0x790a9
leaq -0x178(%rbp), %rdi
leaq -0x1d8(%rbp), %rsi
callq 0x7470
jmp 0x790be
leaq -0x1d8(%rbp), %rdi
callq 0x7708
jmp 0x790ef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x148(%rbp)
movl %eax, -0x14c(%rbp)
leaq -0x1d8(%rbp), %rdi
callq 0x7708
jmp 0x791df
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 0x79118
movb -0x209(%rbp), %cl
xorl %eax, %eax
testb $0x1, %cl
movb %al, -0x215(%rbp)
jne 0x7912d
jmp 0x79152
movq -0x1f0(%rbp), %rdi
movl -0x18(%rbp), %esi
callq 0x78810
movb %al, -0x216(%rbp)
jmp 0x79144
movb -0x216(%rbp), %al
movb %al, -0x215(%rbp)
jmp 0x79152
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 0x79184
movq -0x1f0(%rbp), %rdi
movl -0x10(%rbp), %esi
movl -0x14(%rbp), %edx
callq 0x25500
jmp 0x79198
movq -0x1f0(%rbp), %rdi
movl -0x10(%rbp), %esi
movl -0x18(%rbp), %edx
callq 0x25500
jmp 0x791ac
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 %cs:(%rax,%rax)