// File: rossy[P]crossc/SPIRV-Cross/spirv_cross.cpp
// Function: spirv_cross::Compiler::ActiveBuiltinHandler::handle_builtin(spirv_cross::SPIRType const&, spv::BuiltIn, spirv_cross::Bitset const&)
void Compiler::ActiveBuiltinHandler::handle_builtin(const SPIRType &type, BuiltIn builtin,
                                                    const Bitset &decoration_flags)
{
	// If used, we will need to explicitly declare a new array size for these builtins.

	if (builtin == BuiltInClipDistance)
	{
		if (!type.array_size_literal[0])
			SPIRV_CROSS_THROW("Array size for ClipDistance must be a literal.");
		uint32_t array_size = type.array[0];
		if (array_size == 0)
			SPIRV_CROSS_THROW("Array size for ClipDistance must not be unsized.");
		compiler.clip_distance_count = array_size;
	}
	else if (builtin == BuiltInCullDistance)
	{
		if (!type.array_size_literal[0])
			SPIRV_CROSS_THROW("Array size for CullDistance must be a literal.");
		uint32_t array_size = type.array[0];
		if (array_size == 0)
			SPIRV_CROSS_THROW("Array size for CullDistance must not be unsized.");
		compiler.cull_distance_count = array_size;
	}
	else if (builtin == BuiltInPosition)
	{
		if (decoration_flags.get(DecorationInvariant))
			compiler.position_invariant = true;
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x120, %rsp            # imm = 0x120
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movq %rcx, -0x20(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0xe0(%rbp)
cmpl $0x3, -0x14(%rbp)
jne 0x2aa30
movq -0x10(%rbp), %rdi
addq $0x38, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x118c0
testb $0x1, %al
jne 0x2a930
movb $0x1, -0x55(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0xf0(%rbp)
leaq -0x41(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x7650
movq -0xe8(%rbp), %rdx
leaq 0x115040(%rip), %rsi    # 0x13f8eb
leaq -0x40(%rbp), %rdi
callq 0x7520
jmp 0x2a8b6
movq -0xf0(%rbp), %rdi
leaq -0x40(%rbp), %rsi
callq 0x9c50
jmp 0x2a8c8
movq -0xf0(%rbp), %rdi
movb $0x0, -0x55(%rbp)
leaq 0x1834fe(%rip), %rsi    # 0x1addd8
leaq -0x20c51(%rip), %rdx    # 0x9c90
callq 0x7610
jmp 0x2ac73
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x2a90e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x40(%rbp), %rdi
callq 0x7708
leaq -0x41(%rbp), %rdi
callq 0x73d0
testb $0x1, -0x55(%rbp)
jne 0x2a91f
jmp 0x2a92b
movq -0xf0(%rbp), %rdi
callq 0x72c0
jmp 0x2ac6a
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x8570
movl (%rax), %eax
movl %eax, -0x5c(%rbp)
cmpl $0x0, -0x5c(%rbp)
jne 0x2aa17
movb $0x1, -0x82(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0x100(%rbp)
leaq -0x81(%rbp), %rdi
movq %rdi, -0xf8(%rbp)
callq 0x7650
movq -0xf8(%rbp), %rdx
leaq 0x114f91(%rip), %rsi    # 0x13f91a
leaq -0x80(%rbp), %rdi
callq 0x7520
jmp 0x2a994
movq -0x100(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x9c50
jmp 0x2a9a6
movq -0x100(%rbp), %rdi
movb $0x0, -0x82(%rbp)
leaq 0x18341d(%rip), %rsi    # 0x1addd8
leaq -0x20d32(%rip), %rdx    # 0x9c90
callq 0x7610
jmp 0x2ac73
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x2a9ef
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x7708
leaq -0x81(%rbp), %rdi
callq 0x73d0
testb $0x1, -0x82(%rbp)
jne 0x2aa06
jmp 0x2aa12
movq -0x100(%rbp), %rdi
callq 0x72c0
jmp 0x2ac6a
movq -0xe0(%rbp), %rax
movl -0x5c(%rbp), %ecx
movq 0x8(%rax), %rax
movl %ecx, 0x350(%rax)
jmp 0x2ac61
cmpl $0x4, -0x14(%rbp)
jne 0x2ac2f
movq -0x10(%rbp), %rdi
addq $0x38, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x118c0
testb $0x1, %al
jne 0x2ab23
movb $0x1, -0xaa(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0x110(%rbp)
leaq -0xa9(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x7650
movq -0x108(%rbp), %rdx
leaq 0x114ebf(%rip), %rsi    # 0x13f94b
leaq -0xa8(%rbp), %rdi
callq 0x7520
jmp 0x2aa9a
movq -0x110(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x9c50
jmp 0x2aaaf
movq -0x110(%rbp), %rdi
movb $0x0, -0xaa(%rbp)
leaq 0x183314(%rip), %rsi    # 0x1addd8
leaq -0x20e3b(%rip), %rdx    # 0x9c90
callq 0x7610
jmp 0x2ac73
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x2aafb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x7708
leaq -0xa9(%rbp), %rdi
callq 0x73d0
testb $0x1, -0xaa(%rbp)
jne 0x2ab12
jmp 0x2ab1e
movq -0x110(%rbp), %rdi
callq 0x72c0
jmp 0x2ac6a
movq -0x10(%rbp), %rdi
addq $0x20, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x8570
movl (%rax), %eax
movl %eax, -0xb0(%rbp)
cmpl $0x0, -0xb0(%rbp)
jne 0x2ac16
movb $0x1, -0xd2(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0x120(%rbp)
leaq -0xd1(%rbp), %rdi
movq %rdi, -0x118(%rbp)
callq 0x7650
movq -0x118(%rbp), %rdx
leaq 0x114df8(%rip), %rsi    # 0x13f97a
leaq -0xd0(%rbp), %rdi
callq 0x7520
jmp 0x2ab90
movq -0x120(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x9c50
jmp 0x2aba5
movq -0x120(%rbp), %rdi
movb $0x0, -0xd2(%rbp)
leaq 0x18321e(%rip), %rsi    # 0x1addd8
leaq -0x20f31(%rip), %rdx    # 0x9c90
callq 0x7610
jmp 0x2ac73
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
jmp 0x2abf1
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x50(%rbp)
movl %eax, -0x54(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x7708
leaq -0xd1(%rbp), %rdi
callq 0x73d0
testb $0x1, -0xd2(%rbp)
jne 0x2ac08
jmp 0x2ac14
movq -0x120(%rbp), %rdi
callq 0x72c0
jmp 0x2ac6a
movq -0xe0(%rbp), %rax
movl -0xb0(%rbp), %ecx
movq 0x8(%rax), %rax
movl %ecx, 0x354(%rax)
jmp 0x2ac5f
cmpl $0x0, -0x14(%rbp)
jne 0x2ac5d
movq -0x20(%rbp), %rdi
movl $0x12, %esi
callq 0xef50
testb $0x1, %al
jne 0x2ac49
jmp 0x2ac5b
movq -0xe0(%rbp), %rax
movq 0x8(%rax), %rax
movb $0x1, 0x358(%rax)
jmp 0x2ac5d
jmp 0x2ac5f
jmp 0x2ac61
addq $0x120, %rsp            # imm = 0x120
popq %rbp
retq
movq -0x50(%rbp), %rdi
callq 0x7640
nopw %cs:(%rax,%rax)