// File: /workspace/github_cpp_makefile_star2_O1/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 0x6d1b
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 0x9322(%rip), %rdx      # 0xff78
movq %r15, %rdi
callq 0xa7cc
movq 0x8(%rsp), %rcx
movq %r15, %rsi
subq %rcx, %rsi
movq 0x10(%rsp), %rdx
addq %rcx, %rdx
cmpq %rax, %rdx
je 0x6c88
subq %r15, %rax
leaq 0x8(%rsp), %rdi
movq %rax, %rdx
callq 0x4330
jmp 0x6c91
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 0x92c3(%rip), %rcx      # 0xff78
leaq 0x28(%rsp), %rdi
callq 0xa892
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 0x6d09
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), %r12
movq %r12, -0x10(%r12)
leaq 0x42cb(%rip), %rsi      # 0xb004
leaq 0x42cc(%rip), %rdx      # 0xb00c
leaq 0x30(%rsp), %rdi
callq 0x5e88
callq 0x4030
movl (%rax), %edx
movb $0x1, %r15b
leaq 0x30(%rsp), %rsi
movq %rbx, %rdi
callq 0x5be8
xorl %r15d, %r15d
leaq 0x8985(%rip), %rsi      # 0xf6f0
movq 0x922e(%rip), %rdx      # 0xffa0
movq %rbx, %rdi
callq 0x4520
movq %rax, %r14
movq 0x30(%rsp), %rdi
cmpq %r12, %rdi
je 0x6d9c
movq 0x40(%rsp), %rsi
incq %rsi
callq 0x42c0
jmp 0x6d9c
movq %rax, %r14
movb $0x1, %r15b
testb %r15b, %r15b
je 0x6db2
movq %rbx, %rdi
callq 0x41e0
jmp 0x6db2
jmp 0x6daf
jmp 0x6daf
movq %rax, %r14
movq 0x8(%rsp), %rdi
cmpq %rbp, %rdi
je 0x6dc9
movq 0x18(%rsp), %rsi
incq %rsi
callq 0x42c0
movq %r14, %rdi
callq 0x4550