// File: /workspace/github_c_makefile_star2_O0/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
movq %rsp, %rbp
subq $0x10b0, %rsp           # imm = 0x10B0
movq %rdi, -0x10(%rbp)
movq %rsi, -0x18(%rbp)
movq %rdx, -0x20(%rbp)
movl $0xffffffff, -0x24(%rbp) # imm = 0xFFFFFFFF
leaq 0x49fc(%rip), %rax      # 0xa181
movq %rax, -0x30(%rbp)
movq -0x18(%rbp), %rax
movb $0x0, (%rax)
movq -0x30(%rbp), %rdi
callq 0x5370
movq %rax, -0x1040(%rbp)
cmpq $0x0, -0x1040(%rbp)
jne 0x57b6
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x592c
leaq -0x1030(%rbp), %rdi
movq -0x30(%rbp), %rsi
callq 0x51f0
leaq -0x1030(%rbp), %rax
movq %rax, -0x10a8(%rbp)
leaq -0x1030(%rbp), %rdi
callq 0x5110
movq %rax, %rcx
movq -0x10a8(%rbp), %rax
addq %rcx, %rax
movq %rax, -0x1038(%rbp)
movq -0x1038(%rbp), %rax
movq %rax, %rcx
addq $0x1, %rcx
movq %rcx, -0x1038(%rbp)
movb $0x2f, (%rax)
movq -0x1040(%rbp), %rdi
callq 0x5390
movq %rax, -0x1048(%rbp)
cmpq $0x0, %rax
je 0x591a
movq -0x1048(%rbp), %rax
movsbl 0x13(%rax), %eax
cmpl $0x2e, %eax
jne 0x586b
movq -0x1048(%rbp), %rax
movsbl 0x14(%rax), %eax
cmpl $0x0, %eax
je 0x5869
movq -0x1048(%rbp), %rax
movsbl 0x14(%rax), %eax
cmpl $0x2e, %eax
jne 0x586b
movq -0x1048(%rbp), %rax
movsbl 0x15(%rax), %eax
cmpl $0x0, %eax
jne 0x586b
jmp 0x580c
movq -0x1038(%rbp), %rdi
movq -0x1048(%rbp), %rsi
addq $0x13, %rsi
callq 0x51f0
leaq -0x1030(%rbp), %rdi
xorl %esi, %esi
movb $0x0, %al
callq 0x5180
movl %eax, -0x24(%rbp)
cmpl $0x0, -0x24(%rbp)
jl 0x5915
movl -0x24(%rbp), %edi
movl $0x804f4506, %esi       # imm = 0x804F4506
leaq -0x10a0(%rbp), %rdx
movb $0x0, %al
callq 0x52e0
cmpl $0x1, %eax
jge 0x58bd
movb $0x0, -0x10a0(%rbp)
leaq -0x10a0(%rbp), %rdi
movq -0x20(%rbp), %rsi
callq 0x52d0
cmpl $0x0, %eax
jne 0x5904
movq -0x18(%rbp), %rdi
leaq 0x48af(%rip), %rsi      # 0xa18c
callq 0x51f0
movq -0x18(%rbp), %rdi
movq -0x1038(%rbp), %rsi
callq 0x53e0
movq -0x18(%rbp), %rdi
leaq 0x48a1(%rip), %rsi      # 0xa19e
callq 0x53e0
jmp 0x591a
movl -0x24(%rbp), %edi
callq 0x5410
movl $0xffffffff, -0x24(%rbp) # imm = 0xFFFFFFFF
jmp 0x5915
jmp 0x580c
movq -0x1040(%rbp), %rdi
callq 0x53b0
movl -0x24(%rbp), %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x10b0, %rsp           # imm = 0x10B0
popq %rbp
retq
nopl (%rax,%rax)