// File: rossy[P]crossc/SPIRV-Cross/spirv_hlsl.cpp
// Function: spirv_cross::CompilerHLSL::builtin_to_glsl[abi:cxx11](spv::BuiltIn, spv::StorageClass)
std::string CompilerHLSL::builtin_to_glsl(spv::BuiltIn builtin, spv::StorageClass storage)
{
	switch (builtin)
	{
	case BuiltInVertexId:
		return "gl_VertexID";
	case BuiltInInstanceId:
		return "gl_InstanceID";
	case BuiltInNumWorkgroups:
	{
		if (!num_workgroups_builtin)
			SPIRV_CROSS_THROW("NumWorkgroups builtin is used, but remap_num_workgroups_builtin() was not called. "
			                  "Cannot emit code for this builtin.");

		auto &var = get<SPIRVariable>(num_workgroups_builtin);
		auto &type = get<SPIRType>(var.basetype);
		return sanitize_underscores(join(to_name(num_workgroups_builtin), "_", get_member_name(type.self, 0)));
	}
	case BuiltInPointCoord:
		// Crude hack, but there is no real alternative. This path is only enabled if point_coord_compat is set.
		return "float2(0.5f, 0.5f)";
	case BuiltInSubgroupLocalInvocationId:
		return "WaveGetLaneIndex()";
	case BuiltInSubgroupSize:
		return "WaveGetLaneCount()";

	default:
		return CompilerGLSL::builtin_to_glsl(builtin, storage);
	}
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
movq %rdi, -0xd0(%rbp)
movq %rdi, %rax
movq %rax, -0xc8(%rbp)
movq %rdi, -0x8(%rbp)
movq %rsi, -0x10(%rbp)
movl %edx, -0x14(%rbp)
movl %ecx, -0x18(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0xc0(%rbp)
movl -0x14(%rbp), %eax
addl $-0x5, %eax
movl %eax, %ecx
movq %rcx, -0xb8(%rbp)
subl $0x24, %eax
ja 0xbe652
movq -0xb8(%rbp), %rax
leaq 0x87301(%rip), %rcx     # 0x1455cc
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq -0x19(%rbp), %rdi
movq %rdi, -0xd8(%rbp)
callq 0x7650
movq -0xd0(%rbp), %rdi
movq -0xd8(%rbp), %rdx
leaq 0x851b8(%rip), %rsi     # 0x1434b1
callq 0x7520
jmp 0xbe300
leaq -0x19(%rbp), %rdi
callq 0x73d0
jmp 0xbe66b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x19(%rbp), %rdi
callq 0x73d0
jmp 0xbe67b
leaq -0x2d(%rbp), %rdi
movq %rdi, -0xe0(%rbp)
callq 0x7650
movq -0xd0(%rbp), %rdi
movq -0xe0(%rbp), %rdx
leaq 0x851ca(%rip), %rsi     # 0x143517
callq 0x7520
jmp 0xbe354
leaq -0x2d(%rbp), %rdi
callq 0x73d0
jmp 0xbe66b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x2d(%rbp), %rdi
callq 0x73d0
jmp 0xbe67b
movq -0xc0(%rbp), %rax
cmpl $0x0, 0x7c8(%rax)
jne 0xbe448
movb $0x1, -0x52(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0xf0(%rbp)
leaq -0x51(%rbp), %rdi
movq %rdi, -0xe8(%rbp)
callq 0x7650
movq -0xe8(%rbp), %rdx
leaq 0x87c5d(%rip), %rsi     # 0x146020
leaq -0x50(%rbp), %rdi
callq 0x7520
jmp 0xbe3ce
movq -0xf0(%rbp), %rdi
leaq -0x50(%rbp), %rsi
callq 0x9c50
jmp 0xbe3e0
movq -0xf0(%rbp), %rdi
movb $0x0, -0x52(%rbp)
leaq 0xef9e6(%rip), %rsi     # 0x1addd8
leaq -0xb4769(%rip), %rdx    # 0x9c90
callq 0x7610
jmp 0xbe684
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0xbe426
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x50(%rbp), %rdi
callq 0x7708
leaq -0x51(%rbp), %rdi
callq 0x73d0
testb $0x1, -0x52(%rbp)
jne 0xbe437
jmp 0xbe443
movq -0xf0(%rbp), %rdi
callq 0x72c0
jmp 0xbe67b
movq -0xc0(%rbp), %rdi
movl 0x7c8(%rdi), %esi
callq 0xfec0
movq -0xc0(%rbp), %rdi
movq %rax, -0x60(%rbp)
movq -0x60(%rbp), %rax
movl 0xc(%rax), %esi
callq 0xea90
movq -0xc0(%rbp), %rsi
movq %rax, -0x68(%rbp)
movl 0x7c8(%rsi), %edx
movq (%rsi), %rax
movq 0x38(%rax), %rax
leaq -0xa8(%rbp), %rdi
movl $0x1, %ecx
callq *%rax
movq -0xc0(%rbp), %rdi
movq -0x68(%rbp), %rax
movl 0x8(%rax), %esi
xorl %edx, %edx
callq 0x22fd0
movq %rax, -0xf8(%rbp)
jmp 0xbe4b5
movq -0xf8(%rbp), %rcx
leaq 0x8a05b(%rip), %rdx     # 0x14851e
leaq -0x88(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0xd7be0
jmp 0xbe4d8
movq -0xd0(%rbp), %rdi
leaq -0x88(%rbp), %rsi
callq 0x577c0
jmp 0xbe4ed
leaq -0x88(%rbp), %rdi
callq 0x7708
leaq -0xa8(%rbp), %rdi
callq 0x7708
jmp 0xbe66b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
jmp 0xbe530
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0x88(%rbp), %rdi
callq 0x7708
leaq -0xa8(%rbp), %rdi
callq 0x7708
jmp 0xbe67b
leaq -0xa9(%rbp), %rdi
movq %rdi, -0x100(%rbp)
callq 0x7650
movq -0xd0(%rbp), %rdi
movq -0x100(%rbp), %rdx
leaq 0x87b2c(%rip), %rsi     # 0x146095
callq 0x7520
jmp 0xbe570
leaq -0xa9(%rbp), %rdi
callq 0x73d0
jmp 0xbe66b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0xa9(%rbp), %rdi
callq 0x73d0
jmp 0xbe67b
leaq -0xaa(%rbp), %rdi
movq %rdi, -0x108(%rbp)
callq 0x7650
movq -0xd0(%rbp), %rdi
movq -0x108(%rbp), %rdx
leaq 0x87ae2(%rip), %rsi     # 0x1460a8
callq 0x7520
jmp 0xbe5cd
leaq -0xaa(%rbp), %rdi
callq 0x73d0
jmp 0xbe66b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0xaa(%rbp), %rdi
callq 0x73d0
jmp 0xbe67b
leaq -0xab(%rbp), %rdi
movq %rdi, -0x110(%rbp)
callq 0x7650
movq -0xd0(%rbp), %rdi
movq -0x110(%rbp), %rdx
leaq 0x87a98(%rip), %rsi     # 0x1460bb
callq 0x7520
jmp 0xbe62a
leaq -0xab(%rbp), %rdi
callq 0x73d0
jmp 0xbe66b
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
leaq -0xab(%rbp), %rdi
callq 0x73d0
jmp 0xbe67b
movq -0xc0(%rbp), %rsi
movq -0xd0(%rbp), %rdi
movl -0x14(%rbp), %edx
movl -0x18(%rbp), %ecx
callq 0x82ba0
movq -0xc8(%rbp), %rax
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x7640
nopw %cs:(%rax,%rax)