// File: /workspace/github_c_makefile_star2_O1/STMicroelectronics[P]STMems_Android_Sensor_HAL_Input/SensorBase.cpp
// Function: SensorBase::getSysfsDevicePath(char*, char const*)
int SensorBase::getSysfsDevicePath(char* sysfs_path,
				   const char* inputDeviceName)
{
	int fd = -1;
	const char *dirname = "/dev/input";
	char devname[PATH_MAX];
	char *filename;
	DIR *dir;
	struct dirent *de;

	sysfs_path[0] ='\0';
	dir = opendir(dirname);

	if(dir == NULL)
		return -1;

	strcpy(devname, dirname);
	filename = devname + strlen(devname);
	*filename++ = '/';

	while((de = readdir(dir))) {
		if (de->d_name[0] == '.' && (de->d_name[1] == '\0' ||
		    (de->d_name[1] == '.' && de->d_name[2] == '\0')))
			continue;

		strcpy(filename, de->d_name);
		fd = open(devname, O_RDONLY);
		if (fd >= 0) {
			char name[80];
			if (ioctl(fd, EVIOCGNAME(sizeof(name) - 1),
				  &name) < 1)
				name[0] = '\0';

			if (!strcmp(name, inputDeviceName)) {
				strcpy(sysfs_path,"/sys/class/input/");
				strcat(sysfs_path,filename);
				strcat(sysfs_path,"/device/");

				break;
			} else {
				close(fd);
				fd = -1;
			}
		}
	}

	closedir(dir);
	STLOGE_IF(fd < 0, "couldn't find sysfs path for device '%s' ",
		  inputDeviceName);

	return fd;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x1068, %rsp           # imm = 0x1068
movq %rdx, %r14
movq %rsi, %r15
movb $0x0, (%rsi)
leaq 0x29e0(%rip), %rdi      # 0x8031
callq 0x5350
testq %rax, %rax
je 0x5780
movq %rax, %rbx
movabsq $0x706e692f7665642f, %rax # imm = 0x706E692F7665642F
leaq 0x60(%rsp), %rdi
movq %rax, (%rdi)
movl $0x747570, 0x7(%rdi)    # imm = 0x747570
callq 0x5110
movq %rax, %r12
movb $0x2f, 0x60(%rsp,%rax)
movq %rbx, %rdi
callq 0x5370
testq %rax, %rax
je 0x5787
movq %r14, 0x8(%rsp)
addq %rsp, %r12
addq $0x61, %r12
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
leaq 0x60(%rsp), %r14
cmpb $0x2e, 0x13(%rax)
jne 0x56da
movzbl 0x14(%rax), %ecx
testl %ecx, %ecx
je 0x56c8
cmpl $0x2e, %ecx
jne 0x56da
cmpb $0x0, 0x15(%rax)
jne 0x56da
movq %rbx, %rdi
callq 0x5370
testq %rax, %rax
jne 0x56af
jmp 0x578c
addq $0x13, %rax
movq %r12, %rdi
movq %rax, %rsi
callq 0x51e0
movq %r14, %rdi
xorl %esi, %esi
xorl %eax, %eax
callq 0x5170
movl %eax, %ebp
testl %eax, %eax
js 0x56c8
movl $0x804f4506, %esi       # imm = 0x804F4506
movl %ebp, %edi
leaq 0x10(%rsp), %r13
movq %r13, %rdx
xorl %eax, %eax
callq 0x52d0
testl %eax, %eax
jg 0x571a
movb $0x0, 0x10(%rsp)
movq %r13, %rdi
movq 0x8(%rsp), %rsi
callq 0x52c0
movl %eax, %r13d
testl %eax, %eax
je 0x573c
movl %ebp, %edi
callq 0x5400
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x5775
movups 0x28f9(%rip), %xmm0     # 0x803c
movups %xmm0, (%r15)
movw $0x2f, 0x10(%r15)
movq %r15, %rdi
movq %r12, %rsi
callq 0x53d0
movq %r15, %rdi
callq 0x5110
movabsq $0x2f6563697665642f, %rcx # imm = 0x2F6563697665642F
movq %rcx, (%r15,%rax)
movb $0x0, 0x8(%r15,%rax)
testl %r13d, %r13d
jne 0x56c8
jmp 0x578c
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
jmp 0x5794
movl $0xffffffff, %ebp       # imm = 0xFFFFFFFF
movq %rbx, %rdi
callq 0x5390
movl %ebp, %eax
addq $0x1068, %rsp           # imm = 0x1068
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq