// File: /workspace/github_c_makefile_star2_O0/STMicroelectronics[P]STMems_Android_Sensor_HAL_Input/SensorBase.cpp
// Function: SensorBase::writeSysfsCommand(int, char const*, char const*, long)
int SensorBase::writeSysfsCommand(int32_t handle,
				  const char *sysfsFilename,
				  const char *dataFormat, int64_t param)
{
	int fd;
	int err;
	char buf[8];
	const char *className;

	char formatstring1[50] = "%s Set %s to ";
	char formatstring2[100] = "%s Failed to set %s: ";

	switch(handle) {
#if (SENSORS_ACCELEROMETER_ENABLE == 1)
	case SENSORS_ACCELEROMETER_HANDLE:
	case SENSORS_SIGNIFICANT_MOTION_HANDLE:
		strcpy(&sysfs_device_path[sysfs_device_path_len],
		       sysfsFilename);
		className = "AccelSensor::Command()";
		break;
#endif
	default:
		return -1;
	}

	fd = open(sysfs_device_path, O_RDWR);
	sprintf(buf, dataFormat, param);
	err = write(fd, buf, sizeof(buf));
	close(fd);


	strcat(formatstring1, dataFormat);
	strcat(formatstring2, dataFormat);
	strcat(formatstring2, " - %s");

	if(err > 0) {
		STLOGI(formatstring1, className, sysfsFilename, param);
	} else {
		STLOGE(formatstring2, className, sysfsFilename, param,
		       sysfs_device_path);
	}

        return err > 0 ? 0 : -1;
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x100, %rsp            # imm = 0x100
movq %rdi, -0x10(%rbp)
movl %esi, -0x14(%rbp)
movq %rdx, -0x20(%rbp)
movq %rcx, -0x28(%rbp)
movq %r8, -0x30(%rbp)
movq -0x10(%rbp), %rax
movq %rax, -0x100(%rbp)
movaps 0x4310(%rip), %xmm0     # 0xa0d0
movaps %xmm0, -0x60(%rbp)
movaps 0x42f5(%rip), %xmm0     # 0xa0c0
movaps %xmm0, -0x70(%rbp)
movaps 0x42da(%rip), %xmm0     # 0xa0b0
movaps %xmm0, -0x80(%rbp)
movw $0x0, -0x50(%rbp)
movaps 0x4359(%rip), %xmm0     # 0xa140
movaps %xmm0, -0xa0(%rbp)
movaps 0x433b(%rip), %xmm0     # 0xa130
movaps %xmm0, -0xb0(%rbp)
movaps 0x431d(%rip), %xmm0     # 0xa120
movaps %xmm0, -0xc0(%rbp)
movaps 0x42ff(%rip), %xmm0     # 0xa110
movaps %xmm0, -0xd0(%rbp)
movaps 0x42e1(%rip), %xmm0     # 0xa100
movaps %xmm0, -0xe0(%rbp)
movaps 0x42c3(%rip), %xmm0     # 0xa0f0
movaps %xmm0, -0xf0(%rbp)
movl $0x0, -0x90(%rbp)
movl -0x14(%rbp), %eax
movl %eax, -0xf4(%rbp)
subl $0x1, %eax
je 0x5e5b
jmp 0x5e4e
movl -0xf4(%rbp), %eax
subl $0xe, %eax
jne 0x5e89
jmp 0x5e5b
movq -0x100(%rbp), %rax
movq %rax, %rdi
addq $0x18, %rdi
movslq 0x1018(%rax), %rax
addq %rax, %rdi
movq -0x20(%rbp), %rsi
callq 0x51f0
leaq 0x44d8(%rip), %rax      # 0xa35b
movq %rax, -0x48(%rbp)
jmp 0x5e95
movl $0xffffffff, -0x4(%rbp) # imm = 0xFFFFFFFF
jmp 0x5f2b
movq -0x100(%rbp), %rdi
addq $0x18, %rdi
movl $0x2, %esi
movb $0x0, %al
callq 0x5180
movl %eax, -0x34(%rbp)
leaq -0x40(%rbp), %rdi
movq -0x28(%rbp), %rsi
movq -0x30(%rbp), %rdx
movb $0x0, %al
callq 0x5090
movl -0x34(%rbp), %edi
leaq -0x40(%rbp), %rsi
movl $0x8, %edx
callq 0x50f0
movl %eax, -0x38(%rbp)
movl -0x34(%rbp), %edi
callq 0x5410
leaq -0x80(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x53e0
leaq -0xf0(%rbp), %rdi
movq -0x28(%rbp), %rsi
callq 0x53e0
leaq -0xf0(%rbp), %rdi
leaq 0x4469(%rip), %rsi      # 0xa372
callq 0x53e0
cmpl $0x0, -0x38(%rbp)
jle 0x5f16
jmp 0x5f18
jmp 0x5f18
movl -0x38(%rbp), %edx
movl $0xffffffff, %eax       # imm = 0xFFFFFFFF
xorl %ecx, %ecx
cmpl $0x0, %edx
cmovgl %ecx, %eax
movl %eax, -0x4(%rbp)
movl -0x4(%rbp), %eax
addq $0x100, %rsp            # imm = 0x100
popq %rbp
retq
nopw (%rax,%rax)