// File: /workspace/github_c_makefile_star2_O0/STMicroelectronics[P]STMems_Android_Sensor_HAL_Input/StepDetectorSensor.cpp
// Function: StepDetectorSensor::readEvents(sensors_event_t*, int)
int StepDetectorSensor::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_STEP_D) {

#if (DEBUG_STEP_D == 1)
	STLOGD("StepDetectorSensor::readEvents (event_code=%d)", event->code);
#endif
			switch(event->code) {
			case EVENT_TYPE_STEP_D_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("StepDetectorSensor: unknown event code \
					(type = %d, code = %d)", event->type,
								event->code);
			}
		} else if (event->type == EV_SYN) {

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

		} else {
			STLOGE("StepDetectorSensor: 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 0x92bd
movl $0xffffffea, -0x4(%rbp) # imm = 0xFFFFFFEA
jmp 0x9408
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 0x92ed
movq -0x28(%rbp), %rax
movl %eax, -0x4(%rbp)
jmp 0x9408
movl $0x0, -0x2c(%rbp)
xorl %eax, %eax
cmpl $0x0, -0x1c(%rbp)
movb %al, -0x41(%rbp)
je 0x931d
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 0x9329
jmp 0x9402
movq -0x38(%rbp), %rax
movzwl 0x10(%rax), %eax
cmpl $0x4, %eax
jne 0x9395
movq -0x38(%rbp), %rax
movzwl 0x12(%rax), %eax
movl %eax, -0x48(%rbp)
testl %eax, %eax
je 0x935b
jmp 0x9347
movl -0x48(%rbp), %eax
subl $0x4, %eax
je 0x935d
jmp 0x9351
movl -0x48(%rbp), %eax
subl $0x7, %eax
je 0x9376
jmp 0x9391
jmp 0x9393
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
movslq 0x14(%rcx), %rcx
shlq $0x20, %rcx
movq %rcx, 0x10b8(%rax)
jmp 0x9393
movq -0x40(%rbp), %rax
movq -0x38(%rbp), %rcx
movl 0x14(%rcx), %ecx
orq 0x10b8(%rax), %rcx
movq %rcx, 0x10b8(%rax)
jmp 0x9393
jmp 0x9393
jmp 0x93ed
movq -0x38(%rbp), %rax
movzwl 0x10(%rax), %eax
cmpl $0x0, %eax
jne 0x93e9
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 0x93eb
jmp 0x93eb
jmp 0x93ed
movq -0x40(%rbp), %rdi
addq $0x1028, %rdi           # imm = 0x1028
callq 0x5220
jmp 0x92f4
movl -0x2c(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x50, %rsp
popq %rbp
retq
nopl (%rax)
nopw %cs:(%rax,%rax)
nop