// File: dadocolussi[P]gdc-circular_queue/src/gdc_circular_queue_factory.hpp
// Function: gdc::circular_queue_factory<unsigned long, gdc::circular_queue<unsigned long>>::create_shared(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&, unsigned long, bool, std::function<int (gdc::circular_queue<unsigned long>&)>)
static void create_shared(
			const std::string& name,
			size_type capacity,
			bool sync,
			mdinit_type metadata_initializer)
		{
			// Unlink any old shared memory object with the same name.
			int status = ::shm_unlink(name.c_str());
			if (status == -1 && errno != ENOENT)
			{
				std::string what("shm_unlink: ");
				what.append(::strerror(errno));
				throw circular_queue_error(what);
			}
			
			// Create a new shared memory object.
			int fd = ::shm_open(name.c_str(), O_RDWR | O_CREAT | O_EXCL, S_IRWXU);
			if (fd == -1)
			{
				std::string what("shm_open: ");
				what.append(::strerror(errno));
				::shm_unlink(name.c_str());
				throw circular_queue_error(what);
			}
			
			size_t len = footprint(capacity) + capacity;
			status = ::ftruncate(fd, len);
			if (status != 0)
			{
				std::string what("ftruncate: ");
				what.append(::strerror(errno));
				::close(fd);
				::shm_unlink(name.c_str());
				throw circular_queue_error(what);
			}
			
			void* p = ::mmap(
				NULL,
				len,
				PROT_READ | PROT_WRITE,
				MAP_SHARED,
				fd,
				0);
			if (p == MAP_FAILED)
			{
				std::string what("mmap: ");
				what.append(::strerror(errno));
				::close(fd);
				::shm_unlink(name.c_str());
				throw circular_queue_error(what);
			}
			
			try
			{
				auto q = new (p) Q();
				metadata_initializer(*q);
				auto qq = reinterpret_cast<circular_queue_control_block*>(p);
				qq->properties.sync = sync;
				qq->properties.capacity.store(capacity, std::memory_order_release);
			}
			catch (const std::exception& ex)
			{
				::close(fd);
				::shm_unlink(name.c_str());
				throw;
			}
			
			if (::close(fd) != 0)
			{
				std::string what("close: ");
				what.append(::strerror(errno));
				::shm_unlink(name.c_str());
				throw circular_queue_error(what);
			}
		}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1c0, %rsp            # imm = 0x1C0
movq %rcx, -0x150(%rbp)
movb %dl, %al
movq %rdi, -0x28(%rbp)
movq %rsi, -0x30(%rbp)
andb $0x1, %al
movb %al, -0x31(%rbp)
movq %rcx, -0x40(%rbp)
movq -0x28(%rbp), %rdi
callq 0x20d0
movq %rax, %rdi
callq 0x2360
movl %eax, -0x44(%rbp)
cmpl $-0x1, -0x44(%rbp)
jne 0x451c
callq 0x2030
cmpl $0x2, (%rax)
je 0x451c
leaq -0x69(%rbp), %rdi
movq %rdi, -0x158(%rbp)
callq 0x2320
movq -0x158(%rbp), %rdx
leaq 0x2d97(%rip), %rsi      # 0x71f6
leaq -0x68(%rbp), %rdi
callq 0x2b00
jmp 0x446a
leaq -0x69(%rbp), %rdi
callq 0x2210
callq 0x2030
movl (%rax), %edi
callq 0x2090
movq %rax, %rsi
leaq -0x68(%rbp), %rdi
callq 0x2380
jmp 0x448d
movl $0x18, %edi
callq 0x2100
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x160(%rbp)
leaq -0x68(%rbp), %rsi
callq 0x3aa0
jmp 0x44af
movq -0x160(%rbp), %rdi
leaq 0x6833(%rip), %rsi      # 0xacf0
leaq -0x9d4(%rip), %rdx      # 0x3af0
callq 0x2300
jmp 0x4b5e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x69(%rbp), %rdi
callq 0x2210
jmp 0x4b4d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x450e
movq -0x160(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
callq 0x2190
leaq -0x68(%rbp), %rdi
callq 0x2130
jmp 0x4b4d
movq -0x28(%rbp), %rdi
callq 0x20d0
movq %rax, %rdi
movl $0xc2, %esi
movl $0x1c0, %edx            # imm = 0x1C0
callq 0x22f0
movl %eax, -0x80(%rbp)
cmpl $-0x1, -0x80(%rbp)
jne 0x4647
leaq -0xa1(%rbp), %rdi
movq %rdi, -0x168(%rbp)
callq 0x2320
movq -0x168(%rbp), %rdx
leaq 0x2dd7(%rip), %rsi      # 0x733c
leaq -0xa0(%rbp), %rdi
callq 0x2b00
jmp 0x4573
leaq -0xa1(%rbp), %rdi
callq 0x2210
callq 0x2030
movl (%rax), %edi
callq 0x2090
movq %rax, %rsi
leaq -0xa0(%rbp), %rdi
callq 0x2380
jmp 0x459c
movq -0x28(%rbp), %rdi
callq 0x20d0
movq %rax, %rdi
callq 0x2360
jmp 0x45af
movl $0x18, %edi
callq 0x2100
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x170(%rbp)
leaq -0xa0(%rbp), %rsi
callq 0x3aa0
jmp 0x45d4
movq -0x170(%rbp), %rdi
leaq 0x670e(%rip), %rsi      # 0xacf0
leaq -0xaf9(%rip), %rdx      # 0x3af0
callq 0x2300
jmp 0x4b5e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0xa1(%rbp), %rdi
callq 0x2210
jmp 0x4b4d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x4636
movq -0x170(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
callq 0x2190
leaq -0xa0(%rbp), %rdi
callq 0x2130
jmp 0x4b4d
movq -0x30(%rbp), %rdi
callq 0x5b70
addq -0x30(%rbp), %rax
movq %rax, -0xb0(%rbp)
movl -0x80(%rbp), %edi
movq -0xb0(%rbp), %rsi
callq 0x2280
movl %eax, -0x44(%rbp)
cmpl $0x0, -0x44(%rbp)
je 0x4784
leaq -0xd1(%rbp), %rdi
movq %rdi, -0x178(%rbp)
callq 0x2320
movq -0x178(%rbp), %rdx
leaq 0x2caf(%rip), %rsi      # 0x7347
leaq -0xd0(%rbp), %rdi
callq 0x2b00
jmp 0x46a6
leaq -0xd1(%rbp), %rdi
callq 0x2210
callq 0x2030
movl (%rax), %edi
callq 0x2090
movq %rax, %rsi
leaq -0xd0(%rbp), %rdi
callq 0x2380
jmp 0x46cf
movl -0x80(%rbp), %edi
callq 0x2390
jmp 0x46d9
movq -0x28(%rbp), %rdi
callq 0x20d0
movq %rax, %rdi
callq 0x2360
jmp 0x46ec
movl $0x18, %edi
callq 0x2100
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x180(%rbp)
leaq -0xd0(%rbp), %rsi
callq 0x3aa0
jmp 0x4711
movq -0x180(%rbp), %rdi
leaq 0x65d1(%rip), %rsi      # 0xacf0
leaq -0xc36(%rip), %rdx      # 0x3af0
callq 0x2300
jmp 0x4b5e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0xd1(%rbp), %rdi
callq 0x2210
jmp 0x4b4d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x4773
movq -0x180(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
callq 0x2190
leaq -0xd0(%rbp), %rdi
callq 0x2130
jmp 0x4b4d
movq -0xb0(%rbp), %rsi
movl -0x80(%rbp), %r8d
xorl %eax, %eax
movl %eax, %r9d
movl $0x3, %edx
movl $0x1, %ecx
movq %r9, %rdi
callq 0x2330
movq %rax, -0xe0(%rbp)
movq $-0x1, %rax
cmpq %rax, -0xe0(%rbp)
jne 0x48ce
leaq -0x101(%rbp), %rdi
movq %rdi, -0x188(%rbp)
callq 0x2320
movq -0x188(%rbp), %rdx
leaq 0x2b71(%rip), %rsi      # 0x7353
leaq -0x100(%rbp), %rdi
callq 0x2b00
jmp 0x47f0
leaq -0x101(%rbp), %rdi
callq 0x2210
callq 0x2030
movl (%rax), %edi
callq 0x2090
movq %rax, %rsi
leaq -0x100(%rbp), %rdi
callq 0x2380
jmp 0x4819
movl -0x80(%rbp), %edi
callq 0x2390
jmp 0x4823
movq -0x28(%rbp), %rdi
callq 0x20d0
movq %rax, %rdi
callq 0x2360
jmp 0x4836
movl $0x18, %edi
callq 0x2100
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x190(%rbp)
leaq -0x100(%rbp), %rsi
callq 0x3aa0
jmp 0x485b
movq -0x190(%rbp), %rdi
leaq 0x6487(%rip), %rsi      # 0xacf0
leaq -0xd80(%rip), %rdx      # 0x3af0
callq 0x2300
jmp 0x4b5e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x101(%rbp), %rdi
callq 0x2210
jmp 0x4b4d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x48bd
movq -0x190(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
callq 0x2190
leaq -0x100(%rbp), %rdi
callq 0x2130
jmp 0x4b4d
movq -0xe0(%rbp), %rdi
movq %rdi, -0x198(%rbp)
callq 0x5c50
jmp 0x48e3
movq -0x150(%rbp), %rdi
movq -0x198(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0x110(%rbp), %rsi
callq 0x5c60
jmp 0x4906
movq -0xe0(%rbp), %rax
movq %rax, -0x118(%rbp)
movzbl -0x31(%rbp), %ecx
andl $0x1, %ecx
movq -0x118(%rbp), %rax
movl %ecx, 0x88(%rax)
movq -0x118(%rbp), %rcx
subq $-0x80, %rcx
movq -0x30(%rbp), %rax
movq %rcx, -0x8(%rbp)
movq %rax, -0x10(%rbp)
movl $0x3, -0x14(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x1a8(%rbp)
movl -0x14(%rbp), %edi
movl $0xffff, %esi           # imm = 0xFFFF
callq 0x5ca0
movl %eax, -0x19c(%rbp)
jmp 0x4966
movl -0x19c(%rbp), %eax
movl %eax, -0x18(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0x1ac(%rbp)
movq -0x10(%rbp), %rcx
movq %rcx, -0x20(%rbp)
subl $0x3, %eax
je 0x49a4
jmp 0x4987
movl -0x1ac(%rbp), %eax
subl $0x5, %eax
je 0x49b4
jmp 0x4994
movq -0x1a8(%rbp), %rax
movq -0x20(%rbp), %rcx
movq %rcx, (%rax)
jmp 0x49cc
movq -0x1a8(%rbp), %rax
movq -0x20(%rbp), %rcx
movq %rcx, (%rax)
jmp 0x49cc
movq -0x1a8(%rbp), %rcx
movq -0x20(%rbp), %rax
xchgq %rax, (%rcx)
jmp 0x49cc
movq %rax, %rdi
callq 0x3440
jmp 0x4a39
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
movl -0x7c(%rbp), %eax
movl $0x1, %ecx
cmpl %ecx, %eax
jne 0x4b4d
movq -0x78(%rbp), %rdi
callq 0x20c0
movq %rax, -0x120(%rbp)
movl -0x80(%rbp), %edi
callq 0x2390
jmp 0x4a04
movq -0x28(%rbp), %rdi
callq 0x20d0
movq %rax, %rdi
callq 0x2360
jmp 0x4a17
callq 0x2290
jmp 0x4b5e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
callq 0x22d0
jmp 0x4a34
jmp 0x4b4d
movl -0x80(%rbp), %edi
callq 0x2390
cmpl $0x0, %eax
je 0x4b44
leaq -0x141(%rbp), %rdi
movq %rdi, -0x1b8(%rbp)
callq 0x2320
movq -0x1b8(%rbp), %rdx
leaq 0x28ef(%rip), %rsi      # 0x735a
leaq -0x140(%rbp), %rdi
callq 0x2b00
jmp 0x4a79
leaq -0x141(%rbp), %rdi
callq 0x2210
callq 0x2030
movl (%rax), %edi
callq 0x2090
movq %rax, %rsi
leaq -0x140(%rbp), %rdi
callq 0x2380
jmp 0x4aa2
movq -0x28(%rbp), %rdi
callq 0x20d0
movq %rax, %rdi
callq 0x2360
jmp 0x4ab5
movl $0x18, %edi
callq 0x2100
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x1c0(%rbp)
leaq -0x140(%rbp), %rsi
callq 0x3aa0
jmp 0x4ada
movq -0x1c0(%rbp), %rdi
leaq 0x6208(%rip), %rsi      # 0xacf0
leaq -0xfff(%rip), %rdx      # 0x3af0
callq 0x2300
jmp 0x4b5e
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
leaq -0x141(%rbp), %rdi
callq 0x2210
jmp 0x4b4d
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
jmp 0x4b36
movq -0x1c0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x78(%rbp)
movl %eax, -0x7c(%rbp)
callq 0x2190
leaq -0x140(%rbp), %rdi
callq 0x2130
jmp 0x4b4d
addq $0x1c0, %rsp            # imm = 0x1C0
popq %rbp
retq
movq -0x78(%rbp), %rdi
callq 0x2310
movq %rax, %rdi
callq 0x3440
nop