// File: /workspace/github_cpp_makefile_star2_O1/OtherCrashOverride[P]xu4enc/./M2M.h
// Function: M2M::CreateOutputBuffers()
void CreateOutputBuffers()
	{
		// Request buffers
		v4l2_requestbuffers requestBuffers = { 0 };
		requestBuffers.count = BUFFER_COUNT;
		requestBuffers.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
		requestBuffers.memory = V4L2_MEMORY_MMAP;

		int io = ioctl(mfc_fd, VIDIOC_REQBUFS, &requestBuffers);
		if (io < 0)
		{
			throw Exception("VIDIOC_REQBUFS failed.");
		}

		if (requestBuffers.count > BUFFER_COUNT)
		{
			throw Exception("too many buffers.");
		}
		else
		{
			fprintf(stderr, "CreateOutputBuffers: requestBuffers.count=%d\n", requestBuffers.count);
		}


		// Map buffers
		//BufferMapping bufferMappings[requestBuffers.count] = { 0 };
		for (int i = 0; i < requestBuffers.count; ++i)
		{
			v4l2_plane planes[VIDEO_MAX_PLANES];

			v4l2_buffer buffer = { 0 };
			buffer.type = requestBuffers.type;
			buffer.memory = V4L2_MEMORY_MMAP;
			buffer.index = i;
			buffer.m.planes = planes;
			buffer.length = 1;

			io = ioctl(mfc_fd, VIDIOC_QUERYBUF, &buffer);
			if (io < 0)
			{
				throw Exception("VIDIOC_QUERYBUF failed.");
			}

			BufferMapping mapping = { 0 };

			mapping.Length0 = buffer.m.planes[0].length;
			mapping.Start0 = mmap(NULL, mapping.Length0,
				PROT_READ | PROT_WRITE, /* recommended */
				MAP_SHARED,             /* recommended */
				mfc_fd,
				buffer.m.planes[0].m.mem_offset);
			if (mapping.Start0 == MAP_FAILED)
			{
				throw Exception("mmap 0 failed.");
			}

			//mapping.Length1 = buffer.m.planes[1].length;
			//mapping.Start1 = mmap(NULL, mapping.Length1,
			//	PROT_READ | PROT_WRITE, /* recommended */
			//	MAP_SHARED,             /* recommended */
			//	mfc_fd,
			//	buffer.m.planes[1].m.mem_offset);
			//if (mapping.Start1 == MAP_FAILED)
			//{
			//	throw Exception("mmap 1 failed.");
			//}

			outputBuffers.push_back(mapping);

			// Queue buffers
			int ret = ioctl(mfc_fd, VIDIOC_QBUF, &buffer);
			if (ret != 0)
			{
				throw Exception("VIDIOC_QBUF failed.");
			}
		}
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2a8, %rsp            # imm = 0x2A8
movq %rdi, %rbx
xorps %xmm0, %xmm0
leaq -0x40(%rbp), %rdx
movaps %xmm0, (%rdx)
movl $0x0, 0x10(%rdx)
movabsq $0x900000004, %rax      # imm = 0x900000004
movq %rax, (%rdx)
movl $0x1, 0x8(%rdx)
movl 0x8(%rdi), %edi
movl $0xc0145608, %esi       # imm = 0xC0145608
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x39b2
movl -0x40(%rbp), %edx
cmpl $0x5, %edx
jae 0x39b7
movq 0x478a(%rip), %rax      # 0x7fd8
movq (%rax), %rdi
leaq 0x1c04(%rip), %rsi      # 0x545c
xorl %eax, %eax
callq 0x2120
cmpl $0x0, -0x40(%rbp)
je 0x3991
leaq 0x38(%rbx), %rax
movq %rax, -0x48(%rbp)
xorps %xmm0, %xmm0
movl $0xc0145608, %r15d      # imm = 0xC0145608
leaq 0x440001(%r15), %r12
leaq -0xd0(%rbp), %r13
addq $0x440007, %r15         # imm = 0x440007
xorl %r14d, %r14d
movaps %xmm0, -0xd0(%rbp)
movaps %xmm0, -0xa0(%rbp)
movaps %xmm0, -0x90(%rbp)
movaps %xmm0, -0xb0(%rbp)
movaps %xmm0, -0xc0(%rbp)
movq $0x0, -0x80(%rbp)
movl -0x3c(%rbp), %eax
movl %eax, -0xcc(%rbp)
movl $0x1, %eax
movl %eax, -0x94(%rbp)
movl %r14d, -0xd0(%rbp)
leaq -0x2d0(%rbp), %rcx
movq %rcx, -0x90(%rbp)
movl %eax, -0x88(%rbp)
movl 0x8(%rbx), %edi
movq %r12, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x39a3
xorps %xmm0, %xmm0
movaps %xmm0, -0x60(%rbp)
movaps %xmm0, -0x70(%rbp)
movq -0x90(%rbp), %rax
movl 0x4(%rax), %esi
movq %rsi, -0x68(%rbp)
movl 0x8(%rbx), %r8d
movl 0x8(%rax), %r9d
xorl %edi, %edi
movl $0x3, %edx
movl $0x1, %ecx
callq 0x21d0
movq %rax, -0x70(%rbp)
cmpq $-0x1, %rax
je 0x39a8
movq 0x40(%rbx), %rsi
cmpq 0x48(%rbx), %rsi
je 0x3960
movaps -0x70(%rbp), %xmm0
movaps -0x60(%rbp), %xmm1
movups %xmm1, 0x10(%rsi)
movups %xmm0, (%rsi)
addq $0x20, 0x40(%rbx)
jmp 0x396d
movq -0x48(%rbp), %rdi
leaq -0x70(%rbp), %rdx
callq 0x3c84
movl 0x8(%rbx), %edi
movq %r15, %rsi
movq %r13, %rdx
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
jne 0x39ad
incl %r14d
cmpl -0x40(%rbp), %r14d
xorps %xmm0, %xmm0
jb 0x3892
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
callq 0x2729
callq 0x26f3
callq 0x26bd
callq 0x2795
callq 0x275f