// File: /workspace/github_cpp_makefile_star2_O2/dragazo[P]cpp-gc/./GarbageCollection.h
// Function: GC::ptr<GC::ptr<int> [][2][2]> GC::make<GC::ptr<int> [][2][2], 0>(unsigned long)
[[nodiscard]]
	static ptr<T> make(std::size_t count)
	{
		// -- normalize T -- //

		// strip cv qualifiers and first extent to get element type
		typedef std::remove_cv_t<std::remove_extent_t<T>> element_type;

		// strip cv qualifiers and all extents to get scalar type
		typedef std::remove_cv_t<std::remove_all_extents_t<T>> scalar_type;

		// get the total number of scalar objects - we'll build the array in terms of scalar entities
		const std::size_t scalar_count = count * GC::full_extent<T>::value;

		// get the allocator
		typedef checked_aligned_allocator_for<scalar_type, info> allocator_t;

		// -- create the vtable -- //

		// use lambda to conveniently create the set of all router functions for type T
		auto router_set = [](info &handle, auto func) { for (std::size_t i = 0; i < handle.count; ++i) GC::route(reinterpret_cast<scalar_type*>(handle.obj)[i], func); };

		static const info_vtable _vtable(
			[](info &handle) { for (std::size_t i = 0; i < handle.count; ++i) reinterpret_cast<scalar_type*>(handle.obj)[i].~scalar_type(); },
			[](info &handle) { allocator_t::dealloc(handle.obj); },
			router_set,
			router_set
		);

		// -- create the buffer for the objects and their info object -- //

		// compute the size of the array
		std::size_t arr_sz = scalar_count * sizeof(scalar_type);

		// to make sure the info object is aligned, round this up to a multiple of alignof(info).
		// note: this is not necessary if the element type size is already a multiple of alignof(info).
		if constexpr ((sizeof(element_type) & (alignof(info) - 1)) != 0)
		{
			arr_sz = arr_sz + ((~arr_sz + 1) & (alignof(info) - 1));
		}

		// allocate the buffer space (owning)
		void *const buf = allocator_t::alloc(arr_sz + sizeof(info));
		
		// alias the two buffer partitions
		scalar_type *const obj = reinterpret_cast<scalar_type*>(buf);
		info        *const handle = reinterpret_cast<info*>(reinterpret_cast<char*>(buf) + arr_sz);

		// -- construct the objects -- //

		std::size_t constructed_count = 0; // number of successfully constructed objects

		// try to construct the objects
		try
		{
			for (std::size_t i = 0; i < scalar_count; ++i)
			{
				new (obj + i) scalar_type();
				++constructed_count; // inc constructed_count after each success
			}
		}
		// if that fails
		catch (...)
		{
			// destroy anything we successfully constructed
			for (std::size_t i = 0; i < constructed_count; ++i) (obj + i)->~scalar_type();

			// deallocate the buffer and rethrow whatever killed us
			allocator_t::dealloc(buf);
			throw;
		}

		// construct the info object
		new (handle) info(obj, scalar_count, &_vtable);
		
		// -- do the garbage collection aspects -- //

		// claim its children
		handle->route(GC::router_unroot);

		// create the ptr first - this roots obj
		ptr<T> res(reinterpret_cast<element_type*>(obj), handle, GC::bind_new_obj);

		// begin timed collection (if it's not already)
		GC::start_timed_collect();

		// return the now-initialized ptr
		return res;
	}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rsi, %r15
movq %rdi, %rbx
movb 0x21adf(%rip), %al      # 0x34b98
testb %al, %al
je 0x1314f
imulq $0x60, %r15, %r13
shlq $0x2, %r15
leaq 0x40(%r13), %rdi
callq 0x15e54
movq %rax, %r14
movq %rax, %r12
addq %r13, %r12
xorl %ebp, %ebp
movq %rax, %r13
cmpq %rbp, %r15
je 0x130f8
movq %r13, %rdi
xorl %esi, %esi
callq 0x10ab0
incq %rbp
addq $0x18, %r13
jmp 0x130e0
movq %r14, (%r12)
movq %r15, 0x8(%r12)
leaq 0x21a70(%rip), %rax     # 0x34b78
movq %rax, 0x10(%r12)
callq 0x6860
movq %rax, 0x18(%r12)
movq 0x10(%r12), %rax
leaq -0xc1f5(%rip), %rsi     # 0x6f2e
movq %r12, %rdi
callq *0x10(%rax)
movq %r14, (%rbx)
leaq 0x8(%rbx), %rdi
movq %r12, %rsi
callq 0x15f72
callq 0x6f5a
movq %rbx, %rax
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
leaq 0x21a42(%rip), %rdi     # 0x34b98
callq 0x5470
testl %eax, %eax
je 0x130c1
leaq 0x971e(%rip), %rax      # 0x1c888
movq %rax, 0x21a07(%rip)     # 0x34b78
leaq 0x974e(%rip), %rax      # 0x1c8c6
movq %rax, 0x21a01(%rip)     # 0x34b80
leaq 0x9748(%rip), %rax      # 0x1c8ce
movq %rax, 0x219fb(%rip)     # 0x34b88
leaq 0x9786(%rip), %rax      # 0x1c91a
movq %rax, 0x219f5(%rip)     # 0x34b90
leaq 0x219f6(%rip), %rdi     # 0x34b98
callq 0x51a0
jmp 0x130c1
movq %rax, %r14
movq %rbx, %rdi
callq 0x13308
jmp 0x131ed
movq %rax, %rdi
callq 0x50f0
movq %r14, %rbx
subq $0x1, %rbp
jb 0x131d8
movq %rbx, %rdi
callq 0x10c56
addq $0x18, %rbx
jmp 0x131c4
movq %r14, %rdi
callq 0x5320
callq 0x5390
movq %rax, %r14
callq 0x53f0
movq %r14, %rdi
callq 0x5450
movq %rax, %rdi
callq 0x70ea
nop