// File: rossy[P]crossc/SPIRV-Cross/spirv_glsl.cpp
// Function: spirv_cross::CompilerGLSL::emit_spv_amd_shader_ballot_op(unsigned int, unsigned int, unsigned int, unsigned int const*, unsigned int)
void CompilerGLSL::emit_spv_amd_shader_ballot_op(uint32_t result_type, uint32_t id, uint32_t eop, const uint32_t *args,
                                                 uint32_t)
{
	require_extension_internal("GL_AMD_shader_ballot");

	enum AMDShaderBallot
	{
		SwizzleInvocationsAMD = 1,
		SwizzleInvocationsMaskedAMD = 2,
		WriteInvocationAMD = 3,
		MbcntAMD = 4
	};

	auto op = static_cast<AMDShaderBallot>(eop);

	switch (op)
	{
	case SwizzleInvocationsAMD:
		emit_binary_func_op(result_type, id, args[0], args[1], "swizzleInvocationsAMD");
		register_control_dependent_expression(id);
		break;

	case SwizzleInvocationsMaskedAMD:
		emit_binary_func_op(result_type, id, args[0], args[1], "swizzleInvocationsMaskedAMD");
		register_control_dependent_expression(id);
		break;

	case WriteInvocationAMD:
		emit_trinary_func_op(result_type, id, args[0], args[1], args[2], "writeInvocationAMD");
		register_control_dependent_expression(id);
		break;

	case MbcntAMD:
		emit_unary_func_op(result_type, id, args[0], "mbcntAMD");
		register_control_dependent_expression(id);
		break;

	default:
		statement("// unimplemented SPV AMD shader ballot op ", eop);
		break;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x80, %rsp
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movl %edx, -0x10(%rbp)
movl %ecx, -0x14(%rbp)
movq %r8, -0x20(%rbp)
movl %r9d, -0x24(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x70(%rbp)
leaq -0x49(%rbp), %rdi
movq %rdi, -0x68(%rbp)
callq 0x7650
movq -0x68(%rbp), %rdx
leaq 0xc358f(%rip), %rsi     # 0x142c8f
leaq -0x48(%rbp), %rdi
callq 0x7520
jmp 0x7f70b
movq -0x70(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x589d0
jmp 0x7f71a
leaq -0x48(%rbp), %rdi
callq 0x7708
leaq -0x49(%rbp), %rdi
callq 0x73d0
movl -0x14(%rbp), %eax
movl %eax, -0x60(%rbp)
movl -0x60(%rbp), %eax
decl %eax
movl %eax, %ecx
movq %rcx, -0x78(%rbp)
subl $0x3, %eax
ja 0x7f85a
movq -0x78(%rbp), %rax
leaq 0xc0f13(%rip), %rcx     # 0x140664
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x7f77d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x7708
leaq -0x49(%rbp), %rdi
callq 0x73d0
jmp 0x7f877
movq -0x70(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movl (%rax), %ecx
movq -0x20(%rbp), %rax
movl 0x4(%rax), %r8d
leaq 0xc34fa(%rip), %r9      # 0x142ca4
callq 0x79330
movq -0x70(%rbp), %rdi
movl -0x10(%rbp), %esi
callq 0x7c5f0
jmp 0x7f86e
movq -0x70(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movl (%rax), %ecx
movq -0x20(%rbp), %rax
movl 0x4(%rax), %r8d
leaq 0xc34db(%rip), %r9      # 0x142cba
callq 0x79330
movq -0x70(%rbp), %rdi
movl -0x10(%rbp), %esi
callq 0x7c5f0
jmp 0x7f86e
movq -0x70(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movl (%rax), %ecx
movq -0x20(%rbp), %rax
movl 0x4(%rax), %r8d
movq -0x20(%rbp), %rax
movl 0x8(%rax), %r9d
leaq 0xc34bd(%rip), %rax     # 0x142cd6
movq %rax, (%rsp)
callq 0x798c0
movq -0x70(%rbp), %rdi
movl -0x10(%rbp), %esi
callq 0x7c5f0
jmp 0x7f86e
movq -0x70(%rbp), %rdi
movl -0xc(%rbp), %esi
movl -0x10(%rbp), %edx
movq -0x20(%rbp), %rax
movl (%rax), %ecx
leaq 0xc34a2(%rip), %r8      # 0x142ce9
callq 0x79220
movq -0x70(%rbp), %rdi
movl -0x10(%rbp), %esi
callq 0x7c5f0
jmp 0x7f86e
movq -0x70(%rbp), %rdi
leaq 0xc348d(%rip), %rsi     # 0x142cf2
leaq -0x14(%rbp), %rdx
callq 0xa3e10
addq $0x80, %rsp
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x7640