// File: 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
subq $0x2e0, %rsp            # imm = 0x2E0
movq %rdi, -0x8(%rbp)
movq -0x8(%rbp), %rax
movq %rax, -0x2b0(%rbp)
leaq -0x1c(%rbp), %rdi
xorl %esi, %esi
movl $0x14, %edx
callq 0x20b0
movq -0x2b0(%rbp), %rax
movl $0x4, -0x1c(%rbp)
movl $0xa, -0x18(%rbp)
movl $0x1, -0x14(%rbp)
movl 0x8(%rax), %edi
movl $0xc0145608, %esi       # imm = 0xC0145608
leaq -0x1c(%rbp), %rdx
movb $0x0, %al
callq 0x2120
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0x39be
movl $0x8, %edi
callq 0x2090
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x2b8(%rbp)
leaq 0x3a56(%rip), %rsi      # 0x73d6
callq 0x28c0
jmp 0x3987
movq -0x2b8(%rbp), %rdi
leaq 0x73db(%rip), %rsi      # 0xad70
leaq -0x107c(%rip), %rdx     # 0x2920
callq 0x21b0
movq -0x2b8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x20c0
jmp 0x3cd5
cmpl $0x4, -0x1c(%rbp)
jbe 0x3a20
movl $0x8, %edi
callq 0x2090
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x2c0(%rbp)
leaq 0x3a0b(%rip), %rsi      # 0x73ed
callq 0x28c0
jmp 0x39e9
movq -0x2c0(%rbp), %rdi
leaq 0x7379(%rip), %rsi      # 0xad70
leaq -0x10de(%rip), %rdx     # 0x2920
callq 0x21b0
movq -0x2c0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x20c0
jmp 0x3cd5
movq 0x75b9(%rip), %rax      # 0xafe0
movq (%rax), %rdi
movl -0x1c(%rbp), %edx
leaq 0x39cb(%rip), %rsi      # 0x73ff
movb $0x0, %al
callq 0x2130
movl $0x0, -0x30(%rbp)
movl -0x30(%rbp), %eax
cmpl -0x1c(%rbp), %eax
jae 0x3ccc
leaq -0x288(%rbp), %rdi
xorl %esi, %esi
movl $0x58, %edx
callq 0x20b0
movq -0x2b0(%rbp), %rax
movl -0x18(%rbp), %ecx
movl %ecx, -0x284(%rbp)
movl $0x1, -0x24c(%rbp)
movl -0x30(%rbp), %ecx
movl %ecx, -0x288(%rbp)
leaq -0x230(%rbp), %rcx
movq %rcx, -0x248(%rbp)
movl $0x2, -0x240(%rbp)
movl 0x8(%rax), %edi
movl $0xc0585609, %esi       # imm = 0xC0585609
leaq -0x288(%rbp), %rdx
movb $0x0, %al
callq 0x2120
movl %eax, -0x20(%rbp)
cmpl $0x0, -0x20(%rbp)
jge 0x3b17
movl $0x8, %edi
callq 0x2090
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x2c8(%rbp)
leaq 0x3953(%rip), %rsi      # 0x742c
callq 0x28c0
jmp 0x3ae0
movq -0x2c8(%rbp), %rdi
leaq 0x7282(%rip), %rsi      # 0xad70
leaq -0x11d5(%rip), %rdx     # 0x2920
callq 0x21b0
movq -0x2c8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x20c0
jmp 0x3cd5
leaq -0x2a8(%rbp), %rdi
xorl %esi, %esi
movl $0x20, %edx
callq 0x20b0
movq -0x2b0(%rbp), %rax
movq -0x248(%rbp), %rcx
movl 0x4(%rcx), %ecx
movq %rcx, -0x2a0(%rbp)
movq -0x2a0(%rbp), %rsi
movl 0x8(%rax), %r8d
movq -0x248(%rbp), %rax
movl 0x8(%rax), %eax
movl %eax, %r9d
xorl %eax, %eax
movl %eax, %edi
movl $0x3, %edx
movl $0x1, %ecx
callq 0x21d0
movq %rax, -0x2a8(%rbp)
movq $-0x1, %rax
cmpq %rax, -0x2a8(%rbp)
jne 0x3be0
movl $0x8, %edi
callq 0x2090
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x2d0(%rbp)
leaq 0x38a2(%rip), %rsi      # 0x7444
callq 0x28c0
jmp 0x3ba9
movq -0x2d0(%rbp), %rdi
leaq 0x71b9(%rip), %rsi      # 0xad70
leaq -0x129e(%rip), %rdx     # 0x2920
callq 0x21b0
movq -0x2d0(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x20c0
jmp 0x3cd5
movq -0x2b0(%rbp), %rax
movq -0x248(%rbp), %rcx
movl 0x44(%rcx), %ecx
movq %rcx, -0x290(%rbp)
movq -0x290(%rbp), %rsi
movl 0x8(%rax), %r8d
movq -0x248(%rbp), %rax
movl 0x48(%rax), %eax
movl %eax, %r9d
xorl %eax, %eax
movl %eax, %edi
movl $0x3, %edx
movl $0x1, %ecx
callq 0x21d0
movq %rax, -0x298(%rbp)
movq $-0x1, %rax
cmpq %rax, -0x298(%rbp)
jne 0x3c93
movl $0x8, %edi
callq 0x2090
movq %rax, %rdi
movq %rdi, %rax
movq %rax, -0x2d8(%rbp)
leaq 0x37fb(%rip), %rsi      # 0x7453
callq 0x28c0
jmp 0x3c5f
movq -0x2d8(%rbp), %rdi
leaq 0x7103(%rip), %rsi      # 0xad70
leaq -0x1354(%rip), %rdx     # 0x2920
callq 0x21b0
movq -0x2d8(%rbp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, -0x28(%rbp)
movl %eax, -0x2c(%rbp)
callq 0x20c0
jmp 0x3cd5
movq -0x2b0(%rbp), %rdi
addq $0x20, %rdi
leaq -0x2a8(%rbp), %rsi
callq 0x4f10
movq -0x2b0(%rbp), %rdi
addq $0x58, %rdi
leaq -0x30(%rbp), %rsi
callq 0x4f80
movl -0x30(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x30(%rbp)
jmp 0x3a42
addq $0x2e0, %rsp            # imm = 0x2E0
popq %rbp
retq
movq -0x28(%rbp), %rdi
callq 0x21c0
nop