// File: /workspace/github_cpp_makefile_star2_O3/DMLfor[P]TinyWebServer/./ServerBase.hpp
// Function: WebServer::ServerBase<boost::asio::ssl::stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::execution::any_executor<boost::asio::execution::context_as_t<boost::asio::execution_context&>, boost::asio::execution::detail::blocking::never_t<0>, boost::asio::execution::prefer_only<boost::asio::execution::detail::blocking::possibly_t<0>>, boost::asio::execution::prefer_only<boost::asio::execution::detail::outstanding_work::tracked_t<0>>, boost::asio::execution::prefer_only<boost::asio::execution::detail::outstanding_work::untracked_t<0>>, boost::asio::execution::prefer_only<boost::asio::execution::detail::relationship::fork_t<0>>, boost::asio::execution::prefer_only<boost::asio::execution::detail::relationship::continuation_t<0>>>>>>::respond(std::shared_ptr<boost::asio::ssl::stream<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::execution::any_executor<boost::asio::execution::context_as_t<boost::asio::execution_context&>, boost::asio::execution::detail::blocking::never_t<0>, boost::asio::execution::prefer_only<boost::asio::execution::detail::blocking::possibly_t<0>>, boost::asio::execution::prefer_only<boost::asio::execution::detail::outstanding_work::tracked_t<0>>, boost::asio::execution::prefer_only<boost::asio::execution::detail::outstanding_work::untracked_t<0>>, boost::asio::execution::prefer_only<boost::asio::execution::detail::relationship::fork_t<0>>, boost::asio::execution::prefer_only<boost::asio::execution::detail::relationship::continuation_t<0>>>>>>, std::shared_ptr<WebServer::Request>) const
void WebServer::ServerBase<socket_type>::respond(std::shared_ptr<socket_type> socket, std::shared_ptr<Request> request) const
{
	for(auto res_it : all_resources)
	{
		// 对请求路径和方法进行匹配查找, 并生成响应
		std::regex e(res_it->first);
		std::smatch sm_res;
		if(std::regex_match(request->path, sm_res, e))
		{
			if(res_it->second.count(request->method) > 0)
				request->path_match = move(sm_res);
			// 会被推导为 std::shared_ptr<boost::asio::streambuf>
			auto write_buffer = std::make_shared<boost::asio::streambuf>();
			std::ostream respondse(write_buffer.get());
			res_it->second[request->method](respondse, *request);

			// 在 lambda 中不糊 write_buffer 使其不会再 async_write 完成前被销毁
			boost::asio::async_write(*socket, *write_buffer,
					[this, socket, request, write_buffer](const boost::system::error_code &ec, size_t bytes_transferred)
					{
						// HTTP 持久连接(HTTP 1.1), 递归调用
						if(!ec && stof(request->http_version) > 1.05)
							process_request_and_respond(socket);
					});
			return ;
		}
	}
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1c8, %rsp            # imm = 0x1C8
movq %rsi, 0x48(%rsp)
movq 0x108(%rdi), %r14
movq %rdi, 0x40(%rsp)
movq 0x110(%rdi), %r15
cmpq %r15, %r14
je 0x1ccdb
movq %rdx, %rbx
leaq 0x98(%rsp), %r13
leaq 0x20(%rsp), %rbp
movq (%r14), %r12
leaq 0x20(%r12), %rsi
movq %r13, %rdi
movl $0x10, %edx
callq 0x2cd5a
xorps %xmm0, %xmm0
movaps %xmm0, 0x30(%rsp)
movaps %xmm0, 0x20(%rsp)
movq (%rbx), %rax
movq 0x20(%rax), %rdi
movq 0x28(%rax), %rsi
addq %rdi, %rsi
movq %rbp, %rdx
movq %r13, %rcx
xorl %r8d, %r8d
callq 0x2815a
testb %al, %al
jne 0x1cafd
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x1cae7
callq 0xa5d0
movq %r13, %rdi
callq 0x1cfa4
addq $0x8, %r14
cmpq %r15, %r14
jne 0x1ca96
jmp 0x1ccdb
addq $0x40, %r12
movq (%rbx), %rsi
movq %r12, %rdi
callq 0x2cdf0
testq %rax, %rax
je 0x1cb5b
movq (%rbx), %r14
movq 0xa8(%r14), %rdi
movaps 0x20(%rsp), %xmm0
movups %xmm0, 0xa8(%r14)
movq 0x30(%rsp), %rax
movq %rax, 0xb8(%r14)
xorps %xmm0, %xmm0
movaps %xmm0, 0x20(%rsp)
movq $0x0, 0x30(%rsp)
testq %rdi, %rdi
je 0x1cb4f
callq 0xa5d0
movq 0x38(%rsp), %rax
movq %rax, 0xc0(%r14)
leaq 0x18(%rsp), %rdi
movq $0x0, -0x8(%rdi)
leaq 0x10(%rsp), %rsi
leaq 0xb8(%rsp), %rdx
callq 0x18c2c
movq 0x10(%rsp), %rsi
leaq 0xb8(%rsp), %rdi
callq 0xa2d0
movq (%rbx), %rsi
movq %r12, %rdi
callq 0x2ceec
cmpq $0x0, 0x10(%rax)
je 0x1cced
movq (%rbx), %rdx
leaq 0xb8(%rsp), %rsi
movq %rax, %rdi
callq *0x18(%rax)
movq 0x48(%rsp), %rdx
movq (%rdx), %rax
movq 0x10(%rsp), %rcx
movq 0x40(%rsp), %rsi
movq %rsi, 0x50(%rsp)
movq %rax, 0x58(%rsp)
movq 0x8(%rdx), %rdx
movq %rdx, 0x60(%rsp)
testq %rdx, %rdx
je 0x1cbf2
movq 0x2d3cc(%rip), %rsi     # 0x49fb0
cmpb $0x0, (%rsi)
je 0x1cbee
incl 0x8(%rdx)
jmp 0x1cbf2
lock
incl 0x8(%rdx)
movq (%rbx), %rdx
movq %rdx, 0x68(%rsp)
movq 0x8(%rbx), %rdx
movq %rdx, 0x70(%rsp)
testq %rdx, %rdx
je 0x1cc1d
movq 0x2d3a1(%rip), %rsi     # 0x49fb0
cmpb $0x0, (%rsi)
je 0x1cc19
incl 0x8(%rdx)
jmp 0x1cc1d
lock
incl 0x8(%rdx)
movq 0x10(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq %rsi, 0x78(%rsp)
movq %rdx, 0x80(%rsp)
testq %rdx, %rdx
je 0x1cc4e
movq 0x2d370(%rip), %rsi     # 0x49fb0
cmpb $0x0, (%rsi)
je 0x1cc4a
incl 0x8(%rdx)
jmp 0x1cc4e
lock
incl 0x8(%rdx)
leaq 0x88(%rsp), %rdx
movq %rcx, (%rdx)
leaq 0x90(%rsp), %rdi
movq %rax, (%rdi)
leaq 0x50(%rsp), %rsi
leaq 0xf(%rsp), %rcx
callq 0x2d21e
movq 0x80(%rsp), %rdi
testq %rdi, %rdi
je 0x1cc85
callq 0x1ce68
movq 0x70(%rsp), %rdi
testq %rdi, %rdi
je 0x1cc94
callq 0x1ce68
movq 0x60(%rsp), %rdi
testq %rdi, %rdi
je 0x1cca3
callq 0x1ce68
leaq 0xc0(%rsp), %rdi
callq 0xa250
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x1ccbf
callq 0x1ce68
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x1ccce
callq 0xa5d0
leaq 0x98(%rsp), %rdi
callq 0x1cfa4
addq $0x1c8, %rsp            # imm = 0x1C8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0xa2a0
movq %rax, %rbx
leaq 0x50(%rsp), %rdi
callq 0x2cdbe
jmp 0x1cd0d
movq %rax, %rbx
jmp 0x1cd1a
jmp 0x1cd2b
jmp 0x1cd2b
movq %rax, %rbx
leaq 0xc0(%rsp), %rdi
callq 0xa250
movq 0x18(%rsp), %rdi
testq %rdi, %rdi
je 0x1cd2e
callq 0x1ce68
jmp 0x1cd2e
movq %rax, %rbx
movq 0x20(%rsp), %rdi
testq %rdi, %rdi
je 0x1cd3d
callq 0xa5d0
leaq 0x98(%rsp), %rdi
callq 0x1cfa4
movq %rbx, %rdi
callq 0xaa80