// File: /workspace/github_c_makefile_star2_O0/STMicroelectronics[P]STMems_Android_Sensor_HAL_Input/SignMotionSensor.cpp
// Function: SignMotionSensor::readEvents(sensors_event_t*, int)
int SignMotionSensor::readEvents(sensors_event_t* data, int count)
{
	if (count < 1)
		return -EINVAL;

	ssize_t n = mInputReader.fill(data_fd);
	if (n < 0)
		return n;

	int numEventReceived = 0;
	input_event const* event;

	while (count && mInputReader.readEvent(&event)) {

		if (event->type == EVENT_TYPE_SIGN_M) {

#if (DEBUG_SIGN_M == 1)
	STLOGD("SignMotionSensor::readEvents (event_code=%d)", event->code);
#endif
			switch(event->code) {
			case EVENT_TYPE_SIGN_M_DATA:

				break;
#if defined(INPUT_EVENT_HAS_TIMESTAMP)
			case EVENT_TYPE_TIME_MSB:
				timestamp = ((int64_t)(event->value)) << 32;

				break;
			case EVENT_TYPE_TIME_LSB:
				timestamp |= (uint32_t)(event->value);

				break;
#endif
			default:
				STLOGE("SignMotionSensor: unknown event code \
					(type = %d, code = %d)", event->type,
								event->code);
			}
		} else if (event->type == EV_SYN) {

			enable(SENSORS_SIGN_MOTION_HANDLE, 0, 0);
#if !defined(INPUT_EVENT_HAS_TIMESTAMP)
			timestamp = timevalToNano(event->time);
#endif
			mPendingEvent.timestamp = timestamp;
			memcpy(data, &mPendingEvent, sizeof(mPendingEvent));
			data++;
			count--;
			numEventReceived++;
#if (DEBUG_SIGN_M == 1)
			STLOGD("SignMotionSensor::readEvents (time = %lld), count(%d), received(%d)",
						mPendingEvent.timestamp,
						count, numEventReceived);
#endif

		} else {
			STLOGE("SignMotionSensor: unknown event (type=%d, code=%d)",
						event->type, event->code);
		}
		mInputReader.next();
	}

	return numEventReceived;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x50, %rsp
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movl %edx, -0x1c(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x40(%rbp)
cmpl $0x1, -0x1c(%rbp)
jge 0x8a3d
movl $0xffffffea, -0x4(%rbp) # imm = 0xFFFFFFEA
jmp 0x8b9b
movq -0x40(%rbp), %rax
movq %rax, %rdi
addq $0x1028, %rdi           # imm = 0x1028
movl 0x1020(%rax), %esi
callq 0x50a0
movq %rax, -0x28(%rbp)
cmpq $0x0, -0x28(%rbp)
jge 0x8a6d
movq -0x28(%rbp), %rax
movl %eax, -0x4(%rbp)
jmp 0x8b9b
movl $0x0, -0x2c(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x1c(%rbp)
movb %al, -0x41(%rbp)
je 0x8a9d
movq -0x40(%rbp), %rdi
addq $0x1028, %rdi           # imm = 0x1028
leaq -0x38(%rbp), %rsi
callq 0x52a0
cmpq $0x0, %rax
setne %al
movb %al, -0x41(%rbp)
movb -0x41(%rbp), %al
testb $0x1, %al
jne 0x8aa9
jmp 0x8b95
movq -0x38(%rbp), %rax
movzwl 0x10(%rax), %eax
cmpl $0x4, %eax
jne 0x8b15
movq -0x38(%rbp), %rax
movzwl 0x12(%rax), %eax
movl %eax, -0x48(%rbp)
testl %eax, %eax
je 0x8adb
jmp 0x8ac7
movl -0x48(%rbp), %eax
subl $0x4, %eax
je 0x8add
jmp 0x8ad1
movl -0x48(%rbp), %eax
subl $0x7, %eax
je 0x8af6
jmp 0x8b11
jmp 0x8b13
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
movslq 0x14(%rcx), %rcx
shlq $0x20, %rcx
movq %rcx, 0x10b8(%rax)
jmp 0x8b13
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
movl 0x14(%rcx), %ecx
orq 0x10b8(%rax), %rcx
movq %rcx, 0x10b8(%rax)
jmp 0x8b13
jmp 0x8b13
jmp 0x8b80
movq -0x38(%rbp), %rax
movzwl 0x10(%rax), %eax
cmpl $0x0, %eax
jne 0x8b7c
movq -0x40(%rbp), %rdi
movq (%rdi), %rax
movl $0x16, %esi
xorl %ecx, %ecx
movl %ecx, %edx
callq *0x30(%rax)
movq -0x40(%rbp), %rsi
movq 0x10b8(%rsi), %rax
movq %rax, 0x1060(%rsi)
movq -0x18(%rbp), %rdi
addq $0x1050, %rsi           # imm = 0x1050
movl $0x68, %edx
callq 0x51a0
movq -0x18(%rbp), %rax
addq $0x68, %rax
movq %rax, -0x18(%rbp)
movl -0x1c(%rbp), %eax
addl $-0x1, %eax
movl %eax, -0x1c(%rbp)
movl -0x2c(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x2c(%rbp)
jmp 0x8b7e
jmp 0x8b7e
jmp 0x8b80
movq -0x40(%rbp), %rdi
addq $0x1028, %rdi           # imm = 0x1028
callq 0x5220
jmp 0x8a74
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopw %cs:(%rax,%rax)
nop