// File: /workspace/github_cpp_makefile_star2_O2/rossy[P]crossc/SPIRV-Cross/spirv_glsl.cpp
// Function: spirv_cross::CompilerGLSL::replace_fragment_output(spirv_cross::SPIRVariable&)
void CompilerGLSL::replace_fragment_output(SPIRVariable &var)
{
	auto &m = ir.meta[var.self].decoration;
	uint32_t location = 0;
	if (m.decoration_flags.get(DecorationLocation))
		location = m.location;

	// If our variable is arrayed, we must not emit the array part of this as the SPIR-V will
	// do the access chain part of this for us.
	auto &type = get<SPIRType>(var.basetype);

	if (type.array.empty())
	{
		// Redirect the write to a specific render target in legacy GLSL.
		m.alias = join("gl_FragData[", location, "]");

		if (is_legacy_es() && location != 0)
			require_extension_internal("GL_EXT_draw_buffers");
	}
	else if (type.array.size() == 1)
	{
		// If location is non-zero, we probably have to add an offset.
		// This gets really tricky since we'd have to inject an offset in the access chain.
		// FIXME: This seems like an extremely odd-ball case, so it's probably fine to leave it like this for now.
		m.alias = "gl_FragData";
		if (location != 0)
			SPIRV_CROSS_THROW("Arrayed output variable used, but location is not 0. "
			                  "This is unimplemented in SPIRV-Cross.");

		if (is_legacy_es())
			require_extension_internal("GL_EXT_draw_buffers");
	}
	else
		SPIRV_CROSS_THROW("Array-of-array output variable used. This cannot be implemented in legacy GLSL.");

	var.compat_builtin = true; // We don't want to declare this variable, but use the name as-is.
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r12
pushq %rbx
subq $0x30, %rsp
movq %rsi, %rbx
movq %rdi, %r14
movl 0x8(%rsi), %eax
movq 0x38(%rdi), %rcx
imulq $0x148, %rax, %rax      # imm = 0x148
andl $0x0, 0xc(%rsp)
leaq (%rcx,%rax), %r15
movb $0x1, %bpl
testb $0x40, 0x63(%rcx,%rax)
je 0x2a6da
movl 0xa4(%r15), %eax
movl %eax, 0xc(%rsp)
testl %eax, %eax
sete %bpl
movl 0xc(%rbx), %esi
movq %r14, %rdi
callq 0x90a4
movq 0x20(%rax), %rcx
movq 0x28(%rax), %rax
cmpq %rax, %rcx
je 0x2a75b
subq %rcx, %rax
cmpq $0x4, %rax
jne 0x2a7ea
leaq 0x6860e(%rip), %rsi     # 0x92d14
movq %r15, %rdi
callq 0x64e0
testb %bpl, %bpl
je 0x2a835
cmpb $0x1, 0x43c(%r14)
jne 0x2a7d9
cmpl $0x12b, 0x438(%r14) # imm = 0x12B
ja 0x2a7d9
leaq 0x685c3(%rip), %rsi     # 0x92d00
leaq 0x10(%rsp), %rdi
leaq 0xb(%rsp), %rdx
callq 0x6100
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x21390
jmp 0x2a7cf
leaq 0x68591(%rip), %rsi     # 0x92cf3
leaq 0x6e365(%rip), %rcx     # 0x98ace
leaq 0x10(%rsp), %r12
leaq 0xc(%rsp), %rdx
movq %r12, %rdi
callq 0x42651
movq %r15, %rdi
movq %r12, %rsi
callq 0x6320
movq %r12, %rdi
callq 0x6548
cmpb $0x1, 0x43c(%r14)
jne 0x2a7d9
cmpl $0x12b, 0x438(%r14) # imm = 0x12B
ja 0x2a7d9
cmpl $0x0, 0xc(%rsp)
je 0x2a7d9
leaq 0x6854d(%rip), %rsi     # 0x92d00
leaq 0x10(%rsp), %rdi
leaq 0xb(%rsp), %rdx
callq 0x6100
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x21390
leaq 0x10(%rsp), %rdi
callq 0x6548
movb $0x1, 0x38(%rbx)
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
pushq $0x10
popq %rdi
callq 0x6140
movq %rax, %r14
leaq 0x6857f(%rip), %rsi     # 0x92d7b
leaq 0x10(%rsp), %rdi
leaq 0xb(%rsp), %rdx
callq 0x6100
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x6f6e
xorl %ebp, %ebp
leaq 0xbc59c(%rip), %rsi     # 0xe6dc0
movq 0xbd7b5(%rip), %rdx     # 0xe7fe0
movq %r14, %rdi
callq 0x6490
jmp 0x2a87e
pushq $0x10
popq %rdi
callq 0x6140
movq %rax, %r14
leaq 0x684d9(%rip), %rsi     # 0x92d20
leaq 0x10(%rsp), %rdi
leaq 0xb(%rsp), %rdx
callq 0x6100
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x6f6e
xorl %ebp, %ebp
leaq 0xbc551(%rip), %rsi     # 0xe6dc0
movq 0xbd76a(%rip), %rdx     # 0xe7fe0
movq %r14, %rdi
callq 0x6490
jmp 0x2a882
jmp 0x2a891
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x6548
jmp 0x2a8b9
movq %rax, %rbx
jmp 0x2a8b9
jmp 0x2a89a
jmp 0x2a8ae
movq %rax, %rbx
leaq 0x10(%rsp), %rdi
callq 0x6548
testb %bpl, %bpl
jne 0x2a8b1
jmp 0x2a8b9
movq %rax, %rbx
movq %r14, %rdi
callq 0x6200
movq %rbx, %rdi
callq 0x64b0
nop