// File: /workspace/github_cpp_makefile_star2_O3/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
leaq (%rcx,%rax), %r15
movl $0x0, 0xc(%rsp)
movb $0x1, %bpl
testb $0x40, 0x63(%rcx,%rax)
je 0x326a7
movl 0xa4(%r15), %eax
movl %eax, 0xc(%rsp)
testl %eax, %eax
sete %bpl
movl 0xc(%rbx), %esi
movq %r14, %rdi
callq 0xa3ea
movq 0x20(%rax), %rcx
movq 0x28(%rax), %rax
cmpq %rax, %rcx
je 0x32746
subq %rcx, %rax
cmpq $0x4, %rax
jne 0x327fa
movq 0x8(%r15), %rdx
leaq 0x85659(%rip), %rcx     # 0xb7d34
movl $0xb, %r8d
movq %r15, %rdi
xorl %esi, %esi
callq 0x63f0
testb %bpl, %bpl
je 0x32860
cmpb $0x1, 0x43c(%r14)
jne 0x327e9
cmpl $0x12b, 0x438(%r14) # imm = 0x12B
ja 0x327e9
leaq 0x20(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x855fd(%rip), %rsi     # 0xb7d20
leaq 0x85609(%rip), %rdx     # 0xb7d33
leaq 0x10(%rsp), %rdi
callq 0x7be0
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x26356
jmp 0x327d2
leaq 0x855c6(%rip), %rsi     # 0xb7d13
leaq 0x8b3ea(%rip), %rcx     # 0xbdb3e
leaq 0x10(%rsp), %r12
leaq 0xc(%rsp), %rdx
movq %r12, %rdi
callq 0x526af
movq %r15, %rdi
movq %r12, %rsi
callq 0x6310
movq (%r12), %rdi
leaq 0x20(%rsp), %r15
cmpq %r15, %rdi
je 0x3278c
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x6260
cmpb $0x1, 0x43c(%r14)
jne 0x327e9
cmpl $0x12b, 0x438(%r14) # imm = 0x12B
ja 0x327e9
cmpl $0x0, 0xc(%rsp)
je 0x327e9
leaq 0x10(%rsp), %rdi
movq %r15, (%rdi)
leaq 0x85567(%rip), %rsi     # 0xb7d20
leaq 0x85573(%rip), %rdx     # 0xb7d33
callq 0x7be0
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x26356
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x327e9
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x6260
movb $0x1, 0x38(%rbx)
addq $0x30, %rsp
popq %rbx
popq %r12
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x6140
movq %rax, %r14
leaq 0x20(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x85584(%rip), %rsi     # 0xb7d9b
leaq 0x855cc(%rip), %rdx     # 0xb7dea
leaq 0x10(%rsp), %rdi
callq 0x7be0
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x6320
leaq 0xc9589(%rip), %rax     # 0xfbdc8
addq $0x10, %rax
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0xc9561(%rip), %rsi     # 0xfbdb0
movq 0xca782(%rip), %rdx     # 0xfcfd8
movq %r14, %rdi
callq 0x6470
jmp 0x328c4
movl $0x10, %edi
callq 0x6140
movq %rax, %r14
leaq 0x20(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x854c3(%rip), %rsi     # 0xb7d40
leaq 0x85516(%rip), %rdx     # 0xb7d9a
leaq 0x10(%rsp), %rdi
callq 0x7be0
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x6320
leaq 0xc9523(%rip), %rax     # 0xfbdc8
addq $0x10, %rax
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0xc94fb(%rip), %rsi     # 0xfbdb0
movq 0xca71c(%rip), %rdx     # 0xfcfd8
movq %r14, %rdi
callq 0x6470
jmp 0x328c8
jmp 0x328e4
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x32919
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x32919
movq %rax, %rbx
jmp 0x32919
jmp 0x328ed
jmp 0x3290e
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x32907
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x6260
testb %bpl, %bpl
jne 0x32911
jmp 0x32919
movq %rax, %rbx
movq %r14, %rdi
callq 0x6200
movq %rbx, %rdi
callq 0x64a0
nop