// File: dadocolussi[P]gdc-circular_queue/src/gdc_circular_queue_factory.hpp
// Function: gdc::circular_queue_factory<unsigned long, gdc::circular_queue<unsigned long>>::map_shared(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>> const&)
static Q* map_shared(const std::string& name)
		{
			// Ignore size. The true size is defined in the mapped memory.
			static long page_size = ::sysconf(_SC_PAGESIZE);
			if (page_size == -1)
			{
				std::string what("sysconf: ");
				what.append(::strerror(errno));
				throw circular_queue_error(what);
			}
			assert(page_size > 0);
			
			int fd = ::shm_open(name.c_str(), O_RDWR, S_IRWXU);
			if (fd == -1)
			{
				std::string what("shm_open: ");
				what.append(::strerror(errno));
				throw circular_queue_error(what);
			}
			
			size_type init_size = footprint(0);
			auto p = ::mmap(
				NULL,
				init_size,
				PROT_READ | PROT_WRITE,
				MAP_SHARED,
				fd,
				0);
			if (p == MAP_FAILED)
			{
				std::string what("mmap: ");
				what.append(::strerror(errno));
				::close(fd);
				throw circular_queue_error(what);
			}
			
			Q* q = new (p) Q();
			size_type capacity = q->capacity();
			
			if (capacity == 0)
			{
				// Not fully initialized yet.
				::munmap(p, init_size);
				::close(fd);
				throw circular_queue_error("Not fully initialized yet.");
			}
			
			if (::munmap(p, init_size) != 0)
			{
				std::string what("munmap: ");
				what.append(::strerror(errno));
				::close(fd);
				throw circular_queue_error(what);
			}
			
			size_type fp = footprint(capacity);
			p = ::mmap(
				NULL,
				fp + capacity,
				PROT_READ | PROT_WRITE,
				MAP_SHARED,
				fd,
				0);
			if (p == MAP_FAILED)
			{
				std::string what("mmap: ");
				what.append(::strerror(errno));
				::close(fd);
				throw circular_queue_error(what);
			}
			
			q = new (p) Q();
			void* pp = reinterpret_cast<char*>(p) + fp;
			void* p2 = ::mmap(
				pp,
				capacity,
				PROT_READ | PROT_WRITE, 
				MAP_SHARED | MAP_FIXED,
				fd,
				page_size);
			if (p2 == MAP_FAILED)
			{
				std::string what("mmap: ");
				what.append(::strerror(errno));
				::munmap(p, fp + capacity);
				::close(fd);
				throw circular_queue_error(what);
			}
			
			if (::close(fd) != 0)
			{
				std::string what("close: ");
				what.append(::strerror(errno));
				::munmap(p, fp + capacity);
				::close(fd);
				throw circular_queue_error(what);
			}
			
			return q;
		}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x1f0, %rsp            # imm = 0x1F0
movq %rdi, -0x8(%rbp)
cmpb $0x0, 0x66aa(%rip)      # 0xb220
jne 0x4ba6
leaq 0x66a1(%rip), %rdi      # 0xb220
callq 0x2350
cmpl $0x0, %eax
je 0x4ba6
movl $0x1e, %edi
callq 0x2150
movq %rax, 0x667e(%rip)      # 0xb218
leaq 0x667f(%rip), %rdi      # 0xb220
callq 0x2140
cmpq $-0x1, 0x666a(%rip)     # 0xb218
jne 0x4c8f
leaq -0x29(%rbp), %rdi
movq %rdi, -0x170(%rbp)
callq 0x2320
movq -0x170(%rbp), %rdx
leaq 0x281e(%rip), %rsi      # 0x73f0
leaq -0x28(%rbp), %rdi
callq 0x2b00
jmp 0x4bdd
leaq -0x29(%rbp), %rdi
callq 0x2210
callq 0x2030
movl (%rax), %edi
callq 0x2090
movq %rax, %rsi
leaq -0x28(%rbp), %rdi
callq 0x2380
jmp 0x4c00
movl $0x18, %edi
callq 0x2100
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x178(%rbp)
leaq -0x28(%rbp), %rsi
callq 0x3aa0
jmp 0x4c22
movq -0x178(%rbp), %rdi
leaq 0x60c0(%rip), %rsi      # 0xacf0
leaq -0x1147(%rip), %rdx     # 0x3af0
callq 0x2300
jmp 0x54bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x29(%rbp), %rdi
callq 0x2210
jmp 0x54b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x4c81
movq -0x178(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x2190
leaq -0x28(%rbp), %rdi
callq 0x2130
jmp 0x54b2
cmpq $0x0, 0x6581(%rip)      # 0xb218
jle 0x4c9b
jmp 0x4cba
leaq 0x239a(%rip), %rdi      # 0x703c
leaq 0x2496(%rip), %rsi      # 0x713f
movl $0xd5, %edx
leaq 0x2745(%rip), %rcx      # 0x73fa
callq 0x2160
movq -0x8(%rbp), %rdi
callq 0x20d0
movq %rax, %rdi
movl $0x2, %esi
movl $0x1c0, %edx            # imm = 0x1C0
callq 0x22f0
movl %eax, -0x40(%rbp)
cmpl $-0x1, -0x40(%rbp)
jne 0x4dbd
leaq -0x61(%rbp), %rdi
movq %rdi, -0x180(%rbp)
callq 0x2320
movq -0x180(%rbp), %rdx
leaq 0x263c(%rip), %rsi      # 0x733c
leaq -0x60(%rbp), %rdi
callq 0x2b00
jmp 0x4d0b
leaq -0x61(%rbp), %rdi
callq 0x2210
callq 0x2030
movl (%rax), %edi
callq 0x2090
movq %rax, %rsi
leaq -0x60(%rbp), %rdi
callq 0x2380
jmp 0x4d2e
movl $0x18, %edi
callq 0x2100
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x188(%rbp)
leaq -0x60(%rbp), %rsi
callq 0x3aa0
jmp 0x4d50
movq -0x188(%rbp), %rdi
leaq 0x5f92(%rip), %rsi      # 0xacf0
leaq -0x1275(%rip), %rdx     # 0x3af0
callq 0x2300
jmp 0x54bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x61(%rbp), %rdi
callq 0x2210
jmp 0x54b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x4daf
movq -0x188(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x2190
leaq -0x60(%rbp), %rdi
callq 0x2130
jmp 0x54b2
xorl %eax, %eax
movl %eax, %edi
callq 0x5b70
movq %rax, -0x70(%rbp)
movq -0x70(%rbp), %rsi
movl -0x40(%rbp), %r8d
xorl %eax, %eax
movl %eax, %r9d
movl $0x3, %edx
movl $0x1, %ecx
movq %r9, %rdi
callq 0x2330
movq %rax, -0x78(%rbp)
movq $-0x1, %rax
cmpq %rax, -0x78(%rbp)
jne 0x4ef8
leaq -0x99(%rbp), %rdi
movq %rdi, -0x190(%rbp)
callq 0x2320
movq -0x190(%rbp), %rdx
leaq 0x2534(%rip), %rsi      # 0x7353
leaq -0x98(%rbp), %rdi
callq 0x2b00
jmp 0x4e2d
leaq -0x99(%rbp), %rdi
callq 0x2210
callq 0x2030
movl (%rax), %edi
callq 0x2090
movq %rax, %rsi
leaq -0x98(%rbp), %rdi
callq 0x2380
jmp 0x4e56
movl -0x40(%rbp), %edi
callq 0x2390
jmp 0x4e60
movl $0x18, %edi
callq 0x2100
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x198(%rbp)
leaq -0x98(%rbp), %rsi
callq 0x3aa0
jmp 0x4e85
movq -0x198(%rbp), %rdi
leaq 0x5e5d(%rip), %rsi      # 0xacf0
leaq -0x13aa(%rip), %rdx     # 0x3af0
callq 0x2300
jmp 0x54bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x99(%rbp), %rdi
callq 0x2210
jmp 0x54b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x4ee7
movq -0x198(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x2190
leaq -0x98(%rbp), %rdi
callq 0x2130
jmp 0x54b2
movq -0x78(%rbp), %rdi
movq %rdi, -0x1a0(%rbp)
callq 0x5c50
movq -0x1a0(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0xa8(%rbp), %rdi
callq 0x5cc0
movq %rax, -0xb0(%rbp)
cmpq $0x0, -0xb0(%rbp)
jne 0x4fa4
movq -0x78(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x2120
movl -0x40(%rbp), %edi
callq 0x2390
movl $0x18, %edi
callq 0x2100
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x1a8(%rbp)
leaq 0x2526(%rip), %rsi      # 0x748c
callq 0x5d40
jmp 0x4f6d
movq -0x1a8(%rbp), %rdi
leaq 0x5d75(%rip), %rsi      # 0xacf0
leaq -0x1492(%rip), %rdx     # 0x3af0
callq 0x2300
movq -0x1a8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x2190
jmp 0x54b2
movq -0x78(%rbp), %rdi
movq -0x70(%rbp), %rsi
callq 0x2120
cmpl $0x0, %eax
je 0x50b4
leaq -0xd1(%rbp), %rdi
movq %rdi, -0x1b0(%rbp)
callq 0x2320
movq -0x1b0(%rbp), %rdx
leaq 0x24cc(%rip), %rsi      # 0x74a7
leaq -0xd0(%rbp), %rdi
callq 0x2b00
jmp 0x4fe9
leaq -0xd1(%rbp), %rdi
callq 0x2210
callq 0x2030
movl (%rax), %edi
callq 0x2090
movq %rax, %rsi
leaq -0xd0(%rbp), %rdi
callq 0x2380
jmp 0x5012
movl -0x40(%rbp), %edi
callq 0x2390
jmp 0x501c
movl $0x18, %edi
callq 0x2100
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x1b8(%rbp)
leaq -0xd0(%rbp), %rsi
callq 0x3aa0
jmp 0x5041
movq -0x1b8(%rbp), %rdi
leaq 0x5ca1(%rip), %rsi      # 0xacf0
leaq -0x1566(%rip), %rdx     # 0x3af0
callq 0x2300
jmp 0x54bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0xd1(%rbp), %rdi
callq 0x2210
jmp 0x54b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x50a3
movq -0x1b8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x2190
leaq -0xd0(%rbp), %rdi
callq 0x2130
jmp 0x54b2
movq -0xb0(%rbp), %rdi
callq 0x5b70
movq %rax, -0xe0(%rbp)
movq -0xe0(%rbp), %rsi
addq -0xb0(%rbp), %rsi
movl -0x40(%rbp), %r8d
xorl %eax, %eax
movl %eax, %r9d
movl $0x3, %edx
movl $0x1, %ecx
movq %r9, %rdi
callq 0x2330
movq %rax, -0x78(%rbp)
movq $-0x1, %rax
cmpq %rax, -0x78(%rbp)
jne 0x51ff
leaq -0x101(%rbp), %rdi
movq %rdi, -0x1c0(%rbp)
callq 0x2320
movq -0x1c0(%rbp), %rdx
leaq 0x222d(%rip), %rsi      # 0x7353
leaq -0x100(%rbp), %rdi
callq 0x2b00
jmp 0x5134
leaq -0x101(%rbp), %rdi
callq 0x2210
callq 0x2030
movl (%rax), %edi
callq 0x2090
movq %rax, %rsi
leaq -0x100(%rbp), %rdi
callq 0x2380
jmp 0x515d
movl -0x40(%rbp), %edi
callq 0x2390
jmp 0x5167
movl $0x18, %edi
callq 0x2100
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x1c8(%rbp)
leaq -0x100(%rbp), %rsi
callq 0x3aa0
jmp 0x518c
movq -0x1c8(%rbp), %rdi
leaq 0x5b56(%rip), %rsi      # 0xacf0
leaq -0x16b1(%rip), %rdx     # 0x3af0
callq 0x2300
jmp 0x54bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x101(%rbp), %rdi
callq 0x2210
jmp 0x54b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x51ee
movq -0x1c8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x2190
leaq -0x100(%rbp), %rdi
callq 0x2130
jmp 0x54b2
movq -0x78(%rbp), %rdi
movq %rdi, -0x1d0(%rbp)
callq 0x5c50
movq -0x1d0(%rbp), %rax
movq %rax, -0xa8(%rbp)
movq -0x78(%rbp), %rax
addq -0xe0(%rbp), %rax
movq %rax, -0x110(%rbp)
movq -0x110(%rbp), %rdi
movq -0xb0(%rbp), %rsi
movl -0x40(%rbp), %r8d
movq 0x5fd0(%rip), %r9       # 0xb218
movl $0x3, %edx
movl $0x11, %ecx
callq 0x2330
movq %rax, -0x118(%rbp)
movq $-0x1, %rax
cmpq %rax, -0x118(%rbp)
jne 0x5386
leaq -0x139(%rbp), %rdi
movq %rdi, -0x1d8(%rbp)
callq 0x2320
movq -0x1d8(%rbp), %rdx
leaq 0x20c0(%rip), %rsi      # 0x7353
leaq -0x138(%rbp), %rdi
callq 0x2b00
jmp 0x52a1
leaq -0x139(%rbp), %rdi
callq 0x2210
callq 0x2030
movl (%rax), %edi
callq 0x2090
movq %rax, %rsi
leaq -0x138(%rbp), %rdi
callq 0x2380
jmp 0x52ca
movq -0x78(%rbp), %rdi
movq -0xe0(%rbp), %rsi
movq -0xb0(%rbp), %rax
addq %rax, %rsi
callq 0x2120
movl -0x40(%rbp), %edi
callq 0x2390
jmp 0x52ee
movl $0x18, %edi
callq 0x2100
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x1e0(%rbp)
leaq -0x138(%rbp), %rsi
callq 0x3aa0
jmp 0x5313
movq -0x1e0(%rbp), %rdi
leaq 0x59cf(%rip), %rsi      # 0xacf0
leaq -0x1838(%rip), %rdx     # 0x3af0
callq 0x2300
jmp 0x54bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x139(%rbp), %rdi
callq 0x2210
jmp 0x54b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x5375
movq -0x1e0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x2190
leaq -0x138(%rbp), %rdi
callq 0x2130
jmp 0x54b2
movl -0x40(%rbp), %edi
callq 0x2390
cmpl $0x0, %eax
je 0x54a2
leaq -0x161(%rbp), %rdi
movq %rdi, -0x1e8(%rbp)
callq 0x2320
movq -0x1e8(%rbp), %rdx
leaq 0x1fa2(%rip), %rsi      # 0x735a
leaq -0x160(%rbp), %rdi
callq 0x2b00
jmp 0x53c6
leaq -0x161(%rbp), %rdi
callq 0x2210
callq 0x2030
movl (%rax), %edi
callq 0x2090
movq %rax, %rsi
leaq -0x160(%rbp), %rdi
callq 0x2380
jmp 0x53ef
movq -0x78(%rbp), %rdi
movq -0xe0(%rbp), %rsi
movq -0xb0(%rbp), %rax
addq %rax, %rsi
callq 0x2120
movl -0x40(%rbp), %edi
callq 0x2390
jmp 0x5413
movl $0x18, %edi
callq 0x2100
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x1f0(%rbp)
leaq -0x160(%rbp), %rsi
callq 0x3aa0
jmp 0x5438
movq -0x1f0(%rbp), %rdi
leaq 0x58aa(%rip), %rsi      # 0xacf0
leaq -0x195d(%rip), %rdx     # 0x3af0
callq 0x2300
jmp 0x54bb
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
leaq -0x161(%rbp), %rdi
callq 0x2210
jmp 0x54b2
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
jmp 0x5494
movq -0x1f0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x38(%rbp)
movl %eax, -0x3c(%rbp)
callq 0x2190
leaq -0x160(%rbp), %rdi
callq 0x2130
jmp 0x54b2
movq -0xa8(%rbp), %rax
addq $0x1f0, %rsp            # imm = 0x1F0
popq %rbp
retq
movq -0x38(%rbp), %rdi
callq 0x2310
nopl (%rax,%rax)