// File: /workspace/github_cpp_makefile_star2_O2/OtherCrashOverride[P]xu4enc/./M2M.h
// Function: M2M::CreateInputBuffers()
void CreateInputBuffers()
	{
		// Request buffers
		v4l2_requestbuffers requestBuffers = { 0 };
		requestBuffers.count = BUFFER_COUNT;
		requestBuffers.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_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, "CreateInputBuffers: 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 = 2;

			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.");
			}

			inputBuffers.push_back(mapping);
			freeInputBuffers.push(i);

#if 0 // Dont queue input buffers, only output buffers

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

		}
	}

// Assembly:
pushq %rbp
movq %rsp, %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x2a8, %rsp            # imm = 0x2A8
movq %rdi, %rbx
movl $0xc0145608, %eax       # imm = 0xC0145608
movq %rax, -0x38(%rbp)
leaq -0x74(%rbp), %rdx
andq $0x0, 0xc(%rdx)
movabsq $0xa00000004, %rax      # imm = 0xA00000004
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 0x31f3
movl -0x74(%rbp), %edx
cmpl $0x5, %edx
jae 0x3207
movq 0x3f6d(%rip), %rax      # 0x6fd8
movq (%rax), %rdi
leaq 0x133a(%rip), %rsi      # 0x43af
xorl %eax, %eax
callq 0x2120
leaq 0x20(%rbx), %rax
movq %rax, -0x40(%rbp)
leaq 0x58(%rbx), %r12
leaq -0xc8(%rbp), %r15
xorps %xmm0, %xmm0
addq $0x440001, -0x38(%rbp)  # imm = 0x440001
pushq $0x3
popq %r13
pushq $0x1
popq %r14
xorl %eax, %eax
movl %eax, -0x2c(%rbp)
cmpl -0x74(%rbp), %eax
jae 0x31a5
movups %xmm0, 0x40(%r15)
movups %xmm0, 0x30(%r15)
movups %xmm0, 0x20(%r15)
movups %xmm0, 0x10(%r15)
movups %xmm0, (%r15)
movl -0x70(%rbp), %ecx
movl %ecx, -0xcc(%rbp)
movl $0x1, -0x94(%rbp)
movl %eax, -0xd0(%rbp)
leaq -0x2d0(%rbp), %rax
movq %rax, -0x90(%rbp)
movl $0x2, -0x88(%rbp)
movl 0x8(%rbx), %edi
movq -0x38(%rbp), %rsi
leaq -0xd0(%rbp), %rdx
xorl %eax, %eax
callq 0x2110
testl %eax, %eax
js 0x31cb
xorps %xmm0, %xmm0
movaps %xmm0, -0x50(%rbp)
movaps %xmm0, -0x60(%rbp)
movq -0x90(%rbp), %rax
movl 0x4(%rax), %esi
movq %rsi, -0x58(%rbp)
movl 0x8(%rbx), %r8d
movl 0x8(%rax), %r9d
xorl %edi, %edi
movl %r13d, %edx
movl %r14d, %ecx
callq 0x21d0
movq %rax, -0x60(%rbp)
cmpq $-0x1, %rax
je 0x31df
movq -0x90(%rbp), %rax
movl 0x44(%rax), %esi
movq %rsi, -0x48(%rbp)
movl 0x8(%rbx), %r8d
movl 0x48(%rax), %r9d
xorl %edi, %edi
movl %r13d, %edx
movl %r14d, %ecx
callq 0x21d0
movq %rax, -0x50(%rbp)
cmpq $-0x1, %rax
je 0x31b7
movq -0x40(%rbp), %rdi
leaq -0x60(%rbp), %rsi
callq 0x38e2
movq %r12, %rdi
leaq -0x2c(%rbp), %rsi
callq 0x3a6e
movl -0x2c(%rbp), %eax
incl %eax
xorps %xmm0, %xmm0
jmp 0x30a4
addq $0x2a8, %rsp            # imm = 0x2A8
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
pushq $0x8
popq %rdi
callq 0x2090
movq %rax, %rbx
leaq 0x123a(%rip), %rsi      # 0x4403
jmp 0x3219
pushq $0x8
popq %rdi
callq 0x2090
movq %rax, %rbx
leaq 0x11ff(%rip), %rsi      # 0x43dc
jmp 0x3219
pushq $0x8
popq %rdi
callq 0x2090
movq %rax, %rbx
leaq 0x1203(%rip), %rsi      # 0x43f4
jmp 0x3219
pushq $0x8
popq %rdi
callq 0x2090
movq %rax, %rbx
leaq 0x1181(%rip), %rsi      # 0x4386
jmp 0x3219
pushq $0x8
popq %rdi
callq 0x2090
movq %rax, %rbx
leaq 0x1184(%rip), %rsi      # 0x439d
movq %rax, %rdi
callq 0x264e
leaq 0x3b48(%rip), %rsi      # 0x6d70
movq 0x3db9(%rip), %rdx      # 0x6fe8
movq %rbx, %rdi
callq 0x21b0
nop