// File: /workspace/github_cpp_makefile_star2_O1/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)
testb $0x40, 0x63(%rcx,%rax)
je 0x32d4c
movl 0xa4(%r15), %eax
movl %eax, 0xc(%rsp)
movl 0xc(%rbx), %esi
movq %r14, %rdi
callq 0xa426
movq 0x20(%rax), %rcx
movq 0x28(%rax), %rax
cmpq %rax, %rcx
je 0x32ded
subq %rcx, %rax
cmpq $0x4, %rax
jne 0x32ea1
movq 0x8(%r15), %rdx
leaq 0x85fc4(%rip), %rcx     # 0xb8d44
movl $0xb, %r8d
movq %r15, %rdi
xorl %esi, %esi
callq 0x63f0
cmpl $0x0, 0xc(%rsp)
jne 0x32f07
cmpb $0x1, 0x43c(%r14)
jne 0x32e90
cmpl $0x12b, 0x438(%r14) # imm = 0x12B
ja 0x32e90
leaq 0x20(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x85f66(%rip), %rsi     # 0xb8d30
leaq 0x85f72(%rip), %rdx     # 0xb8d43
leaq 0x10(%rsp), %rdi
callq 0x7c64
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x26a0a
jmp 0x32e79
leaq 0x85f2f(%rip), %rsi     # 0xb8d23
leaq 0x8bd3b(%rip), %rcx     # 0xbeb36
leaq 0x10(%rsp), %r12
leaq 0xc(%rsp), %rdx
movq %r12, %rdi
callq 0x52ea7
movq %r15, %rdi
movq %r12, %rsi
callq 0x6310
movq (%r12), %rdi
leaq 0x20(%rsp), %r15
cmpq %r15, %rdi
je 0x32e33
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x6260
cmpb $0x1, 0x43c(%r14)
jne 0x32e90
cmpl $0x12b, 0x438(%r14) # imm = 0x12B
ja 0x32e90
cmpl $0x0, 0xc(%rsp)
je 0x32e90
leaq 0x10(%rsp), %rdi
movq %r15, (%rdi)
leaq 0x85ed0(%rip), %rsi     # 0xb8d30
leaq 0x85edc(%rip), %rdx     # 0xb8d43
callq 0x7c64
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x26a0a
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x32e90
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 0x85eed(%rip), %rsi     # 0xb8dab
leaq 0x85f35(%rip), %rdx     # 0xb8dfa
leaq 0x10(%rsp), %rdi
callq 0x7c64
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x6320
leaq 0xc9eb2(%rip), %rax     # 0xfcd98
addq $0x10, %rax
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0xc9e8a(%rip), %rsi     # 0xfcd80
movq 0xcb0db(%rip), %rdx     # 0xfdfd8
movq %r14, %rdi
callq 0x6470
jmp 0x32f6b
movl $0x10, %edi
callq 0x6140
movq %rax, %r14
leaq 0x20(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x85e2c(%rip), %rsi     # 0xb8d50
leaq 0x85e7f(%rip), %rdx     # 0xb8daa
leaq 0x10(%rsp), %rdi
callq 0x7c64
movb $0x1, %bpl
leaq 0x10(%rsp), %rsi
movq %r14, %rdi
callq 0x6320
leaq 0xc9e4c(%rip), %rax     # 0xfcd98
addq $0x10, %rax
movq %rax, (%r14)
xorl %ebp, %ebp
leaq 0xc9e24(%rip), %rsi     # 0xfcd80
movq 0xcb075(%rip), %rdx     # 0xfdfd8
movq %r14, %rdi
callq 0x6470
jmp 0x32f6f
jmp 0x32f8b
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x32fc3
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x32fc3
movq %rax, %rbx
jmp 0x32fc3
jmp 0x32f94
jmp 0x32fb0
movq %rax, %rbx
movq 0x10(%rsp), %rdi
cmpq %r15, %rdi
je 0x32fb6
movq 0x20(%rsp), %rsi
incq %rsi
callq 0x6260
jmp 0x32fb6
movq %rax, %rbx
movb $0x1, %bpl
testb %bpl, %bpl
je 0x32fc3
movq %r14, %rdi
callq 0x6200
movq %rbx, %rdi
callq 0x64a0
nop