// File: rossy[P]crossc/SPIRV-Cross/spirv_cross.cpp
// Function: spirv_cross::Compiler::flatten_interface_block(unsigned int)
void Compiler::flatten_interface_block(uint32_t id)
{
	auto &var = get<SPIRVariable>(id);
	auto &type = get<SPIRType>(var.basetype);
	auto &flags = ir.meta.at(type.self).decoration.decoration_flags;

	if (!type.array.empty())
		SPIRV_CROSS_THROW("Type is array of UBOs.");
	if (type.basetype != SPIRType::Struct)
		SPIRV_CROSS_THROW("Type is not a struct.");
	if (!flags.get(DecorationBlock))
		SPIRV_CROSS_THROW("Type is not a block.");
	if (type.member_types.empty())
		SPIRV_CROSS_THROW("Member list of struct is empty.");

	uint32_t t = type.member_types[0];
	for (auto &m : type.member_types)
		if (t != m)
			SPIRV_CROSS_THROW("Types in block differ.");

	auto &mtype = get<SPIRType>(t);
	if (!mtype.array.empty())
		SPIRV_CROSS_THROW("Member type cannot be arrays.");
	if (mtype.basetype == SPIRType::Struct)
		SPIRV_CROSS_THROW("Member type cannot be struct.");

	// Inherit variable name from interface block name.
	ir.meta.at(var.self).decoration.alias = ir.meta.at(type.self).decoration.alias;

	auto storage = var.storage;
	if (storage == StorageClassUniform)
		storage = StorageClassUniformConstant;

	// Change type definition in-place into an array instead.
	// Access chains will still work as-is.
	uint32_t array_size = uint32_t(type.member_types.size());
	type = mtype;
	type.array.push_back(array_size);
	type.pointer = true;
	type.storage = storage;
	var.storage = storage;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x200, %rsp            # imm = 0x200
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq -0x8(%rbp), %rdi
movq %rdi, -0x188(%rbp)
movl -0xc(%rbp), %esi
callq 0xfec0
movq -0x188(%rbp), %rdi
movq %rax, -0x18(%rbp)
movq -0x18(%rbp), %rax
movl 0xc(%rax), %esi
callq 0xea90
movq -0x188(%rbp), %rdi
movq %rax, -0x20(%rbp)
addq $0x8, %rdi
addq $0x30, %rdi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, %esi
callq 0x2f5c0
addq $0x60, %rax
movq %rax, -0x28(%rbp)
movq -0x20(%rbp), %rdi
addq $0x20, %rdi
callq 0x8690
testb $0x1, %al
jne 0x22372
movb $0x1, -0x5d(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0x198(%rbp)
leaq -0x49(%rbp), %rdi
movq %rdi, -0x190(%rbp)
callq 0x7650
movq -0x190(%rbp), %rdx
leaq 0x11d163(%rip), %rsi    # 0x13f450
leaq -0x48(%rbp), %rdi
callq 0x7520
jmp 0x222f8
movq -0x198(%rbp), %rdi
leaq -0x48(%rbp), %rsi
callq 0x9c50
jmp 0x2230a
movq -0x198(%rbp), %rdi
movb $0x0, -0x5d(%rbp)
leaq 0x18babc(%rip), %rsi    # 0x1addd8
leaq -0x18693(%rip), %rdx    # 0x9c90
callq 0x7610
jmp 0x22a45
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x22350
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x48(%rbp), %rdi
callq 0x7708
leaq -0x49(%rbp), %rdi
callq 0x73d0
testb $0x1, -0x5d(%rbp)
jne 0x22361
jmp 0x2236d
movq -0x198(%rbp), %rdi
callq 0x72c0
jmp 0x22a3c
movq -0x20(%rbp), %rax
cmpl $0xc, 0xc(%rax)
je 0x22447
movb $0x1, -0x82(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0x1a8(%rbp)
leaq -0x81(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
callq 0x7650
movq -0x1a0(%rbp), %rdx
leaq 0x11d0ae(%rip), %rsi    # 0x13f467
leaq -0x80(%rbp), %rdi
callq 0x7520
jmp 0x223c4
movq -0x1a8(%rbp), %rdi
leaq -0x80(%rbp), %rsi
callq 0x9c50
jmp 0x223d6
movq -0x1a8(%rbp), %rdi
movb $0x0, -0x82(%rbp)
leaq 0x18b9ed(%rip), %rsi    # 0x1addd8
leaq -0x18762(%rip), %rdx    # 0x9c90
callq 0x7610
jmp 0x22a45
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x2241f
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x80(%rbp), %rdi
callq 0x7708
leaq -0x81(%rbp), %rdi
callq 0x73d0
testb $0x1, -0x82(%rbp)
jne 0x22436
jmp 0x22442
movq -0x1a8(%rbp), %rdi
callq 0x72c0
jmp 0x22a3c
movq -0x28(%rbp), %rdi
movl $0x2, %esi
callq 0xef50
testb $0x1, %al
jne 0x2252d
movb $0x1, -0xaa(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0x1b8(%rbp)
leaq -0xa9(%rbp), %rdi
movq %rdi, -0x1b0(%rbp)
callq 0x7650
movq -0x1b0(%rbp), %rdx
leaq 0x11cfe7(%rip), %rsi    # 0x13f47d
leaq -0xa8(%rbp), %rdi
callq 0x7520
jmp 0x224a4
movq -0x1b8(%rbp), %rdi
leaq -0xa8(%rbp), %rsi
callq 0x9c50
jmp 0x224b9
movq -0x1b8(%rbp), %rdi
movb $0x0, -0xaa(%rbp)
leaq 0x18b90a(%rip), %rsi    # 0x1addd8
leaq -0x18845(%rip), %rdx    # 0x9c90
callq 0x7610
jmp 0x22a45
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x22505
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xa8(%rbp), %rdi
callq 0x7708
leaq -0xa9(%rbp), %rdi
callq 0x73d0
testb $0x1, -0xaa(%rbp)
jne 0x2251c
jmp 0x22528
movq -0x1b8(%rbp), %rdi
callq 0x72c0
jmp 0x22a3c
movq -0x20(%rbp), %rdi
addq $0x68, %rdi
callq 0x8690
testb $0x1, %al
jne 0x22543
jmp 0x22613
movb $0x1, -0xd2(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0x1c8(%rbp)
leaq -0xd1(%rbp), %rdi
movq %rdi, -0x1c0(%rbp)
callq 0x7650
movq -0x1c0(%rbp), %rdx
leaq 0x11cf16(%rip), %rsi    # 0x13f492
leaq -0xd0(%rbp), %rdi
callq 0x7520
jmp 0x2258a
movq -0x1c8(%rbp), %rdi
leaq -0xd0(%rbp), %rsi
callq 0x9c50
jmp 0x2259f
movq -0x1c8(%rbp), %rdi
movb $0x0, -0xd2(%rbp)
leaq 0x18b824(%rip), %rsi    # 0x1addd8
leaq -0x1892b(%rip), %rdx    # 0x9c90
callq 0x7610
jmp 0x22a45
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x225eb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0xd0(%rbp), %rdi
callq 0x7708
leaq -0xd1(%rbp), %rdi
callq 0x73d0
testb $0x1, -0xd2(%rbp)
jne 0x22602
jmp 0x2260e
movq -0x1c8(%rbp), %rdi
callq 0x72c0
jmp 0x22a3c
movq -0x20(%rbp), %rdi
addq $0x68, %rdi
xorl %eax, %eax
movl %eax, %esi
callq 0x8630
movl (%rax), %eax
movl %eax, -0xd8(%rbp)
movq -0x20(%rbp), %rax
addq $0x68, %rax
movq %rax, -0xe0(%rbp)
movq -0xe0(%rbp), %rdi
callq 0x86d0
movq %rax, -0xe8(%rbp)
movq -0xe0(%rbp), %rdi
callq 0x8700
movq %rax, -0xf0(%rbp)
leaq -0xe8(%rbp), %rdi
leaq -0xf0(%rbp), %rsi
callq 0x8730
testb $0x1, %al
jne 0x2267d
jmp 0x22788
leaq -0xe8(%rbp), %rdi
callq 0x8770
movq %rax, -0xf8(%rbp)
movl -0xd8(%rbp), %eax
movq -0xf8(%rbp), %rcx
cmpl (%rcx), %eax
je 0x22775
movb $0x1, -0x11a(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0x1d8(%rbp)
leaq -0x119(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
callq 0x7650
movq -0x1d0(%rbp), %rdx
leaq 0x11cdd4(%rip), %rsi    # 0x13f4b2
leaq -0x118(%rbp), %rdi
callq 0x7520
jmp 0x226ec
movq -0x1d8(%rbp), %rdi
leaq -0x118(%rbp), %rsi
callq 0x9c50
jmp 0x22701
movq -0x1d8(%rbp), %rdi
movb $0x0, -0x11a(%rbp)
leaq 0x18b6c2(%rip), %rsi    # 0x1addd8
leaq -0x18a8d(%rip), %rdx    # 0x9c90
callq 0x7610
jmp 0x22a45
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x2274d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x118(%rbp), %rdi
callq 0x7708
leaq -0x119(%rbp), %rdi
callq 0x73d0
testb $0x1, -0x11a(%rbp)
jne 0x22764
jmp 0x22770
movq -0x1d8(%rbp), %rdi
callq 0x72c0
jmp 0x22a3c
jmp 0x22777
leaq -0xe8(%rbp), %rdi
callq 0x8790
jmp 0x22661
movq -0x188(%rbp), %rdi
movl -0xd8(%rbp), %esi
callq 0xea90
movq %rax, -0x128(%rbp)
movq -0x128(%rbp), %rdi
addq $0x20, %rdi
callq 0x8690
testb $0x1, %al
jne 0x22889
movb $0x1, -0x14a(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0x1e8(%rbp)
leaq -0x149(%rbp), %rdi
movq %rdi, -0x1e0(%rbp)
callq 0x7650
movq -0x1e0(%rbp), %rdx
leaq 0x11ccd7(%rip), %rsi    # 0x13f4c9
leaq -0x148(%rbp), %rdi
callq 0x7520
jmp 0x22800
movq -0x1e8(%rbp), %rdi
leaq -0x148(%rbp), %rsi
callq 0x9c50
jmp 0x22815
movq -0x1e8(%rbp), %rdi
movb $0x0, -0x14a(%rbp)
leaq 0x18b5ae(%rip), %rsi    # 0x1addd8
leaq -0x18ba1(%rip), %rdx    # 0x9c90
callq 0x7610
jmp 0x22a45
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x22861
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x148(%rbp), %rdi
callq 0x7708
leaq -0x149(%rbp), %rdi
callq 0x73d0
testb $0x1, -0x14a(%rbp)
jne 0x22878
jmp 0x22884
movq -0x1e8(%rbp), %rdi
callq 0x72c0
jmp 0x22a3c
movq -0x128(%rbp), %rax
cmpl $0xc, 0xc(%rax)
jne 0x2296a
movb $0x1, -0x172(%rbp)
movl $0x10, %edi
callq 0x71a0
movq %rax, -0x1f8(%rbp)
leaq -0x171(%rbp), %rdi
movq %rdi, -0x1f0(%rbp)
callq 0x7650
movq -0x1f0(%rbp), %rdx
leaq 0x11cc14(%rip), %rsi    # 0x13f4e7
leaq -0x170(%rbp), %rdi
callq 0x7520
jmp 0x228e1
movq -0x1f8(%rbp), %rdi
leaq -0x170(%rbp), %rsi
callq 0x9c50
jmp 0x228f6
movq -0x1f8(%rbp), %rdi
movb $0x0, -0x172(%rbp)
leaq 0x18b4cd(%rip), %rsi    # 0x1addd8
leaq -0x18c82(%rip), %rdx    # 0x9c90
callq 0x7610
jmp 0x22a45
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
jmp 0x22942
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x58(%rbp)
movl %eax, -0x5c(%rbp)
leaq -0x170(%rbp), %rdi
callq 0x7708
leaq -0x171(%rbp), %rdi
callq 0x73d0
testb $0x1, -0x172(%rbp)
jne 0x22959
jmp 0x22965
movq -0x1f8(%rbp), %rdi
callq 0x72c0
jmp 0x22a3c
movq -0x188(%rbp), %rdi
addq $0x8, %rdi
addq $0x30, %rdi
movq -0x20(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, %esi
callq 0x2f5c0
movq -0x188(%rbp), %rdi
movq %rax, -0x200(%rbp)
addq $0x8, %rdi
addq $0x30, %rdi
movq -0x18(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, %esi
callq 0x2f5c0
movq -0x200(%rbp), %rsi
movq %rax, %rdi
callq 0x7050
movq -0x18(%rbp), %rax
movl 0x10(%rax), %eax
movl %eax, -0x178(%rbp)
cmpl $0x2, -0x178(%rbp)
jne 0x229da
movl $0x0, -0x178(%rbp)
movq -0x20(%rbp), %rdi
addq $0x68, %rdi
callq 0x8650
movl %eax, -0x17c(%rbp)
movq -0x128(%rbp), %rsi
movq -0x20(%rbp), %rdi
callq 0x2f600
movq -0x20(%rbp), %rdi
addq $0x20, %rdi
leaq -0x17c(%rbp), %rsi
callq 0x88f0
movq -0x20(%rbp), %rax
movb $0x1, 0x60(%rax)
movl -0x178(%rbp), %ecx
movq -0x20(%rbp), %rax
movl %ecx, 0x64(%rax)
movl -0x178(%rbp), %ecx
movq -0x18(%rbp), %rax
movl %ecx, 0x10(%rax)
addq $0x200, %rsp            # imm = 0x200
popq %rbp
retq
movq -0x58(%rbp), %rdi
callq 0x7640
nopw %cs:(%rax,%rax)