// File: /workspace/github_cpp_makefile_star2_O3/merelin[P]mediasmartserverd/src/mediasmartserverd.cpp
// Function: GetUdevDeviceAttribute(char const*, char const*, char const*)
const char *GetUdevDeviceAttribute(const char *subsystem, const char *sysname, const char *sysattr) {
	struct udev *udev;
	struct udev_device *device;
	std::string value;

	udev = udev_new();
	if (!udev) throw ErrnoException("udev_new");

	device = udev_device_new_from_subsystem_sysname(udev, subsystem, sysname);
	value = udev_device_get_sysattr_value(device, sysattr);
	value.erase(value.begin(), std::find_if(value.begin(), value.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
	value.erase(std::find_if(value.rbegin(), value.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), value.end());
	//free
	udev_device_unref(device);
	udev_unref(udev);
	
	return strdup(value.c_str());
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x58, %rsp
movq %rdx, %r15
movq %rsi, %r14
movq %rdi, %r12
leaq 0x18(%rsp), %rbp
movq %rbp, -0x10(%rbp)
movq $0x0, -0x8(%rbp)
movb $0x0, (%rbp)
callq 0x4380
movq %rax, %rbx
testq %rax, %rax
je 0x6d1c
movq %rbx, %rdi
movq %r12, %rsi
movq %r14, %rdx
callq 0x4420
movq %rax, %r14
movq %rax, %rdi
movq %r15, %rsi
callq 0x43d0
movq %rax, %r15
leaq 0x8(%rsp), %r12
movq 0x8(%r12), %r13
movq %rax, %rdi
callq 0x4130
movq %r12, %rdi
xorl %esi, %esi
movq %r13, %rdx
movq %r15, %rcx
movq %rax, %r8
callq 0x4480
movq 0x8(%rsp), %r15
movq 0x10(%rsp), %rsi
addq %r15, %rsi
movq 0x9321(%rip), %rdx      # 0xff78
movq %r15, %rdi
callq 0xa78e
movq 0x8(%rsp), %rcx
movq %r15, %rsi
subq %rcx, %rsi
movq 0x10(%rsp), %rdx
addq %rcx, %rdx
cmpq %rax, %rdx
je 0x6c89
subq %r15, %rax
leaq 0x8(%rsp), %rdi
movq %rax, %rdx
callq 0x4330
jmp 0x6c92
movq %rsi, 0x10(%rsp)
movb $0x0, (%rcx,%rsi)
movq 0x8(%rsp), %rax
movq 0x10(%rsp), %rcx
addq %rax, %rcx
leaq 0x30(%rsp), %rsi
movq %rcx, (%rsi)
leaq 0x50(%rsp), %rdx
movq %rax, (%rdx)
movq 0x92c2(%rip), %rcx      # 0xff78
leaq 0x28(%rsp), %rdi
callq 0xa85f
movq 0x28(%rsp), %rax
movq %rax, %rcx
subq 0x8(%rsp), %rcx
movq %rcx, 0x10(%rsp)
movb $0x0, (%rax)
movq %r14, %rdi
callq 0x4620
movq %rbx, %rdi
callq 0x4360
movq 0x8(%rsp), %rbx
movq %rbx, %rdi
callq 0x45b0
movq %rax, %r14
cmpq %rbp, %rbx
je 0x6d0a
movq 0x18(%rsp), %rsi
incq %rsi
movq %rbx, %rdi
callq 0x42c0
movq %r14, %rax
addq $0x58, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movl $0x10, %edi
callq 0x4140
movq %rax, %rbx
leaq 0x40(%rsp), %r15
movq %r15, -0x10(%r15)
leaq 0x42cb(%rip), %rsi      # 0xb004
leaq 0x42cc(%rip), %rdx      # 0xb00c
leaq 0x30(%rsp), %rdi
callq 0x5e90
callq 0x4030
movl (%rax), %edx
movb $0x1, %r12b
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0x5be6
xorl %r12d, %r12d
leaq 0x8a15(%rip), %rsi      # 0xf780
movq 0x922e(%rip), %rdx      # 0xffa0
movq %rbx, %rdi
callq 0x4520
movq %rax, %r14
movq 0x30(%rsp), %rdi
cmpq %r15, %rdi
je 0x6d94
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x42c0
testb %r12b, %r12b
jne 0x6d9e
jmp 0x6daf
movq %rax, %r14
movq %rbx, %rdi
callq 0x41e0
jmp 0x6daf
jmp 0x6dac
jmp 0x6dac
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x6dc6
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42c0
movq %r14, %rdi
callq 0x4550